From 0b421b8025a1da938c3689ae67c58d5a58c8542f Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Sat, 1 Aug 2015 14:47:21 +0200 Subject: [PATCH] ChannelControl: Implemented SetLimitLabelsFor(). Implemented without testing how it's done on BeOS. Moreover, I have no idea if, when and where these labels should be drawn. --- src/kits/interface/ChannelControl.cpp | 35 +++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/kits/interface/ChannelControl.cpp b/src/kits/interface/ChannelControl.cpp index 1d1ccfa067..4e8f51ea1a 100644 --- a/src/kits/interface/ChannelControl.cpp +++ b/src/kits/interface/ChannelControl.cpp @@ -7,6 +7,15 @@ #include #include +#include +#include + +struct limit_label { + std::string min_label; + std::string max_label; +}; + +typedef std::map label_map; static property_info sPropertyInfo[] = { @@ -56,6 +65,8 @@ BChannelControl::BChannelControl(BRect frame, const char* name, fChannelValues = new int32[channel_count]; memset(fChannelValues, 0, sizeof(int32) * channel_count); + + fMultiLabels = (void*)new label_map; } @@ -80,6 +91,8 @@ BChannelControl::BChannelControl(const char* name, const char* label, fChannelValues = new int32[channelCount]; memset(fChannelValues, 0, sizeof(int32) * channelCount); + + fMultiLabels = (void*)new label_map; } @@ -127,6 +140,8 @@ BChannelControl::BChannelControl(BMessage* archive) fModificationMsg = modificationMessage; else delete modificationMessage; + + fMultiLabels = (void*)new label_map; } @@ -136,6 +151,7 @@ BChannelControl::~BChannelControl() delete[] fChannelMax; delete[] fChannelValues; delete fModificationMsg; + delete reinterpret_cast(fMultiLabels); } @@ -589,7 +605,9 @@ status_t BChannelControl::SetLimitLabelsFor(int32 channel, const char* minLabel, const char* maxLabel) { - return B_ERROR; + (*(label_map*)fMultiLabels)[channel].max_label = maxLabel; + (*(label_map*)fMultiLabels)[channel].min_label = minLabel; + return B_OK; } @@ -597,13 +615,21 @@ status_t BChannelControl::SetLimitLabelsFor(int32 fromChannel, int32 channelCount, const char* minLabel, const char* maxLabel) { - return B_ERROR; + for (int32 i = fromChannel; i < fromChannel + channelCount; i++) { + SetLimitLabelsFor(i, minLabel, maxLabel); + } + return B_OK; } const char* BChannelControl::MinLimitLabelFor(int32 channel) const { + if (fMultiLabels != NULL) { + label_map::const_iterator iter = ((label_map*)fMultiLabels)->find(channel); + if (iter != ((label_map*)fMultiLabels)->end()) + return (*iter).second.min_label.c_str(); + } return NULL; } @@ -611,6 +637,11 @@ BChannelControl::MinLimitLabelFor(int32 channel) const const char* BChannelControl::MaxLimitLabelFor(int32 channel) const { + if (fMultiLabels != NULL) { + label_map::const_iterator iter = ((label_map*)fMultiLabels)->find(channel); + if (iter != ((label_map*)fMultiLabels)->end()) + return (*iter).second.max_label.c_str(); + } return NULL; }