UI.H 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/ui/rcs/ui.h $
  15. * $Revision: 1.11 $
  16. * $Author: john $
  17. * $Date: 1994/11/18 23:07:33 $
  18. *
  19. * Header file for user interface
  20. *
  21. * $Log: ui.h $
  22. * Revision 1.11 1994/11/18 23:07:33 john
  23. * Changed a bunch of shorts to ints.
  24. *
  25. * Revision 1.10 1994/05/14 17:44:36 matt
  26. * Added extern.
  27. *
  28. * Revision 1.9 1994/05/14 17:20:33 matt
  29. * Added externs
  30. *
  31. * Revision 1.8 1994/02/01 13:29:56 john
  32. * *** empty log message ***
  33. *
  34. * Revision 1.7 1994/01/10 16:25:03 john
  35. * Fixed bug in 800x600 mode with restoring
  36. * bogus font.
  37. *
  38. * Revision 1.6 1993/12/10 14:22:30 john
  39. * Made buttons have up to 2 keys/functions.
  40. *
  41. * Revision 1.5 1993/12/07 12:30:11 john
  42. * new version.
  43. *
  44. * Revision 1.4 1993/10/26 13:46:15 john
  45. * *** empty log message ***
  46. *
  47. * Revision 1.3 1993/10/07 11:23:30 john
  48. * *** empty log message ***
  49. *
  50. * Revision 1.2 1993/10/05 17:31:15 john
  51. * *** empty log message ***
  52. *
  53. * Revision 1.1 1993/09/20 10:36:36 john
  54. * Initial revision
  55. *
  56. *
  57. */
  58. #ifndef _UI_H
  59. #define _UI_H
  60. typedef struct {
  61. char description[100];
  62. char * buttontext[17];
  63. int numkeys;
  64. short keycode[100];
  65. int function_number[100];
  66. } UI_KEYPAD;
  67. typedef struct
  68. {
  69. unsigned int frame;
  70. int type;
  71. int data;
  72. } UI_EVENT;
  73. #define BASE_GADGET \
  74. short kind; \
  75. struct _gadget * prev; \
  76. struct _gadget * next; \
  77. struct _gadget * when_tab; \
  78. struct _gadget * when_btab; \
  79. struct _gadget * when_up; \
  80. struct _gadget * when_down; \
  81. struct _gadget * when_left; \
  82. struct _gadget * when_right; \
  83. struct _gadget * parent; \
  84. int status; \
  85. int oldstatus; \
  86. grs_canvas * canvas; \
  87. int hotkey; \
  88. short x1,y1,x2,y2;
  89. typedef struct _gadget {
  90. BASE_GADGET
  91. unsigned char rsvd[256];
  92. } UI_GADGET;
  93. typedef struct {
  94. BASE_GADGET
  95. int trap_key;
  96. int (*user_function)(void);
  97. } UI_GADGET_KEYTRAP;
  98. typedef struct {
  99. BASE_GADGET
  100. short width, height;
  101. short b1_held_down;
  102. short b1_clicked;
  103. short b1_double_clicked;
  104. short b1_dragging;
  105. short b1_drag_x1, b1_drag_y1;
  106. short b1_drag_x2, b1_drag_y2;
  107. short b1_done_dragging;
  108. int keypress;
  109. short mouse_onme;
  110. short mouse_x, mouse_y;
  111. grs_bitmap * bitmap;
  112. } UI_GADGET_USERBOX;
  113. typedef struct {
  114. BASE_GADGET
  115. short width, height;
  116. char * text;
  117. short position;
  118. short oldposition;
  119. short pressed;
  120. int (*user_function)(void);
  121. int (*user_function1)(void);
  122. int hotkey1;
  123. int dim_if_no_function;
  124. } UI_GADGET_BUTTON;
  125. typedef struct {
  126. BASE_GADGET
  127. short width, height;
  128. char * text;
  129. short length;
  130. short slength;
  131. short position;
  132. short oldposition;
  133. short pressed;
  134. short first_time;
  135. } UI_GADGET_INPUTBOX;
  136. typedef struct {
  137. BASE_GADGET
  138. short width, height;
  139. char * text;
  140. short position;
  141. short oldposition;
  142. short pressed;
  143. short group;
  144. short flag;
  145. } UI_GADGET_RADIO;
  146. typedef struct {
  147. BASE_GADGET
  148. char *text;
  149. short width, height;
  150. byte flag;
  151. byte pressed;
  152. byte position;
  153. byte oldposition;
  154. int trap_key;
  155. int (*user_function)(void);
  156. } UI_GADGET_ICON;
  157. typedef struct {
  158. BASE_GADGET
  159. short width, height;
  160. char * text;
  161. short position;
  162. short oldposition;
  163. short pressed;
  164. short group;
  165. short flag;
  166. } UI_GADGET_CHECKBOX;
  167. typedef struct {
  168. BASE_GADGET
  169. short horz;
  170. short width, height;
  171. int start;
  172. int stop;
  173. int position;
  174. int window_size;
  175. int fake_length;
  176. int fake_position;
  177. int fake_size;
  178. UI_GADGET_BUTTON * up_button;
  179. UI_GADGET_BUTTON * down_button;
  180. unsigned int last_scrolled;
  181. short drag_x, drag_y;
  182. int drag_starting;
  183. int dragging;
  184. int moved;
  185. } UI_GADGET_SCROLLBAR;
  186. typedef struct {
  187. BASE_GADGET
  188. short width, height;
  189. char * list;
  190. int text_width;
  191. int num_items;
  192. int num_items_displayed;
  193. int first_item;
  194. int old_first_item;
  195. int current_item;
  196. int selected_item;
  197. int old_current_item;
  198. unsigned int last_scrolled;
  199. int dragging;
  200. int textheight;
  201. UI_GADGET_SCROLLBAR * scrollbar;
  202. int moved;
  203. } UI_GADGET_LISTBOX;
  204. typedef struct _ui_window {
  205. short x, y;
  206. short width, height;
  207. short text_x, text_y;
  208. grs_canvas * canvas;
  209. grs_canvas * oldcanvas;
  210. grs_bitmap * background;
  211. UI_GADGET * gadget;
  212. UI_GADGET * keyboard_focus_gadget;
  213. struct _ui_window * next;
  214. struct _ui_window * prev;
  215. } UI_WINDOW;
  216. typedef struct {
  217. short new_dx, new_dy;
  218. short new_buttons;
  219. short x, y;
  220. short dx, dy;
  221. short hidden;
  222. short backwards;
  223. short b1_status;
  224. short b1_last_status;
  225. short b2_status;
  226. short b2_last_status;
  227. short b3_status;
  228. short b3_last_status;
  229. short bg_x, bg_y;
  230. short bg_saved;
  231. grs_bitmap * background;
  232. grs_bitmap * pointer;
  233. unsigned int time_lastpressed;
  234. short moved;
  235. } UI_MOUSE;
  236. #define BUTTON_PRESSED 1
  237. #define BUTTON_RELEASED 2
  238. #define BUTTON_JUST_PRESSED 4
  239. #define BUTTON_JUST_RELEASED 8
  240. #define BUTTON_DOUBLE_CLICKED 16
  241. #define B1_PRESSED (Mouse.b1_status & BUTTON_PRESSED)
  242. #define B1_RELEASED (Mouse.b1_status & BUTTON_RELEASED)
  243. #define B1_JUST_PRESSED (Mouse.b1_status & BUTTON_JUST_PRESSED)
  244. #define B1_JUST_RELEASED (Mouse.b1_status & BUTTON_JUST_RELEASED)
  245. #define B1_DOUBLE_CLICKED (Mouse.b1_status & BUTTON_DOUBLE_CLICKED)
  246. extern grs_font * ui_small_font;
  247. extern UI_MOUSE Mouse;
  248. extern UI_WINDOW * CurWindow;
  249. extern UI_WINDOW * FirstWindow;
  250. extern UI_WINDOW * LastWindow;
  251. extern unsigned char CBLACK,CGREY,CWHITE,CBRIGHT,CRED;
  252. extern UI_GADGET * selected_gadget;
  253. extern int last_keypress;
  254. extern void Hline(short x1, short x2, short y );
  255. extern void Vline(short y1, short y2, short x );
  256. extern void ui_string_centered( short x, short y, char * s );
  257. extern void ui_draw_box_out( short x1, short y1, short x2, short y2 );
  258. extern void ui_draw_box_in( short x1, short y1, short x2, short y2 );
  259. extern void ui_draw_line_in( short x1, short y1, short x2, short y2 );
  260. void ui_init();
  261. void ui_close();
  262. int MessageBox( short x, short y, int NumButtons, char * text, ... );
  263. void ui_string_centered( short x, short y, char * s );
  264. int PopupMenu( int NumItems, char * text[] );
  265. extern void ui_mouse_init();
  266. extern grs_bitmap * ui_mouse_set_pointer( grs_bitmap * new );
  267. extern void ui_mouse_process();
  268. extern void ui_mouse_hide();
  269. extern void ui_mouse_show();
  270. #define WIN_BORDER 1
  271. #define WIN_FILLED 2
  272. #define WIN_SAVE_BG 4
  273. #define WIN_DIALOG (4+2+1)
  274. extern UI_WINDOW * ui_open_window( short x, short y, short w, short h, int flags );
  275. extern void ui_close_window( UI_WINDOW * wnd );
  276. extern UI_GADGET * ui_gadget_add( UI_WINDOW * wnd, short kind, short x1, short y1, short x2, short y2 );
  277. extern UI_GADGET_BUTTON * ui_add_gadget_button( UI_WINDOW * wnd, short x, short y, short w, short h, char * text, int (*function_to_call)(void) );
  278. extern void ui_gadget_delete_all( UI_WINDOW * wnd );
  279. extern void ui_window_do_gadgets( UI_WINDOW * wnd );
  280. extern void ui_draw_button( UI_GADGET_BUTTON * button );
  281. extern int ui_mouse_on_gadget( UI_GADGET * gadget );
  282. extern void ui_button_do( UI_GADGET_BUTTON * button, int keypress );
  283. extern void ui_listbox_do( UI_GADGET_LISTBOX * listbox, int keypress );
  284. extern void ui_draw_listbox( UI_GADGET_LISTBOX * listbox );
  285. extern UI_GADGET_LISTBOX * ui_add_gadget_listbox( UI_WINDOW * wnd, short x, short y, short w, short h, short numitems, char * list, int text_width );
  286. extern void ui_mega_process();
  287. extern void ui_get_button_size( char * text, int * width, int * height );
  288. extern UI_GADGET_SCROLLBAR * ui_add_gadget_scrollbar( UI_WINDOW * wnd, short x, short y, short w, short h, int start, int stop, int position, int window_size );
  289. extern void ui_scrollbar_do( UI_GADGET_SCROLLBAR * scrollbar, int keypress );
  290. extern void ui_draw_scrollbar( UI_GADGET_SCROLLBAR * scrollbar );
  291. extern void ui_wprintf( UI_WINDOW * wnd, char * format, ... );
  292. extern void ui_wprintf_at( UI_WINDOW * wnd, short x, short y, char * format, ... );
  293. extern void ui_draw_radio( UI_GADGET_RADIO * radio );
  294. extern UI_GADGET_RADIO * ui_add_gadget_radio( UI_WINDOW * wnd, short x, short y, short w, short h, short group, char * text );
  295. extern void ui_radio_do( UI_GADGET_RADIO * radio, int keypress );
  296. extern void ui_draw_checkbox( UI_GADGET_CHECKBOX * checkbox );
  297. extern UI_GADGET_CHECKBOX * ui_add_gadget_checkbox( UI_WINDOW * wnd, short x, short y, short w, short h, short group, char * text );
  298. extern void ui_checkbox_do( UI_GADGET_CHECKBOX * checkbox, int keypress );
  299. extern UI_GADGET * ui_gadget_get_prev( UI_GADGET * gadget );
  300. extern UI_GADGET * ui_gadget_get_next( UI_GADGET * gadget );
  301. extern void ui_gadget_calc_keys( UI_WINDOW * wnd);
  302. extern void ui_listbox_change( UI_WINDOW * wnd, UI_GADGET_LISTBOX * listbox, short numitems, char * list, int text_width );
  303. extern void ui_draw_inputbox( UI_GADGET_INPUTBOX * inputbox );
  304. extern UI_GADGET_INPUTBOX * ui_add_gadget_inputbox( UI_WINDOW * wnd, short x, short y, short w, short h, char * text );
  305. extern void ui_inputbox_do( UI_GADGET_INPUTBOX * inputbox, int keypress );
  306. extern void ui_userbox_do( UI_GADGET_USERBOX * userbox, int keypress );
  307. extern UI_GADGET_USERBOX * ui_add_gadget_userbox( UI_WINDOW * wnd, short x, short y, short w, short h );
  308. extern void ui_draw_userbox( UI_GADGET_USERBOX * userbox );
  309. extern int MenuX( int x, int y, int NumButtons, char * text[] );
  310. // Changes to a drive if valid.. 1=A, 2=B, etc
  311. // If flag, then changes to it.
  312. // Returns 0 if not-valid, 1 if valid.
  313. int file_chdrive( int DriveNum, int flag );
  314. // Changes to directory in dir. Even drive is changed.
  315. // Returns 1 if failed.
  316. // 0 = Changed ok.
  317. // 1 = Invalid disk drive.
  318. // 2 = Invalid directory.
  319. int file_chdir( char * dir );
  320. int file_getdirlist( int MaxNum, char list[][13] );
  321. int file_getfilelist( int MaxNum, char list[][13], char * filespec );
  322. int ui_get_filename( char * filename, char * Filespec, char * message );
  323. void * ui_malloc( int size );
  324. void ui_free( void * buffer );
  325. UI_GADGET_KEYTRAP * ui_add_gadget_keytrap( UI_WINDOW * wnd, int key_to_trap, int (*function_to_call)(void) );
  326. void ui_keytrap_do( UI_GADGET_KEYTRAP * keytrap, int keypress );
  327. void ui_mouse_close();
  328. #define UI_RECORD_MOUSE 1
  329. #define UI_RECORD_KEYS 2
  330. #define UI_STATUS_NORMAL 0
  331. #define UI_STATUS_RECORDING 1
  332. #define UI_STATUS_PLAYING 2
  333. #define UI_STATUS_FASTPLAY 3
  334. int ui_record_events( int NumberOfEvents, UI_EVENT * buffer, int Flags );
  335. int ui_play_events_realtime( int NumberOfEvents, UI_EVENT * buffer );
  336. int ui_play_events_fast( int NumberOfEvents, UI_EVENT * buffer );
  337. int ui_recorder_status();
  338. void ui_set_playback_speed( int speed );
  339. extern unsigned int ui_number_of_events;
  340. extern unsigned int ui_event_counter;
  341. int ui_get_file( char * filename, char * Filespec );
  342. int MessageBoxN( short xc, short yc, int NumButtons, char * text, char * Button[] );
  343. void ui_draw_icon( UI_GADGET_ICON * icon );
  344. void ui_icon_do( UI_GADGET_ICON * icon, int keypress );
  345. UI_GADGET_ICON * ui_add_gadget_icon( UI_WINDOW * wnd, char * text, short x, short y, short w, short h, int k,int (*f)(void) );
  346. int GetKeyCode(char * text);
  347. int DecodeKeyText( char * text );
  348. void GetKeyDescription( char * text, int keypress );
  349. extern void menubar_init(char * filename );
  350. extern void menubar_do( int keypress );
  351. extern void menubar_close();
  352. extern void menubar_hide();
  353. extern void menubar_show();
  354. void ui_pad_init();
  355. void ui_pad_close();
  356. void ui_pad_activate( UI_WINDOW * wnd, int x, int y );
  357. void ui_pad_deactivate();
  358. void ui_pad_goto(int n);
  359. void ui_pad_goto_next();
  360. void ui_pad_goto_prev();
  361. void ui_pad_read( int n, char * filename );
  362. int ui_pad_get_current();
  363. void ui_barbox_open( char * text, int length );
  364. int ui_barbox_update( int position );
  365. void ui_barbox_close();
  366. void ui_reset_idle_seconds(void);
  367. int ui_get_idle_seconds(void);
  368. extern char filename_list[300][13];
  369. extern char directory_list[100][13];
  370. extern int ui_button_any_drawn;
  371. #endif
  372.