]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/slider.cpp
typo fixed: should be lpthread, not -lpthread in THREAD_OPTS
[wxWidgets.git] / src / os2 / slider.cpp
index 2a9101349e135da068a2c151b80c4a801b9ee637..b190205052f71eb75cd10b046b46a066513d52c8 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdio.h>
 #include <wx/utils.h>
 #include <wx/brush.h>
 #include <stdio.h>
 #include <wx/utils.h>
 #include <wx/brush.h>
+#include <wx/scrolwin.h>
 #endif
 
 #include "wx/slider.h"
 #endif
 
 #include "wx/slider.h"
@@ -49,6 +50,80 @@ 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
+)
+{
+    SWP                             vSwp;
+    int                             nXOffset = nX;
+    int                             nYOffset = nY;
+    int                             nCx;     // slider,min,max sizes
+    int                             nCy;
+    int                             nCyf;
+    char                            zBuf[300];
+
+    wxGetCharSize( GetHWND()
+                  ,&nCx
+                  ,&nCy
+                  ,&this->GetFont()
+                 );
+
+    if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL)
+    {
+        if (m_windowStyle & wxSL_LABELS )
+        {
+            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());
+
+            if (m_hStaticValue)
+            {
+                int                 nNewWidth = wxMax(nMinLen, nMaxLen);
+                int                 nValueHeight = nCyf;
+
+                ::WinSetWindowPos( (HWND)m_hStaticValue
+                                  ,HWND_TOP
+                                  ,(LONG)nXOffset - (nNewWidth + nCx + nMinLen + nCx)
+                                  ,(LONG)nYOffset
+                                  ,(LONG)nNewWidth
+                                  ,(LONG)nValueHeight
+                                  ,SWP_SIZE | SWP_MOVE
+                                 );
+            }
+            ::WinSetWindowPos( (HWND)m_hStaticMin
+                              ,HWND_TOP
+                              ,(LONG)nXOffset - (nMinLen + nCx)
+                              ,(LONG)nYOffset
+                              ,(LONG)nMinLen
+                              ,(LONG)nCy
+                              ,SWP_SIZE | SWP_MOVE
+                             );
+            nXOffset += nWidth + nCx;
+
+            ::WinSetWindowPos( (HWND)m_hStaticMax
+                              ,HWND_TOP
+                              ,(LONG)nXOffset
+                              ,(LONG)nYOffset
+                              ,(LONG)nMaxLen
+                              ,(LONG)nCy
+                              ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
+                             );
+        }
+    }
+    //
+    // Now deal with a vertical slider -- OS/2 doesn't have vertical sliders
+    //
+} // end of wxSlider::AdjustSubControls
+
 void wxSlider::ClearSel()
 {
 } // end of wxSlider::ClearSel
 void wxSlider::ClearSel()
 {
 } // end of wxSlider::ClearSel
@@ -145,6 +220,7 @@ bool wxSlider::Create(
         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;
+
         m_hStaticMin = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle
                                                  ,WC_STATIC                // Window class
                                                  ,(PSZ)wxBuffer            // Initial Text
         m_hStaticMin = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle
                                                  ,WC_STATIC                // Window class
                                                  ,(PSZ)wxBuffer            // Initial Text
@@ -227,7 +303,13 @@ bool wxSlider::Create(
     m_hWnd = (WXHWND)hScrollBar;
     SubclassWin(GetHWND());
     ::WinSetWindowText((HWND)m_hWnd, "");
     m_hWnd = (WXHWND)hScrollBar;
     SubclassWin(GetHWND());
     ::WinSetWindowText((HWND)m_hWnd, "");
-    SetFont(pParent->GetFont());
+
+    wxFont*                          pTextFont = new wxFont( 10
+                                                            ,wxMODERN
+                                                            ,wxNORMAL
+                                                            ,wxNORMAL
+                                                           );
+    SetFont(*pTextFont);
     if (m_windowStyle & wxSL_LABELS)
     {
         //
     if (m_windowStyle & wxSL_LABELS)
     {
         //
@@ -237,6 +319,7 @@ bool wxSlider::Create(
         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;
+
         m_hStaticMax = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle
                                                  ,WC_STATIC                // Window class
                                                  ,(PSZ)wxBuffer            // Initial Text
         m_hStaticMax = (WXHWND)::WinCreateWindow( (HWND)GetHwndOf(pParent) // Parent window handle
                                                  ,WC_STATIC                // Window class
                                                  ,(PSZ)wxBuffer            // Initial Text
@@ -308,7 +391,29 @@ bool wxSlider::Create(
                       ,sizeof(LONG)
                       ,(PVOID)&lColor
                      );
                       ,sizeof(LONG)
                       ,(PVOID)&lColor
                      );
+    lColor = (LONG)m_backgroundColour.GetPixel();
+    ::WinSetPresParam( m_hStaticMin
+                      ,PP_BACKGROUNDCOLOR
+                      ,sizeof(LONG)
+                      ,(PVOID)&lColor
+                     );
+    ::WinSetPresParam( m_hStaticMax
+                      ,PP_BACKGROUNDCOLOR
+                      ,sizeof(LONG)
+                      ,(PVOID)&lColor
+                     );
+    ::WinSetPresParam( m_hStaticValue
+                      ,PP_BACKGROUNDCOLOR
+                      ,sizeof(LONG)
+                      ,(PVOID)&lColor
+                     );
+    ::WinSetPresParam( m_hWnd
+                      ,PP_BACKGROUNDCOLOR
+                      ,sizeof(LONG)
+                      ,(PVOID)&lColor
+                     );
     SetValue(nValue);
     SetValue(nValue);
+    delete pTextFont;
     return TRUE;
 } // end of wxSlider::Create
 
     return TRUE;
 } // end of wxSlider::Create
 
@@ -345,24 +450,11 @@ void wxSlider::DoSetSize(
 
     if (pParent)
     {
 
     if (pParent)
     {
-        //
-        // Under OS/2, where a frame window is the parent, most child windows
-        // that are not specific frame clients are actually children of the
-        // frame's client, not the frame itself, and so position themselves
-        // with regards to the client origin, not the frame.
-        //
-        if (pParent->IsKindOf(CLASSINFO(wxFrame)))
-        {
-            nYOffset = pParent->GetClientSize().y - (nYOffset + nOS2Height);
-            if (nY != -1)
-                nY1 = pParent->GetClientSize().y - (nY1 + nOS2Height);
-        }
-        else
-        {
-            nYOffset = pParent->GetSize().y - (nYOffset + nOS2Height);
-            if (nY != -1)
-                nY1 = pParent->GetSize().y - (nY1 + nOS2Height);
-        }
+        int                         nOS2ParentHeight = GetOS2ParentHeight(pParent);
+
+        nYOffset = nOS2ParentHeight - (nYOffset + nOS2Height);
+        if (nY != -1)
+            nY1 = nOS2ParentHeight - (nY1 + nOS2Height);
     }
     else
     {
     }
     else
     {
@@ -373,6 +465,7 @@ void wxSlider::DoSetSize(
         if (nY != -1)
             nY1 = vRect.yTop - (nY1 + nOS2Height);
     }
         if (nY != -1)
             nY1 = vRect.yTop - (nY1 + nOS2Height);
     }
+    m_nSizeFlags = nSizeFlags;
 
     GetPosition( &nCurrentX
                 ,&nCurrentY
 
     GetPosition( &nCurrentX
                 ,&nCurrentY