home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 December / PCWDEC06.iso / Software / Freeware / Partition Logic 0.63 / partlogic-0.63.iso / system / headers / sys / window.h < prev   
Encoding:
C/C++ Source or Header  |  2006-08-22  |  7.1 KB  |  232 lines

  1. // 
  2. //  Visopsys
  3. //  Copyright (C) 1998-2006 J. Andrew McLaughlin
  4. //  
  5. //  This library is free software; you can redistribute it and/or modify it
  6. //  under the terms of the GNU Lesser General Public License as published by
  7. //  the Free Software Foundation; either version 2.1 of the License, or (at
  8. //  your option) any later version.
  9. //
  10. //  This library is distributed in the hope that it will be useful, but
  11. //  WITHOUT ANY WARRANTY; without even the implied warranty of
  12. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
  13. //  General Public License for more details.
  14. //
  15. //  You should have received a copy of the GNU Lesser General Public License
  16. //  along with this library; if not, write to the Free Software Foundation,
  17. //  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. //
  19. //  window.h
  20. //
  21.  
  22. // This file describes things needed for interaction with the kernel's
  23. // window manager and the Visopsys GUI.
  24.  
  25. #if !defined(_WINDOW_H)
  26.  
  27. #include <sys/image.h>
  28. #include <sys/loader.h>
  29. #include <sys/progress.h>
  30. #include <sys/stream.h>
  31.  
  32. #ifndef _X_
  33. #define _X_
  34. #endif
  35.  
  36. // Window events/masks.  This first batch are "tier 2" events, produced by
  37. // windows, widgets, etc. to indicate that some more abstract thing has
  38. // happened.
  39. #define EVENT_MASK_WINDOW                 0xF000
  40. #define EVENT_WINDOW_RESIZE               0x4000
  41. #define EVENT_WINDOW_CLOSE                0x2000
  42. #define EVENT_WINDOW_MINIMIZE             0x1000
  43. #define EVENT_SELECTION                   0x0800
  44. #define EVENT_CURSOR_MOVE                 0x0400
  45. // And these are "tier 1" events, produced by direct actions of the user.
  46. #define EVENT_MASK_KEY                    0x0300
  47. #define EVENT_KEY_UP                      0x0200
  48. #define EVENT_KEY_DOWN                    0x0100
  49. #define EVENT_MASK_MOUSE                  0x00FF
  50. #define EVENT_MOUSE_DRAG                  0x0080
  51. #define EVENT_MOUSE_MOVE                  0x0040
  52. #define EVENT_MOUSE_RIGHTUP               0x0020
  53. #define EVENT_MOUSE_RIGHTDOWN             0x0010
  54. #define EVENT_MOUSE_MIDDLEUP              0x0008
  55. #define EVENT_MOUSE_MIDDLEDOWN            0x0004
  56. #define EVENT_MOUSE_LEFTUP                0x0002
  57. #define EVENT_MOUSE_LEFTDOWN              0x0001
  58.  
  59. // The maximum numbers of window things
  60. #define WINDOW_MAXWINDOWS                 256
  61. #define WINDOW_MAX_EVENTS                 512
  62. #define WINDOW_MAX_EVENTHANDLERS          256
  63. #define WINDOW_MAX_TITLE_LENGTH           80
  64. #define WINDOW_MAX_LABEL_LENGTH           80
  65. #define WINDOW_MAX_MENUS                  16
  66.  
  67. // Flags for window components
  68. #define WINDOW_COMPFLAG_CLICKABLECURSOR   0x40
  69. #define WINDOW_COMPFLAG_CUSTOMBACKGROUND  0x20
  70. #define WINDOW_COMPFLAG_CUSTOMFOREGROUND  0x10
  71. #define WINDOW_COMPFLAG_STICKYFOCUS       0x08
  72. #define WINDOW_COMPFLAG_HASBORDER         0x04
  73. #define WINDOW_COMPFLAG_FIXEDHEIGHT       0x02
  74. #define WINDOW_COMPFLAG_FIXEDWIDTH        0x01
  75.  
  76. // Flags for file browsing widgets/dialogs.
  77. #define WINFILEBROWSE_CAN_CD              0x01
  78. #define WINFILEBROWSE_CAN_DEL             0x02
  79. #define WINFILEBROWSE_ALL                 (WINFILEBROWSE_CAN_CD | \
  80.                                            WINFILEBROWSE_CAN_DEL)
  81.  
  82. // Some image file names for dialog boxes
  83. #define INFOIMAGE_NAME                    "/system/icons/infoicon.bmp"
  84. #define ERRORIMAGE_NAME                   "/system/icons/bangicon.bmp"
  85. #define QUESTIMAGE_NAME                   "/system/icons/questicon.bmp"
  86. #define WAITIMAGE_NAME                    "/system/mouse/mousebsy.bmp"
  87.  
  88. // An "object key".  Really a pointer to an object in kernel memory, but
  89. // of course not usable by applications other than as a reference
  90. typedef void * objectKey;
  91.  
  92. // These describe the X orientation and Y orientation of a component,
  93. // respectively, within its grid cell
  94.  
  95. typedef enum {
  96.   orient_left, orient_center, orient_right
  97. }  componentXOrientation;
  98.  
  99. typedef enum {
  100.   orient_top, orient_middle, orient_bottom
  101. }  componentYOrientation;
  102.  
  103. // This structure is needed to describe parameters consistent to all
  104. // window components
  105. typedef struct {
  106.   int gridX;
  107.   int gridY;
  108.   int gridWidth;
  109.   int gridHeight;
  110.   int padLeft;
  111.   int padRight;
  112.   int padTop;
  113.   int padBottom;
  114.   int flags;
  115.   componentXOrientation orientationX;
  116.   componentYOrientation orientationY;
  117.   color foreground;
  118.   color background;
  119.   objectKey font;
  120.  
  121. } componentParameters;
  122.  
  123. // A structure for containing various types of window events.
  124. typedef struct {
  125.   unsigned type;
  126.   int xPosition;
  127.   int yPosition;
  128.   unsigned key;
  129.  
  130. } windowEvent;
  131.  
  132. // A structure for a queue of window events as a stream.
  133. typedef struct {
  134.   objectKey component;
  135.   volatile stream s;
  136.  
  137. } windowEventStream;
  138.  
  139. // Types of drawing operations
  140. typedef enum {
  141.   draw_pixel, draw_line, draw_rect, draw_oval, draw_image, draw_text
  142. } drawOperation;
  143.  
  144. // Parameters for any drawing operations
  145. typedef struct {
  146.   drawOperation operation;
  147.   drawMode mode;
  148.   color foreground;
  149.   color background;
  150.   int xCoord1;
  151.   int yCoord1;
  152.   int xCoord2;
  153.   int yCoord2;
  154.   unsigned width;
  155.   unsigned height;
  156.   int thickness;
  157.   int fill;
  158.   objectKey font;
  159.   void *data;
  160.  
  161. } windowDrawParameters;
  162.  
  163. // Types of scroll bars
  164. typedef enum {
  165.   scrollbar_vertical, scrollbar_horizontal
  166. } scrollBarType;
  167.  
  168. // A structure for specifying display percentage and display position
  169. // in scroll bar components
  170. typedef struct {
  171.   unsigned displayPercent;
  172.   unsigned positionPercent;
  173.  
  174. } scrollBarState;
  175.  
  176. // Types of window list displays
  177. typedef enum {
  178.   windowlist_textonly, windowlist_icononly
  179. } windowListType;
  180.  
  181. typedef struct {
  182.   char text[WINDOW_MAX_LABEL_LENGTH];
  183.   image iconImage;
  184.  
  185. } listItemParameters;
  186.  
  187. typedef struct {
  188.   objectKey key;
  189.   void *fileEntries;
  190.   int numFileEntries;
  191.   int browseFlags;
  192.   void (*selectionCallback)(file *, char *, loaderFileClass *);
  193.  
  194.   // Externally-callable service routines
  195.   int (*eventHandler) (void *, windowEvent *);
  196.   int (*update) (void *, const char *);
  197.   int (*destroy) (void *);
  198.  
  199. } windowFileList;
  200.  
  201. void windowCenterDialog(objectKey, objectKey);
  202. int windowClearEventHandler(objectKey);
  203. int windowClearEventHandlers(void);
  204. void windowGuiRun(void);
  205. void windowGuiStop(void);
  206. int windowGuiThread(void);
  207. int windowGuiThreadPid(void);
  208. objectKey windowNewBannerDialog(objectKey, const char *, const char *);
  209. int windowNewChoiceDialog(objectKey, const char *, const char *, char *[],
  210.               int, int);
  211. int windowNewColorDialog(objectKey, color *);
  212. int windowNewErrorDialog(objectKey, const char *, const char *);
  213. int windowNewFileDialog(objectKey, const char *, const char *, const char *,
  214.             char *, unsigned);
  215. windowFileList *windowNewFileList(objectKey, windowListType, int, int,
  216.                   const char *, int, void *,
  217.                   componentParameters *);
  218. int windowNewInfoDialog(objectKey, const char *, const char *);
  219. int windowNewPasswordDialog(objectKey, const char *, const char *, int,
  220.                 char *);
  221. objectKey windowNewProgressDialog(objectKey, const char *, progress *);
  222. int windowNewPromptDialog(objectKey, const char *, const char *, int, int,
  223.               char *);
  224. int windowNewQueryDialog(objectKey, const char *, const char *);
  225. int windowNewRadioDialog(objectKey, const char *, const char *, char *[],
  226.              int, int);
  227. int windowProgressDialogDestroy(objectKey);
  228. int windowRegisterEventHandler(objectKey, void (*)(objectKey, windowEvent *));
  229.  
  230. #define _WINDOW_H
  231. #endif
  232.