X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/73974df1f951f176f592fd900352c41281eb5df2..1e1fafb918b4d27606b1b6197d90c4bf84039fd5:/src/msw/textctrl.cpp diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index dea366f062..86967c3add 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -33,11 +33,12 @@ #include "wx/settings.h" #include "wx/brush.h" #include "wx/utils.h" + #include "wx/intl.h" #include "wx/log.h" + #include "wx/app.h" #endif #if wxUSE_CLIPBOARD - #include "wx/app.h" #include "wx/clipbrd.h" #endif @@ -57,7 +58,7 @@ # include #endif -#if wxUSE_RICHEDIT && (!defined(__GNUWIN32__) || defined(wxUSE_NORLANDER_HEADERS)) +#if wxUSE_RICHEDIT #include #endif @@ -115,8 +116,6 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, if ( !CreateBase(parent, id, pos, size, style, validator, name) ) return FALSE; - // Validator was set in CreateBase - //SetValidator(validator); if ( parent ) parent->AddChild(this); @@ -129,8 +128,8 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, if ( m_windowStyle & wxTE_MULTILINE ) { wxASSERT_MSG( !(m_windowStyle & wxTE_PROCESS_ENTER), - T("wxTE_PROCESS_ENTER style is ignored for multiline " - "text controls (they always process it)") ); + wxT("wxTE_PROCESS_ENTER style is ignored for multiline " + "text controls (they always process it)") ); msStyle |= ES_MULTILINE | ES_WANTRETURN; if ((m_windowStyle & wxTE_NO_VSCROLL) == 0) @@ -167,14 +166,37 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, m_lDlgCode |= DLGC_WANTTAB; // do create the control - either an EDIT or RICHEDIT - const wxChar *windowClass = T("EDIT"); + const wxChar *windowClass = wxT("EDIT"); #if wxUSE_RICHEDIT if ( m_windowStyle & wxTE_RICH ) { - msStyle |= ES_AUTOVSCROLL; - m_isRich = TRUE; - windowClass = T("RICHEDIT"); + static bool s_errorGiven = FALSE; // MT-FIXME + + // only give the error msg once if the DLL can't be loaded + if ( !s_errorGiven ) + { + // first try to load the RichEdit DLL (will do nothing if already + // done) + if ( !wxTheApp->InitRichEdit() ) + { + wxLogError(_("Impossible to create a rich edit control, " + "using simple text control instead.")); + + s_errorGiven = TRUE; + } + } + + if ( s_errorGiven ) + { + m_isRich = FALSE; + } + else + { + msStyle |= ES_AUTOVSCROLL; + m_isRich = TRUE; + windowClass = wxT("RICHEDIT"); + } } else m_isRich = FALSE; @@ -201,7 +223,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, wxGetInstance(), NULL); - wxCHECK_MSG( m_hWnd, FALSE, T("Failed to create text ctrl") ); + wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create text ctrl") ); #if wxUSE_CTL3D if ( want3D ) @@ -260,7 +282,7 @@ void wxTextCtrl::AdoptAttributesFromHWND() GetClassName(hWnd, buf, WXSIZEOF(buf)); - if ( wxStricmp(buf, T("EDIT(")) == 0 ) + if ( wxStricmp(buf, wxT("EDIT")) == 0 ) m_isRich = FALSE; else m_isRich = TRUE; @@ -296,9 +318,12 @@ void wxTextCtrl::SetValue(const wxString& value) { wxString valueDos = wxTextFile::Translate(value, wxTextFileType_Dos); - SetWindowText(GetHwnd(), valueDos); + if ( valueDos != GetValue() ) + { + SetWindowText(GetHwnd(), valueDos); - AdjustSpaceLimit(); + AdjustSpaceLimit(); + } } void wxTextCtrl::WriteText(const wxString& value) @@ -318,7 +343,7 @@ void wxTextCtrl::AppendText(const wxString& text) void wxTextCtrl::Clear() { - SetWindowText(GetHwnd(), T("")); + SetWindowText(GetHwnd(), wxT("")); } // ---------------------------------------------------------------------------- @@ -740,30 +765,6 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event) } } -WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, - WXUINT message, WXWPARAM wParam, - WXLPARAM lParam) -{ -#if wxUSE_CTL3D - if ( m_useCtl3D ) - { - HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam); - return (WXHBRUSH) hbrush; - } -#endif - - HDC hdc = (HDC)pDC; - SetBkMode(hdc, GetParent()->GetTransparentBackground() ? TRANSPARENT - : OPAQUE); - - ::SetBkColor(hdc, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue())); - ::SetTextColor(hdc, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue())); - - wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID); - - return (WXHBRUSH) backgroundBrush->GetResourceHandle(); -} - void wxTextCtrl::OnChar(wxKeyEvent& event) { switch ( event.KeyCode() ) @@ -883,7 +884,7 @@ bool wxTextCtrl::AcceptsFocus() const return IsEditable() && wxControl::AcceptsFocus(); } -wxSize wxTextCtrl::DoGetBestSize() +wxSize wxTextCtrl::DoGetBestSize() const { int cx, cy; wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());