]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/scrolbar.cpp
Added ability to switch off more components of the size page UI
[wxWidgets.git] / src / os2 / scrolbar.cpp
index a27773d3080f62eee90b6c05c1110151a9d9c3d6..ed01ed5c964252a9065a2be7a95d9d13f30cdb12 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        scrolbar.cpp
+// Name:        src/os2/scrolbar.cpp
 // Purpose:     wxScrollBar
 // Author:      David Webster
 // Modified by:
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
+#include "wx/scrolbar.h"
+
 #ifndef WX_PRECOMP
-#include "wx/defs.h"
-#include "wx/utils.h"
+    #include "wx/utils.h"
 #endif
 
-#include "wx/scrolbar.h"
 #include "wx/os2/private.h"
 
-IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl)
-
 // Scrollbar
-bool wxScrollBar::Create (
-  wxWindow*                         pParent
-, wxWindowID                        vId
-, const wxPoint&                    rPos
-, const wxSize&                     rSize
-, long                              lStyle
+bool wxScrollBar::Create(wxWindow* pParent,
+                         wxWindowID vId,
+                         const wxPoint& rPos,
+                         const wxSize& rSize,
+                         long lStyle,
 #if wxUSE_VALIDATORS
-, const wxValidator&                rValidator
+                         const wxValidator& rValidator,
 #endif
-, const wxString&                   rsName
-)
+                         const wxString& rsName
+                        )
 {
-    int                             nX = rPos.x;
-    int                             nY = rPos.y;
-    int                             nWidth = rSize.x;
-    int                             nHeight = rSize.y;
+    int nX = rPos.x;
+    int nY = rPos.y;
+    int nWidth = rSize.x;
+    int nHeight = rSize.y;
 
     if (!pParent)
-        return FALSE;
+        return false;
+
     pParent->AddChild(this);
     SetName(rsName);
 #if wxUSE_VALIDATORS
@@ -50,19 +48,19 @@ bool wxScrollBar::Create (
     SetBackgroundColour(pParent->GetBackgroundColour()) ;
     SetForegroundColour(pParent->GetForegroundColour()) ;
 
-    if (vId == -1L)
+    if (vId == wxID_ANY)
         m_windowId = (int)NewControlId();
     else
         m_windowId = vId;
 
-    if (nWidth == -1)
+    if (nWidth == wxDefaultCoord)
     {
         if (lStyle & wxHORIZONTAL)
             nWidth = 140;
         else
             nWidth = 14;
     }
-    if (nHeight == -1)
+    if (nHeight == wxDefaultCoord)
     {
         if (lStyle & wxVERTICAL)
             nHeight = 140;
@@ -75,19 +73,19 @@ bool wxScrollBar::Create (
     if (GetWindowStyleFlag() & wxCLIP_SIBLINGS)
         dwStyle |= WS_CLIPSIBLINGS;
 
-    DWORD                           dwDirection = (lStyle & wxHORIZONTAL) ? SBS_HORZ: SBS_VERT;
+    DWORD dwDirection = (lStyle & wxHORIZONTAL) ? SBS_HORZ: SBS_VERT;
 
-    HWND                            hScrollBar = ::WinCreateWindow( (HWND)GetHwndOf(pParent)
-                                                                   ,WC_SCROLLBAR
-                                                                   ,(PSZ)NULL
-                                                                   ,dwDirection | dwStyle
-                                                                   ,0, 0, 0, 0
-                                                                   ,(HWND)GetHwndOf(pParent)
-                                                                   ,HWND_TOP
-                                                                   ,(HMENU)m_windowId
-                                                                   ,NULL
-                                                                   ,NULL
-                                                                  );
+    HWND hScrollBar = ::WinCreateWindow( (HWND)GetHwndOf(pParent)
+                                         ,WC_SCROLLBAR
+                                         ,(PSZ)NULL
+                                         ,dwDirection | dwStyle
+                                         ,0, 0, 0, 0
+                                         ,(HWND)GetHwndOf(pParent)
+                                         ,HWND_TOP
+                                         ,(HMENU)m_windowId
+                                         ,NULL
+                                         ,NULL
+                                         );
 
     m_nPageSize = 1;
     m_nViewSize = 1;
@@ -97,9 +95,7 @@ bool wxScrollBar::Create (
                  ,(MPARAM)0
                  ,MPFROM2SHORT(0,1)
                 );
-    ::WinShowWindow( hScrollBar
-                    ,TRUE
-                   );
+    ::WinShowWindow( hScrollBar, TRUE );
     SetFont(*wxSMALL_FONT);
 
     m_hWnd = hScrollBar;
@@ -113,28 +109,26 @@ bool wxScrollBar::Create (
             ,nWidth
             ,nHeight
            );
-    return TRUE;
+    return true;
 } // end of wxScrollBar::Create
 
 wxScrollBar::~wxScrollBar()
 {
 }
 
-bool wxScrollBar::OS2OnScroll (
-  int                               nOrientation
-, WXWORD                            wParam
-, WXWORD                            wPos
-, WXHWND                            hControl
-)
+bool wxScrollBar::OS2OnScroll ( int    WXUNUSED(nOrientation),
+                                WXWORD wParam,
+                                WXWORD wPos,
+                                WXHWND WXUNUSED(hControl) )
 {
-    int                             nPosition;
-    int                             nMaxPos;
-    int                             nTrackPos = wPos;
-    int                             nMinPos;
-    int                             nScrollInc;
-    wxEventType                     vScrollEvent = wxEVT_NULL;
+    int         nPosition;
+    int         nMaxPos;
+    int         nTrackPos = wPos;
+    int         nMinPos;
+    int         nScrollInc;
+    wxEventType vScrollEvent = wxEVT_NULL;
 
-    MRESULT                         vRange;
+    MRESULT     vRange;
 
     //
     // When we're dragging the scrollbar we can't use pos parameter because it
@@ -195,7 +189,7 @@ bool wxScrollBar::OS2OnScroll (
 
         case SB_ENDSCROLL:
             nScrollInc   = 0;
-            vScrollEvent = wxEVT_SCROLL_ENDSCROLL;
+            vScrollEvent = wxEVT_SCROLL_CHANGED;
             break;
 
         default:
@@ -212,34 +206,33 @@ bool wxScrollBar::OS2OnScroll (
         SetThumbPosition(nPosition);
     }
     else if ( vScrollEvent != wxEVT_SCROLL_THUMBRELEASE &&
-              vScrollEvent != wxEVT_SCROLL_ENDSCROLL
+              vScrollEvent != wxEVT_SCROLL_CHANGED
             )
     {
         //
         // Don't process the event if there is no displacement,
         // unless this is a thumb release or end scroll event.
         //
-        return FALSE;
+        return false;
     }
 
     wxScrollEvent                   vEvent( vScrollEvent
                                            ,m_windowId
                                           );
 
+    vEvent.SetOrientation(IsVertical() ? wxVERTICAL : wxHORIZONTAL);
     vEvent.SetPosition(nPosition);
     vEvent.SetEventObject(this);
-    return GetEventHandler()->ProcessEvent(vEvent);
+    return HandleWindowEvent(vEvent);
 } // end of wxScrollBar::OS2OnScroll
 
-void wxScrollBar::SetThumbPosition (
-  int                               nViewStart
-)
+void wxScrollBar::SetThumbPosition ( int nViewStart )
 {
     SBCDATA                        vInfo;
 
     memset(&vInfo, '\0', sizeof(SBCDATA));
     vInfo.cb       = sizeof(SBCDATA);
-    vInfo.posThumb = nViewStart;
+    vInfo.posThumb = (SHORT)nViewStart;
 
     ::WinSendMsg((HWND)GetHwnd(), WM_SETWINDOWPARAMS, (MPARAM)&vInfo, (MPARAM)NULL);
     ::WinSendMsg((HWND)GetHwnd(), SBM_SETPOS, (MPARAM)nViewStart, (MPARAM)NULL);
@@ -250,13 +243,11 @@ int wxScrollBar::GetThumbPosition() const
     return((int)(MRESULT)::WinSendMsg((HWND)GetHwnd(), SBM_QUERYPOS, (MPARAM)NULL, (MPARAM)NULL));
 } // end of wxScrollBar::GetThumbPosition
 
-void wxScrollBar::SetScrollbar (
-  int                               nPosition
-, int                               nThumbSize
-, int                               nRange
-, int                               nPageSize
-, bool                              bRefresh
-)
+void wxScrollBar::SetScrollbar ( int  nPosition,
+                                 int  nThumbSize,
+                                 int  nRange,
+                                 int  nPageSize,
+                                 bool WXUNUSED(bRefresh) )
 {
     SBCDATA                         vInfo;
     //
@@ -279,22 +270,20 @@ void wxScrollBar::SetScrollbar (
         nRange1 += (m_nPageSize - 1);
     }
     vInfo.cb = sizeof(SBCDATA);
-    vInfo.cVisible = m_nPageSize;
+    vInfo.cVisible = (SHORT)m_nPageSize;
     vInfo.posFirst = 0;
-    vInfo.posLast  = nRange1;
-    vInfo.posThumb = nPosition;
+    vInfo.posLast  = (SHORT)nRange1;
+    vInfo.posThumb = (SHORT)nPosition;
 
     ::WinSendMsg((HWND)GetHwnd(), WM_SETWINDOWPARAMS, (MPARAM)&vInfo, (MPARAM)NULL);
 } // end of wxScrollBar::SetScrollbar
 
-WXHBRUSH wxScrollBar::OnCtlColor (
-  WXHDC                             hDC
-, WXHWND                            hWnd
-, WXUINT                            uCtlColor
-, WXUINT                            uMessage
-, WXWPARAM                          wParam
-, WXLPARAM                          lParam
-)
+WXHBRUSH wxScrollBar::OnCtlColor ( WXHDC    WXUNUSED(hDC),
+                                   WXHWND   WXUNUSED(hWnd),
+                                   WXUINT   WXUNUSED(uCtlColor),
+                                   WXUINT   WXUNUSED(uMessage),
+                                   WXWPARAM WXUNUSED(wParam),
+                                   WXLPARAM WXUNUSED(lParam) )
 {
     //
     // Does nothing under OS/2
@@ -302,11 +291,8 @@ WXHBRUSH wxScrollBar::OnCtlColor (
     return 0;
 } // end of wxScrollBar::OnCtlColor
 
-void wxScrollBar::Command (
-  wxCommandEvent&                   rEvent
-)
+void wxScrollBar::Command ( wxCommandEvent& rEvent )
 {
-    SetThumbPosition(rEvent.m_commandInt);
+    SetThumbPosition(rEvent.GetInt());
     ProcessCommand(rEvent);
 } // end of wxScrollBar::Command
-