xref: /haiku/headers/os/interface/ChannelSlider.h (revision 4b7e219688450694efc9d1890f83f816758c16d3)
1 /*
2  * Copyright 2009, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _CHANNEL_SLIDER_H
6 #define _CHANNEL_SLIDER_H
7 
8 
9 #include <ChannelControl.h>
10 
11 
12 class BChannelSlider : public BChannelControl {
13 public:
14 								BChannelSlider(BRect area, const char* name,
15 									const char* label, BMessage* message,
16 									int32 channels = 1,
17 									uint32 resizeMode
18 										= B_FOLLOW_LEFT | B_FOLLOW_TOP,
19 									uint32 flags = B_WILL_DRAW);
20 								BChannelSlider(BRect area, const char* name,
21 									const char* label, BMessage* message,
22 									orientation orientation,
23 									int32 channels = 1,
24 									uint32 resizeMode
25 										= B_FOLLOW_LEFT | B_FOLLOW_TOP,
26 									uint32 flags = B_WILL_DRAW);
27 								BChannelSlider(const char* name,
28 									const char* label, BMessage* message,
29 									orientation orientation,
30 									int32 channels = 1,
31 									uint32 flags = B_WILL_DRAW);
32 								BChannelSlider(BMessage* archive);
33 	virtual						~BChannelSlider();
34 
35 	static	BArchivable*		Instantiate(BMessage* from);
36 	virtual	status_t			Archive(BMessage* into,
37 									bool deep = true) const;
38 
39 	virtual	void				AttachedToWindow();
40 	virtual	void				AllAttached();
41 	virtual	void				DetachedFromWindow();
42 	virtual	void				AllDetached();
43 
44 	virtual	void				MessageReceived(BMessage* message);
45 
46 	virtual	void				Draw(BRect updateRect);
47 	virtual	void				MouseDown(BPoint where);
48 	virtual	void				MouseUp(BPoint where);
49 	virtual	void				MouseMoved(BPoint where, uint32 transit,
50 									const BMessage* dragMessage);
51 	virtual	void				WindowActivated(bool state);
52 	virtual	void				KeyDown(const char* bytes, int32 numBytes);
53 	virtual	void				KeyUp(const char* bytes, int32 numBytes);
54 	virtual	void				FrameResized(float width, float height);
55 
56 	virtual	void				SetFont(const BFont* font,
57 									uint32 mask = B_FONT_ALL);
58 	virtual	void				MakeFocus(bool focusState = true);
59 
60 	virtual	void				GetPreferredSize(float* _width, float* _height);
61 
62 	virtual	BHandler*			ResolveSpecifier(BMessage* message,
63 									int32 index, BMessage* specifier,
64 									int32 form, const char* property);
65 	virtual	status_t			GetSupportedSuites(BMessage* data);
66 
67 	virtual	void				SetEnabled(bool on);
68 
69 	virtual	orientation			Orientation() const;
70 			void				SetOrientation(orientation orientation);
71 
72 	virtual	int32				MaxChannelCount() const;
73 	virtual	bool				SupportsIndividualLimits() const;
74 
75 	virtual	void				DrawChannel(BView* into, int32 channel,
76 									BRect area, bool pressed);
77 
78 	virtual	void				DrawGroove(BView* into, int32 channel,
79 									BPoint leftTop, BPoint rightBottom);
80 
81 	virtual	void				DrawThumb(BView* into, int32 channel,
82 									BPoint where, bool pressed);
83 
84 	virtual	const BBitmap*		ThumbFor(int32 channel, bool pressed);
85 	virtual	BRect				ThumbFrameFor(int32 channel);
86 	virtual	float				ThumbDeltaFor(int32 channel);
87 	virtual	float				ThumbRangeFor(int32 channel);
88 
89 private:
90 	// FBC padding
91 								BChannelSlider(const BChannelSlider&);
92 			BChannelSlider&		operator=(const BChannelSlider&);
93 
94 
95 	virtual	void				_Reserved_BChannelSlider_0(void*, ...);
96 	virtual	void				_Reserved_BChannelSlider_1(void*, ...);
97 	virtual	void				_Reserved_BChannelSlider_2(void*, ...);
98 	virtual	void				_Reserved_BChannelSlider_3(void*, ...);
99 	virtual	void				_Reserved_BChannelSlider_4(void*, ...);
100 	virtual	void				_Reserved_BChannelSlider_5(void*, ...);
101 	virtual	void				_Reserved_BChannelSlider_6(void*, ...);
102 	virtual	void				_Reserved_BChannelSlider_7(void*, ...);
103 
104 private:
105 			void				_InitData();
106 			void				_FinishChange(bool update = false);
107 			void				_UpdateFontDimens();
108 			void				_DrawThumbs();
109 			void				_DrawGrooveFrame(BView* where,
110 									const BRect& area);
111 			void				_MouseMovedCommon(BPoint point, BPoint point2);
112 
113 private:
114 			float				fBaseLine;
115 			float				fLineFeed;
116 			BBitmap*			fLeftKnob;
117 			BBitmap*			fMidKnob;
118 			BBitmap*			fRightKnob;
119 			BBitmap*			fBacking;
120 			BView*				fBackingView;
121 			bool				fIsVertical;
122 			bool				_padding_[3];
123 			BPoint				fClickDelta;
124 
125 			int32				fCurrentChannel;
126 			bool				fAllChannels;
127 			int32*				fInitialValues;
128 			float				fMinPoint;
129 			int32				fFocusChannel;
130 
131 			uint32				_reserved_[12];
132 };
133 
134 
135 #endif // _CHANNEL_SLIDER_H
136