2011-12-12 10:59:53 +00:00
|
|
|
static void CheckBox_toggle(CheckBox *self) {
|
2011-09-05 03:48:23 +00:00
|
|
|
self->state.checked = self->checked();
|
2011-12-12 10:59:53 +00:00
|
|
|
if(self->p.locked == false && self->onToggle) self->onToggle();
|
2011-02-24 09:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool pCheckBox::checked() {
|
|
|
|
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtkWidget));
|
|
|
|
}
|
|
|
|
|
2011-03-22 12:56:49 +00:00
|
|
|
Geometry pCheckBox::minimumGeometry() {
|
2011-09-05 03:48:23 +00:00
|
|
|
Geometry geometry = pFont::geometry(widget.state.font, checkBox.state.text);
|
2011-03-22 12:56:49 +00:00
|
|
|
return { 0, 0, geometry.width + 28, geometry.height + 4 };
|
|
|
|
}
|
|
|
|
|
2011-02-24 09:27:21 +00:00
|
|
|
void pCheckBox::setChecked(bool checked) {
|
|
|
|
locked = true;
|
|
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkWidget), checked);
|
|
|
|
locked = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void pCheckBox::setText(const string &text) {
|
|
|
|
gtk_button_set_label(GTK_BUTTON(gtkWidget), text);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pCheckBox::constructor() {
|
|
|
|
gtkWidget = gtk_check_button_new_with_label("");
|
2011-12-12 10:59:53 +00:00
|
|
|
g_signal_connect_swapped(G_OBJECT(gtkWidget), "toggled", G_CALLBACK(CheckBox_toggle), (gpointer)&checkBox);
|
2011-09-05 03:48:23 +00:00
|
|
|
|
|
|
|
setChecked(checkBox.state.checked);
|
|
|
|
setText(checkBox.state.text);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pCheckBox::destructor() {
|
|
|
|
gtk_widget_destroy(gtkWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pCheckBox::orphan() {
|
|
|
|
destructor();
|
|
|
|
constructor();
|
2011-02-24 09:27:21 +00:00
|
|
|
}
|