File: client\qmenu.h

    1 /*
    2 Copyright (C) 1997-2001 Id Software, Inc.
    3 
    4 This program is free software; you can redistribute it and/or
    5 modify it under the terms of the GNU General Public License
    6 as published by the Free Software Foundation; either version 2
    7 of the License, or (at your option) any later version.
    8 
    9 This program is distributed in the hope that it will be useful,
   10 but WITHOUT ANY WARRANTY; without even the implied warranty of
   11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
   12 
   13 See the GNU General Public License for more details.
   14 
   15 You should have received a copy of the GNU General Public License
   16 along with this program; if not, write to the Free Software
   17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
   18 
   19 */
   20 #ifndef __QMENU_H__
   21 #define __QMENU_H__
   22 
   23 #define MAXMENUITEMS    64
   24 
   25 #define MTYPE_SLIDER            0
   26 #define MTYPE_LIST                      1
   27 #define MTYPE_ACTION            2
   28 #define MTYPE_SPINCONTROL       3
   29 #define MTYPE_SEPARATOR         4
   30 #define MTYPE_FIELD                     5
   31 
   32 #define K_TAB                   9
   33 #define K_ENTER                 13
   34 #define K_ESCAPE                27
   35 #define K_SPACE                 32
   36 
   37 // normal keys should be passed as lowercased ascii
   38 
   39 #define K_BACKSPACE             127
   40 #define K_UPARROW               128
   41 #define K_DOWNARROW             129
   42 #define K_LEFTARROW             130
   43 #define K_RIGHTARROW    131
   44 
   45 #define QMF_LEFT_JUSTIFY        0x00000001
   46 #define QMF_GRAYED                      0x00000002
   47 #define QMF_NUMBERSONLY         0x00000004
   48 
   49 typedef struct _tag_menuframework
   50 {
   51         int x, y;
   52         int     cursor;
   53 
   54         int     nitems;
   55         int nslots;
   56         void *items[64];
   57 
   58         const char *statusbar;
   59 
   60         void (*cursordraw)( struct _tag_menuframework *m );
   61         
   62 } menuframework_s;
   63 
   64 typedef struct
   65 {
   66         int type;
   67         const char *name;
   68         int x, y;
   69         menuframework_s *parent;
   70         int cursor_offset;
   71         int     localdata[4];
   72         unsigned flags;
   73 
   74         const char *statusbar;
   75 
   76         void (*callback)( void *self );
   77         void (*statusbarfunc)( void *self );
   78         void (*ownerdraw)( void *self );
   79         void (*cursordraw)( void *self );
   80 } menucommon_s;
   81 
   82 typedef struct
   83 {
   84         menucommon_s generic;
   85 
   86         char            buffer[80];
   87         int                     cursor;
   88         int                     length;
   89         int                     visible_length;
   90         int                     visible_offset;
   91 } menufield_s;
   92 
   93 typedef struct 
   94 {
   95         menucommon_s generic;
   96 
   97         float minvalue;
   98         float maxvalue;
   99         float curvalue;
  100 
  101         float range;
  102 } menuslider_s;
  103 
  104 typedef struct
  105 {
  106         menucommon_s generic;
  107 
  108         int curvalue;
  109 
  110         const char **itemnames;
  111 } menulist_s;
  112 
  113 typedef struct
  114 {
  115         menucommon_s generic;
  116 } menuaction_s;
  117 
  118 typedef struct
  119 {
  120         menucommon_s generic;
  121 } menuseparator_s;
  122 
  123 qboolean Field_Key( menufield_s *field, int key );
  124 
  125 void    Menu_AddItem( menuframework_s *menu, void *item );
  126 void    Menu_AdjustCursor( menuframework_s *menu, int dir );
  127 void    Menu_Center( menuframework_s *menu );
  128 void    Menu_Draw( menuframework_s *menu );
  129 void    *Menu_ItemAtCursor( menuframework_s *m );
  130 qboolean Menu_SelectItem( menuframework_s *s );
  131 void    Menu_SetStatusBar( menuframework_s *s, const char *string );
  132 void    Menu_SlideItem( menuframework_s *s, int dir );
  133 int             Menu_TallySlots( menuframework_s *menu );
  134 
  135 void     Menu_DrawString( int, int, const char * );
  136 void     Menu_DrawStringDark( int, int, const char * );
  137 void     Menu_DrawStringR2L( int, int, const char * );
  138 void     Menu_DrawStringR2LDark( int, int, const char * );
  139 
  140 #endif
  141