1 ///////////////////////////////////////////////////////////////////////////// 
   4 // Author:      David Webster 
   8 // Copyright:   (c) David Webster 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 // For compilers that support precompilation, includes "wx.h". 
  13 #include "wx/wxprec.h" 
  16     #include "wx/checkbox.h" 
  20 #include "wx/os2/private.h" 
  22 // ---------------------------------------------------------------------------- 
  24 // ---------------------------------------------------------------------------- 
  26 IMPLEMENT_DYNAMIC_CLASS(wxCheckBox
, wxControl
) 
  27 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox
, wxCheckBox
) 
  29 // ============================================================================ 
  31 // ============================================================================ 
  33 // ---------------------------------------------------------------------------- 
  35 // ---------------------------------------------------------------------------- 
  37 bool wxCheckBox::OS2Command( 
  38   WXUINT                            
WXUNUSED(uParam
) 
  39 , WXWORD                            
WXUNUSED(wId
) 
  42     wxCommandEvent                  
rEvent( wxEVT_COMMAND_CHECKBOX_CLICKED
 
  45     rEvent
.SetInt(GetValue()); 
  46     rEvent
.SetEventObject(this); 
  47     ProcessCommand(rEvent
); 
  49 } // end of wxCheckBox::OS2Command 
  51 bool wxCheckBox::Create( 
  54 , const wxString
&                   rsLabel
 
  59 , const wxValidator
&                rValidator
 
  61 , const wxString
&                   rsName
 
  66     SetValidator(rValidator
); 
  69         pParent
->AddChild(this); 
  71     SetBackgroundColour(pParent
->GetBackgroundColour()); 
  72     SetForegroundColour(pParent
->GetForegroundColour()); 
  73     m_windowStyle 
= lStyle
; 
  75     wxString                        sLabel 
= rsLabel
; 
  77     if (sLabel 
== wxT("")) 
  78         sLabel 
= wxT(" "); // Apparently needed or checkbox won't show 
  81         m_windowId 
= NewControlId(); 
  88     int                             nHeight 
= rSize
.y
; 
  91     lSstyle 
= BS_AUTOCHECKBOX 
| 
  94     if (lStyle 
& wxCLIP_SIBLINGS 
) 
  95         lSstyle 
|= WS_CLIPSIBLINGS
; 
  98     // If the parent is a scrolled window the controls must 
  99     // have this style or they will overlap the scrollbars 
 102         if (pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
)) || 
 103             pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
))) 
 104             lSstyle 
|= WS_CLIPSIBLINGS
; 
 106     m_hWnd 
= (WXHWND
)::WinCreateWindow ( GetHwndOf(pParent
) 
 119     // Subclass again for purposes of dialog editing mode 
 123     LONG                            lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 125     ::WinSetPresParam( m_hWnd
 
 131     SetFont(pParent
->GetFont()); 
 139 } // end of wxCheckBox::Create 
 141 void wxCheckBox::SetLabel( 
 142   const wxString
&                   rsLabel
 
 145     ::WinSetWindowText(GetHwnd(), rsLabel
.c_str()); 
 146 } // end of wxCheckBox::SetLabel 
 148 wxSize 
wxCheckBox::DoGetBestSize() const 
 150     static int                      nCheckSize 
= 0; 
 156         vDc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
)); 
 159         // The height of a standard button in the dialog units is 8, 
 160         // translate this to pixels (as one dialog unit is precisely equal to 
 161         // 8 character heights, it's just the char height) 
 163         nCheckSize 
= vDc
.GetCharHeight(); 
 168     wxString                        sStr 
= wxGetWindowText(GetHWND()); 
 176         nWidthCheckbox 
+= nCheckSize 
+ GetCharWidth(); 
 178         if (nHeightCheckbox 
< nCheckSize
) 
 179             nHeightCheckbox 
= nCheckSize
; 
 183         nWidthCheckbox  
= nCheckSize
; 
 184         nHeightCheckbox 
= nCheckSize
; 
 187     return wxSize( nWidthCheckbox
 
 190 } // end of wxCheckBox::DoGetBestSize 
 192 void wxCheckBox::SetValue( 
 196     ::WinSendMsg(GetHwnd(), BM_SETCHECK
, (MPARAM
)bValue
, 0); 
 197 } // end of wxCheckBox::SetValue 
 200 #define BST_CHECKED 0x0001 
 203 bool wxCheckBox::GetValue() const 
 205     return((LONGFROMMR(::WinSendMsg(GetHwnd(), BM_QUERYCHECK
, (MPARAM
)0, (MPARAM
)0)) == 1L)); 
 206 } // end of wxCheckBox::GetValue 
 208 void wxCheckBox::Command ( 
 209   wxCommandEvent
&                  rEvent
 
 212     SetValue((rEvent
.GetInt() != 0)); 
 213     ProcessCommand(rEvent
); 
 214 } // end of wxCheckBox:: Command 
 216 // ---------------------------------------------------------------------------- 
 218 // ---------------------------------------------------------------------------- 
 220 bool wxBitmapCheckBox::Create( 
 223 , const wxBitmap
*                   pLabel
 
 224 , const wxPoint
&                    rPos
 
 225 , const wxSize
&                     rSize
 
 228 , const wxValidator
&                rValidator
 
 230 , const wxString
&                   rsName
 
 235     SetValidator(rValidator
); 
 238         pParent
->AddChild(this); 
 240     SetBackgroundColour(pParent
->GetBackgroundColour()) ; 
 241     SetForegroundColour(pParent
->GetForegroundColour()) ; 
 242     m_windowStyle 
= lStyle
; 
 245         m_windowId 
= NewControlId(); 
 251     int                             nWidth  
= rSize
.x
; 
 252     int                             nHeight 
= rSize
.y
; 
 255     m_nCheckHeight 
= -1 ; 
 256 //    long msStyle = CHECK_FLAGS; 
 258     HWND hButton 
= 0; // TODO: Create the bitmap checkbox 
 260     m_hWnd 
= (WXHWND
)hButton
; 
 263     // Subclass again for purposes of dialog editing mode 
 265     SubclassWin((WXHWND
)hButton
); 
 273     ::WinShowWindow(hButton
, TRUE
); 
 275 } // end of wxBitmapCheckBox::Create 
 277 void wxBitmapCheckBox::SetLabel( 
 278   const wxBitmap
&                   rBitmap
 
 281     wxFAIL_MSG(wxT("not implemented")); 
 282 }  // end of wxBitmapCheckBox::SetLabel