1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <LibCore/Timer.h>
#include <LibGUI/Application.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h>
#include <LibGUI/CheckBox.h>
#include <LibGUI/GroupBox.h>
#include <LibGUI/Label.h>
#include <LibGUI/ProgressBar.h>
#include <LibGUI/RadioButton.h>
#include <LibGUI/ScrollBar.h>
#include <LibGUI/Slider.h>
#include <LibGUI/SpinBox.h>
#include <LibGUI/TextBox.h>
#include <LibGUI/Widget.h>
#include <LibGUI/Window.h>
int main(int argc, char** argv)
{
GUI::Application app(argc, argv);
auto window = GUI::Window::construct();
window->set_rect(100, 100, 320, 620);
window->set_title("Widget Gallery");
auto& main_widget = window->set_main_widget<GUI::Widget>();
main_widget.set_fill_with_background_color(true);
main_widget.set_layout<GUI::VerticalBoxLayout>();
main_widget.layout()->set_margins({ 4, 4, 4, 4 });
auto& checkbox1 = main_widget.add<GUI::CheckBox>("CheckBox 1");
(void)checkbox1;
auto& checkbox2 = main_widget.add<GUI::CheckBox>("CheckBox 2");
checkbox2.set_enabled(false);
auto& radio1 = main_widget.add<GUI::RadioButton>("RadioButton 1");
(void)radio1;
auto& radio2 = main_widget.add<GUI::RadioButton>("RadioButton 2");
radio2.set_enabled(false);
auto& button1 = main_widget.add<GUI::Button>("Button 1");
(void)button1;
auto& button2 = main_widget.add<GUI::Button>("Button 2");
button2.set_enabled(false);
auto& progress1 = main_widget.add<GUI::ProgressBar>();
progress1.add<Core::Timer>(100, [&] {
progress1.set_value(progress1.value() + 1);
if (progress1.value() == progress1.max())
progress1.set_value(progress1.min());
});
auto& label1 = main_widget.add<GUI::Label>("Label 1");
(void)label1;
auto& label2 = main_widget.add<GUI::Label>("Label 2");
label2.set_enabled(false);
auto& textbox1 = main_widget.add<GUI::TextBox>();
textbox1.set_text("TextBox 1");
auto& textbox2 = main_widget.add<GUI::TextBox>();
textbox2.set_text("TextBox 2");
textbox2.set_enabled(false);
auto& spinbox1 = main_widget.add<GUI::SpinBox>();
(void)spinbox1;
auto& spinbox2 = main_widget.add<GUI::SpinBox>();
spinbox2.set_enabled(false);
auto& vertical_slider_container = main_widget.add<GUI::Widget>();
vertical_slider_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
vertical_slider_container.set_preferred_size(0, 100);
vertical_slider_container.set_layout<GUI::HorizontalBoxLayout>();
auto& vslider1 = vertical_slider_container.add<GUI::VerticalSlider>();
(void)vslider1;
auto& vslider2 = vertical_slider_container.add<GUI::VerticalSlider>();
vslider2.set_enabled(false);
auto& vslider3 = vertical_slider_container.add<GUI::VerticalSlider>();
vslider3.set_max(5);
vslider3.set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional);
auto& slider1 = main_widget.add<GUI::HorizontalSlider>();
(void)slider1;
auto& slider2 = main_widget.add<GUI::HorizontalSlider>();
slider2.set_enabled(false);
auto& slider3 = main_widget.add<GUI::HorizontalSlider>();
slider3.set_max(5);
slider3.set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional);
auto& scrollbar1 = main_widget.add<GUI::ScrollBar>(Orientation::Horizontal);
scrollbar1.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
scrollbar1.set_preferred_size(0, 16);
scrollbar1.set_min(0);
scrollbar1.set_max(100);
scrollbar1.set_value(50);
auto& scrollbar2 = main_widget.add<GUI::ScrollBar>(Orientation::Horizontal);
scrollbar2.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
scrollbar2.set_preferred_size(0, 16);
scrollbar2.set_enabled(false);
window->show();
return app.exec();
}
|