ui/qt/graphics.h

Sun, 09 Jun 2024 16:26:28 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 09 Jun 2024 16:26:28 +0200
branch
newapi
changeset 287
5370ea7e45a2
parent 103
6a6718269c22
permissions
-rw-r--r--

fix eventdata not set by menu list events (GTK)

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 #ifndef GRAPHICS_H
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #define GRAPHICS_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 #include "toolkit.h"
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "../ui/graphics.h"
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 #include <QWidget>
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #include <QPainter>
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #include <QColor>
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 #include <QStaticText>
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 typedef struct UiQtGraphics {
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 UiGraphics g;
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 QPainter *painter;
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 QColor color;
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 } UiXlibGraphics;
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 struct UiTextLayout {
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 QStaticText text;
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 QFont font;
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 };
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
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 class DrawingArea : public QWidget {
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 Q_OBJECT
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 UiObject *object;
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 ui_drawfunc drawCallback;
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 void *userdata;
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 public:
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 DrawingArea(UiObject *obj, ui_drawfunc cb, void *data);
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 ~DrawingArea();
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 virtual void paintEvent(QPaintEvent * event);
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 };
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 #endif /* GRAPHICS_H */
6a6718269c22 added drawing area (Qt)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67

mercurial