Example #1
0
txt_mouse_input_t *TXT_NewMouseInput(int *variable)
{
    txt_mouse_input_t *mouse_input;

    mouse_input = malloc(sizeof(txt_mouse_input_t));

    TXT_InitWidget(mouse_input, &txt_mouse_input_class);
    mouse_input->variable = variable;

    return mouse_input;
}
Example #2
0
txt_button_t *TXT_NewButton(char *label)
{
    txt_button_t *button;

    button = malloc(sizeof(txt_button_t));

    TXT_InitWidget(button, &txt_button_class);
    button->label = strdup(label);

    return button;
}
Example #3
0
txt_key_input_t *TXT_NewKeyInput(int *variable)
{
    txt_key_input_t *key_input;

    key_input = malloc(sizeof(txt_key_input_t));

    TXT_InitWidget(key_input, &txt_key_input_class);
    key_input->variable = variable;

    return key_input;
}
txt_joystick_input_t *TXT_NewJoystickInput(int *variable)
{
    txt_joystick_input_t *joystick_input;

    joystick_input = malloc(sizeof(txt_joystick_input_t));

    TXT_InitWidget(joystick_input, &txt_joystick_input_class);
    joystick_input->variable = variable;

    return joystick_input;
}
Example #5
0
txt_strut_t *TXT_NewStrut(int width, int height)
{
    txt_strut_t *strut;

    strut = malloc(sizeof(txt_strut_t));

    TXT_InitWidget(strut, &txt_strut_class);
    strut->width = width;
    strut->height = height;

    return strut;
}
Example #6
0
txt_window_action_t *TXT_NewWindowAction(int key, const char *label)
{
    txt_window_action_t *action;

    action = malloc(sizeof(txt_window_action_t));

    TXT_InitWidget(action, &txt_window_action_class);
    action->key = key;
    action->label = strdup(label);

    return action;
}
Example #7
0
txt_radiobutton_t *TXT_NewRadioButton(char *label, int *variable, int value)
{
    txt_radiobutton_t *radiobutton;

    radiobutton = malloc(sizeof(txt_radiobutton_t));

    TXT_InitWidget(radiobutton, &txt_radiobutton_class);
    radiobutton->label = strdup(label);
    radiobutton->variable = variable;
    radiobutton->value = value;

    return radiobutton;
}
Example #8
0
txt_checkbox_t *TXT_NewCheckBox(char *label, int *variable)
{
    txt_checkbox_t *checkbox;

    checkbox = malloc(sizeof(txt_checkbox_t));

    TXT_InitWidget(checkbox, &txt_checkbox_class);
    checkbox->label = strdup(label);
    checkbox->variable = variable;
    checkbox->inverted = 0;

    return checkbox;
}
Example #9
0
txt_separator_t *TXT_NewSeparator(const char *label)
{
    txt_separator_t *separator;

    separator = malloc(sizeof(txt_separator_t));

    TXT_InitWidget(separator, &txt_separator_class);

    separator->label = NULL;
    TXT_SetSeparatorLabel(separator, label);

    return separator;
}
Example #10
0
static txt_spincontrol_t *TXT_BaseSpinControl(void)
{
    txt_spincontrol_t *spincontrol;

    spincontrol = malloc(sizeof(txt_spincontrol_t));

    TXT_InitWidget(spincontrol, &txt_spincontrol_class);
    spincontrol->buffer = malloc(25);
    strcpy(spincontrol->buffer, "");
    spincontrol->editing = 0;

    return spincontrol;
}
txt_inputbox_t *TXT_NewIntInputBox(int *value, int size)
{
    txt_inputbox_t *inputbox;

    inputbox = malloc(sizeof(txt_inputbox_t));

    TXT_InitWidget(inputbox, &txt_int_inputbox_class);
    inputbox->value = value;
    inputbox->size = size;
    inputbox->buffer = malloc(15);
    inputbox->editing = 0;
    return inputbox;
}
Example #12
0
txt_dropdown_list_t *TXT_NewDropdownList(int *variable, char **values, 
                                         int num_values)
{
    txt_dropdown_list_t *list;

    list = malloc(sizeof(txt_dropdown_list_t));

    TXT_InitWidget(list, &txt_dropdown_list_class);
    list->variable = variable;
    list->values = values;
    list->num_values = num_values;

    return list;
}
Example #13
0
txt_joystick_axis_t *TXT_NewJoystickAxis(int *axis, int *invert,
                                         txt_joystick_axis_direction_t dir)
{
    txt_joystick_axis_t *joystick_axis;

    joystick_axis = malloc(sizeof(txt_joystick_axis_t));

    TXT_InitWidget(joystick_axis, &txt_joystick_axis_class);
    joystick_axis->axis = axis;
    joystick_axis->invert = invert;
    joystick_axis->dir = dir;
    joystick_axis->bad_axis = NULL;

    return joystick_axis;
}
Example #14
0
txt_scrollpane_t *TXT_NewScrollPane(int w, int h, TXT_UNCAST_ARG(target))
{
    TXT_CAST_ARG(txt_widget_t, target);
    txt_scrollpane_t *scrollpane;

    scrollpane = malloc(sizeof(txt_scrollpane_t));
    TXT_InitWidget(scrollpane, &txt_scrollpane_class);
    scrollpane->w = w;
    scrollpane->h = h;
    scrollpane->x = 0;
    scrollpane->y = 0;
    scrollpane->child = target;
    scrollpane->expand_w = w <= 0;
    scrollpane->expand_h = h <= 0;

    return scrollpane;
}
Example #15
0
static txt_inputbox_t *NewInputBox(txt_widget_class_t *widget_class,
                                   void *value, int size)
{
    txt_inputbox_t *inputbox;

    inputbox = malloc(sizeof(txt_inputbox_t));

    TXT_InitWidget(inputbox, widget_class);
    inputbox->value = value;
    inputbox->size = size;
    // 'size' is the maximum number of characters that can be entered,
    // but for a UTF-8 string, each character can take up to four
    // characters.
    inputbox->buffer = malloc(size * 4 + 1);
    inputbox->editing = 0;

    return inputbox;
}
Example #16
0
txt_fileselect_t *TXT_NewFileSelector(char **variable, int size,
                                      char *prompt, char **extensions)
{
    txt_fileselect_t *fileselect;

    fileselect = malloc(sizeof(txt_fileselect_t));
    TXT_InitWidget(fileselect, &txt_fileselect_class);
    fileselect->inputbox = TXT_NewInputBox(variable, 1024);
    fileselect->inputbox->widget.parent = &fileselect->widget;
    fileselect->size = size;
    fileselect->prompt = prompt;
    fileselect->extensions = extensions;

    TXT_SignalConnect(fileselect->inputbox, "changed",
                      InputBoxChanged, fileselect);

    return fileselect;
}
Example #17
0
txt_label_t *TXT_NewLabel(char *text)
{
    txt_label_t *label;

    label = malloc(sizeof(txt_label_t));

    TXT_InitWidget(label, &txt_label_class);
    label->label = NULL;
    label->lines = NULL;

    // Default colors

    label->bgcolor = -1;
    label->fgcolor = -1;

    TXT_SetLabel(label, text);

    return label;
}
Example #18
0
txt_label_t *TXT_NewLabel(char *text)
{
    txt_label_t *label;

    label = malloc(sizeof(txt_label_t));

    TXT_InitWidget(label, &txt_label_class);
    label->widget.selectable = 0;
    label->label = NULL;
    label->lines = NULL;

    // Default colors

    label->bgcolor = TXT_COLOR_BLUE;
    label->fgcolor = TXT_COLOR_BRIGHT_WHITE;

    TXT_SetLabel(label, text);

    return label;
}
Example #19
0
void TXT_InitTable(txt_table_t *table, int columns)
{
    int i;

    TXT_InitWidget(table, &txt_table_class);
    table->columns = columns;
    table->widgets = NULL;
    table->num_widgets = 0;
    table->selected_x = 0;
    table->selected_y = 0;

    // Add a strut for each column at the start of the table. 
    // These are used by the TXT_SetColumnWidths function below:
    // the struts are created with widths of 0 each, but this
    // function changes them.

    for (i=0; i<columns; ++i)
    {
        TXT_AddWidget(table, TXT_NewStrut(0, 0));
    }
}