ref: cef6abcea6218c9638ba67edca9755f7d3fa359f
parent: 87cbe9dbbe6a0921f89e08d79b87fad7aec37cd8
author: Simon Howard <[email protected]>
date: Tue Jun 20 14:48:21 EDT 2006
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
--- a/textscreen/examples/guitest.c
+++ b/textscreen/examples/guitest.c
@@ -77,9 +77,9 @@
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 @@
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 @@
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));
}
--- a/textscreen/txt_button.c
+++ b/textscreen/txt_button.c
@@ -13,9 +13,7 @@
{
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 @@
TXT_BGColor(TXT_COLOR_BLUE, 0);
TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);
- TXT_DrawString(" ");
if (selected)
{
@@ -38,7 +35,7 @@
TXT_DrawString(button->label);
- for (i=strlen(button->label); i < w-2; ++i)
+ for (i=strlen(button->label); i < w; ++i)
{
TXT_DrawString(" ");
}
--- a/textscreen/txt_desktop.c
+++ b/textscreen/txt_desktop.c
@@ -112,6 +112,7 @@
{
free(desktop_title);
desktop_title = strdup(title);
+ SDL_WM_SetCaption(title, NULL);
}
void TXT_DrawDesktop(void)
@@ -128,7 +129,7 @@
for (i=0; i<num_windows; ++i)
{
- TXT_DrawWindow(all_windows[i]);
+ TXT_DrawWindow(all_windows[i], i == num_windows - 1);
}
TXT_UpdateScreen();
--- a/textscreen/txt_separator.c
+++ b/textscreen/txt_separator.c
@@ -39,7 +39,7 @@
// 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)
{
--- a/textscreen/txt_window.c
+++ b/textscreen/txt_window.c
@@ -221,14 +221,14 @@
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 @@
// 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 @@
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 @@
// Draw all widgets
- TXT_DrawWidget(window, 1);
+ TXT_DrawWidget(window, selected);
// Separator for action area