From: Foster B. <fos...@us...> - 2006-02-23 23:29:34
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe/future/widgets/sources/mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25760/adobe/future/widgets/sources/mac Modified Files: metrics.cpp os_utilities.cpp ui_core_implementation.cpp Added Files: label_t_impl.cpp Log Message: the state of things. We've been working to isolate static_text_t (now called label_t) but it has been slow going because we're trying to wrestle with perfecting the API and what effect that has on other components that were using label_t in a way that isn't in accordance with the new API we're trying to write. As it stands static_disabled_text_m is broken on both platforms, but everything else should be working better. Index: metrics.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/future/widgets/sources/mac/metrics.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** metrics.cpp 3 Feb 2006 18:33:37 -0000 1.6 --- metrics.cpp 23 Feb 2006 23:28:55 -0000 1.7 *************** *** 15,18 **** --- 15,19 ---- #include <adobe/dictionary.hpp> #include <adobe/array.hpp> + #include <adobe/once.hpp> #include <sstream> *************** *** 20,23 **** --- 21,49 ---- /****************************************************************************************************/ + ADOBE_ONCE_DECLARATION(mac_metrics_once) + + /****************************************************************************************************/ + + namespace { + + /****************************************************************************************************/ + + ADOBE_THREAD_LOCAL_STORAGE(adobe::virtual_machine_t, metrics_vm) + + /*************************************************************************************************/ + + void init_mac_metrics_once() + { + // initialize the thread-specific virtual machine + + ADOBE_THREAD_LOCAL_STORAGE_INITIALIZE(metrics_vm); + } + + /****************************************************************************************************/ + + } // namespace + + /****************************************************************************************************/ + namespace adobe { *************** *** 26,29 **** --- 52,57 ---- adobe::dictionary_t widget_metrics(const std::string& xstr, const adobe::dictionary_t& context) { + ADOBE_ONCE_INSTANCE(mac_metrics_once); + std::vector<adobe::attribute_set_t::value_type> context_attribute_set; *************** *** 55,63 **** parser.require_expression(expression); ! virtual_machine_t machine; ! machine.evaluate(expression); ! return machine.back().value_m.get<adobe::dictionary_t>(); } --- 83,93 ---- parser.require_expression(expression); ! ADOBE_THREAD_LOCAL_STORAGE_ACCESS(metrics_vm).evaluate(expression); ! adobe::dictionary_t result(ADOBE_THREAD_LOCAL_STORAGE_ACCESS(metrics_vm).back().value_m.get<adobe::dictionary_t>()); ! ADOBE_THREAD_LOCAL_STORAGE_ACCESS(metrics_vm).pop_back(); ! ! return result; } *************** *** 66,68 **** --- 96,102 ---- } // namespace adobe + /*************************************************************************************************/ + + ADOBE_ONCE_DEFINITION(mac_metrics_once, init_mac_metrics_once) + /****************************************************************************************************/ Index: os_utilities.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/future/widgets/sources/mac/os_utilities.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** os_utilities.cpp 3 Feb 2006 18:33:37 -0000 1.1 --- os_utilities.cpp 23 Feb 2006 23:28:55 -0000 1.2 *************** *** 227,230 **** --- 227,256 ---- /****************************************************************************************************/ + adobe::extents_t measure_theme_text(const std::string& text, adobe::theme_t theme) + { + adobe::extents_t result; + ::Point io_bounds = { 0 }; + ::SInt16 out_baseline(0); + + adobe::auto_resource< ::CFStringRef > auto_cfstring(string_to_cfstring(text)); + + ::ADOBE_REQUIRE_STATUS(::GetThemeTextDimensions( + auto_cfstring.get(), + implementation::theme_to_ThemeFontID(theme), + kThemeStateActive, + false, + &io_bounds, + &out_baseline)); + + result.width() = io_bounds.h; + result.height() = io_bounds.v; + + result.vertical().poi_m.push_back(io_bounds.v + out_baseline); + + return result; + } + + /****************************************************************************************************/ + void theme_to_rec(const adobe::theme_t& style, ControlFontStyleRec& style_rec) { *************** *** 241,249 **** 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; } } --- 267,275 ---- switch (masked) { ! case adobe::theme_large_s: result.size = 16; break; ! case adobe::theme_small_s: result.size = 12; break; ! case adobe::theme_mini_s: result.size = 11; break; case adobe::theme_normal_s: ! default: result.size = 14; break; } } 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.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ui_core_implementation.cpp 3 Feb 2006 18:33:37 -0000 1.10 --- ui_core_implementation.cpp 23 Feb 2006 23:28:55 -0000 1.11 *************** *** 89,92 **** --- 89,106 ---- /****************************************************************************************************/ + adobe::extents_t measure_label_text(const std::string& text, adobe::theme_t theme) + { + adobe::label_t label(text, 0, theme); + adobe::extents_t result; + + result.horizontal() = label.measure_horizontal(); + + result.vertical() = label.measure_vertical(result.horizontal()); + + return result; + } + + /****************************************************************************************************/ + const adobe::metric_extractor_t& global_metrics() { *************** *** 534,549 **** extents_t window_t::implementation_t::measure() { ! extents_t result; ! static_text_t temp; adobe::implementation::set_metric_extractor(*this); ! temp.initialize(implementation::get_name(window_m)); ! temp.set_theme(theme_m); ! ! extents_t temp_measure(temp.best_bounds()); ! ! result.width() = temp_measure.width() + metrics_m(adobe::implementation::k_metric_spacing); ! result.height() = temp_measure.height(); return adobe::implementation::apply_fudges(*this, result); --- 548,556 ---- extents_t window_t::implementation_t::measure() { ! extents_t result(measure_label_text(implementation::get_name(window_m), theme_m)); adobe::implementation::set_metric_extractor(*this); ! result.width() += metrics_m(adobe::implementation::k_metric_spacing); return adobe::implementation::apply_fudges(*this, result); *************** *** 743,759 **** // we have to do it for them. ! adobe::extents_t result; adobe::implementation::set_metric_extractor(*this); ! static_text_t temp; ! ! temp.initialize(implementation::get_name(control_m)); ! temp.set_theme(theme_m); ! ! adobe::extents_t temp_measure(temp.best_bounds()); ! result.width() += temp_measure.width() + metrics_m(adobe::implementation::k_metric_spacing); ! result.vertical().frame_m.first = temp_measure.height(); return adobe::implementation::apply_fudges(*this, result); --- 750,760 ---- // we have to do it for them. ! adobe::extents_t result(measure_label_text(implementation::get_name(control_m), theme_m)); adobe::implementation::set_metric_extractor(*this); ! result.width() += metrics_m(adobe::implementation::k_metric_spacing); ! result.vertical().frame_m.first = result.height(); return adobe::implementation::apply_fudges(*this, result); *************** *** 882,893 **** for (tab_set_t::iterator first(items_m.begin()), last(items_m.end()); first != last; ++first) { ! static_text_t temp; ! ! temp.initialize(first->name_m); ! temp.set_theme(theme_m); ! ! adobe::extents_t temp_measure(temp.best_bounds()); result.width() += temp_measure.width() + metrics_m(adobe::implementation::k_metric_spacing); result.vertical().frame_m.first = std::max(result.vertical().frame_m.first, temp_measure.height()); } --- 883,890 ---- for (tab_set_t::iterator first(items_m.begin()), last(items_m.end()); first != last; ++first) { ! adobe::extents_t temp_measure(measure_label_text(first->name_m, theme_m)); result.width() += temp_measure.width() + metrics_m(adobe::implementation::k_metric_spacing); + result.vertical().frame_m.first = std::max(result.vertical().frame_m.first, temp_measure.height()); } *************** *** 1863,2048 **** /****************************************************************************************************/ - ADOBE_WIDGET_TAG_BOILERPLATE(adobe::static_text_t::implementation_t, "<xstr id='metric:static_text'/>"); - - /****************************************************************************************************/ - - namespace implementation { - - /****************************************************************************************************/ - - template <> - std::string get_name<adobe::static_text_t::implementation_t>(const adobe::static_text_t::implementation_t& widget) - { - if (!widget.control_m) return std::string(); - - ::CFStringRef cfstring; - - get_widget_data(widget.control_m, kControlEntireControl, kControlStaticTextCFStringTag, cfstring); - - adobe::auto_resource< ::CFStringRef > auto_cfstring(cfstring); - - return cfstring_to_string(cfstring); - } - - /****************************************************************************************************/ - - template <> - void set_name< adobe::static_text_t::implementation_t >(adobe::static_text_t::implementation_t& control, const std::string& name) - { - set_widget_data( - control.control_m, - kControlEntireControl, - kControlStaticTextCFStringTag, - implementation::localize_to_cfstring(name).get()); - } - - /****************************************************************************************************/ - - } // namespace implementation - - /****************************************************************************************************/ - - ::OSStatus static_text_hit_handler_t::handle_event( ::EventHandlerCallRef next, - ::EventRef event) - { - if (user_data_m.empty()) - return eventNotHandledErr; - - ::UInt32 modifiers; - - implementation::get_event_parameter<kEventParamKeyModifiers>(event, modifiers); - - user_data_m(implementation::convert_modifiers(modifiers)); - - return noErr; - } - - /****************************************************************************************************/ - - static_text_t::implementation_t::implementation_t() : - control_m(0), - theme_m(adobe::theme_normal_s), - hit_handler_m(*this) - { } - - /****************************************************************************************************/ - - static_text_t::implementation_t::implementation_t(const implementation_t& rhs) : - control_m(0), - hit_handler_m(*this) - { - Rect bounds = { 0 }; - - implementation::get_bounds(rhs.control_m, bounds); - - initialize(bounds, implementation::get_name(rhs)); - - set_theme(rhs.theme_m); - } - - /****************************************************************************************************/ - - void static_text_t::implementation_t::initialize( const Rect& bounds, - const std::string& name) - { - assert(!control_m); - - ADOBE_REQUIRE_STATUS(::CreateStaticTextControl( 0, &bounds, - implementation::localize_to_cfstring(name).get(), - NULL, &control_m)); - } - - /****************************************************************************************************/ - - /* - REVISIT (sparent) : This is the basic code for how we _should_ measure static texts. There - may be an issue with word-wrapped text (I didn't touch that case, I'm not sure how it works. - - This fixes our alignment tests, and wrapped text still works, so I'm going to let this go for - the re-write. - */ - - extents_t static_text_t::implementation_t::best_bounds() - { - assert(control_m); - - adobe::extents_t result; - ::CFStringRef cfstring; - ::Point io_bounds = { 0 }; - ::SInt16 out_baseline(0); - - adobe::implementation::set_metric_extractor(*this); - - implementation::get_widget_data(control_m, kControlEntireControl, kControlStaticTextCFStringTag, cfstring); - - adobe::auto_resource< ::CFStringRef > auto_cfstring(cfstring); - - ::ADOBE_REQUIRE_STATUS(::GetThemeTextDimensions( - cfstring, - implementation::theme_to_ThemeFontID(theme_m), - kThemeStateActive, - false, - &io_bounds, - &out_baseline)); - - result.height() = io_bounds.v; - result.width() = io_bounds.h; - - result.vertical().poi_m.push_back(result.height() + out_baseline); - - return implementation::apply_fudges(*this, result); - } - - /****************************************************************************************************/ - - void static_text_t::implementation_t::set_bounds(const point_2d_t& position, const extents_t& extents) - { - assert(control_m); - - implementation::set_bounds(*this, position, extents); - } - - /****************************************************************************************************/ - - void static_text_t::implementation_t::set_name(const std::string& name) - { - assert(control_m); - - implementation::set_name(*this, name); - } - - /****************************************************************************************************/ - - long static_text_t::implementation_t::best_height_given_width(long width) - { - assert(control_m); - - ::Rect static_bounds = { 0, 0, 10, static_cast<short>(width) }; - - implementation::set_bounds(control_m, static_bounds); - - adobe::extents_t best_bounds_result(implementation::measure(*this)); - - return best_bounds_result.height(); - } - - /****************************************************************************************************/ - - void static_text_t::implementation_t::signal_hit(const implementation::static_text_hit_proc_t& proc) - { - assert(control_m); - - hit_handler_m.set_user_data(proc); - hit_handler_m.install(control_m); - } - - /****************************************************************************************************/ - /****************************************************************************************************/ - /****************************************************************************************************/ - /****************************************************************************************************/ - /****************************************************************************************************/ - /****************************************************************************************************/ - /****************************************************************************************************/ - ADOBE_WIDGET_TAG_BOILERPLATE(adobe::edit_text_t::implementation_t, "<xstr id='metric:edit_text'/>"); --- 1860,1863 ---- *************** *** 2138,2142 **** void set_name<adobe::edit_text_t::implementation_t>(adobe::edit_text_t::implementation_t& widget, const std::string& name) { ! widget.get_label().set_name(name); } --- 1953,1957 ---- void set_name<adobe::edit_text_t::implementation_t>(adobe::edit_text_t::implementation_t& widget, const std::string& name) { ! widget.get_label() = label_t(name, 0, widget.theme_m); } *************** *** 2170,2173 **** --- 1985,2009 ---- /****************************************************************************************************/ + template <> + void set_theme<adobe::edit_text_t::implementation_t>(adobe::edit_text_t::implementation_t& edit_text, + adobe::theme_t theme) + { + edit_text.theme_m = theme; + + if (edit_text.scrollable_m) + { + ::TXNObject textview(::HITextViewGetTXNObject(edit_text.control_m)); + + implementation::set_theme(textview, theme); + } + else + implementation::set_theme(edit_text.control_m, theme); + + if (edit_text.using_label_m) + edit_text.get_label() = label_t(implementation::get_name(edit_text.get_label().implementation()), 0, theme); + } + + /****************************************************************************************************/ + } // namespace implementation *************** *** 2273,2283 **** command.commandID == kHICommandRedo) { ! ::TXNObject textview(::HITextViewGetTXNObject(edit_text.control_m)); ! ::OSStatus result = edit_text.post_edit_handler_m.handle_event(next, event); ! ! // Forces the text coming in to the theme of the widget ! implementation::set_theme(textview, edit_text.theme_m); ! ! return result; } --- 2109,2113 ---- command.commandID == kHICommandRedo) { ! return edit_text.post_edit_handler_m.handle_event(next, event); } *************** *** 2291,2294 **** --- 2121,2126 ---- theme_m(adobe::theme_normal_s), scroll_control_m(0), + name_m("dummy", 0, adobe::theme_normal_s), + static_disabled_text_m("dummy", 0, adobe::theme_normal_s), static_disabled_m(false), using_label_m(false), *************** *** 2308,2311 **** --- 2140,2144 ---- name_m(rhs.name_m), field_text_m(rhs.field_text_m), + static_disabled_text_m(rhs.static_disabled_text_m), static_disabled_m(rhs.static_disabled_m), using_label_m(rhs.using_label_m), *************** *** 2375,2379 **** ::HIViewSetVisible(scroll_control_m, true); ! ::ADOBE_REQUIRE_STATUS(::HITextViewCreate(NULL, 0, 0, &control_m)); ::HIViewSetVisible(control_m, true); --- 2208,2217 ---- ::HIViewSetVisible(scroll_control_m, true); ! ::ADOBE_REQUIRE_STATUS(::HITextViewCreate(NULL, ! 0, ! kTXNMonostyledTextMask | ! kTXNWantHScrollBarMask | ! kTXNWantVScrollBarMask, ! &control_m)); ::HIViewSetVisible(control_m, true); *************** *** 2405,2418 **** } ! static_disabled_text_m.initialize("dummy"); ! static_disabled_text_m.set_visible(false); ::SetControlReference(control_m, reinterpret_cast< ::SInt32 >(this)); if (using_label_m) ! { ! get_label().initialize(name); ! get_label().adorn_theme(theme_adornment_label_s); ! } } --- 2243,2252 ---- } ! //static_disabled_text_m.set_visible(false); ::SetControlReference(control_m, reinterpret_cast< ::SInt32 >(this)); if (using_label_m) ! get_label() = label_t(name, 0, theme_m); } *************** *** 2428,2444 **** if (rows_m > 1) { ! static_text_t temp; ! ! temp.initialize(base_text); ! temp.set_theme(theme_m); ! ! #if 0 ! // measure the control directly because we don't apply the ! // fudges yet; we want to do that with the edit text values ! ! result = implementation::measure(temp.implementation().control_m); ! #else ! result = temp.best_bounds(); ! #endif result.height() *= rows_m; --- 2262,2266 ---- if (rows_m > 1) { ! result = measure_label_text(base_text, theme_m); result.height() *= rows_m; *************** *** 2466,2470 **** return result; ! adobe::extents_t label_bounds(get_label().best_bounds()); if (result.vertical().poi_m.size() && label_bounds.vertical().poi_m.size()) --- 2288,2292 ---- return result; ! adobe::extents_t label_bounds(implementation::measure_theme_text(implementation::get_name(get_label().implementation()), theme_m)); if (result.vertical().poi_m.size() && label_bounds.vertical().poi_m.size()) *************** *** 2509,2513 **** label_position.y_m += baseline - static_baseline_m; ! get_label().set_bounds(label_position, label_extents); position.x_m += label_extents.width() + global_metrics()(implementation::k_metric_gap); --- 2331,2335 ---- label_position.y_m += baseline - static_baseline_m; ! get_label().place(label_position, label_extents); position.x_m += label_extents.width() + global_metrics()(implementation::k_metric_gap); *************** *** 2551,2555 **** rect.width() = bounds.right - bounds.left; ! static_disabled_text_m.set_bounds(position, rect); } } --- 2373,2377 ---- rect.width() = bounds.right - bounds.left; ! static_disabled_text_m.place(position, rect); } } *************** *** 2580,2593 **** rect.width() = bounds.right - bounds.left; ! static_disabled_text_m.set_bounds(position, rect); ! static_disabled_text_m.set_name(implementation::get_field_text(*this)); } set_visible(active); ! static_disabled_text_m.set_visible(!active); ! ! // REVISIT : (fbrereto) Should we be disabling the label, or only the edit field? ! //if (using_label_m) ! // get_label().set_active(active); } else --- 2402,2411 ---- rect.width() = bounds.right - bounds.left; ! static_disabled_text_m = label_t(implementation::get_field_text(*this), 0, theme_m); ! static_disabled_text_m.place(position, rect); } set_visible(active); ! //static_disabled_text_m.set_visible(!active); } else *************** *** 2603,2608 **** if (!using_label_m) return; ! if (!static_disabled_m || scrollable_m) ! get_label().set_visible(make_visible); } --- 2421,2426 ---- if (!using_label_m) return; ! // if (!static_disabled_m || scrollable_m) ! // get_label().set_visible(make_visible); } *************** *** 2611,2629 **** void edit_text_t::implementation_t::set_theme(theme_t theme) { ! theme_m = theme; ! ! if (scrollable_m) ! { ! ::TXNObject textview(::HITextViewGetTXNObject(control_m)); ! ! implementation::set_theme(textview, theme); ! } ! else ! implementation::set_theme(control_m, theme); ! ! static_disabled_text_m.set_theme(theme); ! ! if (using_label_m) ! get_label().adorn_theme(theme & ~theme_adornment_mask_s); } --- 2429,2433 ---- void edit_text_t::implementation_t::set_theme(theme_t theme) { ! implementation::set_theme(*this, theme); } *************** *** 2634,2641 **** implementation::adorn_theme(*this, theme); - static_disabled_text_m.adorn_theme(theme); - if (using_label_m) ! get_label().adorn_theme(theme & ~theme_adornment_mask_s); } --- 2438,2443 ---- implementation::adorn_theme(*this, theme); if (using_label_m) ! get_label() = label_t(implementation::get_name(get_label().implementation()), 0, theme_m); } *************** *** 2646,2653 **** implementation::unadorn_theme(*this, theme); - static_disabled_text_m.unadorn_theme(theme); - if (using_label_m) ! get_label().unadorn_theme(theme & ~theme_adornment_mask_s); } --- 2448,2453 ---- implementation::unadorn_theme(*this, theme); if (using_label_m) ! get_label() = label_t(implementation::get_name(get_label().implementation()), 0, theme_m); } *************** *** 2734,2738 **** void edit_text_t::implementation_t::signal_label_hit(const implementation::edit_text_label_hit_proc_t& proc) { ! get_label().signal_hit(proc); } --- 2534,2538 ---- void edit_text_t::implementation_t::signal_label_hit(const implementation::edit_text_label_hit_proc_t& proc) { ! //get_label().signal_hit(proc); } *************** *** 2898,2901 **** --- 2698,2702 ---- control_m(0), theme_m(adobe::theme_normal_s), + static_disabled_text_m("dummy", 0, adobe::theme_normal_s), static_disabled_m(false), using_label_m(false), *************** *** 2907,2914 **** popup_t::implementation_t::implementation_t(const implementation_t& rhs) : control_m(0), static_disabled_m(rhs.static_disabled_m), value_handler_m(*this) { ! Rect bounds = { 0 }; implementation::get_bounds(rhs.control_m, bounds); --- 2708,2716 ---- popup_t::implementation_t::implementation_t(const implementation_t& rhs) : control_m(0), + static_disabled_text_m(rhs.static_disabled_text_m), static_disabled_m(rhs.static_disabled_m), value_handler_m(*this) { ! ::Rect bounds = { 0 }; implementation::get_bounds(rhs.control_m, bounds); *************** *** 2937,2942 **** key_handler_m.install(control_m); ! static_disabled_text_m.initialize("dummy"); ! static_disabled_text_m.set_visible(false); using_label_m = !name.empty(); --- 2739,2743 ---- key_handler_m.install(control_m); ! // static_disabled_text_m.set_visible(false); using_label_m = !name.empty(); *************** *** 2955,2965 **** if (!using_label_m) return result; ! static_text_t temp; ! ! temp.initialize(name_m); ! ! temp.set_theme(theme_m); ! ! result.horizontal().poi_m.push_back(temp.best_bounds().width()); return result; --- 2756,2760 ---- if (!using_label_m) return result; ! result.horizontal().poi_m.push_back(measure_label_text(name_m, theme_m).width()); return result; *************** *** 2988,2992 **** rect.width() = bounds.right - bounds.left; ! static_disabled_text_m.set_bounds(position, rect); } } --- 2783,2787 ---- rect.width() = bounds.right - bounds.left; ! static_disabled_text_m.place(position, rect); } } *************** *** 3016,3025 **** rect.width() = bounds.right - bounds.left; ! static_disabled_text_m.set_bounds(position, rect); ! static_disabled_text_m.set_name(implementation::get_field_text(*this)); } set_visible(active); ! static_disabled_text_m.set_visible(!active); } else --- 2811,2820 ---- rect.width() = bounds.right - bounds.left; ! static_disabled_text_m = label_t(implementation::get_field_text(*this), 0, theme_m); ! static_disabled_text_m.place(position, rect); } set_visible(active); ! // static_disabled_text_m.set_visible(!active); } else *************** *** 3033,3037 **** implementation::set_theme(*this, theme); ! static_disabled_text_m.set_theme(theme & ~theme_adornment_mask_s); } --- 2828,2832 ---- implementation::set_theme(*this, theme); ! static_disabled_text_m = label_t("dummy", 0, theme_m); } *************** *** 3042,3046 **** implementation::adorn_theme(*this, theme); ! static_disabled_text_m.adorn_theme(theme & ~theme_adornment_mask_s); } --- 2837,2841 ---- implementation::adorn_theme(*this, theme); ! static_disabled_text_m = label_t("dummy", 0, theme_m); } *************** *** 3051,3055 **** implementation::unadorn_theme(*this, theme); ! static_disabled_text_m.unadorn_theme(theme & ~theme_adornment_mask_s); } --- 2846,2850 ---- implementation::unadorn_theme(*this, theme); ! static_disabled_text_m = label_t("dummy", 0, theme_m); } *************** *** 3563,3567 **** ADOBE_SERIALIZABLE_EQUALITY_IMPLEMENTATION_DEFINITION(adobe::separator_t::implementation_t); ADOBE_SERIALIZABLE_EQUALITY_IMPLEMENTATION_DEFINITION(adobe::progress_bar_t::implementation_t); - ADOBE_SERIALIZABLE_EQUALITY_IMPLEMENTATION_DEFINITION(adobe::static_text_t::implementation_t); ADOBE_SERIALIZABLE_EQUALITY_IMPLEMENTATION_DEFINITION(adobe::edit_text_t::implementation_t); ADOBE_SERIALIZABLE_EQUALITY_IMPLEMENTATION_DEFINITION(adobe::popup_t::implementation_t); --- 3358,3361 ---- *************** *** 3598,3605 **** /****************************************************************************************************/ - - ADOBE_VIEW_FOR_ELEMENT_AND_INSERT_BOILERPLATE_SPECIALIZATION(static_text_t); - - /****************************************************************************************************/ /* Non-default specialization for window_t */ --- 3392,3395 ---- --- NEW FILE: label_t_impl.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 <adobe/future/widgets/headers/label_t.hpp> #include "label_t_impl.hpp" #include "display.hpp" #include "ui_overlay.hpp" /****************************************************************************************************/ namespace adobe { /****************************************************************************************************/ namespace implementation { /****************************************************************************************************/ template <> std::string get_name<adobe::label_t::implementation_t>(const adobe::label_t::implementation_t& widget) { if (!widget.control_m) return std::string(); ::CFStringRef cfstring; get_widget_data(widget.control_m, kControlEntireControl, kControlStaticTextCFStringTag, cfstring); adobe::auto_resource< ::CFStringRef > auto_cfstring(cfstring); return cfstring_to_string(cfstring); } /****************************************************************************************************/ template <> void set_name< adobe::label_t::implementation_t >(adobe::label_t::implementation_t& control, const std::string& name) { set_widget_data( control.control_m, kControlEntireControl, kControlStaticTextCFStringTag, implementation::localize_to_cfstring(name).get()); } /****************************************************************************************************/ } // namespace implementation /****************************************************************************************************/ ADOBE_WIDGET_TAG_BOILERPLATE(adobe::label_t::implementation_t, "<xstr id='metric:label'/>"); /****************************************************************************************************/ #if 0 ::OSStatus label_hit_handler_t::handle_event(::EventHandlerCallRef next, ::EventRef event) { if (user_data_m.empty()) return eventNotHandledErr; ::UInt32 modifiers; implementation::get_event_parameter<kEventParamKeyModifiers>(event, modifiers); user_data_m(implementation::convert_modifiers(modifiers)); return noErr; } #endif /****************************************************************************************************/ label_t::implementation_t::implementation_t(const std::string& name, std::size_t characters, theme_t theme) : characters_m(0) #if 0 , hit_handler_m(*this) #endif { ::Rect bounds = { 0, 0, 2048, 2048 }; ADOBE_REQUIRE_STATUS(::CreateStaticTextControl( 0, &bounds, implementation::localize_to_cfstring(name).get(), NULL, &control_m)); implementation::set_theme(*this, theme); } /****************************************************************************************************/ label_t::implementation_t::implementation_t(const implementation_t& rhs) : characters_m(rhs.characters_m) #if 0 , hit_handler_m(*this) #endif { ::Rect bounds = { 0 }; implementation::get_bounds(rhs.control_m, bounds); ADOBE_REQUIRE_STATUS(::CreateStaticTextControl( 0, &bounds, implementation::string_to_cfstring(implementation::get_name(rhs)).get(), NULL, &control_m)); implementation::set_theme(*this, rhs.theme_m); } /****************************************************************************************************/ label_t::implementation_t& label_t::implementation_t::operator= (const implementation_t& rhs) { if (control_m) ::DisposeControl(control_m); ::Rect bounds = { 0 }; implementation::get_bounds(rhs.control_m, bounds); ADOBE_REQUIRE_STATUS(::CreateStaticTextControl( 0, &bounds, implementation::string_to_cfstring(implementation::get_name(rhs)).get(), NULL, &control_m)); implementation::set_theme(*this, rhs.theme_m); return *this; } /****************************************************************************************************/ extents_t::slice_t label_t::implementation_t::measure_horizontal() { assert(control_m); adobe::extents_t result; ::CFStringRef cfstring; ::Point io_bounds = { 0 }; ::SInt16 out_baseline(0); adobe::implementation::set_metric_extractor(*this); implementation::get_widget_data(control_m, kControlEntireControl, kControlStaticTextCFStringTag, cfstring); adobe::auto_resource< ::CFStringRef > auto_cfstring(cfstring); ::ADOBE_REQUIRE_STATUS(::GetThemeTextDimensions( cfstring, implementation::theme_to_ThemeFontID(theme_m), kThemeStateActive, false, &io_bounds, &out_baseline)); result.width() = io_bounds.h; result = implementation::apply_fudges(*this, result); return result.horizontal(); } /****************************************************************************************************/ extents_t::slice_t label_t::implementation_t::measure_vertical(const extents_t::slice_t& horizontal) { assert(control_m); ::Rect static_bounds = { 0, 0, 10, static_cast<short>(horizontal.length_m) }; implementation::set_bounds(control_m, static_bounds); adobe::extents_t result(implementation::measure(*this)); result = implementation::apply_fudges(*this, result); return result.vertical(); } /****************************************************************************************************/ #if 0 void label_t::implementation_t::signal_hit(const implementation::label_hit_proc_t& proc) { assert(control_m); hit_handler_m.set_user_data(proc); hit_handler_m.install(control_m); } #endif /****************************************************************************************************/ template <> ::HIViewRef view_for_element< ::HIViewRef, adobe::label_t >(adobe::label_t& widget) { return widget.implementation().control_m; } /****************************************************************************************************/ template <> \ display_t::position_t insert<adobe::label_t>(display_t& display, display_t::position_t& parent, adobe::label_t& element) { ::HIViewRef ref(adobe::view_for_element< ::HIViewRef >(element)); return display.insert<HIViewRef>(parent, ref); } /****************************************************************************************************/ } // namespace adobe /****************************************************************************************************/ |