* 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:
Stephan Aßmus 2008-09-16 15:10:11 +00:00
parent 43f8c6143a
commit b2c4c4f1f7
8 changed files with 142 additions and 20 deletions

View File

@ -27,6 +27,7 @@ SimpleTest WidgetLayoutTest :
MenuBarTest.cpp
MenuFieldTest.cpp
MenuTest.cpp
RadioButtonTest.cpp
ScrollBarTest.cpp
SliderTest.cpp
TextControlTest.cpp

View File

@ -17,6 +17,7 @@
#include "MenuBarTest.h"
#include "MenuFieldTest.h"
#include "MenuTest.h"
#include "RadioButtonTest.h"
#include "ScrollBarTest.h"
#include "SliderTest.h"
#include "StringView.h"
@ -48,6 +49,7 @@ const test_info kTestInfos[] = {
{ "BMenu", MenuTest::CreateTest },
{ "BMenuBar", MenuBarTest::CreateTest },
{ "BMenuField", MenuFieldTest::CreateTest },
{ "BRadioButton", RadioButtonTest::CreateTest },
{ "BScrollBar", ScrollBarTest::CreateTest },
{ "BSlider", SliderTest::CreateTest },
{ "BTextControl", TextControlTest::CreateTest },

View File

@ -17,14 +17,16 @@
enum {
MSG_CHANGE_LABEL_TEXT = 'chlt',
MSG_CHANGE_LABEL_FONT = 'chlf'
MSG_CHANGE_LABEL_FONT = 'chlf',
MSG_CHANGE_MENU_TEXT = 'chmt'
};
// constructor
MenuFieldTest::MenuFieldTest()
: ControlTest("MenuField"),
fLongTextCheckBox(NULL),
fLongLabelTextCheckBox(NULL),
fLongMenuTextCheckBox(NULL),
fBigFontCheckBox(NULL),
fDefaultFont(NULL),
fBigFont(NULL)
@ -75,18 +77,23 @@ MenuFieldTest::ActivateTest(View* controls)
fMenuField->SetViewColor(background);
fMenuField->SetLowColor(background);
// long text
fLongTextCheckBox = new LabeledCheckBox("Long label text",
// long label text
fLongLabelTextCheckBox = new LabeledCheckBox("Long label text",
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
fBigFontCheckBox = new LabeledCheckBox("Big label font",
new BMessage(MSG_CHANGE_LABEL_FONT), this);
group->AddChild(fBigFontCheckBox);
UpdateLabelText();
UpdateLabelFont();
_UpdateLabelText();
_UpdateLabelFont();
group->AddChild(new Glue());
}
@ -105,10 +112,13 @@ MenuFieldTest::MessageReceived(BMessage* message)
{
switch (message->what) {
case MSG_CHANGE_LABEL_TEXT:
UpdateLabelText();
_UpdateLabelText();
break;
case MSG_CHANGE_MENU_TEXT:
_UpdateMenuText();
break;
case MSG_CHANGE_LABEL_FONT:
UpdateLabelFont();
_UpdateLabelFont();
break;
default:
Test::MessageReceived(message);
@ -117,22 +127,36 @@ MenuFieldTest::MessageReceived(BMessage* message)
}
// UpdateLabelText
// _UpdateLabelText
void
MenuFieldTest::UpdateLabelText()
MenuFieldTest::_UpdateLabelText()
{
if (!fLongTextCheckBox || !fMenuField)
if (!fLongLabelTextCheckBox || !fMenuField)
return;
fMenuField->SetLabel(fLongTextCheckBox->IsSelected()
fMenuField->SetLabel(fLongLabelTextCheckBox->IsSelected()
? "Pretty long menu field label"
: "Short label");
}
// UpdateLabelFont
// _UpdateMenuText
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())
return;

View File

@ -27,12 +27,14 @@ public:
virtual void MessageReceived(BMessage* message);
private:
void UpdateLabelText();
void UpdateLabelFont();
void _UpdateLabelText();
void _UpdateMenuText();
void _UpdateLabelFont();
private:
BMenuField* fMenuField;
LabeledCheckBox* fLongTextCheckBox;
LabeledCheckBox* fLongLabelTextCheckBox;
LabeledCheckBox* fLongMenuTextCheckBox;
LabeledCheckBox* fBigFontCheckBox;
BFont* fDefaultFont;
BFont* fBigFont;

View File

@ -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()
{
}

View File

@ -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

View File

@ -1,6 +1,5 @@
ChannelSlider
OptionPopup (covered by MenuField ?)
RadioButton
ScrollView
StringView
TabView

View File

@ -115,7 +115,7 @@ TextControlTest::_UpdateLabelText()
return;
fTextControl->SetLabel(fLongTextCheckBox->IsSelected()
? "Pretty long menu field label"
? "Pretty long text control label"
: "Short label");
}