2015-06-11 18:07:06 -05:00
|
|
|
// 11 june 2015
|
|
|
|
#include "uipriv_unix.h"
|
|
|
|
|
2015-08-27 22:00:34 -05:00
|
|
|
struct uiLabel {
|
|
|
|
uiUnixControl c;
|
2015-06-11 18:07:06 -05:00
|
|
|
GtkWidget *widget;
|
2015-06-27 18:46:11 -05:00
|
|
|
GtkMisc *misc;
|
|
|
|
GtkLabel *label;
|
2015-06-11 18:07:06 -05:00
|
|
|
};
|
|
|
|
|
2015-08-27 22:00:34 -05:00
|
|
|
uiUnixDefineControl(
|
|
|
|
uiLabel, // type name
|
|
|
|
uiLabelType // type function
|
|
|
|
)
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-08-27 22:00:34 -05:00
|
|
|
char *uiLabelText(uiLabel *l)
|
2015-06-11 18:07:06 -05:00
|
|
|
{
|
2015-06-30 21:10:52 -05:00
|
|
|
return uiUnixStrdupText(gtk_label_get_text(l->label));
|
2015-06-11 18:07:06 -05:00
|
|
|
}
|
|
|
|
|
2015-08-27 22:00:34 -05:00
|
|
|
void uiLabelSetText(uiLabel *l, const char *text)
|
2015-06-11 18:07:06 -05:00
|
|
|
{
|
2015-06-30 21:10:52 -05:00
|
|
|
gtk_label_set_text(l->label, text);
|
2015-06-11 18:07:06 -05:00
|
|
|
// changing the text might necessitate a change in the label's size
|
|
|
|
uiControlQueueResize(uiControl(l));
|
|
|
|
}
|
|
|
|
|
|
|
|
uiLabel *uiNewLabel(const char *text)
|
|
|
|
{
|
2015-08-27 22:00:34 -05:00
|
|
|
uiLabel *l;
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-08-27 22:00:34 -05:00
|
|
|
l = (uiLabel *) uiNewControl(uiTypeLabel());
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-06-27 18:46:11 -05:00
|
|
|
l->widget = gtk_label_new(text);
|
|
|
|
l->misc = GTK_MISC(l->widget);
|
|
|
|
l->label = GTK_LABEL(l->widget);
|
|
|
|
|
|
|
|
gtk_misc_set_alignment(l->misc, 0, 0);
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-08-27 22:00:34 -05:00
|
|
|
uiUnixFinishNewControl(l, uiLabel);
|
2015-06-11 18:07:06 -05:00
|
|
|
|
2015-08-27 22:00:34 -05:00
|
|
|
return l;
|
2015-06-11 18:07:06 -05:00
|
|
|
}
|