xref: /haiku/src/apps/cortex/ParameterView/ParameterWindowManager.h (revision 1214ef1b2100f2b3299fc9d8d6142e46f70a4c3f)
1 // ParameterWindowManager.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 __ParameterWindowManager_H__
14 #define __ParameterWindowManager_H__
15 
16 #include <Looper.h>
17 #include <Point.h>
18 
19 class BList;
20 class BWindow;
21 
22 #include "cortex_defs.h"
23 __BEGIN_CORTEX_NAMESPACE
24 
25 class NodeRef;
26 
27 class ParameterWindowManager :
28 	public	BLooper {
29 
30 public:								// *** constants
31 
32 	// the screen position where the first window should
33 	// be displayed
34 	static const BPoint				M_INIT_POSITION;
35 
36 	// horizontal/vertical offset by which subsequent
37 	// parameter windows positions are shifted
38 	static const BPoint 			M_DEFAULT_OFFSET;
39 
40 private:							// *** ctor/dtor
41 
42 	// hidden ctor; is called only from inside Instance()
43 									ParameterWindowManager();
44 
45 public:
46 
47 	// quits all registered parameter windows and control
48 	// panels
49 	virtual							~ParameterWindowManager();
50 
51 public:								// *** singleton access
52 
53 	// access to the one and only instance of this class
54 	static ParameterWindowManager  *Instance();
55 
56 	// will delete the singleton instance and take down all
57 	// open windows
58 	static void						shutDown();
59 
60 public:								// *** operations
61 
62 	// request a ParameterWindow to be openened for the given
63 	// NodeRef; registeres the window
64 	status_t						openWindowFor(
65 										const NodeRef *ref);
66 
67 	// request to call StartControlPanel() for the given
68 	// NodeRef; registeres the panels messenger
69 	status_t						startControlPanelFor(
70 										const NodeRef *ref);
71 
72 public:								// *** BLooper impl
73 
74 	virtual void					MessageReceived(
75 										BMessage *message);
76 
77 private:							// *** internal operations
78 
79 	// ParameterWindow management
80 	bool							_addWindowFor(
81 										const NodeRef *ref,
82 										BWindow *window);
83 	bool							_findWindowFor(
84 										int32 nodeID,
85 										BWindow **outWindow);
86 	void							_removeWindowFor(
87 										int32 nodeID);
88 
89 	// ControlPanel management
90 	bool							_addPanelFor(
91 										int32 id,
92 										const BMessenger &messenger);
93 	bool							_findPanelFor(
94 										int32 nodeID,
95 										BMessenger *outMessenger);
96 	void							_removePanelFor(
97 										int32 nodeID);
98 
99 private:							// *** data members
100 
101 	// a list of window_map_entry objects, ie parameter windows
102 	// identified by the node_id
103 	BList						   *m_windowList;
104 
105 	// a list of window_map_entry objects, this time for
106 	// node control panels
107 	BList						   *m_panelList;
108 
109 	// the BPoint at which the last InfoWindow was initially
110 	// opened
111 	BPoint							m_lastWindowPosition;
112 
113 private:							// *** static members
114 
115 	// the magic singleton instance
116 	static ParameterWindowManager  *s_instance;
117 };
118 
119 __END_CORTEX_NAMESPACE
120 #endif /*__ParameterWindowManager_H__*/
121