xref: /haiku/headers/os/interface/ChannelSlider.h (revision 4afae676ad98b8f1e219f704dfc9c8507bce106e)
1 /*******************************************************************************
2 /
3 /	File:			ChannelSlider.h
4 /
5 /   Description:    BChannelSlider implements a slider which can have a number
6 /					of (on-screen) related values. A typical use is for a stereo
7 /					volume control.
8 /
9 /	Copyright 1998-99, Be Incorporated, All Rights Reserved
10 /
11 *******************************************************************************/
12 
13 #if !defined(_CHANNEL_SLIDER_H)
14 #define _CHANNEL_SLIDER_H
15 
16 #include <ChannelControl.h>
17 
18 class BChannelSlider :
19 	public BChannelControl
20 {
21 public:
22 							BChannelSlider(
23 									BRect area,
24 									const char * name,
25 									const char * label,
26 									BMessage * model,
27 									int32 channels = 1,
28 									uint32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP,
29 									uint32 flags = B_WILL_DRAW);
30 							BChannelSlider(
31 									BRect area,
32 									const char * name,
33 									const char * label,
34 									BMessage * model,
35 									orientation o,
36 									int32 channels = 1,
37 									uint32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP,
38 									uint32 flags = B_WILL_DRAW);
39 							BChannelSlider(
40 									BMessage * from);
41 virtual						~BChannelSlider();
42 
43 static	BArchivable *	Instantiate(BMessage * from);
44 virtual	status_t		Archive(BMessage * into, bool deep = true) const;
45 
46 virtual	orientation		Orientation() const;
47 		void			SetOrientation(orientation o);
48 
49 virtual	int32			MaxChannelCount() const;
50 virtual	bool			SupportsIndividualLimits() const;
51 
52 virtual	void			AttachedToWindow();
53 virtual	void			AllAttached();
54 virtual	void			DetachedFromWindow();
55 virtual	void			AllDetached();
56 
57 virtual	void			MessageReceived(BMessage *msg);
58 
59 virtual	void 			Draw(BRect area);
60 virtual	void			MouseDown(BPoint where);
61 virtual void			MouseUp(BPoint pt);
62 virtual void			MouseMoved( BPoint pt,
63 									uint32 code,
64 									const BMessage * message);
65 virtual	void			WindowActivated(bool state);
66 virtual	void			KeyDown(const char *bytes, int32 numBytes);
67 virtual	void			KeyUp(const char *bytes, int32 numBytes);
68 virtual	void			FrameResized(float width, float height);
69 
70 virtual void			SetFont(const BFont *font, uint32 mask = B_FONT_ALL);
71 virtual	void			MakeFocus(bool focusState = true);
72 
73 virtual void			SetEnabled(bool on);
74 
75 virtual	void			GetPreferredSize(float *width, float *height);
76 
77 virtual BHandler		*ResolveSpecifier(BMessage *msg,
78 										int32 index,
79 										BMessage *specifier,
80 										int32 form,
81 										const char *property);
82 virtual status_t		GetSupportedSuites(BMessage *data);
83 
84 // Perform rendering for an entire slider channel.
85 virtual void			DrawChannel(BView* into,
86 									int32 channel,
87 									BRect area,
88 									bool pressed);
89 
90 // Draw the groove that appears behind a channel's thumb.
91 virtual void			DrawGroove(	BView* into,
92 									int32 channel,
93 									BPoint tl,
94 									BPoint br);
95 
96 // Draw the thumb for a single channel.
97 virtual void			DrawThumb( BView* into,
98 								   int32 channel,
99 								   BPoint where,
100 								   bool pressed );
101 
102 virtual	const BBitmap *	ThumbFor(int32 channel, bool pressed);
103 virtual	BRect			ThumbFrameFor(int32 channel);
104 virtual	float			ThumbDeltaFor(int32 channel);
105 virtual	float			ThumbRangeFor(int32 channel);
106 
107 private:
108 		typedef BChannelControl inherited;
109 
110 		BChannelSlider(	/* unimplemented */
111 				const BChannelSlider &);
112 		BChannelSlider& operator=(	/* unimplemented */
113 				const BChannelSlider &);
114 
115 
116 virtual	status_t _Reserved_BChannelSlider_0(void *, ...);
117 virtual	status_t _Reserved_BChannelSlider_1(void *, ...);
118 virtual	status_t _Reserved_BChannelSlider_2(void *, ...);
119 virtual	status_t _Reserved_BChannelSlider_3(void *, ...);
120 virtual	status_t _Reserved_BChannelSlider_4(void *, ...);
121 virtual	status_t _Reserved_BChannelSlider_5(void *, ...);
122 virtual	status_t _Reserved_BChannelSlider_6(void *, ...);
123 virtual	status_t _Reserved_BChannelSlider_7(void *, ...);
124 
125 		float _m_baseline;
126 		float _m_linefeed;
127 		BBitmap * _m_left_knob;
128 		BBitmap * _m_mid_knob;
129 		BBitmap * _m_right_knob;
130 		BBitmap * _m_backing;
131 		BView * _m_backing_view;
132 		bool _m_vertical;
133 		bool _m_padding_[3];
134 		BPoint _m_click_delta;
135 
136 		int32	fCurrentChannel;
137 		bool	fAllChannels;
138 		int32*	fInitialValues;
139 		float 	fMinpoint;
140 		int32	fFocusChannel;
141 
142 		uint32 _reserved_[12];
143 
144 		void InitData();
145 
146 		void FinishChange();
147 		void UpdateFontDimens();
148 		void DrawThumbs();
149 		void DrawThumbFrame(
150 				BView * where,
151 				const BRect & area);
152 		bool Vertical();
153 		void Redraw();
154 		void MouseMovedCommon(BPoint , BPoint );
155 };
156 
157 
158 #endif /* _CHANNEL_SLIDER_H */
159