summaryrefslogtreecommitdiff
path: root/textscreen/txt_window.c
diff options
context:
space:
mode:
authorSimon Howard2006-05-20 16:34:34 +0000
committerSimon Howard2006-05-20 16:34:34 +0000
commit62b5f953677addeebac38ab6774599bbbab130f0 (patch)
tree66a787570daedf15c342099784e7ed9a1a8f30b0 /textscreen/txt_window.c
parentbb630087923d51ce190461e8aba044bff04249eb (diff)
downloadchocolate-doom-62b5f953677addeebac38ab6774599bbbab130f0.tar.gz
chocolate-doom-62b5f953677addeebac38ab6774599bbbab130f0.tar.bz2
chocolate-doom-62b5f953677addeebac38ab6774599bbbab130f0.zip
Add main loop function and forward key presses to widgets.
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 490
Diffstat (limited to 'textscreen/txt_window.c')
-rw-r--r--textscreen/txt_window.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/textscreen/txt_window.c b/textscreen/txt_window.c
index 1dcb2d88..85c6c5d1 100644
--- a/textscreen/txt_window.c
+++ b/textscreen/txt_window.c
@@ -25,6 +25,8 @@
#include <stdlib.h>
#include <string.h>
+#include "doomkeys.h"
+
#include "txt_desktop.h"
#include "txt_gui.h"
#include "txt_main.h"
@@ -217,3 +219,54 @@ void TXT_SetWindowPosition(txt_window_t *window,
window->y = y;
}
+void TXT_WindowKeyPress(txt_window_t *window, int c)
+{
+ // Send to the currently selected widget first
+
+ if (window->selected > 0 && window->selected <= window->num_widgets)
+ {
+ if (TXT_WidgetKeyPress(window->widgets[window->selected], c))
+ {
+ return;
+ }
+ }
+
+ if (c == KEY_DOWNARROW)
+ {
+ int newsel;
+
+ // Move cursor down to the next selectable widget
+
+ for (newsel = window->selected + 1;
+ newsel < window->num_widgets;
+ ++newsel)
+ {
+ if (window->widgets[newsel]->visible
+ && window->widgets[newsel]->selectable)
+ {
+ window->selected = newsel;
+ break;
+ }
+ }
+ }
+
+ if (c == KEY_UPARROW)
+ {
+ int newsel;
+
+ // Move cursor down to the next selectable widget
+
+ for (newsel = window->selected - 1;
+ newsel >= 0;
+ --newsel)
+ {
+ if (window->widgets[newsel]->visible
+ && window->widgets[newsel]->selectable)
+ {
+ window->selected = newsel;
+ break;
+ }
+ }
+ }
+}
+