QTools  7.3.4
Collection of Host-Based Tools
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
52extern "C" {
53#endif
54
55/* create the custom dialog hosting the embedded front panel ...............*/
56HWND CreateCustDialog(HINSTANCE hInst, int iDlg, HWND hParent,
57 WNDPROC lpfnWndProc, LPCTSTR lpWndClass);
58
59/* OwnerDrawnButton "class" ................................................*/
60typedef struct {
61 UINT itemID;
62 HBITMAP hBitmapUp;
63 HBITMAP hBitmapDown;
64 HCURSOR hCursor;
67
73};
74
76 UINT itemID,
77 HBITMAP hBitmapUp, HBITMAP hBitmapDwn,
78 HCURSOR hCursor);
81 OwnerDrawnButton * const me,
82 LPDRAWITEMSTRUCT lpdis);
84 int isDepressed);
86
87/* GraphicDisplay "class" for drawing graphic displays
88* with up to 24-bit color...
89*/
90typedef struct {
97 HWND hItem;
98 HBITMAP hBitmap;
99 BYTE *bits;
100 BYTE bgColor[3];
102
103void GraphicDisplay_init(GraphicDisplay * const me,
104 UINT width, UINT height,
105 UINT itemID, BYTE const bgColor[3]);
106void GraphicDisplay_xtor(GraphicDisplay * const me);
107void GraphicDisplay_clear(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...........*/
126typedef 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 */
132
133void SegmentDisplay_init(SegmentDisplay * const me,
134 UINT segNum, UINT bitmapNum);
135void SegmentDisplay_xtor(SegmentDisplay * const me);
137 UINT segmentNum, UINT segmentID);
139 UINT bitmapNum, HBITMAP hBitmap);
141 UINT segmentNum, UINT bitmapNum);
142
143/* useful helper functions .................................................*/
144void DrawBitmap(HDC hdc, HBITMAP hBitmap, int xStart, int yStart);
145
146#ifdef __cplusplus
147}
148#endif
149
150#endif /* QWIN_GUI_H_ */
void OwnerDrawnButton_xtor(OwnerDrawnButton *const me)
Definition qwin_gui.c:94
void OwnerDrawnButton_set(OwnerDrawnButton *const me, int isDepressed)
Definition qwin_gui.c:135
enum OwnerDrawnButtonAction OwnerDrawnButton_draw(OwnerDrawnButton *const me, LPDRAWITEMSTRUCT lpdis)
Definition qwin_gui.c:100
void DrawBitmap(HDC hdc, HBITMAP hBitmap, int xStart, int yStart)
Definition qwin_gui.c:288
void OwnerDrawnButton_init(OwnerDrawnButton *const me, UINT itemID, HBITMAP hBitmapUp, HBITMAP hBitmapDwn, HCURSOR hCursor)
Definition qwin_gui.c:82
void GraphicDisplay_redraw(GraphicDisplay *const me)
Definition qwin_gui.c:209
void SegmentDisplay_xtor(SegmentDisplay *const me)
Definition qwin_gui.c:232
void GraphicDisplay_xtor(GraphicDisplay *const me)
Definition qwin_gui.c:189
BOOL SegmentDisplay_initBitmap(SegmentDisplay *const me, UINT bitmapNum, HBITMAP hBitmap)
Definition qwin_gui.c:258
void SegmentDisplay_init(SegmentDisplay *const me, UINT segNum, UINT bitmapNum)
Definition qwin_gui.c:215
BOOL SegmentDisplay_initSegment(SegmentDisplay *const me, UINT segmentNum, UINT segmentID)
Definition qwin_gui.c:246
BOOL OwnerDrawnButton_isDepressed(OwnerDrawnButton const *const me)
Definition qwin_gui.c:148
void GraphicDisplay_clear(GraphicDisplay *const me)
Definition qwin_gui.c:195
void GraphicDisplay_init(GraphicDisplay *const me, UINT width, UINT height, UINT itemID, BYTE const bgColor[3])
Definition qwin_gui.c:153
BOOL SegmentDisplay_setSegment(SegmentDisplay *const me, UINT segmentNum, UINT bitmapNum)
Definition qwin_gui.c:270
OwnerDrawnButtonAction
Definition qwin_gui.h:68
@ BTN_PAINTED
Definition qwin_gui.h:70
@ BTN_RELEASED
Definition qwin_gui.h:72
@ BTN_NOACTION
Definition qwin_gui.h:69
@ BTN_DEPRESSED
Definition qwin_gui.h:71
HWND CreateCustDialog(HINSTANCE hInst, int iDlg, HWND hParent, WNDPROC lpfnWndProc, LPCTSTR lpWndClass)
Definition qwin_gui.c:48
HBITMAP hBitmap
Definition qwin_gui.h:98
BYTE * bits
Definition qwin_gui.h:99
HBITMAP hBitmapDown
Definition qwin_gui.h:63
HBITMAP hBitmapUp
Definition qwin_gui.h:62
HCURSOR hCursor
Definition qwin_gui.h:64
HBITMAP * hBitmap
Definition qwin_gui.h:129
HWND * hSegment
Definition qwin_gui.h:127