]> git.saurik.com Git - wxWidgets.git/blobdiff - src/univ/themes/gtk.cpp
fixed yet another bug in wxStream classes
[wxWidgets.git] / src / univ / themes / gtk.cpp
index fe2695813a46f91a6824ab9f18a7b29e11c63006..ec6405a78f3f00456d1ca8f2d20c3bdb22adb7b6 100644 (file)
@@ -30,6 +30,7 @@
     #include "wx/dcmemory.h"
     #include "wx/window.h"
 
     #include "wx/dcmemory.h"
     #include "wx/window.h"
 
+    #include "wx/bmpbuttn.h"
     #include "wx/button.h"
     #include "wx/checkbox.h"
     #include "wx/listbox.h"
     #include "wx/button.h"
     #include "wx/checkbox.h"
     #include "wx/listbox.h"
@@ -52,7 +53,7 @@
 // constants (to be removed, for testing only)
 // ----------------------------------------------------------------------------
 
 // constants (to be removed, for testing only)
 // ----------------------------------------------------------------------------
 
-static const size_t BORDER_THICKNESS = 10;
+static const size_t BORDER_THICKNESS = 1;
 
 // ----------------------------------------------------------------------------
 // wxGTKRenderer: draw the GUI elements in GTK style
 
 // ----------------------------------------------------------------------------
 // wxGTKRenderer: draw the GUI elements in GTK style
@@ -865,7 +866,10 @@ void wxGTKRenderer::DrawBorder(wxDC& dc,
             break;
 
         case wxBORDER_STATIC:
             break;
 
         case wxBORDER_STATIC:
-            DrawShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
+            for ( width = 0; width < BORDER_THICKNESS; width++ )
+            {
+                DrawShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
+            }
             break;
 
         case wxBORDER_RAISED:
             break;
 
         case wxBORDER_RAISED:
@@ -876,13 +880,19 @@ void wxGTKRenderer::DrawBorder(wxDC& dc,
             break;
 
         case wxBORDER_DOUBLE:
             break;
 
         case wxBORDER_DOUBLE:
-            DrawShadedRect(dc, &rect, m_penLightGrey, m_penBlack);
-            DrawShadedRect(dc, &rect, m_penHighlight, m_penDarkGrey);
-            DrawRect(dc, &rect, m_penLightGrey);
+            for ( width = 0; width < BORDER_THICKNESS; width++ )
+            {
+                DrawShadedRect(dc, &rect, m_penLightGrey, m_penBlack);
+                DrawShadedRect(dc, &rect, m_penHighlight, m_penDarkGrey);
+                DrawRect(dc, &rect, m_penLightGrey);
+            }
             break;
 
         case wxBORDER_SIMPLE:
             break;
 
         case wxBORDER_SIMPLE:
-            DrawRect(dc, &rect, m_penBlack);
+            for ( width = 0; width < BORDER_THICKNESS; width++ )
+            {
+                DrawRect(dc, &rect, m_penBlack);
+            }
             break;
 
         default:
             break;
 
         default:
@@ -910,11 +920,11 @@ wxRect wxGTKRenderer::GetBorderDimensions(wxBorder border) const
 
         case wxBORDER_SIMPLE:
         case wxBORDER_STATIC:
 
         case wxBORDER_SIMPLE:
         case wxBORDER_STATIC:
-            width = 1;
+            width = BORDER_THICKNESS;
             break;
 
         case wxBORDER_DOUBLE:
             break;
 
         case wxBORDER_DOUBLE:
-            width = 3;
+            width = 3*BORDER_THICKNESS;
             break;
 
         default:
             break;
 
         default:
@@ -954,15 +964,18 @@ void wxGTKRenderer::DrawTextBorder(wxDC& dc,
 {
     wxRect rect = rectOrig;
 
 {
     wxRect rect = rectOrig;
 
-    if ( flags & wxCONTROL_FOCUSED )
-    {
-        DrawRect(dc, &rect, m_penBlack);
-        DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
-    }
-    else // !focused
+    if ( border != wxBORDER_NONE )
     {
     {
-        DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
-        DrawAntiShadedRect(dc, &rect, m_penBlack, m_penHighlight);
+        if ( flags & wxCONTROL_FOCUSED )
+        {
+            DrawRect(dc, &rect, m_penBlack);
+            DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
+        }
+        else // !focused
+        {
+            DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
+            DrawAntiShadedRect(dc, &rect, m_penBlack, m_penHighlight);
+        }
     }
 
     if ( rectIn )
     }
 
     if ( rectIn )
@@ -980,8 +993,12 @@ void wxGTKRenderer::DrawButtonBorder(wxDC& dc,
     {
         // button pressed: draw a black border around it and an inward shade
         DrawRect(dc, &rect, m_penBlack);
     {
         // button pressed: draw a black border around it and an inward shade
         DrawRect(dc, &rect, m_penBlack);
-        DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
-        DrawAntiShadedRect(dc, &rect, m_penBlack, m_penDarkGrey);
+
+        for ( size_t width = 0; width < BORDER_THICKNESS; width++ )
+        {
+            DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
+            DrawAntiShadedRect(dc, &rect, m_penBlack, m_penDarkGrey);
+        }
     }
     else
     {
     }
     else
     {
@@ -999,10 +1016,13 @@ void wxGTKRenderer::DrawButtonBorder(wxDC& dc,
         }
 
         // now draw a normal button
         }
 
         // now draw a normal button
-        DrawShadedRect(dc, &rect, m_penHighlight, m_penBlack);
-        DrawAntiShadedRect(dc, &rect,
-                           wxPen(GetBackgroundColour(flags), 0, wxSOLID),
-                           m_penDarkGrey);
+        for ( size_t width = 0; width < BORDER_THICKNESS; width++ )
+        {
+            DrawShadedRect(dc, &rect, m_penHighlight, m_penBlack);
+            DrawAntiShadedRect(dc, &rect,
+                               wxPen(GetBackgroundColour(flags), 0, wxSOLID),
+                               m_penDarkGrey);
+        }
     }
 
     if ( rectIn )
     }
 
     if ( rectIn )
@@ -1472,13 +1492,11 @@ void wxGTKRenderer::DrawRadioButton(wxDC& dc,
 // text control
 // ----------------------------------------------------------------------------
 
 // text control
 // ----------------------------------------------------------------------------
 
-static const int TEXT_BORDER = 2;
-
 wxRect wxGTKRenderer::GetTextTotalArea(const wxTextCtrl *text,
                                        const wxRect& rect)
 {
     wxRect rectTotal = rect;
 wxRect wxGTKRenderer::GetTextTotalArea(const wxTextCtrl *text,
                                        const wxRect& rect)
 {
     wxRect rectTotal = rect;
-    rectTotal.Inflate(TEXT_BORDER);
+    rectTotal.Inflate(2*BORDER_THICKNESS);
     return rectTotal;
 }
 
     return rectTotal;
 }
 
@@ -1487,7 +1505,7 @@ wxRect wxGTKRenderer::GetTextClientArea(const wxTextCtrl *text,
                                         wxCoord *extraSpaceBeyond)
 {
     wxRect rectText = rect;
                                         wxCoord *extraSpaceBeyond)
 {
     wxRect rectText = rect;
-    rectText.Inflate(-TEXT_BORDER);
+    rectText.Inflate(-2*BORDER_THICKNESS);
 
     if ( text->WrapLines() )
     {
 
     if ( text->WrapLines() )
     {
@@ -2280,6 +2298,14 @@ int wxGTKRenderer::PixelToScrollbar(const wxScrollBar *scrollbar,
 
 void wxGTKRenderer::AdjustSize(wxSize *size, const wxWindow *window)
 {
 
 void wxGTKRenderer::AdjustSize(wxSize *size, const wxWindow *window)
 {
+#if wxUSE_BMPBUTTON
+    if ( wxDynamicCast(window, wxBitmapButton) )
+    {
+        size->x += 4;
+        size->y += 4;
+    } else
+#endif // wxUSE_BMPBUTTON
+#if wxUSE_BUTTON
     if ( wxDynamicCast(window, wxButton) )
     {
         if ( !(window->GetWindowStyle() & wxBU_EXACTFIT) )
     if ( wxDynamicCast(window, wxButton) )
     {
         if ( !(window->GetWindowStyle() & wxBU_EXACTFIT) )
@@ -2293,8 +2319,9 @@ void wxGTKRenderer::AdjustSize(wxSize *size, const wxWindow *window)
             // button border width
             size->y += 4;
         }
             // button border width
             size->y += 4;
         }
-    }
-    else if ( wxDynamicCast(window, wxScrollBar) )
+    } else
+#endif wxUSE_BUTTON
+    if ( wxDynamicCast(window, wxScrollBar) )
     {
         // we only set the width of vert scrollbars and height of the
         // horizontal ones
     {
         // we only set the width of vert scrollbars and height of the
         // horizontal ones
@@ -2336,7 +2363,7 @@ bool wxGTKInputHandler::HandleMouse(wxControl *control,
                                     const wxMouseEvent& event)
 {
     // clicking on the control gives it focus
                                     const wxMouseEvent& event)
 {
     // clicking on the control gives it focus
-    if ( event.ButtonDown() )
+    if ( event.ButtonDown() && wxWindow::FindFocus() != control )
     {
         control->SetFocus();
 
     {
         control->SetFocus();