Sun, 01 Oct 2023 16:39:03 +0200
add onchange event for toggle buttons (WinUI3)
103
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2015 Olaf Wintermann. All rights reserved. |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #include "graphics.h" |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | #include "container.h" |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | DrawingArea::DrawingArea(UiObject *obj, ui_drawfunc cb, void *data) { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | object = obj; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | drawCallback = cb; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | userdata = data; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | } |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | DrawingArea::~DrawingArea() { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | } |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | void DrawingArea::paintEvent(QPaintEvent *event) { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | QPainter painter(this); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | UiQtGraphics g; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | g.g.width = this->width(); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | g.g.height = this->height(); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | g.painter = &painter; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | UiEvent ev; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | ev.obj = object; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | ev.window = object->window; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | ev.document = object->ctx->document; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | ev.eventdata = NULL; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | ev.intval = 0; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | drawCallback(&ev, &g.g, userdata); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | } |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | UIWIDGET ui_drawingarea(UiObject *obj, ui_drawfunc f, void *userdata) { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | DrawingArea *widget = new DrawingArea(obj, f, userdata); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | UiContainer *ct = uic_get_current_container(obj); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | ct->add(widget, true); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | return widget; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | } |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | |
115
102fc0b8fe3e
improved context menus
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
114
diff
changeset
|
72 | void ui_drawingarea_mousehandler(UiObject *obj, UIWIDGET widget, ui_callback f, void *u) { |
102fc0b8fe3e
improved context menus
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
114
diff
changeset
|
73 | |
102fc0b8fe3e
improved context menus
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
114
diff
changeset
|
74 | } |
102fc0b8fe3e
improved context menus
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
114
diff
changeset
|
75 | |
102fc0b8fe3e
improved context menus
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
114
diff
changeset
|
76 | void ui_drawingarea_getsize(UIWIDGET drawingarea, int *width, int *height) { |
102fc0b8fe3e
improved context menus
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
114
diff
changeset
|
77 | |
102fc0b8fe3e
improved context menus
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
114
diff
changeset
|
78 | } |
102fc0b8fe3e
improved context menus
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
114
diff
changeset
|
79 | |
102fc0b8fe3e
improved context menus
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
114
diff
changeset
|
80 | void ui_drawingarea_redraw(UIWIDGET drawingarea) { |
102fc0b8fe3e
improved context menus
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
114
diff
changeset
|
81 | |
102fc0b8fe3e
improved context menus
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
114
diff
changeset
|
82 | } |
102fc0b8fe3e
improved context menus
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
114
diff
changeset
|
83 | |
103
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | /* -------------------- text layout functions -------------------- */ |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | UiTextLayout* ui_text(UiGraphics *g) { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
88 | UiTextLayout *textlayout = new UiTextLayout(); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
89 | return textlayout; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
90 | } |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
91 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
92 | void ui_text_free(UiTextLayout *text) { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | delete text; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
94 | } |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
95 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | void ui_text_setstring(UiTextLayout *layout, char *str) { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
97 | layout->text.setText(QString::fromUtf8(str)); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
98 | } |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
99 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
100 | void ui_text_setstringl(UiTextLayout *layout, char *str, int len) { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
101 | layout->text.setText(QString::fromUtf8(str, len)); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | } |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
103 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
104 | void ui_text_setfont(UiTextLayout *layout, char *font, int size) { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
105 | layout->font = QFont(QString::fromUtf8(font), size); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
106 | } |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | void ui_text_getsize(UiTextLayout *layout, int *width, int *height) { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
109 | QSizeF size = layout->text.size(); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
110 | *width = (int)size.width(); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
111 | *height = (int)size.height(); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 | } |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
113 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
114 | void ui_text_setwidth(UiTextLayout *layout, int width) { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
115 | layout->text.setTextWidth((qreal)width); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | } |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | /* -------------------- drawing functions -------------------- */ |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
120 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
121 | void ui_graphics_color(UiGraphics *g, int red, int green, int blue) { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
122 | UiQtGraphics *gr = (UiQtGraphics*)g; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | gr->color = QColor(red, green, blue); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | gr->painter->setPen(gr->color); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
125 | } |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
126 | |
114
909fe96e5659
added ui_draw_line function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
103
diff
changeset
|
127 | void ui_draw_line(UiGraphics *g, int x1, int y1, int x2, int y2) { |
909fe96e5659
added ui_draw_line function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
103
diff
changeset
|
128 | UiQtGraphics *gr = (UiQtGraphics*)g; |
909fe96e5659
added ui_draw_line function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
103
diff
changeset
|
129 | |
909fe96e5659
added ui_draw_line function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
103
diff
changeset
|
130 | gr->painter->drawLine(x1, y1, x2, y2); |
909fe96e5659
added ui_draw_line function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
103
diff
changeset
|
131 | } |
909fe96e5659
added ui_draw_line function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
103
diff
changeset
|
132 | |
103
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | void ui_draw_rect(UiGraphics *g, int x, int y, int w, int h, int fill) { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
134 | UiQtGraphics *gr = (UiQtGraphics*)g; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
135 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
136 | QRect rect(x, y, w, h); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
137 | if(fill) { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
138 | gr->painter->fillRect(rect, gr->color); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
139 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
140 | } else { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
141 | gr->painter->drawRect(rect); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
142 | } |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
143 | } |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
144 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
145 | void ui_draw_text(UiGraphics *g, int x, int y, UiTextLayout *text) { |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
146 | UiQtGraphics *gr = (UiQtGraphics*)g; |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
147 | |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
148 | gr->painter->setFont(text->font); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
149 | gr->painter->drawStaticText(x, y, text->text); |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
150 | } |
6a6718269c22
added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
151 |