From: Foster B. <fos...@us...> - 2006-02-03 18:34:24
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe/future/widgets/sources/mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6755/adobe/future/widgets/sources/mac Modified Files: display.cpp metrics.cpp ui_core_implementation.cpp ui_overlay.cpp Added Files: os_utilities.cpp Log Message: asl 1.0.13 Index: display.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/future/widgets/sources/mac/display.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** display.cpp 24 Jan 2006 19:38:47 -0000 1.4 --- display.cpp 3 Feb 2006 18:33:37 -0000 1.5 *************** *** 1,6 **** /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ --- 1,6 ---- /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ *************** *** 20,28 **** struct view_wrap { ! explicit view_wrap(HIViewRef ref) : ! ref_m(ref) ! { } ! HIViewRef ref_m; }; --- 20,28 ---- struct view_wrap { ! explicit view_wrap(HIViewRef ref) : ! ref_m(ref) ! { } ! HIViewRef ref_m; }; *************** *** 31,35 **** HIViewRef unwrap(adobe::display_t::position_t& position) { ! return (boost::any_cast<view_wrap>(position)).ref_m; } --- 31,35 ---- HIViewRef unwrap(adobe::display_t::position_t& position) { ! return (boost::any_cast<view_wrap>(position)).ref_m; } *************** *** 38,42 **** adobe::display_t::position_t wrap(HIViewRef view) { ! return adobe::display_t::position_t(view_wrap(view)); } --- 38,42 ---- adobe::display_t::position_t wrap(HIViewRef view) { ! return adobe::display_t::position_t(view_wrap(view)); } *************** *** 48,52 **** #if 0 ! #pragma mark - #endif --- 48,52 ---- #if 0 ! #pragma mark - #endif *************** *** 63,69 **** display_t& get_main_display() { ! static display_t display_s; ! return display_s; } --- 63,69 ---- display_t& get_main_display() { ! static display_t display_s; ! return display_s; } *************** *** 72,78 **** struct display_t::implementation_t { ! void erase(display_t::position_t& position); ! std::vector<HIViewRef> roots_m; }; --- 72,78 ---- struct display_t::implementation_t { ! void erase(display_t::position_t& position); ! std::vector<HIViewRef> roots_m; }; *************** *** 92,96 **** #if 0 ! #pragma mark - #endif --- 92,96 ---- #if 0 ! #pragma mark - #endif *************** *** 98,122 **** display_t::display_t() : ! object_m(new implementation_t()) ! { } display_t::~display_t() ! { delete object_m; object_m = 0; } display_t::implementation_t& display_t::implementation() ! { return *object_m; } const display_t::implementation_t& display_t::implementation() const ! { return *object_m; } display_t::position_t display_t::root() ! { return display_t::position_t(root_token()); } void display_t::erase(position_t& position) ! { return object_m->erase(position); } template <typename DisplayElement> display_t::position_t display_t::insert(position_t& parent, DisplayElement& element) ! { return insert(parent, adobe::view_for_element<HIViewRef>(element)); } /****************************************************************************************************/ --- 98,122 ---- display_t::display_t() : ! object_m(new implementation_t()) ! { } display_t::~display_t() ! { delete object_m; object_m = 0; } display_t::implementation_t& display_t::implementation() ! { return *object_m; } const display_t::implementation_t& display_t::implementation() const ! { return *object_m; } display_t::position_t display_t::root() ! { return display_t::position_t(root_token()); } void display_t::erase(position_t& position) ! { return object_m->erase(position); } template <typename DisplayElement> display_t::position_t display_t::insert(position_t& parent, DisplayElement& element) ! { return insert(parent, adobe::view_for_element<HIViewRef>(element)); } /****************************************************************************************************/ *************** *** 125,140 **** display_t::position_t display_t::insert<HIViewRef>(position_t& parent, HIViewRef& element) { ! if (parent.type() == typeid(view_wrap)) ! { ! HIViewRef parent_view(unwrap(parent)); ! ADOBE_REQUIRE_STATUS(::HIViewAddSubview(parent_view, element)); ! } ! else if (parent.type() == typeid(root_token)) ! { ! object_m->roots_m.push_back(element); ! } ! return wrap(element); } --- 125,140 ---- display_t::position_t display_t::insert<HIViewRef>(position_t& parent, HIViewRef& element) { ! if (parent.type() == typeid(view_wrap)) ! { ! HIViewRef parent_view(unwrap(parent)); ! ADOBE_REQUIRE_STATUS(::HIViewAddSubview(parent_view, element)); ! } ! else if (parent.type() == typeid(root_token)) ! { ! object_m->roots_m.push_back(element); ! } ! return wrap(element); } *************** *** 142,146 **** #if 0 ! #pragma mark - #endif --- 142,146 ---- #if 0 ! #pragma mark - #endif *************** *** 149,158 **** void display_t::implementation_t::erase(display_t::position_t&) { ! // REVISIT (fbrereto) : What should we do here? ! // 1) Call DetachSubView on the position? ! // 2) Call erase recursively for all children of the position? ! // 3) Invalidate (wipe) the position data? ! // 4) Invoke some (currently nonexistent) detach() callback for the client? ! // 4a) With what parameters, considering questions 1, 2, & 3? } --- 149,158 ---- void display_t::implementation_t::erase(display_t::position_t&) { ! // REVISIT (fbrereto) : What should we do here? ! // 1) Call DetachSubView on the position? ! // 2) Call erase recursively for all children of the position? ! // 3) Invalidate (wipe) the position data? ! // 4) Invoke some (currently nonexistent) detach() callback for the client? ! // 4a) With what parameters, considering questions 1, 2, & 3? } Index: metrics.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/future/widgets/sources/mac/metrics.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** metrics.cpp 6 Jan 2006 18:02:59 -0000 1.5 --- metrics.cpp 3 Feb 2006 18:33:37 -0000 1.6 *************** *** 1,6 **** /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ --- 1,6 ---- /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ *************** *** 26,63 **** adobe::dictionary_t widget_metrics(const std::string& xstr, const adobe::dictionary_t& context) { ! std::vector<adobe::attribute_set_t::value_type> context_attribute_set; ! if (!context.count(adobe::static_name_t("theme"))) ! context_attribute_set.push_back(std::make_pair(adobe::static_token_range("theme"), adobe::static_token_range("normal"))); ! for ( dictionary_t::const_iterator first(context.begin()), last(context.end()); ! first != last; ++first) ! { ! const char* key_c_str(first->first.get()); ! const char* value_c_str(first->second.get<adobe::name_t>().get()); ! adobe::token_range_t key(key_c_str, key_c_str + std::strlen(key_c_str)); ! adobe::token_range_t value(value_c_str, value_c_str + std::strlen(value_c_str)); ! context_attribute_set.push_back(std::make_pair(key, value)); ! } ! adobe::xstring_context_t local_context(context_attribute_set.begin(), context_attribute_set.end()); ! std::string utf8(adobe::xstring(xstr.c_str(), xstr.size())); ! if (utf8.empty()) return adobe::dictionary_t(); ! std::stringstream expression_stream(utf8); ! expression_parser parser(expression_stream, line_position_t("widget_metrics")); ! array_t expression; ! parser.require_expression(expression); ! virtual_machine_t machine; ! machine.evaluate(expression); ! return machine.back().value_m.get<adobe::dictionary_t>(); } --- 26,63 ---- adobe::dictionary_t widget_metrics(const std::string& xstr, const adobe::dictionary_t& context) { ! std::vector<adobe::attribute_set_t::value_type> context_attribute_set; ! if (!context.count(adobe::static_name_t("theme"))) ! context_attribute_set.push_back(std::make_pair(adobe::static_token_range("theme"), adobe::static_token_range("normal"))); ! for ( dictionary_t::const_iterator first(context.begin()), last(context.end()); ! first != last; ++first) ! { ! const char* key_c_str(first->first.get()); ! const char* value_c_str(first->second.get<adobe::name_t>().get()); ! adobe::token_range_t key(key_c_str, key_c_str + std::strlen(key_c_str)); ! adobe::token_range_t value(value_c_str, value_c_str + std::strlen(value_c_str)); ! context_attribute_set.push_back(std::make_pair(key, value)); ! } ! adobe::xstring_context_t local_context(context_attribute_set.begin(), context_attribute_set.end()); ! std::string utf8(adobe::xstring(xstr.c_str(), xstr.size())); ! if (utf8.empty()) return adobe::dictionary_t(); ! std::stringstream expression_stream(utf8); ! expression_parser parser(expression_stream, line_position_t("widget_metrics")); ! array_t expression; ! parser.require_expression(expression); ! virtual_machine_t machine; ! machine.evaluate(expression); ! return machine.back().value_m.get<adobe::dictionary_t>(); } Index: ui_overlay.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/future/widgets/sources/mac/ui_overlay.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ui_overlay.cpp 24 Jan 2006 19:38:47 -0000 1.5 --- ui_overlay.cpp 3 Feb 2006 18:33:37 -0000 1.6 *************** *** 1,6 **** /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ --- 1,6 ---- /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ *************** *** 24,34 **** struct overlay_data_t { ! adobe::point_2d_t origin_m; ! adobe::extents_t extents_m; }; /****************************************************************************************************/ ! typedef adobe::forest<overlay_data_t> overlay_forest_t; /****************************************************************************************************/ --- 24,34 ---- struct overlay_data_t { ! adobe::point_2d_t origin_m; ! adobe::extents_t extents_m; }; /****************************************************************************************************/ ! typedef adobe::forest<overlay_data_t> overlay_forest_t; /****************************************************************************************************/ *************** *** 36,40 **** overlay_forest_t::iterator unwrap(adobe::ui_overlay_t::position_t& position) { ! return boost::any_cast<overlay_forest_t::iterator>(position); } --- 36,40 ---- overlay_forest_t::iterator unwrap(adobe::ui_overlay_t::position_t& position) { ! return boost::any_cast<overlay_forest_t::iterator>(position); } *************** *** 43,47 **** adobe::ui_overlay_t::position_t wrap(overlay_forest_t::iterator view) { ! return adobe::ui_overlay_t::position_t(view); } --- 43,47 ---- adobe::ui_overlay_t::position_t wrap(overlay_forest_t::iterator view) { ! return adobe::ui_overlay_t::position_t(view); } *************** *** 58,114 **** struct ui_overlay_t::implementation_t { ! implementation_t(); ! ~implementation_t(); ! struct draw_element_t ! { ! enum element_type ! { ! element_type_top_left, ! element_type_top_right, ! element_type_bottom_left, ! element_type_bottom_right, ! element_type_horizontal_poi, ! element_type_vertical_poi, ! element_type_count // always be last ! }; ! draw_element_t(element_type type, const CGRect& rect, const RGBColor& color) : ! type_m(type), rect_m(rect), color_m(color) ! { } ! draw_element_t(const draw_element_t& rhs) : ! type_m(rhs.type_m), rect_m(rhs.rect_m), color_m(rhs.color_m) ! { } ! element_type type_m; ! CGRect rect_m; ! RGBColor color_m; ! }; ! typedef std::vector<draw_element_t> draw_element_set_t; ! position_t root(HIViewRef& element); ! position_t insert(position_t parent); ! void place(position_t node, const point_2d_t& origin, const extents_t& extents); ! void framing(bool do_framing); ! overlay_data_t flatten_overlay_data(overlay_forest_t::iterator iter); ! void tick_extents(const overlay_data_t& overlay_data, draw_element_set_t& set); ! void overlay_bounds_update(); ! void draw_tick(CGContextRef context, const draw_element_set_t::value_type& element); ! WindowRef overlay_m; ! WindowRef source_m; ! ControlRef control_m; ! bool framing_m; ! overlay_forest_t tree_m; }; --- 58,114 ---- struct ui_overlay_t::implementation_t { ! implementation_t(); ! ~implementation_t(); ! struct draw_element_t ! { ! enum element_type ! { ! element_type_top_left, ! element_type_top_right, ! element_type_bottom_left, ! element_type_bottom_right, ! element_type_horizontal_poi, ! element_type_vertical_poi, ! element_type_count // always be last ! }; ! draw_element_t(element_type type, const CGRect& rect, const RGBColor& color) : ! type_m(type), rect_m(rect), color_m(color) ! { } ! draw_element_t(const draw_element_t& rhs) : ! type_m(rhs.type_m), rect_m(rhs.rect_m), color_m(rhs.color_m) ! { } ! element_type type_m; ! CGRect rect_m; ! RGBColor color_m; ! }; ! typedef std::vector<draw_element_t> draw_element_set_t; ! position_t root(HIViewRef& element); ! position_t insert(position_t parent); ! void place(position_t node, const point_2d_t& origin, const extents_t& extents); ! void framing(bool do_framing); ! overlay_data_t flatten_overlay_data(overlay_forest_t::iterator iter); ! void tick_extents(const overlay_data_t& overlay_data, draw_element_set_t& set); ! void overlay_bounds_update(); ! void draw_tick(CGContextRef context, const draw_element_set_t::value_type& element); ! WindowRef overlay_m; ! WindowRef source_m; ! ControlRef control_m; ! bool framing_m; ! overlay_forest_t tree_m; }; *************** *** 125,139 **** pascal void draw_overlay(ControlRef control, SInt16) { ! adobe::ui_overlay_t::implementation_t& overlay ! (*reinterpret_cast<adobe::ui_overlay_t::implementation_t*> ! (::GetControlReference(control))); ! overlay.framing(overlay.framing_m); } /****************************************************************************************************/ ! typedef adobe::point_2d<float> coord_t; ! typedef std::vector<coord_t> coord_set_t; /****************************************************************************************************/ --- 125,139 ---- pascal void draw_overlay(ControlRef control, SInt16) { ! adobe::ui_overlay_t::implementation_t& overlay ! (*reinterpret_cast<adobe::ui_overlay_t::implementation_t*> ! (::GetControlReference(control))); ! overlay.framing(overlay.framing_m); } /****************************************************************************************************/ ! typedef adobe::point_2d<float> coord_t; ! typedef std::vector<coord_t> coord_set_t; /****************************************************************************************************/ *************** *** 141,157 **** void draw_line_path(CGContextRef context, coord_set_t& coord_set) { ! if (coord_set.size() < 2) return; ! coord_set_t::iterator iter(coord_set.begin()); ! coord_set_t::iterator last(coord_set.end()); ! ::CGContextMoveToPoint(context, iter->x_m, iter->y_m); ! while (++iter != last) ::CGContextAddLineToPoint(context, iter->x_m, iter->y_m); ! ::CGContextStrokePath(context); ! ::CGContextClosePath(context); ! coord_set.clear(); } --- 141,157 ---- void draw_line_path(CGContextRef context, coord_set_t& coord_set) { ! if (coord_set.size() < 2) return; ! coord_set_t::iterator iter(coord_set.begin()); ! coord_set_t::iterator last(coord_set.end()); ! ::CGContextMoveToPoint(context, iter->x_m, iter->y_m); ! while (++iter != last) ::CGContextAddLineToPoint(context, iter->x_m, iter->y_m); ! ::CGContextStrokePath(context); ! ::CGContextClosePath(context); ! coord_set.clear(); } *************** *** 167,171 **** ui_overlay_t::ui_overlay_t() : ! object_m(new implementation_t()) { } --- 167,171 ---- ui_overlay_t::ui_overlay_t() : ! object_m(new implementation_t()) { } *************** *** 199,203 **** #if 0 ! #pragma mark - #endif --- 199,203 ---- #if 0 ! #pragma mark - #endif *************** *** 205,212 **** ui_overlay_t::implementation_t::implementation_t() : ! overlay_m(0), ! source_m(0), ! control_m(0), ! framing_m(false) { } --- 205,212 ---- ui_overlay_t::implementation_t::implementation_t() : ! overlay_m(0), ! source_m(0), ! control_m(0), ! framing_m(false) { } *************** *** 215,221 **** ui_overlay_t::implementation_t::~implementation_t() { ! if (overlay_m) ::DisposeWindow(overlay_m); ! overlay_m = 0; } --- 215,221 ---- ui_overlay_t::implementation_t::~implementation_t() { ! if (overlay_m) ::DisposeWindow(overlay_m); ! overlay_m = 0; } *************** *** 224,255 **** ui_overlay_t::position_t ui_overlay_t::implementation_t::root(HIViewRef& element) { ! assert(!control_m); ! assert(element); ! Rect global_bounds; ! WindowGroupRef new_group; ! Rect one_bounds = { 0, 0, 1, 1 }; ! WindowRef owner(::GetControlOwner(element)); ! static ControlUserPaneDrawUPP draw_handler(::NewControlUserPaneDrawUPP(draw_overlay)); ! source_m = owner; ! ADOBE_REQUIRE_STATUS(::GetWindowBounds(source_m, kWindowGlobalPortRgn, &global_bounds)); ! ADOBE_REQUIRE_STATUS(::CreateNewWindow(kOverlayWindowClass, kWindowCompositingAttribute, &global_bounds, &overlay_m)); ! ADOBE_REQUIRE_STATUS(::CreateUserPaneControl(overlay_m, &one_bounds, 0, &control_m)); ! ::ShowWindow(overlay_m); ! ::SetControlReference(control_m, reinterpret_cast<SInt32>(this)); ! ::SetControlData(control_m, kControlEntireControl, kControlUserPaneDrawProcTag, sizeof(ControlUserPaneDrawUPP), &draw_handler); ! ADOBE_REQUIRE_STATUS(::CreateWindowGroup(kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether, &new_group)); ! ADOBE_REQUIRE_STATUS(::SetWindowGroupParent(new_group, ::GetWindowGroup(source_m))); ! ADOBE_REQUIRE_STATUS(::SetWindowGroup(source_m, new_group)); ! ADOBE_REQUIRE_STATUS(::SetWindowGroup(overlay_m, new_group)); ! return wrap(tree_m.insert(tree_m.begin(), overlay_data_t())); } --- 224,255 ---- ui_overlay_t::position_t ui_overlay_t::implementation_t::root(HIViewRef& element) { ! assert(!control_m); ! assert(element); ! Rect global_bounds; ! WindowGroupRef new_group; ! Rect one_bounds = { 0, 0, 1, 1 }; ! WindowRef owner(::GetControlOwner(element)); ! static ControlUserPaneDrawUPP draw_handler(::NewControlUserPaneDrawUPP(draw_overlay)); ! source_m = owner; ! ADOBE_REQUIRE_STATUS(::GetWindowBounds(source_m, kWindowGlobalPortRgn, &global_bounds)); ! ADOBE_REQUIRE_STATUS(::CreateNewWindow(kOverlayWindowClass, kWindowCompositingAttribute, &global_bounds, &overlay_m)); ! ADOBE_REQUIRE_STATUS(::CreateUserPaneControl(overlay_m, &one_bounds, 0, &control_m)); ! ::ShowWindow(overlay_m); ! ::SetControlReference(control_m, reinterpret_cast<SInt32>(this)); ! ::SetControlData(control_m, kControlEntireControl, kControlUserPaneDrawProcTag, sizeof(ControlUserPaneDrawUPP), &draw_handler); ! ADOBE_REQUIRE_STATUS(::CreateWindowGroup(kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether, &new_group)); ! ADOBE_REQUIRE_STATUS(::SetWindowGroupParent(new_group, ::GetWindowGroup(source_m))); ! ADOBE_REQUIRE_STATUS(::SetWindowGroup(source_m, new_group)); ! ADOBE_REQUIRE_STATUS(::SetWindowGroup(overlay_m, new_group)); ! return wrap(tree_m.insert(tree_m.begin(), overlay_data_t())); } *************** *** 258,262 **** ui_overlay_t::position_t ui_overlay_t::implementation_t::insert(position_t parent) { ! return wrap(tree_m.insert(adobe::trailing_of(unwrap(parent)), overlay_data_t())); } --- 258,262 ---- ui_overlay_t::position_t ui_overlay_t::implementation_t::insert(position_t parent) { ! return wrap(tree_m.insert(adobe::trailing_of(unwrap(parent)), overlay_data_t())); } *************** *** 265,277 **** void ui_overlay_t::implementation_t::place(position_t node, const point_2d_t& origin, const extents_t& extents) { ! assert(control_m); ! overlay_forest_t::iterator position(unwrap(node)); ! position->origin_m = origin; ! position->extents_m = extents; ! if (framing_m) ! ADOBE_REQUIRE_STATUS(::HIViewSetNeedsDisplay(control_m, true)); } --- 265,277 ---- void ui_overlay_t::implementation_t::place(position_t node, const point_2d_t& origin, const extents_t& extents) { ! assert(control_m); ! overlay_forest_t::iterator position(unwrap(node)); ! position->origin_m = origin; ! position->extents_m = extents; ! if (framing_m) ! ADOBE_REQUIRE_STATUS(::HIViewSetNeedsDisplay(control_m, true)); } *************** *** 280,330 **** void ui_overlay_t::implementation_t::framing(bool do_framing) { ! assert(control_m); ! framing_m = do_framing; ! if (do_framing) ! { ! ::ShowWindow(overlay_m); ! draw_element_set_t tick_set; ! overlay_forest_t::preorder_iterator first(tree_m.begin()); ! overlay_forest_t::preorder_iterator last(tree_m.end()); ! for (; first != last; ++first) ! tick_extents(flatten_overlay_data(first.base()), tick_set); ! if (!tick_set.empty()) ! { ! CGrafPtr window_port(::GetWindowPort(overlay_m)); ! CGContextRef context(0); ! Rect bounds; ! overlay_bounds_update(); ! ::GetWindowBounds(overlay_m, kWindowContentRgn, &bounds); ! ADOBE_REQUIRE_STATUS(::QDBeginCGContext(window_port, &context)); ! ::CGContextTranslateCTM(context, 0.0, static_cast<float>(bounds.bottom - bounds.top)); ! ::CGContextScaleCTM(context, 1.0, -1.0); ! ::CGContextSetLineWidth(context, 1); ! ::CGContextSetShouldAntialias(context, false); ! ::CGContextSetAlpha(context, .75f); ! ::CGContextBeginPath(context); ! adobe::for_each(tick_set, boost::bind(&implementation_t::draw_tick, boost::ref(*this), context, _1)); ! ::CGContextFlush(context); ! ADOBE_REQUIRE_STATUS(::QDEndCGContext(window_port, &context)); ! } ! } ! else ! { ! ::HideWindow(overlay_m); ! } } --- 280,330 ---- void ui_overlay_t::implementation_t::framing(bool do_framing) { ! assert(control_m); ! framing_m = do_framing; ! if (do_framing) ! { ! ::ShowWindow(overlay_m); ! draw_element_set_t tick_set; ! overlay_forest_t::preorder_iterator first(tree_m.begin()); ! overlay_forest_t::preorder_iterator last(tree_m.end()); ! for (; first != last; ++first) ! tick_extents(flatten_overlay_data(first.base()), tick_set); ! if (!tick_set.empty()) ! { ! CGrafPtr window_port(::GetWindowPort(overlay_m)); ! CGContextRef context(0); ! Rect bounds; ! overlay_bounds_update(); ! ::GetWindowBounds(overlay_m, kWindowContentRgn, &bounds); ! ADOBE_REQUIRE_STATUS(::QDBeginCGContext(window_port, &context)); ! ::CGContextTranslateCTM(context, 0.0, static_cast<float>(bounds.bottom - bounds.top)); ! ::CGContextScaleCTM(context, 1.0, -1.0); ! ::CGContextSetLineWidth(context, 1); ! ::CGContextSetShouldAntialias(context, false); ! ::CGContextSetAlpha(context, .75f); ! ::CGContextBeginPath(context); ! adobe::for_each(tick_set, boost::bind(&implementation_t::draw_tick, boost::ref(*this), context, _1)); ! ::CGContextFlush(context); ! ADOBE_REQUIRE_STATUS(::QDEndCGContext(window_port, &context)); ! } ! } ! else ! { ! ::HideWindow(overlay_m); ! } } *************** *** 333,349 **** overlay_data_t ui_overlay_t::implementation_t::flatten_overlay_data(overlay_forest_t::iterator iter) { ! overlay_data_t result; ! point_2d_t& origin(result.origin_m); ! overlay_forest_t::iterator last(tree_m.end()); ! result.extents_m = iter->extents_m; ! for (; iter != last; iter = find_parent(iter)) ! { ! origin.x_m += iter->origin_m.x_m; ! origin.y_m += iter->origin_m.y_m; ! } ! return result; } --- 333,349 ---- overlay_data_t ui_overlay_t::implementation_t::flatten_overlay_data(overlay_forest_t::iterator iter) { ! overlay_data_t result; ! point_2d_t& origin(result.origin_m); ! overlay_forest_t::iterator last(tree_m.end()); ! result.extents_m = iter->extents_m; ! for (; iter != last; iter = find_parent(iter)) ! { ! origin.x_m += iter->origin_m.x_m; ! origin.y_m += iter->origin_m.y_m; ! } ! return result; } *************** *** 352,376 **** struct frame_rect_t { ! frame_rect_t(float left, float top, float right, float bottom, float tick = 3) : ! tick_width_m(adobe::pin(0.0f, right - left, tick)), ! tick_height_m(adobe::pin(0.0f, bottom - top, tick)), ! tick_start_right_m(std::max(right - tick, left)), ! tick_start_bottom_m(std::max(bottom - tick, top)), ! tl_m(::CGRectMake(left, top, tick_width_m, tick_height_m)), ! tr_m(::CGRectMake(tick_start_right_m, top, tick_width_m, tick_height_m)), ! bl_m(::CGRectMake(left, tick_start_bottom_m, tick_width_m, tick_height_m)), ! br_m(::CGRectMake(tick_start_right_m, tick_start_bottom_m, tick_width_m, tick_height_m)) ! { ! } ! float tick_width_m; ! float tick_height_m; ! float tick_start_right_m; ! float tick_start_bottom_m; ! CGRect tl_m; ! CGRect tr_m; ! CGRect bl_m; ! CGRect br_m; }; --- 352,376 ---- struct frame_rect_t { ! frame_rect_t(float left, float top, float right, float bottom, float tick = 3) : ! tick_width_m(adobe::pin(0.0f, right - left, tick)), ! tick_height_m(adobe::pin(0.0f, bottom - top, tick)), ! tick_start_right_m(std::max(right - tick, left)), ! tick_start_bottom_m(std::max(bottom - tick, top)), ! tl_m(::CGRectMake(left, top, tick_width_m, tick_height_m)), ! tr_m(::CGRectMake(tick_start_right_m, top, tick_width_m, tick_height_m)), ! bl_m(::CGRectMake(left, tick_start_bottom_m, tick_width_m, tick_height_m)), ! br_m(::CGRectMake(tick_start_right_m, tick_start_bottom_m, tick_width_m, tick_height_m)) ! { ! } ! float tick_width_m; ! float tick_height_m; ! float tick_start_right_m; ! float tick_start_bottom_m; ! CGRect tl_m; ! CGRect tr_m; ! CGRect bl_m; ! CGRect br_m; }; *************** *** 379,453 **** void ui_overlay_t::implementation_t::tick_extents(const overlay_data_t& overlay_data, draw_element_set_t& set) { ! typedef draw_element_t de_t; ! static const RGBColor red = { USHRT_MAX, 0, 0 }; ! static const RGBColor green = { 0, USHRT_MAX, 0 }; ! static const RGBColor blue = { 0, 0, USHRT_MAX }; ! const point_2d_t& position(overlay_data.origin_m); ! const extents_t& extents(overlay_data.extents_m); ! float top(static_cast<float>(position.y_m)); ! float left(static_cast<float>(position.x_m)); ! float bottom(top + extents.height()); ! float right(left + extents.width()); ! frame_rect_t bounds(left, top, right, bottom); ! set.push_back(de_t(de_t::element_type_top_left, bounds.tl_m, blue)); ! set.push_back(de_t(de_t::element_type_top_right, bounds.tr_m, blue)); ! set.push_back(de_t(de_t::element_type_bottom_left, bounds.bl_m, blue)); ! set.push_back(de_t(de_t::element_type_bottom_right, bounds.br_m, blue)); ! if (extents.vertical().outset_m.first || extents.vertical().outset_m.second || ! extents.horizontal().outset_m.first || extents.horizontal().outset_m.second) ! { ! float top_outset(top - extents.vertical().outset_m.first); ! float bottom_outset(bottom + extents.vertical().outset_m.second); ! float left_outset(left - extents.horizontal().outset_m.first); ! float right_outset(right + extents.horizontal().outset_m.second); ! frame_rect_t outsets(left_outset, top_outset, right_outset, bottom_outset); ! set.push_back(de_t(de_t::element_type_top_left, outsets.tl_m, green)); ! set.push_back(de_t(de_t::element_type_top_right, outsets.tr_m, green)); ! set.push_back(de_t(de_t::element_type_bottom_left, outsets.bl_m, green)); ! set.push_back(de_t(de_t::element_type_bottom_right, outsets.br_m, green)); ! } ! { ! guide_set_t::const_iterator iter(extents.horizontal().poi_m.begin()); ! guide_set_t::const_iterator last(extents.horizontal().poi_m.end()); ! CGRect top_tick(::CGRectMake(0, top, 1.0, bounds.tick_height_m)); ! CGRect bottom_tick(::CGRectMake(0, bottom - bounds.tick_height_m, 1.0, bounds.tick_height_m)); ! for (; iter != last; ++iter) ! { ! float poi(left + *iter); ! top_tick.origin.x = poi; ! bottom_tick.origin.x = poi; ! set.push_back(de_t(de_t::element_type_horizontal_poi, top_tick, red)); ! set.push_back(de_t(de_t::element_type_horizontal_poi, bottom_tick, red)); ! } ! } ! { ! guide_set_t::const_iterator iter(extents.vertical().poi_m.begin()); ! guide_set_t::const_iterator last(extents.vertical().poi_m.end()); ! CGRect left_tick(::CGRectMake(left, 0, bounds.tick_width_m, 1.0)); ! CGRect right_tick(::CGRectMake(right - bounds.tick_width_m, 0, bounds.tick_width_m, 1.0)); ! for (; iter != last; ++iter) ! { ! float poi(top + *iter); ! left_tick.origin.y = poi; ! right_tick.origin.y = poi; ! set.push_back(de_t(de_t::element_type_vertical_poi, left_tick, red)); ! set.push_back(de_t(de_t::element_type_vertical_poi, right_tick, red)); ! } ! } } --- 379,453 ---- void ui_overlay_t::implementation_t::tick_extents(const overlay_data_t& overlay_data, draw_element_set_t& set) { ! typedef draw_element_t de_t; ! static const RGBColor red = { USHRT_MAX, 0, 0 }; ! static const RGBColor green = { 0, USHRT_MAX, 0 }; ! static const RGBColor blue = { 0, 0, USHRT_MAX }; ! const point_2d_t& position(overlay_data.origin_m); ! const extents_t& extents(overlay_data.extents_m); ! float top(static_cast<float>(position.y_m)); ! float left(static_cast<float>(position.x_m)); ! float bottom(top + extents.height()); ! float right(left + extents.width()); ! frame_rect_t bounds(left, top, right, bottom); ! set.push_back(de_t(de_t::element_type_top_left, bounds.tl_m, blue)); ! set.push_back(de_t(de_t::element_type_top_right, bounds.tr_m, blue)); ! set.push_back(de_t(de_t::element_type_bottom_left, bounds.bl_m, blue)); ! set.push_back(de_t(de_t::element_type_bottom_right, bounds.br_m, blue)); ! if (extents.vertical().outset_m.first || extents.vertical().outset_m.second || ! extents.horizontal().outset_m.first || extents.horizontal().outset_m.second) ! { ! float top_outset(top - extents.vertical().outset_m.first); ! float bottom_outset(bottom + extents.vertical().outset_m.second); ! float left_outset(left - extents.horizontal().outset_m.first); ! float right_outset(right + extents.horizontal().outset_m.second); ! frame_rect_t outsets(left_outset, top_outset, right_outset, bottom_outset); ! set.push_back(de_t(de_t::element_type_top_left, outsets.tl_m, green)); ! set.push_back(de_t(de_t::element_type_top_right, outsets.tr_m, green)); ! set.push_back(de_t(de_t::element_type_bottom_left, outsets.bl_m, green)); ! set.push_back(de_t(de_t::element_type_bottom_right, outsets.br_m, green)); ! } ! { ! guide_set_t::const_iterator iter(extents.horizontal().poi_m.begin()); ! guide_set_t::const_iterator last(extents.horizontal().poi_m.end()); ! CGRect top_tick(::CGRectMake(0, top, 1.0, bounds.tick_height_m)); ! CGRect bottom_tick(::CGRectMake(0, bottom - bounds.tick_height_m, 1.0, bounds.tick_height_m)); ! for (; iter != last; ++iter) ! { ! float poi(left + *iter); ! top_tick.origin.x = poi; ! bottom_tick.origin.x = poi; ! set.push_back(de_t(de_t::element_type_horizontal_poi, top_tick, red)); ! set.push_back(de_t(de_t::element_type_horizontal_poi, bottom_tick, red)); ! } ! } ! { ! guide_set_t::const_iterator iter(extents.vertical().poi_m.begin()); ! guide_set_t::const_iterator last(extents.vertical().poi_m.end()); ! CGRect left_tick(::CGRectMake(left, 0, bounds.tick_width_m, 1.0)); ! CGRect right_tick(::CGRectMake(right - bounds.tick_width_m, 0, bounds.tick_width_m, 1.0)); ! for (; iter != last; ++iter) ! { ! float poi(top + *iter); ! left_tick.origin.y = poi; ! right_tick.origin.y = poi; ! set.push_back(de_t(de_t::element_type_vertical_poi, left_tick, red)); ! set.push_back(de_t(de_t::element_type_vertical_poi, right_tick, red)); ! } ! } } *************** *** 456,513 **** void ui_overlay_t::implementation_t::draw_tick(CGContextRef context, const draw_element_set_t::value_type& element) { ! typedef draw_element_set_t::value_type desvt_t; ! coord_set_t coord_set; ! float top(element.rect_m.origin.y + 1); ! float left(element.rect_m.origin.x); ! float bottom(element.rect_m.origin.y + element.rect_m.size.height); ! float right(element.rect_m.origin.x + element.rect_m.size.width - 1); ! coord_t top_left(left, top); ! coord_t top_right(right, top); ! coord_t bottom_left(left, bottom); ! coord_t bottom_right(right, bottom); ! ::CGContextSetRGBStrokeColor( context, ! element.color_m.red / static_cast<float>(USHRT_MAX), ! element.color_m.green / static_cast<float>(USHRT_MAX), ! element.color_m.blue / static_cast<float>(USHRT_MAX), ! 1.0f); ! if (element.type_m == desvt_t::element_type_top_left) ! { ! coord_set.push_back(top_right); ! coord_set.push_back(top_left); ! coord_set.push_back(bottom_left); ! } ! else if (element.type_m == desvt_t::element_type_top_right) ! { ! coord_set.push_back(top_left); ! coord_set.push_back(top_right); ! coord_set.push_back(bottom_right); ! } ! else if (element.type_m == desvt_t::element_type_bottom_left) ! { ! coord_set.push_back(top_left); ! coord_set.push_back(bottom_left); ! coord_set.push_back(bottom_right); ! } ! else if (element.type_m == desvt_t::element_type_bottom_right) ! { ! coord_set.push_back(top_right); ! coord_set.push_back(bottom_right); ! coord_set.push_back(bottom_left); ! } ! else if (element.type_m == desvt_t::element_type_horizontal_poi) ! { ! coord_set.push_back(top_left); ! coord_set.push_back(bottom_left); ! } ! else if (element.type_m == desvt_t::element_type_vertical_poi) ! { ! coord_set.push_back(top_left); ! coord_set.push_back(top_right); ! } ! draw_line_path(context, coord_set); } --- 456,513 ---- void ui_overlay_t::implementation_t::draw_tick(CGContextRef context, const draw_element_set_t::value_type& element) { ! typedef draw_element_set_t::value_type desvt_t; ! coord_set_t coord_set; ! float top(element.rect_m.origin.y + 1); ! float left(element.rect_m.origin.x); ! float bottom(element.rect_m.origin.y + element.rect_m.size.height); ! float right(element.rect_m.origin.x + element.rect_m.size.width - 1); ! coord_t top_left(left, top); ! coord_t top_right(right, top); ! coord_t bottom_left(left, bottom); ! coord_t bottom_right(right, bottom); ! ::CGContextSetRGBStrokeColor( context, ! element.color_m.red / static_cast<float>(USHRT_MAX), ! element.color_m.green / static_cast<float>(USHRT_MAX), ! element.color_m.blue / static_cast<float>(USHRT_MAX), ! 1.0f); ! if (element.type_m == desvt_t::element_type_top_left) ! { ! coord_set.push_back(top_right); ! coord_set.push_back(top_left); ! coord_set.push_back(bottom_left); ! } ! else if (element.type_m == desvt_t::element_type_top_right) ! { ! coord_set.push_back(top_left); ! coord_set.push_back(top_right); ! coord_set.push_back(bottom_right); ! } ! else if (element.type_m == desvt_t::element_type_bottom_left) ! { ! coord_set.push_back(top_left); ! coord_set.push_back(bottom_left); ! coord_set.push_back(bottom_right); ! } ! else if (element.type_m == desvt_t::element_type_bottom_right) ! { ! coord_set.push_back(top_right); ! coord_set.push_back(bottom_right); ! coord_set.push_back(bottom_left); ! } ! else if (element.type_m == desvt_t::element_type_horizontal_poi) ! { ! coord_set.push_back(top_left); ! coord_set.push_back(bottom_left); ! } ! else if (element.type_m == desvt_t::element_type_vertical_poi) ! { ! coord_set.push_back(top_left); ! coord_set.push_back(top_right); ! } ! draw_line_path(context, coord_set); } *************** *** 516,535 **** void ui_overlay_t::implementation_t::overlay_bounds_update() { ! Rect overlay_bounds = { 0 }; ! Rect hosting_bounds = { 0 }; ! WindowClass host_window_class(0); ! ADOBE_REQUIRE_STATUS(::GetWindowClass(source_m, &host_window_class)); ! ::GetWindowBounds(overlay_m, kWindowContentRgn, &overlay_bounds); ! ::GetWindowBounds(source_m, kWindowContentRgn, &hosting_bounds); ! if (overlay_bounds.top != hosting_bounds.top || ! overlay_bounds.bottom != hosting_bounds.bottom || ! overlay_bounds.left != hosting_bounds.left || ! overlay_bounds.right != hosting_bounds.right) ! { ! ::SetWindowBounds(overlay_m, kWindowContentRgn, &hosting_bounds); ! } } --- 516,535 ---- void ui_overlay_t::implementation_t::overlay_bounds_update() { ! Rect overlay_bounds = { 0 }; ! Rect hosting_bounds = { 0 }; ! WindowClass host_window_class(0); ! ADOBE_REQUIRE_STATUS(::GetWindowClass(source_m, &host_window_class)); ! ::GetWindowBounds(overlay_m, kWindowContentRgn, &overlay_bounds); ! ::GetWindowBounds(source_m, kWindowContentRgn, &hosting_bounds); ! if (overlay_bounds.top != hosting_bounds.top || ! overlay_bounds.bottom != hosting_bounds.bottom || ! overlay_bounds.left != hosting_bounds.left || ! overlay_bounds.right != hosting_bounds.right) ! { ! ::SetWindowBounds(overlay_m, kWindowContentRgn, &hosting_bounds); ! } } --- NEW FILE: os_utilities.cpp --- /* Copyright 2005-2006 Adobe Systems Incorporated Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt or a copy at http://opensource.adobe.com/licenses.html) */ /****************************************************************************************************/ #include "os_utilities.hpp" /****************************************************************************************************/ namespace adobe { /****************************************************************************************************/ namespace implementation { /****************************************************************************************************/ std::string cfstring_to_string(::CFStringRef x) { if (x == 0) return std::string(); const int pad(16); // must be at least one - seems like a good conservative size ::CFIndex max_size(::CFStringGetMaximumSizeForEncoding(::CFStringGetLength(x), kCFStringEncodingUTF8) + pad); std::vector<char> buffer(static_cast<std::size_t>(max_size)); #ifndef NDEBUG ::Boolean result = #endif ::CFStringGetCString(x, &buffer[0], max_size, kCFStringEncodingUTF8); #ifndef NDEBUG assert(result); #endif return std::string(&buffer[0]); } /****************************************************************************************************/ template <> void get_bounds< ::ControlRef >(const ::ControlRef& control, ::Rect& bounds, bool absolute) { assert(control); static const float round(.5); ::HIRect cur_bounds = { { 0, 0 }, { 0, 0 } }; ADOBE_REQUIRE_STATUS(::HIViewGetFrame(control, &cur_bounds)); if (absolute) { // bounds are relative to the parent control; this makes them relative to the window. ::WindowRef window(::GetControlOwner(control)); ::ControlRef root_control(0); if (window) ::ADOBE_REQUIRE_STATUS(::GetRootControl(window, &root_control)); if (root_control) ::ADOBE_REQUIRE_STATUS(::HIViewConvertRect(&cur_bounds, ::HIViewGetSuperview(control), root_control)); } bounds.left = static_cast<short>(cur_bounds.origin.x + round); bounds.top = static_cast<short>(cur_bounds.origin.y + round); bounds.right = static_cast<short>(bounds.left + cur_bounds.size.width + round); bounds.bottom = static_cast<short>(bounds.top + cur_bounds.size.height + round); } /****************************************************************************************************/ template <> std::string get_field_text< ::ControlRef >(::ControlRef& control) { if (!control) return std::string(); ::CFStringRef cfstring(0); ADOBE_REQUIRE_STATUS(::CopyControlTitleAsCFString(control, &cfstring)); adobe::auto_resource< ::CFStringRef > auto_string(cfstring); return cfstring_to_string(cfstring); } /****************************************************************************************************/ std::string get_name(const ::ControlRef& control) { assert (control); ::CFStringRef cfstring(0); ADOBE_REQUIRE_STATUS(::CopyControlTitleAsCFString(control, &cfstring)); adobe::auto_resource< ::CFStringRef > auto_string(cfstring); return cfstring_to_string(cfstring); } /****************************************************************************************************/ std::string get_name(const ::WindowRef& window) { assert(window); ::CFStringRef cfstring(0); ADOBE_REQUIRE_STATUS(::CopyWindowTitleAsCFString(window, &cfstring)); adobe::auto_resource< ::CFStringRef > auto_string(cfstring); return cfstring_to_string(cfstring); } /****************************************************************************************************/ /// REVISIT (fbrereto) : This is tucked into a cpp file because it uses a deprecated MacOS X API ::FMFontFamily get_classic_font_id(const char* font_name, std::size_t name_length) { ::ATSUFontID atsui_font_id(get_atsui_font_id(font_name, name_length)); ::FMFont font(::FMGetFontFromATSFontRef(atsui_font_id)); ::FMFontFamily font_family; ::FMFontStyle font_style; ADOBE_REQUIRE_STATUS(::FMGetFontFamilyInstanceFromFont(font, &font_family, &font_style)); return font_family; } /****************************************************************************************************/ adobe::extents_t get_text_dimensions(const std::string& text, adobe::theme_t theme) { adobe::extents_t result; ::ATSUStyle style_nonauto; ::ATSUTextLayout layout_nonauto; std::vector<boost::uint16_t> unibuffer; ::UniCharCount run_length(kATSUToTextEnd); unibuffer.reserve(text.size()); adobe::to_utf16(text.begin(), text.end(), std::back_inserter(unibuffer)); ADOBE_REQUIRE_STATUS(::ATSUCreateStyle(&style_nonauto)); adobe::auto_resource< ::ATSUStyle > style(style_nonauto); adobe::theme_t masked(theme & adobe::theme_mask_s); if (masked == adobe::theme_mini_s) atsu_set_attribute(style_nonauto, kATSUSizeTag, ::Long2Fix(9)); else if (masked == adobe::theme_small_s) atsu_set_attribute(style_nonauto, kATSUSizeTag, ::Long2Fix(11)); //else if (masked == adobe::theme_normal_s) // atsu_set_attribute(style_nonauto, kATSUSizeTag, ::Long2Fix(13)); if (theme & adobe::theme_adornment_mono_s) atsu_set_attribute(style_nonauto, kATSUFontTag, get_atsui_font_id("Monaco")); ADOBE_REQUIRE_STATUS(::ATSUCreateTextLayoutWithTextPtr( static_cast<UniChar*>(&unibuffer[0]), 0, unibuffer.size(), unibuffer.size(), 1, &run_length, &style_nonauto, &layout_nonauto)); adobe::auto_resource< ::ATSUTextLayout > layout(layout_nonauto); ADOBE_REQUIRE_STATUS(::ATSUSetTransientFontMatching(layout_nonauto, true)); ATSUTextMeasurement before(0); ATSUTextMeasurement after(0); ATSUTextMeasurement ascent(0); ATSUTextMeasurement descent(0); ADOBE_REQUIRE_STATUS(::ATSUGetUnjustifiedBounds( layout_nonauto, 0, unibuffer.size(), &before, &after, &ascent, &descent)); before = ::Fix2Long(before); after = ::Fix2Long(after); ascent = ::Fix2Long(ascent); descent = ::Fix2Long(descent); result.vertical().length_m = ascent; result.horizontal().length_m = after - before; result.vertical().poi_m.push_back(ascent); return result; } /****************************************************************************************************/ adobe::extents_t measure(::ControlRef& control) { assert(control); adobe::extents_t result; ::Rect bounds = { 0 }; ::SInt16 best_baseline(0); ::GetBestControlRect(control, &bounds, &best_baseline); result.height() = bounds.bottom - bounds.top; result.width() = bounds.right - bounds.left; if (best_baseline) result.vertical().poi_m.push_back(result.height() + best_baseline); return result; } /****************************************************************************************************/ void theme_to_rec(const adobe::theme_t& style, ControlFontStyleRec& style_rec) { ControlFontStyleRec result = { 0 }; adobe::theme_t masked(style & adobe::theme_mask_s); if (style & adobe::theme_adornment_mono_s) { result.font = get_classic_font_id("Monaco"); result.flags |= static_cast<int>(kControlUseFontMask) | static_cast<int>(kControlUseSizeMask); switch (masked) { case adobe::theme_large_s: result.size = 14; break; case adobe::theme_small_s: result.size = 10; break; case adobe::theme_mini_s: result.size = 9; break; case adobe::theme_normal_s: default: result.size = 12; break; } } else if (masked) { ThemeFontID font_id(theme_to_ThemeFontID(style)); Str255 font_name; SInt16 font_size; Style font_style; ::GetThemeFont(font_id, smSystemScript, font_name, &font_size, &font_style); result.flags |= static_cast<int>(kControlUseFontMask) | static_cast<int>(kControlUseSizeMask) | static_cast<int>(kControlUseFaceMask); result.font = get_classic_font_id(font_name); result.size = font_size; result.style = font_style; } style_rec = result; } /****************************************************************************************************/ // REVISIT (fbrereto) : This can all get reduced void set_popup_with_text(ControlRef control, const std::string& text, unsigned long cur_time) { static unsigned long last_time(0); static unsigned long double_click_time(::GetDblTime()); static std::string selection_string; std::size_t new_index(1); MenuRef menu(::GetControlPopupMenuHandle(control)); std::size_t menu_item_count(::CountMenuItems(menu)); if (cur_time - last_time > double_click_time) selection_string.erase(selection_string.begin(), selection_string.end()); last_time = cur_time; selection_string.append(text.c_str()); for (; new_index <= menu_item_count; ++new_index) { ::CFStringRef cur_menu_item(0); ADOBE_REQUIRE_STATUS(::CopyMenuItemTextAsCFString(menu, static_cast< ::UInt16 >(new_index), &cur_menu_item)); adobe::auto_resource< ::CFStringRef > auto_string(cur_menu_item); std::string cur_name(cfstring_to_string(cur_menu_item)); for (std::string::iterator i(cur_name.begin()); i != cur_name.end(); ++i) *i = static_cast<std::string::value_type>(std::tolower(*i)); if (cur_name.find(selection_string) == 0) break; } if (new_index > menu_item_count) adobe::system_beep(); else if (new_index != static_cast<std::size_t>(get_value(control))) ::SetControl32BitValue(control, static_cast<long>(new_index)); } /****************************************************************************************************/ /// sets the keyboard focus for a control template <> static void set_focus< ::ControlRef >(::ControlRef& control, bool make_focused) { assert(control); ::ControlRef current_focus(0); ::WindowRef window(::GetControlOwner(control)); ADOBE_REQUIRE_STATUS(::GetKeyboardFocus(window, ¤t_focus)); if (make_focused && current_focus != control) ADOBE_REQUIRE_STATUS(::SetKeyboardFocus(window, control, kControlFocusNextPart)); else if (!make_focused && current_focus == control) ADOBE_REQUIRE_STATUS(::ClearKeyboardFocus(window)); } /****************************************************************************************************/ void set_bounds(::ControlRef control, const ::Rect& new_bounds) { assert(control); ::HIRect bounds = { { static_cast<float>(new_bounds.left), static_cast<float>(new_bounds.top) }, { static_cast<float>(new_bounds.right - new_bounds.left), static_cast<float>(new_bounds.bottom - new_bounds.top) } }; bounds.size.height = std::max(bounds.size.height, 0.0f); bounds.size.width = std::max(bounds.size.width, 0.0f); ADOBE_REQUIRE_STATUS(::HIViewSetFrame(control, &bounds)); } /****************************************************************************************************/ template <> void set_theme< ::ControlRef >(::ControlRef& control, adobe::theme_t theme) { assert(control); ::ControlFontStyleRec new_style = { 0 }; theme_to_rec(theme, new_style); set_widget_data(control, kControlEntireControl, kControlFontStyleTag, new_style, false); ::ControlSize control_size(kControlSizeNormal); switch ( theme & theme_mask_s ) { case theme_large_s: control_size = kControlSizeLarge; break; case theme_small_s: control_size = kControlSizeSmall; break; case theme_mini_s: control_size = kControlSizeMini; break; case theme_normal_s: default: break; } set_widget_data(control, kControlEntireControl, kControlSizeTag, control_size, false); } /****************************************************************************************************/ template <> void set_theme< ::TXNObject >(::TXNObject& hitextview, adobe::theme_t theme) { assert (hitextview); ControlFontStyleRec rec; std::vector<TXNTypeAttributes> attr; TXNTypeAttributes empty_attr = { 0 }; RGBColor black = { 0, 0, 0 }; theme_to_rec(theme, rec); if (rec.flags & kControlUseFontMask) { attr.push_back(empty_attr); attr.back().tag = kTXNQDFontFamilyIDAttribute; attr.back().size = kTXNQDFontFamilyIDAttributeSize; attr.back().data.dataValue = rec.font; } if (rec.flags & kControlUseSizeMask) { attr.push_back(empty_attr); attr.back().tag = kTXNQDFontSizeAttribute; attr.back().size = kTXNFontSizeAttributeSize; attr.back().data.dataValue = static_cast<UInt32>(::Long2Fix(rec.size)); } if (rec.flags & kControlUseFaceMask) { attr.push_back(empty_attr); attr.back().tag = kTXNQDFontStyleAttribute; attr.back().size = kTXNQDFontStyleAttributeSize; attr.back().data.dataValue = rec.style; } attr.push_back(empty_attr); attr.back().tag = kTXNQDFontColorAttribute; attr.back().size = kTXNQDFontColorAttributeSize; attr.back().data.dataPtr = &black; ::ADOBE_REQUIRE_STATUS(::TXNSetTypeAttributes(hitextview, attr.size(), &attr[0], kTXNStartOffset, kTXNEndOffset)); } /****************************************************************************************************/ template <> void set_active< ::ControlRef >(::ControlRef& control, bool make_active) { assert(control); make_active ? ::EnableControl(control) : ::DisableControl(control); } /****************************************************************************************************/ std::string convert_utf(::UniChar* buffer, std::size_t size) { std::string result; result.reserve(size * 2); adobe::to_utf8(buffer, buffer + size, std::back_inserter(result)); return result; } /****************************************************************************************************/ std::string convert_utf(UniChar* buffer) { std::size_t size(0); while (buffer[size] != ::UniChar(0)) ++size; return convert_utf(buffer, size); } /****************************************************************************************************/ adobe::modifiers_t convert_modifiers(::UInt32 os_modifiers) { adobe::modifiers_t result(adobe::modifiers_none_s); if (os_modifiers & cmdKey) result |= adobe::modifiers_any_command_s; if (os_modifiers & shiftKey) result |= adobe::modifiers_left_shift_s; if (os_modifiers & alphaLock) result |= adobe::modifiers_caps_lock_s; if (os_modifiers & optionKey) result |= adobe::modifiers_left_option_s; if (os_modifiers & controlKey) result |= adobe::modifiers_left_control_s; if (os_modifiers & rightShiftKey) result |= adobe::modifiers_right_shift_s; if (os_modifiers & rightOptionKey) result |= adobe::modifiers_right_option_s; if (os_modifiers & rightControlKey) result |= adobe::modifiers_right_control_s; return result; } /****************************************************************************************************/ } // namespace implementation /****************************************************************************************************/ } // namespace adobe /****************************************************************************************************/ Index: ui_core_implementation.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/future/widgets/sources/mac/ui_core_implementation.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ui_core_implementation.cpp 24 Jan 2006 19:38:47 -0000 1.9 --- ui_core_implementation.cpp 3 Feb 2006 18:33:37 -0000 1.10 *************** *** 1,6 **** /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt ! or a copy at http://opensource.adobe.com/licenses.html) */ --- 1,6 ---- /* ! Copyright 2005-2006 Adobe Systems Incorporated ! Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt [...9039 lines suppressed...] ! if (element.implementation().state_set_m.size() > 1) ! { ! WindowRef window(::GetControlOwner(ref)); ! element.implementation().mod_key_handler_m.set_user_data(&(element.implementation())); ! element.implementation().mod_key_handler_m.uninstall(); ! element.implementation().mod_key_handler_m.install(window); ! } ! ! return result; } *************** *** 5481,5485 **** ADOBE_VIEW_FOR_ELEMENT_AND_INSERT_BOILERPLATE_SPECIALIZATION(separator_t); ADOBE_VIEW_FOR_ELEMENT_AND_INSERT_BOILERPLATE_SPECIALIZATION(slider_t); - ADOBE_VIEW_FOR_ELEMENT_AND_INSERT_BOILERPLATE_SPECIALIZATION(bevel_button_t); /****************************************************************************************************/ --- 3731,3734 ---- |