xref: /haiku/src/apps/cortex/DiagramView/DiagramBox.h (revision 1214ef1b2100f2b3299fc9d8d6142e46f70a4c3f)
1 // DiagramBox.h (Cortex/DiagramView.h)
2 //
3 // * HISTORY
4 //   c.lenz		25sep99		Begun
5 //
6 #ifndef DIAGRAM_BOX_H
7 #define DIAGRAM_BOX_H
8 
9 #include "cortex_defs.h"
10 #include "DiagramItem.h"
11 #include "DiagramItemGroup.h"
12 
13 #include <Region.h>
14 #include <Window.h>
15 
16 
17 __BEGIN_CORTEX_NAMESPACE
18 
19 
20 class DiagramBox : public DiagramItem, public DiagramItemGroup {
21 	public:
22 		DiagramBox(BRect frame, uint32 flags = 0);
23 		virtual ~DiagramBox();
24 
25 		virtual void DrawBox() = 0;
26 			// a hook functions that
27 			// is called from Draw() to do the actual drawing
28 
29 		// derived from DiagramItemGroup
30 
31 		virtual bool AddItem(DiagramItem *item);
32 		virtual bool RemoveItem(DiagramItem *item);
33 
34 		// derived from DiagramItem
35 
36 		// returns the Boxes frame rectangle
37 		BRect Frame() const
38 		{
39 			return fFrame;
40 		}
41 
42 		void Draw(BRect updateRect);
43 
44 		virtual void MouseDown(BPoint point, uint32 buttons, uint32 clicks);
45 		virtual void MouseOver(BPoint point, uint32 transit);
46 
47 		virtual void MessageDragged(BPoint point, uint32 transit, const BMessage *message);
48 		virtual void MessageDropped(BPoint point, BMessage *message);
49 
50 		void MoveBy(float x, float y, BRegion *updateRegion);
51 		virtual void ResizeBy(float horizontal, float vertical);
52 
53 		enum flag_t {
54 			M_DRAW_UNDER_ENDPOINTS = 0x1
55 		};
56 
57 	private:
58 		void _SetOwner(DiagramView *owner);
59 
60 	private:
61 		BRect fFrame;
62 			// the boxes' frame rectangle
63 
64 		// flags:
65 		// 	M_DRAW_UNDER_ENDPOINTS -  don't remove EndPoint frames from
66 		//							the clipping region
67 		uint32 fFlags;
68 };
69 
70 __END_CORTEX_NAMESPACE
71 
72 #endif	// DIAGRAM_BOX_H
73