1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "checkbox.h"
16 #include "wx/checkbox.h"
19 #include <Xm/LabelG.h>
20 #include <Xm/ToggleB.h>
21 #include <Xm/ToggleBG.h>
23 #include "wx/motif/private.h"
25 void wxCheckBoxCallback (Widget w
, XtPointer clientData
,
28 #if !USE_SHARED_LIBRARY
29 IMPLEMENT_DYNAMIC_CLASS(wxCheckBox
, wxControl
)
30 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox
, wxCheckBox
)
33 // Single check box item
34 bool wxCheckBox::Create(wxWindow
*parent
, wxWindowID id
, const wxString
& label
,
36 const wxSize
& size
, long style
,
37 const wxValidator
& validator
,
41 SetValidator(validator
);
42 m_windowStyle
= style
;
44 if (parent
) parent
->AddChild(this);
47 m_windowId
= NewControlId();
51 char* label1
= (label
.IsNull() ? "" : (char*) (const char*) label
);
53 XmString text
= XmStringCreateSimple (label1
);
54 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
56 m_mainWidget
= (WXWidget
) XtVaCreateManagedWidget ("toggle",
57 xmToggleButtonWidgetClass
, parentWidget
,
62 XtAddCallback ((Widget
) m_mainWidget
, XmNvalueChangedCallback
, (XtCallbackProc
) wxCheckBoxCallback
,
65 XmToggleButtonSetState ((Widget
) m_mainWidget
, FALSE
, TRUE
);
67 SetCanAddEventHandler(TRUE
);
68 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
, pos
.x
, pos
.y
, size
.x
, size
.y
);
70 ChangeColour(m_mainWidget
);
71 SetFont(* parent
->GetFont());
76 void wxCheckBox::SetValue(bool val
)
80 XmToggleButtonSetState ((Widget
) m_mainWidget
, (Boolean
) val
, TRUE
);
81 // inSetValue = FALSE;
84 bool wxCheckBox::GetValue() const
86 return (XmToggleButtonGetState ((Widget
) m_mainWidget
) != 0);
89 void wxCheckBox::Command (wxCommandEvent
& event
)
91 SetValue ((event
.GetInt() != 0));
92 ProcessCommand (event
);
96 bool wxBitmapCheckBox::Create(wxWindow
*parent
, wxWindowID id
, const wxBitmap
*label
,
98 const wxSize
& size
, long style
,
99 const wxValidator
& validator
,
100 const wxString
& name
)
103 SetValidator(validator
);
104 m_windowStyle
= style
;
106 if (parent
) parent
->AddChild(this);
109 m_windowId
= NewControlId();
113 // TODO: Create the bitmap checkbox
118 void wxBitmapCheckBox::SetLabel(const wxBitmap
*bitmap
)
123 void wxBitmapCheckBox::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
128 void wxBitmapCheckBox::SetValue(bool val
)
133 bool wxBitmapCheckBox::GetValue() const
139 void wxCheckBoxCallback (Widget w
, XtPointer clientData
,
142 wxCheckBox
*item
= (wxCheckBox
*) clientData
;
144 // if (item->inSetValue)
147 wxCommandEvent
event (wxEVT_COMMAND_CHECKBOX_CLICKED
, item
->GetId());
148 event
.SetInt((int) item
->GetValue ());
149 event
.SetEventObject(item
);
150 item
->ProcessCommand (event
);