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