home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / programs / emulaton / at2600 / !v2600 / h / HawkLib < prev    next >
Text File  |  1998-07-28  |  9KB  |  257 lines

  1. #ifndef hawklib_defined
  2. #define hawklib_defined
  3.  
  4. /* HawkLib V6.00 - Wimplib in C */
  5. /* Copyright Hawk Software 1997 */
  6.  
  7. /* Purpose: Make wimp programming a doddle. */
  8.  
  9. /* Version: 0.01 */
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include "swis.h"
  14. #include "strings.h"
  15.  
  16. typedef struct Slider {
  17.   int      x_offset;              /* offset from work area x origin \  offset of BOTTOM LEFT of slider */
  18.   int      y_offset;              /* offset from work area x origin /                                  */
  19.   int      width;                 /* number of OS units it extends to the right of the screen          */
  20.   int      height;                /* number of OS units it extends to the top of the screen            */
  21.   int      max_value;             /* max. value of slider                                              */
  22.   int      min_value;             /* minimum value                                                     */
  23.   int      centre_value;          /* value to start drawing bar from (if different from min_value or   */
  24.                                   /* max_value then a black line is drawn at the start of the slider   */
  25.                                   /* depending on bit 2 of slider flags)                               */
  26.   int      value;                 /* current value of slider                                           */
  27.   int      fg_colour;             /* slider foreground colour from wimp palette.                       */
  28.   int      bg_colour;             /* slider backround colour from wimp palette                         */
  29.   int      flags;                 /* slider flags: bit 0 set slider may not be dragged                 */
  30.                                   /*                   1 set = slider is vertical, not horizontal      */
  31.                                   /*                   2 set = draw line (black) on centreline         */
  32.   int      (*slider_function)();  /* Routine to call on slider update                                  */
  33.   struct   Slider *next_slider;   /* pointer to next slider, if present, or NULL if not.               */
  34. } Slider;
  35.  
  36. typedef struct Window {
  37.   int      handle;                /* window handle                                                     */
  38.   int      *workspace;            /* window workspace so destroy_window can free it                    */
  39.   int      (*redraw_function)();  /* function to be called for this window during the redraw loop      */
  40.   int      (*click_function)();   /* function to be called for this window on a mouse clicked event    */
  41.   struct   Slider *slider;        /* pointer to Slider structure                                       */
  42.   int      win_status;            /* 1 = open : 0 = closed                                             */
  43.   struct   Pane *pane;            /* pointer to (next in a) linked list of pane structs.               */
  44. } Window;
  45.  
  46. typedef struct Pane {
  47.   struct   Window *window;        /* pointer to Window which makes up this pane                        */
  48.   int      x_offset;              /* x-offset                                                          */
  49.   int      y_offset;              /* y-offset                                                          */
  50.   struct   Pane *next_pane;       /* pointer to next pane in the list, or 0 for none */
  51. } Pane;
  52.  
  53. /* define some mappings for wimp_block */
  54.  
  55. typedef struct Window_block {
  56.   int handle;
  57.   int vis_min_x;
  58.   int vis_min_y;
  59.   int vis_max_x;
  60.   int vis_max_y;
  61.   int x_scroll;
  62.   int y_scroll;
  63.   int in_front;
  64.   int window_flags;
  65. } Window_block;
  66.  
  67. typedef struct Menu_block {
  68.   int item_1;
  69.   int item_2;
  70.   int item_3;
  71.   int item_4;
  72.   int item_5;
  73.   int item_6;
  74.   int item_7;
  75. } Menu_block;
  76.  
  77. typedef struct Redraw_block {
  78.   int handle;
  79.   int vis_min_x;
  80.   int vis_min_y;
  81.   int vis_max_x;
  82.   int vis_max_y;
  83.   int x_scroll;
  84.   int y_scroll;
  85.   int gw_min_x;
  86.   int gw_min_y;
  87.   int gw_max_x;
  88.   int gw_max_y;
  89. } Redraw_block;
  90.  
  91. typedef struct Mouse_block {
  92.   int x;
  93.   int y;
  94.   int buttons;
  95.   int window_handle;
  96.   int icon;
  97. } Mouse_block;
  98.  
  99. typedef struct Message_dataload { /* holds data for message type 3 (dataload) */
  100.   int window_handle;
  101.   int icon_handle;
  102.   int dest_x_coord;
  103.   int dest_y_coord;
  104.   int estimated_size;             /* estimated filesize in bytes */
  105.   int filetype;
  106.   char filename[232];             /* filename, null terminated */
  107. } Message_dataload;
  108.  
  109. typedef struct Message_block {
  110.   int length;                     /* message block length in words */
  111.   int sender_task_handle;         /* task handle of sender task (not used on entry) */
  112.   int my_ref;                     /* unique non-zero word */
  113.   int your_ref;                   /* 0 if originating the message */
  114.   int message_action;             /* code depending on message action */
  115. } Message_block;
  116.  
  117. /* Set up some useful pointers / variables */
  118.  
  119. extern int *wimp_block;
  120. extern int quit;
  121. extern Window_block     *window_block;
  122. extern Redraw_block     *redraw_block;
  123. extern Mouse_block      *mouse_block;
  124. extern Message_block    *message_block;
  125. extern Message_dataload *message_dataload;
  126. extern Menu_block       *menu_block;
  127.  
  128. /* Initialise task and setup wimp block. */
  129. /* On exit: 0 = success.
  130.             1 = failed to malloc wimp block. */
  131. int hl_initialise_task(int os_version, char *task_name, int *mask, unsigned int *task_handle);
  132.  
  133. /* Open a template file. */
  134. void hl_open_templates(char *name);
  135.  
  136. /* Close a template file. */
  137. void hl_close_templates(void);
  138.  
  139. /* Load a given window definition and fill in a Window struct.  */
  140. /* sprite_area is a pointer to a sprite area used by the window */
  141. /* On exit: 0 = fail.
  142.             address = success */
  143. Window *hl_load_window(char *name1, int *sprite_area);
  144.  
  145. /* Load the HawkLib sprite area */
  146. /* On exit: ptr to sparea = success.
  147.             1 = couldn't malloc sprite area.
  148.             2 = couldn't open spritefile. */
  149. int *hl_load_sprites(char *name);
  150.  
  151. /* Attach a pane to a window. can be called multiple times to attach multiple panes. */
  152. /* On exit: 0 = success.
  153.             1 = couldn't malloc space to store Pane struct. */
  154. int hl_attach_pane(Window *window, Window *pane, int x_offset, int y_offset);
  155.  
  156. /* Remove a pane from a window */
  157. /* On exit: 0 = success.
  158.             1 = pane not found. */
  159. int hl_remove_pane(Window *window, Window *pane);
  160.  
  161. /* swap two pane windows */
  162. int hl_swap_pane(Window *window, Window *original_pane, Window *new_pane);
  163.  
  164. /* Attach a slider - returns either slider pointer or null for fail */
  165. Slider *hl_attach_slider(Window *window, int x_offset, int y_offset,int width, int height, int max_value, int min_value, int centre_value, int value, int fg_colour, int bg_colour, int (*fnptr)(), int flags);
  166.  
  167. /* Remove a slider from a window */
  168. /* On exit: 0 = success.
  169.             1 = slider not found. */
  170. int hl_remove_slider(Window *window, Slider *slider);
  171.  
  172. /* Handle opening windows and panes of windows... */
  173.  
  174. /* convert window handle to pointer to Window */
  175. /* On exit: NULL = failed
  176.             pointer to window if succeded */
  177. Window *hl_hawklib_convert_to_Window(int handle);
  178.  
  179. /* Open using pointer to window struct */
  180. /* This also calls Wimp_GetWindowState before opening */
  181. void hl_show_window(Window *window, int style);
  182.  
  183. /* find struct pointer given handle... */
  184. int hl_open_window(int handle);
  185.  
  186. /* close window */
  187. void hl_hide_window(Window *window);
  188.  
  189. /* close window given handle, not struct pointer */
  190. int hl_close_window(int handle);
  191.  
  192. /* Initiate a Wimp Drag */
  193. /* Horrid routine */
  194.  
  195. void hl_start_drag(int a, int b, int c, int d, int e, int f, int g, int h, int i,int j, int k, int l, int m, int n);
  196.  
  197. /* Icon routines */
  198.  
  199. int hl_create_icon(int w_handle, int min_x, int min_y, int max_x, int max_y, int flags, int ind_a, int ind_b, int ind_c);
  200.  
  201. /* Set icon text */
  202.  
  203. void hl_set_icon_text(Window *window, int icon_handle, char *icon_text, int flags);
  204.  
  205. /* fill in wimp_block with icon state */
  206.  
  207. void hl_get_icon_state(Window *window, int icon_handle);
  208.  
  209. /* Set an icons state according to the clear and eor words */
  210.  
  211. void hl_set_icon_state(Window *window, int icon_handle, int eor, int clear);
  212.  
  213. /* return pointer to icon text */
  214.  
  215. char *hl_get_icon_text(Window *window, int icon_handle);
  216.  
  217. /* Grey out an icon */
  218.  
  219. void hl_grey_icon(Window *window, int icon_handle);
  220.  
  221. /* Ungrey an icon */
  222.  
  223. void hl_ungrey_icon(Window *window, int icon_handle);
  224.  
  225. /* create menu - returns -1 for fail, otherwise, handle is passed back. */
  226.  
  227. int hl_create_menu(char *title, char tfgc, char tbgc, char wfgc, char wbgc, int width, int height, int gap);
  228.  
  229. /* Add menu item to end of menu returns 0 for success. */
  230.  
  231. int hl_add_menu_item(int menu_handle, int flags, int sub_ptr, int icon_flags, char *name, int i1, int i2, int i3);
  232.  
  233. /* Display menu on screen */
  234. void hl_show_menu(int menu_handle, int x, int y);
  235.  
  236. /* Alter existing menu entries - 1 = first entry, 2 = second etc. */
  237. void hl_alter_menu_item(int menu_handle, int item, int alterflags, int flags, int sub_ptr, int icon_flags, char *name, int i1, int i2, int i3);
  238.  
  239. /* allow menu flags to be edited */
  240.  
  241. void hl_edit_menu_flags(int menu_handle, int item, int new_flags_clear, int new_flags_or);
  242.  
  243. /* Set menu handler function */
  244.  
  245. void hl_set_menu_handler(int (*fnptr)());
  246.  
  247. /* Set mouse rectangle, screen co-ordinates */
  248.  
  249. void hl_set_mouse_rectangle(int min_x, int min_y, int max_x, int max_y);
  250.  
  251. /* On exit: returns reason code from Wimp_Poll. */
  252. int hl_wimp_poll(int polls_per_sec);
  253.  
  254. /* Wimp errors */
  255. void hl_error(char *error);
  256. #endif
  257.