From ce8a95a5b912194ea76ebd5fb6a78c84a22747ad Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 1 Apr 2013 16:38:55 +0000 Subject: Correct incorrect doc comment. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2579 --- textscreen/txt_window.h | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) (limited to 'textscreen') diff --git a/textscreen/txt_window.h b/textscreen/txt_window.h index e183cf6d..19440941 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: + * + * + * // 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); + * * * @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); /** @@ -176,6 +191,6 @@ void TXT_SetMouseListener(txt_window_t *window, TxtWindowMousePress mouse_listener, void *user_data); -#endif /* #ifndef TXT_WINDOW_T */ +#endif /* #ifndef TXT_WINDOW_H */ -- cgit v1.2.3 From ba1c027718cbb862a2f87a417d8bdc94a9897dcf Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 27 May 2013 17:56:06 +0000 Subject: Remove use of WINAPI macro to fix compile under MSVC. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2602 --- textscreen/txt_fileselect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'textscreen') diff --git a/textscreen/txt_fileselect.c b/textscreen/txt_fileselect.c index 56fa1108..6e492734 100644 --- a/textscreen/txt_fileselect.c +++ b/textscreen/txt_fileselect.c @@ -149,7 +149,7 @@ static char *ExecReadOutput(char **argv) #include #include -static BOOL WINAPI (*MyGetOpenFileName)(LPOPENFILENAME) = NULL; +static BOOL (*MyGetOpenFileName)(LPOPENFILENAME) = NULL; static LPITEMIDLIST (*MySHBrowseForFolder)(LPBROWSEINFO) = NULL; static BOOL (*MySHGetPathFromIDList)(LPITEMIDLIST, LPTSTR) = NULL; -- cgit v1.2.3 From e10af52152ba793d983497cd86d7ccc10d32a13d Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 8 Sep 2013 18:57:20 +0000 Subject: Fix file select widget to emit "changed" signal properly. Reset variable value to empty string rather than NULL if cancel is pressed in dialog (thanks Alexandre Xavier). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2638 --- textscreen/txt_fileselect.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'textscreen') diff --git a/textscreen/txt_fileselect.c b/textscreen/txt_fileselect.c index 6e492734..52b0dc1c 100644 --- a/textscreen/txt_fileselect.c +++ b/textscreen/txt_fileselect.c @@ -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; } -- cgit v1.2.3