vfs: check userland buffers before reading them.
[haiku.git] / src / tests / servers / app / playground / States.h
blob37de6d5f75dc6f1b24f6f23fbe3b45a4f20e132d
1 // States.h
3 #ifndef STATES_H
4 #define STATES_H
6 #include <GraphicsDefs.h>
7 #include <Point.h>
9 class BView;
11 enum {
12 OBJECT_LINE = 0,
13 OBJECT_RECT,
14 OBJECT_ROUND_RECT,
15 OBJECT_ELLIPSE,
16 OBJECT_TRIANGLE,
17 OBJECT_SHAPE,
20 class State {
21 public:
22 State();
23 virtual ~State();
25 void Init(rgb_color color, drawing_mode mode,
26 bool fill, float penSize);
28 void MouseDown(BPoint where);
29 void MouseUp();
30 void MouseMoved(BPoint where);
31 bool IsTracking() const
32 { return fTracking; }
34 void SetColor(rgb_color color);
35 rgb_color Color() const
36 { return fColor; }
37 void SetDrawingMode(drawing_mode mode);
38 void SetFill(bool fill);
39 void SetPenSize(float penSize);
41 void SetEditing(bool editing);
43 BRect Bounds() const;
44 virtual void Draw(BView* view) const;
45 virtual bool SupportsFill() const
46 { return true; }
48 static State* StateFor(int32 objectType,
49 rgb_color color, drawing_mode mode,
50 bool fill, float penSize);
52 protected:
53 BRect _ValidRect() const;
54 void _RenderDot(BView* view, BPoint where) const;
55 void _AdjustViewState(BView* view) const;
57 bool _HitTest(BPoint where, BPoint point) const;
59 bool fValid;
61 bool fEditing;
63 enum {
64 TRACKING_NONE = 0,
65 TRACKING_START,
66 TRACKING_END
69 uint32 fTracking;
70 BPoint fClickOffset;
72 BPoint fStartPoint;
73 BPoint fEndPoint;
75 rgb_color fColor;
76 drawing_mode fDrawingMode;
77 bool fFill;
78 float fPenSize;
81 #endif // STATES_H