Debian Codegraph @

phoenix/windows/platform.hpp

raw
1 namespace phoenix {
2
3 struct AppMessage {
4 enum : unsigned {
5 ListView_onActivate = 0,
6 };
7 };
8
9 typedef LRESULT CALLBACK (*WindowProc)(HWND, UINT, WPARAM, LPARAM);
10
11 struct pApplication {
12 static void run();
13 static bool pendingEvents();
14 static void processEvents();
15 static void quit();
16
17 static void initialize();
18 };
19
20 struct Settings {
21 bimap<Keyboard::Scancode, unsigned> keymap;
22 };
23
24 struct pFont;
25 struct pObject;
26 struct pWindow;
27 struct pMenu;
28 struct pLayout;
29 struct pWidget;
30
31 struct pFont {
32 static string serif(unsigned size, string style);
33 static string sans(unsigned size, string style);
34 static string monospace(unsigned size, string style);
35 static Size size(string font, string text);
36
37 static HFONT create(string description);
38 static void free(HFONT hfont);
39 static Size size(HFONT hfont, string text);
40 };
41
42 struct pDesktop {
43 static Size size();
44 static Geometry workspace();
45 };
46
47 struct pMonitor {
48 static unsigned count();
49 static Geometry geometry(unsigned monitor);
50 static unsigned primary();
51 };
52
53 struct pKeyboard {
54 static bool pressed(Keyboard::Scancode scancode);
55 static vector<bool> state();
56
57 static void initialize();
58 };
59
60 struct pMouse {
61 static Position position();
62 static bool pressed(Mouse::Button button);
63 };
64
65 struct pBrowserWindow {
66 static string directory(BrowserWindow::State& state);
67 static string open(BrowserWindow::State& state);
68 static string save(BrowserWindow::State& state);
69 };
70
71 struct pMessageWindow {
72 static MessageWindow::Response error(MessageWindow::State& state);
73 static MessageWindow::Response information(MessageWindow::State& state);
74 static MessageWindow::Response question(MessageWindow::State& state);
75 static MessageWindow::Response warning(MessageWindow::State& state);
76 };
77
78 struct pObject {
79 static vector<pObject*> objects;
80
81 Object& object;
82 uintptr_t id;
83 bool locked;
84
85 pObject(Object& object);
86 static Object* find(unsigned id);
87 virtual ~pObject() {}
88
89 void constructor() {}
90 void destructor() {}
91 };
92
93 struct pTimer : public pObject {
94 Timer& timer;
95 UINT_PTR htimer;
96
97 void setEnabled(bool enabled);
98 void setInterval(unsigned interval);
99
100 pTimer(Timer& timer) : pObject(timer), timer(timer) {}
101 void constructor();
102 };
103
104 struct pWindow : public pObject {
105 static vector<pWindow*> modal;
106 static void updateModality();
107
108 Window& window;
109 HWND hwnd;
110 HMENU hmenu;
111 HWND hstatus;
112 HFONT hstatusfont;
113 HBRUSH brush;
114 COLORREF brushColor;
115
116 static Window& none();
117
118 void append(Layout& layout);
119 void append(Menu& menu);
120 void append(Widget& widget);
121 bool focused();
122 Geometry frameMargin();
123 Geometry geometry();
124 void remove(Layout& layout);
125 void remove(Menu& menu);
126 void remove(Widget& widget);
127 void setBackgroundColor(Color color);
128 void setDroppable(bool droppable);
129 void setFocused();
130 void setFullScreen(bool fullScreen);
131 void setGeometry(Geometry geometry);
132 void setMenuFont(string font);
133 void setMenuVisible(bool visible);
134 void setModal(bool modal);
135 void setResizable(bool resizable);
136 void setStatusFont(string font);
137 void setStatusText(string text);
138 void setStatusVisible(bool visible);
139 void setTitle(string text);
140 void setVisible(bool visible);
141 void setWidgetFont(string font);
142
143 pWindow(Window& window) : pObject(window), window(window) {}
144 void constructor();
145 void destructor();
146 void updateMenu();
147
148 void onClose();
149 void onDrop(WPARAM wparam);
150 bool onEraseBackground();
151 void onModalBegin();
152 void onModalEnd();
153 void onMove();
154 void onSize();
155 };
156
157 struct pAction : public pObject {
158 Action& action;
159 Menu* parentMenu;
160 Window* parentWindow;
161
162 void setEnabled(bool enabled);
163 void setVisible(bool visible);
164
165 pAction(Action& action) : pObject(action), action(action) {}
166 void constructor();
167 };
168
169 struct pMenu : public pAction {
170 Menu& menu;
171 HMENU hmenu;
172 HBITMAP hbitmap;
173
174 void append(Action& action);
175 void remove(Action& action);
176 void setImage(const image& image);
177 void setText(string text);
178
179 pMenu(Menu& menu) : pAction(menu), menu(menu), hbitmap(0) {}
180 void constructor();
181 void destructor();
182 void createBitmap();
183 void update(Window& parentWindow, Menu* parentMenu = nullptr);
184 };
185
186 struct pSeparator : public pAction {
187 Separator& separator;
188
189 pSeparator(Separator& separator) : pAction(separator), separator(separator) {}
190 void constructor();
191 void destructor();
192 };
193
194 struct pItem : public pAction {
195 Item& item;
196 HBITMAP hbitmap;
197
198 void setImage(const image& image);
199 void setText(string text);
200
201 pItem(Item& item) : pAction(item), item(item), hbitmap(0) {}
202 void constructor();
203 void destructor();
204 void createBitmap();
205
206 void onActivate();
207 };
208
209 struct pCheckItem : public pAction {
210 CheckItem& checkItem;
211
212 void setChecked(bool checked);
213 void setText(string text);
214
215 pCheckItem(CheckItem& checkItem) : pAction(checkItem), checkItem(checkItem) {}
216 void constructor();
217 void destructor();
218
219 void onToggle();
220 };
221
222 struct pRadioItem : public pAction {
223 RadioItem& radioItem;
224
225 void setChecked();
226 void setGroup(const group<RadioItem>& group);
227 void setText(string text);
228
229 pRadioItem(RadioItem& radioItem) : pAction(radioItem), radioItem(radioItem) {}
230 void constructor();
231 void destructor();
232
233 void onActivate();
234 };
235
236 struct pSizable : public pObject {
237 Sizable& sizable;
238
239 pSizable(Sizable& sizable) : pObject(sizable), sizable(sizable) {}
240 };
241
242 struct pLayout : public pSizable {
243 Layout& layout;
244
245 pLayout(Layout& layout) : pSizable(layout), layout(layout) {}
246 };
247
248 struct pWidget : public pSizable {
249 Widget& widget;
250 HWND parentHwnd;
251 HWND hwnd;
252 HFONT hfont;
253
254 bool focused();
255 virtual Size minimumSize();
256 virtual void setEnabled(bool enabled);
257 void setFocused();
258 void setFont(string font);
259 virtual void setGeometry(Geometry geometry);
260 virtual void setVisible(bool visible);
261
262 pWidget(Widget& widget) : pSizable(widget), widget(widget) { parentHwnd = pWindow::none().p.hwnd; }
263 void constructor();
264 void destructor();
265 virtual void orphan();
266 void setDefaultFont();
267 void synchronize();
268 };
269
270 struct pButton : public pWidget {
271 Button& button;
272 HBITMAP hbitmap;
273 HIMAGELIST himagelist;
274
275 Size minimumSize();
276 void setImage(const image& image, Orientation orientation);
277 void setText(string text);
278
279 pButton(Button& button) : pWidget(button), button(button), hbitmap(0), himagelist(0) {}
280 void constructor();
281 void destructor();
282 void orphan();
283
284 void onActivate();
285 };
286
287 struct pCanvas : public pWidget {
288 Canvas& canvas;
289 uint32_t* surface = nullptr;
290 unsigned surfaceWidth = 0;
291 unsigned surfaceHeight = 0;
292
293 void setDroppable(bool droppable);
294 void setGeometry(Geometry geometry);
295 void setMode(Canvas::Mode mode);
296 void setSize(Size size);
297
298 pCanvas(Canvas& canvas) : pWidget(canvas), canvas(canvas) {}
299 void constructor();
300 void destructor();
301 void orphan();
302 void paint();
303 void rasterize();
304 void redraw();
305 void release();
306 };
307
308 struct pCheckButton : public pWidget {
309 CheckButton& checkButton;
310 HBITMAP hbitmap;
311 HIMAGELIST himagelist;
312
313 Size minimumSize();
314 void setChecked(bool checked);
315 void setImage(const image& image, Orientation orientation);
316 void setText(string text);
317
318 pCheckButton(CheckButton& checkButton) : pWidget(checkButton), checkButton(checkButton) {}
319 void constructor();
320 void destructor();
321 void orphan();
322
323 void onToggle();
324 };
325
326 struct pCheckLabel : public pWidget {
327 CheckLabel& checkLabel;
328
329 Size minimumSize();
330 void setChecked(bool checked);
331 void setText(string text);
332
333 pCheckLabel(CheckLabel& checkLabel) : pWidget(checkLabel), checkLabel(checkLabel) {}
334 void constructor();
335 void destructor();
336 void orphan();
337
338 void onToggle();
339 };
340
341 struct pComboButton : public pWidget {
342 ComboButton& comboButton;
343
344 void append(string text);
345 void remove(unsigned selection);
346 Size minimumSize();
347 void reset();
348 void setGeometry(Geometry geometry);
349 void setSelection(unsigned selection);
350 void setText(unsigned selection, string text);
351
352 pComboButton(ComboButton& comboButton) : pWidget(comboButton), comboButton(comboButton) {}
353 void constructor();
354 void destructor();
355 void orphan();
356
357 void onChange();
358 };
359
360 struct pConsole : public pWidget {
361 Console& console;
362 LRESULT CALLBACK (*windowProc)(HWND, UINT, LPARAM, WPARAM);
363
364 void print(string text);
365 void reset();
366
367 pConsole(Console& console) : pWidget(console), console(console) {}
368 void constructor();
369 void destructor();
370 void orphan();
371 bool keyPress(unsigned key);
372 };
373
374 struct pFrame : public pWidget {
375 Frame& frame;
376
377 void setEnabled(bool enabled);
378 void setGeometry(Geometry geometry);
379 void setText(string text);
380 void setVisible(bool visible);
381
382 pFrame(Frame& frame) : pWidget(frame), frame(frame) {}
383 void constructor();
384 void destructor();
385 void orphan();
386 };
387
388 struct pHexEdit : public pWidget {
389 HexEdit& hexEdit;
390 WindowProc windowProc = nullptr;
391 HWND scrollBar = nullptr;
392
393 void setColumns(unsigned columns);
394 void setLength(unsigned length);
395 void setOffset(unsigned offset);
396 void setRows(unsigned rows);
397 void update();
398
399 pHexEdit(HexEdit& hexEdit) : pWidget(hexEdit), hexEdit(hexEdit) {}
400 void constructor();
401 void destructor();
402 void orphan();
403 bool keyPress(unsigned key);
404 signed rows();
405 signed rowsScrollable();
406 signed scrollPosition();
407 void scrollTo(signed position);
408 };
409
410 struct pHorizontalScroller : public pWidget {
411 HorizontalScroller& horizontalScroller;
412
413 Size minimumSize();
414 void setLength(unsigned length);
415 void setPosition(unsigned position);
416
417 pHorizontalScroller(HorizontalScroller& horizontalScroller) : pWidget(horizontalScroller), horizontalScroller(horizontalScroller) {}
418 void constructor();
419 void destructor();
420 void orphan();
421
422 void onChange(WPARAM wparam);
423 };
424
425 struct pHorizontalSlider : public pWidget {
426 HorizontalSlider& horizontalSlider;
427
428 Size minimumSize();
429 void setLength(unsigned length);
430 void setPosition(unsigned position);
431
432 pHorizontalSlider(HorizontalSlider& horizontalSlider) : pWidget(horizontalSlider), horizontalSlider(horizontalSlider) {}
433 void constructor();
434 void destructor();
435 void orphan();
436
437 void onChange();
438 };
439
440 struct pLabel : public pWidget {
441 Label& label;
442
443 Size minimumSize();
444 void setText(string text);
445
446 pLabel(Label& label) : pWidget(label), label(label) {}
447 void constructor();
448 void destructor();
449 void orphan();
450 };
451
452 struct pLineEdit : public pWidget {
453 LineEdit& lineEdit;
454
455 Size minimumSize();
456 void setEditable(bool editable);
457 void setText(string text);
458 string text();
459
460 pLineEdit(LineEdit& lineEdit) : pWidget(lineEdit), lineEdit(lineEdit) {}
461 void constructor();
462 void destructor();
463 void orphan();
464
465 void onChange();
466 };
467
468 struct pListView : public pWidget {
469 ListView& listView;
470 HIMAGELIST imageList;
471 vector<vector<unsigned>> imageMap;
472 vector<image> images;
473 bool lostFocus;
474
475 void append(const lstring& text);
476 void autoSizeColumns();
477 void remove(unsigned selection);
478 void reset();
479 void setCheckable(bool checkable);
480 void setChecked(unsigned selection, bool checked);
481 void setGeometry(Geometry geometry);
482 void setHeaderText(const lstring& text);
483 void setHeaderVisible(bool visible);
484 void setImage(unsigned selection, unsigned position, const image& image);
485 void setSelected(bool selected);
486 void setSelection(unsigned selection);
487 void setText(unsigned selection, unsigned position, string text);
488
489 pListView(ListView& listView) : pWidget(listView), listView(listView), imageList(nullptr) {}
490 void constructor();
491 void destructor();
492 void orphan();
493 void buildImageList();
494
495 void onActivate(LPARAM lparam);
496 void onChange(LPARAM lparam);
497 LRESULT onCustomDraw(LPARAM lparam);
498 };
499
500 struct pProgressBar : public pWidget {
501 ProgressBar& progressBar;
502
503 Size minimumSize();
504 void setPosition(unsigned position);
505
506 pProgressBar(ProgressBar& progressBar) : pWidget(progressBar), progressBar(progressBar) {}
507 void constructor();
508 void destructor();
509 void orphan();
510 };
511
512 struct pRadioButton : public pWidget {
513 RadioButton& radioButton;
514 HBITMAP hbitmap;
515 HIMAGELIST himagelist;
516
517 Size minimumSize();
518 void setChecked();
519 void setGroup(const group<RadioButton>& group);
520 void setImage(const image& image, Orientation orientation);
521 void setText(string text);
522
523 pRadioButton(RadioButton& radioButton) : pWidget(radioButton), radioButton(radioButton) {}
524 void constructor();
525 void destructor();
526 void orphan();
527
528 void onActivate();
529 };
530
531 struct pRadioLabel : public pWidget {
532 RadioLabel& radioLabel;
533
534 Size minimumSize();
535 void setChecked();
536 void setGroup(const group<RadioLabel>& group);
537 void setText(string text);
538
539 pRadioLabel(RadioLabel& radioLabel) : pWidget(radioLabel), radioLabel(radioLabel) {}
540 void constructor();
541 void destructor();
542 void orphan();
543
544 void onActivate();
545 };
546
547 struct pTabFrame : public pWidget {
548 TabFrame& tabFrame;
549 WindowProc windowProc = nullptr;
550 HIMAGELIST imageList = nullptr;
551
552 void append(string text, const image& image);
553 void remove(unsigned selection);
554 void setEnabled(bool enabled);
555 void setGeometry(Geometry geometry);
556 void setImage(unsigned selection, const image& image);
557 void setSelection(unsigned selection);
558 void setText(unsigned selection, string text);
559 void setVisible(bool visible);
560
561 pTabFrame(TabFrame& tabFrame) : pWidget(tabFrame), tabFrame(tabFrame) {}
562 void constructor();
563 void destructor();
564 void orphan();
565 void buildImageList();
566 void synchronizeLayout();
567
568 void onChange();
569 void onDrawItem(LPARAM lparam);
570 };
571
572 struct pTextEdit : public pWidget {
573 TextEdit& textEdit;
574
575 void setCursorPosition(unsigned position);
576 void setEditable(bool editable);
577 void setText(string text);
578 void setWordWrap(bool wordWrap);
579 string text();
580
581 pTextEdit(TextEdit& textEdit) : pWidget(textEdit), textEdit(textEdit) {}
582 void constructor();
583 void destructor();
584 void orphan();
585
586 void onChange();
587 };
588
589 struct pVerticalScroller : public pWidget {
590 VerticalScroller& verticalScroller;
591
592 Size minimumSize();
593 void setLength(unsigned length);
594 void setPosition(unsigned position);
595
596 pVerticalScroller(VerticalScroller& verticalScroller) : pWidget(verticalScroller), verticalScroller(verticalScroller) {}
597 void constructor();
598 void destructor();
599 void orphan();
600
601 void onChange(WPARAM wparam);
602 };
603
604 struct pVerticalSlider : public pWidget {
605 VerticalSlider& verticalSlider;
606
607 Size minimumSize();
608 void setLength(unsigned length);
609 void setPosition(unsigned position);
610
611 pVerticalSlider(VerticalSlider& verticalSlider) : pWidget(verticalSlider), verticalSlider(verticalSlider) {}
612 void constructor();
613 void destructor();
614 void orphan();
615
616 void onChange();
617 };
618
619 struct pViewport : public pWidget {
620 Viewport& viewport;
621
622 uintptr_t handle();
623 void setDroppable(bool droppable);
624
625 pViewport(Viewport& viewport) : pWidget(viewport), viewport(viewport) {}
626 void constructor();
627 void destructor();
628 void orphan();
629 };
630
631 }