/* * Copyright (c)1998 by Angry Red Planet. * * This code is distributed under a modified form of the * Artistic License. A copy of this license should have * been included with it; if this wasn't the case, the * entire package can be obtained at * . * * A logical GUI layout engine: the programmer describes * high-level relationships between the different user interface * object through formal container classes, which then take care * of their physical placement. The system is completely * font-sensitive and resizeable. * * ---------------------------------------------------------------------- * * ArpRunningBar.h * * A layout class that organizes its children as a horizontal * or vertical row. Each child object can be assigned a weight, * which is used to determine how to space the objects along * the horizontal or vertical axis. * * ---------------------------------------------------------------------- * * Known Bugs * ~~~~~~~~~~ * * ---------------------------------------------------------------------- * * To Do * ~~~~~ * * • Add "make equal size" option. * * ---------------------------------------------------------------------- * * History * ~~~~~~~ * * Dec 6, 1998: * First public release. * */ #pragma once #ifndef ARPLAYOUT_ARPRUNNINGBAR_H #define ARPLAYOUT_ARPRUNNINGBAR_H #ifndef ARPLAYOUT_ARPLAYOUTABLE_H #include #endif // This type defines where to place an object within a larger // frame. It may be centered, in one of the eight compass // directions, or stretched to fill the larger frame. enum ArpGravity { ArpCenter = 0x0000, ArpNorth = 0x0001, ArpSouth = 0x0002, ArpWest = 0x0004, ArpEast = 0x0008, ArpNorthEast = ArpNorth|ArpEast, ArpNorthWest = ArpNorth|ArpWest, ArpSouthEast = ArpSouth|ArpEast, ArpSouthWest = ArpSouth|ArpWest, ArpNorthSouth = ArpNorth|ArpSouth, ArpEastWest = ArpEast|ArpWest, ArpFillAll = ArpNorthSouth|ArpEastWest }; class ArpRunningBar : public ArpLayoutable { private: typedef ArpLayoutable inherited; public: ArpRunningBar(const char* name = 0); ArpRunningBar(BMessage* data); static ArpRunningBar* Instantiate(BMessage* archive); virtual status_t Archive(BMessage* data, bool deep=TRUE); /* Parameters: * "Orientation" (int32) Orientation of the object -- * that is, one of B_HORIZONTAL or B_VERTICAL. * B_HORIZONTAL means the children are placed side-by-side * next to each other; B_VERTICAL places them on top of * each other. * * "InsetLeft", "InsetRight", "InsetTop", "InsetBottom" * (float or int32) Space to place on sides, between the * children and this object's frame. Floats specify the * dimensions in character units (font height, width of a * single "W" character), while int32s are absolute pixel * dimensions. All defaults are zero. * * "IntraSpace" (float or int32) The amount of space to * put between children; dimensions are as above, and the * default is also zero. * * NOTE: Absolute dimensioning (int32) is not implemented. */ static const char* OrientationP; static const char* InsetLeftP; static const char* InsetRightP; static const char* InsetTopP; static const char* InsetBottomP; static const char* IntraSpaceP; /* Constraints: * "Weight" (float) The weight of an object, relative to * its other siblings. This determines how much extra space * is assigned to that object. * * "Fill" (int32) How to place a space-limited child in a * larger area allocated to it. Valid values are the ArpGravity * flags. */ static const char* WeightC; static const char* FillC; protected: virtual void DoSetParams(const ArpMessage* g, const ArpMessage* p); virtual bool DoParams(ArpMessage& p, const char* name); virtual void ComputeDimens(void); virtual void Layout(void); ArpString PG_Orientation; ArpString PG_InsetLeft; ArpString PG_InsetRight; ArpString PG_InsetTop; ArpString PG_InsetBottom; ArpString PG_IntraSpace; int32 PV_Orientation; float PV_InsetLeft; float PV_InsetRight; float PV_InsetTop; float PV_InsetBottom; float PV_IntraSpace; private: float total_weight; // WeightC constraint of all chidren float min_weight; // pref-min size of all children float char_w, char_h; float inset_l, inset_r, inset_t, inset_b; float intra_s; }; #endif