]> git.saurik.com Git - wxWidgets.git/commitdiff
Dialogs and slider updates
authorDavid Webster <Dave.Webster@bhmi.com>
Mon, 22 Jul 2002 03:29:07 +0000 (03:29 +0000)
committerDavid Webster <Dave.Webster@bhmi.com>
Mon, 22 Jul 2002 03:29:07 +0000 (03:29 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16249 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/os2/bitmap.cpp
src/os2/control.cpp
src/os2/dc.cpp
src/os2/listbox.cpp
src/os2/slider.cpp
src/os2/spinctrl.cpp
src/os2/statbmp.cpp
src/os2/statline.cpp
src/os2/textctrl.cpp

index 1be5569b215a796e908303177fa824059878db7d..8727225de88229a37670f65621ae9723a438b20e 100644 (file)
@@ -58,7 +58,7 @@ wxBitmapRefData::wxBitmapRefData()
     m_pSelectedInto = NULL;
     m_nNumColors    = 0;
     m_pBitmapMask   = NULL;
-    m_hBitmap = (WXHBITMAP) NULL;
+    m_hBitmap       = (WXHBITMAP) NULL;
 } // end of wxBitmapRefData::wxBitmapRefData
 
 void wxBitmapRefData::Free()
@@ -303,6 +303,7 @@ wxBitmap::wxBitmap(
     LoadFile( nId
              ,(int)lType
             );
+    SetId(nId);
 } // end of wxBitmap::wxBitmap
 
 bool wxBitmap::Create(
index 61fd7206cf459bced251280de3e6733d2ada08a2..a7d56cb07dd15b00ffce05f5138bdb8ef9e92a06 100644 (file)
@@ -168,6 +168,8 @@ bool wxControl::OS2CreateControl(
     // Controls use the same font and colours as their parent dialog by default
     //
     InheritAttributes();
+    SetXComp(0);
+    SetYComp(0);
     if (nW == 0 || nH == 0)
         SetBestSize(rSize);
     return TRUE;
index 301788aa2321c6ba909a150371db3d14568df00f..28ac299e82489a19e9a26e4b127b942a892a262b 100644 (file)
@@ -1038,7 +1038,7 @@ void wxDC::DoDrawRectangle(
         if(m_brush.GetStyle() == wxTRANSPARENT)
             lControl = DRO_OUTLINE;
 
-        ::GpiSetColor(m_hPS, lColor);
+        ::GpiSetColor(m_hPS, lBorderColor);
         ::GpiBox( m_hPS       // handle to a presentation space
                  ,lControl   // draw the box outline ? or ?
                  ,&vPoint[1]  // address of the corner
index d23bedc5125dbf0d97312db157f0250457a86cc6..968cd9a851b95f46d1e77b2775c8611b602df2a8 100644 (file)
@@ -421,8 +421,18 @@ bool wxListBox::IsSelected(
 
     LONG                            lItem;
 
-    lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)N, (MPARAM)0));
-    return (lItem != LIT_NONE);
+    if (GetWindowStyleFlag() & wxLB_EXTENDED)
+    {
+        if (N == 0)
+            lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)LIT_FIRST, (MPARAM)0));
+        else
+            lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)(N - 1), (MPARAM)0));
+    }
+    else
+    {
+        lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)LIT_FIRST, (MPARAM)0));
+    }
+    return (lItem == (LONG)N && lItem != LIT_NONE);
 } // end of wxListBox::IsSelected
 
 wxClientData* wxListBox::DoGetItemClientObject(
index cf5d9798f5fd2ed4d92704b2bdf7096eb198d790..c548169535a1ce35ebf7a53d6110a7947c3f8a74 100644 (file)
@@ -115,13 +115,58 @@ void wxSlider::AdjustSubControls(
                               ,(LONG)nYOffset
                               ,(LONG)nMaxLen
                               ,(LONG)nCy
-                              ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
+                              ,SWP_ZORDER | SWP_SHOW
+                             );
+        }
+    }
+    else
+    {
+        //
+        // Now deal with a vertical slider
+        //
+
+        if (m_lWindowStyle & winSL_LABELS )
+        {
+            int                     nMinLen = 0;
+            int                     nMaxLen = 0;
+
+            ::WinQueryWindowText((HWND)m_hStaticMin, 300, zBuf);
+            GetTextExtent(zBuf, &lMinLen, &nCyf, NULL, NULL, &this->GetFont());
+
+            ::WinQueryWindowText((HWND)m_hStaticMax, 300, zBuf);
+            GetTextExtent(zBuf, &lMaxLen, &nCyf, NULL, NULL, &this->GetFont());
+
+            if (m_hStaticValue)
+            {
+                int                 nNewWidth = (DAWUTL_MAX(nMinLen, nMaxLen));
+
+                ::WinSetWindowPos( (HWND)m_hStaticValue
+                                  ,HWND_TOP
+                                  ,(LONG)nXOffset
+                                  ,(LONG)nYOffset + nHeight + nCyf
+                                  ,(LONG)nNewWidth
+                                  ,(LONG)nCyf
+                                  ,SWP_SIZE | SWP_MOVE
+                                 );
+            }
+            ::WinSetWindowPos( (HWND)m_hStaticMax
+                              ,HWND_TOP
+                              ,(LONG)nXOffset
+                              ,(LONG)nYOffset + nHeight
+                              ,(LONG)nMaxLen
+                              ,(LONG)nCyf
+                              ,SWP_SIZE | SWP_MOVE
+                             );
+            ::WinSetWindowPos( (HWND)m_hStaticMin
+                              ,HWND_TOP
+                              ,(LONG)nXOffset
+                              ,(LONG)nYOffset - nCyf
+                              ,(LONG)nMinLen
+                              ,(LONG)nCyf
+                              ,SWP_SIZE | SWP_MOVE
                              );
         }
     }
-    //
-    // Now deal with a vertical slider -- OS/2 doesn't have vertical sliders
-    //
 } // end of wxSlider::AdjustSubControls
 
 void wxSlider::ClearSel()
@@ -239,9 +284,9 @@ bool wxSlider::Create(
 
     vSlData.cbSize = sizeof(SLDCDATA);
     if (m_windowStyle & wxSL_VERTICAL)
-        lMsStyle = SLS_VERTICAL | WS_VISIBLE | WS_TABSTOP;
+        lMsStyle = SLS_VERTICAL | SLS_HOMEBOTTOM | WS_VISIBLE | WS_TABSTOP;
     else
-        lMsStyle = SLS_HORIZONTAL | WS_VISIBLE | WS_TABSTOP;
+        lMsStyle = SLS_HORIZONTAL | SLS_HOMELEFT| WS_VISIBLE | WS_TABSTOP;
 
     if (m_windowStyle & wxCLIP_SIBLINGS)
         lMsStyle |= WS_CLIPSIBLINGS;
@@ -264,6 +309,7 @@ bool wxSlider::Create(
         lMsStyle |= SLS_PRIMARYSCALE1 | SLS_PRIMARYSCALE2;
     else
         lMsStyle |= SLS_PRIMARYSCALE2;
+    lMsStyle |= SLS_RIBBONSTRIP;
 
     m_nPageSize = ((nMaxValue - nMinValue)/10);
     vSlData.usScale1Increments = m_nPageSize;
@@ -288,7 +334,7 @@ bool wxSlider::Create(
     //
     ::WinSendMsg( hScrollBar
                  ,SLM_SETTICKSIZE
-                 ,MPFROM2SHORT(SMA_SETALLTICKS, 6)
+                 ,MPFROM2SHORT(SMA_SETALLTICKS, (USHORT)12)
                  ,NULL
                 );
     //
@@ -304,12 +350,7 @@ bool wxSlider::Create(
     SubclassWin(GetHWND());
     ::WinSetWindowText((HWND)m_hWnd, "");
 
-    wxFont*                          pTextFont = new wxFont( 10
-                                                            ,wxMODERN
-                                                            ,wxNORMAL
-                                                            ,wxNORMAL
-                                                           );
-    SetFont(*pTextFont);
+    SetFont(*wxSMALL_FONT);
     if (m_windowStyle & wxSL_LABELS)
     {
         //
@@ -412,6 +453,13 @@ bool wxSlider::Create(
                       ,sizeof(LONG)
                       ,(PVOID)&lColor
                      );
+    vColour.Set(wxString("BLUE"));
+    lColor = (LONG)vColour.GetPixel();
+    ::WinSetPresParam( m_hWnd
+                      ,PP_HILITEBACKGROUNDCOLOR
+                      ,sizeof(LONG)
+                      ,(PVOID)&lColor
+                     );
     SetValue(nValue);
     delete pTextFont;
     return TRUE;
@@ -515,7 +563,7 @@ void wxSlider::DoSetSize(
             ::WinSetWindowPos( (HWND)m_hStaticMin
                               ,HWND_TOP
                               ,(LONG)nXOffset
-                              ,(LONG)nYOffset - nCyf
+                              ,(LONG)nYOffset - (nCyf * 1.2)
                               ,(LONG)nMinLen
                               ,(LONG)nCy
                               ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
@@ -547,7 +595,7 @@ void wxSlider::DoSetSize(
             ::WinSetWindowPos( (HWND)m_hStaticMax
                               ,HWND_TOP
                               ,(LONG)nXOffset
-                              ,(LONG)nYOffset - nCyf
+                              ,(LONG)nYOffset - (nCyf * 1.2)
                               ,(LONG)nMaxLen
                               ,(LONG)nCy
                               ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
@@ -606,27 +654,24 @@ void wxSlider::DoSetSize(
                 // The height needs to be a bit bigger under Win95 if using native
                 // 3D effects.
                 //
-                nValueHeight = (int)(nValueHeight * 1.5);
                 ::WinSetWindowPos( (HWND)m_hStaticValue
                                   ,HWND_TOP
                                   ,(LONG)nXOffset
-                                  ,(LONG)nYOffset
+                                  ,(LONG)nYOffset + lHeight
                                   ,(LONG)nNewWidth
                                   ,(LONG)nValueHeight
                                   ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
                                  );
-                nYOffset -= nValueHeight;
-                nUsedHeight += nValueHeight;
+                nUsedHeight += nCy;
             }
             ::WinSetWindowPos( (HWND)m_hStaticMin
                               ,HWND_TOP
                               ,(LONG)nXOffset
-                              ,(LONG)nYOffset
+                              ,(LONG)nYOffset + lHeight -lCyf
                               ,(LONG)nMinLen
                               ,(LONG)nCy
                               ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
                              );
-            nYOffset -= nCy;
             nUsedHeight += nCy;
 
             int                  nSliderLength = nHeight1 - (nUsedHeight + (2 * nCy));
@@ -641,7 +686,7 @@ void wxSlider::DoSetSize(
             if (nSliderLength < 100)
                 nSliderLength = 100;
 
-            ::WinSetWindowPos( (HWND)m_hStaticMin
+            ::WinSetWindowPos( GetHwnd()
                               ,HWND_TOP
                               ,(LONG)nXOffset
                               ,(LONG)nYOffset
@@ -649,7 +694,6 @@ void wxSlider::DoSetSize(
                               ,(LONG)nSliderLength
                               ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
                              );
-            nYOffset -= nSliderLength;
             nUsedHeight += nSliderLength;
             ::WinSetWindowPos( (HWND)m_hStaticMax
                               ,HWND_TOP
index 8c2735901ef9b6ba91f8dceeea7e244240134bb4..2fa04e704975bcbb73591d6ac5d9f1d592d9b038 100644 (file)
@@ -337,8 +337,8 @@ int wxSpinCtrl::GetValue() const
                                ,SPBQ_UPDATEIFVALID
                               )
                 );
-    lVal - atol(zVal);
-    return lVal;
+    lVal = atol(zVal);
+    return (int)lVal;
 } // end of wxSpinCtrl::GetValue
 
 void wxSpinCtrl::OnChar (
@@ -488,4 +488,4 @@ bool wxSpinCtrl::Show(
     return TRUE;
 } // end of wxSpinCtrl::Show
 
-#endif //wxUSE_SPINBTN
\ No newline at end of file
+#endif //wxUSE_SPINBTN
index 07856d8e84d92976df405df0c72092ba8c1ea70b..5d523be4ffd9fb8f72fc31d458580724b3acee00 100644 (file)
 
 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
 
+static wxGDIImage* ConvertImage(
+  const wxGDIImage&                 rBitmap
+)
+{
+    bool                            bIsIcon = rBitmap.IsKindOf( CLASSINFO(wxIcon) );
+
+    if(!bIsIcon )
+    {
+        wxASSERT_MSG( wxDynamicCast(&rBitmap, wxBitmap),
+                      _T("not an icon and not a bitmap?") );
+
+        const wxBitmap&             rBmp = (const wxBitmap&)rBitmap;
+        wxMask*                     pMask = rBmp.GetMask();
+
+        if (pMask && pMask->GetMaskBitmap())
+        {
+            wxIcon*                 pIcon = new wxIcon;
+
+            pIcon->CopyFromBitmap(rBmp);
+            return pIcon;
+        }
+        return new wxBitmap(rBmp);
+    }
+
+    // copying a bitmap is a cheap operation
+    return new wxIcon( (const wxIcon&)rBitmap );
+} // end of ConvertImage
+
 // ---------------------------------------------------------------------------
 //  wxStaticBitmap
 // ---------------------------------------------------------------------------
@@ -46,15 +74,15 @@ bool wxStaticBitmap::Create(
 , const wxString&                   rName
 )
 {
+    ERRORID                         vError;
+    wxString                        sError;
+
     Init();
 
     SetName(rName);
     if (pParent)
         pParent->AddChild(this);
 
-    m_backgroundColour = pParent->GetBackgroundColour() ;
-    m_foregroundColour = pParent->GetForegroundColour() ;
-
     if (nId == -1)
         m_windowId = (int)NewControlId();
     else
@@ -66,16 +94,21 @@ bool wxStaticBitmap::Create(
     int                             nY = rPos.y;
     int                             nWidth = rSize.x;
     int                             nHeight = rSize.y;
+    char                            zId[16];
 
     m_windowStyle = lStyle;
 
     m_bIsIcon = rBitmap.IsKindOf(CLASSINFO(wxIcon));
 
-    int                             nWinstyle = m_bIsIcon ? SS_ICON : SS_BITMAP;
+    //
+    // For now we only support an ICON
+    //
+    int                             nWinstyle = SS_ICON;
 
+    sprintf(zId, "#%d", rBitmap.GetId());
     m_hWnd = (WXHWND)::WinCreateWindow( pParent->GetHWND()
                                        ,WC_STATIC
-                                       ,rName.c_str()
+                                       ,zId
                                        ,nWinstyle | WS_VISIBLE
                                        ,0,0,0,0
                                        ,pParent->GetHWND()
@@ -84,17 +117,20 @@ bool wxStaticBitmap::Create(
                                        ,NULL
                                        ,NULL
                                       );
-
+    if (!m_hWnd)
+    {
+        vError = ::WinGetLastError(wxGetInstance());
+        sError = wxPMErrorToStr(vError);
+        return FALSE;
+    }
     wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create static bitmap") );
-
-    SetImage(rBitmap);
+    m_pImage = ConvertImage(rBitmap);
+    m_pImage->SetHandle((WXHWND)::WinSendMsg(m_hWnd, SM_QUERYHANDLE, (MPARAM)0, (MPARAM)0));
 
     // Subclass again for purposes of dialog editing mode
     SubclassWin(m_hWnd);
-    SetFont(*wxSMALL_FONT);
-    SetSize(nX, nY, nWidth, nHeight);
-    return(FALSE);
-}
+    return(TRUE);
+} // end of wxStaticBitmap::Create
 
 bool wxStaticBitmap::ImageIsOk() const
 {
@@ -103,14 +139,17 @@ bool wxStaticBitmap::ImageIsOk() const
 
 void wxStaticBitmap::Free()
 {
-    delete m_pImage;
+    if (m_pImage)
+        delete m_pImage;
     m_pImage = NULL;
-}
+} // end of wxStaticBitmap::Free
 
 wxSize wxStaticBitmap::DoGetBestSize() const
 {
-    // reuse the current size (as wxWindow does) instead of using some
+    //
+    // Reuse the current size (as wxWindow does) instead of using some
     // arbitrary default size (as wxControl, our immediate base class, does)
+    //
     return wxWindow::DoGetBestSize();
 }
 
@@ -118,54 +157,28 @@ void wxStaticBitmap::SetImage(
   const wxGDIImage&                 rBitmap
 )
 {
-    Free();
-
-    m_bIsIcon = rBitmap.IsKindOf(CLASSINFO(wxIcon));
-    if (m_bIsIcon)
-        m_pImage = new wxIcon((const wxIcon&)rBitmap);
-    else
-        m_pImage = new wxBitmap((const wxBitmap &)rBitmap);
-
-    int                             nX;
-    int                             nY;
-    int                             nW;
-    int                             nH;
-
-    GetPosition(&nX, &nY);
-    GetSize(&nW, &nH);
+    int                             nX = 0;
+    int                             nY = 0;
+    int                             nWidth = 0;
+    int                             nHeight = 0;
 
+    Free();
     ::WinSendMsg( GetHwnd()
                  ,SM_SETHANDLE
-                 ,MPFROMHWND(m_pImage->GetHandle())
+                 ,MPFROMHWND(rBitmap.GetHandle())
                  ,NULL
                 );
-    if (ImageIsOk())
-    {
-        int                         nWidth = rBitmap.GetWidth();
-        int                         nHeight = rBitmap.GetHeight();
+    m_pImage = ConvertImage(rBitmap);
 
-        if (nWidth && nHeight)
-        {
-            nW = nWidth;
-            nW = nHeight;
-
-            ::WinSetWindowPos( GetHwnd()
-                              ,HWND_TOP
-                              ,nX
-                              ,nY
-                              ,nWidth
-                              ,nHeight
-                              ,SWP_SIZE | SWP_MOVE | SWP_SHOW
-                             );
-        }
-    }
+    GetPosition(&nX, &nY);
+    GetSize(&nWidth, &nHeight);
 
     RECTL                           vRect;
 
-    vRect.xLeft   = nW;
+    vRect.xLeft   = nX;
     vRect.yTop    = nY;
-    vRect.xRight  = nX + nW;
-    vRect.yBottom = nY + nH;
+    vRect.xRight  = nX + nWidth;
+    vRect.yBottom = nY + nHeight;
 
     ::WinInvalidateRect(GetHwndOf(GetParent()), &vRect, TRUE);
 }
index effb7de3505bfb725eeb0410f82adc36711208b4..cd3343c3be9eb2f2ff24154cfaf921e209d81024 100644 (file)
@@ -60,12 +60,26 @@ bool wxStaticLine::Create(
                         ,rsName
                        ))
         return FALSE;
-    return OS2CreateControl( _T("STATIC")
-                            ,_T("")
-                            ,rPos
-                            ,vSize
-                            ,lStyle
-                           );
+    if (!OS2CreateControl( "STATIC"
+                          ,SS_FGNDFRAME
+                          ,rPos
+                          ,rSize
+                          ,rsName
+                         ))
+        return FALSE;
+
+    wxColour                        vColour;
+
+    vColour.Set(wxString("GREY"));
+
+    LONG                            lColor = (LONG)vColour.GetPixel();
+
+    ::WinSetPresParam( m_hWnd
+                      ,PP_FOREGROUNDCOLOR
+                      ,sizeof(LONG)
+                      ,(PVOID)&lColor
+                     );
+    return TRUE;
 } // end of wxStaticLine::Create
 
 WXDWORD wxStaticLine::OS2GetStyle(
index 3949c8f7872e9cd48c3713876b1cc80d27008af8..a9e711e7b0b58659f535785ea2f5907cfc890491 100644 (file)
@@ -125,6 +125,7 @@ bool wxTextCtrl::Create(
     }
 
     m_windowStyle = lStyle;
+    m_bIsMLE = FALSE;
 
     long                            lSstyle = WS_VISIBLE | WS_TABSTOP;
 
@@ -200,7 +201,7 @@ bool wxTextCtrl::Create(
     //
     // Set font, position, size and initial value
     //
-    wxFont*                          pTextFont = new wxFont( 10
+    wxFont*                          pTextFont = new wxFont( 8
                                                             ,wxMODERN
                                                             ,wxNORMAL
                                                             ,wxNORMAL
@@ -218,8 +219,8 @@ bool wxTextCtrl::Create(
     ::WinQueryWindowPos(m_hWnd, &vSwp);
     SetXComp(vSwp.x);
     SetYComp(vSwp.y);
-    SetSize( vPos.x
-            ,vPos.y
+    SetSize( vPos.x - GetXComp()
+            ,vPos.y - GetYComp()
             ,rSize.x
             ,rSize.y
            );