home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR21 / DOUGM.ZIP / DM168SRC.ZIP / DOUGMENU.H < prev    next >
Text File  |  1992-07-26  |  10KB  |  299 lines

  1. #define byte             unsigned char
  2. #define MAX_LINE         140
  3. #define MAX_FILE_NAME    80
  4. #define MAX_VARS         9     
  5. #define MAX_PALETTES     10
  6. #define MAX_SPECIAL      30
  7. #define PALETTE_SIZE     7
  8. #define MAX_RECURSION    9
  9. #define CENTER           255
  10. #define VAR_NOT_FOUND    (char) 255
  11.  
  12. /***************************************************************************/
  13. typedef enum { NO, YES } boolean;
  14.  
  15. /***************************************************************************/
  16. typedef enum { EXECUTE_BATCH, LEAVE_MENU, EXECUTE_N_LEAVE } exit_actions;
  17.  
  18. /***************************************************************************/
  19. typedef enum { BACK, TEXT, TITLE, BORDER, HIGHLIGHT, S_BACK, SELECT } palette_colors;
  20.  
  21. /***************************************************************************/
  22. typedef enum { MEMORY, FILE_OPEN, SYNTAX, VALUE, POSITION, DISPLAY, 
  23.         ENVIROMENT } error_type;
  24.  
  25. /***************************************************************************/
  26. typedef enum { NO_ACTION, MOVE_UP, MOVE_DOWN, GOTO_TOP, GOTO_BOTTOM, GOTO_ITEM, 
  27.         BACK_SPACE, ESCAPE, KEY_PRESS, OTHER, DO_ITEM, SPECIAL } action_type;
  28.  
  29. /***************************************************************************/
  30. typedef enum { MAKE_BATCH, NEW_WINDOW, MAKE_TEXT_BOX, GET_DISK_SPACE, 
  31.         FIND_FLOPPY, ASK_FOR_VAR, PASSWORD, LOGOUT, EXIT, REBOOT,
  32.         IF, IF_USERNAME, IF_MEMBER, ELSE, ENDIF }
  33.         execute_option;
  34.  
  35. /***************************************************************************/
  36. struct linked_text
  37. {
  38.     struct linked_text *next_line;
  39.     char   text_line[1];
  40. };
  41.  
  42. typedef struct linked_text Linked_Text;
  43.  
  44. /***************************************************************************/
  45. struct linked_text_block
  46. {
  47.     Linked_Text              *first_line;
  48.     struct linked_text_block *next_block;
  49.     byte                     x1,y1,pal;
  50. };
  51.  
  52. typedef struct linked_text_block Linked_Text_Block;
  53.  
  54. /***************************************************************************/
  55. struct item
  56. {
  57.     byte             title_length, item_number;
  58.     struct item      *next_item,*last_item;
  59.     struct linked_text *first_line;
  60.     char             title[1];
  61. };
  62.  
  63. typedef struct item Item;
  64.  
  65. /***************************************************************************/
  66. struct menu
  67. {
  68.     byte             offset_x, offset_y, palette, number_of_items, 
  69.                      title_length;
  70.     struct menu      *next_menu;
  71.     struct item      *first_item;
  72.     char             title[1];
  73. };
  74.  
  75. typedef struct menu Menu;
  76.  
  77. /***************************************************************************/
  78. struct window_record
  79. {
  80.     Menu            *menu;
  81.     Item            *item;
  82.     int             *storage;
  83.     byte            left, right, width, top, bottom, height;
  84.     action_type     event;
  85. };
  86.  
  87. typedef struct window_record Window_Record;
  88.  
  89. /***************************************************************************/
  90. struct event
  91. {
  92.     action_type   action;
  93.     byte          data;
  94. };
  95.  
  96. typedef struct event Event;
  97.  
  98. /***************************************************************************/
  99. struct vars
  100. {
  101.     char   *name, *value;
  102. };
  103.  
  104. typedef struct vars Vars;
  105.  
  106. /***************************************************************************/
  107.                   /* palettes */
  108. /*BACKground, TEXT, TITLE, BORDER, HIGHLIGHT, Selection BACKground, SELECTion*/
  109.  
  110. byte palette[ MAX_PALETTES ][ PALETTE_SIZE ] = {
  111.             {1,15,15,15,14,7,1},{3,1,1,1,1,0,15},
  112.             {4,14,14,14,14,7,15},{7,5,1,15,15,5,15},
  113.             {0,3,3,8,7,7,0},{0,12,13,1,9,7,15},
  114.             {0,11,15,8,7,2,15},{2,0,15,10,14,0,10},
  115.             {0,7,15,7,15,7,0},{7,0,0,0,0,0,7}   };
  116.  
  117. /***************************************************************************/
  118.                 /*Global Variables */
  119.  
  120. /* global menu defaults */
  121. byte             default_x = CENTER, default_y = CENTER, default_palette, 
  122.                  header_palette, error_palette, message_palette,
  123.                  backdrop_color, footer_color, footer_highlight, 
  124.                  backdrop_char = '░', cascade_x = 4, cascade_y = 1;
  125.         
  126. boolean          exitable = YES, shadow = NO, draw_shadow = NO, cascade = NO;
  127.  
  128. /* global pointers */
  129. Menu            *first_menu, *current_menu;
  130. Item            *current_item;
  131. Linked_Text     *current_text;
  132. Linked_Text_Block *first_text_block, *current_text_block;
  133. char            *current_file;
  134. int far         *video_start;
  135. char far        *env_start;
  136.  
  137. /* working records */
  138. Window_Record   Win[MAX_RECURSION+2];
  139. Event           event;
  140. byte            win_index;
  141.  
  142. Vars             vars[MAX_VARS];
  143. byte             var_number = 0;
  144.  
  145. /* working window */
  146. byte            top, bottom, left, right, height, width;
  147.  
  148. /* file names */
  149. char            *backdrop_file = NULL;
  150.  
  151. /* special items & their helpers*/
  152. Item            *special_item[MAX_SPECIAL];
  153.        /*  list of special items :        0       timer
  154.                                         1 -10   function keys
  155.                                         11-30   hot keys       */
  156.  
  157.                 /* timer stuff */
  158. byte            current_minute = 61,
  159.                 timer = 0, timer_holder = 0;
  160. unsigned int    clock_place;
  161.  
  162.                 /*hot key stuff */
  163. byte            hot_keys = 11;
  164.  
  165. /* video varibles */
  166. boolean         color_monitor;
  167. byte            max_screen_x, max_screen_y;
  168.  
  169. /* mouse variables */
  170. byte            last_button, last_x, last_y, selected_fn;
  171.  
  172. /* shadow stuff */
  173. byte            shadow_color, *shad_buf;
  174.  
  175. /* other variables */
  176. byte            l_len;
  177. unsigned int    line_count;
  178. boolean         show_time = YES;
  179. boolean         first_run = YES;
  180. boolean         do_return = YES;
  181. boolean         quick_select = NO;
  182. boolean         allow_comments = YES;
  183. char            *screen_saver_message = NULL;
  184. char            *header_message = NULL;
  185. byte            video_mode;
  186. byte            cursor_top;
  187. byte            cursor_bottom;
  188.  
  189. /***************************************************************************/
  190. /* procedure definitions */
  191.  
  192.     /* parse.c */
  193. Menu        *Allocate_Menu( void );
  194. Item        *Allocate_Item( void );
  195. Linked_Text *Allocate_Linked_Text( void );
  196. void        Read_Line(char *t_line, FILE *Script );
  197. boolean     Compare(char *string1, char *string2);
  198. char        *After_Space(char *place);
  199. char        *After_Equals(char *place);
  200. char        *After_Comma(char *place);
  201. byte        Get_Palette(char *place, byte def_value);
  202. byte        Get_Color(char *place,byte def_value);
  203. byte        Get_Value(char *place, byte def_value);
  204. void        Do_If( char *place, FILE *Script );
  205. void        Do_If_Username( char *place, FILE *Script );
  206. void        Do_If_Member( char *place, FILE *Script );
  207. void        Do_Else( char *place, FILE *Script );
  208. void        Parse_Command(char *place,FILE *Script);
  209. void        Parse_Menu(char t_line[]);
  210. void        Parse_Item(char t_line[]);
  211. void        Parse_Item_Text(char t_line[]);
  212. void        Parse_Engine( void );
  213. void        Parse( char dos_param_2[] );
  214. void        Include( char *place );
  215.  
  216.     /* draw.c */
  217. void _fastcall Draw(byte x,byte y,char thing,byte color);
  218. byte _fastcall Read_Color(byte x, byte y);
  219. void _fastcall Put_Color(byte x,byte y,byte color);
  220. void _fastcall Fill_Screen(char thing,byte color);
  221. void _fastcall Put_Cursor(byte col,byte row);
  222. void        Hide_Cursor( void );
  223. void        Show_Cursor( void );
  224. void        Hide_Mouse( void );
  225. void        Show_Mouse( void );
  226. void        Clean_Up( void );
  227. void        Screen_Saver( void );
  228. int         *Store_Screen( void );
  229. void        Restore_Screen(int *storage_addr );
  230. void        Display_Menu(Item *hi_item);
  231. void        Select(Item *new_item);
  232. void        Display_Text_Box(char *lines[],byte x1,byte y1, byte pal);
  233. void        Display_Shadow( void );
  234. void        Remove_Shadow( void );
  235. void        Draw_Backdrop( void );
  236. void        Draw_Header( void );
  237. void        Draw_Footer( void );
  238. void        Draw_Back_Boxes( void );
  239.  
  240.     /* input.c */
  241. void        Update_Time( void );
  242. void        Select_Fn( byte x );
  243. void        Unselect_Fn( void );
  244. byte        Old_Window(byte x,byte y);
  245. void        Update_Mouse( void );
  246. void        Scan_For_Letter(char key_input );
  247. void        Get_Key_Input( void );
  248. void        Wait_For_Event( void );
  249. void        Pause_Until_Serious_Action( void );
  250.  
  251.     /* dougmenu.c */
  252. boolean     Windowfy_Menu(Menu *menu);
  253. Item        *Number_To_Item(byte number);
  254. Item        *Home_Item( void );
  255. Item        *End_Item( void );
  256. Item        *Previous_Item( void );
  257. Item        *Next_Item( void );
  258. void        Last_Window_Globals( void );
  259. void        Remove_Window( void );
  260. Menu        *Find_Menu( Linked_Text *title_text );
  261. void        main( int argc, char *argv[] );
  262.  
  263.     /* execute.c */
  264. byte        Do_Query_Window( Menu *query );
  265. void        Exit_Query( void );
  266. void        Choice_Query(char *place, char temp[] );
  267. void        String_Query(char *place, char string[], boolean show_it );
  268. void        Create_Text_Box( char *place );
  269. void        Get_Disk_Space( char *place );
  270. void        Find_Floppy( char *place );
  271. void        Ask_For_Pass( char *place );
  272. void        Logout( void );
  273. void        Reboot( void );
  274. void        Execute_Item( void );
  275. execute_option What_To_Do( char *temp);
  276. void        Make_Batch( void );
  277. void        Exec_If( char *place );
  278. void        Exec_If_Username( char *place );
  279. void        Exec_If_Member( char *place );
  280. void        Exec_Else( char *place );
  281.  
  282.  
  283.  
  284.     /* misc.c */
  285. void        Break_Off( void );
  286. long int    Disk_Space_Check( byte drive );
  287. void        Monochrome_Defaults( void );
  288. void        Get_Video_Info( char *parameter );
  289. void        Set_Up_Enviroment( void );
  290. void        Set_Up_Mouse( void );
  291. void        Set_Up_Screen( void );
  292. void        Find_Env_Var( char *var, char *string, byte space);
  293. boolean     Fcompare( char *string1,char far *string2 );
  294. void        Ask_For_Var( char *place );
  295. void        Transcribe_String(char *old,char *new);
  296. boolean     Get_DM_Var( char *place, char *temp, byte space);
  297. void        Critical_Error(error_type error);
  298. void        Error_Box(char line1[],char line2[]);
  299.