summaryrefslogtreecommitdiff
path: root/textscreen
diff options
context:
space:
mode:
authorSimon Howard2011-09-18 14:16:27 +0000
committerSimon Howard2011-09-18 14:16:27 +0000
commit96f7da6adf5d4b6eb7b6ab66bd1758a2b14d1efa (patch)
tree4ae7dd32a8ce3da3f44c67b31c12b1ea242dad62 /textscreen
parent4dc7b33e17069c6559e9b1b7cc1ecd878162f629 (diff)
downloadchocolate-doom-96f7da6adf5d4b6eb7b6ab66bd1758a2b14d1efa.tar.gz
chocolate-doom-96f7da6adf5d4b6eb7b6ab66bd1758a2b14d1efa.tar.bz2
chocolate-doom-96f7da6adf5d4b6eb7b6ab66bd1758a2b14d1efa.zip
Hook query code into setup tool, and add search results window.
Subversion-branch: /branches/v2-branch Subversion-revision: 2383
Diffstat (limited to 'textscreen')
-rw-r--r--textscreen/txt_desktop.c27
-rw-r--r--textscreen/txt_desktop.h19
-rw-r--r--textscreen/txt_scrollpane.c18
3 files changed, 58 insertions, 6 deletions
diff --git a/textscreen/txt_desktop.c b/textscreen/txt_desktop.c
index c497f0e3..31c3921e 100644
--- a/textscreen/txt_desktop.c
+++ b/textscreen/txt_desktop.c
@@ -39,6 +39,10 @@ static txt_window_t *all_windows[MAXWINDOWS];
static int num_windows = 0;
static int main_loop_running = 0;
+static TxtIdleCallback periodic_callback = NULL;
+static void *periodic_callback_data;
+static unsigned int periodic_callback_period;
+
void TXT_AddDesktopWindow(txt_window_t *win)
{
all_windows[num_windows] = win;
@@ -197,6 +201,15 @@ void TXT_DrawASCIITable(void)
TXT_UpdateScreen();
}
+void TXT_SetPeriodicCallback(TxtIdleCallback callback,
+ void *user_data,
+ unsigned int period)
+{
+ periodic_callback = callback;
+ periodic_callback_data = user_data;
+ periodic_callback_period = period;
+}
+
void TXT_GUIMainLoop(void)
{
main_loop_running = 1;
@@ -211,10 +224,20 @@ void TXT_GUIMainLoop(void)
{
TXT_ExitMainLoop();
}
-
+
TXT_DrawDesktop();
// TXT_DrawASCIITable();
- TXT_Sleep(0);
+
+ if (periodic_callback == NULL)
+ {
+ TXT_Sleep(0);
+ }
+ else
+ {
+ TXT_Sleep(periodic_callback_period);
+
+ periodic_callback(periodic_callback_data);
+ }
}
}
diff --git a/textscreen/txt_desktop.h b/textscreen/txt_desktop.h
index 42a011e7..4b6bd4b5 100644
--- a/textscreen/txt_desktop.h
+++ b/textscreen/txt_desktop.h
@@ -30,6 +30,8 @@
#include "txt_window.h"
+typedef void (*TxtIdleCallback)(void *user_data);
+
void TXT_AddDesktopWindow(txt_window_t *win);
void TXT_RemoveDesktopWindow(txt_window_t *win);
void TXT_DrawDesktop(void);
@@ -72,6 +74,21 @@ void TXT_GUIMainLoop(void);
txt_window_t *TXT_GetActiveWindow(void);
-#endif /* #ifndef TXT_DESKTOP_H */
+/**
+ * Set a callback function to be invoked periodically by the main
+ * loop code.
+ *
+ * @param callback The callback to invoke, or NULL to cancel
+ * an existing callback.
+ * @param user_data Extra data to pass to the callback.
+ * @param period Maximum time between invoking each callback.
+ * eg. a value of 200 will cause the callback
+ * to be invoked at least once every 200ms.
+ */
+
+void TXT_SetPeriodicCallback(TxtIdleCallback callback,
+ void *user_data,
+ unsigned int period);
+#endif /* #ifndef TXT_DESKTOP_H */
diff --git a/textscreen/txt_scrollpane.c b/textscreen/txt_scrollpane.c
index 2fd45c55..dba69d30 100644
--- a/textscreen/txt_scrollpane.c
+++ b/textscreen/txt_scrollpane.c
@@ -158,6 +158,18 @@ static void TXT_ScrollPaneSizeCalc(TXT_UNCAST_ARG(scrollpane))
{
++scrollpane->widget.w;
}
+
+ if (scrollpane->child != NULL)
+ {
+ if (scrollpane->child->w < scrollpane->w)
+ {
+ scrollpane->child->w = scrollpane->w;
+ }
+ if (scrollpane->child->h < scrollpane->h)
+ {
+ scrollpane->child->h = scrollpane->h;
+ }
+ }
}
static void TXT_ScrollPaneDrawer(TXT_UNCAST_ARG(scrollpane), int selected)
@@ -382,10 +394,10 @@ static int TXT_ScrollPaneKeyPress(TXT_UNCAST_ARG(scrollpane), int key)
// automatically move the scroll pane to show the new
// selected item.
- if (scrollpane->child->widget_class == &txt_table_class
- && (key == KEY_UPARROW || key == KEY_DOWNARROW
+ if ((key == KEY_UPARROW || key == KEY_DOWNARROW
|| key == KEY_LEFTARROW || key == KEY_RIGHTARROW
- || key == KEY_PGUP || key == KEY_PGDN))
+ || key == KEY_PGUP || key == KEY_PGDN)
+ && scrollpane->child->widget_class == &txt_table_class)
{
if (PageSelectedWidget(scrollpane, key))
{