1 2 #ifndef __LAYER_H__ 3 #define __LAYER_H__ 4 5 #include <OS.h> 6 #include <Region.h> 7 #include <Rect.h> 8 #include <GraphicsDefs.h> 9 10 class MyView; 11 12 class Layer 13 { 14 public: 15 Layer(BRect frame, const char* name, uint32 rm, uint32 flags, rgb_color c); 16 virtual ~Layer(); 17 18 void AddLayer(Layer* layer); 19 bool RemLayer(Layer* layer); 20 21 void MoveBy(float dx, float dy); 22 void ResizeBy(float dx, float dy); 23 void ScrollBy(float dx, float dy); 24 25 bool IsHidden() const; 26 void Hide(); 27 void Show(); 28 29 void Invalidate( const BRegion &invalid, 30 const Layer *startFrom = NULL); 31 32 virtual void MovedByHook(float dx, float dy) { } 33 virtual void ResizedByHook(float dx, float dy, bool automatic) { } 34 virtual void ScrolledByHook(float dx, float dy) { } 35 36 Layer* BottomChild() const; 37 Layer* TopChild() const; 38 Layer* UpperSibling() const; 39 Layer* LowerSibling() const; 40 41 void RebuildVisibleRegions( const BRegion &invalid, 42 const Layer *startFrom); 43 void ConvertToScreen2(BRect* rect) const; 44 void ConvertToScreen2(BRegion* reg) const; 45 MyView* GetRootLayer() const; 46 void SetRootLayer(MyView* view) { fView = view; } 47 48 BRegion* Visible() { return &fVisible; } 49 BRegion* FullVisible() { return &fFullVisible; } 50 void GetWantedRegion(BRegion ®); 51 52 BRect Frame() const { return fFrame; } 53 BRect Bounds() const { BRect r(fFrame); 54 r.OffsetTo(fOrigin); 55 return r; } 56 const char* Name() const { return fName; } 57 Layer* Parent() const { return fParent; } 58 void PrintToStream() const; 59 bool IsTopLayer() const { return fView? true: false; } 60 61 rgb_color HighColor() const { return fColor; } 62 63 void rebuild_visible_regions(const BRegion &invalid, 64 const BRegion &parentLocalVisible, 65 const Layer *startFrom); 66 protected: 67 rgb_color fColor; 68 69 private: 70 virtual bool alter_visible_for_children(BRegion ®ion); 71 virtual void get_user_regions(BRegion ®); 72 73 void clear_visible_regions(); 74 void resize_layer_frame_by(float x, float y); 75 void rezize_layer_redraw_more(BRegion ®, float dx, float dy); 76 void resize_layer_full_update_on_resize(BRegion ®, float dx, float dy); 77 78 char fName[50]; 79 BRegion fVisible; 80 BRegion fFullVisible; 81 82 BRect fFrame; 83 BPoint fOrigin; 84 uint32 fResizeMode; 85 86 Layer* fBottom; 87 Layer* fUpper; 88 Layer* fLower; 89 Layer* fTop; 90 Layer* fParent; 91 mutable Layer* fCurrent; 92 93 uint32 fFlags; 94 bool fHidden; 95 96 MyView* fView; 97 }; 98 99 #endif