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// ParameterWindowManager.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 __ParameterWindowManager_H__
45#define __ParameterWindowManager_H__
46
47#include <Looper.h>
48#include <Point.h>
49
50class BList;
51class BWindow;
52
53#include "cortex_defs.h"
54__BEGIN_CORTEX_NAMESPACE
55
56class NodeRef;
57
58class ParameterWindowManager :
59	public	BLooper {
60
61public:								// *** constants
62
63	// the screen position where the first window should
64	// be displayed
65	static const BPoint				M_INIT_POSITION;
66
67	// horizontal/vertical offset by which subsequent
68	// parameter windows positions are shifted
69	static const BPoint 			M_DEFAULT_OFFSET;
70
71private:							// *** ctor/dtor
72
73	// hidden ctor; is called only from inside Instance()
74									ParameterWindowManager();
75
76public:
77
78	// quits all registered parameter windows and control
79	// panels
80	virtual							~ParameterWindowManager();
81
82public:								// *** singleton access
83
84	// access to the one and only instance of this class
85	static ParameterWindowManager  *Instance();
86
87	// will delete the singleton instance and take down all
88	// open windows
89	static void						shutDown();
90
91public:								// *** operations
92
93	// request a ParameterWindow to be openened for the given
94	// NodeRef; registeres the window
95	status_t						openWindowFor(
96										const NodeRef *ref);
97
98	// request to call StartControlPanel() for the given
99	// NodeRef; registeres the panels messenger
100	status_t						startControlPanelFor(
101										const NodeRef *ref);
102
103public:								// *** BLooper impl
104
105	virtual void					MessageReceived(
106										BMessage *message);
107
108private:							// *** internal operations
109
110	// ParameterWindow management
111	bool							_addWindowFor(
112										const NodeRef *ref,
113										BWindow *window);
114	bool							_findWindowFor(
115										int32 nodeID,
116										BWindow **outWindow);
117	void							_removeWindowFor(
118										int32 nodeID);
119
120	// ControlPanel management
121	bool							_addPanelFor(
122										int32 id,
123										const BMessenger &messenger);
124	bool							_findPanelFor(
125										int32 nodeID,
126										BMessenger *outMessenger);
127	void							_removePanelFor(
128										int32 nodeID);
129
130private:							// *** data members
131
132	// a list of window_map_entry objects, ie parameter windows
133	// identified by the node_id
134	BList						   *m_windowList;
135
136	// a list of window_map_entry objects, this time for
137	// node control panels
138	BList						   *m_panelList;
139
140	// the BPoint at which the last InfoWindow was initially
141	// opened
142	BPoint							m_lastWindowPosition;
143
144private:							// *** static members
145
146	// the magic singleton instance
147	static ParameterWindowManager  *s_instance;
148};
149
150__END_CORTEX_NAMESPACE
151#endif /*__ParameterWindowManager_H__*/
152