+bool wxToggleBitmapButton::IsOwnGtkWindow(GdkWindow *window)
+{
+ return window == TOGGLE_BUTTON_EVENT_WIN(m_widget);
+}
+
+void wxToggleBitmapButton::OnInternalIdle()
+{
+ wxCursor cursor = m_cursor;
+
+ if (g_globalCursor.Ok())
+ cursor = g_globalCursor;
+
+ GdkWindow *win = TOGGLE_BUTTON_EVENT_WIN(m_widget);
+ if ( win && cursor.Ok() )
+ {
+ /* I now set the cursor the anew in every OnInternalIdle call
+ as setting the cursor in a parent window also effects the
+ windows above so that checking for the current cursor is
+ not possible. */
+
+ gdk_window_set_cursor(win, cursor.GetCursor());
+ }
+
+ if (wxUpdateUIEvent::CanUpdate(this))
+ UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
+}
+
+
+// Get the "best" size for this control.
+wxSize wxToggleBitmapButton::DoGetBestSize() const
+{
+ wxSize best;
+
+ if (m_bitmap.Ok())
+ {
+ int border = HasFlag(wxNO_BORDER) ? 4 : 10;
+ best.x = m_bitmap.GetWidth()+border;
+ best.y = m_bitmap.GetHeight()+border;
+ }
+ CacheBestSize(best);
+ return best;
+}
+
+
+// static
+wxVisualAttributes
+wxToggleBitmapButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
+{
+ return GetDefaultAttributesFromGTKWidget(gtk_toggle_button_new);
+}
+
+
+// ------------------------------------------------------------------------
+// wxToggleButton
+// ------------------------------------------------------------------------
+
+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& validator,
+ const wxString &name)
+{
+ m_needParent = true;
+ m_acceptsFocus = true;
+
+ m_blockEvent = false;
+
+ if (!PreCreation(parent, pos, size) ||
+ !CreateBase(parent, id, pos, size, style, validator, name )) {
+ wxFAIL_MSG(wxT("wxToggleButton creation failed"));
+ return false;
+ }
+
+ wxControl::SetLabel(label);
+
+ // Create the gtk widget.
+ m_widget = gtk_toggle_button_new_with_label( wxGTK_CONV( m_label ) );
+
+ gtk_signal_connect(GTK_OBJECT(m_widget), "clicked",
+ GTK_SIGNAL_FUNC(gtk_togglebutton_clicked_callback),
+ (gpointer *)this);
+
+ m_parent->DoAddChild(this);
+
+ PostCreation(size);
+
+ return true;