summaryrefslogtreecommitdiff
path: root/textscreen
diff options
context:
space:
mode:
authorSimon Howard2013-09-08 19:10:40 +0000
committerSimon Howard2013-09-08 19:10:40 +0000
commitf2c204ccca3b93b318cda3aebf29592aa30385e4 (patch)
treed63ddaa28421cccdf9789673cd2cb2dc688fb982 /textscreen
parentf3afff090adb5af99dc6e1929a9907bf72fda920 (diff)
parente10af52152ba793d983497cd86d7ccc10d32a13d (diff)
downloadchocolate-doom-f2c204ccca3b93b318cda3aebf29592aa30385e4.tar.gz
chocolate-doom-f2c204ccca3b93b318cda3aebf29592aa30385e4.tar.bz2
chocolate-doom-f2c204ccca3b93b318cda3aebf29592aa30385e4.zip
Merge from trunk.
Subversion-branch: /branches/v2-branch Subversion-revision: 2639
Diffstat (limited to 'textscreen')
-rw-r--r--textscreen/txt_fileselect.c25
-rw-r--r--textscreen/txt_window.h50
2 files changed, 56 insertions, 19 deletions
diff --git a/textscreen/txt_fileselect.c b/textscreen/txt_fileselect.c
index 56fa1108..52b0dc1c 100644
--- a/textscreen/txt_fileselect.c
+++ b/textscreen/txt_fileselect.c
@@ -149,7 +149,7 @@ static char *ExecReadOutput(char **argv)
#include <windows.h>
#include <shlobj.h>
-static BOOL WINAPI (*MyGetOpenFileName)(LPOPENFILENAME) = NULL;
+static BOOL (*MyGetOpenFileName)(LPOPENFILENAME) = NULL;
static LPITEMIDLIST (*MySHBrowseForFolder)(LPBROWSEINFO) = NULL;
static BOOL (*MySHGetPathFromIDList)(LPITEMIDLIST, LPTSTR) = NULL;
@@ -591,6 +591,16 @@ static int DoSelectFile(txt_fileselect_t *fileselect)
{
path = TXT_SelectFile(fileselect->prompt,
fileselect->extensions);
+
+ // Update inputbox variable.
+ // If cancel was pressed (ie. NULL was returned by TXT_SelectFile)
+ // then reset to empty string, not NULL).
+
+ if (path == NULL)
+ {
+ path = strdup("");
+ }
+
var = fileselect->inputbox->value;
free(*var);
*var = path;
@@ -658,6 +668,16 @@ txt_widget_class_t txt_fileselect_class =
TXT_FileSelectFocused,
};
+// If the (inner) inputbox widget is changed, emit a change to the
+// outer (fileselect) widget.
+
+static void InputBoxChanged(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(fileselect))
+{
+ TXT_CAST_ARG(txt_fileselect_t, fileselect);
+
+ TXT_EmitSignal(&fileselect->widget, "changed");
+}
+
txt_fileselect_t *TXT_NewFileSelector(char **variable, int size,
char *prompt, char **extensions)
{
@@ -671,6 +691,9 @@ txt_fileselect_t *TXT_NewFileSelector(char **variable, int size,
fileselect->prompt = prompt;
fileselect->extensions = extensions;
+ TXT_SignalConnect(fileselect->inputbox, "changed",
+ InputBoxChanged, fileselect);
+
return fileselect;
}
diff --git a/textscreen/txt_window.h b/textscreen/txt_window.h
index bfae2a9a..8b1e1fb9 100644
--- a/textscreen/txt_window.h
+++ b/textscreen/txt_window.h
@@ -1,4 +1,4 @@
-// Emacs style mode select -*- C++ -*-
+// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright(C) 2006 Simon Howard
@@ -49,15 +49,16 @@
typedef struct txt_window_s txt_window_t;
-#include "txt_widget.h"
+#include "txt_widget.h"
#include "txt_table.h"
#include "txt_window_action.h"
// Callback function for window key presses
-typedef int (*TxtWindowKeyPress)(txt_window_t *window, int key, void *user_data);
-typedef int (*TxtWindowMousePress)(txt_window_t *window,
- int x, int y, int b,
+typedef int (*TxtWindowKeyPress)(txt_window_t *window, int key,
+ void *user_data);
+typedef int (*TxtWindowMousePress)(txt_window_t *window,
+ int x, int y, int b,
void *user_data);
struct txt_window_s
@@ -65,7 +66,7 @@ struct txt_window_s
// Base class: all windows are tables with one column.
txt_table_t table;
-
+
// Window title
char *title;
@@ -114,17 +115,31 @@ void TXT_CloseWindow(txt_window_t *window);
/**
* Set the position of a window on the screen.
*
- * The window is specified as coordinates relative to a predefined
- * position on the screen (eg. center of the screen, top left of the
- * screen, etc).
+ * The position is specified as a pair of x, y, coordinates on the
+ * screen. These specify the position of a particular point on the
+ * window. The following are some examples:
+ *
+ * <code>
+ * // Centered on the screen:
+ *
+ * TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_CENTER,
+ * TXT_SCREEN_W / 2, TXT_SCREEN_H / 2);
+ *
+ * // Horizontally centered, with top of the window on line 6:
+ *
+ * TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP,
+ * TXT_SCREEN_W / 2, 6);
+ *
+ * // Top-left of window at 20, 6:
+ *
+ * TXT_SetWindowPosition(window, TXT_HORIZ_LEFT, TXT_VERT_TOP, 20, 6);
+ * </code>
*
* @param window The window.
- * @param horiz_align Horizontal position on the screen to which the
- * coordinates are relative (left side, right side
- * or center).
- * @param vert_align Vertical position on the screen to which the
- * coordinates are relative (top, bottom or center).
- * @param x X coordinate (horizonal axis) for window position.
+ * @param horiz_align Horizontal location on the window for the X
+ * position.
+ * @param vert_align Vertical location on the window for the Y position.
+ * @param x X coordinate (horizontal axis) for window position.
* @param y Y coordinate (vertical axis) for window position.
*/
@@ -145,7 +160,7 @@ void TXT_SetWindowPosition(txt_window_t *window,
* current window action in the given slot is removed.
*/
-void TXT_SetWindowAction(txt_window_t *window, txt_horiz_align_t position,
+void TXT_SetWindowAction(txt_window_t *window, txt_horiz_align_t position,
txt_window_action_t *action);
/**
@@ -186,6 +201,5 @@ void TXT_SetMouseListener(txt_window_t *window,
txt_window_t *TXT_MessageBox(char *title, char *message, ...);
-#endif /* #ifndef TXT_WINDOW_T */
-
+#endif /* #ifndef TXT_WINDOW_H */