]> git.saurik.com Git - wxWidgets.git/blobdiff - src/univ/slider.cpp
add Scintilla.iface to the distribution
[wxWidgets.git] / src / univ / slider.cpp
index d8fdc3acf3da648c805ee20cbbb3a93da7146f45..0e29c6080665404a15a5feb1e589c5258297248d 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        univ/slider.cpp
+// Name:        src/univ/slider.cpp
 // Purpose:     implementation of the universal version of wxSlider
 // Author:      Vadim Zeitlin
 // Modified by:
     #pragma hdrstop
 #endif
 
-#ifndef WX_PRECOMP
-    #include "wx/dc.h"
-#endif
+#if wxUSE_SLIDER
 
 #include "wx/slider.h"
 
-#if wxUSE_SLIDER
+#ifndef WX_PRECOMP
+    #include "wx/dc.h"
+#endif
 
 #include "wx/univ/renderer.h"
 #include "wx/univ/inphand.h"
 #include "wx/univ/theme.h"
 
+// ----------------------------------------------------------------------------
+// wxStdSliderInputHandler: default slider input handling
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxStdSliderInputHandler : public wxStdInputHandler
+{
+public:
+    // default ctor
+    wxStdSliderInputHandler(wxInputHandler *inphand)
+        : wxStdInputHandler(inphand)
+    {
+    }
+
+    // base class methods
+    virtual bool HandleKey(wxInputConsumer *consumer,
+                           const wxKeyEvent& event,
+                           bool pressed);
+    virtual bool HandleMouse(wxInputConsumer *consumer,
+                             const wxMouseEvent& event);
+    virtual bool HandleMouseMove(wxInputConsumer *consumer,
+                                 const wxMouseEvent& event);
+
+    virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
+};
+
 // ----------------------------------------------------------------------------
 // constants
 // ----------------------------------------------------------------------------
@@ -146,7 +171,7 @@ bool wxSlider::Create(wxWindow *parent,
 
     // call this after setting the range as the best size depends (at least if
     // we have wxSL_LABELS style) on the range
-    SetBestSize(size);
+    SetInitialSize(size);
 
     CreateInputHandler(wxINP_HANDLER_SLIDER);
 
@@ -821,6 +846,14 @@ bool wxSlider::PerformAction(const wxControlAction& action,
     return true;
 }
 
+/* static */
+wxInputHandler *wxSlider::GetStdInputHandler(wxInputHandler *handlerDef)
+{
+    static wxStdSliderInputHandler s_handler(handlerDef);
+
+    return &s_handler;
+}
+
 // ----------------------------------------------------------------------------
 // wxSlider implementation of wxControlWithThumb interface
 // ----------------------------------------------------------------------------
@@ -832,7 +865,7 @@ wxScrollThumb::Shaft wxSlider::HitTest(const wxPoint& pt) const
     CalcThumbRect(&rectShaft, &rectThumb, NULL);
 
     // check for possible shaft or thumb hit
-    if (!rectShaft.Inside(pt) && !rectThumb.Inside(pt))
+    if (!rectShaft.Contains(pt) && !rectThumb.Contains(pt))
     {
         return wxScrollThumb::Shaft_None;
     }
@@ -977,10 +1010,10 @@ bool wxSlider::OnPageScroll(int pageInc)
 }
 
 // ----------------------------------------------------------------------------
-// wxStdSliderButtonInputHandler
+// wxStdSliderInputHandler
 // ----------------------------------------------------------------------------
 
-bool wxStdSliderButtonInputHandler::HandleKey(wxInputConsumer *consumer,
+bool wxStdSliderInputHandler::HandleKey(wxInputConsumer *consumer,
                                               const wxKeyEvent& event,
                                               bool pressed)
 {
@@ -1009,12 +1042,10 @@ bool wxStdSliderButtonInputHandler::HandleKey(wxInputConsumer *consumer,
                 action = wxACTION_SLIDER_LINE_DOWN;
                 break;
 
-            case WXK_PRIOR:
             case WXK_PAGEUP:
                 action = wxACTION_SLIDER_PAGE_UP;
                 break;
 
-            case WXK_NEXT:
             case WXK_PAGEDOWN:
                 action = wxACTION_SLIDER_PAGE_DOWN;
                 break;
@@ -1031,7 +1062,7 @@ bool wxStdSliderButtonInputHandler::HandleKey(wxInputConsumer *consumer,
     return wxStdInputHandler::HandleKey(consumer, event, pressed);
 }
 
-bool wxStdSliderButtonInputHandler::HandleMouse(wxInputConsumer *consumer,
+bool wxStdSliderInputHandler::HandleMouse(wxInputConsumer *consumer,
                                                 const wxMouseEvent& event)
 {
     wxSlider *slider = wxStaticCast(consumer->GetInputWindow(), wxSlider);
@@ -1045,7 +1076,7 @@ bool wxStdSliderButtonInputHandler::HandleMouse(wxInputConsumer *consumer,
     return wxStdInputHandler::HandleMouse(consumer, event);
 }
 
-bool wxStdSliderButtonInputHandler::HandleMouseMove(wxInputConsumer *consumer,
+bool wxStdSliderInputHandler::HandleMouseMove(wxInputConsumer *consumer,
                                                     const wxMouseEvent& event)
 {
     wxSlider *slider = wxStaticCast(consumer->GetInputWindow(), wxSlider);
@@ -1060,10 +1091,10 @@ bool wxStdSliderButtonInputHandler::HandleMouseMove(wxInputConsumer *consumer,
 }
 
 bool
-wxStdSliderButtonInputHandler::HandleFocus(wxInputConsumer * WXUNUSED(consumer),
+wxStdSliderInputHandler::HandleFocus(wxInputConsumer * WXUNUSED(consumer),
                                            const wxFocusEvent& WXUNUSED(event))
 {
-    // slider's appearance changes when it gets/loses focus
+    // slider appearance changes when it gets/loses focus
     return true;
 }