xref: /haiku/headers/os/interface/ChannelControl.h (revision 3be9edf8da228afd9fec0390f408c964766122aa)
1 /*
2  * Copyright 2008-2009, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _CHANNEL_CONTROL_H
6 #define _CHANNEL_CONTROL_H
7 
8 //! BChannelControl is the base class for controls that have several
9 // independent values, with minima and maxima.
10 
11 #include <Control.h>
12 #include <String.h>
13 
14 class BChannelControl : public BControl {
15 public:
16 								BChannelControl(BRect frame, const char* name,
17 									const char* label, BMessage* model,
18 									int32 channelCount = 1,
19 									uint32 resizeFlags
20 										= B_FOLLOW_LEFT | B_FOLLOW_TOP,
21 									uint32 viewFlags = B_WILL_DRAW);
22 								BChannelControl(const char* name,
23 									const char* label, BMessage* model,
24 									int32 channelCount = 1,
25 									uint32 viewFlags = B_WILL_DRAW);
26 								BChannelControl(BMessage* archive);
27 	virtual						~BChannelControl();
28 
29 	virtual	status_t			Archive(BMessage* into, bool deep = true) const;
30 
31 	virtual	void				Draw(BRect updateRect) = 0;
32 	virtual	void				MouseDown(BPoint where) = 0;
33 	virtual	void				KeyDown(const char* bytes, int32 size) = 0;
34 
35 	virtual	void				FrameResized(float width, float height);
36 	virtual	void				SetFont(const BFont* font,
37 									uint32 mask = B_FONT_ALL);
38 
39 	virtual	void				AttachedToWindow();
40 	virtual	void				DetachedFromWindow();
41 	virtual	void				ResizeToPreferred();
42 	virtual	void				GetPreferredSize(float* width,
43 									float* height) = 0;
44 
45 	virtual	void				MessageReceived(BMessage* message);
46 
47 	virtual	BHandler*			ResolveSpecifier(BMessage* message, int32 index,
48 									BMessage* specifier, int32 form,
49 									const char* property);
50 	virtual	status_t			GetSupportedSuites(BMessage* data);
51 
52 	virtual	void				SetModificationMessage(BMessage* message);
53 			BMessage*			ModificationMessage() const;
54 
55 	virtual	status_t			Invoke(BMessage* withMessage = NULL);
56 
57 	//! These methods are similar to Invoke() Invoke() and InvokeNotify(), but
58 	// include additional information about all of the channels in the control.
59 	virtual	status_t			InvokeChannel(BMessage* message = NULL,
60 									int32 fromChannel = 0,
61 									int32 channelCount = -1,
62 									const bool* _mask = NULL);
63 			status_t			InvokeNotifyChannel(BMessage* message = NULL,
64 									uint32 kind = B_CONTROL_INVOKED,
65 									int32 fromChannel = 0,
66 									int32 channelCount = -1,
67 									const bool* _mask = NULL);
68 
69 	virtual	void				SetValue(int32 value);
70 		// SetCurrentChannel() determines which channel
71 	virtual	status_t			SetCurrentChannel(int32 index);
72 			int32				CurrentChannel() const;
73 
74 	virtual	int32				CountChannels() const;
75 	virtual	int32				MaxChannelCount() const = 0;
76 	virtual	status_t			SetChannelCount(int32 count);
77 			int32				ValueFor(int32 channel) const;
78 	virtual	int32				GetValue(int32* _values, int32 fromChannel,
79 									int32 channelCount) const;
80 			status_t			SetValueFor(int32 channel, int32 value);
81 	virtual	status_t			SetValue(int32 fromChannel, int32 channelCount,
82 									const int32* values);
83 			status_t			SetAllValue(int32 values);
84 			status_t			SetLimitsFor(int32 channel, int32 minimum,
85 									int32 maximum);
86 			status_t			GetLimitsFor(int32 channel, int32* _minimum,
87 									int32* _maximum) const ;
88 	virtual	status_t			SetLimitsFor(int32 fromChannel,
89 									int32 channelCount, const int32* minima,
90 									const int32* maxima);
91 	virtual	status_t			GetLimitsFor(int32 fromChannel,
92 									int32 channelCount, int32* minima,
93 									int32* maxima) const;
94 			status_t			SetLimits(int32 minimum, int32 maximum);
95 			status_t			GetLimits(int32* _minimum,
96 									int32* _maximum) const;
97 
98 	virtual	bool				SupportsIndividualLimits() const = 0;
99 	virtual	status_t			SetLimitLabels(const char* minLabel,
100 									const char* maxLabel);
101 			const char* 		MinLimitLabel() const;
102 			const char* 		MaxLimitLabel() const;
103 	virtual	status_t			SetLimitLabelsFor(int32 channel,
104 									const char* minLabel, const char* maxLabel);
105 	virtual	status_t			SetLimitLabelsFor(int32 fromChannel,
106 									int32 channelCount, const char* minLabel,
107 									const char* maxLabel);
108 			const char*			MinLimitLabelFor(int32 channel) const;
109 			const char*			MaxLimitLabelFor(int32 channel) const;
110 private:
111 	// Forbidden (and unimplemented)
112 								BChannelControl(const BChannelControl& other);
113 			BChannelControl&	operator=(const BChannelControl& other);
114 
115 	virtual	void				_Reserverd_ChannelControl_0(void *, ...);
116 	virtual	void				_Reserverd_ChannelControl_1(void *, ...);
117 	virtual	void				_Reserverd_ChannelControl_2(void *, ...);
118 	virtual	void				_Reserverd_ChannelControl_3(void *, ...);
119 	virtual	void				_Reserverd_ChannelControl_4(void *, ...);
120 	virtual	void				_Reserverd_ChannelControl_5(void *, ...);
121 	virtual	void				_Reserverd_ChannelControl_6(void *, ...);
122 	virtual	void				_Reserverd_ChannelControl_7(void *, ...);
123 	virtual	void				_Reserverd_ChannelControl_8(void *, ...);
124 	virtual	void				_Reserverd_ChannelControl_9(void *, ...);
125 	virtual	void				_Reserverd_ChannelControl_10(void *, ...);
126 	virtual	void				_Reserverd_ChannelControl_11(void *, ...);
127 
128 protected:
129 	inline	int32* const&		MinLimitList() const;
130 	inline	int32* const&		MaxLimitList() const;
131 	inline	int32* const&		ValueList() const;
132 
133 private:
134 			int32				fChannelCount;
135 			int32				fCurrentChannel;
136 			int32*				fChannelMin;
137 			int32*				fChannelMax;
138 			int32*				fChannelValues;
139 
140 			BString				fMinLabel;
141 			BString				fMaxLabel;
142 
143 			void*				fMultiLabels;
144 
145 			BMessage*			fModificationMsg;
146 
147 			uint32				_reserved_[15];
148 
149 			status_t			StuffValues(int32 fromChannel,
150 									int32 channelCount, const int32* values);
151 };
152 
153 
154 inline int32* const&
155 BChannelControl::MinLimitList() const
156 {
157 	return fChannelMin;
158 }
159 
160 
161 inline int32* const&
162 BChannelControl::MaxLimitList() const
163 {
164 	return fChannelMax;
165 }
166 
167 
168 inline int32* const&
169 BChannelControl::ValueList() const
170 {
171 	return fChannelValues;
172 }
173 
174 
175 #endif // _CHANNEL_CONTROL_H
176