X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cd4718483a06eb0ef00822781408a89746ea7e19..33d28952b29818b6931d91984a7b612a072d843d:/src/msw/textctrl.cpp?ds=sidebyside diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index b497ef0929..558855f000 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -39,12 +39,9 @@ #include #if wxUSE_IOSTREAMH -#include +# include #else -#include -# ifdef _MSC_VER - using namespace std; -# endif +# include #endif #include @@ -98,7 +95,6 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - m_fileName = ""; SetName(name); SetValidator(validator); if (parent) parent->AddChild(this); @@ -125,6 +121,9 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, long msStyle = ES_LEFT | WS_VISIBLE | WS_CHILD | WS_TABSTOP; if (m_windowStyle & wxTE_MULTILINE) { + wxASSERT_MSG( !(m_windowStyle & wxTE_PROCESS_ENTER), + "wxTE_PROCESS_ENTER style is ignored for multiline controls" ); + msStyle |= ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL ; // WS_BORDER m_windowStyle |= wxTE_PROCESS_ENTER; } @@ -177,7 +176,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, wxCHECK_MSG( m_hWnd, FALSE, "Failed to create text ctrl" ); -#if CTL3D +#if wxUSE_CTL3D if ( want3D ) { Ctl3dSubclassCtl((HWND)m_hWnd); @@ -312,7 +311,7 @@ void wxTextCtrl::SetValue(const wxString& value) SetWindowText((HWND) GetHWND(), (const char *)value); } -void wxTextCtrl::SetSize(int x, int y, int width, int height, int sizeFlags) +void wxTextCtrl::DoSetSize(int x, int y, int width, int height, int sizeFlags) { int currentX, currentY; GetPosition(¤tX, ¤tY); @@ -454,6 +453,7 @@ long wxTextCtrl::GetLastPosition() const void wxTextCtrl::Replace(long from, long to, const wxString& value) { +#if wxUSE_CLIPBOARD HWND hWnd = (HWND) GetHWND(); long fromChar = from; long toChar = to; @@ -471,6 +471,9 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value) // Paste into edit control SendMessage(hWnd, WM_PASTE, (WPARAM)0, (LPARAM)0L); +#else + wxFAIL_MSG("wxTextCtrl::Replace not implemented if wxUSE_CLIPBOARD is 0."); +#endif } void wxTextCtrl::Remove(long from, long to) @@ -630,9 +633,14 @@ void wxTextCtrl::WriteText(const wxString& text) delete[] newtext; } +void wxTextCtrl::AppendText(const wxString& text) +{ + SetInsertionPointEnd(); + WriteText(text); +} + void wxTextCtrl::Clear() { -// SendMessage((HWND) GetHWND(), WM_SETTEXT, 0, (LPARAM)""); SetWindowText((HWND) GetHWND(), ""); } @@ -700,11 +708,6 @@ void wxTextCtrl::ShowPosition(long pos) int linesToScroll = specifiedLineLineNo - currentLineLineNo; -/* - wxDebugMsg("Caret line: %d; Current visible line: %d; Specified line: %d; lines to scroll: %d\n", - currentLineLineNo1, currentLineLineNo, specifiedLineLineNo, linesToScroll); -*/ - if (linesToScroll != 0) (void)SendMessage(hWnd, EM_LINESCROLL, (WPARAM)0, (LPARAM)MAKELPARAM(linesToScroll, 0)); } @@ -809,7 +812,7 @@ int wxTextCtrl::overflow(int c) txt[plen] = (char)c; // append c txt[plen+xtra] = '\0'; // append '\0' or overwrite c // If the put area already contained \0, output will be truncated there - WriteText(txt); + AppendText(txt); delete[] txt; } @@ -874,15 +877,15 @@ int wxTextCtrl::underflow() wxTextCtrl& wxTextCtrl::operator<<(const wxString& s) { - WriteText(s); - return *this; + AppendText(s); + return *this; } wxTextCtrl& wxTextCtrl::operator<<(float f) { wxString str; str.Printf("%.2f", f); - WriteText(str); + AppendText(str); return *this; } @@ -890,7 +893,7 @@ wxTextCtrl& wxTextCtrl::operator<<(double d) { wxString str; str.Printf("%.2f", d); - WriteText(str); + AppendText(str); return *this; } @@ -898,7 +901,7 @@ wxTextCtrl& wxTextCtrl::operator<<(int i) { wxString str; str.Printf("%d", i); - WriteText(str); + AppendText(str); return *this; } @@ -906,7 +909,7 @@ wxTextCtrl& wxTextCtrl::operator<<(long i) { wxString str; str.Printf("%ld", i); - WriteText(str); + AppendText(str); return *this; } @@ -916,14 +919,14 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c) buf[0] = c; buf[1] = 0; - WriteText(buf); + AppendText(buf); return *this; } WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { -#if CTL3D +#if wxUSE_CTL3D if ( m_useCtl3D ) { HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam); @@ -952,6 +955,8 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) { switch( event.KeyCode() ) { + // VZ: commented out until somebody explains to me what it does +#if 0 // Fix by Marcel Rasche to allow Alt-Ctrl insertion of special characters case '{': case '}': @@ -962,38 +967,53 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) case '\\': { char c = (char)event.KeyCode(); - *this << c; + WriteText(c); } break; +#endif // 0 case WXK_RETURN: - wxASSERT_MSG( m_windowStyle & wxTE_PROCESS_ENTER, - "this text ctrl should never receive return" ); + { + if ( (m_windowStyle & wxTE_MULTILINE) == 0 ) { wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); event.SetEventObject( this ); if ( GetEventHandler()->ProcessEvent(event) ) return; } + //else: multiline controls need Enter for themselves + + break; + } case WXK_TAB: - // only produce navigation event if we don't process TAB ourself - if ( !(m_windowStyle & wxTE_PROCESS_TAB) ) + // only produce navigation event if we don't process TAB ourself or + // if it's a Shift-Tab keypress (we assume nobody will ever need + // this key combo for himself) + // + // NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is + // handled by Windows + if ( event.ShiftDown() || !(m_windowStyle & wxTE_PROCESS_TAB) ) { - wxNavigationKeyEvent event; - event.SetDirection(!(::GetKeyState(VK_SHIFT) & 0x100)); - event.SetWindowChange(FALSE); - event.SetEventObject(this); + wxNavigationKeyEvent eventNav; + eventNav.SetDirection(!event.ShiftDown()); + eventNav.SetWindowChange(FALSE); + eventNav.SetEventObject(this); - if ( GetEventHandler()->ProcessEvent(event) ) + if ( GetEventHandler()->ProcessEvent(eventNav) ) return; } + break; + + default: + event.Skip(); } // don't just call event.Skip() because this will cause TABs and ENTERs // be passed upwards and we don't always want this - instead process it // right here Default(); +// event.Skip(); } long wxTextCtrl::MSWGetDlgCode()