Debian Codegraph @

phoenix/core/core.cpp

raw
1 #if defined(PHOENIX_WINDOWS)
2 #include "../windows/header.hpp"
3 #elif defined(PHOENIX_QT)
4 #include "../qt/header.hpp"
5 #elif defined(PHOENIX_GTK)
6 #include "../gtk/header.hpp"
7 #elif defined(PHOENIX_COCOA)
8 #include "../cocoa/header.hpp"
9 #elif defined(PHOENIX_REFERENCE)
10 #include "../reference/header.hpp"
11 #endif
12
13 #include "core.hpp"
14 using namespace nall;
15
16 namespace phoenix {
17 #include "state.hpp"
18 #include "layout/fixed-layout.cpp"
19 #include "layout/horizontal-layout.cpp"
20 #include "layout/vertical-layout.cpp"
21 }
22
23 #if defined(PHOENIX_WINDOWS)
24 #include "../windows/platform.cpp"
25 #elif defined(PHOENIX_QT)
26 #include "../qt/platform.cpp"
27 #elif defined(PHOENIX_GTK)
28 #include "../gtk/platform.cpp"
29 #elif defined(PHOENIX_COCOA)
30 #include "../cocoa/platform.cpp"
31 #elif defined(PHOENIX_REFERENCE)
32 #include "../reference/platform.cpp"
33 #endif
34
35 namespace phoenix {
36
37 //Application
38 //===========
39
40 function<void ()> Application::main;
41
42 function<void ()> Application::Windows::onModalBegin;
43 function<void ()> Application::Windows::onModalEnd;
44
45 function<void ()> Application::Cocoa::onAbout;
46 function<void ()> Application::Cocoa::onActivate;
47 function<void ()> Application::Cocoa::onPreferences;
48 function<void ()> Application::Cocoa::onQuit;
49
50 void Application::run() {
51 return pApplication::run();
52 }
53
54 bool Application::pendingEvents() {
55 return pApplication::pendingEvents();
56 }
57
58 void Application::processEvents() {
59 return pApplication::processEvents();
60 }
61
62 void Application::quit() {
63 applicationState.quit = true;
64 return pApplication::quit();
65 }
66
67 void Application::setName(const string& name) {
68 applicationState.name = name;
69 }
70
71 void Application::initialize() {
72 static bool initialized = false;
73 if(initialized == false) {
74 initialized = true;
75 return pApplication::initialize();
76 }
77 }
78
79 //Color
80 //=====
81
82 uint32_t Color::rgb() const {
83 return (255 << 24) + (red << 16) + (green << 8) + (blue << 0);
84 }
85
86 uint32_t Color::argb() const {
87 return (alpha << 24) + (red << 16) + (green << 8) + (blue << 0);
88 }
89
90 //Geometry
91 //========
92
93 Position Geometry::position() const {
94 return {x, y};
95 }
96
97 Size Geometry::size() const {
98 return {width, height};
99 }
100
101 string Geometry::text() const {
102 return {x, ",", y, ",", width, ",", height};
103 }
104
105 Geometry::Geometry(const string& text) {
106 lstring part = text.split(",");
107 x = integer(part(0, "256"));
108 y = integer(part(1, "256"));
109 width = decimal(part(2, "256"));
110 height = decimal(part(3, "256"));
111 }
112
113 //Font
114 //====
115
116 string Font::serif(unsigned size, const string& style) {
117 return pFont::serif(size, style);
118 }
119
120 string Font::sans(unsigned size, const string& style) {
121 return pFont::sans(size, style);
122 }
123
124 string Font::monospace(unsigned size, const string& style) {
125 return pFont::monospace(size, style);
126 }
127
128 Size Font::size(const string& font, const string& text) {
129 return pFont::size(font, text);
130 }
131
132 //Desktop
133 //=======
134
135 Size Desktop::size() {
136 return pDesktop::size();
137 }
138
139 Geometry Desktop::workspace() {
140 return pDesktop::workspace();
141 }
142
143 //Monitor
144 //=======
145
146 unsigned Monitor::count() {
147 return pMonitor::count();
148 }
149
150 Geometry Monitor::geometry(unsigned monitor) {
151 return pMonitor::geometry(monitor);
152 }
153
154 unsigned Monitor::primary() {
155 return pMonitor::primary();
156 }
157
158 //Keyboard
159 //========
160
161 bool Keyboard::pressed(Keyboard::Scancode scancode) {
162 return pKeyboard::pressed(scancode);
163 }
164
165 bool Keyboard::released(Keyboard::Scancode scancode) {
166 return !pressed(scancode);
167 }
168
169 vector<bool> Keyboard::state() {
170 return pKeyboard::state();
171 }
172
173 //Mouse
174 //=====
175
176 Position Mouse::position() {
177 return pMouse::position();
178 }
179
180 bool Mouse::pressed(Mouse::Button button) {
181 return pMouse::pressed(button);
182 }
183
184 bool Mouse::released(Mouse::Button button) {
185 return !pressed(button);
186 }
187
188 //BrowserWindow
189 //=============
190
191 string BrowserWindow::directory() {
192 return pBrowserWindow::directory(state);
193 }
194
195 string BrowserWindow::open() {
196 return pBrowserWindow::open(state);
197 }
198
199 string BrowserWindow::save() {
200 return pBrowserWindow::save(state);
201 }
202
203 BrowserWindow& BrowserWindow::setFilters(const lstring& filters) {
204 state.filters = filters;
205 return *this;
206 }
207
208 BrowserWindow& BrowserWindow::setParent(Window& parent) {
209 state.parent = &parent;
210 return *this;
211 }
212
213 BrowserWindow& BrowserWindow::setPath(const string& path) {
214 state.path = path;
215 return *this;
216 }
217
218 BrowserWindow& BrowserWindow::setTitle(const string& title) {
219 state.title = title;
220 return *this;
221 }
222
223 BrowserWindow::BrowserWindow():
224 state(*new State) {
225 }
226
227 BrowserWindow::~BrowserWindow() {
228 delete &state;
229 }
230
231 //MessageWindow
232 //=============
233
234 MessageWindow::Response MessageWindow::error(MessageWindow::Buttons buttons) {
235 state.buttons = buttons;
236 return pMessageWindow::error(state);
237 }
238
239 MessageWindow::Response MessageWindow::information(MessageWindow::Buttons buttons) {
240 state.buttons = buttons;
241 return pMessageWindow::information(state);
242 }
243
244 MessageWindow::Response MessageWindow::question(MessageWindow::Buttons buttons) {
245 state.buttons = buttons;
246 return pMessageWindow::question(state);
247 }
248
249 MessageWindow& MessageWindow::setParent(Window& parent) {
250 state.parent = &parent;
251 return *this;
252 }
253
254 MessageWindow& MessageWindow::setText(const string& text) {
255 state.text = text;
256 return *this;
257 }
258
259 MessageWindow& MessageWindow::setTitle(const string& title) {
260 state.title = title;
261 return *this;
262 }
263
264 MessageWindow::Response MessageWindow::warning(MessageWindow::Buttons buttons) {
265 state.buttons = buttons;
266 return pMessageWindow::warning(state);
267 }
268
269 MessageWindow::MessageWindow(const string& text):
270 state(*new State) {
271 state.text = text;
272 }
273
274 MessageWindow::~MessageWindow() {
275 delete &state;
276 }
277
278 //Object
279 //======
280
281 Object::Object(pObject& p):
282 p(p) {
283 Application::initialize();
284 p.constructor();
285 }
286
287 Object::~Object() {
288 p.destructor();
289 delete &p;
290 }
291
292 //Timer
293 //=====
294
295 bool Timer::enabled() const {
296 return state.enabled;
297 }
298
299 unsigned Timer::interval() const {
300 return state.interval;
301 }
302
303 void Timer::setEnabled(bool enabled) {
304 state.enabled = enabled;
305 return p.setEnabled(enabled);
306 }
307
308 void Timer::setInterval(unsigned interval) {
309 state.interval = interval;
310 return p.setInterval(interval);
311 }
312
313 Timer::Timer():
314 state(*new State),
315 base_from_member<pTimer&>(*new pTimer(*this)),
316 Object(base_from_member<pTimer&>::value),
317 p(base_from_member<pTimer&>::value) {
318 p.constructor();
319 }
320
321 Timer::~Timer() {
322 p.destructor();
323 delete &state;
324 }
325
326 //Window
327 //======
328
329 void Window::append(Layout& layout) {
330 if(state.layout.append(layout)) {
331 layout.Sizable::state.parent = nullptr;
332 layout.Sizable::state.window = this;
333 p.append(layout);
334 layout.synchronizeLayout();
335 }
336 }
337
338 void Window::append(Menu& menu) {
339 if(state.menu.append(menu)) {
340 menu.Action::state.window = this;
341 p.append(menu);
342 }
343 }
344
345 void Window::append(Widget& widget) {
346 if(state.widget.append(widget)) {
347 widget.Sizable::state.window = this;
348 p.append(widget);
349 widget.synchronizeLayout();
350 }
351 }
352
353 Color Window::backgroundColor() const {
354 return state.backgroundColor;
355 }
356
357 bool Window::droppable() const {
358 return state.droppable;
359 }
360
361 Geometry Window::frameGeometry() {
362 Geometry geometry = p.geometry();
363 Geometry margin = p.frameMargin();
364 return {
365 geometry.x - margin.x, geometry.y - margin.y,
366 geometry.width + margin.width, geometry.height + margin.height
367 };
368 }
369
370 Geometry Window::frameMargin() {
371 return p.frameMargin();
372 }
373
374 bool Window::focused() {
375 return p.focused();
376 }
377
378 bool Window::fullScreen() const {
379 return state.fullScreen;
380 }
381
382 Geometry Window::geometry() {
383 return p.geometry();
384 }
385
386 string Window::menuFont() const {
387 return state.menuFont;
388 }
389
390 bool Window::menuVisible() const {
391 return state.menuVisible;
392 }
393
394 bool Window::modal() const {
395 return state.modal;
396 }
397
398 void Window::remove(Layout& layout) {
399 if(state.layout.remove(layout)) {
400 p.remove(layout);
401 layout.Sizable::state.window = nullptr;
402 }
403 }
404
405 void Window::remove(Menu& menu) {
406 if(state.menu.remove(menu)) {
407 p.remove(menu);
408 menu.Action::state.window = nullptr;
409 }
410 }
411
412 void Window::remove(Widget& widget) {
413 if(state.widget.remove(widget)) {
414 p.remove(widget);
415 widget.Sizable::state.window = nullptr;
416 }
417 }
418
419 bool Window::resizable() const {
420 return state.resizable;
421 }
422
423 void Window::setBackgroundColor(Color color) {
424 state.backgroundColorOverride = true;
425 state.backgroundColor = color;
426 return p.setBackgroundColor(color);
427 }
428
429 void Window::setDroppable(bool droppable) {
430 state.droppable = droppable;
431 return p.setDroppable(droppable);
432 }
433
434 void Window::setFrameGeometry(Geometry geometry) {
435 Geometry margin = p.frameMargin();
436 return setGeometry({
437 geometry.x + margin.x, geometry.y + margin.y,
438 geometry.width - margin.width, geometry.height - margin.height
439 });
440 }
441
442 void Window::setFocused() {
443 return p.setFocused();
444 }
445
446 void Window::setFullScreen(bool fullScreen) {
447 state.fullScreen = fullScreen;
448 return p.setFullScreen(fullScreen);
449 }
450
451 void Window::setGeometry(Geometry geometry) {
452 state.geometry = geometry;
453 return p.setGeometry(geometry);
454 }
455
456 void Window::setMenuFont(const string& font) {
457 state.menuFont = font;
458 return p.setMenuFont(font);
459 }
460
461 void Window::setMenuVisible(bool visible) {
462 state.menuVisible = visible;
463 return p.setMenuVisible(visible);
464 }
465
466 void Window::setModal(bool modal) {
467 state.modal = modal;
468 return p.setModal(modal);
469 }
470
471 void Window::setResizable(bool resizable) {
472 state.resizable = resizable;
473 return p.setResizable(resizable);
474 }
475
476 void Window::setStatusFont(const string& font) {
477 state.statusFont = font;
478 return p.setStatusFont(font);
479 }
480
481 void Window::setStatusText(const string& text) {
482 state.statusText = text;
483 return p.setStatusText(text);
484 }
485
486 void Window::setStatusVisible(bool visible) {
487 state.statusVisible = visible;
488 return p.setStatusVisible(visible);
489 }
490
491 void Window::setTitle(const string& text) {
492 state.title = text;
493 return p.setTitle(text);
494 }
495
496 void Window::setVisible(bool visible) {
497 state.visible = visible;
498 synchronizeLayout();
499 return p.setVisible(visible);
500 }
501
502 void Window::setWidgetFont(const string& font) {
503 state.widgetFont = font;
504 return p.setWidgetFont(font);
505 }
506
507 void Window::setWindowGeometry(Geometry geometry) {
508 Geometry margin = p.frameMargin();
509 return setGeometry({
510 geometry.x + margin.x, geometry.y + margin.y,
511 geometry.width, geometry.height
512 });
513 }
514
515 string Window::statusFont() const {
516 return state.statusFont;
517 }
518
519 string Window::statusText() const {
520 return state.statusText;
521 }
522
523 bool Window::statusVisible() const {
524 return state.statusVisible;
525 }
526
527 void Window::synchronizeLayout() {
528 if(visible() && applicationState.quit == false) setGeometry(geometry());
529 }
530
531 string Window::title() const {
532 return state.title;
533 }
534
535 bool Window::visible() const {
536 return state.visible;
537 }
538
539 string Window::widgetFont() const {
540 return state.widgetFont;
541 }
542
543 Window::Window():
544 state(*new State),
545 base_from_member<pWindow&>(*new pWindow(*this)),
546 Object(base_from_member<pWindow&>::value),
547 p(base_from_member<pWindow&>::value) {
548 p.constructor();
549 }
550
551 Window::~Window() {
552 p.destructor();
553 delete &state;
554 }
555
556 //Action
557 //======
558
559 bool Action::enabled() const {
560 return state.enabled;
561 }
562
563 void Action::setEnabled(bool enabled) {
564 state.enabled = enabled;
565 return p.setEnabled(enabled);
566 }
567
568 void Action::setVisible(bool visible) {
569 state.visible = visible;
570 return p.setVisible(visible);
571 }
572
573 bool Action::visible() const {
574 return state.visible;
575 }
576
577 Action::Action(pAction& p):
578 state(*new State),
579 Object(p),
580 p(p) {
581 p.constructor();
582 }
583
584 Action::~Action() {
585 p.destructor();
586 delete &state;
587 }
588
589 //Menu
590 //====
591
592 void Menu::append(const group<Action>& list) {
593 for(auto& action : list) {
594 if(state.action.append(action)) {
595 action.state.menu = this;
596 p.append(action);
597 }
598 }
599 }
600
601 image Menu::image() const {
602 return state.image;
603 }
604
605 void Menu::remove(const group<Action>& list) {
606 for(auto& action : list) {
607 if(state.action.remove(action)) {
608 action.state.menu = nullptr;
609 return p.remove(action);
610 }
611 }
612 }
613
614 void Menu::setImage(const nall::image& image) {
615 state.image = image;
616 return p.setImage(image);
617 }
618
619 void Menu::setText(const string& text) {
620 state.text = text;
621 return p.setText(text);
622 }
623
624 string Menu::text() const {
625 return state.text;
626 }
627
628 Menu::Menu():
629 state(*new State),
630 base_from_member<pMenu&>(*new pMenu(*this)),
631 Action(base_from_member<pMenu&>::value),
632 p(base_from_member<pMenu&>::value) {
633 p.constructor();
634 }
635
636 Menu::~Menu() {
637 p.destructor();
638 delete &state;
639 }
640
641 //Separator
642 //=========
643
644 Separator::Separator():
645 base_from_member<pSeparator&>(*new pSeparator(*this)),
646 Action(base_from_member<pSeparator&>::value),
647 p(base_from_member<pSeparator&>::value) {
648 p.constructor();
649 }
650
651 Separator::~Separator() {
652 p.destructor();
653 }
654
655 //Item
656 //====
657
658 image Item::image() const {
659 return state.image;
660 }
661
662 void Item::setImage(const nall::image& image) {
663 state.image = image;
664 return p.setImage(image);
665 }
666
667 void Item::setText(const string& text) {
668 state.text = text;
669 return p.setText(text);
670 }
671
672 string Item::text() const {
673 return state.text;
674 }
675
676 Item::Item():
677 state(*new State),
678 base_from_member<pItem&>(*new pItem(*this)),
679 Action(base_from_member<pItem&>::value),
680 p(base_from_member<pItem&>::value) {
681 p.constructor();
682 }
683
684 Item::~Item() {
685 p.destructor();
686 delete &state;
687 }
688
689 //CheckItem
690 //=========
691
692 bool CheckItem::checked() const {
693 return state.checked;
694 }
695
696 void CheckItem::setChecked(bool checked) {
697 state.checked = checked;
698 return p.setChecked(checked);
699 }
700
701 void CheckItem::setText(const string& text) {
702 state.text = text;
703 return p.setText(text);
704 }
705
706 string CheckItem::text() const {
707 return state.text;
708 }
709
710 CheckItem::CheckItem():
711 state(*new State),
712 base_from_member<pCheckItem&>(*new pCheckItem(*this)),
713 Action(base_from_member<pCheckItem&>::value),
714 p(base_from_member<pCheckItem&>::value) {
715 p.constructor();
716 }
717
718 CheckItem::~CheckItem() {
719 p.destructor();
720 delete &state;
721 }
722
723 //RadioItem
724 //=========
725
726 void RadioItem::group(const nall::group<RadioItem>& list) {
727 for(auto& item : list) item.p.setGroup(item.state.group = list);
728 if(list.size()) list.first().setChecked();
729 }
730
731 bool RadioItem::checked() const {
732 return state.checked;
733 }
734
735 void RadioItem::setChecked() {
736 for(auto& item : state.group) item.state.checked = false;
737 state.checked = true;
738 return p.setChecked();
739 }
740
741 void RadioItem::setText(const string& text) {
742 state.text = text;
743 return p.setText(text);
744 }
745
746 string RadioItem::text() const {
747 return state.text;
748 }
749
750 RadioItem::RadioItem():
751 state(*new State),
752 base_from_member<pRadioItem&>(*new pRadioItem(*this)),
753 Action(base_from_member<pRadioItem&>::value),
754 p(base_from_member<pRadioItem&>::value) {
755 p.constructor();
756 }
757
758 RadioItem::~RadioItem() {
759 for(auto& item : state.group) {
760 if(&item != this) item.state.group.remove(*this);
761 }
762 p.destructor();
763 delete &state;
764 }
765
766 //Sizable
767 //=======
768
769 bool Sizable::enabled() const {
770 return state.enabled;
771 }
772
773 bool Sizable::enabledToAll() const {
774 if(state.enabled == false) return false;
775 if(state.parent) return state.parent->enabledToAll();
776 return true;
777 }
778
779 Layout* Sizable::layout() const {
780 if(state.parent && dynamic_cast<Layout*>(state.parent)) return (Layout*)state.parent;
781 return nullptr;
782 }
783
784 Sizable* Sizable::parent() const {
785 return state.parent;
786 }
787
788 bool Sizable::visible() const {
789 return state.visible;
790 }
791
792 bool Sizable::visibleToAll() const {
793 if(state.visible == false) return false;
794 if(state.parent) return state.parent->visibleToAll();
795 return true;
796 }
797
798 Window* Sizable::window() const {
799 return state.window;
800 }
801
802 Sizable::Sizable(pSizable& p):
803 state(*new State),
804 Object(p),
805 p(p) {
806 p.constructor();
807 }
808
809 Sizable::~Sizable() {
810 if(layout()) layout()->remove(*this);
811 p.destructor();
812 delete &state;
813 }
814
815 //Layout
816 //======
817
818 void Layout::append(Sizable& sizable) {
819 sizable.state.parent = this;
820 sizable.state.window = Sizable::state.window;
821
822 if(dynamic_cast<Layout*>(&sizable)) {
823 Layout& layout = (Layout&)sizable;
824 layout.synchronizeLayout();
825 }
826
827 if(dynamic_cast<Widget*>(&sizable)) {
828 Widget& widget = (Widget&)sizable;
829 if(sizable.window()) sizable.window()->append(widget);
830 }
831 }
832
833 void Layout::remove(Sizable& sizable) {
834 if(dynamic_cast<Widget*>(&sizable)) {
835 Widget& widget = (Widget&)sizable;
836 if(sizable.window()) sizable.window()->remove(widget);
837 }
838
839 sizable.state.parent = nullptr;
840 sizable.state.window = nullptr;
841 }
842
843 void Layout::reset() {
844 }
845
846 Layout::Layout():
847 state(*new State),
848 base_from_member<pLayout&>(*new pLayout(*this)),
849 Sizable(base_from_member<pLayout&>::value),
850 p(base_from_member<pLayout&>::value) {
851 }
852
853 Layout::Layout(pLayout& p):
854 state(*new State),
855 base_from_member<pLayout&>(p),
856 Sizable(p),
857 p(p) {
858 }
859
860 Layout::~Layout() {
861 if(layout()) layout()->remove(*this);
862 if(window()) window()->remove(*this);
863 p.destructor();
864 delete &state;
865 }
866
867 //Widget
868 //======
869
870 bool Widget::focused() {
871 return p.focused();
872 }
873
874 string Widget::font() const {
875 return state.font;
876 }
877
878 Geometry Widget::geometry() const {
879 return state.geometry;
880 }
881
882 Size Widget::minimumSize() {
883 return p.minimumSize();
884 }
885
886 void Widget::setEnabled(bool enabled) {
887 Sizable::state.enabled = enabled;
888 return p.setEnabled(enabled);
889 }
890
891 void Widget::setFocused() {
892 return p.setFocused();
893 }
894
895 void Widget::setFont(const string& font) {
896 state.font = font;
897 return p.setFont(font);
898 }
899
900 void Widget::setGeometry(Geometry geometry) {
901 state.geometry = geometry;
902 return p.setGeometry(geometry);
903 }
904
905 void Widget::setVisible(bool visible) {
906 Sizable::state.visible = visible;
907 return p.setVisible(visible);
908 }
909
910 void Widget::synchronizeLayout() {
911 }
912
913 Widget::Widget():
914 state(*new State),
915 base_from_member<pWidget&>(*new pWidget(*this)),
916 Sizable(base_from_member<pWidget&>::value),
917 p(base_from_member<pWidget&>::value) {
918 state.abstract = true;
919 p.constructor();
920 }
921
922 Widget::Widget(pWidget& p):
923 state(*new State),
924 base_from_member<pWidget&>(p),
925 Sizable(base_from_member<pWidget&>::value),
926 p(base_from_member<pWidget&>::value) {
927 p.constructor();
928 }
929
930 Widget::~Widget() {
931 p.destructor();
932 delete &state;
933 }
934
935 //Button
936 //======
937
938 image Button::image() const {
939 return state.image;
940 }
941
942 Orientation Button::orientation() const {
943 return state.orientation;
944 }
945
946 void Button::setImage(const nall::image& image, Orientation orientation) {
947 state.image = image;
948 state.orientation = orientation;
949 return p.setImage(image, orientation);
950 }
951
952 void Button::setText(const string& text) {
953 state.text = text;
954 return p.setText(text);
955 }
956
957 nall::string Button::text() const {
958 return state.text;
959 }
960
961 Button::Button():
962 state(*new State),
963 base_from_member<pButton&>(*new pButton(*this)),
964 Widget(base_from_member<pButton&>::value),
965 p(base_from_member<pButton&>::value) {
966 p.constructor();
967 }
968
969 Button::~Button() {
970 p.destructor();
971 delete &state;
972 }
973
974 //Canvas
975 //======
976
977 Color Canvas::color() const {
978 return state.color;
979 }
980
981 uint32_t* Canvas::data() const {
982 return state.data;
983 }
984
985 bool Canvas::droppable() const {
986 return state.droppable;
987 }
988
989 vector<Color> Canvas::gradient() const {
990 return state.gradient;
991 }
992
993 image Canvas::image() const {
994 return state.image;
995 }
996
997 Canvas::Mode Canvas::mode() const {
998 return state.mode;
999 }
1000
1001 void Canvas::setColor(Color color) {
1002 state.color = color;
1003 return setMode(Canvas::Mode::Color);
1004 }
1005
1006 void Canvas::setData() {
1007 if(state.width == 0 || state.height == 0) return; //dynamic sizing not supported in Mode::Data
1008 return setMode(Canvas::Mode::Data);
1009 }
1010
1011 void Canvas::setDroppable(bool droppable) {
1012 state.droppable = droppable;
1013 return p.setDroppable(droppable);
1014 }
1015
1016 void Canvas::setGradient(Color topLeft, Color topRight, Color bottomLeft, Color bottomRight) {
1017 state.gradient[0] = topLeft;
1018 state.gradient[1] = topRight;
1019 state.gradient[2] = bottomLeft;
1020 state.gradient[3] = bottomRight;
1021 return setMode(Canvas::Mode::Gradient);
1022 }
1023
1024 void Canvas::setHorizontalGradient(Color left, Color right) {
1025 state.gradient[0] = state.gradient[2] = left;
1026 state.gradient[1] = state.gradient[3] = right;
1027 return setMode(Canvas::Mode::Gradient);
1028 }
1029
1030 void Canvas::setImage(const nall::image& image) {
1031 state.image = image;
1032 return setMode(Canvas::Mode::Image);
1033 }
1034
1035 void Canvas::setMode(Mode mode) {
1036 state.mode = mode;
1037 return p.setMode(mode);
1038 }
1039
1040 void Canvas::setSize(Size size) {
1041 if(size.width == Size::Maximum) size.width = 0;
1042 if(size.height == Size::Maximum) size.height = 0;
1043 state.width = size.width;
1044 state.height = size.height;
1045 delete[] state.data;
1046 state.data = new uint32_t[state.width * state.height]();
1047 return setMode(state.mode);
1048 }
1049
1050 void Canvas::setVerticalGradient(Color top, Color bottom) {
1051 state.gradient[0] = state.gradient[1] = top;
1052 state.gradient[2] = state.gradient[3] = bottom;
1053 return setMode(Canvas::Mode::Gradient);
1054 }
1055
1056 Size Canvas::size() const {
1057 return {state.width, state.height};
1058 }
1059
1060 Canvas::Canvas():
1061 state(*new State),
1062 base_from_member<pCanvas&>(*new pCanvas(*this)),
1063 Widget(base_from_member<pCanvas&>::value),
1064 p(base_from_member<pCanvas&>::value) {
1065 state.data = new uint32_t[state.width * state.height]();
1066 p.constructor();
1067 }
1068
1069 Canvas::~Canvas() {
1070 p.destructor();
1071 delete[] state.data;
1072 delete &state;
1073 }
1074
1075 //CheckButton
1076 //===========
1077
1078 bool CheckButton::checked() const {
1079 return state.checked;
1080 }
1081
1082 image CheckButton::image() const {
1083 return state.image;
1084 }
1085
1086 void CheckButton::setChecked(bool checked) {
1087 state.checked = checked;
1088 return p.setChecked(checked);
1089 }
1090
1091 void CheckButton::setImage(const nall::image& image, Orientation orientation) {
1092 state.image = image;
1093 state.orientation = orientation;
1094 return p.setImage(image, orientation);
1095 }
1096
1097 void CheckButton::setText(const string& text) {
1098 state.text = text;
1099 return p.setText(text);
1100 }
1101
1102 string CheckButton::text() const {
1103 return state.text;
1104 }
1105
1106 CheckButton::CheckButton():
1107 state(*new State),
1108 base_from_member<pCheckButton&>(*new pCheckButton(*this)),
1109 Widget(base_from_member<pCheckButton&>::value),
1110 p(base_from_member<pCheckButton&>::value) {
1111 p.constructor();
1112 }
1113
1114 CheckButton::~CheckButton() {
1115 p.destructor();
1116 delete &state;
1117 }
1118
1119 //CheckLabel
1120 //==========
1121
1122 bool CheckLabel::checked() const {
1123 return state.checked;
1124 }
1125
1126 void CheckLabel::setChecked(bool checked) {
1127 state.checked = checked;
1128 return p.setChecked(checked);
1129 }
1130
1131 void CheckLabel::setText(const string& text) {
1132 state.text = text;
1133 return p.setText(text);
1134 }
1135
1136 string CheckLabel::text() const {
1137 return state.text;
1138 }
1139
1140 CheckLabel::CheckLabel():
1141 state(*new State),
1142 base_from_member<pCheckLabel&>(*new pCheckLabel(*this)),
1143 Widget(base_from_member<pCheckLabel&>::value),
1144 p(base_from_member<pCheckLabel&>::value) {
1145 p.constructor();
1146 }
1147
1148 CheckLabel::~CheckLabel() {
1149 p.destructor();
1150 delete &state;
1151 }
1152
1153
1154 //ComboButton
1155 //===========
1156
1157 void ComboButton::append(const string& text) {
1158 state.text.append(text);
1159 return p.append(text);
1160 }
1161
1162 void ComboButton::remove(unsigned selection) {
1163 if(selection >= state.text.size()) return;
1164 state.text.remove(selection);
1165 p.remove(selection);
1166 }
1167
1168 void ComboButton::reset() {
1169 state.selection = 0;
1170 state.text.reset();
1171 return p.reset();
1172 }
1173
1174 unsigned ComboButton::rows() const {
1175 return state.text.size();
1176 }
1177
1178 unsigned ComboButton::selection() const {
1179 return state.selection;
1180 }
1181
1182 void ComboButton::setSelection(unsigned selection) {
1183 if(selection >= state.text.size()) return;
1184 state.selection = selection;
1185 return p.setSelection(selection);
1186 }
1187
1188 void ComboButton::setText(unsigned selection, const string& text) {
1189 if(selection >= state.text.size()) return;
1190 state.text[selection] = text;
1191 p.setText(selection, text);
1192 }
1193
1194 string ComboButton::text() const {
1195 if(state.text.empty()) return "";
1196 return state.text[state.selection];
1197 }
1198
1199 string ComboButton::text(unsigned selection) const {
1200 if(selection >= state.text.size()) return "";
1201 return state.text[selection];
1202 }
1203
1204 ComboButton::ComboButton():
1205 state(*new State),
1206 base_from_member<pComboButton&>(*new pComboButton(*this)),
1207 Widget(base_from_member<pComboButton&>::value),
1208 p(base_from_member<pComboButton&>::value) {
1209 p.constructor();
1210 }
1211
1212 ComboButton::~ComboButton() {
1213 p.destructor();
1214 delete &state;
1215 }
1216
1217 //Console
1218 //=======
1219
1220 void Console::print(const string& text) {
1221 return p.print(text);
1222 }
1223
1224 void Console::reset() {
1225 return p.reset();
1226 }
1227
1228 Console::Console():
1229 state(*new State),
1230 base_from_member<pConsole&>(*new pConsole(*this)),
1231 Widget(base_from_member<pConsole&>::value),
1232 p(base_from_member<pConsole&>::value) {
1233 p.constructor();
1234 }
1235
1236 Console::~Console() {
1237 p.destructor();
1238 delete &state;
1239 }
1240
1241 //Frame
1242 //=====
1243
1244 void Frame::setLayout(Layout& layout) {
1245 state.layout = &layout;
1246 synchronizeLayout();
1247 }
1248
1249 void Frame::setText(const string& text) {
1250 state.text = text;
1251 return p.setText(text);
1252 }
1253
1254 void Frame::synchronizeLayout() {
1255 if(state.layout == nullptr) return;
1256 state.layout->Sizable::state.window = Sizable::state.window;
1257 state.layout->Sizable::state.parent = this;
1258 state.layout->state.widget = this;
1259 state.layout->synchronizeLayout();
1260 }
1261
1262 string Frame::text() const {
1263 return state.text;
1264 }
1265
1266 Frame::Frame():
1267 state(*new State),
1268 base_from_member<pFrame&>(*new pFrame(*this)),
1269 Widget(base_from_member<pFrame&>::value),
1270 p(base_from_member<pFrame&>::value) {
1271 p.constructor();
1272 }
1273
1274 Frame::~Frame() {
1275 p.destructor();
1276 delete &state;
1277 }
1278
1279 //HexEdit
1280 //=======
1281
1282 unsigned HexEdit::columns() const {
1283 return state.columns;
1284 }
1285
1286 unsigned HexEdit::length() const {
1287 return state.length;
1288 }
1289
1290 unsigned HexEdit::offset() const {
1291 return state.offset;
1292 }
1293
1294 unsigned HexEdit::rows() const {
1295 return state.rows;
1296 }
1297
1298 void HexEdit::setColumns(unsigned columns) {
1299 state.columns = columns;
1300 return p.setColumns(columns);
1301 }
1302
1303 void HexEdit::setLength(unsigned length) {
1304 state.length = length;
1305 return p.setLength(length);
1306 }
1307
1308 void HexEdit::setOffset(unsigned offset) {
1309 state.offset = offset;
1310 return p.setOffset(offset);
1311 }
1312
1313 void HexEdit::setRows(unsigned rows) {
1314 state.rows = rows;
1315 return p.setRows(rows);
1316 }
1317
1318 void HexEdit::update() {
1319 return p.update();
1320 }
1321
1322 HexEdit::HexEdit():
1323 state(*new State),
1324 base_from_member<pHexEdit&>(*new pHexEdit(*this)),
1325 Widget(base_from_member<pHexEdit&>::value),
1326 p(base_from_member<pHexEdit&>::value) {
1327 p.constructor();
1328 }
1329
1330 HexEdit::~HexEdit() {
1331 p.destructor();
1332 delete &state;
1333 }
1334
1335 //HorizontalScroller
1336 //==================
1337
1338 unsigned HorizontalScroller::length() const {
1339 return state.length;
1340 }
1341
1342 unsigned HorizontalScroller::position() const {
1343 return state.position;
1344 }
1345
1346 void HorizontalScroller::setLength(unsigned length) {
1347 state.length = length;
1348 return p.setLength(length);
1349 }
1350
1351 void HorizontalScroller::setPosition(unsigned position) {
1352 state.position = position;
1353 return p.setPosition(position);
1354 }
1355
1356 HorizontalScroller::HorizontalScroller():
1357 state(*new State),
1358 base_from_member<pHorizontalScroller&>(*new pHorizontalScroller(*this)),
1359 Widget(base_from_member<pHorizontalScroller&>::value),
1360 p(base_from_member<pHorizontalScroller&>::value) {
1361 p.constructor();
1362 }
1363
1364 HorizontalScroller::~HorizontalScroller() {
1365 p.destructor();
1366 delete &state;
1367 }
1368
1369 //HorizontalSlider
1370 //================
1371
1372 unsigned HorizontalSlider::length() const {
1373 return state.length;
1374 }
1375
1376 unsigned HorizontalSlider::position() const {
1377 return state.position;
1378 }
1379
1380 void HorizontalSlider::setLength(unsigned length) {
1381 state.length = length;
1382 return p.setLength(length);
1383 }
1384
1385 void HorizontalSlider::setPosition(unsigned position) {
1386 state.position = position;
1387 return p.setPosition(position);
1388 }
1389
1390 HorizontalSlider::HorizontalSlider():
1391 state(*new State),
1392 base_from_member<pHorizontalSlider&>(*new pHorizontalSlider(*this)),
1393 Widget(base_from_member<pHorizontalSlider&>::value),
1394 p(base_from_member<pHorizontalSlider&>::value) {
1395 p.constructor();
1396 }
1397
1398 HorizontalSlider::~HorizontalSlider() {
1399 p.destructor();
1400 delete &state;
1401 }
1402
1403 //Label
1404 //=====
1405
1406 void Label::setText(const string& text) {
1407 state.text = text;
1408 return p.setText(text);
1409 }
1410
1411 string Label::text() const {
1412 return state.text;
1413 }
1414
1415 Label::Label():
1416 state(*new State),
1417 base_from_member<pLabel&>(*new pLabel(*this)),
1418 Widget(base_from_member<pLabel&>::value),
1419 p(base_from_member<pLabel&>::value) {
1420 p.constructor();
1421 }
1422
1423 Label::~Label() {
1424 p.destructor();
1425 delete &state;
1426 }
1427
1428 //LineEdit
1429 //========
1430
1431 bool LineEdit::editable() const {
1432 return state.editable;
1433 }
1434
1435 void LineEdit::setEditable(bool editable) {
1436 state.editable = editable;
1437 return p.setEditable(editable);
1438 }
1439
1440 void LineEdit::setText(const string& text) {
1441 state.text = text;
1442 return p.setText(text);
1443 }
1444
1445 string LineEdit::text() {
1446 return p.text();
1447 }
1448
1449 LineEdit::LineEdit():
1450 state(*new State),
1451 base_from_member<pLineEdit&>(*new pLineEdit(*this)),
1452 Widget(base_from_member<pLineEdit&>::value),
1453 p(base_from_member<pLineEdit&>::value) {
1454 p.constructor();
1455 }
1456
1457 LineEdit::~LineEdit() {
1458 p.destructor();
1459 delete &state;
1460 }
1461
1462 //ListView
1463 //========
1464
1465 void ListView::append(const lstring& text) {
1466 state.checked.append(false);
1467 state.image.append({});
1468 state.text.append(text);
1469 return p.append(text);
1470 }
1471
1472 void ListView::autoSizeColumns() {
1473 return p.autoSizeColumns();
1474 }
1475
1476 bool ListView::checkable() const {
1477 return state.checkable;
1478 }
1479
1480 bool ListView::checked(unsigned selection) const {
1481 if(selection >= state.text.size()) return false;
1482 return state.checked[selection];
1483 }
1484
1485 unsigned ListView::columns() const {
1486 return max(1u, state.headerText.size());
1487 }
1488
1489 bool ListView::headerVisible() const {
1490 return state.headerVisible;
1491 }
1492
1493 image ListView::image(unsigned selection, unsigned position) const {
1494 if(selection >= state.text.size()) return {};
1495 return state.image[selection](position);
1496 }
1497
1498 void ListView::remove(unsigned selection) {
1499 if(selection >= state.text.size()) return;
1500 state.checked.remove(selection);
1501 state.image.remove(selection);
1502 state.text.remove(selection);
1503 return p.remove(selection);
1504 }
1505
1506 void ListView::reset() {
1507 state.checked.reset();
1508 state.image.reset();
1509 state.selected = false;
1510 state.selection = 0;
1511 state.text.reset();
1512 return p.reset();
1513 }
1514
1515 unsigned ListView::rows() const {
1516 return state.text.size();
1517 }
1518
1519 bool ListView::selected() const {
1520 return state.selected;
1521 }
1522
1523 unsigned ListView::selection() const {
1524 return state.selection;
1525 }
1526
1527 void ListView::setCheckable(bool checkable) {
1528 state.checkable = checkable;
1529 return p.setCheckable(checkable);
1530 }
1531
1532 void ListView::setChecked(unsigned selection, bool checked) {
1533 if(selection >= state.text.size()) return;
1534 state.checked[selection] = checked;
1535 return p.setChecked(selection, checked);
1536 }
1537
1538 void ListView::setHeaderText(const lstring& text) {
1539 state.headerText = text;
1540 return p.setHeaderText(text);
1541 }
1542
1543 void ListView::setHeaderVisible(bool visible) {
1544 state.headerVisible = visible;
1545 return p.setHeaderVisible(visible);
1546 }
1547
1548 void ListView::setImage(unsigned selection, unsigned position, const nall::image& image) {
1549 if(selection >= state.text.size()) return;
1550 state.image[selection](position) = image;
1551 return p.setImage(selection, position, image);
1552 }
1553
1554 void ListView::setSelected(bool selected) {
1555 state.selected = selected;
1556 return p.setSelected(selected);
1557 }
1558
1559 void ListView::setSelection(unsigned selection) {
1560 if(selection >= state.text.size()) return;
1561 state.selected = true;
1562 state.selection = selection;
1563 return p.setSelection(selection);
1564 }
1565
1566 void ListView::setText(unsigned selection, const lstring& text) {
1567 if(selection >= state.text.size()) return;
1568 for(unsigned position = 0; position < text.size(); position++) {
1569 setText(selection, position, text[position]);
1570 }
1571 }
1572
1573 void ListView::setText(unsigned selection, unsigned position, const string& text) {
1574 if(selection >= state.text.size()) return;
1575 state.text[selection](position) = text;
1576 return p.setText(selection, position, text);
1577 }
1578
1579 string ListView::text(unsigned selection, unsigned position) const {
1580 if(selection >= state.text.size()) return "";
1581 return state.text[selection](position);
1582 }
1583
1584 ListView::ListView():
1585 state(*new State),
1586 base_from_member<pListView&>(*new pListView(*this)),
1587 Widget(base_from_member<pListView&>::value),
1588 p(base_from_member<pListView&>::value) {
1589 p.constructor();
1590 }
1591
1592 ListView::~ListView() {
1593 p.destructor();
1594 delete &state;
1595 }
1596
1597 //ProgressBar
1598 //===========
1599
1600 unsigned ProgressBar::position() const {
1601 return state.position;
1602 }
1603
1604 void ProgressBar::setPosition(unsigned position) {
1605 state.position = position;
1606 return p.setPosition(position);
1607 }
1608
1609 ProgressBar::ProgressBar():
1610 state(*new State),
1611 base_from_member<pProgressBar&>(*new pProgressBar(*this)),
1612 Widget(base_from_member<pProgressBar&>::value),
1613 p(base_from_member<pProgressBar&>::value) {
1614 p.constructor();
1615 }
1616
1617 ProgressBar::~ProgressBar() {
1618 p.destructor();
1619 delete &state;
1620 }
1621
1622 //RadioButton
1623 //===========
1624
1625 void RadioButton::group(const nall::group<RadioButton>& list) {
1626 for(auto& item : list) item.p.setGroup(item.state.group = list);
1627 if(list.size()) list.first().setChecked();
1628 }
1629
1630 bool RadioButton::checked() const {
1631 return state.checked;
1632 }
1633
1634 image RadioButton::image() const {
1635 return state.image;
1636 }
1637
1638 void RadioButton::setChecked() {
1639 for(auto& item : state.group) item.state.checked = false;
1640 state.checked = true;
1641 return p.setChecked();
1642 }
1643
1644 void RadioButton::setImage(const nall::image& image, Orientation orientation) {
1645 state.image = image;
1646 state.orientation = orientation;
1647 return p.setImage(image, orientation);
1648 }
1649
1650 void RadioButton::setText(const string& text) {
1651 state.text = text;
1652 return p.setText(text);
1653 }
1654
1655 string RadioButton::text() const {
1656 return state.text;
1657 }
1658
1659 RadioButton::RadioButton():
1660 state(*new State),
1661 base_from_member<pRadioButton&>(*new pRadioButton(*this)),
1662 Widget(base_from_member<pRadioButton&>::value),
1663 p(base_from_member<pRadioButton&>::value) {
1664 p.constructor();
1665 }
1666
1667 RadioButton::~RadioButton() {
1668 for(auto& item : state.group) {
1669 if(&item != this) item.state.group.remove(*this);
1670 }
1671 p.destructor();
1672 delete &state;
1673 }
1674
1675 //RadioLabel
1676 //==========
1677
1678 void RadioLabel::group(const nall::group<RadioLabel>& list) {
1679 for(auto& item : list) item.p.setGroup(item.state.group = list);
1680 if(list.size()) list.first().setChecked();
1681 }
1682
1683 bool RadioLabel::checked() const {
1684 return state.checked;
1685 }
1686
1687 void RadioLabel::setChecked() {
1688 for(auto &item : state.group) item.state.checked = false;
1689 state.checked = true;
1690 return p.setChecked();
1691 }
1692
1693 void RadioLabel::setText(const string& text) {
1694 state.text = text;
1695 return p.setText(text);
1696 }
1697
1698 string RadioLabel::text() const {
1699 return state.text;
1700 }
1701
1702 RadioLabel::RadioLabel():
1703 state(*new State),
1704 base_from_member<pRadioLabel&>(*new pRadioLabel(*this)),
1705 Widget(base_from_member<pRadioLabel&>::value),
1706 p(base_from_member<pRadioLabel&>::value) {
1707 p.constructor();
1708 }
1709
1710 RadioLabel::~RadioLabel() {
1711 for(auto& item : state.group) {
1712 if(&item != this) item.state.group.remove(*this);
1713 }
1714 p.destructor();
1715 delete &state;
1716 }
1717
1718 //TabFrame
1719 //========
1720
1721 void TabFrame::append(const string& text, const nall::image& image) {
1722 state.image.append(image);
1723 state.layout.append(nullptr);
1724 state.text.append(text);
1725 return p.append(text, image);
1726 }
1727
1728 image TabFrame::image(unsigned selection) const {
1729 if(selection >= state.text.size()) return {};
1730 return state.image[selection];
1731 }
1732
1733 void TabFrame::remove(unsigned selection) {
1734 if(selection >= state.text.size()) return;
1735 state.image.remove(selection);
1736 state.layout.remove(selection);
1737 state.text.remove(selection);
1738 return p.remove(selection);
1739 }
1740
1741 unsigned TabFrame::selection() const {
1742 return state.selection;
1743 }
1744
1745 void TabFrame::setImage(unsigned selection, const nall::image& image) {
1746 if(selection >= state.text.size()) return;
1747 state.image[selection] = image;
1748 return p.setImage(selection, image);
1749 }
1750
1751 void TabFrame::setLayout(unsigned selection, Layout& layout) {
1752 if(selection >= state.text.size()) return;
1753 state.layout[selection] = &layout;
1754 synchronizeLayout();
1755 }
1756
1757 void TabFrame::setSelection(unsigned selection) {
1758 state.selection = selection;
1759 return p.setSelection(selection);
1760 }
1761
1762 void TabFrame::setText(unsigned selection, const string& text) {
1763 if(selection >= state.text.size()) return;
1764 state.text[selection] = text;
1765 return p.setText(selection, text);
1766 }
1767
1768 void TabFrame::synchronizeLayout() {
1769 for(unsigned n = 0; n < state.layout.size(); n++) {
1770 Layout* layout = state.layout[n];
1771 if(layout == nullptr) continue;
1772 layout->Sizable::state.parent = this;
1773 layout->Sizable::state.window = Sizable::state.window;
1774 layout->state.widget = this;
1775 layout->state.widgetSelection = n;
1776 layout->synchronizeLayout();
1777 }
1778 }
1779
1780 unsigned TabFrame::tabs() const {
1781 return state.text.size();
1782 }
1783
1784 string TabFrame::text(unsigned selection) const {
1785 if(selection >= state.text.size()) return "";
1786 return state.text[selection];
1787 }
1788
1789 TabFrame::TabFrame():
1790 state(*new State),
1791 base_from_member<pTabFrame&>(*new pTabFrame(*this)),
1792 Widget(base_from_member<pTabFrame&>::value),
1793 p(base_from_member<pTabFrame&>::value) {
1794 p.constructor();
1795 }
1796
1797 TabFrame::~TabFrame() {
1798 p.destructor();
1799 delete &state;
1800 }
1801
1802 //TextEdit
1803 //========
1804
1805 bool TextEdit::editable() const {
1806 return state.editable;
1807 }
1808
1809 void TextEdit::setCursorPosition(unsigned position) {
1810 state.cursorPosition = position;
1811 return p.setCursorPosition(position);
1812 }
1813
1814 void TextEdit::setEditable(bool editable) {
1815 state.editable = editable;
1816 return p.setEditable(editable);
1817 }
1818
1819 void TextEdit::setText(const string& text) {
1820 state.text = text;
1821 return p.setText(text);
1822 }
1823
1824 void TextEdit::setWordWrap(bool wordWrap) {
1825 state.wordWrap = wordWrap;
1826 return p.setWordWrap(wordWrap);
1827 }
1828
1829 string TextEdit::text() {
1830 return p.text();
1831 }
1832
1833 bool TextEdit::wordWrap() const {
1834 return state.wordWrap;
1835 }
1836
1837 TextEdit::TextEdit():
1838 state(*new State),
1839 base_from_member<pTextEdit&>(*new pTextEdit(*this)),
1840 Widget(base_from_member<pTextEdit&>::value),
1841 p(base_from_member<pTextEdit&>::value) {
1842 p.constructor();
1843 }
1844
1845 TextEdit::~TextEdit() {
1846 p.destructor();
1847 delete &state;
1848 }
1849
1850 //VerticalScroller
1851 //================
1852
1853 unsigned VerticalScroller::length() const {
1854 return state.length;
1855 }
1856
1857 unsigned VerticalScroller::position() const {
1858 return state.position;
1859 }
1860
1861 void VerticalScroller::setLength(unsigned length) {
1862 state.length = length;
1863 return p.setLength(length);
1864 }
1865
1866 void VerticalScroller::setPosition(unsigned position) {
1867 state.position = position;
1868 return p.setPosition(position);
1869 }
1870
1871 VerticalScroller::VerticalScroller():
1872 state(*new State),
1873 base_from_member<pVerticalScroller&>(*new pVerticalScroller(*this)),
1874 Widget(base_from_member<pVerticalScroller&>::value),
1875 p(base_from_member<pVerticalScroller&>::value) {
1876 p.constructor();
1877 }
1878
1879 VerticalScroller::~VerticalScroller() {
1880 p.destructor();
1881 delete &state;
1882 }
1883
1884 //VerticalSlider
1885 //==============
1886
1887 unsigned VerticalSlider::length() const {
1888 return state.length;
1889 }
1890
1891 unsigned VerticalSlider::position() const {
1892 return state.position;
1893 }
1894
1895 void VerticalSlider::setLength(unsigned length) {
1896 state.length = length;
1897 return p.setLength(length);
1898 }
1899
1900 void VerticalSlider::setPosition(unsigned position) {
1901 state.position = position;
1902 return p.setPosition(position);
1903 }
1904
1905 VerticalSlider::VerticalSlider():
1906 state(*new State),
1907 base_from_member<pVerticalSlider&>(*new pVerticalSlider(*this)),
1908 Widget(base_from_member<pVerticalSlider&>::value),
1909 p(base_from_member<pVerticalSlider&>::value) {
1910 p.constructor();
1911 }
1912
1913 VerticalSlider::~VerticalSlider() {
1914 p.destructor();
1915 delete &state;
1916 }
1917
1918 //Viewport
1919 //========
1920
1921 bool Viewport::droppable() const {
1922 return state.droppable;
1923 }
1924
1925 uintptr_t Viewport::handle() {
1926 return p.handle();
1927 }
1928
1929 void Viewport::setDroppable(bool droppable) {
1930 state.droppable = droppable;
1931 return p.setDroppable(droppable);
1932 }
1933
1934 Viewport::Viewport():
1935 state(*new State),
1936 base_from_member<pViewport&>(*new pViewport(*this)),
1937 Widget(base_from_member<pViewport&>::value),
1938 p(base_from_member<pViewport&>::value) {
1939 p.constructor();
1940 }
1941
1942 Viewport::~Viewport() {
1943 p.destructor();
1944 delete &state;
1945 }
1946
1947 }