Odamex
Setting the Standard in Multiplayer Doom
textscreen/txt_widget.h
Go to the documentation of this file.
00001 // Emacs style mode select   -*- C++ -*- 
00002 //-----------------------------------------------------------------------------
00003 //
00004 // Copyright(C) 2006 Simon Howard
00005 //
00006 // This program is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU General Public License
00008 // as published by the Free Software Foundation; either version 2
00009 // of the License, or (at your option) any later version.
00010 //
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00019 // 02111-1307, USA.
00020 //
00021 
00022 #ifndef TXT_WIDGET_H
00023 #define TXT_WIDGET_H
00024 
00031 #ifndef DOXYGEN
00032 
00033 #define TXT_UNCAST_ARG_NAME(name) uncast_ ## name
00034 #define TXT_UNCAST_ARG(name)   void * TXT_UNCAST_ARG_NAME(name)
00035 #define TXT_CAST_ARG(type, name)  type *name = (type *) uncast_ ## name
00036 
00037 #else
00038 
00039 #define TXT_UNCAST_ARG(name) txt_widget_t *name
00040 
00041 #endif
00042 
00043 typedef enum
00044 {
00045     TXT_VERT_TOP,
00046     TXT_VERT_CENTER,
00047     TXT_VERT_BOTTOM,
00048 } txt_vert_align_t;
00049 
00050 typedef enum
00051 {
00052     TXT_HORIZ_LEFT,
00053     TXT_HORIZ_CENTER,
00054     TXT_HORIZ_RIGHT,
00055 } txt_horiz_align_t;
00056 
00068 typedef struct txt_widget_s txt_widget_t;
00069 
00070 typedef struct txt_widget_class_s txt_widget_class_t;
00071 typedef struct txt_callback_table_s txt_callback_table_t;
00072 
00073 typedef void (*TxtWidgetSizeCalc)(TXT_UNCAST_ARG(widget));
00074 typedef void (*TxtWidgetDrawer)(TXT_UNCAST_ARG(widget), int selected);
00075 typedef void (*TxtWidgetDestroy)(TXT_UNCAST_ARG(widget));
00076 typedef int (*TxtWidgetKeyPress)(TXT_UNCAST_ARG(widget), int key);
00077 typedef void (*TxtWidgetSignalFunc)(TXT_UNCAST_ARG(widget), void *user_data);
00078 typedef void (*TxtMousePressFunc)(TXT_UNCAST_ARG(widget), int x, int y, int b);
00079 typedef void (*TxtWidgetLayoutFunc)(TXT_UNCAST_ARG(widget));
00080 
00081 struct txt_widget_class_s
00082 {
00083     TxtWidgetSizeCalc size_calc;
00084     TxtWidgetDrawer drawer;
00085     TxtWidgetKeyPress key_press;
00086     TxtWidgetDestroy destructor;
00087     TxtMousePressFunc mouse_press;
00088     TxtWidgetLayoutFunc layout;
00089 };
00090 
00091 struct txt_widget_s
00092 {
00093     txt_widget_class_t *widget_class;
00094     txt_callback_table_t *callback_table;
00095     int selectable;
00096     int visible;
00097     txt_horiz_align_t align;
00098 
00099     // These are set automatically when the window is drawn and should
00100     // not be set manually.
00101 
00102     int x, y;
00103     unsigned int w, h;
00104 };
00105 
00106 void TXT_InitWidget(TXT_UNCAST_ARG(widget), txt_widget_class_t *widget_class);
00107 void TXT_CalcWidgetSize(TXT_UNCAST_ARG(widget));
00108 void TXT_DrawWidget(TXT_UNCAST_ARG(widget), int selected);
00109 void TXT_EmitSignal(TXT_UNCAST_ARG(widget), const char *signal_name);
00110 int TXT_WidgetKeyPress(TXT_UNCAST_ARG(widget), int key);
00111 void TXT_WidgetMousePress(TXT_UNCAST_ARG(widget), int x, int y, int b);
00112 void TXT_DestroyWidget(TXT_UNCAST_ARG(widget));
00113 void TXT_LayoutWidget(TXT_UNCAST_ARG(widget));
00114 
00124 void TXT_SignalConnect(TXT_UNCAST_ARG(widget), const char *signal_name,
00125                        TxtWidgetSignalFunc func, void *user_data);
00126 
00135 void TXT_SetWidgetAlign(TXT_UNCAST_ARG(widget), txt_horiz_align_t horiz_align);
00136 
00137 #endif /* #ifndef TXT_WIDGET_H */
00138 
00139 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends