]> git.saurik.com Git - wxWidgets.git/blobdiff - src/palmos/checkbox.cpp
don't provide unnecessary (as default) arguments to wxPen ctor, this incidentally...
[wxWidgets.git] / src / palmos / checkbox.cpp
index 5b55dd7c0024b6f38a9fe8bb10876f58b4bbb294..8a74d281262f41653b3017974ee2e584507dc34c 100644 (file)
 // headers
 // ----------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma implementation "checkbox.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 
 #if wxUSE_CHECKBOX
 
+#include "wx/checkbox.h"
+
 #ifndef WX_PRECOMP
-    #include "wx/checkbox.h"
     #include "wx/brush.h"
     #include "wx/dcscreen.h"
     #include "wx/settings.h"
 #endif
 
+#include <Control.h>
+
 // ============================================================================
 // implementation
 // ============================================================================
@@ -106,8 +105,11 @@ bool wxCheckBox::Create(wxWindow *parent,
                         const wxValidator& validator,
                         const wxString& name)
 {
-    wxControl::PalmCreateControl(checkboxCtl, parent, id, label, pos, size);
-    return true;
+    if(!wxControl::Create(parent, id, pos, size, style, validator, name))
+        return false;
+
+    m_state = wxCHK_UNCHECKED;
+    return wxControl::PalmCreateControl(checkboxCtl, label, pos, size);
 }
 
 wxSize wxCheckBox::DoGetBestSize() const
@@ -125,17 +127,51 @@ bool wxCheckBox::GetValue() const
     return GetBoolValue();
 }
 
+bool wxCheckBox::SendClickEvent()
+{
+    wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, GetId());
+    event.SetInt(GetValue());
+    event.SetEventObject(this);
+    return ProcessCommand(event);
+}
+
 void wxCheckBox::Command(wxCommandEvent& event)
 {
+    int state = event.GetInt();
+    wxCHECK_RET( (state == wxCHK_UNCHECKED) || (state == wxCHK_CHECKED)
+        || (state == wxCHK_UNDETERMINED),
+        wxT("event.GetInt() returned an invalid checkbox state") );
+
+    Set3StateValue((wxCheckBoxState) state);
+    ProcessCommand(event);
 }
 
 void wxCheckBox::DoSet3StateValue(wxCheckBoxState state)
 {
+    Int16 newValue;
+    ControlType *control = (ControlType *)GetObjectPtr();
+    if(NULL == control) {
+        return;
+    }
+    m_state = state;
+    switch (state) {
+    case wxCHK_UNCHECKED:
+        newValue = 0;
+        break;
+    case wxCHK_CHECKED:
+        newValue = 1;
+        break;
+    case wxCHK_UNDETERMINED:
+    default:
+        return;
+        break;
+    }
+    CtlSetValue (control, newValue);
 }
 
 wxCheckBoxState wxCheckBox::DoGet3StateValue() const
 {
-    return (wxCheckBoxState) 0;
+    return m_state;
 }
 
 #endif // wxUSE_CHECKBOX