+ m_inSetValue = true;
+
+#if wxHAS_3STATE
+ unsigned char value;
+
+ switch (state)
+ {
+ case wxCHK_UNCHECKED: value = XmUNSET; break;
+ case wxCHK_CHECKED: value = XmSET; break;
+ case wxCHK_UNDETERMINED: value = XmINDETERMINATE; break;
+ default: wxASSERT(0); return;
+ }
+
+ XtVaSetValues( (Widget) m_mainWidget,
+ XmNset, value,
+ NULL );
+#else
+ XmToggleButtonSetState ((Widget) m_mainWidget,
+ state == wxCHK_CHECKED, True);
+#endif
+
+ m_inSetValue = false;
+}
+
+wxCheckBoxState wxCheckBox::DoGet3StateValue() const
+{
+#if wxHAS_3STATE
+ unsigned char value = 0;
+
+ XtVaGetValues( (Widget) m_mainWidget,
+ XmNset, &value,
+ NULL );
+
+ switch (value)
+ {
+ case XmUNSET: return wxCHK_UNCHECKED;
+ case XmSET: return wxCHK_CHECKED;
+ case XmINDETERMINATE: return wxCHK_UNDETERMINED;
+ }
+
+ // impossible...
+ return wxCHK_UNDETERMINED;
+#else
+ return wxCheckBoxState(XmToggleButtonGetState ((Widget) m_mainWidget));
+#endif
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// wxToggleButton
+///////////////////////////////////////////////////////////////////////////////
+
+#if wxUSE_TOGGLEBTN
+
+wxDEFINE_EVENT( wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEvent );
+IMPLEMENT_DYNAMIC_CLASS(wxToggleButton, wxControl)
+
+bool wxToggleButton::Create( wxWindow* parent, wxWindowID id,
+ const wxString& label,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxValidator& val,
+ const wxString &name )
+{
+ if( !wxCheckBox::Create( parent, id, label, pos, size, style, val, name ) )
+ return false;
+
+ XtVaSetValues( (Widget)m_mainWidget,
+ XmNindicatorSize, 0,
+#if XmVersion >= 2000
+ XmNindicatorOn, XmINDICATOR_NONE,
+#else
+ XmNindicatorOn, False,
+#endif
+ XmNfillOnSelect, False,
+ XmNshadowThickness, 2,
+ XmNalignment, XmALIGNMENT_CENTER,
+ XmNmarginLeft, 0,
+ XmNmarginRight, 0,
+ NULL );
+
+ // set it again, because the XtVaSetValue above resets it
+ if( size.x != -1 || size.y != -1 )
+ SetSize( size );
+
+ return true;