home *** CD-ROM | disk | FTP | other *** search
- #ifndef CPP_LAYOUTER_LAYOUTER_H
- #define CPP_LAYOUTER_LAYOUTER_H
-
- // Layouter für Gadgets und andere rechteckige Oberflächenelemente
- //
- // Autor: Jochen Becher
- //
- // Historie:
- // Version 1.0 am 8. März 94
-
- #ifndef EXEC_TYPES_H
- #include <exec/types.h>
- #endif
-
- #ifndef CPP_EXEC_LISTS_H
- #include <classes/exec/lists.h>
- #endif
-
- #ifndef CPP_UTILITY_HOOKS_H
- #include <classes/utility/hooks.h>
- #endif
-
- #ifndef CPP_EXCEPTIONS_EXCEPTIONS_H
- #include <classes/exceptions/exceptions.h>
- #endif
-
- #define LAYOUT_NOSIZE 0
- #define LAYOUT_AUTOSIZE -1
-
- class LayoutC {
- public:
- virtual BOOL layoutWidth() { return TRUE; };
- virtual BOOL layoutHeight() { return TRUE; };
- virtual VOID setTop(WORD t) = 0;
- virtual VOID setLeft(WORD l) = 0;
- virtual VOID setWidth(WORD w) = 0;
- virtual VOID setHeight(WORD h) = 0;
- virtual WORD top() const = 0;
- virtual WORD left() const = 0;
- virtual WORD width() const = 0;
- virtual WORD height() const = 0;
- virtual BOOL autoWidth() const = 0;
- virtual BOOL autoHeight() const = 0;
- virtual WORD topBorder() const = 0;
- virtual WORD bottomBorder() const = 0;
- virtual WORD leftBorder() const = 0;
- virtual WORD rightBorder() const = 0;
- virtual WORD minWidth() { return width(); };
- virtual WORD minHeight() { return height(); };
- };
-
- class TransparentLayoutC : public LayoutC {
- public:
- TransparentLayoutC(
- WORD width = LAYOUT_AUTOSIZE, WORD height = LAYOUT_AUTOSIZE);
- BOOL layoutWidth();
- BOOL layoutHeight();
- VOID setTop(WORD t) { Top = t; };
- VOID setLeft(WORD l) { Left = l; };
- VOID setWidth(WORD w);
- VOID setHeight(WORD h);
- WORD top() const { return Top; };
- WORD left() const { return Left; };
- WORD width() const { return Width; };
- WORD height() const { return Height; };
- BOOL autoWidth() const { return aWidth; };
- BOOL autoHeight() const { return aHeight; };
- WORD topBorder() const { return 0; };
- WORD bottomBorder() const { return 0; };
- WORD leftBorder() const { return 0; };
- WORD rightBorder() const { return 0; };
- private:
- WORD Left;
- WORD Top;
- WORD Height;
- WORD Width;
- BOOL aWidth;
- BOOL aHeight;
- };
-
- class GroupLayoutC : public LayoutC {
- public:
- GroupLayoutC() : LayoutC(), minimumWidth(0), minimumHeight(0) { };
- virtual WORD innerTopBorder() const = 0;
- virtual WORD innerBottomBorder() const = 0;
- virtual WORD innerLeftBorder() const = 0;
- virtual WORD innerRightBorder() const = 0;
- WORD minWidth() { return minimumWidth; };
- WORD minHeight() { return minimumHeight; };
- virtual VOID setMinWidth(WORD w) { minimumWidth = w; };
- virtual VOID setMinHeight(WORD h) { minimumHeight = h; };
- private:
- WORD minimumWidth;
- WORD minimumHeight;
- };
-
- class TransparentGroupLayoutC : public GroupLayoutC {
- public:
- TransparentGroupLayoutC(
- WORD width = LAYOUT_AUTOSIZE, WORD height = LAYOUT_AUTOSIZE);
- BOOL layoutWidth();
- BOOL layoutHeight();
- VOID setTop(WORD t) { Top = t; };
- VOID setLeft(WORD l) { Left = l; };
- VOID setWidth(WORD w);
- VOID setHeight(WORD h);
- WORD top() const { return Top; };
- WORD left() const { return Left; };
- WORD width() const { return Width; };
- WORD height() const { return Height; };
- BOOL autoWidth() const { return aWidth; };
- BOOL autoHeight() const { return aHeight; };
- WORD topBorder() const { return 0; };
- WORD bottomBorder() const { return 0; };
- WORD leftBorder() const { return 0; };
- WORD rightBorder() const { return 0; };
- WORD minWidth() { return GroupLayoutC::minWidth(); };
- WORD minHeight() { return GroupLayoutC::minHeight(); };
- WORD innerTopBorder() const { return 0; };
- WORD innerBottomBorder() const { return 0; };
- WORD innerLeftBorder() const { return 0; };
- WORD innerRightBorder() const { return 0; };
- private:
- WORD Left;
- WORD Top;
- WORD Height;
- WORD Width;
- BOOL aWidth;
- BOOL aHeight;
- };
-
- class GeometryC;
- class GeometryGroupC;
- class GeometryBaseC { };
-
- // alle möglichen Relationsarten
- #define LAYOUT_SIZE 0
- #define LAYOUT_SAME 1
- #define LAYOUT_SAMEBORDER 2
- #define LAYOUT_GROUP 3
- #define LAYOUT_OPP 4
- #define LAYOUT_OPPBORDER 5
- #define LAYOUT_OPPGROUP 6
- #define LAYOUT_MAXSIZE 7
- #define LAYOUT_SAMESIZE 8
- #define LAYOUT_PROCENT 9
- #define LAYOUT_PROCENTCENTER 10
- #define LAYOUT_MAXSAMEBORDER 11
- #define LAYOUT_MAXOPPBORDER 12
- #define LAYOUT_HOOK 13
- #define LAYOUT_BORDERGROUP 14
-
- class LayoutParamPkt {
- public:
- UWORD command;
- UWORD flags;
- GeometryGroupC *parent;
- WORD parentPosition;
- WORD parentSize;
- ULONG count;
- WORD offset;
- WORD other_coor;
- WORD coor_result;
- };
-
- // Commands
- #define LAYOUTC_PREWIDTH 1
- #define LAYOUTC_PREHEIGHT 2
- #define LAYOUTC_PRELEFT 3
- #define LAYOUTC_PRERIGHT 4
- #define LAYOUTC_PRETOP 5
- #define LAYOUTC_PREBOTTOM 6
- #define LAYOUTC_LEFT 7
- #define LAYOUTC_RIGHT 8
- #define LAYOUTC_TOP 9
- #define LAYOUTC_BOTTOM 10
-
- // Flags
- #define LAYOUTB_VALID_OTHER 0
- #define LAYOUTF_VALID_OTHER 1
- #define LAYOUTB_LAST_CHANCE 1
- #define LAYOUTF_LAST_CHANCE 2
-
- // Return codes
- #define LAYOUTR_UNKNOWN 0
- #define LAYOUTR_OK 1
- #define LAYOUTR_ERROR 2
- #define LAYOUTR_NOTYET 3
-
- class GeometryHookC : public GeometryBaseC, public HookC {
- public:
- GeometryHookC(APTR data = NULL);
- virtual ULONG layout(GeometryC *, struct LayoutParamPkt *);
- ULONG hook(APTR, APTR);
- ULONG call(GeometryC *, struct LayoutParamPkt *);
- };
-
- class GeometryC : public GeometryBaseC, public NodeC {
- friend class GeometryGroupC;
- public:
- GeometryC(LayoutC &g,
- ULONG topRelation, GeometryBaseC *topObject, WORD topOffset,
- ULONG bottomRelation, GeometryBaseC *bottomObject, WORD bottomOffset,
- ULONG leftRelation, GeometryBaseC *leftObject, WORD leftOffset,
- ULONG rightRelation, GeometryBaseC *rightObject, WORD rightOffset);
- virtual ~GeometryC();
- virtual BOOL layoutX(WORD parentLeft, WORD parentWidth, ULONG countX);
- virtual BOOL layoutY(WORD parentTop, WORD parentHeight, ULONG countY);
- virtual BOOL preLayoutX(ULONG countX);
- virtual BOOL preLayoutY(ULONG countY);
- virtual VOID move(WORD dx, WORD dy);
- virtual BOOL layoutGadWidth();
- virtual BOOL layoutGadHeight();
- WORD layoutedTop() { return top; };
- WORD layoutedLeft() { return left; };
- WORD layoutedRight() { return right; };
- WORD layoutedBottom() { return bottom; };
- WORD layoutedWidth() { return right-left; };
- WORD layoutedHeight() { return bottom-top; };
- virtual WORD topBorder() { return gadget->topBorder(); };
- virtual WORD bottomBorder() { return gadget->bottomBorder(); };
- virtual WORD leftBorder() { return gadget->leftBorder(); };
- virtual WORD rightBorder() { return gadget->rightBorder(); };
- LayoutC *layoutObject() { return gadget; };
- VOID setTopRule(ULONG relation, GeometryBaseC *object, WORD offset);
- VOID setBottomRule(ULONG relation, GeometryBaseC *object, WORD offset);
- VOID setLeftRule(ULONG relation, GeometryBaseC *object, WORD offset);
- VOID setRightRule(ULONG relation, GeometryBaseC *object, WORD offset);
- ULONG topRule(GeometryBaseC *&object, WORD &offset);
- ULONG bottomRule(GeometryBaseC *&object, WORD &offset);
- ULONG leftRule(GeometryBaseC *&object, WORD &offset);
- ULONG rightRule(GeometryBaseC *&object, WORD &offset);
- WORD pWidth() { return preWidth; };
- WORD pHeight() { return preHeight; };
- private:
- virtual VOID setCounters(ULONG cX, ULONG cY, ULONG pX, ULONG pY);
- BOOL xLayouting;
- BOOL yLayouting;
- ULONG counterX;
- WORD left;
- WORD right;
- ULONG counterY;
- WORD top;
- WORD bottom;
- ULONG preCounterX;
- WORD preLeft;
- WORD preRight;
- WORD preWidth;
- ULONG preCounterY;
- WORD preTop;
- WORD preBottom;
- WORD preHeight;
- protected:
- LayoutC *gadget;
- GeometryGroupC *parent;
- ULONG tRel;
- GeometryC *tObj;
- WORD tOffset;
- ULONG bRel;
- GeometryC *bObj;
- WORD bOffset;
- ULONG lRel;
- GeometryC *lObj;
- WORD lOffset;
- ULONG rRel;
- GeometryC *rObj;
- WORD rOffset;
- };
-
- class GeometryGroupC : public GeometryC, protected ListC {
- public:
- GeometryGroupC(GroupLayoutC &g,
- ULONG topRelation, GeometryBaseC *topObject, WORD topOffset,
- ULONG bottomRelation, GeometryBaseC *bottomObject, WORD bottomOffset,
- ULONG leftRelation, GeometryBaseC *leftObject, WORD leftOffset,
- ULONG rightRelation, GeometryBaseC *rightObject, WORD rightOffset);
- virtual ~GeometryGroupC();
- VOID add(GeometryC &g);
- BOOL layoutX(WORD parentLeft, WORD parentWidth, ULONG countX);
- BOOL layoutY(WORD parentTop, WORD parentHeight, ULONG countY);
- BOOL preLayoutX(ULONG countX);
- BOOL preLayoutY(ULONG countY);
- VOID move(WORD dx, WORD dy);
- BOOL layoutGadWidth();
- BOOL layoutGadHeight();
- WORD topBorder() { return maxTBorder; };
- WORD bottomBorder() { return maxBBorder; };
- WORD leftBorder() { return maxLBorder; };
- WORD rightBorder() { return maxRBorder; };
- WORD maxWidth() { return maximumWidth; };
- WORD maxHeight() { return maximumHeight; };
- WORD maxLeftBorder() { return maximumLeftB; };
- WORD maxRightBorder() { return maximumRightB; };
- WORD maxTopBorder() { return maximumTopB; };
- WORD maxBottomBorder() { return maximumBottomB; };
- private:
- VOID setCounters(ULONG cX, ULONG cY, ULONG pX, ULONG pY);
- GroupLayoutC *border;
- WORD maximumWidth;
- WORD maximumHeight;
- WORD maximumLeftB;
- WORD maximumRightB;
- WORD maximumTopB;
- WORD maximumBottomB;
- WORD maxLBorder;
- WORD maxRBorder;
- WORD maxTBorder;
- WORD maxBBorder;
- };
-
- class RootGeometryC {
- public:
- RootGeometryC();
- RootGeometryC(GroupLayoutC &);
- VOID add(GeometryC &g);
- VOID layout(WORD parentTop, WORD parentLeft,
- WORD parentWidth, WORD parentHeight);
- WORD top() { return group.layoutedTop(); };
- WORD left() { return group.layoutedLeft(); };
- WORD width() { return group.layoutedWidth(); };
- WORD height() { return group.layoutedHeight(); };
- VOID move(WORD dx, WORD dy) { group.move(dx,dy); };
- private:
- TransparentGroupLayoutC transparent;
- GroupLayoutC &gadget;
- GeometryGroupC group;
- ULONG counterX;
- ULONG counterY;
- };
-
- #endif
-
-