1 /* 2 * Copyright 2007, Ingo Weinhold <bonefish@cs.tu-berlin.de>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef WIDGET_LAYOUT_TEST_VIEW_H 6 #define WIDGET_LAYOUT_TEST_VIEW_H 7 8 9 #include <Alignment.h> 10 #include <List.h> 11 #include <Rect.h> 12 13 14 class BView; 15 16 17 class View { 18 public: 19 View(); 20 View(BRect frame); 21 virtual ~View(); 22 23 virtual void SetFrame(BRect frame); 24 BRect Frame() const; 25 BRect Bounds() const; 26 27 void SetLocation(BPoint location); 28 BPoint Location() const; 29 30 void SetSize(BSize size); 31 BSize Size() const; 32 33 virtual BSize MinSize(); 34 virtual BSize MaxSize(); 35 virtual BSize PreferredSize(); 36 virtual BAlignment Alignment(); 37 38 BPoint LocationInContainer() const; 39 BRect FrameInContainer() const; 40 41 BPoint ConvertFromContainer(BPoint point) const; 42 BRect ConvertFromContainer(BRect rect) const; 43 BPoint ConvertToContainer(BPoint point) const; 44 BRect ConvertToContainer(BRect rect) const; 45 46 View* Parent() const; 47 BView* Container() const; 48 49 bool AddChild(View* child); 50 bool RemoveChild(View* child); 51 View* RemoveChild(int32 index); 52 53 int32 CountChildren() const; 54 View* ChildAt(int32 index) const; 55 View* ChildAt(BPoint point) const; 56 View* AncestorAt(BPoint point, 57 BPoint* localPoint = NULL) const; 58 int32 IndexOfChild(View* child) const; 59 60 void Invalidate(BRect rect); 61 void Invalidate(); 62 virtual void InvalidateLayout(); 63 bool IsLayoutValid() const; 64 65 void SetViewColor(rgb_color color); 66 67 virtual void Draw(BView* container, BRect updateRect); 68 69 virtual void MouseDown(BPoint where, uint32 buttons, 70 int32 modifiers); 71 virtual void MouseUp(BPoint where, uint32 buttons, 72 int32 modifiers); 73 virtual void MouseMoved(BPoint where, uint32 buttons, 74 int32 modifiers); 75 76 virtual void AddedToContainer(); 77 virtual void RemovingFromContainer(); 78 79 virtual void FrameChanged(BRect oldFrame, BRect newFrame); 80 81 virtual void Layout(); 82 83 protected: 84 void _AddedToParent(View* parent); 85 void _RemovingFromParent(); 86 87 void _AddedToContainer(BView* container); 88 void _RemovingFromContainer(); 89 90 void _Draw(BView* container, BRect updateRect); 91 92 private: 93 BRect fFrame; 94 BView* fContainer; 95 View* fParent; 96 BList fChildren; 97 rgb_color fViewColor; 98 bool fLayoutValid; 99 }; 100 101 #endif // WIDGET_LAYOUT_TEST_VIEW_H 102