Skip to content

Commit

Permalink
Issue #89: Change stack to sizer
Browse files Browse the repository at this point in the history
  • Loading branch information
rmpowell77 committed Feb 13, 2023
1 parent 46a0a02 commit d4def89
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 190 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ ExampleDialog::ExampleDialog(wxWindow* parent)
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
using namespace wxUI;
VStack {
VSizer {
wxSizerFlags().Expand().Border(),
VStack {
VSizer {
"Text examples",
Text { "Example of Text in wxUI" },
TextCtrl { "Single line of text" }
Expand All @@ -37,15 +37,15 @@ ExampleDialog::ExampleDialog(wxWindow* parent)
.withMajorDim(1)
.withSelection(1),

HStack {
HSizer {
"Details",
CheckBox { "Show" },
Choice { { "Less", "More" } },
TextCtrl { wxSizerFlags(1).Expand().Border(), "Fill in the blank" }
.withStyle(wxALIGN_LEFT),
},

HStack {
HSizer {
wxSizerFlags().Center().Border(),
Button { wxSizerFlags().Border(wxRIGHT), "Left" }
.bind([] { wxLogMessage("Pressed Left"); }),
Expand Down Expand Up @@ -103,9 +103,9 @@ ExampleDialog::ExampleDialog(wxWindow* parent)
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
using namespace wxUI;
VStack {
VSizer {
wxSizerFlags().Expand().Border(),
VStack {
VSizer {
"Text examples",
Text { "Example of Text in wxUI" },
TextCtrl { "Single line of text" }
Expand Down
34 changes: 17 additions & 17 deletions docs/ProgrammersGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,41 +85,41 @@ The `wxUI::MenuBar` and related objects are generally "lazy" objects. They hold
### Layout
The basics of `wxUI` layout is the "Layout". You use a specific type of "Layout", with the `VStack` and `HStack` being the most common. When a "Layout" is set as the top level, it uses the layout as a sort of "blueprint" for stamping out the UI by constructing the ownership hierarchy and layout.
The basics of `wxUI` layout is the "Layout". You use a specific type of "Layout", with the `VSizer` (Vertical Sizer or "row") and `HSizer` (Horizontal Sizer or "column") being the most common. When a "Layout" is set as the top level, it uses the layout as a sort of "blueprint" for stamping out the UI by constructing the ownership hierarchy and layout.
```cpp
VStack {
VSizer {
wxSizerFlags().Expand().Border(),
VStack {
VSizer {
"Text examples",
// ...
}
.attachTo(this);
```

In the above example we have constructed a vertical layout stack that will use a `wxSizer` with the `wxSizerFlags` set to expand with a default border. Then the first item in the stack is a second layer stack with another vertical layout. The `wxSizerFlags` are propogated to each layer so the vertical layout in this example would also be set to expand with a default border. The second stack would be created as a "named" box vertical stack.
In the above example we have constructed a vertical layout sizer that will use a `wxSizer` with the `wxSizerFlags` set to expand with a default border. Then the first item in the sizer is a second layer sizer with horizontal layout. The `wxSizerFlags` are propogated to each layer so the horizontal layout in this example would also be set to expand with a default border. The second sizer would be created as a "named" box horizonal sizer.

A "Layout" takes a collection of Items, which can be either additional "Layout" (to create a tree of "Layouts") or "Controllers". Here is the general form of constructions for Stacks:
A "Layout" takes a collection of Items, which can be either additional "Layout" (to create a tree of "Layouts") or "Controllers". Here is the general form of constructions for Sizers:

```
Stack { Items... }
Stack { SizerFlags, Items... }
Stack { "Name", Items... }
Stack { "Name", SizerFlags, Items... }
Sizer { Items... }
Sizer { SizerFlags, Items... }
Sizer { "Name", Items... }
Sizer { "Name", SizerFlags, Items... }
```

`wxUI` supports 3 flavors of Stacks: `VStack` (Vertical Stacks), `HStack` (Horizontal Stacks), and `FlexGridStack` (Flexible Grid Stacks). Both `VStack` and `HStack` can be created with a string to create a "named" box.
`wxUI` supports 3 flavors of Sizers: `VSizer` (Vertical Sizers), `HSizer` (Horizontal Sizers), and `FlexGridSizer` (Flexible Grid Sizers). Both `VSizer` and `HSizer` can be created with a string to create a "named" box.

Note: Because Stacks are intented to be "recursive" data structures, it is possible for a `VStack` to contain a `VStack`. However, be aware that if an empty `VStack` is created with *just* a `VStack` as the argument, we collapse that to be a single `VStack`. ie, this:
Note: Because Sizers are intented to be "recursive" data structures, it is possible for a `VSizer` to contain a `VSizer`. However, be aware that if an empty `VSizer` is created with *just* a `VSizer` as the argument, we collapse that to be a single `VSizer`. ie, this:

```
wxUI::VStack { wxUI::VStack { "Current Frame" } }.attachTo(this);
wxUI::VSizer { wxUI::VSizer { "Current Frame" } }.attachTo(this);
```

is equivalant to:

```
wxUI::VStack { "Current Frame" }.attachTo(this);
wxUI::VSizer { "Current Frame" }.attachTo(this);
```


Expand All @@ -128,7 +128,7 @@ wxUI::VStack { "Current Frame" }.attachTo(this);
One special type of "Layout" is `Generic`. There are cases where you may have an existing layout as a `wxSizer` (such as a common dialog) or `wxWindow` (such as a custom window) that you wish to use with `wxUI`. This is a case to use `Generic`:

```cpp
VStack {
VSizer {
wxSizerFlags().Expand().Border(),
// ...
Generic { CreateStdDialogButtonSizer(wxOK) },
Expand All @@ -141,7 +141,7 @@ One special type of "Layout" is `Generic`. There are cases where you may have a
"Controllers" are the general term to refer to items that behave like a [`wxContol`](https://docs.wxwidgets.org/3.0/classwx_control.html). In `wxUI` we attempt to conform a consistent style that favors the common things you do with a specific `wxControl`.
```cpp
HStack {
HSizer {
"Details",
CheckBox { "Show" },
Choice { { "Less", "More" } },
Expand Down Expand Up @@ -210,7 +210,7 @@ ExtendedExample::ExtendedExample(wxWindow* parent)
: wxDialog(parent, wxID_ANY, "ExtendedExample")
{
using namespace wxUI;
VStack {
VSizer {
TextCtrl { "Hello" }
.getHandle(&mText),
},
Expand All @@ -236,7 +236,7 @@ concept CreateAndAddFunction = requires(T function, wxWindow* window, wxSizer* s
You would then create the controller to confomr

```cpp
HStack {
HSizer {
Custom {
[](wxWindow* window, wxSizer* sizer, wxSizerFlags flags) {
for (auto&& title : { "1", "2", "3" }) {
Expand Down
24 changes: 12 additions & 12 deletions docs/src/docs/ProgrammersGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,35 @@ The `wxUI::MenuBar` and related objects are generally "lazy" objects. They hold
### Layout
The basics of `wxUI` layout is the "Layout". You use a specific type of "Layout", with the `VStack` and `HStack` being the most common. When a "Layout" is set as the top level, it uses the layout as a sort of "blueprint" for stamping out the UI by constructing the ownership hierarchy and layout.
The basics of `wxUI` layout is the "Layout". You use a specific type of "Layout", with the `VSizer` (Vertical Sizer or "row") and `HSizer` (Horizontal Sizer or "column") being the most common. When a "Layout" is set as the top level, it uses the layout as a sort of "blueprint" for stamping out the UI by constructing the ownership hierarchy and layout.
```cpp
{{{ examples/HelloWorld/HelloWorld.cpp wxUILayoutBasic " // ..." }}}
```

In the above example we have constructed a vertical layout stack that will use a `wxSizer` with the `wxSizerFlags` set to expand with a default border. Then the first item in the stack is a second layer stack with another vertical layout. The `wxSizerFlags` are propogated to each layer so the vertical layout in this example would also be set to expand with a default border. The second stack would be created as a "named" box vertical stack.
In the above example we have constructed a vertical layout sizer that will use a `wxSizer` with the `wxSizerFlags` set to expand with a default border. Then the first item in the sizer is a second layer sizer with horizontal layout. The `wxSizerFlags` are propogated to each layer so the horizontal layout in this example would also be set to expand with a default border. The second sizer would be created as a "named" box horizonal sizer.

A "Layout" takes a collection of Items, which can be either additional "Layout" (to create a tree of "Layouts") or "Controllers". Here is the general form of constructions for Stacks:
A "Layout" takes a collection of Items, which can be either additional "Layout" (to create a tree of "Layouts") or "Controllers". Here is the general form of constructions for Sizers:

```
Stack { Items... }
Stack { SizerFlags, Items... }
Stack { "Name", Items... }
Stack { "Name", SizerFlags, Items... }
Sizer { Items... }
Sizer { SizerFlags, Items... }
Sizer { "Name", Items... }
Sizer { "Name", SizerFlags, Items... }
```

`wxUI` supports 3 flavors of Stacks: `VStack` (Vertical Stacks), `HStack` (Horizontal Stacks), and `FlexGridStack` (Flexible Grid Stacks). Both `VStack` and `HStack` can be created with a string to create a "named" box.
`wxUI` supports 3 flavors of Sizers: `VSizer` (Vertical Sizers), `HSizer` (Horizontal Sizers), and `FlexGridSizer` (Flexible Grid Sizers). Both `VSizer` and `HSizer` can be created with a string to create a "named" box.

Note: Because Stacks are intented to be "recursive" data structures, it is possible for a `VStack` to contain a `VStack`. However, be aware that if an empty `VStack` is created with *just* a `VStack` as the argument, we collapse that to be a single `VStack`. ie, this:
Note: Because Sizers are intented to be "recursive" data structures, it is possible for a `VSizer` to contain a `VSizer`. However, be aware that if an empty `VSizer` is created with *just* a `VSizer` as the argument, we collapse that to be a single `VSizer`. ie, this:

```
wxUI::VStack { wxUI::VStack { "Current Frame" } }.attachTo(this);
wxUI::VSizer { wxUI::VSizer { "Current Frame" } }.attachTo(this);
```

is equivalant to:

```
wxUI::VStack { "Current Frame" }.attachTo(this);
wxUI::VSizer { "Current Frame" }.attachTo(this);
```


Expand Down Expand Up @@ -158,7 +158,7 @@ ExtendedExample::ExtendedExample(wxWindow* parent)
: wxDialog(parent, wxID_ANY, "ExtendedExample")
{
using namespace wxUI;
VStack {
VSizer {
TextCtrl { "Hello" }
.getHandle(&mText),
},
Expand Down
32 changes: 16 additions & 16 deletions examples/HelloWorld/ExtendedExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,49 +33,49 @@ ExtendedExample::ExtendedExample(wxWindow* parent)
{
using namespace wxUI;
wxStaticText* text = nullptr;
VStack {
VSizer {
wxSizerFlags().Expand().Border(),
HStack {
HSizer {
BitmapButton { wxBitmap {} },
},
HStack {
HSizer {
BitmapComboBox { { std::tuple { "", wxBitmap {} } } },
},
HStack {
HSizer {
BitmapToggleButton { wxBitmap {} },
},
HStack {
HSizer {
Button {},
},
HStack {
HSizer {
CheckBox {},
},
HStack {
HSizer {
ComboBox { { "hello" } },
},
HStack {
HSizer {
Line {},
},
HStack {
HSizer {
ListBox { {} },
},
HStack {
HSizer {
RadioBox { std::vector<wxString> { "hello" } },
},
HStack {
HSizer {
Slider {},
},
HStack {
HSizer {
SpinCtrl {},
},
HStack {
HSizer {
Text {},
},
HStack {
HSizer {
TextCtrl {},
},
// getHandle example
HStack {
HSizer {
Text { "Hello" }
.getHandle(&text),
},
Expand All @@ -89,7 +89,7 @@ ExtendedExample::ExtendedExample(wxWindow* parent)
.bind([](auto& e) { (void)e; }),
},
// snippet CustomExample
HStack {
HSizer {
Custom {
[](wxWindow* window, wxSizer* sizer, wxSizerFlags flags) {
for (auto&& title : { "1", "2", "3" }) {
Expand Down
8 changes: 4 additions & 4 deletions examples/HelloWorld/HelloWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ ExampleDialog::ExampleDialog(wxWindow* parent)
using namespace wxUI;
// snippet wxUILayoutBasic
// snippet wxUIGeneric
VStack {
VSizer {
wxSizerFlags().Expand().Border(),
// endsnippet wxUIGeneric
VStack {
VSizer {
"Text examples",
// endsnippet wxUILayoutBasic
Text { "Example of Text in wxUI" },
Expand All @@ -257,7 +257,7 @@ ExampleDialog::ExampleDialog(wxWindow* parent)
.withSelection(1),

// snippet wxUIController
HStack {
HSizer {
"Details",
CheckBox { "Show" },
Choice { { "Less", "More" } },
Expand All @@ -266,7 +266,7 @@ ExampleDialog::ExampleDialog(wxWindow* parent)
},
// endsnippet wxUIController

HStack {
HSizer {
wxSizerFlags().Center().Border(),
// snippet wxUIBind
Button { wxSizerFlags().Border(wxRIGHT), "Left" }
Expand Down
Loading

0 comments on commit d4def89

Please sign in to comment.