xref: /haiku/src/apps/cortex/RouteApp/StatusView.h (revision d3d8b26997fac34a84981e6d2b649521de2cc45a)
1 // StatusView.h (Cortex/ParameterWindow)
2 //
3 // * PURPOSE
4 //	 a small view to display a short message string with
5 //   an icon. for error messages, it will play a sound for
6 //   catching the users attention. messages will decay slowly
7 //   (become fully transparent). all this to avoid modal alert
8 //   boxes for error notification.
9 //
10 // * TODO
11 //   reduce flicker while message decay
12 //
13 // * HISTORY
14 //   c.lenz		21may00		Begun
15 //
16 
17 #ifndef __StatusView_H__
18 #define __StatusView_H__
19 
20 // Interface Kit
21 #include <StringView.h>
22 // Support Kit
23 #include <String.h>
24 
25 #include "cortex_defs.h"
26 
27 class BBitmap;
28 class BMessageRunner;
29 
30 __BEGIN_CORTEX_NAMESPACE
31 
32 class RouteAppNodeManager;
33 
34 class StatusView :
35 	public BStringView {
36 
37 public:					// *** ctor/dtor
38 
39 						StatusView(
40 							BRect frame,
41 							RouteAppNodeManager *manager,
42 							BScrollBar *scrollBar = 0);
43 
44 	virtual				~StatusView();
45 
46 public:					// *** BScrollView impl.
47 
48 	virtual void		AttachedToWindow();
49 
50 	virtual void		Draw(
51 							BRect updateRect);
52 
53 	virtual void		FrameResized(
54 							float width,
55 							float height);
56 
57 	virtual void		MessageReceived(
58 							BMessage *message);
59 
60 	virtual void		MouseDown(
61 							BPoint point);
62 
63 	virtual void		MouseMoved(
64 							BPoint point,
65 							uint32 transit,
66 							const BMessage *message);
67 
68 	virtual void		MouseUp(
69 							BPoint point);
70 
71 //	virtual void		Pulse();
72 
73 public:					// *** operations
74 
75 	void				drawInto(
76 							BView *view,
77 							BRect updateRect);
78 
79 	void				setMessage(
80 							BString &title,
81 							BString &details,
82 							status_t error = B_OK);
83 
84 	void				setErrorMessage(
85 							BString text,
86 							bool error = false);
87 
88 	void				startFade();
89 
90 	void				fadeTick();
91 
92 	void				allocBackBitmap(
93 							float width,
94 							float height);
95 
96 	void				freeBackBitmap();
97 
98 private:					// *** data members
99 
100 	// the sibling scrollbar which should be resized by the
101 	// status view
102 	BScrollBar *			m_scrollBar;
103 
104 	BBitmap	*				m_icon;
105 
106 	// from 0.0 to 1.0
107 	float					m_opacity;
108 	int32					m_decayDelay;
109 	BMessageRunner *		m_clock;
110 
111 	// untruncated string
112 	BString					m_fullText;
113 
114 	// is being resized
115 	bool					m_dragging;
116 
117 	// offscreen buffer
118 	BBitmap *				m_backBitmap;
119 	BView *					m_backView;
120 	bool					m_dirty;
121 
122 	RouteAppNodeManager *	m_manager;
123 };
124 
125 __END_CORTEX_NAMESPACE
126 #endif /* __StatusView_H__ */
127