]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/textctrl.cpp
1. corrected problem with label updating in wxProgressDialog
[wxWidgets.git] / src / msw / textctrl.cpp
index 347fd91f7cf77de4ed719210ee1d8adb42153b07..c4969c93942f6fc51158c2cd32afcc6acbcc0df7 100644 (file)
@@ -58,7 +58,7 @@
 #   include <fstream>
 #endif
 
-#if wxUSE_RICHEDIT && (!defined(__GNUWIN32__) || defined(wxUSE_NORLANDER_HEADERS))
+#if wxUSE_RICHEDIT && !defined(__GNUWIN32_OLD__)
     #include <richedit.h>
 #endif
 
@@ -175,8 +175,6 @@ 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;
 
@@ -237,7 +235,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 +262,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 +372,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;
@@ -418,8 +416,8 @@ void wxTextCtrl::SetValue(const wxString& value)
     if ( (value.length() > 0x400) || (value != GetValue()) )
     {
         wxString valueDos = wxTextFile::Translate(value, wxTextFileType_Dos);
-
-        SetWindowText(GetHwnd(), valueDos);
+                               
+        SetWindowText(GetHwnd(), valueDos.c_str());
 
         AdjustSpaceLimit();
     }
@@ -809,7 +807,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);
@@ -893,30 +900,19 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
             // ourselves the fact that we got here means that the user code
             // decided to skip processing of this TAB - probably to let it
             // do its default job.
-            //
-            // NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is
-            //     handled by Windows
             {
                 wxNavigationKeyEvent eventNav;
                 eventNav.SetDirection(!event.ShiftDown());
-                eventNav.SetWindowChange(FALSE);
+                eventNav.SetWindowChange(event.ControlDown());
                 eventNav.SetEventObject(this);
 
-                if ( GetEventHandler()->ProcessEvent(eventNav) )
+                if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav) )
                     return;
             }
             break;
-
-        default:
-            event.Skip();
-            return;
     }
 
-    // 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
-
-    // FIXME
+    // no, we didn't process it
     event.Skip();
 }
 
@@ -938,11 +934,9 @@ 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 );
-                ProcessCommand(event);
+                event.SetString( GetValue() );
+                ProcessCommand( event );
             }
             break;