]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/textctrl.cpp
compilation fix
[wxWidgets.git] / src / msw / textctrl.cpp
index e6e9e3fae8fcc3a02126809881a1251caa8065af..276df78633511438a047059ca6ee72d3ccac4310 100644 (file)
 #include <windowsx.h>
 
 #include "wx/msw/private.h"
+#include "wx/msw/winundef.h"
 
 #include <string.h>
 #include <stdlib.h>
+
+#ifndef __WXWINCE__
 #include <sys/types.h>
+#endif
 
 #if wxUSE_RICHEDIT
 
@@ -140,6 +144,8 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
 #ifdef __WIN16__
     EVT_ERASE_BACKGROUND(wxTextCtrl::OnEraseBackground)
 #endif
+
+    EVT_SET_FOCUS(wxTextCtrl::OnSetFocus)
 END_EVENT_TABLE()
 
 // ============================================================================
@@ -158,6 +164,7 @@ void wxTextCtrl::Init()
 
     m_privateContextMenu = NULL;
     m_suppressNextUpdate = FALSE;
+    m_isNativeCaretShown = true;
 }
 
 wxTextCtrl::~wxTextCtrl()
@@ -355,12 +362,6 @@ void wxTextCtrl::AdoptAttributesFromHWND()
 
 WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
 {
-    // default border for the text controls is the sunken one
-    if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT )
-    {
-        style |= wxBORDER_SUNKEN;
-    }
-
     long msStyle = wxControl::MSWGetStyle(style, exstyle);
 
     // styles which we alaways add by default
@@ -424,9 +425,6 @@ WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
 
 void wxTextCtrl::SetWindowStyleFlag(long style)
 {
-    if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT )
-        style |= wxBORDER_SUNKEN;
-
 #if wxUSE_RICHEDIT
     // we have to deal with some styles separately because they can't be
     // changed by simply calling SetWindowLong(GWL_STYLE) but can be changed
@@ -565,7 +563,8 @@ DWORD CALLBACK wxRichEditStreamIn(DWORD dwCookie, BYTE *buf, LONG cb, LONG *pcb)
     return 0;
 }
 
-extern long wxEncodingToCodepage(wxFontEncoding encoding); // from utils.cpp
+// from utils.cpp
+extern WXDLLIMPEXP_BASE long wxEncodingToCodepage(wxFontEncoding encoding);
 
 #if wxUSE_UNICODE_MSLU
 bool wxTextCtrl::StreamIn(const wxString& value,
@@ -757,7 +756,7 @@ void wxTextCtrl::AppendText(const wxString& text)
 
 void wxTextCtrl::Clear()
 {
-    ::SetWindowText(GetHwnd(), wxT(""));
+    ::SetWindowText(GetHwnd(), wxEmptyString);
 
 #if wxUSE_RICHEDIT
     if ( !IsRich() )
@@ -1072,7 +1071,7 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value)
 
 void wxTextCtrl::Remove(long from, long to)
 {
-    Replace(from, to, _T(""));
+    Replace(from, to, wxEmptyString);
 }
 
 bool wxTextCtrl::LoadFile(const wxString& file)
@@ -1244,6 +1243,27 @@ bool wxTextCtrl::CanRedo() const
     return ::SendMessage(GetHwnd(), EM_CANUNDO, 0, 0) != 0;
 }
 
+// ----------------------------------------------------------------------------
+// caret handling (Windows only)
+// ----------------------------------------------------------------------------
+
+bool wxTextCtrl::ShowNativeCaret(bool show)
+{
+    if ( show != m_isNativeCaretShown )
+    {
+        if ( !(show ? ::ShowCaret(GetHwnd()) : ::HideCaret(GetHwnd())) )
+        {
+            // not an error, may simply indicate that it's not shown/hidden
+            // yet (i.e. it had been hidden/showh 2 times before)
+            return false;
+        }
+
+        m_isNativeCaretShown = show;
+    }
+
+    return true;
+}
+
 // ----------------------------------------------------------------------------
 // implemenation details
 // ----------------------------------------------------------------------------
@@ -1491,11 +1511,6 @@ WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSE
 #endif // wxUSE_CTL3D
 
     HDC hdc = (HDC)pDC;
-    if (GetParent()->GetTransparentBackground())
-        SetBkMode(hdc, TRANSPARENT);
-    else
-        SetBkMode(hdc, OPAQUE);
-
     wxColour colBack = GetBackgroundColour();
 
     if (!IsEnabled() && (GetWindowStyle() & wxTE_MULTILINE) == 0)
@@ -1720,6 +1735,15 @@ void wxTextCtrl::OnRightClick(wxMouseEvent& event)
     event.Skip();
 }
 
+void wxTextCtrl::OnSetFocus(wxFocusEvent& event)
+{
+    // be sure the caret remains invisible if the user had hidden it
+    if ( !m_isNativeCaretShown )
+    {
+        ::HideCaret(GetHwnd());
+    }
+}
+
 // the rest of the file only deals with the rich edit controls
 #if wxUSE_RICHEDIT
 
@@ -2243,6 +2267,7 @@ void wxRichEditModule::OnExit()
         if ( ms_hRichEdit[i] )
         {
             ::FreeLibrary(ms_hRichEdit[i]);
+            ms_hRichEdit[i] = NULL;
         }
     }
 }