예제 #1
0
static int KeyPressCallback(txt_window_t *window, int key, 
                            TXT_UNCAST_ARG(key_input))
{
    TXT_CAST_ARG(txt_key_input_t, key_input);

    if (key != KEY_ESCAPE)
    {
        // Got the key press.  Save to the variable and close the window.

        *key_input->variable = key;

        if (key_input->check_conflicts)
        {
            TXT_EmitSignal(key_input, "set");
        }

        TXT_CloseWindow(window);

        // Re-enable key mappings now that we have the key

        TXT_EnableKeyMapping(1);

        return 1;
    }
    else
    {
        return 0;
    }
}
예제 #2
0
static int TXT_ButtonKeyPress(TXT_UNCAST_ARG(button), int key)
{
    TXT_CAST_ARG(txt_button_t, button);

    if (key == KEY_ENTER)
    {
        TXT_EmitSignal(button, "pressed");
        return 1;
    }
    
    return 0;
}
예제 #3
0
static int TXT_WindowActionKeyPress(TXT_UNCAST_ARG(action), int key)
{
    TXT_CAST_ARG(txt_window_action_t, action);

    if (tolower(key) == tolower(action->key))
    {
        TXT_EmitSignal(action, "pressed");
        return 1;
    }

    return 0;
}
예제 #4
0
static int TXT_CheckBoxKeyPress(TXT_UNCAST_ARG(checkbox), int key)
{
    TXT_CAST_ARG(txt_checkbox_t, checkbox);

    if (key == KEY_ENTER || key == ' ')
    {
        *checkbox->variable = !*checkbox->variable;
        TXT_EmitSignal(checkbox, "changed");
        return 1;
    }
    
    return 0;
}
예제 #5
0
파일: txt_dropdown.c 프로젝트: AlexMax/d2k
static void ItemSelected(TXT_UNCAST_ARG(button), TXT_UNCAST_ARG(callback_data))
{
    TXT_CAST_ARG(callback_data_t, callback_data);

    // Set the variable

    *callback_data->list->variable = callback_data->item;

    TXT_EmitSignal(callback_data->list, "changed");

    // Close the window

    TXT_CloseWindow(callback_data->window);
}
예제 #6
0
static int TXT_RadioButtonKeyPress(TXT_UNCAST_ARG(radiobutton), int key)
{
    TXT_CAST_ARG(txt_radiobutton_t, radiobutton);

    if (key == KEY_ENTER || key == ' ')
    {
        if (*radiobutton->variable != radiobutton->value)
        {
            *radiobutton->variable = radiobutton->value;
            TXT_EmitSignal(radiobutton, "selected");
        }
        return 1;
    }
    
    return 0;
}
static int EventCallback(SDL_Event *event, TXT_UNCAST_ARG(joystick_input))
{
    TXT_CAST_ARG(txt_joystick_input_t, joystick_input);

    // Got the joystick button press?

    if (event->type == SDL_JOYBUTTONDOWN)
    {
        *joystick_input->variable = event->jbutton.button;
        TXT_EmitSignal(joystick_input, "set");
        TXT_CloseWindow(joystick_input->prompt_window);
        return 1;
    }

    return 0;
}
static int TXT_InputBoxKeyPress(TXT_UNCAST_ARG(inputbox), int key)
{
    TXT_CAST_ARG(txt_inputbox_t, inputbox);

    if (!inputbox->editing)
    {
        if (key == KEY_ENTER)
        {
            SetBufferFromValue(inputbox);
            inputbox->editing = 1;
            return 1;
        }

        return 0;
    }

    if (key == KEY_ENTER)
    {
        free(*((char **)inputbox->value));
        *((char **) inputbox->value) = strdup(inputbox->buffer);

        TXT_EmitSignal(&inputbox->widget, "changed");

        inputbox->editing = 0;
    }

    if (key == KEY_ESCAPE)
    {
        inputbox->editing = 0;
    }

    if (isprint(key))
    {
        // Add character to the buffer

        AddCharacter(inputbox, key);
    }

    if (key == KEY_BACKSPACE)
    {
        Backspace(inputbox);
    }
    
    return 1;
}
예제 #9
0
static int MousePressCallback(txt_window_t *window, 
                              int x, int y, int b,
                              TXT_UNCAST_ARG(mouse_input))
{
    TXT_CAST_ARG(txt_mouse_input_t, mouse_input);

    // Got the mouse press.  Save to the variable and close the window.

    *mouse_input->variable = b - TXT_MOUSE_BASE;

    if (mouse_input->check_conflicts)
    {
        TXT_EmitSignal(mouse_input, "set");
    }

    TXT_CloseWindow(window);

    return 1;
}
예제 #10
0
void TXT_CloseWindow(txt_window_t *window)
{
    int i;

    TXT_EmitSignal(window, "closed");
    TXT_RemoveDesktopWindow(window);

    free(window->title);

    // Destroy all actions

    for (i=0; i<3; ++i)
    {
        if (window->actions[i] != NULL)
        {
            TXT_DestroyWidget(window->actions[i]);
        }
    }

    // Destroy table and window

    TXT_DestroyWidget(window);
}
예제 #11
0
static void FinishEditing(txt_inputbox_t *inputbox)
{
    if (!inputbox->editing)
    {
        return;
    }

    // Save the new value back to the variable.

    if (inputbox->widget.widget_class == &txt_inputbox_class)
    {
        free(*((char **)inputbox->value));
        *((char **) inputbox->value) = strdup(inputbox->buffer);
    }
    else if (inputbox->widget.widget_class == &txt_int_inputbox_class)
    {
        *((int *) inputbox->value) = atoi(inputbox->buffer);
    }

    TXT_EmitSignal(&inputbox->widget, "changed");

    inputbox->editing = 0;
}
예제 #12
0
static void InputBoxChanged(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(fileselect))
{
    TXT_CAST_ARG(txt_fileselect_t, fileselect);

    TXT_EmitSignal(&fileselect->widget, "changed");
}