Exemple #1
0
static void TXT_MouseInputDrawer(TXT_UNCAST_ARG(mouse_input))
{
    TXT_CAST_ARG(txt_mouse_input_t, mouse_input);
    char buf[20];
    int i;

    if (*mouse_input->variable < 0)
    {
        M_StringCopy(buf, "(none)", sizeof(buf));
    }
    else
    {
        GetMouseButtonDescription(*mouse_input->variable, buf, sizeof(buf));
    }

    TXT_SetWidgetBG(mouse_input);
    TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);
    
    TXT_DrawString(buf);
    
    for (i=strlen(buf); i<MOUSE_INPUT_WIDTH; ++i)
    {
        TXT_DrawString(" ");
    }
}
static void TXT_JoystickInputDrawer(TXT_UNCAST_ARG(joystick_input))
{
    TXT_CAST_ARG(txt_joystick_input_t, joystick_input);
    char buf[20];
    int i;

    if (*joystick_input->variable < 0)
    {
        M_StringCopy(buf, "(none)", sizeof(buf));
    }
    else
    {
        GetJoystickButtonDescription(*joystick_input->variable,
                                     buf, sizeof(buf));
    }

    TXT_SetWidgetBG(joystick_input);
    TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);

    TXT_DrawString(buf);

    for (i=strlen(buf); i<JOYSTICK_INPUT_WIDTH; ++i)
    {
        TXT_DrawString(" ");
    }
}
static void TXT_KeyInputDrawer(TXT_UNCAST_ARG(key_input))
{
    TXT_CAST_ARG(txt_key_input_t, key_input);
    char buf[20];
    int i;

    if (*key_input->variable == 0)
    {
        M_StringCopy(buf, "(none)", sizeof(buf));
    }
    else
    {
        TXT_GetKeyDescription(*key_input->variable, buf, sizeof(buf));
    }

    TXT_SetWidgetBG(key_input);
    TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);
    
    TXT_DrawString(buf);
    
    for (i=strlen(buf); i<KEY_INPUT_WIDTH; ++i)
    {
        TXT_DrawString(" ");
    }
}
static void TXT_InputBoxDrawer(TXT_UNCAST_ARG(inputbox))
{
    TXT_CAST_ARG(txt_inputbox_t, inputbox);
    int focused;
    int i;
    int chars;
    int w;

    focused = inputbox->widget.focused;
    w = inputbox->widget.w;

    // Select the background color based on whether we are currently
    // editing, and if not, whether the widget is focused.

    if (inputbox->editing && focused)
    {
        TXT_BGColor(TXT_COLOR_BLACK, 0);
    }
    else
    {
        TXT_SetWidgetBG(inputbox);
    }

    if (!inputbox->editing)
    {
        // If not editing, use the current value from inputbox->value.

        SetBufferFromValue(inputbox);
    }

    // If string size exceeds the widget's width, show only the end.

    if (TXT_UTF8_Strlen(inputbox->buffer) > w - 1)
    {
        TXT_DrawString("\xae");
        TXT_DrawUTF8String(
            TXT_UTF8_SkipChars(inputbox->buffer,
                               TXT_UTF8_Strlen(inputbox->buffer) - w + 2));
        chars = w - 1;
    }
    else
    {
        TXT_DrawUTF8String(inputbox->buffer);
        chars = TXT_UTF8_Strlen(inputbox->buffer);
    }

    if (chars < w && inputbox->editing && focused)
    {
        TXT_BGColor(TXT_COLOR_BLACK, 1);
        TXT_DrawString("_");
        ++chars;
    }

    for (i=chars; i < w; ++i)
    {
        TXT_DrawString(" ");
    }
}
Exemple #5
0
static void TXT_SpinControlDrawer(TXT_UNCAST_ARG(spincontrol))
{
    TXT_CAST_ARG(txt_spincontrol_t, spincontrol);
    unsigned int i;
    unsigned int padding;
    int focused;

    focused = spincontrol->widget.focused;

    TXT_FGColor(TXT_COLOR_BRIGHT_CYAN);
    TXT_BGColor(TXT_WINDOW_BACKGROUND, 0);

    TXT_DrawString("\x1b ");
    
    TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);

    // Choose background color

    if (focused && spincontrol->editing)
    {
        TXT_BGColor(TXT_COLOR_BLACK, 0);
    }
    else
    {
        TXT_SetWidgetBG(spincontrol);
    }

    if (!spincontrol->editing)
    {
        SetBuffer(spincontrol);
    }
    
    i = 0;

    padding = spincontrol->widget.w - strlen(spincontrol->buffer) - 4;

    while (i < padding)
    {
        TXT_DrawString(" ");
        ++i;
    }

    TXT_DrawString(spincontrol->buffer);
    i += strlen(spincontrol->buffer);

    while (i < spincontrol->widget.w - 4)
    {
        TXT_DrawString(" ");
        ++i;
    }

    TXT_FGColor(TXT_COLOR_BRIGHT_CYAN);
    TXT_BGColor(TXT_WINDOW_BACKGROUND, 0);
    TXT_DrawString(" \x1a");
}
Exemple #6
0
static void TXT_InputBoxDrawer(TXT_UNCAST_ARG(inputbox), int selected)
{
    TXT_CAST_ARG(txt_inputbox_t, inputbox);
    int i;
    int chars;
    int w;

    w = inputbox->widget.w;

    // Select the background color based on whether we are currently
    // editing, and if not, whether the widget is selected.

    if (inputbox->editing && selected)
    {
        TXT_BGColor(TXT_COLOR_BLACK, 0);
    }
    else
    {
        TXT_SetWidgetBG(inputbox, selected);
    }

    TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);

    if (!inputbox->editing)
    {
        // If not editing, use the current value from inputbox->value.
 
        SetBufferFromValue(inputbox);
    }
    
    TXT_DrawString(inputbox->buffer);

    chars = strlen(inputbox->buffer);

    if (chars < w && inputbox->editing && selected)
    {
        TXT_BGColor(TXT_COLOR_BLACK, 1);
        TXT_DrawString("_");
        ++chars;
    }
    
    for (i=chars; i < w; ++i)
    {
        TXT_DrawString(" ");
    }
}
Exemple #7
0
static void TXT_JoystickAxisDrawer(TXT_UNCAST_ARG(joystick_axis))
{
    TXT_CAST_ARG(txt_joystick_axis_t, joystick_axis);
    char buf[JOYSTICK_AXIS_WIDTH + 1];
    int i;

    if (*joystick_axis->axis < 0)
    {
        M_StringCopy(buf, "(none)", sizeof(buf));
    }
    else if (IS_BUTTON_AXIS(*joystick_axis->axis))
    {
        int neg, pos;

        neg = BUTTON_AXIS_NEG(*joystick_axis->axis);
        pos = BUTTON_AXIS_POS(*joystick_axis->axis);
        M_snprintf(buf, sizeof(buf), "BUTTONS #%i+#%i", neg, pos);
    }
    else if (IS_HAT_AXIS(*joystick_axis->axis))
    {
        int hat, dir;

        hat = HAT_AXIS_HAT(*joystick_axis->axis);
        dir = HAT_AXIS_DIRECTION(*joystick_axis->axis);

        M_snprintf(buf, sizeof(buf), "HAT #%i (%s)", hat,
                   dir == HAT_AXIS_HORIZONTAL ? "horizontal" : "vertical");
    }
    else
    {
        M_snprintf(buf, sizeof(buf), "AXIS #%i", *joystick_axis->axis);
    }

    TXT_SetWidgetBG(joystick_axis);
    TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);

    TXT_DrawString(buf);

    for (i = TXT_UTF8_Strlen(buf); i < joystick_axis->widget.w; ++i)
    {
        TXT_DrawString(" ");
    }
}
Exemple #8
0
static void TXT_RadioButtonDrawer(TXT_UNCAST_ARG(radiobutton))
{
    TXT_CAST_ARG(txt_radiobutton_t, radiobutton);
    int i;
    int w;

    w = radiobutton->widget.w;

    TXT_BGColor(TXT_WINDOW_BACKGROUND, 0);
    TXT_FGColor(TXT_COLOR_BRIGHT_CYAN);
    TXT_DrawString("(");

    TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);

    if (*radiobutton->variable == radiobutton->value)
    {
        TXT_DrawString("\x07");
    }
    else
    {
        TXT_DrawString(" ");
    }

    TXT_FGColor(TXT_COLOR_BRIGHT_CYAN);

    TXT_DrawString(") ");

    TXT_SetWidgetBG(radiobutton);
    TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);

    TXT_DrawString(radiobutton->label);
    
    for (i=strlen(radiobutton->label); i < w-5; ++i)
    {
        TXT_DrawString(" ");
    }
}
Exemple #9
0
static void TXT_CheckBoxDrawer(TXT_UNCAST_ARG(checkbox))
{
    TXT_CAST_ARG(txt_checkbox_t, checkbox);
    int i;
    int w;

    w = checkbox->widget.w;

    TXT_BGColor(TXT_WINDOW_BACKGROUND, 0);
    TXT_FGColor(TXT_COLOR_BRIGHT_CYAN);
    TXT_DrawString("(");

    TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);

    if ((*checkbox->variable != 0) ^ checkbox->inverted)
    {
        TXT_DrawString("\x07");
    }
    else
    {
        TXT_DrawString(" ");
    }

    TXT_FGColor(TXT_COLOR_BRIGHT_CYAN);

    TXT_DrawString(") ");

    TXT_SetWidgetBG(checkbox);
    TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);

    TXT_DrawString(checkbox->label);
    
    for (i=strlen(checkbox->label); i < w-5; ++i)
    {
        TXT_DrawString(" ");
    }
}