]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/slider.cpp
Follow changes in common code.
[wxWidgets.git] / src / os2 / slider.cpp
index b97747f687fd17fe90e7a8baf9a565cff22a455b..e2827fa6ce3def706b6e7fdf5a62feddbacf065f 100644 (file)
@@ -52,25 +52,24 @@ wxSlider::~wxSlider()
         ::WinDestroyWindow((HWND)m_hStaticValue);
 } // end of wxSlider::~wxSlider
 
         ::WinDestroyWindow((HWND)m_hStaticValue);
 } // end of wxSlider::~wxSlider
 
-void wxSlider::AdjustSubControls(
-  int                               nX
-, int                               nY
-, int                               nWidth
-, int                               nHeight
-, int                               nSizeFlags
-)
+void wxSlider::AdjustSubControls( int nX,
+                                  int nY,
+                                  int nWidth,
+                                  int nHeight,
+                                  int WXUNUSED(nSizeFlags) )
 {
     int                             nXOffset = nX;
     int                             nYOffset = nY;
     int                             nCx;     // slider,min,max sizes
     int                             nCy;
     int                             nCyf;
 {
     int                             nXOffset = nX;
     int                             nYOffset = nY;
     int                             nCx;     // slider,min,max sizes
     int                             nCy;
     int                             nCyf;
-    char                            zBuf[300];
+    wxChar                          zBuf[300];
+    wxFont                          vFont = this->GetFont();
 
     wxGetCharSize( GetHWND()
                   ,&nCx
                   ,&nCy
 
     wxGetCharSize( GetHWND()
                   ,&nCx
                   ,&nCy
-                  ,&this->GetFont()
+                  ,&vFont
                  );
 
     if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL)
                  );
 
     if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL)
@@ -80,11 +79,11 @@ void wxSlider::AdjustSubControls(
             int                     nMinLen = 0;
             int                     nMaxLen = 0;
 
             int                     nMinLen = 0;
             int                     nMaxLen = 0;
 
-            ::WinQueryWindowText((HWND)m_hStaticMin, 300, zBuf);
-            GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &this->GetFont());
+            ::WinQueryWindowText((HWND)m_hStaticMin, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &vFont);
 
 
-            ::WinQueryWindowText((HWND)m_hStaticMax, 300, zBuf);
-            GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &this->GetFont());
+            ::WinQueryWindowText((HWND)m_hStaticMax, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &vFont);
 
             if (m_hStaticValue)
             {
 
             if (m_hStaticValue)
             {
@@ -131,11 +130,11 @@ void wxSlider::AdjustSubControls(
             int                     nMinLen = 0;
             int                     nMaxLen = 0;
 
             int                     nMinLen = 0;
             int                     nMaxLen = 0;
 
-            ::WinQueryWindowText((HWND)m_hStaticMin, 300, zBuf);
-            GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &this->GetFont());
+            ::WinQueryWindowText((HWND)m_hStaticMin, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &vFont);
 
 
-            ::WinQueryWindowText((HWND)m_hStaticMax, 300, zBuf);
-            GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &this->GetFont());
+            ::WinQueryWindowText((HWND)m_hStaticMax, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &vFont);
 
             if (m_hStaticValue)
             {
 
             if (m_hStaticValue)
             {
@@ -260,7 +259,7 @@ bool wxSlider::Create(
         //
         // Now create min static control
         //
         //
         // Now create min static control
         //
-        sprintf(wxBuffer, "%d", nMinValue);
+        wxSprintf(wxBuffer, wxT("%d"), nMinValue);
         lWstyle = SS_TEXT|DT_LEFT|WS_VISIBLE;
         if (m_windowStyle & wxCLIP_SIBLINGS)
             lWstyle |= WS_CLIPSIBLINGS;
         lWstyle = SS_TEXT|DT_LEFT|WS_VISIBLE;
         if (m_windowStyle & wxCLIP_SIBLINGS)
             lWstyle |= WS_CLIPSIBLINGS;
@@ -311,20 +310,20 @@ bool wxSlider::Create(
     lMsStyle |= SLS_RIBBONSTRIP;
 
     m_nPageSize = ((nMaxValue - nMinValue)/10);
     lMsStyle |= SLS_RIBBONSTRIP;
 
     m_nPageSize = ((nMaxValue - nMinValue)/10);
-    vSlData.usScale1Increments = m_nPageSize;
-    vSlData.usScale2Increments = m_nPageSize;
-
-    HWND                            hScrollBar = ::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle
-                                                                   ,WC_SLIDER                // Window class
-                                                                   ,(PSZ)wxBuffer            // Initial Text
-                                                                   ,(ULONG)lMsStyle          // Style flags
-                                                                   ,0L, 0L, 0L, 0L           // Origin -- 0 size
-                                                                   ,(HWND)GetHwndOf(pParent) // owner window handle (same as parent
-                                                                   ,HWND_BOTTOM                 // initial z position
-                                                                   ,(HMENU)m_windowId       // Window identifier
-                                                                   ,&vSlData                 // Slider control data
-                                                                   ,NULL                     // no Presentation parameters
-                                                                  );
+    vSlData.usScale1Increments = (USHORT)m_nPageSize;
+    vSlData.usScale2Increments = (USHORT)m_nPageSize;
+
+    HWND hScrollBar = ::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle
+                                        ,WC_SLIDER                // Window class
+                                        ,(PSZ)wxBuffer            // Initial Text
+                                        ,(ULONG)lMsStyle          // Style flags
+                                        ,0L, 0L, 0L, 0L           // Origin -- 0 size
+                                        ,(HWND)GetHwndOf(pParent) // owner window handle (same as parent
+                                        ,HWND_BOTTOM                 // initial z position
+                                        ,(HMENU)m_windowId       // Window identifier
+                                        ,&vSlData                 // Slider control data
+                                        ,NULL                     // no Presentation parameters
+                                       );
     m_nRangeMax = nMaxValue;
     m_nRangeMin = nMinValue;
 
     m_nRangeMax = nMaxValue;
     m_nRangeMin = nMinValue;
 
@@ -355,7 +354,7 @@ bool wxSlider::Create(
         //
         // Finally, create max value static item
         //
         //
         // Finally, create max value static item
         //
-        sprintf(wxBuffer, "%d", nMaxValue);
+        wxSprintf(wxBuffer, wxT("%d"), nMaxValue);
         lWstyle = SS_TEXT|DT_LEFT|WS_VISIBLE;
         if (m_windowStyle & wxCLIP_SIBLINGS)
             lMsStyle |= WS_CLIPSIBLINGS;
         lWstyle = SS_TEXT|DT_LEFT|WS_VISIBLE;
         if (m_windowStyle & wxCLIP_SIBLINGS)
             lMsStyle |= WS_CLIPSIBLINGS;
@@ -409,7 +408,7 @@ bool wxSlider::Create(
 
     wxColour                        vColour;
 
 
     wxColour                        vColour;
 
-    vColour.Set(wxString("BLACK"));
+    vColour.Set(wxString(wxT("BLACK")));
 
     LONG                            lColor = (LONG)vColour.GetPixel();
 
 
     LONG                            lColor = (LONG)vColour.GetPixel();
 
@@ -454,7 +453,7 @@ bool wxSlider::Create(
                       ,sizeof(LONG)
                       ,(PVOID)&lColor
                      );
                       ,sizeof(LONG)
                       ,(PVOID)&lColor
                      );
-    vColour.Set(wxString("BLUE"));
+    vColour.Set(wxString(wxT("BLUE")));
     lColor = (LONG)vColour.GetPixel();
     ::WinSetPresParam( m_hWnd
                       ,PP_HILITEBACKGROUNDCOLOR
     lColor = (LONG)vColour.GetPixel();
     ::WinSetPresParam( m_hWnd
                       ,PP_HILITEBACKGROUNDCOLOR
@@ -484,7 +483,8 @@ void wxSlider::DoSetSize(
     int                             nCyf;
     int                             nCurrentX;
     int                             nCurrentY;
     int                             nCyf;
     int                             nCurrentX;
     int                             nCurrentY;
-    char                            zBuf[300];
+    wxChar                          zBuf[300];
+    wxFont                          vFont = this->GetFont();
 
     //
     // Adjust for OS/2's reverse coordinate system
 
     //
     // Adjust for OS/2's reverse coordinate system
@@ -530,7 +530,7 @@ void wxSlider::DoSetSize(
     wxGetCharSize( GetHWND()
                   ,&nCx
                   ,&nCy
     wxGetCharSize( GetHWND()
                   ,&nCx
                   ,&nCy
-                  ,&this->GetFont()
+                  ,&vFont
                  );
 
     if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL)
                  );
 
     if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL)
@@ -540,10 +540,10 @@ void wxSlider::DoSetSize(
             int                  nMinLen = 0;
             int                  nMaxLen = 0;
 
             int                  nMinLen = 0;
             int                  nMaxLen = 0;
 
-            ::WinQueryWindowText((HWND)m_hStaticMin, 300, zBuf);
-            GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &this->GetFont());
-            ::WinQueryWindowText((HWND)m_hStaticMax, 300, zBuf);
-            GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &this->GetFont());
+            ::WinQueryWindowText((HWND)m_hStaticMin, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &vFont);
+            ::WinQueryWindowText((HWND)m_hStaticMax, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &vFont);
 
             if (m_hStaticValue)
             {
 
             if (m_hStaticValue)
             {
@@ -647,10 +647,10 @@ void wxSlider::DoSetSize(
             int                  nMinLen;
             int                  nMaxLen;
 
             int                  nMinLen;
             int                  nMaxLen;
 
-            ::WinQueryWindowText((HWND)m_hStaticMin, 300, zBuf);
-            GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &this->GetFont());
-            ::WinQueryWindowText((HWND)m_hStaticMax, 300, zBuf);
-            GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &this->GetFont());
+            ::WinQueryWindowText((HWND)m_hStaticMin, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &vFont);
+            ::WinQueryWindowText((HWND)m_hStaticMax, 300, (PSZ)zBuf);
+            GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &vFont);
             if (m_hStaticValue)
             {
                 int              nNewWidth = wxMax(nMinLen, nMaxLen);
             if (m_hStaticValue)
             {
                 int              nNewWidth = wxMax(nMinLen, nMaxLen);
@@ -920,14 +920,12 @@ WXHBRUSH wxSlider::OnCtlColor(
            );
 } // end of wxSlider::OnCtlColor
 
            );
 } // end of wxSlider::OnCtlColor
 
-bool wxSlider::OS2OnScroll(
-  int                               WXUNUSED(nOrientation)
-, WXWORD                            wParam
-, WXWORD                            wPos
-, WXHWND                            hControl
-)
+bool wxSlider::OS2OnScroll( int    WXUNUSED(nOrientation),
+                            WXWORD wParam,
+                            WXWORD WXUNUSED(wPos),
+                            WXHWND WXUNUSED(hControl) )
 {
 {
-    wxEventType                     eScrollEvent = wxEVT_NULL;
+    wxEventType eScrollEvent = wxEVT_NULL;
 
     switch (wParam)
     {
 
     switch (wParam)
     {
@@ -946,24 +944,21 @@ bool wxSlider::OS2OnScroll(
             return false;
     }
 
             return false;
     }
 
-    int                             nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd()
-                                                                            ,SLM_QUERYSLIDERINFO
-                                                                            ,MPFROM2SHORT( SMA_SHAFTDIMENSIONS
-                                                                                          ,SMA_RANGEVALUE
-                                                                                         )
-                                                                            ,(MPARAM)0
-                                                                           )
-                                                              );
+    int nPixelRange = SHORT1FROMMR(::WinSendMsg( GetHwnd()
+                                               , SLM_QUERYSLIDERINFO
+                                               , MPFROM2SHORT( SMA_SHAFTDIMENSIONS, SMA_RANGEVALUE )
+                                               , (MPARAM)0
+                                               )
+                                  );
     m_dPixelToRange = (double)(nPixelRange - m_nThumbLength)/(double)(m_nRangeMax - m_nRangeMin);
     m_dPixelToRange = (double)(nPixelRange - m_nThumbLength)/(double)(m_nRangeMax - m_nRangeMin);
-    int                             nNewPos = 0;
-    int                             nPixelPos = SHORT1FROMMR(::WinSendMsg( GetHwnd()
-                                                                          ,SLM_QUERYSLIDERINFO
-                                                                          ,MPFROM2SHORT( SMA_SLIDERARMPOSITION
-                                                                                        ,SMA_RANGEVALUE
-                                                                                       )
-                                                                          ,(MPARAM)0
-                                                                         )
-                                                            );
+    int nNewPos = 0;
+    int nPixelPos = SHORT1FROMMR(::WinSendMsg( GetHwnd()
+                                             , SLM_QUERYSLIDERINFO
+                                             , MPFROM2SHORT( SMA_SLIDERARMPOSITION, SMA_RANGEVALUE )
+                                             , (MPARAM)0
+                                             )
+                                );
+
     nNewPos = (int)(nPixelPos/m_dPixelToRange);
     if (nNewPos > (m_nRangeMax - m_nRangeMin)/2)
         nNewPos++;
     nNewPos = (int)(nPixelPos/m_dPixelToRange);
     if (nNewPos > (m_nRangeMax - m_nRangeMin)/2)
         nNewPos++;
@@ -976,34 +971,26 @@ bool wxSlider::OS2OnScroll(
     }
     SetValue(nNewPos);
 
     }
     SetValue(nNewPos);
 
-    wxScrollEvent                   vEvent( eScrollEvent
-                                           ,m_windowId
-                                          );
+    wxScrollEvent vEvent( eScrollEvent, m_windowId );
 
     vEvent.SetPosition(nNewPos);
     vEvent.SetEventObject(this);
     GetEventHandler()->ProcessEvent(vEvent);
 
 
     vEvent.SetPosition(nNewPos);
     vEvent.SetEventObject(this);
     GetEventHandler()->ProcessEvent(vEvent);
 
-    wxCommandEvent                  vCevent( wxEVT_COMMAND_SLIDER_UPDATED
-                                            ,GetId()
-                                           );
+    wxCommandEvent vCevent( wxEVT_COMMAND_SLIDER_UPDATED, GetId() );
 
     vCevent.SetInt(nNewPos);
     vCevent.SetEventObject(this);
     return (GetEventHandler()->ProcessEvent(vCevent));
 } // end of wxSlider::OS2OnScroll
 
 
     vCevent.SetInt(nNewPos);
     vCevent.SetEventObject(this);
     return (GetEventHandler()->ProcessEvent(vCevent));
 } // end of wxSlider::OS2OnScroll
 
-void wxSlider::SetLineSize(
-  int                               nLineSize
-)
+void wxSlider::SetLineSize( int nLineSize )
 {
     m_nLineSize = nLineSize;
 } // end of wxSlider::SetLineSize
 
 
 {
     m_nLineSize = nLineSize;
 } // end of wxSlider::SetLineSize
 
 
-void wxSlider::SetPageSize(
-  int                               nPageSize
-)
+void wxSlider::SetPageSize( int nPageSize )
 {
     m_nPageSize = nPageSize;
 } // end of wxSlider::SetPageSize
 {
     m_nPageSize = nPageSize;
 } // end of wxSlider::SetPageSize
@@ -1030,13 +1017,13 @@ void wxSlider::SetRange(
     if (m_hStaticMin)
     {
         wxSprintf(zBuf, wxT("%d"), m_nRangeMin);
     if (m_hStaticMin)
     {
         wxSprintf(zBuf, wxT("%d"), m_nRangeMin);
-        ::WinSetWindowText((HWND)m_hStaticMin, zBuf);
+        ::WinSetWindowText((HWND)m_hStaticMin, (PSZ)zBuf);
     }
 
     if (m_hStaticMax)
     {
         wxSprintf(zBuf, wxT("%d"), m_nRangeMax);
     }
 
     if (m_hStaticMax)
     {
         wxSprintf(zBuf, wxT("%d"), m_nRangeMax);
-        ::WinSetWindowText((HWND)m_hStaticMax, zBuf);
+        ::WinSetWindowText((HWND)m_hStaticMax, (PSZ)zBuf);
     }
 } // end of wxSlider::SetRange
 
     }
 } // end of wxSlider::SetRange
 
@@ -1092,15 +1079,12 @@ void wxSlider::SetTick(
 } // end of wxSlider::SetTick
 
 // For trackbars only
 } // end of wxSlider::SetTick
 
 // For trackbars only
-void wxSlider::SetTickFreq(
-  int                               n
-, int                               nPos
-)
+void wxSlider::SetTickFreq( int n, int WXUNUSED(nPos) )
 {
 {
-    SLDCDATA                        vSlData;
-    WNDPARAMS                       vWndParams;
-    int                             nPixelPos;
-    int                             i;
+    SLDCDATA  vSlData;
+    WNDPARAMS vWndParams;
+    int       nPixelPos;
+    int       i;
 
     vSlData.cbSize = sizeof(SLDCDATA);
     if (m_windowStyle & wxSL_AUTOTICKS)
 
     vSlData.cbSize = sizeof(SLDCDATA);
     if (m_windowStyle & wxSL_AUTOTICKS)
@@ -1108,8 +1092,8 @@ void wxSlider::SetTickFreq(
         vSlData.usScale1Spacing = 0;
         vSlData.usScale2Spacing = 0;
     }
         vSlData.usScale1Spacing = 0;
         vSlData.usScale2Spacing = 0;
     }
-    vSlData.usScale1Increments = (m_nRangeMax - m_nRangeMin)/n;
-    vSlData.usScale2Increments = (m_nRangeMax - m_nRangeMin)/n;
+    vSlData.usScale1Increments = (USHORT)((m_nRangeMax - m_nRangeMin)/n);
+    vSlData.usScale2Increments = (USHORT)((m_nRangeMax - m_nRangeMin)/n);
 
     vWndParams.fsStatus = WPM_CTLDATA;
     vWndParams.cchText  = 0L;
 
     vWndParams.fsStatus = WPM_CTLDATA;
     vWndParams.cchText  = 0L;
@@ -1155,7 +1139,7 @@ void wxSlider::SetValue(
     if (m_hStaticValue)
     {
         wxSprintf(wxBuffer, wxT("%d"), nValue);
     if (m_hStaticValue)
     {
         wxSprintf(wxBuffer, wxT("%d"), nValue);
-        ::WinSetWindowText((HWND)m_hStaticValue, wxBuffer);
+        ::WinSetWindowText((HWND)m_hStaticValue, (PSZ)wxBuffer);
     }
 } // end of wxSlider::SetValue
 
     }
 } // end of wxSlider::SetValue