X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b3260bce473ab247edd8ca1d3aee4eb648b4b97e..c921fd5994d6d22b08ec98512eb59ee6f8939460:/src/os2/textctrl.cpp diff --git a/src/os2/textctrl.cpp b/src/os2/textctrl.cpp index 87c8150bac..3b2b97719a 100644 --- a/src/os2/textctrl.cpp +++ b/src/os2/textctrl.cpp @@ -86,6 +86,10 @@ wxTextCtrl::wxTextCtrl() { } +wxTextCtrl::~wxTextCtrl() +{ +} + bool wxTextCtrl::Create( wxWindow* pParent , wxWindowID vId @@ -93,14 +97,13 @@ bool wxTextCtrl::Create( , const wxPoint& rPos , const wxSize& rSize , long lStyle -#if wxUSE_VALIDATORS , const wxValidator& rValidator -#endif , const wxString& rsName ) { HWND hParent; int nTempy; + // // Base initialization // @@ -109,9 +112,7 @@ bool wxTextCtrl::Create( ,rPos ,rSize ,lStyle -#if wxUSE_VALIDATORS ,rValidator -#endif ,rsName )) return FALSE; @@ -125,6 +126,7 @@ bool wxTextCtrl::Create( } m_windowStyle = lStyle; + m_bIsMLE = FALSE; long lSstyle = WS_VISIBLE | WS_TABSTOP; @@ -200,7 +202,7 @@ bool wxTextCtrl::Create( // // Set font, position, size and initial value // - wxFont* pTextFont = new wxFont( 10 + wxFont* pTextFont = new wxFont( 8 ,wxMODERN ,wxNORMAL ,wxNORMAL @@ -218,8 +220,8 @@ bool wxTextCtrl::Create( ::WinQueryWindowPos(m_hWnd, &vSwp); SetXComp(vSwp.x); SetYComp(vSwp.y); - SetSize( vPos.x - ,vPos.y + SetSize( vPos.x - GetXComp() + ,vPos.y - GetYComp() ,rSize.x ,rSize.y ); @@ -252,6 +254,58 @@ void wxTextCtrl::AdoptAttributesFromHWND() } } // end of wxTextCtrl::AdoptAttributesFromHWND +WXDWORD wxTextCtrl::OS2GetStyle( + long lStyle +, WXDWORD* pdwExstyle +) const +{ + // + // Default border for the text controls is the sunken one + // + if ((lStyle & wxBORDER_MASK) == wxBORDER_DEFAULT ) + { + lStyle |= wxBORDER_SUNKEN; + } + + long dwStyle = wxControl::OS2GetStyle( lStyle + ,pdwExstyle + ); + + dwStyle = WS_VISIBLE | WS_TABSTOP; + + // + // Single and multiline edit fields are two different controls in PM + // + if ( m_windowStyle & wxTE_MULTILINE ) + { + dwStyle |= MLS_BORDER | MLS_WORDWRAP; + if ((m_windowStyle & wxTE_NO_VSCROLL) == 0) + dwStyle |= MLS_VSCROLL; + if (m_windowStyle & wxHSCROLL) + dwStyle |= MLS_HSCROLL; + if (m_windowStyle & wxTE_READONLY) + dwStyle |= MLS_READONLY; + } + else + { + dwStyle |= ES_LEFT | ES_AUTOSCROLL | ES_MARGIN; + if (m_windowStyle & wxHSCROLL) + dwStyle |= ES_AUTOSCROLL; + if (m_windowStyle & wxTE_READONLY) + dwStyle |= ES_READONLY; + if (m_windowStyle & wxTE_PASSWORD) // hidden input + dwStyle |= ES_UNREADABLE; + } + return dwStyle; +} // end of wxTextCtrl::OS2GetStyle + +void wxTextCtrl::SetWindowStyleFlag( + long lStyle +) +{ + wxControl::SetWindowStyleFlag(lStyle); +} // end of wxTextCtrl::SetWindowStyleFlag + void wxTextCtrl::SetupColours() { wxColour vBkgndColour; @@ -288,7 +342,6 @@ wxString wxTextCtrl::GetValue() const if (*zStr == '\r') *zStr = '\n'; } - sStr = zStr; return sStr; } // end of wxTextCtrl::GetValue @@ -333,6 +386,14 @@ void wxTextCtrl::Clear() ::WinSetWindowText(GetHwnd(), ""); } // end of wxTextCtrl::Clear +bool wxTextCtrl::EmulateKeyPress( + const wxKeyEvent& rEvent +) +{ + SetFocus(); + return(wxTextCtrlBase::EmulateKeyPress(rEvent)); +} // end of wxTextCtrl::EmulateKeyPress + // ---------------------------------------------------------------------------- // Clipboard operations // ---------------------------------------------------------------------------- @@ -1110,9 +1171,11 @@ void wxTextCtrl::AdjustSpaceLimit() bool wxTextCtrl::AcceptsFocus() const { // - // We don't want focus if we can't be edited + // We don't want focus if we can't be edited unless we're a multiline + // control because then it might be still nice to get focus from keyboard + // to be able to scroll it without mouse // - return IsEditable() && wxControl::AcceptsFocus(); + return (IsEditable() || IsMultiLine()) && wxControl::AcceptsFocus(); } // end of wxTextCtrl::Command wxSize wxTextCtrl::DoGetBestSize() const @@ -1172,6 +1235,29 @@ void wxTextCtrl::OnRedo( Redo(); } // end of wxTextCtrl::OnRedo +void wxTextCtrl::OnDelete( + wxCommandEvent& rEvent +) +{ + long lFrom; + long lTo; + + GetSelection( &lFrom + ,&lTo + ); + if (lFrom != -1 && lTo != -1) + Remove( lFrom + ,lTo + ); +} // end of wxTextCtrl::OnDelete + +void wxTextCtrl::OnSelectAll( + wxCommandEvent& rEvent +) +{ + SetSelection(-1, -1); +} // end of wxTextCtrl::OnSelectAll + void wxTextCtrl::OnUpdateCut( wxUpdateUIEvent& rEvent ) @@ -1207,6 +1293,26 @@ void wxTextCtrl::OnUpdateRedo( rEvent.Enable(CanRedo()); } // end of wxTextCtrl::OnUpdateRedo +void wxTextCtrl::OnUpdateDelete( + wxUpdateUIEvent& rEvent +) +{ + long lFrom; + long lTo; + + GetSelection( &lFrom + ,&lTo + ); + rEvent.Enable( lFrom != -1L && lTo != -1L && lFrom != lTo && IsEditable()) ; +} // end of wxTextCtrl::OnUpdateDelete + +void wxTextCtrl::OnUpdateSelectAll( + wxUpdateUIEvent& rEvent +) +{ + rEvent.Enable(GetLastPosition() > 0); +} // end of wxTextCtrl::OnUpdateSelectAll + bool wxTextCtrl::SetBackgroundColour( const wxColour& rColour )