From: Foster B. <fos...@us...> - 2005-03-29 23:29:49
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/visual/sources/win In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1768/adobe-source/adobe/test/visual/sources/win Modified Files: ui_core_implementation.cpp Log Message: Link widgets / tab groups / ASL 1.0.2 prep; other bugs fixed Index: ui_core_implementation.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/visual/sources/win/ui_core_implementation.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ui_core_implementation.cpp 28 Mar 2005 19:33:27 -0000 1.4 --- ui_core_implementation.cpp 29 Mar 2005 23:29:39 -0000 1.5 *************** *** 283,296 **** /****************************************************************************************************/ - long get_control_value(HWND control) - { - if (!control) return 0; - - return -1; - //return ::GetControl32BitValue(control); - } - - /****************************************************************************************************/ - std::string get_popup_current_text(HWND popup) { --- 283,286 ---- *************** *** 551,554 **** --- 541,545 ---- void set_popup_with_text(HWND control, const std::string& text, unsigned long cur_time) { + assert(control); } *************** *** 603,627 **** /****************************************************************************************************/ - void set_control_min_value(HWND control, long value) - { - assert(control); - } - - /****************************************************************************************************/ - - void set_control_max_value(HWND control, long value) - { - assert(control); - } - - /****************************************************************************************************/ - - void set_control_value(HWND control, long value) - { - assert(control); - } - - /****************************************************************************************************/ - template <typename T> void set_user_reference(HWND control, T data) --- 594,597 ---- *************** *** 655,714 **** /****************************************************************************************************/ ! void draw_link(HWND control, boost::int16_t) { try { static const long link_line_width(2); ! #if 0 ! adobe::link_t::implementation_t& link(*reinterpret_cast<adobe::link_t::implementation_t*>(get_user_reference(control))); ! ! RECT bounds = { 0 }; ! HWND our_window(::GetControlOwner(control)); ! CGrafPtr window_port(::GetWindowPort(our_window)); long num_prongs(link.prongs_m.size()); ! RECT window_bounds = { 0 }; ! CGContextRef context(0); point_set_t points; std::string link_icon_name("link_icon.png"); - CFBundleRef main_bundle(::CFBundleGetMainBundle()); - CFURLRef resource_bundle_url(::CFBundleCopyResourcesDirectoryURL(main_bundle)); - CFURLRef url_to_png(::CFURLCreateFromFileSystemRepresentationRelativeToBase(0, reinterpret_cast<const UInt8*>(link_icon_name.c_str()), link_icon_name.size(), false, resource_bundle_url)); - CGDataProviderRef data_ref_to_png(::CGDataProviderCreateWithURL(url_to_png)); - CGImageRef link_icon(::CGImageCreateWithPNGDataProvider(data_ref_to_png, 0, true, kCGRenderingIntentSaturation)); ! ::GetWindowBounds(our_window, kWindowContentRgn, &window_bounds); ! get_control_bounds(control, bounds); ! ! ADOBE_REQUIRE_STATUS(::QDBeginCGContext(window_port, &context)); ! ! ::CGContextTranslateCTM(context, 0, window_bounds.bottom - window_bounds.top - 1); ! ::CGContextScaleCTM(context, 1.0, -1.0); ! ::CGContextSetLineWidth(context, link_line_width); ! ::CGContextSetShouldAntialias(context, false); ! ! ::CGContextBeginPath(context); // REVISIT (sparent) : If this were aligned top instead of fill then the hieght _should_ be correct. // REVISIT (sparent) : We should require up front (and default) to a count of 2. ! ::CGContextSetRGBFillColor(context, 0, 0, 0, 1); // REVISIT (sparent) FIXED VALUE bounds.right -= 6; // inset the rect a bit to create padding for the link icon ! if (::IsControlEnabled(control) && num_prongs > 1) { for (std::size_t i(0); i < num_prongs; ++i) { ! ::CGContextFillRect(context, ::CGRectMake( bounds.left, ! bounds.top + link.prongs_m[i] - link_line_width - 1, ! bounds.right - bounds.left, ! link_line_width)); } ! ::CGContextFillRect(context, ::CGRectMake( bounds.right, ! bounds.top + link.prongs_m[0] - link_line_width - 1, ! link_line_width, ! link.prongs_m[num_prongs - 1] - link.prongs_m[0] + link_line_width)); bounds.right += 2; // reset inset for the link icon --- 625,677 ---- /****************************************************************************************************/ ! void draw_link(const adobe::link_t::implementation_t& link, HDC context) { try { static const long link_line_width(2); ! HWND parent(::GetAncestor(link.control_m, GA_ROOT)); long num_prongs(link.prongs_m.size()); ! RECT bounds = { 0 }; point_set_t points; std::string link_icon_name("link_icon.png"); ! ::GetClientRect(link.control_m, &bounds); // REVISIT (sparent) : If this were aligned top instead of fill then the hieght _should_ be correct. // REVISIT (sparent) : We should require up front (and default) to a count of 2. ! HPEN pen(::CreatePen(PS_SOLID, 1, RGB(0, 0, 0))); ! HPEN old_pen((HPEN) SelectObject(context, pen)); // REVISIT (sparent) FIXED VALUE bounds.right -= 6; // inset the rect a bit to create padding for the link icon ! if (::IsWindowEnabled(link.control_m) && num_prongs > 1) { for (std::size_t i(0); i < num_prongs; ++i) { ! long top(bounds.top + link.prongs_m[i] - link_line_width); ! ! RECT fill_rect = ! { ! bounds.left, ! top, ! bounds.right, ! top + link_line_width ! }; ! ! ::FillRect(context, &fill_rect, (HBRUSH) ::GetStockObject(BLACK_BRUSH)); } ! // link spine ! RECT fill_rect = ! { ! bounds.right, ! bounds.top + link.prongs_m[0] - link_line_width, ! bounds.right + link_line_width, ! link.prongs_m[num_prongs - 1] - link.prongs_m[0] + 1 * link_line_width ! }; ! ! ::FillRect(context, &fill_rect, (HBRUSH) ::GetStockObject(BLACK_BRUSH)); bounds.right += 2; // reset inset for the link icon *************** *** 718,728 **** (link.prongs_m[num_prongs - 1] - link.prongs_m[0]) / 2; ! ::CGContextDrawImage(context, ::CGRectMake(bounds.right - 5, center - 8, 9, 16), link_icon); } ! ::CGContextSynchronize(context); ! ! ADOBE_REQUIRE_STATUS(::QDEndCGContext(window_port, &context)); ! #endif } catch (...) --- 681,690 ---- (link.prongs_m[num_prongs - 1] - link.prongs_m[0]) / 2; ! // draw link icon here at { bounds.right - 5, center - 8, 9, 16 } } ! // clean up pen work ! SelectObject(context, old_pen); ! DeleteObject(pen); } catch (...) *************** *** 800,804 **** #if 0 adobe::hitless_t::implementation_t& hitless(*reinterpret_cast<adobe::hitless_t::implementation_t*>(::get_user_reference(control))); ! HWND window(hitless.overlay_window_m); CGrafPtr window_port(::GetWindowPort(window)); CGContextRef context(0); --- 762,766 ---- #if 0 adobe::hitless_t::implementation_t& hitless(*reinterpret_cast<adobe::hitless_t::implementation_t*>(::get_user_reference(control))); ! HWND window(hitless.overlay_window_m); CGrafPtr window_port(::GetWindowPort(window)); CGContextRef context(0); *************** *** 867,872 **** RECT top_left_rect = { left, top, left + tick_width, top + tick_height }; RECT top_right_rect = { tick_start_right, top, tick_start_right + tick_width, top + tick_height }; ! RECT bottom_left_rect = { left, tick_start_bottom, left + tick_width, tick_start_bottom + tick_height }; ! RECT bottom_right_rect = { tick_start_right, tick_start_bottom, tick_start_right + tick_width, tick_start_bottom + tick_height }; frame_set.push_back(de_t(de_t::element_type_top_left, top_left_rect, green)); --- 829,834 ---- RECT top_left_rect = { left, top, left + tick_width, top + tick_height }; RECT top_right_rect = { tick_start_right, top, tick_start_right + tick_width, top + tick_height }; ! RECT bottom_left_rect = { left, tick_start_bottom + 1, left + tick_width + 1, tick_start_bottom + tick_height }; ! RECT bottom_right_rect = { tick_start_right - 1, tick_start_bottom + 1, tick_start_right + tick_width, tick_start_bottom + tick_height }; frame_set.push_back(de_t(de_t::element_type_top_left, top_left_rect, green)); *************** *** 918,938 **** /****************************************************************************************************/ - void slider_action(HWND control) - { - adobe::slider_t::implementation_t& slider_impl(*reinterpret_cast<adobe::slider_t::implementation_t*>(get_user_reference(control))); - - try - { - if (slider_impl.value_proc_m) - slider_impl.value_proc_m(get_control_value(slider_impl.control_m)); - } - catch (...) - { - adobe::report_exception(); - } - } - - /****************************************************************************************************/ - void erase_menu(HWND combo_box) { --- 880,883 ---- *************** *** 1144,1147 **** --- 1089,1107 ---- } } + else if ( message == WM_NOTIFY ) + { + NMHDR* notice((NMHDR*) lParam); + HWND control_hwnd(notice->hwndFrom); + control_t* control(reinterpret_cast<control_t*>(get_user_reference(control_hwnd))); + tab_group_t::implementation_t* tab_group(dynamic_cast<tab_group_t::implementation_t*>(control)); + + if (notice->code == TCN_SELCHANGE && tab_group) + { + long index(::SendMessage(control_hwnd, TCM_GETCURSEL, 0, 0)); + + if (!tab_group->value_proc_m.empty()) + tab_group->value_proc_m(tab_group->items_m[index].value_m); + } + } #if 0 // Do we really need to add a set focus handler in every widget dialog handling proc? yuck. *************** *** 1620,1650 **** /****************************************************************************************************/ - void control_t::set_min_value(long value) - { - assert(control_m); - - set_control_min_value(control_m, value); - } - - /****************************************************************************************************/ - - void control_t::set_max_value(long value) - { - assert(control_m); - - set_control_max_value(control_m, value); - } - - /****************************************************************************************************/ - - void control_t::set_value(long value) - { - assert(control_m); - - set_control_value(control_m, value); - } - - /****************************************************************************************************/ - void control_t::trap_window_proc(WNDPROC new_window_proc) { --- 1580,1583 ---- *************** *** 1766,1769 **** --- 1699,1717 ---- /****************************************************************************************************/ + LRESULT CALLBACK tab_group_window_proc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) + { + control_t* control(reinterpret_cast<control_t*>(get_user_reference(window))); + tab_group_t::implementation_t* tab_group(dynamic_cast<tab_group_t::implementation_t*>(control)); + bool handled(false); + + LRESULT result = handled ? 0 : ::CallWindowProc( control->default_window_proc_m, window, message, wParam, lParam ); + + if (control && message == WM_PAINT) frame_widget(*control); + + return result; + } + + /****************************************************************************************************/ + tab_group_t::implementation_t::implementation_t() { *************** *** 1790,1818 **** assert (!control_m); ! #if 0 ! ControlTabSize size(kControlSizeNormal); ! ControlTabDirection direction(kControlTabDirectionNorth); ! long group_value(0); ! ADOBE_REQUIRE_STATUS(::CreateTabsControl( 0, &bounds, ! size, direction, ! 0, NULL, &control_m)); for (; first != last; ++first) { ! auto_resource<CFStringRef> cfstring(string_to_cfstring(first->name_m).release()); ! ControlTabInfoRecV1 new_tab = ! { ! kControlTabInfoVersionOne, ! 0, cfstring.get() ! }; ! items_m.push_back(*first); ! set_control_max_value(control_m, ++group_value); ! set_widget_data(control_m, group_value, kControlTabInfoTag, new_tab); } - #endif } --- 1738,1771 ---- assert (!control_m); ! long width(bounds.right - bounds.left); ! long height(bounds.bottom - bounds.top); ! control_m = ::CreateWindowEx( 0, ! WC_TABCONTROL, ! NULL, ! WS_POPUP | WS_VISIBLE, ! 0, 0, width, height, ! NULL, ! NULL, ! ::GetModuleHandle(NULL), ! NULL); ! ! if (control_m == NULL) ADOBE_THROW_LAST_ERROR; ! ! set_user_reference(control_m, this); ! ! trap_window_proc(tab_group_window_proc); for (; first != last; ++first) { ! TCITEM item = { TCIF_TEXT }; ! item.pszText = (LPSTR) first->name_m.c_str(); ! item.cchTextMax = first->name_m.size(); ! ::SendMessage(control_m, TCM_INSERTITEM, ::SendMessage(control_m, TCM_GETITEMCOUNT, 0, 0), (LPARAM) &item); ! items_m.push_back(*first); } } *************** *** 1826,1836 **** theme_t masked(theme & theme_mask_s); - - // ControlSize size = kControlSizeLarge; - // if (masked == theme_normal_s) size = kControlSizeNormal; - // else if (masked == theme_small_s) size = kControlSizeSmall; - // else if (masked == theme_mini_s) size = kControlSizeMini; - - //set_widget_data(control_m, kControlEntireControl, kControlSizeTag, size); } --- 1779,1782 ---- *************** *** 1845,1849 **** // REVISIT (fbrereto) : Static values ! result.height() = 20; result.slice_m[rectangle_slices_t::vertical].frame_m.first = 20; --- 1791,1795 ---- // REVISIT (fbrereto) : Static values ! result.height() = 15; result.slice_m[rectangle_slices_t::vertical].frame_m.first = 20; *************** *** 1856,1865 **** { assert(control_m); ! tab_set_t::iterator iter(adobe::find_match(items_m, new_value, adobe::compare_members(&tab_t::value_m, std::equal_to<adobe::value_t>()))); ! if (iter == items_m.end()) return; ! ! set_control_value(control_m, (iter - items_m.begin()) + 1); } --- 1802,1811 ---- { assert(control_m); ! tab_set_t::iterator iter(adobe::find_match(items_m, new_value, adobe::compare_members(&tab_t::value_m, std::equal_to<adobe::value_t>()))); ! if (iter == items_m.end()) return; ! ! ::SendMessage(control_m, TCM_SETCURSEL, iter - items_m.begin(), 0); } *************** *** 1871,1881 **** if (!value_proc_m) - { value_proc_m = proc; - - // handle_event( control_m, kEventClassControl, - // kEventControlValueFieldChanged, - // handle_tab_group_value_change, *this); - } } --- 1817,1821 ---- *************** *** 1916,1919 **** --- 1856,1873 ---- /****************************************************************************************************/ + LRESULT CALLBACK panel_window_proc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) + { + control_t* control(reinterpret_cast<control_t*>(get_user_reference(window))); + bool handled(false); + + LRESULT result = handled ? 0 : ::CallWindowProc( control->default_window_proc_m, window, message, wParam, lParam ); + + if (control && message == WM_PAINT) frame_widget(*control); + + return result; + } + + /****************************************************************************************************/ + panel_t::implementation_t::implementation_t() { *************** *** 1937,1946 **** { assert(!control_m); ! #if 0 ! ADOBE_REQUIRE_STATUS(::CreateUserPaneControl( 0, &bounds, ! kControlSupportsEmbedding, ! &control_m)); ! #endif set_user_reference(control_m, this); } --- 1891,1913 ---- { assert(!control_m); ! ! long width(bounds.right - bounds.left); ! long height(bounds.bottom - bounds.top); ! ! control_m = ::CreateWindowEx( WS_EX_CONTROLPARENT, ! "STATIC", ! NULL, ! WS_POPUP | WS_VISIBLE | WS_TABSTOP, ! bounds.left, bounds.top, width, height, ! NULL, ! NULL, ! ::GetModuleHandle(NULL), ! NULL); ! ! if (control_m == NULL) ADOBE_THROW_LAST_ERROR; ! set_user_reference(control_m, this); + + trap_window_proc(panel_window_proc); } *************** *** 1973,1979 **** LRESULT result = handled ? 0 : ::CallWindowProc( control->default_window_proc_m, window, message, wParam, lParam ); - #if 1 if (control && message == WM_PAINT) frame_widget(*control); - #endif return result; --- 1940,1944 ---- *************** *** 2183,2189 **** LRESULT result = handled ? 0 : ::CallWindowProc( control->default_window_proc_m, window, message, wParam, lParam ); - #if 1 if (control && message == WM_PAINT) frame_widget(*control); - #endif return result; --- 2148,2152 ---- *************** *** 2331,2337 **** LRESULT result = handled ? 0 : ::CallWindowProc( control->default_window_proc_m, window, message, wParam, lParam ); - #if 1 if (control && message == WM_PAINT) frame_widget(*control); - #endif return result; --- 2294,2298 ---- *************** *** 2470,2473 **** --- 2431,2482 ---- /****************************************************************************************************/ + LRESULT CALLBACK link_window_proc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) + { + control_t* control(reinterpret_cast<control_t*>(get_user_reference(window))); + link_t::implementation_t* link(dynamic_cast<link_t::implementation_t*>(control)); + bool handled(false); + + if ( message == WM_NCHITTEST ) + { + handled = true; + + return HTCLIENT; + } + else if ( message == WM_LBUTTONDOWN ) + { + if ( link ) + { + link->hit_proc_m(modifiers_t()); + } + + #if 1 + RECT bounds; + + ::GetClientRect(window, &bounds); + + ::InvalidateRect(window, &bounds, TRUE); + + ::UpdateWindow(window); + #endif + + handled = true; + } + + LRESULT result = handled ? 0 : ::CallWindowProc( control->default_window_proc_m, window, message, wParam, lParam ); + + if (control && message == WM_PAINT) + { + HDC context(::GetWindowDC(control->control_m)); + + draw_link(*link, context); + + frame_widget(*control); // Done after the default wind proc has drawn the widget + } + + return result; + } + + /****************************************************************************************************/ + link_t::implementation_t::implementation_t() : value_m(true), visible_m(true), active_m(true) *************** *** 2498,2502 **** control_m = ::CreateWindow( "STATIC", NULL, ! WS_POPUP | WS_VISIBLE, bounds.left, bounds.top, width, height, NULL, --- 2507,2511 ---- control_m = ::CreateWindow( "STATIC", NULL, ! WS_POPUP, bounds.left, bounds.top, width, height, NULL, *************** *** 2508,2511 **** --- 2517,2522 ---- set_user_reference(control_m, this); + + trap_window_proc(link_window_proc); } *************** *** 2564,2573 **** if (!hit_proc_m) - { hit_proc_m = proc; - - //handle_event( control_m, kEventClassControl, kEventControlClick, - // handle_control_hit<implementation_t>, *this); - } } --- 2575,2579 ---- *************** *** 2660,2663 **** --- 2666,2687 ---- /****************************************************************************************************/ + void progress_bar_t::implementation_t::set_min_value(long min_value) + { + } + + /****************************************************************************************************/ + + void progress_bar_t::implementation_t::set_max_value(long max_value) + { + } + + /****************************************************************************************************/ + + void progress_bar_t::implementation_t::set_value(long value) + { + } + + /****************************************************************************************************/ + dictionary_t progress_bar_t::implementation_t::essentials() const { *************** *** 2754,2760 **** LRESULT result = handled ? 0 : ::CallWindowProc( control->default_window_proc_m, window, message, wParam, lParam ); - #if 1 if (control && message == WM_PAINT) frame_widget(*control); - #endif return result; --- 2778,2782 ---- *************** *** 2913,2919 **** } - #if 1 if (control && message == WM_PAINT) frame_widget(*control); - #endif return result; --- 2935,2939 ---- *************** *** 3285,3291 **** LRESULT result = handled ? 0 : ::CallWindowProc( control->default_window_proc_m, window, message, wParam, lParam ); - #if 1 if (control && message == WM_PAINT) frame_widget(*control); - #endif return result; --- 3305,3309 ---- *************** *** 3919,3922 **** --- 3937,3958 ---- /****************************************************************************************************/ + void slider_t::implementation_t::set_min_value(long min_value) + { + } + + /****************************************************************************************************/ + + void slider_t::implementation_t::set_max_value(long max_value) + { + } + + /****************************************************************************************************/ + + void slider_t::implementation_t::set_value(long value) + { + } + + /****************************************************************************************************/ + void slider_t::implementation_t::signal_value_change(const implementation::slider_value_proc_t& proc) { |