Initial commit
[amiga/OpenBoopsi.git] / include / BoopsiLib.h
1 /*
2 **      $Id: BoopsiLib.h,v 1.1 2000/01/12 20:30:05 bernie Exp $
3 **
4 **      Copyright (C) 1999 Bernardo Innocenti
5 **      All rights reserved.
6 **
7 **      Use 4 chars wide TABs to read this file
8 **
9 **      Prototypes for the GetGadgetBox() and GetGadgetBounds() helpers
10 */
11
12 #ifndef INTUITION_CGHOOKS_H
13 #include <intuition/cghooks.h>
14 #endif
15
16 #ifndef INTUITION_IMAGECLASS_H
17 #include <intuition/imageclass.h>
18 #endif
19
20
21 /* Supported class flavours:
22  *
23  * FLAVOUR_CLASSLIB
24  *      Build a class library if this option is set or
25  *      a static linker object otherwise.
26  *
27  * FLAVOUR_PUBCLASS
28  *      Call AddClass() to show this class globally if set,
29  *      make a private class otherwise.
30  */
31 #define FLAVOUR_CLASSLIB        (1<<0)
32 #define FLAVOUR_PUBCLASS        (1<<1)
33
34
35
36 /* Useful functions to compute the actual size of a gadget, regardless
37  * of its relativity flags
38  */
39 void GetGadgetBox(struct GadgetInfo *ginfo, struct ExtGadget *g, struct IBox *box);
40 void GetGadgetBounds(struct GadgetInfo *ginfo, struct ExtGadget *g, struct IBox *bounds);
41
42
43 /* Convert a struct IBox to a struct Rectangle
44  */
45 INLINE void IBoxToRect(struct IBox *box, struct Rectangle *rect)
46 {
47         ASSERT_VALID_PTR(box)
48         ASSERT_VALID_PTR(rect)
49
50         rect->MinX = box->Left;
51         rect->MinY = box->Top;
52         rect->MaxX = box->Left + box->Width - 1;
53         rect->MaxY = box->Top + box->Height - 1;
54 }
55
56
57 /* Tell if a gadget has a boopsi frame
58  */
59 INLINE BOOL GadgetHasFrame(struct Gadget *g)
60 {
61         return (BOOL)(
62                 g->GadgetRender &&
63                 (g->Flags & GFLG_GADGIMAGE) &&
64                 (((struct Image *)g->GadgetRender)->Depth == CUSTOMIMAGEDEPTH));
65 }
66
67
68 /* Some layers magic adapded from "MUI.undoc",
69  * by Alessandro Zummo <azummo@ita.flashnet.it>
70  */
71
72 /* This macro evalutates to true when the layer is
73  * covered by another layer
74  */
75 #define LayerCovered(l)                                                                 \
76         ((!(l)->ClipRect) ||                                                            \
77         ((l)->bounds.MinX != (l)->ClipRect->bounds.MinX) ||     \
78         ((l)->bounds.MinY != (l)->ClipRect->bounds.MinY) ||     \
79         ((l)->bounds.MaxX != (l)->ClipRect->bounds.MaxX) ||     \
80         ((l)->bounds.MaxY != (l)->ClipRect->bounds.MaxY))
81
82 /* memcmp(&(l)->ClipRect->bounds, &(l)->bounds, sizeof (struct Rectangle))) */
83
84 /* This macro evalutates to true if the layer has damage regions */
85 #define LayerDamaged(l) \
86         ((l)->DamageList && (l)->DamageList->RegionRectangle)
87
88 /* This macro checks if ScrollRaster() needs to be called to
89  * scroll the layer damage after a scrolling operation.
90  */
91 #define NeedZeroScrollRaster(l) \
92         (((l)->Flags & LAYERSIMPLE) && (LayerCovered(l) || LayerDamaged(l)))