]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/textctrl.cpp
update to make digitalmars compile/link libraries
[wxWidgets.git] / src / os2 / textctrl.cpp
index 0c762e5d8e4e1d055e1c525338eb7b4456293157..679d0fa248cd56ac7bb8bb1da1306173bd09a3ea 100644 (file)
@@ -86,6 +86,10 @@ wxTextCtrl::wxTextCtrl()
 {
 }
 
 {
 }
 
+wxTextCtrl::~wxTextCtrl()
+{
+}
+
 bool wxTextCtrl::Create(
   wxWindow*                         pParent
 , wxWindowID                        vId
 bool wxTextCtrl::Create(
   wxWindow*                         pParent
 , wxWindowID                        vId
@@ -93,14 +97,13 @@ bool wxTextCtrl::Create(
 , const wxPoint&                    rPos
 , const wxSize&                     rSize
 , long                              lStyle
 , const wxPoint&                    rPos
 , const wxSize&                     rSize
 , long                              lStyle
-#if wxUSE_VALIDATORS
 , const wxValidator&                rValidator
 , const wxValidator&                rValidator
-#endif
 , const wxString&                   rsName
 )
 {
     HWND                            hParent;
     int                             nTempy;
 , const wxString&                   rsName
 )
 {
     HWND                            hParent;
     int                             nTempy;
+
     //
     // Base initialization
     //
     //
     // Base initialization
     //
@@ -109,9 +112,7 @@ bool wxTextCtrl::Create(
                      ,rPos
                      ,rSize
                      ,lStyle
                      ,rPos
                      ,rSize
                      ,lStyle
-#if wxUSE_VALIDATORS
                      ,rValidator
                      ,rValidator
-#endif
                      ,rsName
                     ))
         return FALSE;
                      ,rsName
                     ))
         return FALSE;
@@ -125,6 +126,7 @@ bool wxTextCtrl::Create(
     }
 
     m_windowStyle = lStyle;
     }
 
     m_windowStyle = lStyle;
+    m_bIsMLE = FALSE;
 
     long                            lSstyle = WS_VISIBLE | WS_TABSTOP;
 
 
     long                            lSstyle = WS_VISIBLE | WS_TABSTOP;
 
@@ -154,14 +156,6 @@ bool wxTextCtrl::Create(
         if (m_windowStyle & wxTE_PASSWORD) // hidden input
             lSstyle |= ES_UNREADABLE;
     }
         if (m_windowStyle & wxTE_PASSWORD) // hidden input
             lSstyle |= ES_UNREADABLE;
     }
-    //
-    // If the parent is a scrolled window the controls must
-    // have this style or they will overlap the scrollbars
-    //
-    if (pParent)
-        if (pParent->IsKindOf(CLASSINFO(wxScrolledWindow)) ||
-            pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)))
-            lSstyle |= WS_CLIPSIBLINGS;
 
     if (m_bIsMLE)
     {
 
     if (m_bIsMLE)
     {
@@ -208,7 +202,7 @@ bool wxTextCtrl::Create(
     //
     // Set font, position, size and initial value
     //
     //
     // Set font, position, size and initial value
     //
-    wxFont*                          pTextFont = new wxFont( 10
+    wxFont*                          pTextFont = new wxFont( 8
                                                             ,wxMODERN
                                                             ,wxNORMAL
                                                             ,wxNORMAL
                                                             ,wxMODERN
                                                             ,wxNORMAL
                                                             ,wxNORMAL
@@ -226,11 +220,12 @@ bool wxTextCtrl::Create(
     ::WinQueryWindowPos(m_hWnd, &vSwp);
     SetXComp(vSwp.x);
     SetYComp(vSwp.y);
     ::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
            );
             ,rSize.x
             ,rSize.y
            );
+    delete pTextFont;
     return TRUE;
 } // end of wxTextCtrl::Create
 
     return TRUE;
 } // end of wxTextCtrl::Create
 
@@ -259,6 +254,58 @@ void wxTextCtrl::AdoptAttributesFromHWND()
     }
 } // end of 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;
 void wxTextCtrl::SetupColours()
 {
     wxColour                        vBkgndColour;
@@ -295,7 +342,6 @@ wxString wxTextCtrl::GetValue() const
         if (*zStr == '\r')
             *zStr = '\n';
     }
         if (*zStr == '\r')
             *zStr = '\n';
     }
-    sStr = zStr;
     return sStr;
 } // end of wxTextCtrl::GetValue
 
     return sStr;
 } // end of wxTextCtrl::GetValue
 
@@ -320,7 +366,10 @@ void wxTextCtrl::WriteText(
   const wxString&                   rsValue
 )
 {
   const wxString&                   rsValue
 )
 {
-    ::WinSendMsg(GetHwnd(), MLM_INSERT, MPARAM((PCHAR)rsValue.c_str()), MPARAM(0));
+    if (m_bIsMLE)
+        ::WinSendMsg(GetHwnd(), MLM_INSERT, MPARAM((PCHAR)rsValue.c_str()), MPARAM(0));
+    else
+        ::WinSetWindowText(GetHwnd(), rsValue.c_str());
     AdjustSpaceLimit();
 } // end of wxTextCtrl::WriteText
 
     AdjustSpaceLimit();
 } // end of wxTextCtrl::WriteText
 
@@ -337,6 +386,14 @@ void wxTextCtrl::Clear()
     ::WinSetWindowText(GetHwnd(), "");
 } // end of 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
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // Clipboard operations
 // ----------------------------------------------------------------------------
@@ -450,6 +507,15 @@ void wxTextCtrl::SetInsertionPointEnd()
 {
     long                            lPos = GetLastPosition();
 
 {
     long                            lPos = GetLastPosition();
 
+    //
+    // We must not do anything if the caret is already there because calling
+    // SetInsertionPoint() thaws the controls if Freeze() had been called even
+    // if it doesn't actually move the caret anywhere and so the simple fact of
+    // doing it results in horrible flicker when appending big amounts of text
+    // to the control in a few chunks (see DoAddText() test in the text sample)
+    //
+    if (GetInsertionPoint() == GetLastPosition())
+        return;
     SetInsertionPoint(lPos);
 } // end of wxTextCtrl::SetInsertionPointEnd
 
     SetInsertionPoint(lPos);
 } // end of wxTextCtrl::SetInsertionPointEnd
 
@@ -1114,9 +1180,11 @@ void wxTextCtrl::AdjustSpaceLimit()
 bool wxTextCtrl::AcceptsFocus() const
 {
     //
 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
 } // end of wxTextCtrl::Command
 
 wxSize wxTextCtrl::DoGetBestSize() const
@@ -1176,6 +1244,29 @@ void wxTextCtrl::OnRedo(
     Redo();
 } // end of 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
 )
 void wxTextCtrl::OnUpdateCut(
   wxUpdateUIEvent&                  rEvent
 )
@@ -1211,6 +1302,26 @@ void wxTextCtrl::OnUpdateRedo(
     rEvent.Enable(CanRedo());
 } // end of 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
 )
 bool wxTextCtrl::SetBackgroundColour(
   const wxColour&                   rColour
 )