]> git.saurik.com Git - wxWidgets.git/blobdiff - src/palmos/checkbox.cpp
Provide a task-dialog based wxMSW wxMessageDialog implementation.
[wxWidgets.git] / src / palmos / checkbox.cpp
index 4d756ff5fe6406b8bae22f1c220e831e091450ed..8a74d281262f41653b3017974ee2e584507dc34c 100644 (file)
@@ -2,10 +2,10 @@
 // Name:        src/palmos/checkbox.cpp
 // Purpose:     wxCheckBox
 // Author:      William Osborne - minimal working wxPalmOS port
-// Modified by:
+// Modified by: Wlodzimierz ABX Skiba - native implementation
 // Created:     10/13/04
 // RCS-ID:      $Id$
-// Copyright:   (c) William Osborne
+// Copyright:   (c) William Osborne, Wlodzimierz Skiba
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // 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 "wx/palmos/private.h"
-
-#ifndef BST_UNCHECKED
-    #define BST_UNCHECKED 0x0000
-#endif
-
-#ifndef BST_CHECKED
-    #define BST_CHECKED 0x0001
-#endif
-
-#ifndef BST_INDETERMINATE
-    #define BST_INDETERMINATE 0x0002
-#endif
+#include <Control.h>
 
 // ============================================================================
 // implementation
@@ -112,11 +97,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
 // wxCheckBox
 // ----------------------------------------------------------------------------
 
-bool wxCheckBox::MSWCommand(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id))
-{
-    return true;
-}
-
 bool wxCheckBox::Create(wxWindow *parent,
                         wxWindowID id,
                         const wxString& label,
@@ -125,11 +105,11 @@ bool wxCheckBox::Create(wxWindow *parent,
                         const wxValidator& validator,
                         const wxString& name)
 {
-    return false;
-}
+    if(!wxControl::Create(parent, id, pos, size, style, validator, name))
+        return false;
 
-void wxCheckBox::SetLabel(const wxString& label)
-{
+    m_state = wxCHK_UNCHECKED;
+    return wxControl::PalmCreateControl(checkboxCtl, label, pos, size);
 }
 
 wxSize wxCheckBox::DoGetBestSize() const
@@ -139,28 +119,59 @@ wxSize wxCheckBox::DoGetBestSize() const
 
 void wxCheckBox::SetValue(bool val)
 {
+    SetBoolValue(val);
 }
 
 bool wxCheckBox::GetValue() const
 {
-    return false;
+    return GetBoolValue();
 }
 
-void wxCheckBox::Command(wxCommandEvent& event)
+bool wxCheckBox::SendClickEvent()
 {
+    wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, GetId());
+    event.SetInt(GetValue());
+    event.SetEventObject(this);
+    return ProcessCommand(event);
 }
 
-wxCOMPILE_TIME_ASSERT(wxCHK_UNCHECKED == BST_UNCHECKED
-    && wxCHK_CHECKED == BST_CHECKED
-    && wxCHK_UNDETERMINED == BST_INDETERMINATE, EnumValuesIncorrect);
+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