]> git.saurik.com Git - wxWidgets.git/blobdiff - src/univ/themes/win32.cpp
added wxWindow::IsFrozen() (only existed in wxMSW and wxDFB before)
[wxWidgets.git] / src / univ / themes / win32.cpp
index 48959999ee4a9a21ab1a78e84cede9e4f31d9d08..6608ee824a5c71a5eb16287c002a0dc9b4766e95 100644 (file)
@@ -40,7 +40,6 @@
     #include "wx/scrolbar.h"
     #include "wx/slider.h"
     #include "wx/textctrl.h"
-    #include "wx/listbox.h"
     #include "wx/toolbar.h"
     #include "wx/statusbr.h"
 
     #endif
     #include "wx/menu.h"
     #include "wx/settings.h"
+    #include "wx/toplevel.h"
+    #include "wx/image.h"
 #endif // WX_PRECOMP
 
 #include "wx/notebook.h"
 #include "wx/spinbutt.h"
 #include "wx/artprov.h"
-#include "wx/toplevel.h"
-#include "wx/image.h"
 #ifdef wxUSE_TOGGLEBTN
 #include "wx/tglbtn.h"
 #endif // wxUSE_TOGGLEBTN
@@ -244,6 +243,7 @@ public:
                                  int flags = 0,
                                  wxAlignment align = wxALIGN_LEFT,
                                  int indexAccel = -1);
+#if wxUSE_TOOLBAR
     virtual void DrawToolBarButton(wxDC& dc,
                                    const wxString& label,
                                    const wxBitmap& bitmap,
@@ -251,6 +251,7 @@ public:
                                    int flags = 0,
                                    long style = 0,
                                    int tbarStyle = 0);
+#endif // wxUSE_TOOLBAR
     virtual void DrawTextLine(wxDC& dc,
                               const wxString& text,
                               const wxRect& rect,
@@ -266,6 +267,7 @@ public:
                          int flags = 0,
                          int indexAccel = -1);
 
+#if wxUSE_SLIDER
     virtual void DrawSliderShaft(wxDC& dc,
                                  const wxRect& rect,
                                  int lenThumb,
@@ -287,7 +289,9 @@ public:
                                  int step = 1,
                                  int flags = 0,
                                  long style = 0);
+#endif // wxUSE_SLIDER
 
+#if wxUSE_MENUS
     virtual void DrawMenuBarItem(wxDC& dc,
                                  const wxRect& rect,
                                  const wxString& label,
@@ -304,11 +308,14 @@ public:
     virtual void DrawMenuSeparator(wxDC& dc,
                                    wxCoord y,
                                    const wxMenuGeometryInfo& geomInfo);
+#endif // wxUSE_MENUS
 
+#if wxUSE_STATUSBAR
     virtual void DrawStatusField(wxDC& dc,
                                  const wxRect& rect,
                                  const wxString& label,
                                  int flags = 0, int style = 0);
+#endif // wxUSE_STATUSBAR
 
     // titlebars
     virtual void DrawFrameTitleBar(wxDC& dc,
@@ -353,6 +360,8 @@ public:
 
     virtual wxSize GetScrollbarArrowSize() const
         { return m_sizeScrollbarArrow; }
+
+#if wxUSE_SCROLLBAR
     virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
                                     wxScrollBar::Element elem,
                                     int thumbPos = -1) const;
@@ -362,6 +371,8 @@ public:
     virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
                                      int thumbPos = -1);
     virtual int PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord);
+#endif // wxUSE_SCROLLBAR
+
     virtual wxCoord GetListboxItemHeight(wxCoord fontHeight)
         { return fontHeight + 2; }
     virtual wxSize GetCheckBitmapSize() const
@@ -376,15 +387,19 @@ public:
     virtual wxSize GetToolBarMargin() const
         { return wxSize(4, 4); }
 
+#if wxUSE_TEXTCTRL
     virtual wxRect GetTextTotalArea(const wxTextCtrl *text,
                                     const wxRect& rect) const;
     virtual wxRect GetTextClientArea(const wxTextCtrl *text,
                                      const wxRect& rect,
                                      wxCoord *extraSpaceBeyond) const;
+#endif // wxUSE_TEXTCTRL
 
     virtual wxSize GetTabIndent() const { return wxSize(2, 2); }
     virtual wxSize GetTabPadding() const { return wxSize(6, 5); }
 
+#if wxUSE_SLIDER
+
     virtual wxCoord GetSliderDim() const { return SLIDER_THUMB_LENGTH + 2*BORDER_THICKNESS; }
     virtual wxCoord GetSliderTickLen() const { return SLIDER_TICK_LENGTH; }
     virtual wxRect GetSliderShaftRect(const wxRect& rect,
@@ -394,13 +409,19 @@ public:
     virtual wxSize GetSliderThumbSize(const wxRect& rect,
                                       int lenThumb,
                                       wxOrientation orient) const;
+#endif // wxUSE_SLIDER
+
     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;
+#endif // wxUSE_MENUS
 
+#if wxUSE_STATUSBAR
     virtual wxSize GetStatusBarBorders(wxCoord *borderBetweenFields) const;
+#endif // wxUSE_STATUSBAR
 
 protected:
     // helper of DrawLabel() and DrawCheckOrRadioButton()
@@ -544,6 +565,7 @@ protected:
     wxWin32Renderer *m_renderer;
 };
 
+#if wxUSE_SCROLLBAR
 class wxWin32ScrollBarInputHandler : public wxStdScrollBarInputHandler
 {
 public:
@@ -575,7 +597,9 @@ protected:
     // we remember the interval of the timer to be able to restart it
     int m_interval;
 };
+#endif // wxUSE_SCROLLBAR
 
+#if wxUSE_CHECKBOX
 class wxWin32CheckboxInputHandler : public wxStdCheckboxInputHandler
 {
 public:
@@ -586,7 +610,9 @@ public:
                            const wxKeyEvent& event,
                            bool pressed);
 };
+#endif // wxUSE_CHECKBOX
 
+#if wxUSE_TEXTCTRL
 class wxWin32TextCtrlInputHandler : public wxStdTextCtrlInputHandler
 {
 public:
@@ -597,6 +623,7 @@ public:
                            const wxKeyEvent& event,
                            bool pressed);
 };
+#endif // wxUSE_TEXTCTRL
 
 class wxWin32StatusBarInputHandler : public wxStdInputHandler
 {
@@ -627,14 +654,16 @@ class wxWin32FrameInputHandler : public wxStdFrameInputHandler
 {
 public:
     wxWin32FrameInputHandler(wxInputHandler *handler);
-    ~wxWin32FrameInputHandler();
+    virtual ~wxWin32FrameInputHandler();
 
     virtual bool HandleMouse(wxInputConsumer *control,
                              const wxMouseEvent& event);
 
     virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
 
+#if wxUSE_MENUS
     void PopupSystemMenu(wxTopLevelWindow *window, const wxPoint& pos) const;
+#endif // wxUSE_MENUS
 
 private:
     // was the mouse over the grip last time we checked?
@@ -1298,14 +1327,18 @@ wxInputHandler *wxWin32Theme::GetDefaultInputHandler()
 
 wxInputHandler *wxWin32Theme::GetInputHandler(const wxString& control)
 {
-    wxInputHandler *handler;
+    wxInputHandler *handler = NULL;
     int n = m_handlerNames.Index(control);
     if ( n == wxNOT_FOUND )
     {
         // create a new handler
         if ( control == wxINP_HANDLER_SCROLLBAR )
+        {
+#if wxUSE_SCROLLBAR
             handler = new wxWin32ScrollBarInputHandler(m_renderer,
                                                        GetDefaultInputHandler());
+#endif // wxUSE_SCROLLBAR
+        }
 #if wxUSE_BUTTON
         else if ( control == wxINP_HANDLER_BUTTON )
             handler = new wxStdButtonInputHandler(GetDefaultInputHandler());
@@ -1352,7 +1385,8 @@ wxInputHandler *wxWin32Theme::GetInputHandler(const wxString& control)
 #endif // wxUSE_TOOLBAR
         else if ( control == wxINP_HANDLER_TOPLEVEL )
             handler = new wxWin32FrameInputHandler(GetDefaultInputHandler());
-        else
+
+        if(!handler)
             handler = GetDefaultInputHandler();
 
         n = m_handlerNames.Add(control);
@@ -1390,10 +1424,14 @@ wxColour wxWin32ColourScheme::GetBackground(wxWindow *win) const
 
     if ( !win->ShouldInheritColours() )
     {
+#if wxUSE_TEXTCTRL
         wxTextCtrl *text = wxDynamicCast(win, wxTextCtrl);
+#endif // wxUSE_TEXTCTRL
 #if wxUSE_LISTBOX
         wxListBox* listBox = wxDynamicCast(win, wxListBox);
-#endif
+#endif // wxUSE_LISTBOX
+
+#if wxUSE_TEXTCTRL
         if ( text
 #if wxUSE_LISTBOX
          || listBox
@@ -1411,6 +1449,7 @@ wxColour wxWin32ColourScheme::GetBackground(wxWindow *win) const
                 }
             }
         }
+#endif // wxUSE_TEXTCTRL
 
         if (!col.Ok())
             col = Get(CONTROL); // Most controls should be this colour, not WINDOW
@@ -1423,10 +1462,12 @@ wxColour wxWin32ColourScheme::GetBackground(wxWindow *win) const
         // and for the states for which we don't have any specific colours
         if ( !col.Ok() || (flags & wxCONTROL_PRESSED) != 0 )
         {
+#if wxUSE_SCROLLBAR
             if ( wxDynamicCast(win, wxScrollBar) )
                 col = Get(flags & wxCONTROL_PRESSED ? SCROLLBAR_PRESSED
                                                     : SCROLLBAR);
             else
+#endif // wxUSE_SCROLLBAR
                 col = Get(CONTROL);
         }
     }
@@ -2476,6 +2517,7 @@ void wxWin32Renderer::DrawCheckButton(wxDC& dc,
                            0); // no focus rect offset for checkboxes
 }
 
+#if wxUSE_TOOLBAR
 void wxWin32Renderer::DrawToolBarButton(wxDC& dc,
                                         const wxString& label,
                                         const wxBitmap& bitmap,
@@ -2537,6 +2579,7 @@ void wxWin32Renderer::DrawToolBarButton(wxDC& dc,
     }
     // don't draw wxTOOL_STYLE_CONTROL
 }
+#endif // wxUSE_TOOLBAR
 
 // ----------------------------------------------------------------------------
 // text control
@@ -2628,12 +2671,20 @@ void wxWin32Renderer::DrawTab(wxDC& dc,
         dcMem.SetFont(dc.GetFont());
         dcMem.SetTextForeground(dc.GetTextForeground());
         dcMem.Clear();
-        bitmapRotated = wxBitmap( wxImage( bitmap.ConvertToImage() ).Rotate90(dir==wxLEFT) );
+        bitmapRotated =
+#if wxUSE_IMAGE
+                        wxBitmap( wxImage( bitmap.ConvertToImage() ).Rotate90(dir==wxLEFT) )
+#else
+                        bitmap
+#endif // wxUSE_IMAGE
+                        ;
         DrawButtonLabel(dcMem, label, bitmapRotated, rectLabel,
                         flags, wxALIGN_CENTRE, indexAccel);
         dcMem.SelectObject(wxNullBitmap);
         bitmapMem = bitmapMem.GetSubBitmap(rectLabel);
+#if wxUSE_IMAGE
         bitmapMem = wxBitmap(wxImage(bitmapMem.ConvertToImage()).Rotate90(dir==wxRIGHT));
+#endif // wxUSE_IMAGE
         dc.DrawBitmap(bitmapMem, rectLabel.y, rectLabel.x, false);
     }
     else
@@ -2738,6 +2789,8 @@ void wxWin32Renderer::DrawTab(wxDC& dc,
     #undef REVERSE_FOR_VERTICAL
 }
 
+#if wxUSE_SLIDER
+
 // ----------------------------------------------------------------------------
 // slider
 // ----------------------------------------------------------------------------
@@ -3087,6 +3140,10 @@ void wxWin32Renderer::DrawSliderTicks(wxDC& dc,
     }
 }
 
+#endif // wxUSE_SLIDER
+
+#if wxUSE_MENUS
+
 // ----------------------------------------------------------------------------
 // menu and menubar
 // ----------------------------------------------------------------------------
@@ -3349,6 +3406,10 @@ wxMenuGeometryInfo *wxWin32Renderer::GetMenuGeometry(wxWindow *win,
     return gi;
 }
 
+#endif // wxUSE_MENUS
+
+#if wxUSE_STATUSBAR
+
 // ----------------------------------------------------------------------------
 // status bar
 // ----------------------------------------------------------------------------
@@ -3441,6 +3502,8 @@ void wxWin32Renderer::DrawStatusField(wxDC& dc,
     DrawLabel(dc, label, rectIn, flags, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
 }
 
+#endif // wxUSE_STATUSBAR
+
 // ----------------------------------------------------------------------------
 // combobox
 // ----------------------------------------------------------------------------
@@ -3601,6 +3664,8 @@ void wxWin32Renderer::DrawScrollCorner(wxDC& dc, const wxRect& rect)
     DoDrawBackground(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
 }
 
+#if wxUSE_SCROLLBAR
+
 wxRect wxWin32Renderer::GetScrollbarRect(const wxScrollBar *scrollbar,
                                          wxScrollBar::Element elem,
                                          int thumbPos) const
@@ -3632,6 +3697,8 @@ int wxWin32Renderer::PixelToScrollbar(const wxScrollBar *scrollbar,
     return StandardPixelToScrollbar(scrollbar, coord, m_sizeScrollbarArrow);
 }
 
+#endif // wxUSE_SCROLLBAR
+
 // ----------------------------------------------------------------------------
 // top level windows
 // ----------------------------------------------------------------------------
@@ -3640,7 +3707,7 @@ int wxWin32Renderer::HitTestFrame(const wxRect& rect, const wxPoint& pt, int fla
 {
     wxRect client = GetFrameClientArea(rect, flags);
 
-    if ( client.Inside(pt) )
+    if ( client.Contains(pt) )
         return wxHT_TOPLEVEL_CLIENT_AREA;
 
     if ( flags & wxTOPLEVEL_TITLEBAR )
@@ -3649,7 +3716,7 @@ int wxWin32Renderer::HitTestFrame(const wxRect& rect, const wxPoint& pt, int fla
 
         if ( flags & wxTOPLEVEL_ICON )
         {
-            if ( wxRect(client.GetPosition(), GetFrameIconSize()).Inside(pt) )
+            if ( wxRect(client.GetPosition(), GetFrameIconSize()).Contains(pt) )
                 return wxHT_TOPLEVEL_ICON;
         }
 
@@ -3659,31 +3726,31 @@ int wxWin32Renderer::HitTestFrame(const wxRect& rect, const wxPoint& pt, int fla
 
         if ( flags & wxTOPLEVEL_BUTTON_CLOSE )
         {
-            if ( btnRect.Inside(pt) )
+            if ( btnRect.Contains(pt) )
                 return wxHT_TOPLEVEL_BUTTON_CLOSE;
             btnRect.x -= FRAME_BUTTON_WIDTH + 2;
         }
         if ( flags & wxTOPLEVEL_BUTTON_MAXIMIZE )
         {
-            if ( btnRect.Inside(pt) )
+            if ( btnRect.Contains(pt) )
                 return wxHT_TOPLEVEL_BUTTON_MAXIMIZE;
             btnRect.x -= FRAME_BUTTON_WIDTH;
         }
         if ( flags & wxTOPLEVEL_BUTTON_RESTORE )
         {
-            if ( btnRect.Inside(pt) )
+            if ( btnRect.Contains(pt) )
                 return wxHT_TOPLEVEL_BUTTON_RESTORE;
             btnRect.x -= FRAME_BUTTON_WIDTH;
         }
         if ( flags & wxTOPLEVEL_BUTTON_ICONIZE )
         {
-            if ( btnRect.Inside(pt) )
+            if ( btnRect.Contains(pt) )
                 return wxHT_TOPLEVEL_BUTTON_ICONIZE;
             btnRect.x -= FRAME_BUTTON_WIDTH;
         }
         if ( flags & wxTOPLEVEL_BUTTON_HELP )
         {
-            if ( btnRect.Inside(pt) )
+            if ( btnRect.Contains(pt) )
                 return wxHT_TOPLEVEL_BUTTON_HELP;
             btnRect.x -= FRAME_BUTTON_WIDTH;
         }
@@ -4291,6 +4358,8 @@ wxBitmap wxWin32ArtProvider::CreateBitmap(const wxArtID& id,
 }
 
 
+#if wxUSE_TEXTCTRL
+
 // ----------------------------------------------------------------------------
 // text control geometry
 // ----------------------------------------------------------------------------
@@ -4335,6 +4404,8 @@ wxWin32Renderer::GetTextClientArea(const wxTextCtrl * WXUNUSED(text),
     return rectText;
 }
 
+#endif // wxUSE_TEXTCTRL
+
 // ----------------------------------------------------------------------------
 // size adjustments
 // ----------------------------------------------------------------------------
@@ -4447,6 +4518,8 @@ bool wxWin32InputHandler::HandleMouse(wxInputConsumer *control,
     return false;
 }
 
+#if wxUSE_SCROLLBAR
+
 // ----------------------------------------------------------------------------
 // wxWin32ScrollBarInputHandler
 // ----------------------------------------------------------------------------
@@ -4629,6 +4702,10 @@ bool wxWin32ScrollBarInputHandler::HandleMouseMove(wxInputConsumer *control,
     return wxStdScrollBarInputHandler::HandleMouseMove(control, event);
 }
 
+#endif // wxUSE_SCROLLBAR
+
+#if wxUSE_CHECKBOX
+
 // ----------------------------------------------------------------------------
 // wxWin32CheckboxInputHandler
 // ----------------------------------------------------------------------------
@@ -4670,6 +4747,10 @@ bool wxWin32CheckboxInputHandler::HandleKey(wxInputConsumer *control,
     return false;
 }
 
+#endif // wxUSE_CHECKBOX
+
+#if wxUSE_TEXTCTRL
+
 // ----------------------------------------------------------------------------
 // wxWin32TextCtrlInputHandler
 // ----------------------------------------------------------------------------
@@ -4708,6 +4789,10 @@ bool wxWin32TextCtrlInputHandler::HandleKey(wxInputConsumer *control,
     return wxStdTextCtrlInputHandler::HandleKey(control, event, pressed);
 }
 
+#endif // wxUSE_TEXTCTRL
+
+#if wxUSE_STATUSBAR
+
 // ----------------------------------------------------------------------------
 // wxWin32StatusBarInputHandler
 // ----------------------------------------------------------------------------
@@ -4801,6 +4886,8 @@ bool wxWin32StatusBarInputHandler::HandleMouseMove(wxInputConsumer *consumer,
     return wxStdInputHandler::HandleMouseMove(consumer, event);
 }
 
+#endif // wxUSE_STATUSBAR
+
 // ----------------------------------------------------------------------------
 // wxWin32FrameInputHandler
 // ----------------------------------------------------------------------------
@@ -4884,7 +4971,9 @@ void wxWin32SystemMenuEvtHandler::OnSystemMenu(wxCommandEvent &WXUNUSED(event))
     m_wnd->SetAcceleratorTable(wxNullAcceleratorTable);
 #endif
 
+#if wxUSE_MENUS
     m_inputHnd->PopupSystemMenu(m_wnd, pt);
+#endif // wxUSE_MENUS
 
 #if wxUSE_ACCEL
     m_wnd->SetAcceleratorTable(table);
@@ -4943,7 +5032,9 @@ bool wxWin32FrameInputHandler::HandleMouse(wxInputConsumer *consumer,
                       (hit == wxHT_TOPLEVEL_TITLEBAR ||
                        hit == wxHT_TOPLEVEL_ICON)) )
             {
+#if wxUSE_MENUS
                 PopupSystemMenu(tlw, event.GetPosition());
+#endif // wxUSE_MENUS
                 return true;
             }
         }
@@ -4952,6 +5043,8 @@ bool wxWin32FrameInputHandler::HandleMouse(wxInputConsumer *consumer,
     return wxStdFrameInputHandler::HandleMouse(consumer, event);
 }
 
+#if wxUSE_MENUS
+
 void wxWin32FrameInputHandler::PopupSystemMenu(wxTopLevelWindow *window,
                                                const wxPoint& pos) const
 {
@@ -4986,6 +5079,8 @@ void wxWin32FrameInputHandler::PopupSystemMenu(wxTopLevelWindow *window,
     delete menu;
 }
 
+#endif // wxUSE_MENUS
+
 bool wxWin32FrameInputHandler::HandleActivation(wxInputConsumer *consumer,
                                                 bool activated)
 {