]> git.saurik.com Git - wxWidgets.git/blobdiff - src/univ/themes/metal.cpp
More doxygen topic overview cleanup.
[wxWidgets.git] / src / univ / themes / metal.cpp
index dc580faaf03899b21e12438bafacaaafc84981d4..a0849274c4e59be29d9d297de9ad6b40ef710dc2 100644 (file)
@@ -1,11 +1,12 @@
-// Name:        univ/themes/metal.cpp
+///////////////////////////////////////////////////////////////////////////////
+// Name:        src/univ/themes/metal.cpp
 // Purpose:     wxUniversal theme implementing Win32-like LNF
 // Author:      Vadim Zeitlin, Robert Roebling
 // Modified by:
 // Created:     06.08.00
 // RCS-ID:      $Id$
 // Copyright:   (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
 // Purpose:     wxUniversal theme implementing Win32-like LNF
 // Author:      Vadim Zeitlin, Robert Roebling
 // Modified by:
 // Created:     06.08.00
 // RCS-ID:      $Id$
 // Copyright:   (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
 // ===========================================================================
 ///////////////////////////////////////////////////////////////////////////////
 
 // ===========================================================================
     #pragma hdrstop
 #endif
 
     #pragma hdrstop
 #endif
 
+#include "wx/univ/theme.h"
+
+#if wxUSE_THEME_METAL
+
 #ifndef WX_PRECOMP
     #include "wx/timer.h"
     #include "wx/intl.h"
 #ifndef WX_PRECOMP
     #include "wx/timer.h"
     #include "wx/intl.h"
     #include "wx/textctrl.h"
     #include "wx/toolbar.h"
 
     #include "wx/textctrl.h"
     #include "wx/toolbar.h"
 
-    #ifdef __WXMSW__
-        // for COLOR_* constants
-        #include "wx/msw/private.h"
-    #endif
+    #include "wx/menu.h"
+    #include "wx/settings.h"
+    #include "wx/toplevel.h"
 #endif // WX_PRECOMP
 
 #include "wx/notebook.h"
 #include "wx/spinbutt.h"
 #endif // WX_PRECOMP
 
 #include "wx/notebook.h"
 #include "wx/spinbutt.h"
-#include "wx/settings.h"
-#include "wx/menu.h"
 #include "wx/artprov.h"
 #include "wx/artprov.h"
-#include "wx/toplevel.h"
 
 #include "wx/univ/scrtimer.h"
 #include "wx/univ/renderer.h"
 
 #include "wx/univ/scrtimer.h"
 #include "wx/univ/renderer.h"
+#include "wx/univ/inpcons.h"
 #include "wx/univ/inphand.h"
 #include "wx/univ/colschem.h"
 #include "wx/univ/inphand.h"
 #include "wx/univ/colschem.h"
-#include "wx/univ/theme.h"
 
 
+// ----------------------------------------------------------------------------
 // wxMetalRenderer: draw the GUI elements in Metal style
 // ----------------------------------------------------------------------------
 
 // wxMetalRenderer: draw the GUI elements in Metal style
 // ----------------------------------------------------------------------------
 
@@ -79,18 +81,18 @@ class wxMetalRenderer : public wxDelegateRenderer
         Arrow_Normal,
         Arrow_Disabled,
         Arrow_Pressed,
         Arrow_Normal,
         Arrow_Disabled,
         Arrow_Pressed,
-        Arrow_Inversed,
-        Arrow_InversedDisabled,
+        Arrow_Inverted,
+        Arrow_InvertedDisabled,
         Arrow_StateMax
     };
 public:
     wxMetalRenderer(wxRenderer *renderer, wxColourScheme* scheme);
 
     virtual void DrawButtonSurface(wxDC& dc,
         Arrow_StateMax
     };
 public:
     wxMetalRenderer(wxRenderer *renderer, wxColourScheme* scheme);
 
     virtual void DrawButtonSurface(wxDC& dc,
-                                   const wxColour& col,
+                                   const wxColour& WXUNUSED(col),
                                    const wxRect& rect,
                                    const wxRect& rect,
-                                   int flags )
-        { DrawMetal( dc, rect ); }
+                                   int WXUNUSED(flags))
+        { DrawMetal(dc, rect); }
 
     virtual void DrawScrollbarThumb(wxDC& dc,
                                     wxOrientation orient,
 
     virtual void DrawScrollbarThumb(wxDC& dc,
                                     wxOrientation orient,
@@ -122,7 +124,7 @@ protected:
     void DrawShadedRect(wxDC& dc, wxRect *rect,
                         const wxPen& pen1, const wxPen& pen2);
 
     void DrawShadedRect(wxDC& dc, wxRect *rect,
                         const wxPen& pen1, const wxPen& pen2);
 
-    void DrawArrowBorder(wxDC& dc, wxRect *rect, bool isPressed = FALSE);
+    void DrawArrowBorder(wxDC& dc, wxRect *rect, bool isPressed = false);
 
     void DrawArrow(wxDC& dc, const wxRect& rect,
                    wxArrowDirection arrowDir, wxArrowStyle arrowStyle);
 
     void DrawArrow(wxDC& dc, const wxRect& rect,
                    wxArrowDirection arrowDir, wxArrowStyle arrowStyle);
@@ -141,92 +143,42 @@ private:
 // wxMetalTheme
 // ----------------------------------------------------------------------------
 
 // wxMetalTheme
 // ----------------------------------------------------------------------------
 
-WX_DEFINE_ARRAY(wxInputHandler *, wxArrayHandlers);
-
-class wxMetalTheme : public wxTheme
+class wxMetalTheme : public wxDelegateTheme
 {
 public:
 {
 public:
-    wxMetalTheme();
-    virtual ~wxMetalTheme();
+    wxMetalTheme() : wxDelegateTheme(_T("win32")), m_renderer(NULL) {}
+    ~wxMetalTheme() { delete m_renderer; }
 
 
-    virtual wxRenderer *GetRenderer();
-    virtual wxArtProvider *GetArtProvider();
-    virtual wxInputHandler *GetInputHandler(const wxString& control);
-    virtual wxColourScheme *GetColourScheme();
-private:
-    bool GetOrCreateTheme()
+protected:
+    virtual wxRenderer *GetRenderer()
     {
     {
-        if ( !m_win32Theme )
-            m_win32Theme = wxTheme::Create("win32");
-        return m_win32Theme != NULL;
+        if ( !m_renderer )
+        {
+            m_renderer = new wxMetalRenderer(m_theme->GetRenderer(),
+                                             GetColourScheme());
+        }
+
+        return m_renderer;
     }
     }
-private:
-    wxTheme *m_win32Theme;
-    wxMetalRenderer *m_renderer;
-    
+
+    wxRenderer *m_renderer;
+
     WX_DECLARE_THEME(Metal)
 };
 
     WX_DECLARE_THEME(Metal)
 };
 
-// ============================================================================
-// implementation
-// ============================================================================
-
 WX_IMPLEMENT_THEME(wxMetalTheme, Metal, wxTRANSLATE("Metal theme"));
 
 WX_IMPLEMENT_THEME(wxMetalTheme, Metal, wxTRANSLATE("Metal theme"));
 
-// ----------------------------------------------------------------------------
-// wxMetalTheme
-// ----------------------------------------------------------------------------
-
-wxMetalTheme::wxMetalTheme()
-{
-    m_win32Theme = NULL;
-    m_renderer = NULL;
-}
-
-wxMetalTheme::~wxMetalTheme()
-{
-    delete m_win32Theme;
-    delete m_renderer;
-}
-
-wxRenderer *wxMetalTheme::GetRenderer()
-{
-    if ( !GetOrCreateTheme() )
-        return 0;
-    if ( !m_renderer )
-        m_renderer = new wxMetalRenderer(m_win32Theme->GetRenderer(),
-                                         m_win32Theme->GetColourScheme());
-
-    return m_renderer;
-}
-
-wxArtProvider *wxMetalTheme::GetArtProvider()
-{
-    if ( !GetOrCreateTheme() )
-        return 0;
-    return m_win32Theme->GetArtProvider();
-}
-
-wxInputHandler *wxMetalTheme::GetInputHandler(const wxString& control)
-{
-    if ( !GetOrCreateTheme() )
-        return 0;
-    return m_win32Theme->GetInputHandler(control);
-}
 
 
-wxColourScheme *wxMetalTheme::GetColourScheme()
-{
-    if ( !GetOrCreateTheme() )
-        return 0;
-    return m_win32Theme->GetColourScheme();
-}
+// ============================================================================
+// implementation
+// ============================================================================
 
 // ----------------------------------------------------------------------------
 // wxMetalRenderer
 // ----------------------------------------------------------------------------
 
 wxMetalRenderer::wxMetalRenderer(wxRenderer *renderer, wxColourScheme *scheme)
 
 // ----------------------------------------------------------------------------
 // wxMetalRenderer
 // ----------------------------------------------------------------------------
 
 wxMetalRenderer::wxMetalRenderer(wxRenderer *renderer, wxColourScheme *scheme)
-    : wxDelegateRenderer(renderer)
+               : wxDelegateRenderer(renderer)
 {
     // init colours and pens
     m_penBlack = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_DARK), 0, wxSOLID);
 {
     // init colours and pens
     m_penBlack = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_DARK), 0, wxSOLID);
@@ -366,31 +318,31 @@ wxMetalRenderer::wxMetalRenderer(wxRenderer *renderer, wxColourScheme *scheme)
 
         }
 
 
         }
 
-        // create the inversed bitmap but only for the right arrow as we only
+        // create the inverted bitmap but only for the right arrow as we only
         // use it for the menus
         if ( n == Arrow_Right )
         {
         // use it for the menus
         if ( n == Arrow_Right )
         {
-            m_bmpArrows[Arrow_Inversed][n].Create(w, h);
-            dcInverse.SelectObject(m_bmpArrows[Arrow_Inversed][n]);
+            m_bmpArrows[Arrow_Inverted][n].Create(w, h);
+            dcInverse.SelectObject(m_bmpArrows[Arrow_Inverted][n]);
             dcInverse.Clear();
             dcInverse.Blit(0, 0, w, h,
                           &dcNormal, 0, 0,
                           wxXOR);
             dcInverse.SelectObject(wxNullBitmap);
 
             dcInverse.Clear();
             dcInverse.Blit(0, 0, w, h,
                           &dcNormal, 0, 0,
                           wxXOR);
             dcInverse.SelectObject(wxNullBitmap);
 
-            mask = new wxMask(m_bmpArrows[Arrow_Inversed][n], *wxBLACK);
-            m_bmpArrows[Arrow_Inversed][n].SetMask(mask);
+            mask = new wxMask(m_bmpArrows[Arrow_Inverted][n], *wxBLACK);
+            m_bmpArrows[Arrow_Inverted][n].SetMask(mask);
 
 
-            m_bmpArrows[Arrow_InversedDisabled][n].Create(w, h);
-            dcInverse.SelectObject(m_bmpArrows[Arrow_InversedDisabled][n]);
+            m_bmpArrows[Arrow_InvertedDisabled][n].Create(w, h);
+            dcInverse.SelectObject(m_bmpArrows[Arrow_InvertedDisabled][n]);
             dcInverse.Clear();
             dcInverse.Blit(0, 0, w, h,
                           &dcDisabled, 0, 0,
                           wxXOR);
             dcInverse.SelectObject(wxNullBitmap);
 
             dcInverse.Clear();
             dcInverse.Blit(0, 0, w, h,
                           &dcDisabled, 0, 0,
                           wxXOR);
             dcInverse.SelectObject(wxNullBitmap);
 
-            mask = new wxMask(m_bmpArrows[Arrow_InversedDisabled][n], *wxBLACK);
-            m_bmpArrows[Arrow_InversedDisabled][n].SetMask(mask);
+            mask = new wxMask(m_bmpArrows[Arrow_InvertedDisabled][n], *wxBLACK);
+            m_bmpArrows[Arrow_InvertedDisabled][n].SetMask(mask);
         }
 
         dcNormal.SelectObject(wxNullBitmap);
         }
 
         dcNormal.SelectObject(wxNullBitmap);
@@ -406,9 +358,9 @@ wxMetalRenderer::wxMetalRenderer(wxRenderer *renderer, wxColourScheme *scheme)
 }
 
 void wxMetalRenderer::DrawScrollbarThumb(wxDC& dc,
 }
 
 void wxMetalRenderer::DrawScrollbarThumb(wxDC& dc,
-                                         wxOrientation orient,
+                                         wxOrientation WXUNUSED(orient),
                                          const wxRect& rect,
                                          const wxRect& rect,
-                                         int flags)
+                                         int WXUNUSED(flags))
 {
     // we don't use the flags, the thumb never changes appearance
     wxRect rectThumb = rect;
 {
     // we don't use the flags, the thumb never changes appearance
     wxRect rectThumb = rect;
@@ -417,15 +369,15 @@ void wxMetalRenderer::DrawScrollbarThumb(wxDC& dc,
 }
 
 void wxMetalRenderer::DrawScrollbarShaft(wxDC& dc,
 }
 
 void wxMetalRenderer::DrawScrollbarShaft(wxDC& dc,
-                                         wxOrientation orient,
+                                         wxOrientation WXUNUSED(orient),
                                          const wxRect& rectBar,
                                          const wxRect& rectBar,
-                                         int flags)
+                                         int WXUNUSED(flags))
 {
 {
-    DrawMetal( dc, rectBar );
+    DrawMetal(dc, rectBar);
 }
 
 void wxMetalRenderer::GetComboBitmaps(wxBitmap *bmpNormal,
 }
 
 void wxMetalRenderer::GetComboBitmaps(wxBitmap *bmpNormal,
-                                      wxBitmap *bmpFocus,
+                                      wxBitmap * WXUNUSED(bmpFocus),
                                       wxBitmap *bmpPressed,
                                       wxBitmap *bmpDisabled)
 {
                                       wxBitmap *bmpPressed,
                                       wxBitmap *bmpDisabled)
 {
@@ -575,7 +527,7 @@ void wxMetalRenderer::DrawArrow(wxDC& dc,
         x--;
 
     // draw it
         x--;
 
     // draw it
-    dc.DrawBitmap(bmp, x, y, TRUE /* use mask */);
+    dc.DrawBitmap(bmp, x, y, true /* use mask */);
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------
@@ -587,8 +539,10 @@ void wxMetalRenderer::DrawMetal(wxDC &dc, const wxRect &rect )
     dc.SetPen(*wxTRANSPARENT_PEN);
     for (int y = rect.y; y < rect.height+rect.y; y++)
     {
     dc.SetPen(*wxTRANSPARENT_PEN);
     for (int y = rect.y; y < rect.height+rect.y; y++)
     {
-       int intens = 230 + 80 * (rect.y-y) / rect.height;
+       unsigned char intens = (unsigned char)(230 + 80 * (rect.y-y) / rect.height);
        dc.SetBrush( wxBrush( wxColour(intens,intens,intens), wxSOLID ) );
        dc.DrawRectangle( rect.x, y, rect.width, 1 );
     }
 }
        dc.SetBrush( wxBrush( wxColour(intens,intens,intens), wxSOLID ) );
        dc.DrawRectangle( rect.x, y, rect.width, 1 );
     }
 }
+
+#endif // wxUSE_THEME_METAL