summaryrefslogtreecommitdiff
path: root/textscreen
diff options
context:
space:
mode:
Diffstat (limited to 'textscreen')
-rw-r--r--textscreen/Makefile.am1
-rw-r--r--textscreen/txt_strut.c55
-rw-r--r--textscreen/txt_strut.h47
3 files changed, 103 insertions, 0 deletions
diff --git a/textscreen/Makefile.am b/textscreen/Makefile.am
index 12a876b0..15eb526c 100644
--- a/textscreen/Makefile.am
+++ b/textscreen/Makefile.am
@@ -18,6 +18,7 @@ libtextscreen_a_SOURCES = \
txt_label.c txt_label.h \
txt_radiobutton.c txt_radiobutton.h \
txt_separator.c txt_separator.h \
+ txt_strut.c txt_strut.h \
txt_table.c txt_table.h \
txt_widget.c txt_widget.h \
txt_window.c txt_window.h \
diff --git a/textscreen/txt_strut.c b/textscreen/txt_strut.c
new file mode 100644
index 00000000..47e80130
--- /dev/null
+++ b/textscreen/txt_strut.c
@@ -0,0 +1,55 @@
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "doomkeys.h"
+
+#include "txt_strut.h"
+#include "txt_io.h"
+#include "txt_main.h"
+#include "txt_window.h"
+
+static void TXT_StrutSizeCalc(TXT_UNCAST_ARG(strut), int *w, int *h)
+{
+ TXT_CAST_ARG(txt_strut_t, strut);
+
+ // Minimum width is the string length + two spaces for padding
+
+ *w = strut->width;
+ *h = 0;
+}
+
+static void TXT_StrutDrawer(TXT_UNCAST_ARG(strut), int w, int selected)
+{
+ // Nothing is drawn for a strut.
+}
+
+static void TXT_StrutDestructor(TXT_UNCAST_ARG(strut))
+{
+}
+
+static int TXT_StrutKeyPress(TXT_UNCAST_ARG(strut), int key)
+{
+}
+
+txt_widget_class_t txt_strut_class =
+{
+ TXT_StrutSizeCalc,
+ TXT_StrutDrawer,
+ TXT_StrutKeyPress,
+ TXT_StrutDestructor,
+};
+
+txt_strut_t *TXT_NewStrut(int width)
+{
+ txt_strut_t *strut;
+
+ strut = malloc(sizeof(txt_strut_t));
+
+ TXT_InitWidget(strut, &txt_strut_class);
+ strut->widget.selectable = 0;
+ strut->width = width;
+
+ return strut;
+}
+
diff --git a/textscreen/txt_strut.h b/textscreen/txt_strut.h
new file mode 100644
index 00000000..5bf7b7e7
--- /dev/null
+++ b/textscreen/txt_strut.h
@@ -0,0 +1,47 @@
+// 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.
+//
+
+#ifndef TXT_STRUT_H
+#define TXT_STRUT_H
+
+typedef struct txt_strut_s txt_strut_t;
+
+#include "txt_widget.h"
+
+//
+// A strut is used to force a table to a minimum width. It is not
+// visible but it takes up space.
+//
+
+struct txt_strut_s
+{
+ txt_widget_t widget;
+ int width;
+};
+
+txt_strut_t *TXT_NewStrut(int width);
+
+#endif /* #ifndef TXT_STRUT_H */
+
+