* Added BRadioButton test (the class seems to work fine).
* Extended the BMenuField test to see what happens when the super item label changes (works fine now). * Updated TODO. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27586 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
43f8c6143a
commit
b2c4c4f1f7
|
@ -27,6 +27,7 @@ SimpleTest WidgetLayoutTest :
|
||||||
MenuBarTest.cpp
|
MenuBarTest.cpp
|
||||||
MenuFieldTest.cpp
|
MenuFieldTest.cpp
|
||||||
MenuTest.cpp
|
MenuTest.cpp
|
||||||
|
RadioButtonTest.cpp
|
||||||
ScrollBarTest.cpp
|
ScrollBarTest.cpp
|
||||||
SliderTest.cpp
|
SliderTest.cpp
|
||||||
TextControlTest.cpp
|
TextControlTest.cpp
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "MenuBarTest.h"
|
#include "MenuBarTest.h"
|
||||||
#include "MenuFieldTest.h"
|
#include "MenuFieldTest.h"
|
||||||
#include "MenuTest.h"
|
#include "MenuTest.h"
|
||||||
|
#include "RadioButtonTest.h"
|
||||||
#include "ScrollBarTest.h"
|
#include "ScrollBarTest.h"
|
||||||
#include "SliderTest.h"
|
#include "SliderTest.h"
|
||||||
#include "StringView.h"
|
#include "StringView.h"
|
||||||
|
@ -48,6 +49,7 @@ const test_info kTestInfos[] = {
|
||||||
{ "BMenu", MenuTest::CreateTest },
|
{ "BMenu", MenuTest::CreateTest },
|
||||||
{ "BMenuBar", MenuBarTest::CreateTest },
|
{ "BMenuBar", MenuBarTest::CreateTest },
|
||||||
{ "BMenuField", MenuFieldTest::CreateTest },
|
{ "BMenuField", MenuFieldTest::CreateTest },
|
||||||
|
{ "BRadioButton", RadioButtonTest::CreateTest },
|
||||||
{ "BScrollBar", ScrollBarTest::CreateTest },
|
{ "BScrollBar", ScrollBarTest::CreateTest },
|
||||||
{ "BSlider", SliderTest::CreateTest },
|
{ "BSlider", SliderTest::CreateTest },
|
||||||
{ "BTextControl", TextControlTest::CreateTest },
|
{ "BTextControl", TextControlTest::CreateTest },
|
||||||
|
|
|
@ -17,14 +17,16 @@
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MSG_CHANGE_LABEL_TEXT = 'chlt',
|
MSG_CHANGE_LABEL_TEXT = 'chlt',
|
||||||
MSG_CHANGE_LABEL_FONT = 'chlf'
|
MSG_CHANGE_LABEL_FONT = 'chlf',
|
||||||
|
MSG_CHANGE_MENU_TEXT = 'chmt'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
MenuFieldTest::MenuFieldTest()
|
MenuFieldTest::MenuFieldTest()
|
||||||
: ControlTest("MenuField"),
|
: ControlTest("MenuField"),
|
||||||
fLongTextCheckBox(NULL),
|
fLongLabelTextCheckBox(NULL),
|
||||||
|
fLongMenuTextCheckBox(NULL),
|
||||||
fBigFontCheckBox(NULL),
|
fBigFontCheckBox(NULL),
|
||||||
fDefaultFont(NULL),
|
fDefaultFont(NULL),
|
||||||
fBigFont(NULL)
|
fBigFont(NULL)
|
||||||
|
@ -75,18 +77,23 @@ MenuFieldTest::ActivateTest(View* controls)
|
||||||
fMenuField->SetViewColor(background);
|
fMenuField->SetViewColor(background);
|
||||||
fMenuField->SetLowColor(background);
|
fMenuField->SetLowColor(background);
|
||||||
|
|
||||||
// long text
|
// long label text
|
||||||
fLongTextCheckBox = new LabeledCheckBox("Long label text",
|
fLongLabelTextCheckBox = new LabeledCheckBox("Long label text",
|
||||||
new BMessage(MSG_CHANGE_LABEL_TEXT), this);
|
new BMessage(MSG_CHANGE_LABEL_TEXT), this);
|
||||||
group->AddChild(fLongTextCheckBox);
|
group->AddChild(fLongLabelTextCheckBox);
|
||||||
|
|
||||||
|
// long menu text
|
||||||
|
fLongMenuTextCheckBox = new LabeledCheckBox("Long menu text",
|
||||||
|
new BMessage(MSG_CHANGE_MENU_TEXT), this);
|
||||||
|
group->AddChild(fLongMenuTextCheckBox);
|
||||||
|
|
||||||
// big font
|
// big font
|
||||||
fBigFontCheckBox = new LabeledCheckBox("Big label font",
|
fBigFontCheckBox = new LabeledCheckBox("Big label font",
|
||||||
new BMessage(MSG_CHANGE_LABEL_FONT), this);
|
new BMessage(MSG_CHANGE_LABEL_FONT), this);
|
||||||
group->AddChild(fBigFontCheckBox);
|
group->AddChild(fBigFontCheckBox);
|
||||||
|
|
||||||
UpdateLabelText();
|
_UpdateLabelText();
|
||||||
UpdateLabelFont();
|
_UpdateLabelFont();
|
||||||
|
|
||||||
group->AddChild(new Glue());
|
group->AddChild(new Glue());
|
||||||
}
|
}
|
||||||
|
@ -105,10 +112,13 @@ MenuFieldTest::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case MSG_CHANGE_LABEL_TEXT:
|
case MSG_CHANGE_LABEL_TEXT:
|
||||||
UpdateLabelText();
|
_UpdateLabelText();
|
||||||
|
break;
|
||||||
|
case MSG_CHANGE_MENU_TEXT:
|
||||||
|
_UpdateMenuText();
|
||||||
break;
|
break;
|
||||||
case MSG_CHANGE_LABEL_FONT:
|
case MSG_CHANGE_LABEL_FONT:
|
||||||
UpdateLabelFont();
|
_UpdateLabelFont();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Test::MessageReceived(message);
|
Test::MessageReceived(message);
|
||||||
|
@ -117,22 +127,36 @@ MenuFieldTest::MessageReceived(BMessage* message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// UpdateLabelText
|
// _UpdateLabelText
|
||||||
void
|
void
|
||||||
MenuFieldTest::UpdateLabelText()
|
MenuFieldTest::_UpdateLabelText()
|
||||||
{
|
{
|
||||||
if (!fLongTextCheckBox || !fMenuField)
|
if (!fLongLabelTextCheckBox || !fMenuField)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fMenuField->SetLabel(fLongTextCheckBox->IsSelected()
|
fMenuField->SetLabel(fLongLabelTextCheckBox->IsSelected()
|
||||||
? "Pretty long menu field label"
|
? "Pretty long menu field label"
|
||||||
: "Short label");
|
: "Short label");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// UpdateLabelFont
|
// _UpdateMenuText
|
||||||
void
|
void
|
||||||
MenuFieldTest::UpdateLabelFont()
|
MenuFieldTest::_UpdateMenuText()
|
||||||
|
{
|
||||||
|
if (!fLongMenuTextCheckBox || !fMenuField)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fMenuField->Menu()->Superitem()->SetLabel(
|
||||||
|
fLongMenuTextCheckBox->IsSelected()
|
||||||
|
? "Pretty long menu field text"
|
||||||
|
: "Short text");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// _UpdateLabelFont
|
||||||
|
void
|
||||||
|
MenuFieldTest::_UpdateLabelFont()
|
||||||
{
|
{
|
||||||
if (!fBigFontCheckBox || !fMenuField || !fMenuField->Window())
|
if (!fBigFontCheckBox || !fMenuField || !fMenuField->Window())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -27,12 +27,14 @@ public:
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateLabelText();
|
void _UpdateLabelText();
|
||||||
void UpdateLabelFont();
|
void _UpdateMenuText();
|
||||||
|
void _UpdateLabelFont();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BMenuField* fMenuField;
|
BMenuField* fMenuField;
|
||||||
LabeledCheckBox* fLongTextCheckBox;
|
LabeledCheckBox* fLongLabelTextCheckBox;
|
||||||
|
LabeledCheckBox* fLongMenuTextCheckBox;
|
||||||
LabeledCheckBox* fBigFontCheckBox;
|
LabeledCheckBox* fBigFontCheckBox;
|
||||||
BFont* fDefaultFont;
|
BFont* fDefaultFont;
|
||||||
BFont* fBigFont;
|
BFont* fBigFont;
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2008, Stephan Aßmus <superstippi@gmx.de>.
|
||||||
|
* Copyright 2007, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "RadioButtonTest.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <RadioButton.h>
|
||||||
|
|
||||||
|
#include "GroupView.h"
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
RadioButtonTest::RadioButtonTest()
|
||||||
|
: ControlTest("RadioButton"),
|
||||||
|
fRadioButton(new BRadioButton("", NULL))
|
||||||
|
{
|
||||||
|
SetView(fRadioButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
RadioButtonTest::~RadioButtonTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CreateTest
|
||||||
|
Test*
|
||||||
|
RadioButtonTest::CreateTest()
|
||||||
|
{
|
||||||
|
return new RadioButtonTest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ActivateTest
|
||||||
|
void
|
||||||
|
RadioButtonTest::ActivateTest(View* controls)
|
||||||
|
{
|
||||||
|
// BControl sets its background color to that of its parent in
|
||||||
|
// AttachedToWindow(). Override.
|
||||||
|
rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
fControl->SetViewColor(background);
|
||||||
|
fControl->SetLowColor(background);
|
||||||
|
|
||||||
|
GroupView* group = new GroupView(B_VERTICAL);
|
||||||
|
group->SetFrame(controls->Bounds());
|
||||||
|
controls->AddChild(group);
|
||||||
|
|
||||||
|
ControlTest::ActivateTest(group);
|
||||||
|
|
||||||
|
group->AddChild(new Glue());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// DectivateTest
|
||||||
|
void
|
||||||
|
RadioButtonTest::DectivateTest()
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2008, Stephan Aßmus <superstippi@gmx.de>.
|
||||||
|
* Copyright 2007, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef WIDGET_LAYOUT_TEST_RADIO_BUTTON_TEST_H
|
||||||
|
#define WIDGET_LAYOUT_TEST_RADIO_BUTTON_TEST_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "ControlTest.h"
|
||||||
|
|
||||||
|
|
||||||
|
class BRadioButton;
|
||||||
|
|
||||||
|
|
||||||
|
class RadioButtonTest : public ControlTest {
|
||||||
|
public:
|
||||||
|
RadioButtonTest();
|
||||||
|
virtual ~RadioButtonTest();
|
||||||
|
|
||||||
|
static Test* CreateTest();
|
||||||
|
|
||||||
|
virtual void ActivateTest(View* controls);
|
||||||
|
virtual void DectivateTest();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BRadioButton* fRadioButton;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // WIDGET_LAYOUT_TEST_RADIO_BUTTON_TEST_H
|
|
@ -1,6 +1,5 @@
|
||||||
ChannelSlider
|
ChannelSlider
|
||||||
OptionPopup (covered by MenuField ?)
|
OptionPopup (covered by MenuField ?)
|
||||||
RadioButton
|
|
||||||
ScrollView
|
ScrollView
|
||||||
StringView
|
StringView
|
||||||
TabView
|
TabView
|
||||||
|
|
|
@ -115,7 +115,7 @@ TextControlTest::_UpdateLabelText()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fTextControl->SetLabel(fLongTextCheckBox->IsSelected()
|
fTextControl->SetLabel(fLongTextCheckBox->IsSelected()
|
||||||
? "Pretty long menu field label"
|
? "Pretty long text control label"
|
||||||
: "Short label");
|
: "Short label");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue