xref: /haiku/src/apps/cortex/InfoView/InfoWindowManager.h (revision d9cebac2b77547b7064f22497514eecd2d047160)
1 // InfoWindowManager.h
2 //
3 // * PURPOSE
4 //	 Manages all the ParameterWindows and control panels.
5 //   Will not let you open multiple windows referring to
6 //	 the same node, and takes care of quitting them all
7 //	 when shut down.
8 //
9 // * HISTORY
10 //   c.lenz		17feb2000		Begun
11 //
12 
13 #ifndef __InfoWindowManager_H__
14 #define __InfoWindowManager_H__
15 
16 #include <Looper.h>
17 #include <Point.h>
18 
19 class BList;
20 class BWindow;
21 
22 #include "cortex_defs.h"
23 
24 struct dormant_node_info;
25 struct media_destination;
26 struct media_input;
27 struct media_output;
28 struct media_source;
29 
30 __BEGIN_CORTEX_NAMESPACE
31 
32 class Connection;
33 class NodeRef;
34 
35 class InfoWindowManager :
36 	public	BLooper {
37 
38 public:								// *** constants
39 
40 	// the screen position where the first window should
41 	// be displayed
42 	static const BPoint				M_INIT_POSITION;
43 
44 	// horizontal/vertical offset by which subsequent
45 	// windows positions are shifted
46 	static const BPoint 			M_DEFAULT_OFFSET;
47 
48 	enum message_t {
49 									M_INFO_WINDOW_REQUESTED = InfoView_message_base,
50 
51 									M_LIVE_NODE_WINDOW_CLOSED,
52 
53 									M_DORMANT_NODE_WINDOW_CLOSED,
54 
55 									M_CONNECTION_WINDOW_CLOSED,
56 
57 									M_INPUT_WINDOW_CLOSED,
58 
59 									M_OUTPUT_WINDOW_CLOSED
60 	};
61 
62 private:							// *** ctor/dtor
63 
64 	// hidden ctor; is called only from inside Instance()
65 									InfoWindowManager();
66 
67 public:
68 
69 	// quits all registered info windows
70 	virtual							~InfoWindowManager();
71 
72 public:								// *** singleton access
73 
74 	// access to the one and only instance of this class
75 	static InfoWindowManager	   *Instance();
76 
77 	// will delete the singleton instance and take down all
78 	// open windows
79 	static void						shutDown();
80 
81 public:								// *** operations
82 
83 	status_t						openWindowFor(
84 										const NodeRef *ref);
85 
86 	status_t						openWindowFor(
87 										const dormant_node_info &info);
88 
89 	status_t						openWindowFor(
90 										const Connection &connection);
91 
92 	status_t						openWindowFor(
93 										const media_input &input);
94 
95 	status_t						openWindowFor(
96 										const media_output &output);
97 
98 public:								// *** BLooper impl
99 
100 	virtual void					MessageReceived(
101 										BMessage *message);
102 
103 private:							// *** internal operations
104 
105 	// management of windows for live nodes
106 	bool							_addWindowFor(
107 										const NodeRef *ref,
108 										BWindow *window);
109 	bool							_findWindowFor(
110 										int32 nodeID,
111 										BWindow **outWindow);
112 	void							_removeWindowFor(
113 										int32 nodeID);
114 
115 	// management of windows for dormant nodes
116 	bool							_addWindowFor(
117 										const dormant_node_info &info,
118 										BWindow *window);
119 	bool							_findWindowFor(
120 										const dormant_node_info &info,
121 										BWindow **outWindow);
122 	void							_removeWindowFor(
123 										const dormant_node_info &info);
124 
125 	// management of windows for connections
126 	bool							_addWindowFor(
127 										const Connection &connection,
128 										BWindow *window);
129 	bool							_findWindowFor(
130 										const media_source &source,
131 										const media_destination &destination,
132 										BWindow **outWindow);
133 	void							_removeWindowFor(
134 										const media_source &source,
135 										const media_destination &destination);
136 
137 	// management of windows for media_inputs
138 	bool							_addWindowFor(
139 										const media_input &input,
140 										BWindow *window);
141 	bool							_findWindowFor(
142 										const media_destination &destination,
143 										BWindow **outWindow);
144 	void							_removeWindowFor(
145 										const media_destination &destination);
146 
147 	// management of windows for media_outputs
148 	bool							_addWindowFor(
149 										const media_output &output,
150 										BWindow *window);
151 	bool							_findWindowFor(
152 										const media_source &source,
153 										BWindow **outWindow);
154 	void							_removeWindowFor(
155 										const media_source &source);
156 
157 private:							// *** data members
158 
159 	// list of all currently open windows about live nodes
160 	BList						   *m_liveNodeWindows;
161 
162 	// list of all currently open windows about dormant nodes
163 	BList						   *m_dormantNodeWindows;
164 
165 	// list of all currently open windows about connections
166 	BList						   *m_connectionWindows;
167 
168 	// list of all currently open windows about media_inputs
169 	BList						   *m_inputWindows;
170 
171 	// list of all currently open windows about media_outputs
172 	BList						   *m_outputWindows;
173 
174 	// the BPoint at which the last InfoWindow was initially
175 	// opened
176 	BPoint							m_nextWindowPosition;
177 
178 private:							// *** static members
179 
180 	// the magic singleton instance
181 	static InfoWindowManager  *s_instance;
182 };
183 
184 __END_CORTEX_NAMESPACE
185 #endif /*__InfoWindowManager_H__*/
186