home *** CD-ROM | disk | FTP | other *** search
/ Dream 44 / Amiga_Dream_44.iso / Amiga / programmation / geometryengine.lha / GeometryEngine / include / geometry.h
C/C++ Source or Header  |  1997-08-27  |  8KB  |  228 lines

  1. /*
  2. **    $Id: geometry.h 1.1 1997/08/03 00:52:00 Aric_Caley Exp Aric_Caley $
  3. **
  4. **      Header file for Geometry.lib
  5. **
  6. **    Written by Aric R Caley
  7. **
  8. **    (C) Copyright 1997 Greywire designs
  9. **        All Rights Reserved
  10.  
  11. $Log: geometry.h $
  12.  * Revision 1.1  1997/08/03  00:52:00  Aric_Caley
  13.  * Initial revision
  14.  *
  15. */
  16.  
  17. #define INTUI_V36_NAMES_ONLY
  18.  
  19. #include <exec/types.h>
  20. #include <intuition/intuition.h>
  21. #include <intuition/gadgetclass.h>
  22. #include <intuition/icclass.h>
  23. #include <libraries/gadtools.h>
  24.  
  25. #include <proto/exec.h>
  26. #include <proto/intuition.h>
  27. #include <proto/graphics.h>
  28. #include <proto/utility.h>
  29. #include <proto/dos.h>
  30. #include <proto/gadtools.h>
  31. #include <proto/diskfont.h>
  32.  
  33. #include <clib/alib_protos.h>
  34.  
  35. #include <stdio.h>
  36. #include <math.h>
  37.  
  38. typedef struct LongPoint
  39. {
  40.   LONG x, y;    //** 16.16 bit fractions.
  41. } LongPoint;
  42.  
  43. //** Dont mess with this stuff.  In fact, just close your eyes.  :)
  44. typedef struct GTTemplate
  45. {
  46.   struct Gadget *Gadget, *Context;
  47.   ULONG Kind;
  48.   UBYTE *Text;
  49.   UWORD NumGads;    //** Number of gadgets we have (stupid GadTools)
  50.   UWORD ID;
  51.   ULONG Flags;
  52.   APTR UserData;
  53.   struct TagItem *Tags;
  54.   struct TagItem *State;
  55.   void *StateData;
  56. } GTTemplate;
  57.  
  58. //** A minimum geometry, used for "leafs", like a gadget.
  59. typedef struct MGeometry
  60. {
  61.   struct MGeometry *Next;
  62.   void *Object;        //** Note: same as member "Children" in a full geometry
  63.   ULONG Flags;
  64.   struct IBox Box;    //** Relative (interpreted) domain dimensions (see Domains.txt)
  65.   struct IBox Real;    //** Actual calculated pixel dimensions.
  66.   struct IBox Min;    //** Minimum pixel dimensions (Left / Top ignored)
  67. } MGeometry;
  68.  
  69. typedef struct CustomGeometry
  70. {
  71.   struct Leaf *Next;
  72.   void *Object;        //** Note: same as member "Children" in a full geometry
  73.   ULONG Flags;
  74.   struct IBox Box;    //** Relative (interpreted) domain dimensions (see Domains.txt)
  75.   struct IBox Real;    //** Actual calculated pixel dimensions.
  76.   struct IBox Min;    //** Minimum pixel dimensions (Left / Top ignored)
  77.   struct Hook *Free;
  78.   struct Hook *Render;
  79.   struct Hook *Minsize;
  80.   struct Hook *Resize;
  81. } CustomGeometry;
  82.  
  83. //** A full geometry; typicaly NOT a "leaf": gadget, image, etc.
  84. typedef struct Geometry
  85. {
  86.   struct Geometry *Next;
  87.   struct Geometry *Children;
  88.   ULONG Flags;
  89.   struct IBox Box;    //** Relative (interpreted) domain dimensions (see Domains.txt)
  90.   struct IBox Real;    //** Actual calculated pixel dimensions.
  91.   struct IBox Min;    //** Minimum pixel dimensions (Left / Top ignored)
  92.   struct Hook *Free;
  93.   struct Hook *Render;
  94.   struct Hook *Minsize;
  95.   struct Hook *Resize;
  96.   Point PropRange;    //** Sum of proportions of our children (* ScaleFact * ScaleMin = actual size)
  97.   Point MinRange;    //** Sum of minsizes of our children
  98.   LongPoint ScaleMin;    //** What we need to scale the proportions by (min) (static).
  99.   LongPoint ScaleFact;    //** What we need to scale by to fit into our parent, relative to our minsize! (dynamic).
  100.   Point Pad;        //** How much "padding" to put around our children (for the frame and/or title text, etc)
  101.   SHORT Spacing;    //** Space between children.
  102. } Geometry;
  103. //** How we layout our children
  104. #define GYF_TYPEFLAGS 0x00000003
  105. #define GYF_PROP 0x00000000
  106. #define GYF_HORIZ 0x00000001
  107. #define GYF_VERT 0x00000002
  108. #define GYF_CUSTOM 0x00000003
  109. #define GYF_JUSTIFYFLAGS 0x0000000C
  110. #define GYF_JRIGHTBOTTOM 0x00000004
  111. #define GYF_JCENTER 0x00000008
  112.  
  113. //** This is an MGeometry
  114. #define GYF_LEAF 0x10000000
  115. //** This MGeometry is a CustomGeom with Object pointing to a Hook for custom handling,
  116. //** Otherwise it would be a gadtools object with Object pointing to a GTTemplate.
  117. #define GYF_HOOK  0x20000000
  118.  
  119. //** Frame flags
  120. #define GYF_FRAMEBITS 0x00000070
  121. #define GYF_NONE   0x00
  122. #define GYF_RECESS 0x00000010
  123. #define GYF_RAISED 0x00000020
  124. #define GYF_RIDGE  0x00000030
  125. #define GYF_THICK  0x00000040
  126. //** Text flags
  127. // GYF_TEXTABOVE 0x00000000
  128. #define GYF_TEXTBITS  0x00000300
  129. #define GYF_TEXTBELOW 0x00000100
  130. #define GYF_TEXTLEFT  0x00000200
  131. #define GYF_TEXTRIGHT 0x00000300
  132. // GYF_TEXTBREAKFRAME 0x00000000
  133. #define GYF_TEXTINFRAME 0x00000400
  134. #define GYF_TEXTOUTFRAME 0x00000800
  135.  
  136. typedef struct GUI
  137. {
  138.   struct Screen *Scr;
  139.   APTR VI;
  140.   struct DrawInfo *DrInfo;
  141.   struct Window *Win;
  142.   struct TextAttr Attr;
  143.   struct TextFont *Font;
  144.   ULONG Flags;
  145.   Geometry *Geom;
  146. } GUI;
  147. //** Don't mess with these!
  148. //** In the middle of a resize
  149. #define GUIF_RESIZING 0x00000001
  150. #define GUIF_NEEDSREFRESH 0x00000002
  151. #define GUIF_DYING 0x00000004
  152.  
  153. //** High level interface construct
  154. typedef struct GUIForm
  155. {
  156.   GUI *GUI;
  157.   struct TagItem *Args;
  158.   ULONG *OKID;    //** The ID's to consider in order to close the window
  159.   ULONG *CancelID;
  160.   struct Hook *Custom;
  161. } GUIForm;
  162.  
  163. //** Tags
  164. #define GE_Geometry    (TAG_USER + 1) //** Init this geometry under the given GUI envirionment
  165. #define GE_Child    GE_Geometry
  166. #define GE_RenderHook    (TAG_USER + 2)
  167. #define GE_MinsizeHook    (TAG_USER + 3)
  168. #define GE_ResizeHook    (TAG_USER + 4)
  169. #define GE_FreeHook    (TAG_USER + 5)
  170. #define GE_ScreenName    (TAG_USER + 6)
  171. #define GE_FontAttr    (TAG_USER + 7)
  172. #define GE_Object    (TAG_USER + 8)
  173.  
  174. //** Geometry management/layout functions
  175. /* Ignore the #define's and IT_* functions.  This was due to an API change, to
  176. keep compatible with a few programs.  This will go away.  In fact I don't know
  177. why it's still here.  Just paranoid I guess :)
  178. */
  179. //        IT_InitGeometry(GUI *MyGUI);
  180. #define     IT_InitGeometry(gui) GE_InitGeometry(gui,TAG_END)
  181. BOOL        GE_InitGeometry(GUI *MyGUI, Tag tags,...);
  182. BOOL        GE_InitGeometryA(GUI *MyGUI, struct TagItem *tags);
  183.  
  184. //void        IT_BeginResizeGeometry(GUI *MyGUI);
  185. #define        IT_BeginResizeGeometry(gui) GE_BeginResizeGeometry(gui,TAG_END);
  186. BOOL        GE_BeginResizeGeometry(GUI *MyGUI, Tag tags,...);
  187. BOOL        GE_BeginResizeGeometryA(GUI *MyGUI, struct TagItem *tags);
  188.  
  189. //        IT_ResizeGeometry(GUI *MyGUI);
  190. #define        IT_ResizeGeometry(gui) GE_ResizeGeometry(gui,TAG_END);
  191. BOOL        GE_ResizeGeometry(GUI *MyGUI, Tag tags,...);
  192. BOOL        GE_ResizeGeometryA(GUI *MyGUI, struct TagItem *tags);
  193.  
  194. #define        IT_RefreshGeometry(gui) GE_RenderGeometry(gui,TAG_END)
  195. BOOL        GE_RenderGeometry(GUI *MyGUI,Tag tags,...);
  196. BOOL        GE_RenderGeometryA(GUI *MyGUI, struct TagItem *tags);
  197.  
  198. //void        IT_GTMinSize(struct RastPort *rp,GUI *MyGUI,Geometry *me);
  199. //void        IT_GTReSize(GUI *MyGUI,Geometry *me,SHORT width, SHORT height);
  200.  
  201. //** Geometry/template creation functions
  202. Geometry *    GE_CreateGTA(SHORT Width, SHORT Height,ULONG Kind,UBYTE *Text,UWORD ID,ULONG Flags,struct TagItem *tags);
  203. Geometry *    GE_CreateGT(SHORT Width, SHORT Height,ULONG Kind,UBYTE *Text,UWORD ID,ULONG Flags,Tag tags,...);
  204. //Geometry *    IT_CreateMGeometry(ULONG Flags,SHORT Width, SHORT Height,void *object);
  205. Geometry *    GE_CreateGeometryA(ULONG Flags,SHORT Width, SHORT Height, struct TagItem *tags);
  206. Geometry *    GE_CreateGeometry(ULONG Flags,SHORT Width, SHORT Height, Tag tags,...);
  207. void        GE_FreeGeometries(GUI *MyGUI,Geometry *me);
  208. void        GE_FreeGT(GUI *MyGUI,Geometry *gt);
  209.  
  210. //** GUI functions
  211. #define     IT_CreateGUI(scr,attr) GE_CreateGUI(GE_ScreenName,scr,GE_FontAttr,attr,TAG_END)
  212. GUI *           GE_CreateGUI(Tag tags,...);
  213. GUI *           GE_CreateGUIA(struct TagItem *tags);
  214. void        GE_FreeGUI(GUI *MyGUI);
  215. struct Window *    GE_OpenWindow(GUI *MyGUI,Tag tags,...);
  216. struct Window *    GE_OpenWindowA(GUI *MyGUI,struct TagItem *tags);
  217. void        GE_CloseWindow(GUI *MyGUI);
  218.  
  219. //** Higher level requester-like functions
  220. BOOL        IT_OpenForm(GUIForm *Form);
  221. BOOL        IT_HandleForm(GUIForm *Form);
  222. BOOL        IT_CloseForm(GUIForm *Form);
  223. ULONG        IT_DoForm(GUIForm *Form);
  224.  
  225. //** A couple of internal functions for GadTools stuff
  226. SHORT CountGadgets(struct Gadget *gads);
  227. void TerminateGadgets(struct Gadget *gads, SHORT count);
  228.