Implemented uiRadioButtons on GTK+.
This commit is contained in:
parent
395cc5108c
commit
c3abede628
|
@ -6,11 +6,15 @@
|
||||||
struct radiobuttons {
|
struct radiobuttons {
|
||||||
uiRadioButtons r;
|
uiRadioButtons r;
|
||||||
GtkWidget *boxWidget;
|
GtkWidget *boxWidget;
|
||||||
|
GtkContainer *boxContainer;
|
||||||
GtkBox *box;
|
GtkBox *box;
|
||||||
|
GPtrArray *buttons;
|
||||||
};
|
};
|
||||||
|
|
||||||
uiDefineControlType(uiRadioButtons, uiTypeRadioButtons, struct radiobuttons)
|
uiDefineControlType(uiRadioButtons, uiTypeRadioButtons, struct radiobuttons)
|
||||||
|
|
||||||
|
// TODO destroy
|
||||||
|
|
||||||
// TODO note that the handle of a uiRadioButtons is undefined (or at least highly platform-dependent and unreliable)
|
// TODO note that the handle of a uiRadioButtons is undefined (or at least highly platform-dependent and unreliable)
|
||||||
static uintptr_t radiobuttonsHandle(uiControl *c)
|
static uintptr_t radiobuttonsHandle(uiControl *c)
|
||||||
{
|
{
|
||||||
|
@ -22,8 +26,16 @@ static uintptr_t radiobuttonsHandle(uiControl *c)
|
||||||
static void radiobuttonsAppend(uiRadioButtons *rr, const char *text)
|
static void radiobuttonsAppend(uiRadioButtons *rr, const char *text)
|
||||||
{
|
{
|
||||||
struct radiobuttons *r = (struct radiobuttons *) rr;
|
struct radiobuttons *r = (struct radiobuttons *) rr;
|
||||||
|
GtkWidget *rb;
|
||||||
|
GtkRadioButton *previous;
|
||||||
|
|
||||||
PUT_CODE_HERE;
|
previous = NULL;
|
||||||
|
if (r->buttons->len > 0)
|
||||||
|
previous = GTK_RADIO_BUTTON(g_ptr_array_index(r->buttons, 0));
|
||||||
|
rb = gtk_radio_button_new_with_label_from_widget(previous, text);
|
||||||
|
gtk_container_add(r->boxContainer, rb);
|
||||||
|
g_ptr_array_add(r->buttons, rb);
|
||||||
|
gtk_widget_show(rb);
|
||||||
uiControlQueueResize(uiControl(r));
|
uiControlQueueResize(uiControl(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,9 +46,12 @@ uiRadioButtons *uiNewRadioButtons(void)
|
||||||
r = (struct radiobuttons *) uiNewControl(uiTypeRadioButtons());
|
r = (struct radiobuttons *) uiNewControl(uiTypeRadioButtons());
|
||||||
|
|
||||||
r->boxWidget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
|
r->boxWidget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
|
||||||
|
r->boxContainer = GTK_CONTAINER(r->boxWidget);
|
||||||
r->box = GTK_BOX(r->boxWidget);
|
r->box = GTK_BOX(r->boxWidget);
|
||||||
uiUnixMakeSingleWidgetControl(uiControl(r), r->boxWidget);
|
uiUnixMakeSingleWidgetControl(uiControl(r), r->boxWidget);
|
||||||
|
|
||||||
|
r->buttons = g_ptr_array_new();
|
||||||
|
|
||||||
uiControl(r)->Handle = radiobuttonsHandle;
|
uiControl(r)->Handle = radiobuttonsHandle;
|
||||||
|
|
||||||
uiRadioButtons(r)->Append = radiobuttonsAppend;
|
uiRadioButtons(r)->Append = radiobuttonsAppend;
|
||||||
|
|
Loading…
Reference in New Issue