|
From: Foster B. <fos...@us...> - 2005-03-31 22:50:58
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/visual/sources/mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10117/sources/mac Modified Files: main.cpp ui_core_implementation.cpp Log Message: began new mac metrics work Index: main.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/visual/sources/mac/main.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** main.cpp 30 Mar 2005 17:14:56 -0000 1.5 --- main.cpp 31 Mar 2005 22:50:43 -0000 1.6 *************** *** 345,348 **** --- 345,353 ---- InitCursor(); + // + // Register this app as an Appearance Client + // + RegisterAppearanceClient(); + return true; } Index: ui_core_implementation.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/visual/sources/mac/ui_core_implementation.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ui_core_implementation.cpp 31 Mar 2005 18:51:01 -0000 1.5 --- ui_core_implementation.cpp 31 Mar 2005 22:50:44 -0000 1.6 *************** *** 27,30 **** --- 27,34 ---- /****************************************************************************************************/ + namespace adobe { + + /****************************************************************************************************/ + /* REVIST (sparent) : Need to file a bug report on this with Apple. Our default bounds is large *************** *** 33,42 **** are effected even if they are outside the group. */ - namespace adobe { - const Rect initial_bounds_g = { 0, 0, 2048, 2048 }; const CGRect cg_initial_bounds_g = ::CGRectMake(0, 0, 2048, 2048); ! } /****************************************************************************************************/ --- 37,46 ---- are effected even if they are outside the group. */ const Rect initial_bounds_g = { 0, 0, 2048, 2048 }; const CGRect cg_initial_bounds_g = ::CGRectMake(0, 0, 2048, 2048); ! /****************************************************************************************************/ ! ! } // namespace adobe /****************************************************************************************************/ *************** *** 52,55 **** --- 56,144 ---- /****************************************************************************************************/ + #if 0 + #pragma mark - + #endif + + /****************************************************************************************************/ + + inline long theme_metric(ThemeMetric metric) + { + SInt32 value(0); + + ::GetThemeMetric(metric, &value); + + return value; + } + + /****************************************************************************************************/ + + template <typename T> + adobe::rectangle_t widget_metrics(adobe::theme_t /*theme*/) + { return adobe::rectangle_t(); } + + /****************************************************************************************************/ + + template <> + adobe::rectangle_t widget_metrics<adobe::checkbox_t::implementation_t>(adobe::theme_t theme) + { + adobe::rectangle_t result; + + theme &= adobe::theme_mask_s; + + if (theme == adobe::theme_mini_s) + { + result.width() += theme_metric(kThemeMetricMiniCheckBoxWidth); + + result.height() += theme_metric(kThemeMetricMiniCheckBoxHeight); + } + else if (theme == adobe::theme_small_s) + { + result.width() += theme_metric(kThemeMetricSmallCheckBoxWidth); + + result.height() += theme_metric(kThemeMetricSmallCheckBoxHeight); + } + else // if (theme == adobe::theme_normal_s) + { + result.width() += theme_metric(kThemeMetricCheckBoxWidth); + + result.height() += theme_metric(kThemeMetricCheckBoxHeight); + } + + return result; + } + + /****************************************************************************************************/ + + std::string get_control_title(ControlRef control); + adobe::rectangle_t get_text_dimensions(const std::string& text, adobe::theme_t theme); + + /****************************************************************************************************/ + + template <typename T> + adobe::rectangle_t widget_measurement(const T& widget) + { + std::string name(get_control_title(widget.control_m)); + adobe::rectangle_t result(widget_metrics<T>(widget.theme_m)); + adobe::rectangle_t text(get_text_dimensions(name, widget.theme_m)); + + result.width() += text.width(); + + if (name.size()) + result.width() += gap; + + adobe::copy( text.slice_m[adobe::rectangle_slices_t::vertical].poi_m, + std::back_inserter(result.slice_m[adobe::rectangle_slices_t::vertical].poi_m)); + + return result; + } + + /****************************************************************************************************/ + + #if 0 + #pragma mark - + #endif + + /****************************************************************************************************/ + std::string cfstring_to_string(CFStringRef x) { *************** *** 316,324 **** geometry.slice_m[adobe::rectangle_slices_t::horizontal].length_m += fudges.left() + fudges.right(); ! // why did we do this? ! //geometry.slice_m[adobe::rectangle_slices_t::vertical].outset_m.first += fudges.top(); ! //geometry.slice_m[adobe::rectangle_slices_t::vertical].outset_m.second -= fudges.bottom() + fudges.top(); ! //geometry.slice_m[adobe::rectangle_slices_t::horizontal].outset_m.first += fudges.left(); ! //geometry.slice_m[adobe::rectangle_slices_t::horizontal].outset_m.second -= fudges.right() + fudges.left(); adobe::points_of_interest_t& poi(geometry.slice_m[adobe::rectangle_slices_t::vertical].poi_m); --- 405,414 ---- geometry.slice_m[adobe::rectangle_slices_t::horizontal].length_m += fudges.left() + fudges.right(); ! #if 0 ! geometry.slice_m[adobe::rectangle_slices_t::vertical].outset_m.first += fudges.top(); ! geometry.slice_m[adobe::rectangle_slices_t::vertical].outset_m.second -= fudges.bottom() + fudges.top(); ! geometry.slice_m[adobe::rectangle_slices_t::horizontal].outset_m.first += fudges.left(); ! geometry.slice_m[adobe::rectangle_slices_t::horizontal].outset_m.second -= fudges.right() + fudges.left(); ! #endif adobe::points_of_interest_t& poi(geometry.slice_m[adobe::rectangle_slices_t::vertical].poi_m); *************** *** 333,337 **** position.second -= fudges.top(); position.first -= fudges.left(); ! geometry.height() -= fudges.bottom(); geometry.width() -= fudges.right(); --- 423,427 ---- position.second -= fudges.top(); position.first -= fudges.left(); ! geometry.height() -= fudges.bottom(); geometry.width() -= fudges.right(); *************** *** 2308,2313 **** assert(control_m); ! point_t position(pos); ! rectangle_t geometry(geo); shed_fudges(position, geometry, fudges_m); --- 2398,2403 ---- assert(control_m); ! point_t position(pos); ! rectangle_t geometry(geo); shed_fudges(position, geometry, fudges_m); *************** *** 2348,2351 **** --- 2438,2461 ---- set_widget_data(control_m, kControlEntireControl, kControlFontStyleTag, new_style, false); + + #if 0 + try + { + ControlSize control_size(kControlSizeNormal); + + switch ( theme & theme_mask_s ) + { + case theme_large_s: control_size = kControlSizeLarge; break; + //case theme_normal_s: control_size = kControlSizeNormal; break; + case theme_small_s: control_size = kControlSizeSmall; break; + case theme_mini_s: control_size = kControlSizeMini; break; + } + + // could throw -- we don't care + set_widget_data(control_m, kControlEntireControl, kControlSizeTag, control_size); + } + catch (...) + { } + #endif } *************** *** 3083,3088 **** { assert(control_m); ! ! rectangle_t result(_super::best_bounds()); if (get_control_title(control_m).empty()) --- 3193,3200 ---- { assert(control_m); ! #if 0 ! return widget_measurement(*this); ! #else ! rectangle_t result(_super::best_bounds()); if (get_control_title(control_m).empty()) *************** *** 3097,3101 **** temp.set_theme(theme_m); ! rectangle_t result2(temp.best_bounds()); points_of_interest_t& dst_poi(result.slice_m[rectangle_slices_t::vertical].poi_m); --- 3209,3213 ---- temp.set_theme(theme_m); ! rectangle_t result2(temp.best_bounds()); points_of_interest_t& dst_poi(result.slice_m[rectangle_slices_t::vertical].poi_m); *************** *** 3109,3112 **** --- 3221,3225 ---- return result; + #endif } |