]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/textctrl.cpp
wxUSE_POSTSCRIPT is not a sufficient test by itself for
[wxWidgets.git] / src / msw / textctrl.cpp
index b6a7a6a53d8811e73cb344753912cb2ef946eaf4..210d3ecf59531e8a00bb385d43a504531bdc3a1c 100644 (file)
@@ -991,8 +991,8 @@ bool wxTextCtrl::EmulateKeyPress(const wxKeyEvent& event)
     size_t lenOld = GetValue().length();
 
     wxUint32 code = event.GetRawKeyCode();
-    ::keybd_event(code, 0, 0 /* key press */, 0);
-    ::keybd_event(code, 0, KEYEVENTF_KEYUP, 0);
+    ::keybd_event((BYTE)code, 0, 0 /* key press */, 0);
+    ::keybd_event((BYTE)code, 0, KEYEVENTF_KEYUP, 0);
 
     // assume that any alphanumeric key changes the total number of characters
     // in the control - this should work in 99% of cases
@@ -2122,9 +2122,12 @@ bool wxTextCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                     case WM_SETCURSOR:
                         // ok, so it is hardcoded - do we really nee to
                         // customize it?
-                        ::SetCursor(GetHcursorOf(wxCursor(wxCURSOR_HAND)));
-                        *result = TRUE;
-                        break;
+                        {
+                            wxCursor cur(wxCURSOR_HAND);
+                            ::SetCursor(GetHcursorOf(cur));
+                            *result = TRUE;
+                            break;
+                        }
 
                     case WM_MOUSEMOVE:
                     case WM_LBUTTONDOWN:
@@ -2173,6 +2176,22 @@ bool wxTextCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
     return wxTextCtrlBase::MSWOnNotify(idCtrl, lParam, result);
 }
 
+// ----------------------------------------------------------------------------
+// default colors for MSW text control
+// ----------------------------------------------------------------------------
+
+wxVisualAttributes wxTextCtrl::GetDefaultAttributes() const
+{
+    // it is important to return valid values for all attributes from here,
+    // GetXXX() below rely on this
+    wxVisualAttributes attrs;
+    attrs.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
+    attrs.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
+    attrs.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
+
+    return attrs;
+}
+
 // ----------------------------------------------------------------------------
 // colour setting for the rich edit controls
 // ----------------------------------------------------------------------------
@@ -2403,7 +2422,7 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
 
         const wxArrayInt& tabs = style.GetTabs();
 
-        pf.cTabCount = wxMin(tabs.GetCount(), MAX_TAB_STOPS);
+        pf.cTabCount = (SHORT)wxMin(tabs.GetCount(), MAX_TAB_STOPS);
         size_t i;
         for (i = 0; i < (size_t) pf.cTabCount; i++)
         {
@@ -2493,6 +2512,7 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
     (void) ::SendMessage(GetHwnd(), EM_GETCHARFORMAT,
                             SCF_SELECTION, (LPARAM)&cf) ;
 
+
     LOGFONT lf;
     lf.lfHeight = cf.yHeight;
     lf.lfWidth = 0;
@@ -2500,17 +2520,32 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
     lf.lfClipPrecision = 0;
     lf.lfEscapement = 0;
     wxStrcpy(lf.lfFaceName, cf.szFaceName);
+
+    //NOTE:  we _MUST_ set each of these values to _something_ since we
+    //do not call wxZeroMemory on the LOGFONT lf 
     if (cf.dwEffects & CFE_ITALIC)
         lf.lfItalic = TRUE;
+    else
+        lf.lfItalic = FALSE;
+
     lf.lfOrientation = 0;
     lf.lfPitchAndFamily = cf.bPitchAndFamily;
     lf.lfQuality = 0;
+
     if (cf.dwEffects & CFE_STRIKEOUT)
         lf.lfStrikeOut = TRUE;
+    else
+        lf.lfStrikeOut = FALSE;
+
     if (cf.dwEffects & CFE_UNDERLINE)
         lf.lfUnderline = TRUE;
+    else
+        lf.lfUnderline = FALSE;
+
     if (cf.dwEffects & CFE_BOLD)
         lf.lfWeight = FW_BOLD;
+    else
+        lf.lfWeight = FW_NORMAL;
 
     wxFont font = wxCreateFontFromLogFont(& lf);
     if (font.Ok())