]> git.saurik.com Git - wxWidgets.git/blobdiff - src/univ/themes/gtk.cpp
mention wx[Flex]GridSizer too
[wxWidgets.git] / src / univ / themes / gtk.cpp
index 94fd15e47ef61cab2e8e4a81fdb6891060e713ee..776d9cd4e70b184d53f9d9d98f5b002cb8a504ee 100644 (file)
 #include "wx/univ/inphand.h"
 #include "wx/univ/colschem.h"
 #include "wx/univ/theme.h"
+#include "wx/toplevel.h"
 
 // ----------------------------------------------------------------------------
 // constants (to be removed, for testing only)
 // ----------------------------------------------------------------------------
 
-static const size_t BORDER_THICKNESS = 2;
+static const wxCoord BORDER_THICKNESS = 1;
 
 // ----------------------------------------------------------------------------
 // wxGTKRenderer: draw the GUI elements in GTK style
@@ -205,6 +206,39 @@ public:
                                    wxCoord y,
                                    const wxMenuGeometryInfo& geomInfo);
 #endif
+
+    virtual void DrawFrameTitleBar(wxDC& dc,
+                                   const wxRect& rect,
+                                   const wxString& title,
+                                   const wxIcon& icon,
+                                   int flags,
+                                   int specialButton = 0,
+                                   int specialButtonFlag = 0);
+    virtual void DrawFrameBorder(wxDC& dc,
+                                 const wxRect& rect,
+                                 int flags);
+    virtual void DrawFrameBackground(wxDC& dc,
+                                     const wxRect& rect,
+                                     int flags);
+    virtual void DrawFrameTitle(wxDC& dc,
+                                const wxRect& rect,
+                                const wxString& title,
+                                int flags);
+    virtual void DrawFrameIcon(wxDC& dc,
+                               const wxRect& rect,
+                               const wxIcon& icon,
+                               int flags);
+    virtual void DrawFrameButton(wxDC& dc,
+                                 wxCoord x, wxCoord y,
+                                 int button,
+                                 int flags = 0);
+
+    // titlebars
+    virtual wxRect GetFrameClientArea(const wxRect& rect, int flags) const;
+    virtual wxSize GetFrameTotalSize(const wxSize& clientSize, int flags) const;
+    virtual wxSize GetFrameIconSize() const;
+    virtual int HitTestFrame(const wxRect& rect, const wxPoint& pt, int flags) const;
+
     virtual void GetComboBitmaps(wxBitmap *bmpNormal,
                                  wxBitmap *bmpFocus,
                                  wxBitmap *bmpPressed,
@@ -419,12 +453,12 @@ class wxGTKInputHandler : public wxInputHandler
 public:
     wxGTKInputHandler(wxGTKRenderer *renderer);
 
-    virtual bool HandleKey(wxControl *control,
+    virtual bool HandleKey(wxInputConsumer *control,
                            const wxKeyEvent& event,
                            bool pressed);
-    virtual bool HandleMouse(wxControl *control,
+    virtual bool HandleMouse(wxInputConsumer *control,
                              const wxMouseEvent& event);
-    virtual bool HandleMouseMove(wxControl *control, const wxMouseEvent& event);
+    virtual bool HandleMouseMove(wxInputConsumer *control, const wxMouseEvent& event);
 
 protected:
     wxGTKRenderer *m_renderer;
@@ -470,7 +504,7 @@ public:
     wxGTKCheckboxInputHandler(wxInputHandler *handler)
         : wxStdCheckboxInputHandler(handler) { }
 
-    virtual bool HandleKey(wxControl *control,
+    virtual bool HandleKey(wxInputConsumer *control,
                            const wxKeyEvent& event,
                            bool pressed);
 };
@@ -481,7 +515,7 @@ public:
     wxGTKTextCtrlInputHandler(wxInputHandler *handler)
         : wxStdTextCtrlInputHandler(handler) { }
 
-    virtual bool HandleKey(wxControl *control,
+    virtual bool HandleKey(wxInputConsumer *control,
                            const wxKeyEvent& event,
                            bool pressed);
 };
@@ -618,6 +652,8 @@ wxInputHandler *wxGTKTheme::GetInputHandler(const wxString& control)
         else if ( control == wxINP_HANDLER_NOTEBOOK )
             handler = new wxStdNotebookInputHandler(GetDefaultInputHandler());
 #endif // wxUSE_NOTEBOOK
+        else if ( control == wxINP_HANDLER_TOPLEVEL )
+            handler = new wxStdFrameInputHandler(GetDefaultInputHandler());
         else
             handler = GetDefaultInputHandler();
 
@@ -858,7 +894,7 @@ void wxGTKRenderer::DrawBorder(wxDC& dc,
     switch ( border )
     {
         case wxBORDER_SUNKEN:
-            for ( width = 0; width < BORDER_THICKNESS / 2; width++ )
+            for ( width = 0; width < BORDER_THICKNESS; width++ )
             {
                 DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
                 DrawShadedRect(dc, &rect, m_penBlack, m_penLightGrey);
@@ -866,21 +902,21 @@ void wxGTKRenderer::DrawBorder(wxDC& dc,
             break;
 
         case wxBORDER_STATIC:
-            for ( width = 0; width < BORDER_THICKNESS / 2; width++ )
+            for ( width = 0; width < BORDER_THICKNESS; width++ )
             {
                 DrawShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
             }
             break;
 
         case wxBORDER_RAISED:
-            for ( width = 0; width < BORDER_THICKNESS / 2; width++ )
+            for ( width = 0; width < BORDER_THICKNESS; width++ )
             {
                 DrawRaisedBorder(dc, &rect);
             }
             break;
 
         case wxBORDER_DOUBLE:
-            for ( width = 0; width < BORDER_THICKNESS / 3; width++ )
+            for ( width = 0; width < BORDER_THICKNESS; width++ )
             {
                 DrawShadedRect(dc, &rect, m_penLightGrey, m_penBlack);
                 DrawShadedRect(dc, &rect, m_penHighlight, m_penDarkGrey);
@@ -964,7 +1000,7 @@ void wxGTKRenderer::DrawTextBorder(wxDC& dc,
 {
     wxRect rect = rectOrig;
 
-    for ( size_t width = 0; width < BORDER_THICKNESS / 2; width++ )
+    if ( border != wxBORDER_NONE )
     {
         if ( flags & wxCONTROL_FOCUSED )
         {
@@ -994,7 +1030,7 @@ void wxGTKRenderer::DrawButtonBorder(wxDC& dc,
         // button pressed: draw a black border around it and an inward shade
         DrawRect(dc, &rect, m_penBlack);
 
-        for ( size_t width = 0; width < BORDER_THICKNESS / 2; width++ )
+        for ( size_t width = 0; width < BORDER_THICKNESS; width++ )
         {
             DrawAntiShadedRect(dc, &rect, m_penDarkGrey, m_penHighlight);
             DrawAntiShadedRect(dc, &rect, m_penBlack, m_penDarkGrey);
@@ -1016,7 +1052,7 @@ void wxGTKRenderer::DrawButtonBorder(wxDC& dc,
         }
 
         // now draw a normal button
-        for ( size_t width = 0; width < BORDER_THICKNESS / 2; width++ )
+        for ( size_t width = 0; width < BORDER_THICKNESS; width++ )
         {
             DrawShadedRect(dc, &rect, m_penHighlight, m_penBlack);
             DrawAntiShadedRect(dc, &rect,
@@ -1492,13 +1528,11 @@ void wxGTKRenderer::DrawRadioButton(wxDC& dc,
 // text control
 // ----------------------------------------------------------------------------
 
-static const int TEXT_BORDER = 2;
-
 wxRect wxGTKRenderer::GetTextTotalArea(const wxTextCtrl *text,
                                        const wxRect& rect)
 {
     wxRect rectTotal = rect;
-    rectTotal.Inflate(TEXT_BORDER);
+    rectTotal.Inflate(2*BORDER_THICKNESS);
     return rectTotal;
 }
 
@@ -1507,7 +1541,7 @@ wxRect wxGTKRenderer::GetTextClientArea(const wxTextCtrl *text,
                                         wxCoord *extraSpaceBeyond)
 {
     wxRect rectText = rect;
-    rectText.Inflate(-TEXT_BORDER);
+    rectText.Inflate(-2*BORDER_THICKNESS);
 
     if ( text->WrapLines() )
     {
@@ -2341,6 +2375,75 @@ void wxGTKRenderer::AdjustSize(wxSize *size, const wxWindow *window)
     }
 }
 
+// ----------------------------------------------------------------------------
+// top level windows
+// ----------------------------------------------------------------------------
+
+void wxGTKRenderer::DrawFrameTitleBar(wxDC& dc,
+                                      const wxRect& rect,
+                                      const wxString& title,
+                                      const wxIcon& icon,
+                                      int flags,
+                                      int specialButton,
+                                      int specialButtonFlag)
+{
+}
+
+void wxGTKRenderer::DrawFrameBorder(wxDC& dc,
+                                    const wxRect& rect,
+                                    int flags)
+{
+}
+
+void wxGTKRenderer::DrawFrameBackground(wxDC& dc,
+                                        const wxRect& rect,
+                                        int flags)
+{
+}
+
+void wxGTKRenderer::DrawFrameTitle(wxDC& dc,
+                                   const wxRect& rect,
+                                   const wxString& title,
+                                   int flags)
+{
+}
+
+void wxGTKRenderer::DrawFrameIcon(wxDC& dc,
+                                  const wxRect& rect,
+                                  const wxIcon& icon,
+                                  int flags)
+{
+}
+
+void wxGTKRenderer::DrawFrameButton(wxDC& dc,
+                                    wxCoord x, wxCoord y,
+                                    int button,
+                                    int flags)
+{
+}
+
+wxRect wxGTKRenderer::GetFrameClientArea(const wxRect& rect, int flags) const
+{
+    return rect;
+}
+
+wxSize wxGTKRenderer::GetFrameTotalSize(const wxSize& clientSize, int flags) const
+{
+    return clientSize;
+}
+
+wxSize wxGTKRenderer::GetFrameIconSize() const
+{
+    return wxSize(-1, -1);
+}
+
+int wxGTKRenderer::HitTestFrame(const wxRect& rect, const wxPoint& pt, int flags) const
+{
+    return wxHT_TOPLEVEL_CLIENT_AREA;
+}
+
+
+
 // ============================================================================
 // wxInputHandler
 // ============================================================================
@@ -2354,20 +2457,20 @@ wxGTKInputHandler::wxGTKInputHandler(wxGTKRenderer *renderer)
     m_renderer = renderer;
 }
 
-bool wxGTKInputHandler::HandleKey(wxControl *control,
+bool wxGTKInputHandler::HandleKey(wxInputConsumer *control,
                                   const wxKeyEvent& event,
                                   bool pressed)
 {
     return FALSE;
 }
 
-bool wxGTKInputHandler::HandleMouse(wxControl *control,
+bool wxGTKInputHandler::HandleMouse(wxInputConsumer *control,
                                     const wxMouseEvent& event)
 {
     // clicking on the control gives it focus
-    if ( event.ButtonDown() )
+    if ( event.ButtonDown() && wxWindow::FindFocus() != control->GetInputWindow() )
     {
-        control->SetFocus();
+        control->GetInputWindow()->SetFocus();
 
         return TRUE;
     }
@@ -2375,16 +2478,16 @@ bool wxGTKInputHandler::HandleMouse(wxControl *control,
     return FALSE;
 }
 
-bool wxGTKInputHandler::HandleMouseMove(wxControl *control,
+bool wxGTKInputHandler::HandleMouseMove(wxInputConsumer *control,
                                         const wxMouseEvent& event)
 {
     if ( event.Entering() )
     {
-        control->SetCurrent(TRUE);
+        control->GetInputWindow()->SetCurrent(TRUE);
     }
     else if ( event.Leaving() )
     {
-        control->SetCurrent(FALSE);
+        control->GetInputWindow()->SetCurrent(FALSE);
     }
     else
     {
@@ -2398,7 +2501,7 @@ bool wxGTKInputHandler::HandleMouseMove(wxControl *control,
 // wxGTKCheckboxInputHandler
 // ----------------------------------------------------------------------------
 
-bool wxGTKCheckboxInputHandler::HandleKey(wxControl *control,
+bool wxGTKCheckboxInputHandler::HandleKey(wxInputConsumer *control,
                                           const wxKeyEvent& event,
                                           bool pressed)
 {
@@ -2420,7 +2523,7 @@ bool wxGTKCheckboxInputHandler::HandleKey(wxControl *control,
 // wxGTKTextCtrlInputHandler
 // ----------------------------------------------------------------------------
 
-bool wxGTKTextCtrlInputHandler::HandleKey(wxControl *control,
+bool wxGTKTextCtrlInputHandler::HandleKey(wxInputConsumer *control,
                                           const wxKeyEvent& event,
                                           bool pressed)
 {