// $Revision: 1.9 $ // Copyright (C) 1994 Taligent, Inc. All rights reserved. #ifndef Taligent_LAYOUTVIEWS #define Taligent_LAYOUTVIEWS #ifndef Taligent_VIEW #include #endif #ifndef Taligent_RGBCOLOR #include #endif //---- TLayoutView ------------------------------------------------------------- class TLayoutView : public TView { public: // return number of children virtual long Count() const; // get n-th child virtual TView* GetChild(long index) const; // Miss Manners stuff VersionDeclarationsMacro(TLayoutView); TLayoutView(); TLayoutView(const TLayoutView &other); virtual ~TLayoutView(); virtual bool NeedsClipping(); protected: TLayoutView& operator=(const TLayoutView&); // returns natural (sometimes minimal?), desired size of the view virtual void GetBounds(TGArea& area) const; virtual void PlaceAndSizeChildren(const TGRect& area)= 0; virtual void HandleNumberofChildrenChanged(); virtual void DrawContents(TGrafPort& port) const; virtual void HandleAllocatedAreaChanged(const TGArea& area); virtual void HandleAfterConnectionToViewRoot(); virtual void GetOpaquelyDrawnArea(TGArea& opaqueArea); private: void DoLayout(); void PostLayoutRequest(); bool fLayoutValid; }; //---- TBoxView -------------------------------------------------------------------- class TBoxView : public TLayoutView { public: enum EAlign { kLeft, kTop= kLeft, kCentered, kRight, kBottom= kRight }; enum EExpand { kNoExpand, kExpand, kGapExpand }; public: TBoxView(long columns, long rows, TView* v1= NIL, TView* v2= NIL, TView* v3= NIL, TView* v4= NIL); TBoxView(long columns, long rows, EAlign ha, EAlign va, TView* v1= NIL, TView* v2= NIL, TView* v3= NIL, TView* v4= NIL); TBoxView(long columns, long rows, const TGPoint &gap, TView* v1= NIL, TView* v2= NIL, TView* v3= NIL, TView* v4= NIL); TBoxView(long columns, long rows, EAlign ha, EAlign va, EExpand he, EExpand ve, const TGPoint &gap); virtual void GetColumnsRows(long &columns, long &rows) const; virtual GCoordinate GetItemWidth(long column, long row) const; virtual GCoordinate GetItemHeight(long column, long row) const; virtual TGPoint GetItemSize(long column, long row) const; virtual GCoordinate GetGapWidth(long column) const; virtual GCoordinate GetGapHeight(long row) const; virtual TGPoint GetCellPosition(long column, long row) const; virtual TGPoint GetCellSize(long column, long row) const; virtual EAlign GetCellHAlign(long column, long row) const; virtual EAlign GetCellVAlign(long column, long row) const; virtual EExpand GetCellHExpand(long column, long row) const; virtual EExpand GetCellVExpand(long column, long row) const; virtual void AlignViewInCell(TView &v, EAlign halign, EAlign valign, const TGPoint &cellposition, const TGPoint &cellsize, const TGPoint &item) const; virtual GCoordinate GetWidth() const; virtual GCoordinate GetHeight() const; virtual GCoordinate GetColumnWidth(long column) const; virtual GCoordinate GetRowHeight(long row) const; virtual TView* GetChildAt(long column, long row) const; // Setters virtual void SetColumns(const long &columns); virtual void SetRows(const long &rows); virtual void SetHAlign(EAlign ha); virtual void SetVAlign(EAlign va); virtual void SetHExpand(EExpand he); virtual void SetVExpand(EExpand va); virtual void SetGapWidth(const GCoordinate &width); virtual void SetGapHeight(const GCoordinate &height); // convenience method void AdoptChildren(TView* v1, TView* v2, TView* v3, TView* v4); // Miss Manners stuff MCollectibleDeclarationsMacro(TBoxView); TBoxView(); TBoxView(const TBoxView &other); virtual ~TBoxView(); TBoxView& operator=(const TBoxView &other); virtual TStream& operator>>=(TStream&) const; virtual TStream& operator<<=(TStream&); protected: virtual void GetBounds(TGArea& area) const; virtual void PlaceAndSizeChildren(const TGRect& area); private: long fCols; long fRows; TGPoint fGap; EAlign fHAlign; EAlign fVAlign; EExpand fHExpand; EExpand fVExpand; enum { kOriginalVersion }; }; //---- THBoxView ------------------------------------------------------------------- class THBoxView : public TBoxView { public: THBoxView(TView* v1, TView* v2= NIL, TView* v3= NIL, TView* v4= NIL); THBoxView(EAlign va, TView* v1= NIL, TView* v2= NIL, TView* v3= NIL, TView* v4= NIL); THBoxView(GCoordinate gap, TView* v1= NIL, TView* v2= NIL, TView* v3= NIL, TView* v4= NIL); // Miss Manners stuff MCollectibleDeclarationsMacro(THBoxView); THBoxView(); THBoxView(const THBoxView &other); virtual ~THBoxView(); THBoxView& operator=(const THBoxView &other); }; //---- TVBoxView ------------------------------------------------------------------- class TVBoxView : public TBoxView { public: TVBoxView(TView* v1, TView* v2= NIL, TView* v3= NIL, TView* v4= NIL); TVBoxView(EAlign ha, TView* v1= NIL, TView* v2= NIL, TView* v3= NIL, TView* v4= NIL); TVBoxView(GCoordinate gap, TView* v1= NIL, TView* v2= NIL, TView* v3= NIL, TView* v4= NIL); // Miss Manners stuff MCollectibleDeclarationsMacro(TVBoxView); TVBoxView(); TVBoxView(const TVBoxView &other); virtual ~TVBoxView(); TVBoxView& operator=(const TVBoxView &other); }; //---- TBackgroundView --------------------------------------------------------- class TBackgroundView : public TLayoutView { public: TBackgroundView(const TGPoint &p, const TColor &c, TView* vievToAdopt= NIL); TBackgroundView(const TGPoint &p, TGrafBundle* bundleToAdopt, TView* vievToAdopt= NIL); TBackgroundView(const TGPoint &p, TView* vievToAdopt); // Miss Manners stuff MCollectibleDeclarationsMacro(TBackgroundView); TBackgroundView(); TBackgroundView(const TBackgroundView &other); virtual ~TBackgroundView(); TBackgroundView& operator=(const TBackgroundView &other); virtual TStream& operator>>=(TStream&) const; virtual TStream& operator<<=(TStream&); protected: virtual void GetBounds(TGArea& area) const; virtual void DrawContents(TGrafPort& port) const; virtual void PlaceAndSizeChildren(const TGRect& area); private: TGPoint fBorder; enum { kOriginalVersion }; }; #endif