User Manual Host-Based Tools for QTools 8.1.6
Toggle main menu visibility
Loading...
Searching...
No Matches
qwin_gui.h
Go to the documentation of this file.
1
/**
2
* @file
3
* @brief QWIN GUI facilities for building realistic embedded front panels
4
* @cond
5
******************************************************************************
6
* Last updated for version 6.7.0
7
* Last updated on 2020-01-15
8
*
9
* Q u a n t u m L e a P s
10
* ------------------------
11
* Modern Embedded Software
12
*
13
* Copyright (C) 2020 Quantum Leaps, LLC. All rights reserved.
14
*
15
* MIT License:
16
*
17
* Permission is hereby granted, free of charge, to any person obtaining a copy
18
* of this software and associated documentation files (the "Software"), to
19
* deal in the Software without restriction, including without limitation the
20
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
21
* sell copies of the Software, and to permit persons to whom the Software is
22
* furnished to do so, subject to the following conditions:
23
*
24
* The above copyright notice and this permission notice shall be included in
25
* all copies or substantial portions of the Software.
26
*
27
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
32
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
33
* IN THE SOFTWARE.
34
*
35
* Contact information:
36
* <www.state-machine.com>
37
* <info@state-machine.com>
38
******************************************************************************
39
* @endcond
40
*/
41
#ifndef QWIN_GUI_H_
42
#define QWIN_GUI_H_
43
44
#ifndef QWIN_GUI
45
#error The pre-processor macro QWIN_GUI must be defined
46
#endif
47
48
#define WIN32_LEAN_AND_MEAN
49
#include <windows.h>
/* Win32 API */
50
51
#ifdef __cplusplus
52
extern
"C"
{
53
#endif
54
55
/* create the custom dialog hosting the embedded front panel ...............*/
56
HWND CreateCustDialog(HINSTANCE hInst,
int
iDlg, HWND hParent,
57
WNDPROC lpfnWndProc, LPCTSTR lpWndClass);
58
59
/* OwnerDrawnButton "class" ................................................*/
60
typedef
struct
{
61
UINT itemID;
62
HBITMAP hBitmapUp;
63
HBITMAP hBitmapDown;
64
HCURSOR hCursor;
65
int
isDepressed;
66
}
OwnerDrawnButton
;
67
68
enum
OwnerDrawnButtonAction {
69
BTN_NOACTION,
70
BTN_PAINTED,
71
BTN_DEPRESSED,
72
BTN_RELEASED
73
};
74
75
void
OwnerDrawnButton_init(
OwnerDrawnButton
*
const
me,
76
UINT itemID,
77
HBITMAP hBitmapUp, HBITMAP hBitmapDwn,
78
HCURSOR hCursor);
79
void
OwnerDrawnButton_xtor(
OwnerDrawnButton
*
const
me);
80
enum
OwnerDrawnButtonAction OwnerDrawnButton_draw(
81
OwnerDrawnButton
*
const
me,
82
LPDRAWITEMSTRUCT lpdis);
83
void
OwnerDrawnButton_set(
OwnerDrawnButton
*
const
me,
84
int
isDepressed);
85
BOOL OwnerDrawnButton_isDepressed(
OwnerDrawnButton
const
*
const
me);
86
87
/* GraphicDisplay "class" for drawing graphic displays
88
* with up to 24-bit color...
89
*/
90
typedef
struct
{
91
HDC src_hDC;
92
int
src_width;
93
int
src_height;
94
HDC dst_hDC;
95
int
dst_width;
96
int
dst_height;
97
HWND hItem;
98
HBITMAP hBitmap;
99
BYTE *bits;
100
BYTE bgColor[3];
101
}
GraphicDisplay
;
102
103
void
GraphicDisplay_init(
GraphicDisplay
*
const
me,
104
UINT width, UINT height,
105
UINT itemID, BYTE
const
bgColor[3]);
106
void
GraphicDisplay_xtor(
GraphicDisplay
*
const
me);
107
void
GraphicDisplay_clear(
GraphicDisplay
*
const
me);
108
void
GraphicDisplay_redraw(
GraphicDisplay
*
const
me);
109
#define GraphicDisplay_setPixel(me_, x_, y_, color_) do { \
110
BYTE *pixelRGB = &(me_)->bits[3*((x_) \
111
+ (me_)->src_width * ((me_)->src_height - 1U - (y_)))]; \
112
pixelRGB[0] = (color_)[0]; \
113
pixelRGB[1] = (color_)[1]; \
114
pixelRGB[2] = (color_)[2]; \
115
} while (0)
116
117
#define GraphicDisplay_clearPixel(me_, x_, y_) do { \
118
BYTE *pixelRGB = &(me_)->bits[3*((x_) \
119
+ (me_)->src_width * ((me_)->src_height - 1U - (y_)))]; \
120
pixelRGB[0] = (me_)->bgColor[0]; \
121
pixelRGB[1] = (me_)->bgColor[1]; \
122
pixelRGB[2] = (me_)->bgColor[2]; \
123
} while (0)
124
125
/* SegmentDisplay "class" for drawing segment displays, LEDs, etc...........*/
126
typedef
struct
{
127
HWND *hSegment;
/* array of segment controls */
128
UINT segmentNum;
/* number of segments */
129
HBITMAP *hBitmap;
/* array of bitmap handles */
130
UINT bitmapNum;
/* number of bitmaps */
131
}
SegmentDisplay
;
132
133
void
SegmentDisplay_init(
SegmentDisplay
*
const
me,
134
UINT segNum, UINT bitmapNum);
135
void
SegmentDisplay_xtor(
SegmentDisplay
*
const
me);
136
BOOL SegmentDisplay_initSegment(
SegmentDisplay
*
const
me,
137
UINT segmentNum, UINT segmentID);
138
BOOL SegmentDisplay_initBitmap(
SegmentDisplay
*
const
me,
139
UINT bitmapNum, HBITMAP hBitmap);
140
BOOL SegmentDisplay_setSegment(
SegmentDisplay
*
const
me,
141
UINT segmentNum, UINT bitmapNum);
142
143
/* useful helper functions .................................................*/
144
void
DrawBitmap(HDC hdc, HBITMAP hBitmap,
int
xStart,
int
yStart);
145
146
#ifdef __cplusplus
147
}
148
#endif
149
150
#endif
/* QWIN_GUI_H_ */
GraphicDisplay
Definition
qwin_gui.h:90
OwnerDrawnButton
Definition
qwin_gui.h:60
SegmentDisplay
Definition
qwin_gui.h:126
qtools
qwin
qwin_gui.h
©
Quantum Leaps
|
YouTube
|
GitHub
| created with
Spexygen
©
Quantum Leaps
|
YouTube
|
GitHub
| created with
Spexygen