Debian Codegraph @

phoenix/gtk/platform.hpp

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