]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/textctrl.cpp
warnings in wxCHeCK_MSG fixed
[wxWidgets.git] / src / msw / textctrl.cpp
index 91df514f6f1d197ec8861fee3dc7dd32b7b60281..e48ba50b35f9b573cab85320dd0d32b39126eacc 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        textctrl.cpp
+// Name:        msw/textctrl.cpp
 // Purpose:     wxTextCtrl
 // Author:      Julian Smart
 // Modified by:
@@ -175,11 +175,13 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
     if (m_windowStyle & wxTE_READONLY)
         msStyle |= ES_READONLY;
 
-    if (m_windowStyle & wxHSCROLL)
-        msStyle |= (WS_HSCROLL | ES_AUTOHSCROLL);
     if (m_windowStyle & wxTE_PASSWORD) // hidden input
         msStyle |= ES_PASSWORD;
 
+   if (m_windowStyle & wxTE_AUTO_SCROLL)
+        msStyle |=  ES_AUTOHSCROLL;
+
+
     // we always want the characters and the arrows
     m_lDlgCode = DLGC_WANTCHARS | DLGC_WANTARROWS;
 
@@ -237,7 +239,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
 #ifndef RICHEDIT_CLASS
                 wxString RICHEDIT_CLASS;
                 RICHEDIT_CLASS.Printf(_T("RichEdit%d0"), ver);
-#ifdef wxUSE_UNICODE
+#if wxUSE_UNICODE
                 RICHEDIT_CLASS += _T('W');
 #else // ANSI
                 RICHEDIT_CLASS += _T('A');
@@ -264,7 +266,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
     //     might be -1 in which case we should use the default values (and
     //     SetSize called below takes care of it)
     m_hWnd = (WXHWND)::CreateWindowEx(exStyle,
-                                      windowClass,
+                                      windowClass.c_str(),
                                       NULL,
                                       msStyle,
                                       0, 0, 0, 0,
@@ -374,9 +376,9 @@ wxString wxTextCtrl::GetValue() const
 #if wxUSE_RICHEDIT
     if ( m_isRich )
     {
-        wxString str;
-
         int len = GetWindowTextLength(GetHwnd()) + 1;
+
+        wxString str;
         wxChar *p = str.GetWriteBuf(len);
 
         TEXTRANGE textRange;
@@ -419,7 +421,7 @@ void wxTextCtrl::SetValue(const wxString& value)
     {
         wxString valueDos = wxTextFile::Translate(value, wxTextFileType_Dos);
 
-        SetWindowText(GetHwnd(), valueDos);
+        SetWindowText(GetHwnd(), valueDos.c_str());
 
         AdjustSpaceLimit();
     }
@@ -556,7 +558,7 @@ void wxTextCtrl::SetInsertionPoint(long pos)
     SendMessage(hWnd, EM_SETSEL, 0, MAKELPARAM(pos, pos));
 #endif // Win32/16
 
-    static const char *nothing = "";
+    static const wxChar *nothing = _T("");
     SendMessage(hWnd, EM_REPLACESEL, 0, (LPARAM)nothing);
 }
 
@@ -809,7 +811,16 @@ int wxTextCtrl::GetLineLength(long lineNo) const
 
 wxString wxTextCtrl::GetLineText(long lineNo) const
 {
+    // TODO this should probably be optimized by using GetWriteBuf()
+
     size_t len = (size_t)GetLineLength(lineNo) + 1;
+    if ( len < sizeof(WORD) )
+    {
+        // there must be at least enough place for the length WORD in the
+        // buffer
+        len += sizeof(WORD);
+    }
+
     char *buf = (char *)malloc(len);
     *(WORD *)buf = len;
     int noChars = (int)SendMessage(GetHwnd(), EM_GETLINE, lineNo, (LPARAM)buf);
@@ -880,7 +891,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
             if ( !(m_windowStyle & wxTE_MULTILINE) )
             {
                 wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
-                event.SetEventObject( this );
+                InitCommandEvent(event);
                 if ( GetEventHandler()->ProcessEvent(event) )
                     return;
             }
@@ -927,10 +938,8 @@ bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
         case EN_CHANGE:
             {
                 wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
-                wxString val(GetValue());
-                if ( !val.IsNull() )
-                    event.m_commandString = WXSTRINGCAST val;
-                event.SetEventObject( this );
+                InitCommandEvent(event);
+                event.SetString(GetValue());
                 ProcessCommand(event);
             }
             break;
@@ -1011,27 +1020,27 @@ wxSize wxTextCtrl::DoGetBestSize() const
 // standard handlers for standard edit menu events
 // ----------------------------------------------------------------------------
 
-void wxTextCtrl::OnCut(wxCommandEvent& event)
+void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))
 {
     Cut();
 }
 
-void wxTextCtrl::OnCopy(wxCommandEvent& event)
+void wxTextCtrl::OnCopy(wxCommandEvent& WXUNUSED(event))
 {
     Copy();
 }
 
-void wxTextCtrl::OnPaste(wxCommandEvent& event)
+void wxTextCtrl::OnPaste(wxCommandEvent& WXUNUSED(event))
 {
     Paste();
 }
 
-void wxTextCtrl::OnUndo(wxCommandEvent& event)
+void wxTextCtrl::OnUndo(wxCommandEvent& WXUNUSED(event))
 {
     Undo();
 }
 
-void wxTextCtrl::OnRedo(wxCommandEvent& event)
+void wxTextCtrl::OnRedo(wxCommandEvent& WXUNUSED(event))
 {
     Redo();
 }