]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/gauge.cpp
correct painting of the items with custom colours in TVIS_DROPHILITED state (patch...
[wxWidgets.git] / src / os2 / gauge.cpp
index e12f17230431c2e0fef5361da4b9629e50470f4c..2bf1c242ebca162c74f4a3590bb13e7912fe9717 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        gauge.cpp
+// Name:        src/os2/gauge.cpp
 // Purpose:     wxGauge class
 // Author:      David Webster
 // Modified by:
@@ -12,9 +12,8 @@
 #include "wx/wxprec.h"
 
 #ifndef WX_PRECOMP
-#include "wx/defs.h"
-#include "wx/utils.h"
-#include "wx/scrolwin.h"
+    #include "wx/utils.h"
+    #include "wx/scrolwin.h"
 #endif
 
 #include "wx/os2/private.h"
@@ -37,12 +36,10 @@ MRESULT EXPENTRY wxGaugeWndProc(
     wxGauge*                        pGauge = (wxGauge *)::WinQueryWindowULong( hWnd
                                                                               ,QWL_USER
                                                                              );
-    wxWindowOS2*                    pWindow = NULL;
-    MRESULT                         rc = (MRESULT)0;
-    bool                            bProcessed = FALSE;
     HPS                             hPS;
     RECTL                           vRect;
     RECTL                           vRect2;
+    RECTL                           vRect3;
     double                          dPixelToRange = 0.0;
     double                          dRange = 0.0;
 
@@ -70,28 +67,55 @@ MRESULT EXPENTRY wxGaugeWndProc(
                                          ,0L
                                          ,NULL
                                         );
+                //
+                // Draw the guage box
+                //
+                LONG                lColor = 0x00FFFFFF; // White
+                POINTL              vPoint = {vRect.xLeft + 1, vRect.yBottom + 1};
+
+                ::GpiSetColor(hPS, lColor);
+                ::GpiMove(hPS, &vPoint);
+                vPoint.x = vRect.xRight - 1;
+                ::GpiLine(hPS, &vPoint);
+                vPoint.y = vRect.yTop - 1;
+                ::GpiLine(hPS, &vPoint);
+                lColor = 0x000C0C0C; // Darkish Grey to give depth feel
+                ::GpiSetColor(hPS, lColor);
+                vPoint.x = vRect.xLeft + 1;
+                ::GpiLine(hPS, &vPoint);
+                vPoint.y = vRect.yBottom + 1;
+                ::GpiLine(hPS, &vPoint);
+                vRect3.xLeft   = vRect.xLeft + 2;
+                vRect3.xRight  = vRect.xRight - 2;
+                vRect3.yTop    = vRect.yTop - 2;
+                vRect3.yBottom = vRect.yBottom + 2;
+
                 if (pGauge->GetWindowStyleFlag() & wxGA_VERTICAL)
                 {
-                    dRange = (double)(vRect.yTop - vRect.yBottom);
+                    dRange = (double)(vRect3.yTop - vRect3.yBottom);
                     dPixelToRange  = dRange/(double)pGauge->GetRange();
                     vRect2.yTop    = (int)(pGauge->GetValue() * dPixelToRange);
-                    vRect2.yBottom = vRect.yBottom;
-                    vRect2.xLeft   = vRect.xLeft;
-                    vRect2.xRight  = vRect.xRight;
-                    vRect.yBottom  = vRect2.yTop;
-                    ::WinFillRect(hPS, &vRect,  pGauge->GetBackgroundColour().GetPixel());
+                    vRect2.yBottom = vRect3.yBottom;
+                    vRect2.xLeft   = vRect3.xLeft;
+                    vRect2.xRight  = vRect3.xRight;
+                    vRect3.yBottom  = vRect2.yTop;
+                    if (vRect3.yBottom <= 1)
+                         vRect3.yBottom = 2;
+                    ::WinFillRect(hPS, &vRect3,  pGauge->GetBackgroundColour().GetPixel());
                     ::WinFillRect(hPS, &vRect2, pGauge->GetForegroundColour().GetPixel());
                 }
                 else
                 {
-                    dRange = (double)(vRect.xRight - vRect.xLeft);
+                    dRange = (double)(vRect3.xRight - vRect3.xLeft);
                     dPixelToRange  = dRange/(double)pGauge->GetRange();
-                    vRect2.yTop    = vRect.yTop;
-                    vRect2.yBottom = vRect.yBottom;
-                    vRect2.xLeft   = vRect.xLeft;
+                    vRect2.yTop    = vRect3.yTop;
+                    vRect2.yBottom = vRect3.yBottom;
+                    vRect2.xLeft   = vRect3.xLeft;
                     vRect2.xRight  = (int)(pGauge->GetValue() * dPixelToRange);
-                    vRect.xLeft = vRect2.xRight;
-                    ::WinFillRect(hPS, &vRect,  pGauge->GetBackgroundColour().GetPixel());
+                    vRect3.xLeft = vRect2.xRight;
+                    if (vRect3.xLeft <= 1)
+                        vRect3.xLeft = 2;
+                    ::WinFillRect(hPS, &vRect3,  pGauge->GetBackgroundColour().GetPixel());
                     ::WinFillRect(hPS, &vRect2, pGauge->GetForegroundColour().GetPixel());
                 }
                 ::WinEndPaint(hPS);
@@ -112,9 +136,7 @@ bool wxGauge::Create(
 , const wxPoint&                    rPos
 , const wxSize&                     rSize
 , long                              lStyle
-#if wxUSE_VALIDATORS
 , const wxValidator&                rValidator
-#endif
 , const wxString&                   rsName
 )
 {
@@ -131,8 +153,8 @@ bool wxGauge::Create(
 #endif
     if (pParent)
         pParent->AddChild(this);
-    SetBackgroundColour(pParent->GetBackgroundColour()) ;
-    SetForegroundColour(pParent->GetForegroundColour()) ;
+    m_backgroundColour.Set(wxString(wxT("LIGHT GREY")));
+    m_foregroundColour.Set(wxString(wxT("NAVY")));
 
     m_nRangeMax   = nRange;
     m_nGaugePos   = 0;
@@ -191,6 +213,8 @@ bool wxGauge::Create(
             ,nWidth
             ,nHeight
            );
+    m_nWidth  = nWidth;     // Save for GetBestSize
+    m_nHeight = nHeight;
     ::WinShowWindow((HWND)GetHWND(), TRUE);
     delete pTextFont;
     return TRUE;
@@ -216,12 +240,10 @@ int wxGauge::GetValue() const
     return m_nGaugePos;
 } // end of wxGauge::GetValue
 
-bool wxGauge::SetBackgroundColour(
-  const wxColour&                   rColour
-)
+bool wxGauge::SetBackgroundColour( const wxColour& rColour )
 {
     if (!wxControl::SetBackgroundColour(rColour))
-        return FALSE;
+        return false;
 
     LONG                            lColor = (LONG)rColour.GetPixel();
 
@@ -230,7 +252,7 @@ bool wxGauge::SetBackgroundColour(
                       ,sizeof(LONG)
                       ,(PVOID)&lColor
                      );
-    return TRUE;
+    return true;
 } // end of wxGauge::SetBackgroundColour
 
 void wxGauge::SetBezelFace(
@@ -239,14 +261,12 @@ void wxGauge::SetBezelFace(
 {
 } // end of wxGauge::SetBezelFace
 
-bool wxGauge::SetForegroundColour(
-  const wxColour&                   rColour
-)
+bool wxGauge::SetForegroundColour( const wxColour& rColour )
 {
     if (!wxControl::SetForegroundColour(rColour))
-        return FALSE;
+        return false;
 
-    LONG                            lColor = (LONG)rColour.GetPixel();
+    LONG lColor = (LONG)rColour.GetPixel();
 
     ::WinSetPresParam( GetHwnd()
                       ,PP_FOREGROUNDCOLOR
@@ -254,7 +274,7 @@ bool wxGauge::SetForegroundColour(
                       ,(PVOID)&lColor
                      );
 
-    return TRUE;
+    return true;
 } // end of wxGauge::SetForegroundColour
 
 void wxGauge::SetRange(
@@ -281,4 +301,7 @@ void wxGauge::SetValue(
     ::WinInvalidateRect(GetHwnd(), &vRect, FALSE);
 } // end of wxGauge::SetValue
 
-
+wxSize wxGauge::DoGetBestSize() const
+{
+    return wxSize(m_nWidth,m_nHeight);
+}