Added BScrollBar test.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27495 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -27,6 +27,7 @@ SimpleTest WidgetLayoutTest :
|
|||||||
MenuBarTest.cpp
|
MenuBarTest.cpp
|
||||||
MenuFieldTest.cpp
|
MenuFieldTest.cpp
|
||||||
MenuTest.cpp
|
MenuTest.cpp
|
||||||
|
ScrollBarTest.cpp
|
||||||
SliderTest.cpp
|
SliderTest.cpp
|
||||||
:
|
:
|
||||||
be
|
be
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "MenuBarTest.h"
|
#include "MenuBarTest.h"
|
||||||
#include "MenuFieldTest.h"
|
#include "MenuFieldTest.h"
|
||||||
#include "MenuTest.h"
|
#include "MenuTest.h"
|
||||||
|
#include "ScrollBarTest.h"
|
||||||
#include "SliderTest.h"
|
#include "SliderTest.h"
|
||||||
#include "StringView.h"
|
#include "StringView.h"
|
||||||
#include "Test.h"
|
#include "Test.h"
|
||||||
@@ -46,6 +47,7 @@ const test_info kTestInfos[] = {
|
|||||||
{ "BMenu", MenuTest::CreateTest },
|
{ "BMenu", MenuTest::CreateTest },
|
||||||
{ "BMenuBar", MenuBarTest::CreateTest },
|
{ "BMenuBar", MenuBarTest::CreateTest },
|
||||||
{ "BMenuField", MenuFieldTest::CreateTest },
|
{ "BMenuField", MenuFieldTest::CreateTest },
|
||||||
|
{ "BScrollBar", ScrollBarTest::CreateTest },
|
||||||
{ "BSlider", SliderTest::CreateTest },
|
{ "BSlider", SliderTest::CreateTest },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,129 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008, Stephan Aßmus <[email protected]>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ScrollBarTest.h"
|
||||||
|
|
||||||
|
#include <Message.h>
|
||||||
|
#include <ScrollBar.h>
|
||||||
|
|
||||||
|
#include "RadioButton.h"
|
||||||
|
#include "TestView.h"
|
||||||
|
|
||||||
|
|
||||||
|
// messages
|
||||||
|
enum {
|
||||||
|
MSG_ORIENTATION_CHANGED = 'orch'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// OrientationRadioButton
|
||||||
|
class ScrollBarTest::OrientationRadioButton : public LabeledRadioButton {
|
||||||
|
public:
|
||||||
|
OrientationRadioButton(const char* label, enum orientation orientation)
|
||||||
|
: LabeledRadioButton(label),
|
||||||
|
fOrientation(orientation)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
enum orientation fOrientation;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ScrollBarTest::ScrollBarTest()
|
||||||
|
: Test("ScrollBar", NULL),
|
||||||
|
fScrollBar(new BScrollBar("scroll bar", NULL, 0, 100, B_HORIZONTAL)),
|
||||||
|
fOrientationRadioGroup(NULL)
|
||||||
|
{
|
||||||
|
SetView(fScrollBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ScrollBarTest::~ScrollBarTest()
|
||||||
|
{
|
||||||
|
delete fOrientationRadioGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Test*
|
||||||
|
ScrollBarTest::CreateTest()
|
||||||
|
{
|
||||||
|
return new ScrollBarTest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScrollBarTest::ActivateTest(View* controls)
|
||||||
|
{
|
||||||
|
// the radio button group for selecting the orientation
|
||||||
|
|
||||||
|
GroupView* vGroup = new GroupView(B_VERTICAL);
|
||||||
|
vGroup->SetFrame(controls->Bounds());
|
||||||
|
vGroup->SetSpacing(0, 4);
|
||||||
|
controls->AddChild(vGroup);
|
||||||
|
|
||||||
|
fOrientationRadioGroup = new RadioButtonGroup(
|
||||||
|
new BMessage(MSG_ORIENTATION_CHANGED), this);
|
||||||
|
|
||||||
|
// horizontal
|
||||||
|
LabeledRadioButton* button = new OrientationRadioButton("Horizontal",
|
||||||
|
B_HORIZONTAL);
|
||||||
|
vGroup->AddChild(button);
|
||||||
|
fOrientationRadioGroup->AddButton(button->GetRadioButton());
|
||||||
|
|
||||||
|
// vertical
|
||||||
|
button = new OrientationRadioButton("Vertical", B_VERTICAL);
|
||||||
|
vGroup->AddChild(button);
|
||||||
|
fOrientationRadioGroup->AddButton(button->GetRadioButton());
|
||||||
|
|
||||||
|
// default to horizontal
|
||||||
|
fOrientationRadioGroup->SelectButton(0L);
|
||||||
|
|
||||||
|
// glue
|
||||||
|
vGroup->AddChild(new Glue());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScrollBarTest::DectivateTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScrollBarTest::MessageReceived(BMessage* message)
|
||||||
|
{
|
||||||
|
switch (message->what) {
|
||||||
|
case MSG_ORIENTATION_CHANGED:
|
||||||
|
_UpdateOrientation();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Test::MessageReceived(message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ScrollBarTest::_UpdateOrientation()
|
||||||
|
{
|
||||||
|
if (fOrientationRadioGroup == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// We need to get the parent of the actually selected button, since
|
||||||
|
// that is the labeled radio button we've derived our
|
||||||
|
// BorderStyleRadioButton from.
|
||||||
|
AbstractButton* selectedButton
|
||||||
|
= fOrientationRadioGroup->SelectedButton();
|
||||||
|
View* parent = (selectedButton ? selectedButton->Parent() : NULL);
|
||||||
|
OrientationRadioButton* button = dynamic_cast<OrientationRadioButton*>(
|
||||||
|
parent);
|
||||||
|
if (button)
|
||||||
|
fScrollBar->SetOrientation(button->fOrientation);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008, Stephan Aßmus <[email protected]>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef WIDGET_LAYOUT_TEST_SCROLL_BAR_TEST_H
|
||||||
|
#define WIDGET_LAYOUT_TEST_SCROLL_BAR_TEST_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "Test.h"
|
||||||
|
|
||||||
|
|
||||||
|
class BScrollBar;
|
||||||
|
class RadioButtonGroup;
|
||||||
|
|
||||||
|
|
||||||
|
class ScrollBarTest : public Test {
|
||||||
|
public:
|
||||||
|
ScrollBarTest();
|
||||||
|
virtual ~ScrollBarTest();
|
||||||
|
|
||||||
|
static Test* CreateTest();
|
||||||
|
|
||||||
|
virtual void ActivateTest(View* controls);
|
||||||
|
virtual void DectivateTest();
|
||||||
|
|
||||||
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void _UpdateOrientation();
|
||||||
|
|
||||||
|
private:
|
||||||
|
class OrientationRadioButton;
|
||||||
|
|
||||||
|
BScrollBar* fScrollBar;
|
||||||
|
RadioButtonGroup* fOrientationRadioGroup;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // WIDGET_LAYOUT_TEST_SCROLL_BAR_TEST_H
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
ChannelSlider
|
ChannelSlider
|
||||||
OptionPopup (covered by MenuField ?)
|
OptionPopup (covered by MenuField ?)
|
||||||
RadioButton
|
RadioButton
|
||||||
ScrollBar
|
|
||||||
ScrollView
|
ScrollView
|
||||||
StringView
|
StringView
|
||||||
TabView
|
TabView
|
||||||
|
|||||||
Reference in New Issue
Block a user