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// ParameterWindow.h (Cortex/ParameterWindow)
33//
34// * PURPOSE
35//	 Window subclass to contain BMediaTheme generated 'parameter
36//	 views' and offers elegant resizing/zooming behaviour.
37//
38//	 The ParameterWindow currently listens to the MediaRoster for
39// 	 changes of the parameter web, but this should change when the
40//   provided BMediaTheme becomes more 'intelligent'.
41//
42//	 Support for selecting alternate themes is planned, but not
43//	 yet finished (see the 'Themes' menu)
44//
45// * HISTORY
46//   c.lenz		24nov99		Begun
47//   c.lenz		17feb00		Added scrollbar support, migrated the
48//							basic management functionality to new
49//							class ParameterWindowManager
50//
51
52#ifndef __ParameterWindow_H__
53#define __ParameterWindow_H__
54
55// Interface Kit
56#include <Window.h>
57// Media Kit
58#include <MediaNode.h>
59
60class BMediaTheme;
61class BMessenger;
62
63#include "cortex_defs.h"
64__BEGIN_CORTEX_NAMESPACE
65
66class NodeRef;
67
68class ParameterWindow :
69	public		BWindow {
70
71public:						// *** messages
72
73	enum message_t {
74
75		// OUTBOUND
76		// fields:
77		//	B_INT32_TYPE		"nodeID
78		M_CLOSED = ParameterWindow_message_base,
79
80		// OUTBOUND
81		// fields:
82		//	B_INT32_TYPE		"nodeID"
83		//  B_MESSENGER_TYPE	"messenger"
84		M_CONTROL_PANEL_STARTED,
85
86		// INBOUND
87		// fields:
88		//	B_BOOL_TYPE			"replace"
89		M_START_CONTROL_PANEL,
90
91		// INBOUND
92		// fields:
93		//  B_INT32_TYPE		"themeID"
94		M_THEME_SELECTED
95	};
96
97public:						// *** ctor/dtor
98
99							ParameterWindow(
100								BPoint position,
101								live_node_info &nodeInfo,
102								BMessenger *notifyTarget = 0);
103
104	virtual					~ParameterWindow();
105
106public:						// *** BWindow impl
107
108	// remember that frame was changed manually
109	virtual void			FrameResized(
110								float width,
111								float height);
112
113	// closes the window when the node is released
114	virtual void			MessageReceived(
115								BMessage *message);
116
117	// stop watching the MediaRoster, tell the notifyTarget
118	virtual bool			QuitRequested();
119
120	// extend basic Zoom() functionality to 'minimize' the
121	// window when currently at max size
122	virtual void			Zoom(
123								BPoint origin,
124								float width,
125								float height);
126
127private:					// *** internal operations
128
129	// is called from the ctor for window-positioning
130	void					_init();
131
132	// adds or updates the parameter view using the given
133	// theme
134	void					_updateParameterView(
135								BMediaTheme *theme = 0);
136
137	// resizes the window to fit in the current screen rect
138	void					_constrainToScreen();
139
140	// tries to start the nodes control panel through the
141	// MediaRoster
142	status_t				_startControlPanel();
143
144private:					// *** data members
145
146	media_node				m_node;
147
148	BView				   *m_parameters;
149
150	BMessenger			   *m_notifyTarget;
151
152	BRect					m_manualSize;
153
154	BRect					m_idealSize;
155
156	bool					m_zoomed;
157
158	bool					m_zooming;
159};
160
161__END_CORTEX_NAMESPACE
162#endif /* __ParameterWindow_H__ */
163