Also test the UpdateText() behavior.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26448 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <Message.h>
|
||||
#include <Slider.h>
|
||||
|
||||
#include "CheckBox.h"
|
||||
#include "GroupView.h"
|
||||
#include "RadioButton.h"
|
||||
#include "TestView.h"
|
||||
@@ -23,10 +24,32 @@ enum {
|
||||
MSG_HASH_MARKS_CHANGED = 'hmch',
|
||||
MSG_BAR_THICKNESS_CHANGED = 'btch',
|
||||
MSG_LABEL_CHANGED = 'lbch',
|
||||
MSG_LIMIT_LABELS_CHANGED = 'lmch'
|
||||
MSG_LIMIT_LABELS_CHANGED = 'lmch',
|
||||
MSG_UPDATE_TEXT_CHANGED = 'utch'
|
||||
};
|
||||
|
||||
|
||||
// TestSlider
|
||||
class SliderTest::TestSlider : public BSlider {
|
||||
public:
|
||||
TestSlider()
|
||||
: BSlider("test slider", "Label", NULL, 1, 100, B_HORIZONTAL),
|
||||
fExportUpdateText(false)
|
||||
{
|
||||
}
|
||||
|
||||
virtual char* UpdateText() const
|
||||
{
|
||||
if (!fExportUpdateText)
|
||||
return NULL;
|
||||
sprintf(fUpdateText, "%ld", Value());
|
||||
return fUpdateText;
|
||||
}
|
||||
|
||||
mutable char fUpdateText[32];
|
||||
bool fExportUpdateText;
|
||||
};
|
||||
|
||||
// OrientationRadioButton
|
||||
class SliderTest::OrientationRadioButton : public LabeledRadioButton {
|
||||
public:
|
||||
@@ -110,13 +133,14 @@ public:
|
||||
// constructor
|
||||
SliderTest::SliderTest()
|
||||
: Test("Slider", NULL),
|
||||
fSlider(new BSlider("test slider", "Label", NULL, 1, 100, B_HORIZONTAL)),
|
||||
fSlider(new TestSlider()),
|
||||
fOrientationRadioGroup(NULL),
|
||||
fThumbStyleRadioGroup(NULL),
|
||||
fHashMarkLocationRadioGroup(NULL),
|
||||
fBarThicknessRadioGroup(NULL),
|
||||
fLabelRadioGroup(NULL),
|
||||
fLimitLabelsRadioGroup(NULL)
|
||||
fLimitLabelsRadioGroup(NULL),
|
||||
fUpdateTextCheckBox(NULL)
|
||||
{
|
||||
SetView(fSlider);
|
||||
}
|
||||
@@ -321,6 +345,14 @@ SliderTest::ActivateTest(View* controls)
|
||||
// default to no limit labels
|
||||
fLimitLabelsRadioGroup->SelectButton(0L);
|
||||
|
||||
// spacing
|
||||
group->AddChild(new VStrut(10));
|
||||
|
||||
// update text
|
||||
fUpdateTextCheckBox = new LabeledCheckBox("Update text",
|
||||
new BMessage(MSG_UPDATE_TEXT_CHANGED), this);
|
||||
group->AddChild(fUpdateTextCheckBox);
|
||||
|
||||
|
||||
// glue
|
||||
group->AddChild(new Glue());
|
||||
@@ -357,6 +389,9 @@ SliderTest::MessageReceived(BMessage* message)
|
||||
case MSG_LIMIT_LABELS_CHANGED:
|
||||
_UpdateLimitLabels();
|
||||
break;
|
||||
case MSG_UPDATE_TEXT_CHANGED:
|
||||
_UpdateUpdateText();
|
||||
break;
|
||||
default:
|
||||
Test::MessageReceived(message);
|
||||
break;
|
||||
@@ -470,3 +505,15 @@ SliderTest::_UpdateLimitLabels()
|
||||
}
|
||||
}
|
||||
|
||||
// _UpdateUpdateText
|
||||
void
|
||||
SliderTest::_UpdateUpdateText()
|
||||
{
|
||||
if (!fUpdateTextCheckBox
|
||||
|| fUpdateTextCheckBox->IsSelected() == fSlider->fExportUpdateText)
|
||||
return;
|
||||
|
||||
fSlider->fExportUpdateText = fUpdateTextCheckBox->IsSelected();
|
||||
fSlider->UpdateTextChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "Test.h"
|
||||
|
||||
|
||||
class BSlider;
|
||||
class LabeledCheckBox;
|
||||
class RadioButtonGroup;
|
||||
|
||||
|
||||
@@ -33,8 +33,10 @@ private:
|
||||
void _UpdateBarThickness();
|
||||
void _UpdateLabel();
|
||||
void _UpdateLimitLabels();
|
||||
void _UpdateUpdateText();
|
||||
|
||||
private:
|
||||
class TestSlider;
|
||||
class OrientationRadioButton;
|
||||
class ThumbStyleRadioButton;
|
||||
class HashMarkLocationRadioButton;
|
||||
@@ -42,13 +44,14 @@ private:
|
||||
class LabelRadioButton;
|
||||
class LimitLabelsRadioButton;
|
||||
|
||||
BSlider* fSlider;
|
||||
TestSlider* fSlider;
|
||||
RadioButtonGroup* fOrientationRadioGroup;
|
||||
RadioButtonGroup* fThumbStyleRadioGroup;
|
||||
RadioButtonGroup* fHashMarkLocationRadioGroup;
|
||||
RadioButtonGroup* fBarThicknessRadioGroup;
|
||||
RadioButtonGroup* fLabelRadioGroup;
|
||||
RadioButtonGroup* fLimitLabelsRadioGroup;
|
||||
LabeledCheckBox* fUpdateTextCheckBox;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user