Always add a bit of padding inside windows (removes the need to add padding

explicitly in labels). Set the window title from the desktop title. 
Only draw widget selection highlight in the window with focus (top window).

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 560
This commit is contained in:
Simon Howard 2006-06-20 18:48:21 +00:00
parent 87cbe9dbbe
commit cef6abcea6
5 changed files with 21 additions and 23 deletions

View file

@ -77,9 +77,9 @@ void SetupWindow(void)
TXT_AddWidget(window, TXT_NewSeparator("Main section"));
table = TXT_NewTable(3);
toplabel = TXT_NewLabel(" This is a multiline label.\n"
" A single label object contains \n"
" all three of these lines.\n");
toplabel = TXT_NewLabel("This is a multiline label.\n"
"A single label object contains \n"
"all three of these lines.\n");
TXT_AddWidget(window, toplabel);
TXT_SetWidgetAlign(toplabel, TXT_HORIZ_CENTER);
@ -87,11 +87,11 @@ void SetupWindow(void)
for (i=0; i<5; ++i)
{
sprintf(buf, " Option %i in a table:", i + 1);
sprintf(buf, "Option %i in a table:", i + 1);
TXT_AddWidget(table, TXT_NewLabel(buf));
sprintf(buf, "Button %i-1", i + 1);
sprintf(buf, " Button %i-1 ", i + 1);
TXT_AddWidget(table, TXT_NewButton(buf));
sprintf(buf, "Button %i-2", i + 1);
sprintf(buf, " Button %i-2 ", i + 1);
TXT_AddWidget(table, TXT_NewButton(buf));
}
@ -153,9 +153,9 @@ void Window2(void)
TXT_AddWidget(window, TXT_NewSeparator("Input boxes"));
table = TXT_NewTable(2);
TXT_AddWidget(window, table);
TXT_AddWidget(table, TXT_NewLabel(" String: "));
TXT_AddWidget(table, TXT_NewLabel("String: "));
TXT_AddWidget(table, TXT_NewInputBox(&textbox_value, 30));
TXT_AddWidget(table, TXT_NewLabel(" Int: "));
TXT_AddWidget(table, TXT_NewLabel("Int: "));
TXT_AddWidget(table, TXT_NewIntInputBox(&numbox_value, 10));
}

View file

@ -13,9 +13,7 @@ static void TXT_ButtonSizeCalc(TXT_UNCAST_ARG(button))
{
TXT_CAST_ARG(txt_button_t, button);
// Minimum width is the string length + two spaces for padding
button->widget.w = strlen(button->label) + 2;
button->widget.w = strlen(button->label);
button->widget.h = 1;
}
@ -29,7 +27,6 @@ static void TXT_ButtonDrawer(TXT_UNCAST_ARG(button), int selected)
TXT_BGColor(TXT_COLOR_BLUE, 0);
TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);
TXT_DrawString(" ");
if (selected)
{
@ -38,7 +35,7 @@ static void TXT_ButtonDrawer(TXT_UNCAST_ARG(button), int selected)
TXT_DrawString(button->label);
for (i=strlen(button->label); i < w-2; ++i)
for (i=strlen(button->label); i < w; ++i)
{
TXT_DrawString(" ");
}

View file

@ -112,6 +112,7 @@ void TXT_SetDesktopTitle(char *title)
{
free(desktop_title);
desktop_title = strdup(title);
SDL_WM_SetCaption(title, NULL);
}
void TXT_DrawDesktop(void)
@ -128,7 +129,7 @@ void TXT_DrawDesktop(void)
for (i=0; i<num_windows; ++i)
{
TXT_DrawWindow(all_windows[i]);
TXT_DrawWindow(all_windows[i], i == num_windows - 1);
}
TXT_UpdateScreen();

View file

@ -39,7 +39,7 @@ static void TXT_SeparatorDrawer(TXT_UNCAST_ARG(separator), int selected)
// Draw separator. Go back one character and draw two extra
// to overlap the window borders.
TXT_DrawSeparator(x-1, y, w + 2);
TXT_DrawSeparator(x-2, y, w + 4);
if (separator->label != NULL)
{

View file

@ -221,14 +221,14 @@ void TXT_LayoutWindow(txt_window_t *window)
TXT_CalcWidgetSize(window);
// Widgets area: add one character of padding on each side
widgets_w = widgets->w + 2;
// Calculate the size of the action area
// Make window wide enough to action area
actionarea_w = ActionAreaWidth(window);
// Which one is larger?
widgets_w = widgets->w;
if (actionarea_w > widgets_w)
widgets_w = actionarea_w;
@ -251,9 +251,9 @@ void TXT_LayoutWindow(txt_window_t *window)
// Set the table size and position
widgets->w = widgets_w;
widgets->w = widgets_w - 2;
// widgets->h (already set)
widgets->x = window->window_x + 1;
widgets->x = window->window_x + 2;
widgets->y = window->window_y + window->window_h - widgets->h - 3;
// Layout the table and action area
@ -262,7 +262,7 @@ void TXT_LayoutWindow(txt_window_t *window)
TXT_LayoutWidget(widgets);
}
void TXT_DrawWindow(txt_window_t *window)
void TXT_DrawWindow(txt_window_t *window, int selected)
{
txt_widget_t *widgets;
int x, y;
@ -279,7 +279,7 @@ void TXT_DrawWindow(txt_window_t *window)
// Draw all widgets
TXT_DrawWidget(window, 1);
TXT_DrawWidget(window, selected);
// Separator for action area