]> git.saurik.com Git - wxWidgets.git/blobdiff - src/univ/themes/win32.cpp
fixed yet another bug in wxStream classes
[wxWidgets.git] / src / univ / themes / win32.cpp
index b584acc8118afb173d57121fb58f611755323f1d..3f682335bc7de6906d94ecf49ed77517bebb0db6 100644 (file)
@@ -1,11 +1,10 @@
-///////////////////////////////////////////////////////////////////////////////
 // Name:        univ/themes/win32.cpp
 // Purpose:     wxUniversal theme implementing Win32-like LNF
 // Author:      Vadim Zeitlin
 // Modified by:
 // Created:     06.08.00
 // RCS-ID:      $Id$
 // Name:        univ/themes/win32.cpp
 // Purpose:     wxUniversal theme implementing Win32-like LNF
 // Author:      Vadim Zeitlin
 // Modified by:
 // Created:     06.08.00
 // RCS-ID:      $Id$
-// Copyright:   (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
+// Copyright:   (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
 // Licence:     wxWindows license
 ///////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows license
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -44,6 +43,7 @@
 #include "wx/notebook.h"
 #include "wx/spinbutt.h"
 #include "wx/settings.h"
 #include "wx/notebook.h"
 #include "wx/spinbutt.h"
 #include "wx/settings.h"
+#include "wx/menu.h"
 
 #include "wx/univ/scrtimer.h"
 
 
 #include "wx/univ/scrtimer.h"
 
@@ -87,7 +87,6 @@ enum IndicatorStatus
     IndicatorStatus_Max
 };
 
     IndicatorStatus_Max
 };
 
-// ----------------------------------------------------------------------------
 // wxWin32Renderer: draw the GUI elements in Win32 style
 // ----------------------------------------------------------------------------
 
 // wxWin32Renderer: draw the GUI elements in Win32 style
 // ----------------------------------------------------------------------------
 
@@ -235,6 +234,7 @@ public:
                                  int end,
                                  int step = 1,
                                  int flags = 0);
                                  int end,
                                  int step = 1,
                                  int flags = 0);
+#if wxUSE_MENUS
 
     virtual void DrawMenuBarItem(wxDC& dc,
                                  const wxRect& rect,
 
     virtual void DrawMenuBarItem(wxDC& dc,
                                  const wxRect& rect,
@@ -252,8 +252,9 @@ public:
     virtual void DrawMenuSeparator(wxDC& dc,
                                    wxCoord y,
                                    const wxMenuGeometryInfo& geomInfo);
     virtual void DrawMenuSeparator(wxDC& dc,
                                    wxCoord y,
                                    const wxMenuGeometryInfo& geomInfo);
-
+#endif
     virtual void GetComboBitmaps(wxBitmap *bmpNormal,
     virtual void GetComboBitmaps(wxBitmap *bmpNormal,
+                                 wxBitmap *bmpFocus,
                                  wxBitmap *bmpPressed,
                                  wxBitmap *bmpDisabled);
 
                                  wxBitmap *bmpPressed,
                                  wxBitmap *bmpDisabled);
 
@@ -298,10 +299,11 @@ public:
                                       wxOrientation orient) const;
     virtual wxSize GetProgressBarStep() const { return wxSize(16, 32); }
 
                                       wxOrientation orient) const;
     virtual wxSize GetProgressBarStep() const { return wxSize(16, 32); }
 
+#if wxUSE_MENUS
     virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const;
     virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win,
                                                 const wxMenu& menu) const;
     virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const;
     virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win,
                                                 const wxMenu& menu) const;
-
+#endif
 protected:
     // helper of DrawLabel() and DrawCheckOrRadioButton()
     void DoDrawLabel(wxDC& dc,
 protected:
     // helper of DrawLabel() and DrawCheckOrRadioButton()
     void DoDrawLabel(wxDC& dc,
@@ -1087,6 +1089,37 @@ wxColour wxWin32ColourScheme::Get(wxWin32ColourScheme::StdColour col) const
 {
     switch ( col )
     {
 {
     switch ( col )
     {
+        // use the system colours under Windows
+#if defined(__WXMSW__)
+        case WINDOW:            return wxColour(GetSysColor(COLOR_WINDOW));
+
+        case CONTROL_PRESSED:
+        case CONTROL_CURRENT:
+        case CONTROL:           return wxColour(GetSysColor(COLOR_BTNFACE));
+
+        case CONTROL_TEXT:      return wxColour(GetSysColor(COLOR_BTNTEXT));
+
+        case SCROLLBAR:         return wxColour(GetSysColor(COLOR_SCROLLBAR));
+        case SCROLLBAR_PRESSED: return wxColour(GetSysColor(COLOR_HIGHLIGHT));
+
+        case HIGHLIGHT:         return wxColour(GetSysColor(COLOR_HIGHLIGHT));
+        case HIGHLIGHT_TEXT:    return wxColour(GetSysColor(COLOR_HIGHLIGHTTEXT));
+
+#if defined(COLOR_3DDKSHADOW)
+        case SHADOW_DARK:       return wxColour(GetSysColor(COLOR_3DDKSHADOW));
+#else
+        case SHADOW_DARK:       return *wxBLACK;
+#endif
+
+        case CONTROL_TEXT_DISABLED:
+        case SHADOW_HIGHLIGHT:  return wxColour(GetSysColor(COLOR_BTNHIGHLIGHT));
+
+        case SHADOW_IN:         return wxColour(GetSysColor(COLOR_BTNFACE));
+
+        case CONTROL_TEXT_DISABLED_SHADOW:
+        case SHADOW_OUT:        return wxColour(GetSysColor(COLOR_BTNSHADOW));
+#else // !__WXMSW__
+        // use the standard Windows colours elsewhere
         case WINDOW:            return *wxWHITE;
 
         case CONTROL_PRESSED:
         case WINDOW:            return *wxWHITE;
 
         case CONTROL_PRESSED:
@@ -1110,6 +1143,7 @@ wxColour wxWin32ColourScheme::Get(wxWin32ColourScheme::StdColour col) const
 
         case CONTROL_TEXT_DISABLED_SHADOW:
         case SHADOW_OUT:        return wxColour(0x7f7f7f);
 
         case CONTROL_TEXT_DISABLED_SHADOW:
         case SHADOW_OUT:        return wxColour(0x7f7f7f);
+#endif // __WXMSW__
 
         case MAX:
         default:
 
         case MAX:
         default:
@@ -1801,14 +1835,6 @@ void wxWin32Renderer::DoDrawLabel(wxDC& dc,
     {
         if ( focusOffset.x || focusOffset.y )
         {
     {
         if ( focusOffset.x || focusOffset.y )
         {
-            // before calling Inflate(), ensure that we will have a valid rect
-            // afterwards
-            if ( rectLabel.x < focusOffset.x )
-                rectLabel.x = focusOffset.x;
-
-            if ( rectLabel.y < focusOffset.y )
-                rectLabel.y = focusOffset.y;
-
             rectLabel.Inflate(focusOffset.x, focusOffset.y);
         }
 
             rectLabel.Inflate(focusOffset.x, focusOffset.y);
         }
 
@@ -2419,6 +2445,8 @@ void wxWin32Renderer::DrawSliderTicks(wxDC& dc,
 // menu and menubar
 // ----------------------------------------------------------------------------
 
 // menu and menubar
 // ----------------------------------------------------------------------------
 
+#if wxUSE_MENUS
+
 // wxWin32MenuGeometryInfo: the wxMenuGeometryInfo used by wxWin32Renderer
 class WXDLLEXPORT wxWin32MenuGeometryInfo : public wxMenuGeometryInfo
 {
 // wxWin32MenuGeometryInfo: the wxMenuGeometryInfo used by wxWin32Renderer
 class WXDLLEXPORT wxWin32MenuGeometryInfo : public wxMenuGeometryInfo
 {
@@ -2447,6 +2475,8 @@ private:
                 GetMenuGeometry(wxWindow *, const wxMenu&) const;
 };
 
                 GetMenuGeometry(wxWindow *, const wxMenu&) const;
 };
 
+#endif // wxUSE_MENUS
+
 // FIXME: all constants are hardcoded but shouldn't be
 static const wxCoord MENU_LEFT_MARGIN = 9;
 static const wxCoord MENU_RIGHT_MARGIN = 18;
 // FIXME: all constants are hardcoded but shouldn't be
 static const wxCoord MENU_LEFT_MARGIN = 9;
 static const wxCoord MENU_RIGHT_MARGIN = 18;
@@ -2466,6 +2496,10 @@ static const wxCoord MENU_SEPARATOR_HEIGHT = 3;
 // the size of the standard checkmark bitmap
 static const wxCoord MENU_CHECK_SIZE = 9;
 
 // the size of the standard checkmark bitmap
 static const wxCoord MENU_CHECK_SIZE = 9;
 
+// we can't implement these methods without wxMenuGeometryInfo implementation
+// which we don't have if !wxUSE_MENUS
+#if wxUSE_MENUS
+
 void wxWin32Renderer::DrawMenuBarItem(wxDC& dc,
                                       const wxRect& rectOrig,
                                       const wxString& label,
 void wxWin32Renderer::DrawMenuBarItem(wxDC& dc,
                                       const wxRect& rectOrig,
                                       const wxString& label,
@@ -2677,11 +2711,55 @@ wxMenuGeometryInfo *wxWin32Renderer::GetMenuGeometry(wxWindow *win,
     return gi;
 }
 
     return gi;
 }
 
+#else // !wxUSE_MENUS
+
+/*
+void wxWin32Renderer::DrawMenuBarItem(wxDC& WXUNUSED(dc),
+                                      const wxRect& WXUNUSED(rectOrig),
+                                      const wxString& WXUNUSED(label),
+                                      int WXUNUSED(flags),
+                                      int WXUNUSED(indexAccel))
+{
+}
+
+void wxWin32Renderer::DrawMenuItem(wxDC& WXUNUSED(dc),
+                                   wxCoord WXUNUSED(y),
+                                   const wxMenuGeometryInfo& WXUNUSED(gi),
+                                   const wxString& WXUNUSED(label),
+                                   const wxString& WXUNUSED(accel),
+                                   const wxBitmap& WXUNUSED(bitmap),
+                                   int WXUNUSED(flags),
+                                   int WXUNUSED(indexAccel))
+{
+}
+
+void wxWin32Renderer::DrawMenuSeparator(wxDC& WXUNUSED(dc),
+                                        wxCoord WXUNUSED(y),
+                                        const wxMenuGeometryInfo& WXUNUSED(gi))
+{
+}
+
+wxSize wxWin32Renderer::GetMenuBarItemSize(const wxSize& size) const
+{
+    return size;
+}
+
+wxMenuGeometryInfo *
+wxWin32Renderer::GetMenuGeometry(wxWindow *WXUNUSED(win),
+                                 const wxMenu& WXUNUSED(menu)) const
+{
+    return NULL;
+}
+*/
+
+#endif // wxUSE_MENUS/!wxUSE_MENUS
+
 // ----------------------------------------------------------------------------
 // combobox
 // ----------------------------------------------------------------------------
 
 void wxWin32Renderer::GetComboBitmaps(wxBitmap *bmpNormal,
 // ----------------------------------------------------------------------------
 // combobox
 // ----------------------------------------------------------------------------
 
 void wxWin32Renderer::GetComboBitmaps(wxBitmap *bmpNormal,
+                                      wxBitmap *bmpFocus,
                                       wxBitmap *bmpPressed,
                                       wxBitmap *bmpDisabled)
 {
                                       wxBitmap *bmpPressed,
                                       wxBitmap *bmpDisabled)
 {
@@ -2880,11 +2958,6 @@ wxRect wxWin32Renderer::GetTextTotalArea(const wxTextCtrl *text,
     wxRect rectTotal = rect;
 
     wxCoord widthBorder = GetTextBorderWidth();
     wxRect rectTotal = rect;
 
     wxCoord widthBorder = GetTextBorderWidth();
-    if ( rectTotal.x < widthBorder )
-        rectTotal.x = widthBorder;
-    if ( rectTotal.y < widthBorder )
-        rectTotal.y = widthBorder;
-
     rectTotal.Inflate(widthBorder);
 
     // this is what Windows does
     rectTotal.Inflate(widthBorder);
 
     // this is what Windows does
@@ -2904,11 +2977,6 @@ wxRect wxWin32Renderer::GetTextClientArea(const wxTextCtrl *text,
         rectText.height--;
 
     wxCoord widthBorder = GetTextBorderWidth();
         rectText.height--;
 
     wxCoord widthBorder = GetTextBorderWidth();
-    if ( rectText.width < 2*widthBorder )
-        rectText.width = 2*widthBorder;
-    if ( rectText.height < 2*widthBorder )
-        rectText.height = 2*widthBorder;
-
     rectText.Inflate(-widthBorder);
 
     if ( extraSpaceBeyond )
     rectText.Inflate(-widthBorder);
 
     if ( extraSpaceBeyond )
@@ -2941,19 +3009,17 @@ void wxWin32Renderer::AdjustSize(wxSize *size, const wxWindow *window)
 #if wxUSE_BUTTON
     if ( wxDynamicCast(window, wxButton) )
     {
 #if wxUSE_BUTTON
     if ( wxDynamicCast(window, wxButton) )
     {
-        // TODO
-        size->x += 3*window->GetCharWidth();
-#if 0 // do allow creating small buttons if wanted
-        wxSize sizeDef = wxButton::GetDefaultSize();
-        if ( size->x < sizeDef.x )
-            size->x = sizeDef.x;
-#endif // 0
-
-        wxCoord heightBtn = (11*(window->GetCharHeight() + 8))/10;
-        if ( size->y < heightBtn - 8 )
-            size->y = heightBtn;
-        else
-            size->y += 9;
+        if ( !(window->GetWindowStyle() & wxBU_EXACTFIT) )
+        {
+            // TODO: don't harcode all this
+            size->x += 3*window->GetCharWidth();
+
+            wxCoord heightBtn = (11*(window->GetCharHeight() + 8))/10;
+            if ( size->y < heightBtn - 8 )
+                size->y = heightBtn;
+            else
+                size->y += 9;
+        }
 
         // no border width adjustments for buttons
         return;
 
         // no border width adjustments for buttons
         return;
@@ -2989,6 +3055,14 @@ bool wxWin32InputHandler::HandleKey(wxControl *control,
 bool wxWin32InputHandler::HandleMouse(wxControl *control,
                                       const wxMouseEvent& event)
 {
 bool wxWin32InputHandler::HandleMouse(wxControl *control,
                                       const wxMouseEvent& event)
 {
+    // clicking on the control gives it focus
+    if ( event.ButtonDown() && wxWindow::FindFocus() != control )
+    {
+        control->SetFocus();
+
+        return TRUE;
+    }
+
     return FALSE;
 }
 
     return FALSE;
 }