From 344823214b77a076351e1101a89e8c2a407dca48 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 19 May 2006 19:57:59 +0000 Subject: Split off text mode gui desktop code into a separate file. Rename some of the functions in txt_gui.c. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 483 --- textscreen/Makefile.am | 1 + textscreen/guitest.c | 6 +-- textscreen/txt_desktop.c | 133 +++++++++++++++++++++++++++++++++++++++++++++++ textscreen/txt_desktop.h | 37 +++++++++++++ textscreen/txt_gui.c | 6 +-- textscreen/txt_gui.h | 6 +-- textscreen/txt_window.c | 64 +++-------------------- textscreen/txt_window.h | 2 - 8 files changed, 186 insertions(+), 69 deletions(-) create mode 100644 textscreen/txt_desktop.c create mode 100644 textscreen/txt_desktop.h (limited to 'textscreen') diff --git a/textscreen/Makefile.am b/textscreen/Makefile.am index 2c7903f1..c00f6179 100644 --- a/textscreen/Makefile.am +++ b/textscreen/Makefile.am @@ -5,6 +5,7 @@ noinst_LIBRARIES=libtextscreen.a bin_PROGRAMS=guitest libtextscreen_a_SOURCES = \ + txt_desktop.c txt_desktop.h \ txt_gui.c txt_gui.h \ txt_io.c txt_io.h \ txt_main.c txt_main.h \ diff --git a/textscreen/guitest.c b/textscreen/guitest.c index d65aa67c..7fc19df8 100644 --- a/textscreen/guitest.c +++ b/textscreen/guitest.c @@ -4,6 +4,7 @@ #include "txt_main.h" #include "txt_button.h" +#include "txt_desktop.h" #include "txt_separator.h" #include "txt_window.h" @@ -45,7 +46,7 @@ void Window2(void) txt_window_t *window; int i; - window = TXT_NewWindow("Another test", 30, 7); + window = TXT_NewWindow("Another test", 50, 7); for (i=0; i<5; ++i) { @@ -65,8 +66,7 @@ int main() { firstwin->selected = (firstwin->selected + 1) % firstwin->num_widgets; - TXT_DrawAllWindows(); - + TXT_DrawDesktop(); } } diff --git a/textscreen/txt_desktop.c b/textscreen/txt_desktop.c new file mode 100644 index 00000000..a2ec5c56 --- /dev/null +++ b/textscreen/txt_desktop.c @@ -0,0 +1,133 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// $Id$ +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2006 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// + +#include +#include + +#include "txt_desktop.h" +#include "txt_gui.h" +#include "txt_main.h" +#include "txt_separator.h" +#include "txt_window.h" + +#define MAXWINDOWS 128 + +static char *desktop_title; +static txt_window_t *all_windows[MAXWINDOWS]; +static int num_windows = 0; + +void TXT_AddDesktopWindow(txt_window_t *win) +{ + all_windows[num_windows] = win; + ++num_windows; +} + +void TXT_RemoveDesktopWindow(txt_window_t *win) +{ + int from, to; + + for (from=0, to=0; from #include +#include "txt_desktop.h" #include "txt_gui.h" +#include "txt_main.h" #include "txt_separator.h" #include "txt_window.h" -#define MAXWINDOWS 128 - -static char *desktop_title; -static txt_window_t *all_windows[MAXWINDOWS]; -static int num_windows = 0; - -static void AddWindow(txt_window_t *win) -{ - all_windows[num_windows] = win; - ++num_windows; -} - -static void RemoveWindow(txt_window_t *win) -{ - int from, to; - - for (from=0, to=0; fromnum_widgets = 0; win->selected = 0; - AddWindow(win); + TXT_AddDesktopWindow(win); return win; } @@ -92,7 +66,7 @@ void TXT_CloseWindow(txt_window_t *window) free(window->title); free(window); - RemoveWindow(window); + TXT_RemoveDesktopWindow(window); } static void TXT_WindowSize(txt_window_t *window, int *w, int *h) @@ -115,7 +89,7 @@ static void TXT_WindowSize(txt_window_t *window, int *w, int *h) *h = window->num_widgets; } -static void DrawWindow(txt_window_t *window) +void TXT_DrawWindow(txt_window_t *window) { int widgets_w, widgets_h; int window_w, window_h; @@ -138,7 +112,7 @@ static void DrawWindow(txt_window_t *window) // Draw the window - TXT_DrawWindow(window->title, window_x, window_y, window_w, window_h); + TXT_DrawWindowFrame(window->title, window_x, window_y, window_w, window_h); // Draw all widgets @@ -153,32 +127,6 @@ static void DrawWindow(txt_window_t *window) TXT_DrawSeparator(window_x, window_y + 2 + window->num_widgets, window_w); } -void TXT_SetDesktopTitle(char *title) -{ - free(desktop_title); - desktop_title = strdup(title); -} - -void TXT_DrawAllWindows(void) -{ - int i; - char *title; - - if (desktop_title == NULL) - title = ""; - else - title = desktop_title; - - TXT_DrawDesktop(title); - - for (i=0; i