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