]> git.saurik.com Git - wxWidgets.git/blobdiff - src/univ/checkbox.cpp
Add doc for wxGraphicsContext.Create(), which is a lightweight context with no target...
[wxWidgets.git] / src / univ / checkbox.cpp
index d02c0c1d0b264124d938ac0ae03a7af1125547be..f038623987f985c71092466dac5c5c9dcfdeeaf7 100644 (file)
 #include "wx/univ/inphand.h"
 #include "wx/univ/colschem.h"
 
+// ----------------------------------------------------------------------------
+// wxStdCheckboxInputHandler: handles the mouse events for the check and radio
+// boxes (handling the keyboard input is simple, but its handling differs a
+// lot between GTK and MSW, so a new class should be derived for this)
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxStdCheckboxInputHandler : public wxStdInputHandler
+{
+public:
+    wxStdCheckboxInputHandler(wxInputHandler *inphand);
+
+    // we have to override this one as wxStdButtonInputHandler version works
+    // only with the buttons
+    virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
+};
+
 // ============================================================================
 // implementation
 // ============================================================================
 
-IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
-
 // ----------------------------------------------------------------------------
 // wxCheckBox
 // ----------------------------------------------------------------------------
@@ -64,11 +78,12 @@ bool wxCheckBox::Create(wxWindow *parent,
                         const wxValidator& validator,
                         const wxString &name)
 {
+    WXValidateStyle( &style );
     if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
         return false;
 
     SetLabel(label);
-    SetBestSize(size);
+    SetInitialSize(size);
 
     CreateInputHandler(wxINP_HANDLER_CHECKBOX);
 
@@ -101,7 +116,7 @@ void wxCheckBox::OnCheck()
 wxBitmap wxCheckBox::GetBitmap(State state, Status status) const
 {
     wxBitmap bmp = m_bitmaps[state][status];
-    if ( !bmp.Ok() )
+    if ( !bmp.IsOk() )
         bmp = m_bitmaps[State_Normal][status];
 
     return bmp;
@@ -163,7 +178,7 @@ void wxCheckBox::DoDraw(wxControlRenderer *renderer)
 wxSize wxCheckBox::GetBitmapSize() const
 {
     wxBitmap bmp = GetBitmap(State_Normal, Status_Checked);
-    return bmp.Ok() ? wxSize(bmp.GetWidth(), bmp.GetHeight())
+    return bmp.IsOk() ? wxSize(bmp.GetWidth(), bmp.GetHeight())
                     : GetRenderer()->GetCheckBitmapSize();
 }
 
@@ -201,7 +216,7 @@ void wxCheckBox::DoSet3StateValue(wxCheckBoxState state)
     {
         case wxCHK_UNCHECKED:    status = Status_Unchecked;   break;
         case wxCHK_CHECKED:      status = Status_Checked; break;
-        default:                 wxFAIL_MSG(_T("Unknown checkbox state"));
+        default:                 wxFAIL_MSG(wxT("Unknown checkbox state"));
         case wxCHK_UNDETERMINED: status = Status_3rdState;  break;
     }
     if ( status != m_status )
@@ -283,7 +298,7 @@ void wxCheckBox::ChangeValue(bool value)
 
 void wxCheckBox::SendEvent()
 {
-    wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, GetId());
+    wxCommandEvent event(wxEVT_CHECKBOX, GetId());
     InitCommandEvent(event);
     wxCheckBoxState state = Get3StateValue();
 
@@ -323,12 +338,20 @@ bool wxCheckBox::PerformAction(const wxControlAction& action,
     return true;
 }
 
+/* static */
+wxInputHandler *wxCheckBox::CreateStdInputHandler(wxInputHandler *handlerDef)
+{
+    static wxStdCheckboxInputHandler s_handler(handlerDef);
+
+    return &s_handler;
+}
+
 // ----------------------------------------------------------------------------
 // wxStdCheckboxInputHandler
 // ----------------------------------------------------------------------------
 
-wxStdCheckboxInputHandler::wxStdCheckboxInputHandler(wxInputHandler *inphand)
-                         : wxStdButtonInputHandler(inphand)
+wxStdCheckboxInputHandler::wxStdCheckboxInputHandler(wxInputHandler *def)
+                         : wxStdInputHandler(wxButton::GetStdInputHandler(def))
 {
 }