Skip to content

Commit

Permalink
testjx: upgrade TestTabDirector to jxl
Browse files Browse the repository at this point in the history
  • Loading branch information
jafl committed Feb 10, 2024
1 parent 067abdd commit 75e628e
Show file tree
Hide file tree
Showing 6 changed files with 294 additions and 83 deletions.
129 changes: 63 additions & 66 deletions libjx/testui/code/TestTabDirector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,74 @@ TestTabDirector::~TestTabDirector()
void
TestTabDirector::BuildWindow()
{
JXWindow* window = jnew JXWindow(this, 300,300, JString::empty);
// begin JXLayout

window->SetTitle(JGetString("WindowTitle::TestTabDirector"));
window->SetWMClass("testjx", "TestTabDirector");
window->LockCurrentMinSize();

itsTabGroup = jnew JXTabGroup(window, JXWidget::kHElastic, JXWidget::kVElastic,
5, 5, 290, 290);
auto* window = jnew JXWindow(this, 300,300, JGetString("WindowTitle::TestTabDirector::JXLayout"));
window->SetWMClass(JXGetApplication()->GetWMName().GetBytes(), "TestTabDirector");

JXContainer* card3 = itsTabGroup->AppendTab(JGetString("Tab3Label::TestTabDirector"));
JXContainer* card1 = itsTabGroup->PrependTab(JGetString("Tab1Label::TestTabDirector"));
JXContainer* card2 = itsTabGroup->InsertTab(2, JGetString("Tab2Label::TestTabDirector"));
itsTabGroup =
jnew JXTabGroup(window,
JXWidget::kHElastic, JXWidget::kVElastic, 5,5, 290,290);
itsTabGroup->AppendTab(JGetString("itsTabGroup::tab1::TestTabDirector::JXLayout"));
itsTabGroup->AppendTab(JGetString("itsTabGroup::tab2::TestTabDirector::JXLayout"));
itsTabGroup->AppendTab(JGetString("itsTabGroup::tab3::TestTabDirector::JXLayout"));

// card 1
itsAddTabButton =
jnew JXTextButton(JGetString("itsAddTabButton::TestTabDirector::JXLayout"), itsTabGroup->GetTabEnclosure(2),
JXWidget::kFixedLeft, JXWidget::kFixedBottom, 20,20, 240,30);

itsFontMenu =
jnew JXFontNameMenu(JGetString("FontMenuTitle::TestTabDirector"), true, card1,
JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,20, 50,30);
assert( itsFontMenu != nullptr );
jnew JXFontNameMenu(JGetString("FontMenuTitle::TestTabDirector"), true, itsTabGroup->GetTabEnclosure(1),
JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,20, 240,30);

itsMonoFont =
jnew JXChooseMonoFont(itsTabGroup->GetTabEnclosure(3),
JXWidget::kHElastic, JXWidget::kFixedTop, 20,50, 230,60);

itsSizeMenu =
jnew JXFontSizeMenu(itsFontMenu, JGetString("SizeMenuTitle::TestTabDirector"), itsTabGroup->GetTabEnclosure(1),
JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,60, 240,30);

itsEdgeRG =
jnew JXRadioGroup(itsTabGroup->GetTabEnclosure(1),
JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,100, 240,140);

auto* rb1 =
jnew JXTextRadioButton(JXTabGroup::kTop, JGetString("rb1::TestTabDirector::JXLayout"), itsEdgeRG,
JXWidget::kFixedLeft, JXWidget::kFixedTop, 10,10, 210,20);
assert( rb1 != nullptr );

auto* rb2 =
jnew JXTextRadioButton(JXTabGroup::kLeft, JGetString("rb2::TestTabDirector::JXLayout"), itsEdgeRG,
JXWidget::kFixedLeft, JXWidget::kFixedTop, 10,40, 210,20);
assert( rb2 != nullptr );

auto* rb3 =
jnew JXTextRadioButton(JXTabGroup::kBottom, JGetString("rb3::TestTabDirector::JXLayout"), itsEdgeRG,
JXWidget::kFixedLeft, JXWidget::kFixedTop, 10,70, 210,20);
assert( rb3 != nullptr );

auto* rb4 =
jnew JXTextRadioButton(JXTabGroup::kRight, JGetString("rb4::TestTabDirector::JXLayout"), itsEdgeRG,
JXWidget::kFixedLeft, JXWidget::kFixedTop, 10,100, 210,20);
assert( rb4 != nullptr );

auto* input =
jnew JXIntegerInput(itsTabGroup->GetTabEnclosure(2),
JXWidget::kHElastic, JXWidget::kFixedTop, 20,60, 240,20);
input->SetIsRequired(false);
input->SetLowerLimit(-10);
input->SetUpperLimit(10);

itsMonoFontSample =
jnew JXInputField(itsTabGroup->GetTabEnclosure(3),
JXWidget::kHElastic, JXWidget::kFixedTop, 20,20, 240,20);
itsMonoFontSample->SetFont(JFontManager::GetDefaultMonospaceFont());

// end JXLayout

window->LockCurrentMinSize();

itsFontMenu->SetFontName(itsTabGroup->GetFont().GetName());
itsFontMenu->SetToPopupChoice();
ListenTo(itsFontMenu, std::function([this](const JXFontNameMenu::NameChanged&)
Expand All @@ -83,76 +132,24 @@ TestTabDirector::BuildWindow()
itsSizeMenu->SetFontName(name);
}));

const JString fontName = itsFontMenu->GetFontName();

itsSizeMenu =
jnew JXFontSizeMenu(fontName, JGetString("SizeMenuTitle::TestTabDirector"), card1,
JXWidget::kFixedLeft, JXWidget::kFixedTop, 20,60, 50,30);
assert( itsSizeMenu != nullptr );
itsSizeMenu->SetToPopupChoice();
ListenTo(itsSizeMenu, std::function([this](const JXFontSizeMenu::SizeChanged& msg)
{
itsTabGroup->SetFontSize(msg.GetSize());
}));

itsEdgeRG = jnew JXRadioGroup(card1, JXWidget::kFixedLeft, JXWidget::kFixedTop,
20,100, 100,140);

JXTextRadioButton* rb1 =
jnew JXTextRadioButton(JXTabGroup::kTop, JGetString("TopRBLabel::TestTabDirector"), itsEdgeRG,
JXWidget::kFixedLeft, JXWidget::kFixedTop,
10,10, 80,20);
assert( rb1 != nullptr );

JXTextRadioButton* rb2 =
jnew JXTextRadioButton(JXTabGroup::kLeft, JGetString("LeftRBLabel::TestTabDirector"), itsEdgeRG,
JXWidget::kFixedLeft, JXWidget::kFixedTop,
10,40, 80,20);
assert( rb2 != nullptr );

JXTextRadioButton* rb3 =
jnew JXTextRadioButton(JXTabGroup::kBottom, JGetString("BottomRBLabel::TestTabDirector"), itsEdgeRG,
JXWidget::kFixedLeft, JXWidget::kFixedTop,
10,70, 80,20);
assert( rb3 != nullptr );

JXTextRadioButton* rb4 =
jnew JXTextRadioButton(JXTabGroup::kRight, JGetString("RightRBLabel::TestTabDirector"), itsEdgeRG,
JXWidget::kFixedLeft, JXWidget::kFixedTop,
10,100, 80,20);
assert( rb4 != nullptr );

itsEdgeRG->SelectItem(itsTabGroup->GetTabEdge());
ListenTo(itsEdgeRG, std::function([this](const JXRadioGroup::SelectionChanged& msg)
{
itsTabGroup->SetTabEdge((JXTabGroup::Edge) msg.GetID());
}));

// card 2

itsAddTabButton =
jnew JXTextButton(JGetString("NewTabButtonLabel::TestTabDirector"), card2,
JXWidget::kFixedLeft, JXWidget::kFixedBottom,
20, 20, 200, 30);
assert( itsAddTabButton != nullptr );
ListenTo(itsAddTabButton);

JXIntegerInput* input =
jnew JXIntegerInput(card2, JXWidget::kHElastic, JXWidget::kFixedTop,
20, 60, 250, 20);
input->SetLimits(-10, 10);
input->SetValue(0);

// card 3

itsMonoFontSample =
jnew JXInputField(card3, JXWidget::kHElastic, JXWidget::kFixedTop,
20, 20, 200, 20);
itsMonoFontSample->GetText()->SetText(JGetString("SampleText::TestTabDirector"));

itsMonoFont =
jnew JXChooseMonoFont(card3, JXWidget::kHElastic, JXWidget::kFixedTop,
20, 50, 300, 100);
ListenTo(itsMonoFont, std::function([this](const JXChooseMonoFont::FontChanged&)
{
UpdateFontSample();
Expand Down
21 changes: 13 additions & 8 deletions libjx/testui/code/TestTabDirector.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@ class TestTabDirector : public JXWindowDirector

private:

JXTabGroup* itsTabGroup;
JXTextButton* itsAddTabButton;
JIndex itsNextTabIndex;
JXFontNameMenu* itsFontMenu;
JXFontSizeMenu* itsSizeMenu;
JXRadioGroup* itsEdgeRG;
JXChooseMonoFont* itsMonoFont;
JXInputField* itsMonoFontSample;
JIndex itsNextTabIndex;

// begin JXLayout

JXTabGroup* itsTabGroup;
JXTextButton* itsAddTabButton;
JXFontNameMenu* itsFontMenu;
JXChooseMonoFont* itsMonoFont;
JXFontSizeMenu* itsSizeMenu;
JXRadioGroup* itsEdgeRG;
JXInputField* itsMonoFontSample;

// end JXLayout

private:

Expand Down
199 changes: 199 additions & 0 deletions libjx/testui/code/TestTabDirector.jxl
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
jx_layout_editor 8
300
300
"JXLayout"
"Test Tab Group"
"TestTabDirector"
""
0

1
0
0
"TabGroup"
2
2
5 5 295 295
"itsTabGroup"
1
0
0
0
3
"First tab"
"Tab #2"
"Testing"

1
1
3
"InputField"
2
0
20 20 40 260
"itsMonoFontSample"
1
2
0
0
0
0
""
""
""
0
0
1
""

1
1
2
"TextButton"
0
1
20 20 50 260
"itsAddTabButton"
1
0
0
"Add new tab"
""

1
1
1
"CustomWidget"
0
0
20 20 50 260
"itsFontMenu"
1
0
0
"JXFontNameMenu"
"JGetString(\"FontMenuTitle::TestTabDirector\"), true"
0
""

1
1
3
"CustomWidget"
2
0
50 20 110 250
"itsMonoFont"
1
0
0
"JXChooseMonoFont"
""
0
""

1
1
2
"IntegerInput"
2
0
60 20 80 260
"input"
0
1
0
0
1 -10
1 10

1
1
1
"CustomWidget"
0
0
60 20 90 260
"itsSizeMenu"
1
0
0
"JXFontSizeMenu"
"itsFontMenu, JGetString(\"SizeMenuTitle::TestTabDirector\")"
0
""

1
1
1
"RadioGroup"
0
0
100 20 240 260
"itsEdgeRG"
1
0
0
0

1
8
1
"TextRadioButton"
0
0
10 10 30 220
"rb1"
0
0
0
"JXTabGroup::kTop"
"Top"
""

1
8
1
"TextRadioButton"
0
0
40 10 60 220
"rb2"
0
0
0
"JXTabGroup::kLeft"
"Left"
""

1
8
1
"TextRadioButton"
0
0
70 10 90 220
"rb3"
0
0
0
"JXTabGroup::kBottom"
"Bottom"
""

1
8
1
"TextRadioButton"
0
0
100 10 120 220
"rb4"
0
0
0
"JXTabGroup::kRight"
"Right"
""

0
Loading

0 comments on commit 75e628e

Please sign in to comment.