window.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* $Id$
  2. * MegaZeux
  3. *
  4. * Copyright (C) 1996 Greg Janson
  5. * Copyright (C) 1998 Matthew D. Williams - dbwilli@scsn.net
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. /* WINDOW.H- Declarations for WINDOW.CPP */
  22. #ifndef __WINDOW_H
  23. #define __WINDOW_H
  24. //Error message for being out of window memory for list_menu, etc functions
  25. #define OUT_OF_WIN_MEM -32766
  26. //All screen-affecting code preserves the mouse cursor
  27. char window_cpp_entry(void);
  28. void window_cpp_exit(void);
  29. char save_screen(unsigned int segment);
  30. char restore_screen(unsigned int segment);
  31. char draw_window_box(int x1,int y1,int x2,int y2,unsigned int segment,
  32. unsigned char color,unsigned char dark_color,unsigned char corner_color,
  33. char shadow=1,char fill_center=1);
  34. int list_menu(char far *choices,char choice_size,char far *title,int
  35. current,int num_choices,unsigned int segment,char xpos=31);
  36. int char_selection(unsigned char current,unsigned int segment);
  37. int color_selection(int current,unsigned int segment,char allow_wild=0);
  38. void draw_color_box(unsigned char color,char q_bit,char x,char y,
  39. unsigned int segment);
  40. //Shell for list_menu() (returns -1 for ESC)
  41. int choose_board(int current,char far *title,unsigned int segment,
  42. char board0_none=0);
  43. //Shell for run_dialog() (returns 0 for ok, 1 for cancel, -1 for ESC)
  44. char confirm(char far *str);
  45. char ask_yes_no(char far *str);
  46. //Shell for list_menu() (copies file chosen to ret and returns -1 for ESC)
  47. //dirs_okay of 1 means drive and directory changing is allowed. Returns
  48. //zero on proper selection.
  49. char choose_file(char far *wildcards,char far *ret,char far *title,
  50. char dirs_okay=0);
  51. /* Dialog box structure definition */
  52. struct dialog {
  53. int x1,y1,x2,y2;//Location. Always has a shadow and colors are preset.
  54. char far *title;//Not alloc'd- points to memory. (most titles are static)
  55. char num_elements;//Number of elements
  56. char far *element_types;//(not alloc'd) Points to array of types for
  57. //the elements. Element types #define'd below
  58. char far *element_xs;//(not alloc'd) Points to array of x locations
  59. //(as offsets from top left corner)
  60. char far *element_ys;//(not alloc'd) Points to array of y locations
  61. //(as offsets from top left corner)
  62. char far **element_strs;//(not alloc'd) Points to array of str pointers
  63. //for element names/text.
  64. int far *element_param1s;//(not alloc'd) Points to array of parameters
  65. int far *element_param2s;//(not alloc'd) Points to array of parameters
  66. void far **element_storage;//(not alloc'd) Points to array of void
  67. //pointers, each pointing to where in memory
  68. //the answer of each element is.
  69. char curr_element;//The currently selected element
  70. };
  71. typedef struct dialog dialog;
  72. //Element typ #define's (DE=Dialog Element)
  73. #define DE_TEXT 0
  74. #define DE_BOX 1
  75. #define DE_LINE 2
  76. #define DE_INPUT 3
  77. #define DE_CHECK 4
  78. #define DE_RADIO 5
  79. #define DE_COLOR 6
  80. #define DE_CHAR 7
  81. #define DE_BUTTON 8
  82. #define DE_NUMBER 9
  83. #define DE_LIST 10
  84. #define DE_BOARD 11
  85. #define DE_FIVE 12
  86. //DE_TEXT- String is the text. Storage- None. Uses color_string.
  87. //DE_BOX- Param 1 is width, param 2 is height. Storage- None.
  88. //DE_LINE- Param 1 is length, param 2 is 0 for horiz, 1 for vert. Storage-
  89. // None.
  90. //DE_INPUT- String is the question, param 1 is the max length, param 2 is
  91. // the type of input. Storage- char far * for a string. Input
  92. // type byte- See INTAKE.H or INTAKE.CPP.
  93. //DE_CHECK- String is a string containing the multiple lines of check box
  94. // identifiers, seperated by returns. Param 1 is the number of
  95. // check boxes, param 2 is the length of the longest identifier.
  96. // Storage- char far * for an array of yes/no bytes.
  97. //DE_RADIO- String is a string containing the multiple lines of radio options,
  98. // seperated by returns. Param 1 is the number of options, param 2
  99. // is the length of the longest option. Storage- char far * for a
  100. // numerical answer. int far * is also okay, it will just use the
  101. // lowest byte.
  102. //DE_COLOR- String is the question, param 1 is 0 normally, 1 if ?? colors are
  103. // allowed. Storage- int far * for a numerical answer.
  104. //DE_CHAR- String is the question. Storage- unsigned char far * for a byte
  105. // answer. If param 1 is 1 then char 255 is allowed, otherwise it
  106. // is not. Char 0 is NEVER allowed. Both are set to 1 if selected.
  107. //DE_BUTTON- String is the button label, param 1 is the return code sent back
  108. // for pressing this button. Storage- None.
  109. //DE_NUMBER- String is the question, param 1 is the lower limit, param 2 is
  110. // the upper limit. If the lower limit is 1 and the upper
  111. // limit is 9 or less, the number is shown as a highlighted number
  112. // on a line of dark numbers- 1234567. (4 being highlighted)
  113. // Storage- int far * for a numerical answer. (signed numbers are
  114. // allowed) Behavior undefined if param 1 >= param 2.
  115. //DE_LIST- Param 1 is the number of list choices, param 2 is the length in
  116. // memory of each choice (IE 25 is 24 chars plus a null, with junk
  117. // padding for those < 24 chars) String points to the sequential
  118. // list. The first element is the question to place ABOVE the list.
  119. // Storage- int far * for a numerical answer. The x/y location is
  120. // the location of the QUESTION. The list answer is one below.
  121. // The list/elements are drawn w/color_string.
  122. //DE_BOARD- String is the question. Storage- int far * for a numerical answer.
  123. // See DE_LIST for details. Board 0 is shown as "(none)" IF AND
  124. // ONLY IF param 1 is non-zero.
  125. //DE_FIVE- String is the question, param 1 is the lower limit/5, param 2 is
  126. // the upper limit/5. This is like DE_NUMBER but the number shown is
  127. // multiplied by 5 before showing. Storage- int far * for the
  128. // answer/5.
  129. //Dialog box color #define's-
  130. #define DI_MAIN 31
  131. #define DI_DARK 16
  132. #define DI_CORNER 25
  133. #define DI_TITLE 31
  134. #define DI_LINE 16
  135. #define DI_TEXT 27
  136. #define DI_NONACTIVE 25
  137. #define DI_ACTIVE 31
  138. #define DI_INPUT 159
  139. #define DI_CHAR 159
  140. #define DI_NUMERIC 159
  141. #define DI_LIST 159
  142. #define DI_BUTTON 176
  143. #define DI_ACTIVEBUTTON 252
  144. #define DI_ARROWBUTTON 249
  145. #define DI_METER 159
  146. #define DI_PCARROW 30
  147. #define DI_PCFILLER 25
  148. #define DI_PCDOT 144
  149. //Code to run a dialog box. Returns button code pressed, or -1 for ESC.
  150. //If reset_curr=1, the current element will be set to the top. Otherwise,
  151. //the current element from within the di structure will be used.
  152. //If sfx_alt_t is 1, ALT+T will PLAY_SFX any DE_INPUT.
  153. //If sfx_alt_t is >1, END jumps to location 0, and HOME to location
  154. // SFX_ALT_T.
  155. int run_dialog(dialog far *di,unsigned int segment,char reset_curr=1,
  156. char sfx_alt_t=0);
  157. //Characters for dialog box elements
  158. extern char check_on[4];
  159. extern char check_off[4];
  160. extern char radio_on[4];
  161. extern char radio_off[4];
  162. extern unsigned char color_blank;
  163. extern unsigned char color_wild;
  164. extern unsigned char color_dot;
  165. extern char list_button[4];
  166. extern char num_buttons[7];
  167. //Foreground colors that look nice for each background color
  168. extern char fg_per_bk[16];
  169. #endif