|
From: Ralph T. <ra...@us...> - 2005-04-10 01:24:46
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/visual/sources/win In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24636/adobe-source/adobe/test/visual/sources/win Modified Files: metrics.cpp ui_core_implementation.cpp Log Message: multiline edit_text_t now works on Win32! I *think* that means that Windows now has all of the required widgets for Adobe Begin as it currently stands. This check-in changes the ui-core interface. I have removed the set_row_col_count function from edit_text_t. It made a Win32 implementation very hard, as you cannot go between a single- and multi-line edit control on Windows (at least, not without destroying the control and creating a new one, which is a hack). This change meant that changes had to be made to the Mac ui-core implementation. Index: metrics.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/test/visual/sources/win/metrics.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** metrics.cpp 8 Apr 2005 21:03:50 -0000 1.4 --- metrics.cpp 10 Apr 2005 01:24:36 -0000 1.5 *************** *** 130,133 **** --- 130,138 ---- return true; } + if ((widget_type == EP_EDITTEXT) && (measurement == TMT_BORDERSIZE)) + { + out_val = 1; + return true; + } out_val = 0; return false; 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.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ui_core_implementation.cpp 8 Apr 2005 21:03:50 -0000 1.13 --- ui_core_implementation.cpp 10 Apr 2005 01:24:36 -0000 1.14 *************** *** 811,819 **** /// /// \param control the HWND of the edit control to obtain the best bounds for. ! /// \param extents the largest extents this edit control must contain. /// /// \return the best bounds for the edit control, including baseline. // ! ::adobe::rectangle_t calculate_edit_bounds(HWND control, RECT extents) { ::adobe::rectangle_t result; --- 811,820 ---- /// /// \param control the HWND of the edit control to obtain the best bounds for. ! /// \param cols the number of columns (or characters across) the edit control should contain ! /// \param rows the number of rows of text to contain. /// /// \return the best bounds for the edit control, including baseline. // ! ::adobe::rectangle_t calculate_edit_bounds(HWND control, int cols, int rows) { ::adobe::rectangle_t result; *************** *** 841,852 **** // TEXTMETRIC font_metrics; if (!::adobe::metrics_t::get_instance().set_window(control)) return result; if (!::adobe::metrics_t::get_instance().get_font_metrics(EP_EDITTEXT, font_metrics)) return result; // ! // Now we can calculate the rectangle! // ! result.height() = em_rect.bottom + (wi.rcClient.top - wi.rcWindow.top) + (wi.rcWindow.bottom - wi.rcClient.bottom); result.width() = (extents.right - extents.left) + (wi.rcClient.left - wi.rcWindow.left) + (wi.rcWindow.right - wi.rcClient.right); ! result.slice_m[::adobe::rectangle_slices_t::vertical].poi_m.push_back((wi.rcClient.top - wi.rcWindow.top) + font_metrics.tmAscent); return result; } --- 842,861 ---- // TEXTMETRIC font_metrics; + RECT extents = {0, 0, 0, 0}; + int border = 0; if (!::adobe::metrics_t::get_instance().set_window(control)) return result; + if (!::adobe::metrics_t::get_instance().get_text_extents(EP_EDITTEXT, std::wstring(L"0", cols), extents)) return result; if (!::adobe::metrics_t::get_instance().get_font_metrics(EP_EDITTEXT, font_metrics)) return result; + if (!::adobe::metrics_t::get_instance().get_integer(EP_EDITTEXT, TMT_BORDERSIZE, border)) return result; // ! // Now we can calculate the rectangle: // ! // Height: Top border + Bottom border + (rows * text height) + vertical text offset ! // Width : Left border + Right border + text extent ! // Baseline: Top border + font ascent + one if this has multiple lines... ! // ! result.height() = (wi.rcClient.top - wi.rcWindow.top) + (wi.rcWindow.bottom - wi.rcClient.bottom) + (rows * font_metrics.tmHeight) + em_rect.top + border; result.width() = (extents.right - extents.left) + (wi.rcClient.left - wi.rcWindow.left) + (wi.rcWindow.right - wi.rcClient.right); ! result.slice_m[::adobe::rectangle_slices_t::vertical].poi_m.push_back((wi.rcClient.top - wi.rcWindow.top) + font_metrics.tmAscent + border); return result; } *************** *** 1161,1165 **** if (b) DeleteObject(b); } ! else if ((message == WM_CTLCOLORSTATIC) || (message == WM_CTLCOLOREDIT)) { // --- 1170,1174 ---- if (b) DeleteObject(b); } ! else if (message == WM_CTLCOLORSTATIC) { // *************** *** 3052,3056 **** get_control_bounds(rhs.control_m, bounds); ! initialize(bounds, get_control_string(name_m), scrollable_m); } --- 3061,3065 ---- get_control_bounds(rhs.control_m, bounds); ! initialize(bounds, get_control_string(name_m), scrollable_m, cols_m, rows_m); } *************** *** 3063,3069 **** /****************************************************************************************************/ ! void edit_text_t::implementation_t::initialize( const RECT& bounds, ! const std::string& name, ! bool scrollable) { assert(!control_m); --- 3072,3080 ---- /****************************************************************************************************/ ! void edit_text_t::implementation_t::initialize( const RECT& bounds, ! const std::string& name, ! bool scrollable, ! long cols, ! long rows) { assert(!control_m); *************** *** 3076,3091 **** scrollable_m = scrollable; using_label_m = !name.empty(); ! ! if (scrollable) ! { ! } ! else ! { ! } control_m = ::CreateWindowEx( WS_EX_COMPOSITED | WS_EX_CLIENTEDGE, "EDIT", NULL, ! WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_AUTOVSCROLL | WS_TABSTOP, bounds.left, bounds.top, width, height, invisible_parent_m, --- 3087,3097 ---- scrollable_m = scrollable; using_label_m = !name.empty(); ! cols_m = cols; ! rows_m = rows; control_m = ::CreateWindowEx( WS_EX_COMPOSITED | WS_EX_CLIENTEDGE, "EDIT", NULL, ! get_window_style(), bounds.left, bounds.top, width, height, invisible_parent_m, *************** *** 3117,3128 **** assert(control_m); // ! // In order to calculate the best bounds we have to get the extents of our ! // text. We actually take the extents of "0", because we don't know the text ! // yet. // ! RECT extents = {0, 0, 0, 0}; ! metrics_t::get_instance().set_window(control_m); ! metrics_t::get_instance().get_text_extents(uxtheme_type_m, std::wstring(L"0", cols_m), extents); ! rectangle_t result = calculate_edit_bounds(control_m, extents); // // Store the height and baseline so that we can correctly align the edit widget --- 3123,3130 ---- assert(control_m); // ! // The calculate_edit_bounds function can figure out the size this edit box ! // should be, based on the number of rows and columns. // ! rectangle_t result = calculate_edit_bounds(control_m, cols_m, rows_m); // // Store the height and baseline so that we can correctly align the edit widget *************** *** 3289,3302 **** /****************************************************************************************************/ - void edit_text_t::implementation_t::set_row_col_count(long columns, long rows) - { - assert(control_m); - - cols_m = columns; - rows_m = rows; - } - - /****************************************************************************************************/ - void edit_text_t::implementation_t::set_selection(long start_char, long end_char) { --- 3291,3294 ---- *************** *** 3335,3338 **** --- 3327,3358 ---- /****************************************************************************************************/ + long edit_text_t::implementation_t::get_window_style() const + { + // + // Make it so that the edit box automatically scrolls when the + // user types beyond the visible region or clicks and drags + // inside the text box. + // + // The NoHideSel(ection) flag tells windows to make sure that + // the any selection in an edit is always visible -- not just + // when the edit control has focus. + // + long edit_style = ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_NOHIDESEL; + // + // We can set the ES_MULTILINE style if we have multiple rows. + // The ES_WANTRETURN flag tells the edit control to interpret + // the return key as a newline/return, rather than to tell the + // parent window about it. + // + if (rows_m > 1) edit_style |= ES_MULTILINE | ES_WANTRETURN; + // + // The WS_VSCROLL and WS_HSCROLL styles apply to any window. + // + if (scrollable_m) edit_style |= WS_VSCROLL | WS_HSCROLL; + return edit_style | WS_CHILD | WS_TABSTOP | WS_VISIBLE; + } + + /****************************************************************************************************/ + LRESULT edit_text_t::implementation_t::event(UINT message, WPARAM wParam, LPARAM lParam) { *************** *** 3811,3822 **** get_control_bounds(rhs.control_m, bounds); ! initialize(bounds, get_control_string(name_m), using_popup_m); } /****************************************************************************************************/ ! void unit_edit_text_t::implementation_t::initialize(const RECT& bounds, ! const std::string& name, ! bool using_popup) { assert(!control_m); --- 3831,3844 ---- get_control_bounds(rhs.control_m, bounds); ! initialize(bounds, get_control_string(name_m), using_popup_m, cols_m, rows_m); } /****************************************************************************************************/ ! void unit_edit_text_t::implementation_t::initialize( const RECT& bounds, ! const std::string& name, ! bool using_popup, ! long cols, ! long rows) { assert(!control_m); *************** *** 3824,3828 **** using_popup_m = using_popup; ! _super::initialize(bounds, name, false); if (using_popup_m) --- 3846,3850 ---- using_popup_m = using_popup; ! _super::initialize(bounds, name, false, cols, rows); if (using_popup_m) |