qmenu.h 3.0 KB

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