Ejemplo n.º 1
0
static char *ExtensionsList(char **extensions)
{
    char *result, *escaped;
    unsigned int result_len;
    unsigned int i;

    if (extensions == NULL)
    {
        return NULL;
    }

    result_len = 3;
    for (i = 0; extensions[i] != NULL; ++i)
    {
        result_len += 5 + strlen(extensions[i]) * 2;
    }

    result = malloc(result_len);
    TXT_StringCopy(result, "{", result_len);

    for (i = 0; extensions[i] != NULL; ++i)
    {
        escaped = EscapedString(extensions[i]);
        TXT_StringConcat(result, escaped, result_len);
        free(escaped);

        if (extensions[i + 1] != NULL)
            TXT_StringConcat(result, ",", result_len);
    }

    TXT_StringConcat(result, "}", result_len);

    return result;
}
Ejemplo n.º 2
0
static void SetBufferFromValue(txt_inputbox_t *inputbox)
{
    if (inputbox->widget.widget_class == &txt_inputbox_class)
    {
        char **value = (char **) inputbox->value;

        if (*value != NULL)
        {
            TXT_StringCopy(inputbox->buffer, *value, inputbox->size);
        }
        else
        {
            TXT_StringCopy(inputbox->buffer, "", inputbox->buffer_len);
        }
    }
    else if (inputbox->widget.widget_class == &txt_int_inputbox_class)
    {
        int *value = (int *) inputbox->value;
        TXT_snprintf(inputbox->buffer, inputbox->buffer_len, "%i", *value);
    }
}
Ejemplo n.º 3
0
static char *GenerateSelector(char *window_title, char **extensions)
{
    char *chooser, *ext_list, *result;
    unsigned int result_len;

    result_len = 64;

    if (extensions == TXT_DIRECTORY)
    {
        chooser = "choose folder";
        ext_list = NULL;
    }
    else
    {
        chooser = "choose file";
        ext_list = ExtensionsList(extensions);
    }

    // Calculate size.

    if (window_title != NULL)
    {
        window_title = EscapedString(window_title);
        result_len += strlen(window_title);
    }
    if (ext_list != NULL)
    {
        result_len += strlen(ext_list);
    }

    result = malloc(result_len);

    TXT_StringCopy(result, chooser, result_len);

    if (window_title != NULL)
    {
        TXT_StringConcat(result, " with prompt ", result_len);
        TXT_StringConcat(result, window_title, result_len);
        free(window_title);
    }

    if (ext_list != NULL)
    {
        TXT_StringConcat(result, "of type ", result_len);
        TXT_StringConcat(result, ext_list, result_len);
        free(ext_list);
    }

    return result;
}
Ejemplo n.º 4
0
static void StartEditing(txt_inputbox_t *inputbox)
{
    // Integer input boxes start from an empty buffer:

    if (inputbox->widget.widget_class == &txt_int_inputbox_class)
    {
        TXT_StringCopy(inputbox->buffer, "", inputbox->buffer_len);
    }
    else
    {
        SetBufferFromValue(inputbox);
    }

    inputbox->editing = 1;
}
Ejemplo n.º 5
0
static void StartEditing(txt_inputbox_t *inputbox)
{
    // Integer input boxes start from an empty buffer:

    if (inputbox->widget.widget_class == &txt_int_inputbox_class)
    {
        TXT_StringCopy(inputbox->buffer, "", inputbox->buffer_len);
    }
    else
    {
        SetBufferFromValue(inputbox);
    }

    // Switch to text input mode so we get shifted input.
    TXT_SetInputMode(TXT_INPUT_TEXT);
    inputbox->editing = 1;
}
Ejemplo n.º 6
0
static void StartEditing(txt_inputbox_t *inputbox)
{
    #ifdef USE_VIRTUALKEYBOARD
    VKBCreateWindow(inputbox, 0);
    #endif // USE_VIRTUALKEYBOARD
    // Integer input boxes start from an empty buffer:

    if (inputbox->widget.widget_class == &txt_int_inputbox_class)
    {
        TXT_StringCopy(inputbox->buffer, "", inputbox->buffer_len);
    }
    else
    {
        SetBufferFromValue(inputbox);
    }

    inputbox->editing = 1;
}