]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/checkbox.cpp
Removed deprecated parser.o from cocoa.t, reran tmake
[wxWidgets.git] / src / os2 / checkbox.cpp
index 2c18c0eb223499f82a543d4594467799a29972a2..83480a8ef2ff54c281fd68f3c1e27b536de6e982 100644 (file)
 IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
 
+extern void  wxAssociateWinWithHandle( HWND         hWnd
+                                      ,wxWindowOS2* pWin
+                                     );
+
 // ============================================================================
 // implementation
 // ============================================================================
@@ -58,87 +62,44 @@ bool wxCheckBox::Create(
 , const wxPoint&                    rPos
 , const wxSize&                     rSize
 , long                              lStyle
-#if wxUSE_VALIDATORS
 , const wxValidator&                rValidator
-#endif
 , const wxString&                   rsName
 )
 {
-    SetName(rsName);
-#if wxUSE_VALIDATORS
-    SetValidator(rValidator);
-#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();
-
+    LONG                            lColor;
+    bool                            bOk;
+
+    if (!CreateControl( pParent
+                       ,vId
+                       ,rPos
+                       ,rSize
+                       ,lStyle
+                       ,rValidator
+                       ,rsName
+                      ))
+        return FALSE;
+
+
+    long                            osStyle = BS_AUTOCHECKBOX |
+                                              WS_TABSTOP      |
+                                              WS_VISIBLE;
+
+    bOk = OS2CreateControl( wxT("BUTTON")
+                           ,osStyle
+                           ,rPos
+                           ,rSize
+                           ,rsLabel
+                           ,0
+                          );
+    m_backgroundColour = pParent->GetBackgroundColour();
+    lColor = (LONG)m_backgroundColour.GetPixel();
     ::WinSetPresParam( m_hWnd
                       ,PP_BACKGROUNDCOLOR
                       ,sizeof(LONG)
                       ,(PVOID)&lColor
                      );
-
-    SetFont(*wxSMALL_FONT);
-
-    SetSize( nX
-            ,nY
-            ,nWidth
-            ,nHeight
-           );
-    return TRUE;
+    wxAssociateWinWithHandle(m_hWnd, this);
+    return bOk;
 } // end of wxCheckBox::Create
 
 void wxCheckBox::SetLabel(
@@ -227,9 +188,7 @@ bool wxBitmapCheckBox::Create(
 , const wxPoint&                    rPos
 , const wxSize&                     rSize
 , long                              lStyle
-#if wxUSE_VALIDATORS
 , const wxValidator&                rValidator
-#endif
 , const wxString&                   rsName
 )
 {