2015-06-11 18:07:06 -05:00
|
|
|
// 11 june 2015
|
|
|
|
#include "uipriv_unix.h"
|
|
|
|
|
|
|
|
struct group {
|
|
|
|
uiGroup g;
|
|
|
|
GtkWidget *widget;
|
2015-06-26 20:52:42 -05:00
|
|
|
GtkContainer *container;
|
|
|
|
GtkFrame *frame;
|
2015-06-11 18:07:06 -05:00
|
|
|
uiControl *child;
|
|
|
|
int margined;
|
|
|
|
};
|
|
|
|
|
|
|
|
uiDefineControlType(uiGroup, uiTypeGroup, struct group)
|
|
|
|
|
|
|
|
static uintptr_t groupHandle(uiControl *c)
|
|
|
|
{
|
|
|
|
struct group *g = (struct group *) c;
|
|
|
|
|
|
|
|
return (uintptr_t) (g->widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void groupContainerUpdateState(uiControl *c)
|
|
|
|
{
|
|
|
|
struct group *g = (struct group *) c;
|
|
|
|
|
|
|
|
if (g->child != NULL)
|
|
|
|
uiControlUpdateState(g->child);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *groupTitle(uiGroup *gg)
|
|
|
|
{
|
|
|
|
struct group *g = (struct group *) gg;
|
|
|
|
|
|
|
|
return PUT_CODE_HERE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void groupSetTitle(uiGroup *gg, const char *text)
|
|
|
|
{
|
|
|
|
struct group *g = (struct group *) gg;
|
|
|
|
|
|
|
|
PUT_CODE_HERE;
|
|
|
|
// changing the text might necessitate a change in the groupbox's size
|
|
|
|
uiControlQueueResize(uiControl(g));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void groupSetChild(uiGroup *gg, uiControl *child)
|
|
|
|
{
|
|
|
|
struct group *g = (struct group *) gg;
|
|
|
|
|
|
|
|
if (g->child != NULL)
|
|
|
|
uiControlSetParent(g->child, NULL);
|
|
|
|
g->child = child;
|
|
|
|
if (g->child != NULL) {
|
|
|
|
uiControlSetParent(g->child, uiControl(g));
|
|
|
|
uiControlQueueResize(g->child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int groupMargined(uiGroup *gg)
|
|
|
|
{
|
|
|
|
struct group *g = (struct group *) gg;
|
|
|
|
|
|
|
|
return g->margined;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void groupSetMargined(uiGroup *gg, int margined)
|
|
|
|
{
|
|
|
|
struct group *g = (struct group *) gg;
|
|
|
|
|
|
|
|
g->margined = margined;
|
|
|
|
uiControlQueueResize(uiControl(g));
|
|
|
|
}
|
|
|
|
|
|
|
|
uiGroup *uiNewGroup(const char *text)
|
|
|
|
{
|
|
|
|
struct group *g;
|
2015-06-26 20:52:42 -05:00
|
|
|
gfloat yalign;
|
|
|
|
GtkLabel *label;
|
|
|
|
PangoAttribute *bold;
|
|
|
|
PangoAttrList *boldlist;
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-06-14 19:02:38 -05:00
|
|
|
g = (struct group *) uiNewControl(uiTypeGroup());
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-06-26 20:52:42 -05:00
|
|
|
g->widget = gtk_frame_new(text);
|
|
|
|
g->container = GTK_CONTAINER(g->widget);
|
|
|
|
g->frame = GTK_FRAME(g->widget);
|
|
|
|
uiUnixMakeSingleWidgetControl(uiControl(g), g->widget);
|
|
|
|
|
|
|
|
// with GTK+, groupboxes by default have frames and slightly x-offset regular text
|
|
|
|
// they should have no frame and fully left-justified, bold text
|
|
|
|
// preserve default y-alignment
|
|
|
|
gtk_frame_get_label_align(g->frame, NULL, &yalign);
|
|
|
|
gtk_frame_set_label_align(g->frame, 0, yalign);
|
|
|
|
gtk_frame_set_shadow_type(g->frame, GTK_SHADOW_NONE);
|
|
|
|
label = GTK_LABEL(gtk_frame_get_label_widget(g->frame));
|
|
|
|
// this is the boldness level used by GtkPrintUnixDialog
|
|
|
|
// (it technically uses "bold" but see pango's pango-enum-types.c for the name conversion; GType is weird)
|
|
|
|
bold = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
|
|
|
|
boldlist = pango_attr_list_new();
|
|
|
|
pango_attr_list_insert(boldlist, bold);
|
|
|
|
gtk_label_set_attributes(label, boldlist);
|
|
|
|
pango_attr_list_unref(boldlist); // thanks baedert in irc.gimp.net/#gtk+
|
2015-06-11 18:07:06 -05:00
|
|
|
|
|
|
|
uiControl(g)->Handle = groupHandle;
|
|
|
|
uiControl(g)->ContainerUpdateState = groupContainerUpdateState;
|
|
|
|
|
|
|
|
uiGroup(g)->Title = groupTitle;
|
|
|
|
uiGroup(g)->SetTitle = groupSetTitle;
|
|
|
|
uiGroup(g)->SetChild = groupSetChild;
|
|
|
|
uiGroup(g)->Margined = groupMargined;
|
|
|
|
uiGroup(g)->SetMargined = groupSetMargined;
|
|
|
|
|
|
|
|
return uiGroup(g);
|
|
|
|
}
|