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" 
  18     #include "wx/scrolwin.h" 
  19     #include "wx/dcscreen.h" 
  20     #include "wx/settings.h" 
  23 #include "wx/os2/private.h" 
  25 // ---------------------------------------------------------------------------- 
  27 // ---------------------------------------------------------------------------- 
  29 IMPLEMENT_DYNAMIC_CLASS(wxCheckBox
, wxControl
) 
  30 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox
, wxCheckBox
) 
  32 extern void  wxAssociateWinWithHandle( HWND         hWnd
 
  36 // ============================================================================ 
  38 // ============================================================================ 
  40 // ---------------------------------------------------------------------------- 
  42 // ---------------------------------------------------------------------------- 
  44 bool wxCheckBox::OS2Command( WXUINT 
WXUNUSED(uParam
), 
  45                              WXWORD 
WXUNUSED(wId
) ) 
  47     wxCommandEvent 
rEvent( wxEVT_COMMAND_CHECKBOX_CLICKED
, m_windowId 
); 
  48     rEvent
.SetInt(GetValue()); 
  49     rEvent
.SetEventObject(this); 
  50     ProcessCommand(rEvent
); 
  52 } // end of wxCheckBox::OS2Command 
  54 bool wxCheckBox::Create( 
  57 , const wxString
&                   rsLabel
 
  61 , const wxValidator
&                rValidator
 
  62 , const wxString
&                   rsName
 
  68     if (!CreateControl( pParent
 
  79     long                            osStyle 
= BS_AUTOCHECKBOX 
| 
  83     bOk 
= OS2CreateControl( wxT("BUTTON") 
  90     m_backgroundColour 
= pParent
->GetBackgroundColour(); 
  91     lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
  92     ::WinSetPresParam( m_hWnd
 
  97     wxAssociateWinWithHandle(m_hWnd
, this); 
  99 } // end of wxCheckBox::Create 
 101 void wxCheckBox::SetLabel( 
 102   const wxString
&                   rsLabel
 
 105     wxString                         sLabel
=::wxPMTextToLabel(rsLabel
); 
 106     ::WinSetWindowText(GetHwnd(), (PSZ
)sLabel
.c_str()); 
 107 } // end of wxCheckBox::SetLabel 
 109 wxSize 
wxCheckBox::DoGetBestSize() const 
 111     // We should probably compute nCheckSize but it seems to be a constant 
 112     // independent of its label's font size and not made available by OS/2. 
 113     int      nCheckSize 
= RADIO_SIZE
; 
 116     wxString sStr 
= wxGetWindowText(GetHWND()); 
 124         nWidthCheckbox 
+= nCheckSize
; 
 126         if (nHeightCheckbox 
< nCheckSize
) 
 127             nHeightCheckbox 
= nCheckSize
; 
 131         nWidthCheckbox  
= nCheckSize
; 
 132         nHeightCheckbox 
= nCheckSize
; 
 135     return wxSize( nWidthCheckbox
 
 138 } // end of wxCheckBox::DoGetBestSize 
 140 void wxCheckBox::SetValue( 
 144     ::WinSendMsg(GetHwnd(), BM_SETCHECK
, (MPARAM
)bValue
, 0); 
 145 } // end of wxCheckBox::SetValue 
 148 #define BST_CHECKED 0x0001 
 151 bool wxCheckBox::GetValue() const 
 153     return((LONGFROMMR(::WinSendMsg(GetHwnd(), BM_QUERYCHECK
, (MPARAM
)0, (MPARAM
)0)) == 1L)); 
 154 } // end of wxCheckBox::GetValue 
 156 void wxCheckBox::Command ( 
 157   wxCommandEvent
&                  rEvent
 
 160     SetValue((rEvent
.GetInt() != 0)); 
 161     ProcessCommand(rEvent
); 
 162 } // end of wxCheckBox:: Command 
 164 // ---------------------------------------------------------------------------- 
 166 // ---------------------------------------------------------------------------- 
 168 bool wxBitmapCheckBox::Create( wxWindow
*          pParent
, 
 170                                const wxBitmap
*    WXUNUSED(pLabel
), 
 174                                const wxValidator
& rValidator
, 
 175                                const wxString
&    rsName
) 
 179     SetValidator(rValidator
); 
 182         pParent
->AddChild(this); 
 184     SetBackgroundColour(pParent
->GetBackgroundColour()) ; 
 185     SetForegroundColour(pParent
->GetForegroundColour()) ; 
 186     m_windowStyle 
= lStyle
; 
 189         m_windowId 
= NewControlId(); 
 195     int                             nWidth  
= rSize
.x
; 
 196     int                             nHeight 
= rSize
.y
; 
 199     m_nCheckHeight 
= -1 ; 
 200 //    long msStyle = CHECK_FLAGS; 
 202     HWND hButton 
= 0; // TODO: Create the bitmap checkbox 
 204     m_hWnd 
= (WXHWND
)hButton
; 
 207     // Subclass again for purposes of dialog editing mode 
 209     SubclassWin((WXHWND
)hButton
); 
 217     ::WinShowWindow(hButton
, TRUE
); 
 219 } // end of wxBitmapCheckBox::Create 
 221 void wxBitmapCheckBox::SetLabel( const wxBitmap
& WXUNUSED(rBitmap
) ) 
 223     wxFAIL_MSG(wxT("not implemented")); 
 224 }  // end of wxBitmapCheckBox::SetLabel