X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8300f815fa5f0e9486d14b057ce8fdda5785549b..a78d2fbab115b4c6537349fb06275d1610bf4aa0:/src/msw/wince/textctrlce.cpp diff --git a/src/msw/wince/textctrlce.cpp b/src/msw/wince/textctrlce.cpp index 9fe3ce6394..9d3650ce62 100644 --- a/src/msw/wince/textctrlce.cpp +++ b/src/msw/wince/textctrlce.cpp @@ -6,10 +6,9 @@ // Created: 30.08.2004 // RCS-ID: $Id$ // Copyright: (c) Wlodzimierz Skiba -// License: wxWindows licence +// Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// - // ============================================================================ // declarations // ============================================================================ @@ -18,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "textctrlce.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -29,19 +24,17 @@ #pragma hdrstop #endif +#if wxUSE_TEXTCTRL && defined(__SMARTPHONE__) && defined(__WXWINCE__) + +#include "wx/textctrl.h" + #ifndef WX_PRECOMP - #include "wx/textctrl.h" + #include "wx/msw/wrapcctl.h" // include "properly" #endif #include "wx/spinbutt.h" #include "wx/textfile.h" -#include -#include "wx/msw/missing.h" -#include "wx/msw/winundef.h" - -#if wxUSE_TEXTCTRL && defined(__SMARTPHONE__) && defined(__WXWINCE__) - #define GetBuddyHwnd() (HWND)(m_hwndBuddy) #define IsVertical(wxStyle) (true) @@ -50,12 +43,6 @@ // event tables and other macros // ---------------------------------------------------------------------------- -#if wxUSE_EXTENDED_RTTI -// TODO -#else -IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl) -#endif - BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) EVT_CHAR(wxTextCtrl::OnChar) @@ -167,7 +154,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ; wxSize sizeText(size), sizeBtn(size); - sizeBtn.x = GetBestSpinerSize(IsVertical(style)).x / 2; + sizeBtn.x = GetBestSpinnerSize(IsVertical(style)).x / 2; if ( sizeText.x == wxDefaultCoord ) { @@ -178,7 +165,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, sizeText.x -= sizeBtn.x + MARGIN_BETWEEN; if ( sizeText.x <= 0 ) { - wxLogDebug(_T("not enough space for wxSpinCtrl!")); + wxLogDebug(wxT("not enough space for wxSpinCtrl!")); } wxPoint posBtn(pos); @@ -206,7 +193,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, m_hwndBuddy = (WXHWND)::CreateWindowEx ( exStyle, // sunken border - _T("EDIT"), // window class + wxT("EDIT"), // window class valueWin, // no window title msStyle, // style (will be shown later) pos.x, pos.y, // position @@ -240,7 +227,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, if ( style & wxSP_WRAP ) spiner_style |= UDS_WRAP; - if ( !MSWCreateControl(UPDOWN_CLASS, spiner_style, posBtn, sizeBtn, _T(""), 0) ) + if ( !MSWCreateControl(UPDOWN_CLASS, spiner_style, posBtn, sizeBtn, wxT(""), 0) ) return false; // subclass the text ctrl to be able to intercept some events @@ -263,7 +250,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, sizeText.y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy); } - SetBestSize(size); + SetInitialSize(size); (void)::ShowWindow(GetBuddyHwnd(), SW_SHOW); @@ -400,7 +387,7 @@ wxString wxTextCtrl::GetRange(long from, long to) const return str; } -void wxTextCtrl::SetValue(const wxString& value) +void wxTextCtrl::DoSetValue(const wxString& value, int flags) { // if the text is long enough, it's faster to just set it instead of first // comparing it with the old one (chances are that it will be different @@ -408,7 +395,7 @@ void wxTextCtrl::SetValue(const wxString& value) // edit controls mostly) if ( (value.length() > 0x400) || (value != GetValue()) ) { - DoWriteText(value, false); + DoWriteText(value, flags); // for compatibility, don't move the cursor when doing SetValue() SetInsertionPoint(0); @@ -416,7 +403,8 @@ void wxTextCtrl::SetValue(const wxString& value) else // same text { // still send an event for consistency - SendUpdateEvent(); + if ( flags & SetValue_SendEvent ) + SendUpdateEvent(); } // we should reset the modified flag even if the value didn't really change @@ -431,8 +419,9 @@ void wxTextCtrl::WriteText(const wxString& value) DoWriteText(value); } -void wxTextCtrl::DoWriteText(const wxString& value, bool selectionOnly) +void wxTextCtrl::DoWriteText(const wxString& value, int flags) { + bool selectionOnly = (flags & SetValue_SelectionOnly) != 0; wxString valueDos; if ( m_windowStyle & wxTE_MULTILINE ) valueDos = wxTextFile::Translate(value, wxTextFileType_Dos); @@ -443,7 +432,7 @@ void wxTextCtrl::DoWriteText(const wxString& value, bool selectionOnly) // call below which is confusing for the client code and so should be // avoided // - if ( ( selectionOnly && HasSelection() ) ) + if ( selectionOnly && HasSelection() ) { m_suppressNextUpdate = true; } @@ -451,7 +440,7 @@ void wxTextCtrl::DoWriteText(const wxString& value, bool selectionOnly) ::SendMessage(GetBuddyHwnd(), selectionOnly ? EM_REPLACESEL : WM_SETTEXT, 0, (LPARAM)valueDos.c_str()); - if ( !selectionOnly ) + if ( !selectionOnly && !( flags & SetValue_SendEvent ) ) { // Windows already sends an update event for single-line // controls. @@ -566,7 +555,7 @@ long wxTextCtrl::GetInsertionPoint() const return Pos & 0xFFFF; } -long wxTextCtrl::GetLastPosition() const +wxTextPos wxTextCtrl::GetLastPosition() const { int numLines = GetNumberOfLines(); long posStartLastLine = XYToPosition(0, numLines - 1); @@ -648,7 +637,7 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value) // Set selection and remove it DoSetSelection(from, to, false); - DoWriteText(value, true); + DoWriteText(value, SetValue_SelectionOnly); } void wxTextCtrl::Remove(long from, long to) @@ -812,7 +801,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const // remove the '\n' at the end, if any (this is how this function is // supposed to work according to the docs) - if ( buf[len - 1] == _T('\n') ) + if ( buf[len - 1] == wxT('\n') ) { len--; } @@ -1040,40 +1029,6 @@ bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) return true; } -WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor), -#if wxUSE_CTL3D - WXUINT message, - WXWPARAM wParam, - WXLPARAM lParam -#else - WXUINT WXUNUSED(message), - WXWPARAM WXUNUSED(wParam), - WXLPARAM WXUNUSED(lParam) -#endif - ) -{ -#if wxUSE_CTL3D - if ( m_useCtl3D ) - { - HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam); - return (WXHBRUSH) hbrush; - } -#endif // wxUSE_CTL3D - - HDC hdc = (HDC)pDC; - wxColour colBack = GetBackgroundColour(); - - if (!IsEnabled() && (GetWindowStyle() & wxTE_MULTILINE) == 0) - colBack = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); - - ::SetBkColor(hdc, wxColourToRGB(colBack)); - ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour())); - - wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID); - - return (WXHBRUSH)brush->GetResourceHandle(); -} - bool wxTextCtrl::AdjustSpaceLimit() { unsigned int limit = ::SendMessage(GetBuddyHwnd(), EM_GETLIMITTEXT, 0, 0); @@ -1122,11 +1077,11 @@ bool wxTextCtrl::AcceptsFocus() const void wxTextCtrl::DoMoveWindow(int x, int y, int width, int height) { - int widthBtn = GetBestSpinerSize(IsVertical(GetWindowStyle())).x / 2; + int widthBtn = GetBestSpinnerSize(IsVertical(GetWindowStyle())).x / 2; int widthText = width - widthBtn - MARGIN_BETWEEN; if ( widthText <= 0 ) { - wxLogDebug(_T("not enough space for wxSpinCtrl!")); + wxLogDebug(wxT("not enough space for wxSpinCtrl!")); } if ( !::MoveWindow(GetBuddyHwnd(), x, y, widthText, height, TRUE) )