]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/checkbox.cpp
typo fixed: should be lpthread, not -lpthread in THREAD_OPTS
[wxWidgets.git] / src / os2 / checkbox.cpp
index 0101e79a0c355a3cf9a4f0f6b650b925329af4b9..720eff958e818448211d80c52e614bbd08cd97ac 100644 (file)
@@ -15,6 +15,9 @@
 #ifndef WX_PRECOMP
     #include "wx/checkbox.h"
     #include "wx/brush.h"
+    #include "wx/scrolwin.h"
+    #include "wx/dcscreen.h"
+    #include "wx/settings.h"
 #endif
 
 #include "wx/os2/private.h"
@@ -61,81 +64,29 @@ bool wxCheckBox::Create(
 , const wxString&                   rsName
 )
 {
-    SetName(rsName);
+    if (!CreateControl( pParent
+                       ,vId
+                       ,rPos
+                       ,rSize
+                       ,lStyle
 #if wxUSE_VALIDATORS
-    SetValidator(rValidator);
+                       ,wxDefaultValidator
 #endif
-    if (pParent)
-        pParent->AddChild(this);
-
-    SetBackgroundColour(pParent->GetBackgroundColour());
-    SetForegroundColour(pParent->GetForegroundColour());
-    m_windowStyle = lStyle;
-
-    wxString                        sLabel = rsLabel;
-
-    if (sLabel == wxT(""))
-        sLabel = wxT(" "); // Apparently needed or checkbox won't show
-
-    if (vId == -1 )
-        m_windowId = NewControlId();
-    else
-        m_windowId = vId;
-
-    int                             nX      = rPos.x;
-    int                             nY      = rPos.y;
-    int                             nWidth  = rSize.x;
-    int                             nHeight = rSize.y;
-    long                            lSstyle = 0L;
-
-    lSstyle = BS_AUTOCHECKBOX |
-              WS_TABSTOP      |
-              WS_VISIBLE;
-    if (lStyle & wxCLIP_SIBLINGS )
-        lSstyle |= WS_CLIPSIBLINGS;
-
-    //
-    // If the parent is a scrolled window the controls must
-    // have this style or they will overlap the scrollbars
-    //
-    if (pParent)
-        if (pParent->IsKindOf(CLASSINFO(wxScrolledWindow)) ||
-            pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)))
-            lSstyle |= WS_CLIPSIBLINGS;
-
-    m_hWnd = (WXHWND)::WinCreateWindow ( GetHwndOf(pParent)
-                                        ,WC_BUTTON
-                                        ,rsLabel.c_str()
-                                        ,lSstyle
-                                        ,0, 0, 0, 0
-                                        ,GetWinHwnd(pParent)
-                                        ,HWND_TOP
-                                        ,(HMENU)m_windowId
-                                        ,NULL
-                                        ,NULL
-                                       );
-
-    //
-    // Subclass again for purposes of dialog editing mode
-    //
-    SubclassWin(m_hWnd);
-
-    LONG                            lColor = (LONG)m_backgroundColour.GetPixel();
-
-    ::WinSetPresParam( m_hWnd
-                      ,PP_BACKGROUNDCOLOR
-                      ,sizeof(LONG)
-                      ,(PVOID)&lColor
-                     );
-
-    SetFont(pParent->GetFont());
-
-    SetSize( nX
-            ,nY
-            ,nWidth
-            ,nHeight
-           );
-    return TRUE;
+                       ,rsName
+                      ))
+        return FALSE;
+
+    long                            osStyle = BS_AUTOCHECKBOX |
+                                              WS_TABSTOP      |
+                                              WS_VISIBLE;
+
+    return OS2CreateControl( wxT("BUTTON")
+                            ,osStyle
+                            ,rPos
+                            ,rSize
+                            ,rsLabel
+                            ,0
+                           );
 } // end of wxCheckBox::Create
 
 void wxCheckBox::SetLabel(
@@ -153,7 +104,7 @@ wxSize wxCheckBox::DoGetBestSize() const
     {
         wxScreenDC                  vDc;
 
-        vDc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+        vDc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
 
         //
         // The height of a standard button in the dialog units is 8,