2005-01-15 04:29:19 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright 2005, Haiku Inc. All Rights Reserved.
|
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <ChannelControl.h>
|
2005-02-01 13:16:22 +00:00
|
|
|
#include <PropertyInfo.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static property_info // TODO: Finish this
|
|
|
|
|
sPropertyInfo[] = {
|
|
|
|
|
{0}
|
|
|
|
|
};
|
2005-01-15 04:29:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
BChannelControl::BChannelControl(BRect frame, const char *name, const char *label,
|
|
|
|
|
BMessage *model, int32 channel_count, uint32 resizeMode, uint32 flags)
|
2005-02-01 07:42:07 +00:00
|
|
|
: BControl(frame, name, label, model, resizeMode, flags),
|
2005-02-01 14:29:06 +00:00
|
|
|
fChannelCount(channel_count),
|
|
|
|
|
fCurrentChannel(0),
|
|
|
|
|
fChannelMin(NULL),
|
|
|
|
|
fChannelMax(NULL),
|
|
|
|
|
fChannelValues(NULL),
|
|
|
|
|
fMultiLabels(NULL),
|
2005-02-01 07:42:07 +00:00
|
|
|
fModificationMsg(NULL)
|
|
|
|
|
{
|
2005-02-01 14:29:06 +00:00
|
|
|
fChannelMin = new int32[channel_count];
|
|
|
|
|
memset(fChannelMin, 0, sizeof(int32) * channel_count);
|
2005-02-01 07:42:07 +00:00
|
|
|
|
2005-02-01 14:29:06 +00:00
|
|
|
fChannelMax = new int32[channel_count];
|
|
|
|
|
memset(fChannelMax, 100, sizeof(int32) * channel_count);
|
2005-02-01 07:42:07 +00:00
|
|
|
|
2005-02-01 14:29:06 +00:00
|
|
|
fChannelValues = new int32[channel_count];
|
|
|
|
|
memset(fChannelValues, 0, sizeof(int32) * channel_count);
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BChannelControl::BChannelControl(BMessage *archive)
|
|
|
|
|
: BControl(archive)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BChannelControl::~BChannelControl()
|
|
|
|
|
{
|
2005-02-01 14:29:06 +00:00
|
|
|
delete[] fChannelMin;
|
|
|
|
|
delete[] fChannelMax;
|
|
|
|
|
delete[] fChannelValues;
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::Archive(BMessage *into, bool deep) const
|
|
|
|
|
{
|
|
|
|
|
return B_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
BChannelControl::FrameResized(float width, float height)
|
|
|
|
|
{
|
2005-02-01 07:42:07 +00:00
|
|
|
BView::FrameResized(width, height);
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
BChannelControl::SetFont(const BFont *font, uint32 mask)
|
|
|
|
|
{
|
2005-02-01 07:42:07 +00:00
|
|
|
BView::SetFont(font, mask);
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
BChannelControl::AttachedToWindow()
|
|
|
|
|
{
|
2005-02-01 07:42:07 +00:00
|
|
|
BControl::AttachedToWindow();
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
BChannelControl::DetachedFromWindow()
|
|
|
|
|
{
|
2005-02-01 07:42:07 +00:00
|
|
|
BControl::DetachedFromWindow();
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
BChannelControl::ResizeToPreferred()
|
|
|
|
|
{
|
2005-02-01 07:42:07 +00:00
|
|
|
float width, height;
|
|
|
|
|
GetPreferredSize(&width, &height);
|
|
|
|
|
ResizeTo(width, height);
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
BChannelControl::MessageReceived(BMessage *message)
|
|
|
|
|
{
|
2005-02-01 07:42:07 +00:00
|
|
|
BControl::MessageReceived(message);
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BHandler *
|
|
|
|
|
BChannelControl::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier,
|
|
|
|
|
int32 form, const char *property)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::GetSupportedSuites(BMessage *data)
|
|
|
|
|
{
|
2005-02-01 13:16:22 +00:00
|
|
|
if (data == NULL)
|
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
|
|
|
|
|
|
data->AddString("suites", "suite/vnd.Be-channel-control");
|
|
|
|
|
|
|
|
|
|
BPropertyInfo propertyInfo(sPropertyInfo);
|
|
|
|
|
data->AddFlat("messages", &propertyInfo);
|
|
|
|
|
|
|
|
|
|
return BControl::GetSupportedSuites(data);
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
BChannelControl::SetModificationMessage(BMessage *message)
|
|
|
|
|
{
|
2005-02-01 07:42:07 +00:00
|
|
|
delete fModificationMsg;
|
|
|
|
|
fModificationMsg = message;
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BMessage *
|
|
|
|
|
BChannelControl::ModificationMessage() const
|
|
|
|
|
{
|
2005-02-01 07:42:07 +00:00
|
|
|
return fModificationMsg;
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::Invoke(BMessage *msg)
|
|
|
|
|
{
|
2005-02-02 09:34:06 +00:00
|
|
|
bool notify = false;
|
|
|
|
|
BMessage invokeMessage(InvokeKind(¬ify));
|
|
|
|
|
|
|
|
|
|
if (msg != NULL)
|
|
|
|
|
invokeMessage = *msg;
|
|
|
|
|
else if (Message() != NULL)
|
|
|
|
|
invokeMessage = *Message();
|
|
|
|
|
|
|
|
|
|
invokeMessage.AddInt32("be:current_channel", fCurrentChannel);
|
|
|
|
|
|
|
|
|
|
return BControl::Invoke(&invokeMessage);
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::InvokeChannel(BMessage *msg, int32 fromChannel,
|
|
|
|
|
int32 channelCount, const bool *inMask)
|
|
|
|
|
{
|
|
|
|
|
return B_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::InvokeNotifyChannel(BMessage *msg, uint32 kind,
|
|
|
|
|
int32 fromChannel, int32 channelCount, const bool *inMask)
|
|
|
|
|
{
|
2005-02-01 07:42:07 +00:00
|
|
|
BeginInvokeNotify(kind);
|
|
|
|
|
status_t status = InvokeChannel(msg, fromChannel, channelCount, inMask);
|
|
|
|
|
EndInvokeNotify();
|
|
|
|
|
|
|
|
|
|
return status;
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
BChannelControl::SetValue(int32 value)
|
|
|
|
|
{
|
2005-02-01 07:42:07 +00:00
|
|
|
// Get real
|
2005-02-01 14:29:06 +00:00
|
|
|
if (value > fChannelMax[fCurrentChannel])
|
|
|
|
|
value = fChannelMax[fCurrentChannel];
|
2005-02-01 07:42:07 +00:00
|
|
|
|
2005-02-01 14:29:06 +00:00
|
|
|
if (value < fChannelMin[fCurrentChannel]);
|
|
|
|
|
value = fChannelMin[fCurrentChannel];
|
2005-02-01 07:42:07 +00:00
|
|
|
|
2005-02-01 14:29:06 +00:00
|
|
|
if (value != fChannelValues[fCurrentChannel]) {
|
|
|
|
|
StuffValues(fCurrentChannel, 1, &value);
|
2005-02-01 07:42:07 +00:00
|
|
|
BControl::SetValue(value);
|
|
|
|
|
}
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::SetCurrentChannel(int32 channel)
|
|
|
|
|
{
|
2005-02-01 14:29:06 +00:00
|
|
|
if (channel < 0 || channel >= fChannelCount)
|
2005-02-01 07:42:07 +00:00
|
|
|
return B_BAD_INDEX;
|
|
|
|
|
|
2005-02-01 14:29:06 +00:00
|
|
|
if (channel != fCurrentChannel) {
|
|
|
|
|
fCurrentChannel = channel;
|
|
|
|
|
BControl::SetValue(fChannelValues[fCurrentChannel]);
|
2005-02-01 07:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return B_OK;
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int32
|
|
|
|
|
BChannelControl::CurrentChannel() const
|
|
|
|
|
{
|
2005-02-01 14:29:06 +00:00
|
|
|
return fCurrentChannel;
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int32
|
|
|
|
|
BChannelControl::CountChannels() const
|
|
|
|
|
{
|
2005-02-01 14:29:06 +00:00
|
|
|
return fChannelCount;
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::SetChannelCount(int32 channel_count)
|
|
|
|
|
{
|
2005-02-01 07:42:07 +00:00
|
|
|
if (channel_count < 0 || channel_count >= MaxChannelCount())
|
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
|
|
|
|
|
|
// TODO: Currently we only grow the buffer. Test what BeOS does
|
2005-02-01 14:29:06 +00:00
|
|
|
if (channel_count > fChannelCount) {
|
2005-02-01 07:42:07 +00:00
|
|
|
int32 *newMin = new int32[channel_count];
|
|
|
|
|
int32 *newMax = new int32[channel_count];
|
|
|
|
|
int32 *newVal = new int32[channel_count];
|
|
|
|
|
|
2005-02-01 14:29:06 +00:00
|
|
|
memcpy(newMin, fChannelMin, fChannelCount);
|
|
|
|
|
memcpy(newMax, fChannelMax, fChannelCount);
|
|
|
|
|
memcpy(newVal, fChannelValues, fChannelCount);
|
2005-02-01 07:42:07 +00:00
|
|
|
|
2005-02-01 14:29:06 +00:00
|
|
|
delete[] fChannelMin;
|
|
|
|
|
delete[] fChannelMax;
|
|
|
|
|
delete[] fChannelValues;
|
2005-02-01 07:42:07 +00:00
|
|
|
|
2005-02-01 14:29:06 +00:00
|
|
|
fChannelMin = newMin;
|
|
|
|
|
fChannelMax = newMax;
|
|
|
|
|
fChannelValues = newVal;
|
2005-02-01 07:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
2005-02-01 14:29:06 +00:00
|
|
|
fChannelCount = channel_count;
|
2005-02-01 07:42:07 +00:00
|
|
|
|
|
|
|
|
return B_OK;
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int32
|
|
|
|
|
BChannelControl::ValueFor(int32 channel) const
|
|
|
|
|
{
|
2005-02-01 07:42:07 +00:00
|
|
|
int32 value = 0;
|
|
|
|
|
if (GetValue(&value, channel, 1) <= 0)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
return value;
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int32
|
|
|
|
|
BChannelControl::GetValue(int32 *outValues, int32 fromChannel,
|
|
|
|
|
int32 channelCount) const
|
|
|
|
|
{
|
2005-02-01 07:42:07 +00:00
|
|
|
int32 i = 0;
|
|
|
|
|
for (i = 0; i < channelCount; i++)
|
2005-02-01 14:29:06 +00:00
|
|
|
outValues[i] = fChannelValues[fromChannel + i];
|
2005-02-01 07:42:07 +00:00
|
|
|
|
|
|
|
|
return i;
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::SetValueFor(int32 channel, int32 value)
|
|
|
|
|
{
|
2005-02-01 07:42:07 +00:00
|
|
|
return SetValue(channel, 1, &value);
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::SetValue(int32 fromChannel, int32 channelCount,
|
|
|
|
|
const int32 *inValues)
|
|
|
|
|
{
|
2005-02-01 07:42:07 +00:00
|
|
|
return StuffValues(fromChannel, channelCount, inValues);
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::SetAllValue(int32 values)
|
|
|
|
|
{
|
|
|
|
|
return B_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::SetLimitsFor(int32 channel, int32 minimum, int32 maximum)
|
|
|
|
|
{
|
2005-02-02 09:34:06 +00:00
|
|
|
return SetLimitsFor(channel, 1, &minimum, &maximum);
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::GetLimitsFor(int32 channel, int32 *minimum, int32 *maximum) const
|
|
|
|
|
{
|
2005-02-02 09:34:06 +00:00
|
|
|
return GetLimitsFor(channel, 1, minimum, maximum);
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::SetLimitsFor(int32 fromChannel, int32 channelCount,
|
|
|
|
|
const int32 *minimum, const int32 *maximum)
|
|
|
|
|
{
|
2005-02-02 09:34:06 +00:00
|
|
|
|
2005-01-15 04:29:19 +00:00
|
|
|
return B_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::GetLimitsFor(int32 fromChannel, int32 channelCount,
|
|
|
|
|
int32 *minimum, int32 *maximum) const
|
|
|
|
|
{
|
|
|
|
|
return B_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::SetLimits(int32 minimum, int32 maximum)
|
|
|
|
|
{
|
|
|
|
|
return B_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::GetLimits(int32 *outMinimum, int32 *outMaximum) const
|
|
|
|
|
{
|
|
|
|
|
return B_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
2005-02-02 09:34:06 +00:00
|
|
|
BChannelControl::SetLimitLabels(const char *minLabel, const char *maxLabel)
|
2005-01-15 04:29:19 +00:00
|
|
|
{
|
2005-02-02 09:34:06 +00:00
|
|
|
if (minLabel != fMinLabel)
|
|
|
|
|
fMinLabel = minLabel;
|
|
|
|
|
|
|
|
|
|
if (maxLabel != fMaxLabel)
|
|
|
|
|
fMaxLabel = maxLabel;
|
|
|
|
|
|
|
|
|
|
Invalidate();
|
|
|
|
|
|
|
|
|
|
return B_OK;
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
BChannelControl::MinLimitLabel() const
|
|
|
|
|
{
|
2005-02-02 09:34:06 +00:00
|
|
|
return fMinLabel.String();
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
BChannelControl::MaxLimitLabel() const
|
|
|
|
|
{
|
2005-02-02 09:34:06 +00:00
|
|
|
return fMaxLabel.String();
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::SetLimitLabelsFor(int32 channel, const char *minLabel, const char *maxLabel)
|
|
|
|
|
{
|
|
|
|
|
return B_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::SetLimitLabelsFor(int32 from_channel, int32 channel_count, const char *minLabel, const char *maxLabel)
|
|
|
|
|
{
|
|
|
|
|
return B_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
BChannelControl::MinLimitLabelFor(int32 channel) const
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
BChannelControl::MaxLimitLabelFor(int32 channel) const
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
|
BChannelControl::StuffValues(int32 fromChannel, int32 channelCount,
|
|
|
|
|
const int32 *inValues)
|
|
|
|
|
{
|
2005-02-02 09:34:06 +00:00
|
|
|
if (inValues == NULL)
|
|
|
|
|
return B_BAD_VALUE;
|
|
|
|
|
|
|
|
|
|
if (fromChannel < 0 || fromChannel >= fChannelCount
|
|
|
|
|
|| fromChannel + channelCount >= fChannelCount)
|
|
|
|
|
return B_BAD_INDEX;
|
|
|
|
|
|
|
|
|
|
for (int32 i = 0; i < channelCount; i++) {
|
|
|
|
|
if (inValues[i] <= fChannelMax[fromChannel + i]
|
|
|
|
|
&& inValues[i] >= fChannelMin[fromChannel + i])
|
|
|
|
|
fChannelValues[fromChannel + i] = inValues[i];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the current channel was updated, update also the control value
|
|
|
|
|
if (fCurrentChannel >= fromChannel && fCurrentChannel <= fromChannel + channelCount)
|
|
|
|
|
BControl::SetValue(fChannelValues[fCurrentChannel]);
|
|
|
|
|
|
|
|
|
|
return B_OK;
|
2005-01-15 04:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BChannelControl::_Reserverd_ChannelControl_0(void *, ...) {}
|
|
|
|
|
void BChannelControl::_Reserverd_ChannelControl_1(void *, ...) {}
|
|
|
|
|
void BChannelControl::_Reserverd_ChannelControl_2(void *, ...) {}
|
|
|
|
|
void BChannelControl::_Reserverd_ChannelControl_3(void *, ...) {}
|
|
|
|
|
void BChannelControl::_Reserverd_ChannelControl_4(void *, ...) {}
|
|
|
|
|
void BChannelControl::_Reserverd_ChannelControl_5(void *, ...) {}
|
|
|
|
|
void BChannelControl::_Reserverd_ChannelControl_6(void *, ...) {}
|
|
|
|
|
void BChannelControl::_Reserverd_ChannelControl_7(void *, ...) {}
|
|
|
|
|
void BChannelControl::_Reserverd_ChannelControl_8(void *, ...) {}
|
|
|
|
|
void BChannelControl::_Reserverd_ChannelControl_9(void *, ...) {}
|
|
|
|
|
void BChannelControl::_Reserverd_ChannelControl_10(void *, ...) {}
|
|
|
|
|
void BChannelControl::_Reserverd_ChannelControl_11(void *, ...) {}
|