1/*
2 * Copyright (c) 1999-2000, Eric Moon.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions, and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions, and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * 3. The name of the author may not be used to endorse or promote products
17 *    derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31
32// InfoWindowManager.h
33//
34// * PURPOSE
35//	 Manages all the ParameterWindows and control panels.
36//   Will not let you open multiple windows referring to
37//	 the same node, and takes care of quitting them all
38//	 when shut down.
39//
40// * HISTORY
41//   c.lenz		17feb2000		Begun
42//
43
44#ifndef __InfoWindowManager_H__
45#define __InfoWindowManager_H__
46
47#include <Looper.h>
48#include <Point.h>
49
50class BList;
51class BWindow;
52
53#include "cortex_defs.h"
54
55struct dormant_node_info;
56struct media_destination;
57struct media_input;
58struct media_output;
59struct media_source;
60
61__BEGIN_CORTEX_NAMESPACE
62
63class Connection;
64class NodeRef;
65
66class InfoWindowManager :
67	public	BLooper {
68
69public:								// *** constants
70
71	// the screen position where the first window should
72	// be displayed
73	static const BPoint				M_INIT_POSITION;
74
75	// horizontal/vertical offset by which subsequent
76	// windows positions are shifted
77	static const BPoint 			M_DEFAULT_OFFSET;
78
79	enum message_t {
80									M_INFO_WINDOW_REQUESTED = InfoView_message_base,
81
82									M_LIVE_NODE_WINDOW_CLOSED,
83
84									M_DORMANT_NODE_WINDOW_CLOSED,
85
86									M_CONNECTION_WINDOW_CLOSED,
87
88									M_INPUT_WINDOW_CLOSED,
89
90									M_OUTPUT_WINDOW_CLOSED
91	};
92
93private:							// *** ctor/dtor
94
95	// hidden ctor; is called only from inside Instance()
96									InfoWindowManager();
97
98public:
99
100	// quits all registered info windows
101	virtual							~InfoWindowManager();
102
103public:								// *** singleton access
104
105	// access to the one and only instance of this class
106	static InfoWindowManager	   *Instance();
107
108	// will delete the singleton instance and take down all
109	// open windows
110	static void						shutDown();
111
112public:								// *** operations
113
114	status_t						openWindowFor(
115										const NodeRef *ref);
116
117	status_t						openWindowFor(
118										const dormant_node_info &info);
119
120	status_t						openWindowFor(
121										const Connection &connection);
122
123	status_t						openWindowFor(
124										const media_input &input);
125
126	status_t						openWindowFor(
127										const media_output &output);
128
129public:								// *** BLooper impl
130
131	virtual void					MessageReceived(
132										BMessage *message);
133
134private:							// *** internal operations
135
136	// management of windows for live nodes
137	bool							_addWindowFor(
138										const NodeRef *ref,
139										BWindow *window);
140	bool							_findWindowFor(
141										int32 nodeID,
142										BWindow **outWindow);
143	void							_removeWindowFor(
144										int32 nodeID);
145
146	// management of windows for dormant nodes
147	bool							_addWindowFor(
148										const dormant_node_info &info,
149										BWindow *window);
150	bool							_findWindowFor(
151										const dormant_node_info &info,
152										BWindow **outWindow);
153	void							_removeWindowFor(
154										const dormant_node_info &info);
155
156	// management of windows for connections
157	bool							_addWindowFor(
158										const Connection &connection,
159										BWindow *window);
160	bool							_findWindowFor(
161										const media_source &source,
162										const media_destination &destination,
163										BWindow **outWindow);
164	void							_removeWindowFor(
165										const media_source &source,
166										const media_destination &destination);
167
168	// management of windows for media_inputs
169	bool							_addWindowFor(
170										const media_input &input,
171										BWindow *window);
172	bool							_findWindowFor(
173										const media_destination &destination,
174										BWindow **outWindow);
175	void							_removeWindowFor(
176										const media_destination &destination);
177
178	// management of windows for media_outputs
179	bool							_addWindowFor(
180										const media_output &output,
181										BWindow *window);
182	bool							_findWindowFor(
183										const media_source &source,
184										BWindow **outWindow);
185	void							_removeWindowFor(
186										const media_source &source);
187
188private:							// *** data members
189
190	// list of all currently open windows about live nodes
191	BList						   *m_liveNodeWindows;
192
193	// list of all currently open windows about dormant nodes
194	BList						   *m_dormantNodeWindows;
195
196	// list of all currently open windows about connections
197	BList						   *m_connectionWindows;
198
199	// list of all currently open windows about media_inputs
200	BList						   *m_inputWindows;
201
202	// list of all currently open windows about media_outputs
203	BList						   *m_outputWindows;
204
205	// the BPoint at which the last InfoWindow was initially
206	// opened
207	BPoint							m_nextWindowPosition;
208
209private:							// *** static members
210
211	// the magic singleton instance
212	static InfoWindowManager  *s_instance;
213};
214
215__END_CORTEX_NAMESPACE
216#endif /*__InfoWindowManager_H__*/
217