QTools  6.8.1
qwin_gui.h
Go to the documentation of this file.
1 
39 #ifndef QWIN_GUI_H
40 #define QWIN_GUI_H
41 
42 #ifndef QWIN_GUI
43  #error The pre-processor macro QWIN_GUI must be defined
44 #endif
45 
46 #define WIN32_LEAN_AND_MEAN
47 #include <windows.h> /* Win32 API */
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 /* create the custom dialog hosting the embedded front panel ...............*/
54 HWND CreateCustDialog(HINSTANCE hInst, int iDlg, HWND hParent,
55  WNDPROC lpfnWndProc, LPCTSTR lpWndClass);
56 
57 /* OwnerDrawnButton "class" ................................................*/
58 typedef struct {
59  UINT itemID;
60  HBITMAP hBitmapUp;
61  HBITMAP hBitmapDown;
62  HCURSOR hCursor;
65 
71 };
72 
74  UINT itemID,
75  HBITMAP hBitmapUp, HBITMAP hBitmapDwn,
76  HCURSOR hCursor);
79  OwnerDrawnButton * const me,
80  LPDRAWITEMSTRUCT lpdis);
82  int isDepressed);
83 BOOL OwnerDrawnButton_isDepressed(OwnerDrawnButton const * const me);
84 
85 /* GraphicDisplay "class" for drawing graphic displays
86 * with up to 24-bit color...
87 */
88 typedef struct {
89  HDC src_hDC;
90  int src_width;
92  HDC dst_hDC;
93  int dst_width;
95  HWND hItem;
96  HBITMAP hBitmap;
97  BYTE *bits;
98  BYTE bgColor[3];
100 
101 void GraphicDisplay_init(GraphicDisplay * const me,
102  UINT width, UINT height,
103  UINT itemID, BYTE const bgColor[3]);
104 void GraphicDisplay_xtor(GraphicDisplay * const me);
105 void GraphicDisplay_clear(GraphicDisplay * const me);
106 void GraphicDisplay_redraw(GraphicDisplay * const me);
107 #define GraphicDisplay_setPixel(me_, x_, y_, color_) do { \
108  BYTE *pixelRGB = &(me_)->bits[3*((x_) \
109  + (me_)->src_width * ((me_)->src_height - 1U - (y_)))]; \
110  pixelRGB[0] = (color_)[0]; \
111  pixelRGB[1] = (color_)[1]; \
112  pixelRGB[2] = (color_)[2]; \
113 } while (0)
114 
115 #define GraphicDisplay_clearPixel(me_, x_, y_) do { \
116  BYTE *pixelRGB = &(me_)->bits[3*((x_) \
117  + (me_)->src_width * ((me_)->src_height - 1U - (y_)))]; \
118  pixelRGB[0] = (me_)->bgColor[0]; \
119  pixelRGB[1] = (me_)->bgColor[1]; \
120  pixelRGB[2] = (me_)->bgColor[2]; \
121 } while (0)
122 
123 /* SegmentDisplay "class" for drawing segment displays, LEDs, etc...........*/
124 typedef struct {
125  HWND *hSegment; /* array of segment controls */
126  UINT segmentNum; /* number of segments */
127  HBITMAP *hBitmap; /* array of bitmap handles */
128  UINT bitmapNum; /* number of bitmaps */
130 
131 void SegmentDisplay_init(SegmentDisplay * const me,
132  UINT segNum, UINT bitmapNum);
133 void SegmentDisplay_xtor(SegmentDisplay * const me);
135  UINT segmentNum, UINT segmentID);
137  UINT bitmapNum, HBITMAP hBitmap);
139  UINT segmentNum, UINT bitmapNum);
140 
141 /* useful helper functions .................................................*/
142 void DrawBitmap(HDC hdc, HBITMAP hBitmap, int xStart, int yStart);
143 
144 #ifdef __cplusplus
145 }
146 #endif
147 
148 #endif /* QWIN_GUI_H */
OwnerDrawnButton_set
void OwnerDrawnButton_set(OwnerDrawnButton *const me, int isDepressed)
Definition: qwin_gui.c:133
SegmentDisplay_setSegment
BOOL SegmentDisplay_setSegment(SegmentDisplay *const me, UINT segmentNum, UINT bitmapNum)
Definition: qwin_gui.c:268
GraphicDisplay::hBitmap
HBITMAP hBitmap
Definition: qwin_gui.h:96
OwnerDrawnButton::hBitmapDown
HBITMAP hBitmapDown
Definition: qwin_gui.h:61
OwnerDrawnButton_init
void OwnerDrawnButton_init(OwnerDrawnButton *const me, UINT itemID, HBITMAP hBitmapUp, HBITMAP hBitmapDwn, HCURSOR hCursor)
Definition: qwin_gui.c:80
SegmentDisplay_initSegment
BOOL SegmentDisplay_initSegment(SegmentDisplay *const me, UINT segmentNum, UINT segmentID)
Definition: qwin_gui.c:244
OwnerDrawnButton_isDepressed
BOOL OwnerDrawnButton_isDepressed(OwnerDrawnButton const *const me)
Definition: qwin_gui.c:146
OwnerDrawnButton::hBitmapUp
HBITMAP hBitmapUp
Definition: qwin_gui.h:60
GraphicDisplay_init
void GraphicDisplay_init(GraphicDisplay *const me, UINT width, UINT height, UINT itemID, BYTE const bgColor[3])
Definition: qwin_gui.c:151
GraphicDisplay::dst_hDC
HDC dst_hDC
Definition: qwin_gui.h:92
BTN_RELEASED
@ BTN_RELEASED
Definition: qwin_gui.h:70
SegmentDisplay_init
void SegmentDisplay_init(SegmentDisplay *const me, UINT segNum, UINT bitmapNum)
Definition: qwin_gui.c:213
SegmentDisplay_initBitmap
BOOL SegmentDisplay_initBitmap(SegmentDisplay *const me, UINT bitmapNum, HBITMAP hBitmap)
Definition: qwin_gui.c:256
OwnerDrawnButton::hCursor
HCURSOR hCursor
Definition: qwin_gui.h:62
GraphicDisplay::bits
BYTE * bits
Definition: qwin_gui.h:97
SegmentDisplay
Definition: qwin_gui.h:124
SegmentDisplay::hSegment
HWND * hSegment
Definition: qwin_gui.h:125
OwnerDrawnButton
Definition: qwin_gui.h:58
OwnerDrawnButton::isDepressed
int isDepressed
Definition: qwin_gui.h:63
OwnerDrawnButtonAction
OwnerDrawnButtonAction
Definition: qwin_gui.h:66
BTN_NOACTION
@ BTN_NOACTION
Definition: qwin_gui.h:67
SegmentDisplay::hBitmap
HBITMAP * hBitmap
Definition: qwin_gui.h:127
GraphicDisplay::src_width
int src_width
Definition: qwin_gui.h:90
GraphicDisplay::src_hDC
HDC src_hDC
Definition: qwin_gui.h:89
GraphicDisplay::dst_height
int dst_height
Definition: qwin_gui.h:94
CreateCustDialog
HWND CreateCustDialog(HINSTANCE hInst, int iDlg, HWND hParent, WNDPROC lpfnWndProc, LPCTSTR lpWndClass)
Definition: qwin_gui.c:46
SegmentDisplay_xtor
void SegmentDisplay_xtor(SegmentDisplay *const me)
Definition: qwin_gui.c:230
GraphicDisplay
Definition: qwin_gui.h:88
BTN_DEPRESSED
@ BTN_DEPRESSED
Definition: qwin_gui.h:69
SegmentDisplay::segmentNum
UINT segmentNum
Definition: qwin_gui.h:126
DrawBitmap
void DrawBitmap(HDC hdc, HBITMAP hBitmap, int xStart, int yStart)
Definition: qwin_gui.c:286
SegmentDisplay::bitmapNum
UINT bitmapNum
Definition: qwin_gui.h:128
OwnerDrawnButton_draw
enum OwnerDrawnButtonAction OwnerDrawnButton_draw(OwnerDrawnButton *const me, LPDRAWITEMSTRUCT lpdis)
Definition: qwin_gui.c:98
GraphicDisplay::hItem
HWND hItem
Definition: qwin_gui.h:95
OwnerDrawnButton_xtor
void OwnerDrawnButton_xtor(OwnerDrawnButton *const me)
Definition: qwin_gui.c:92
GraphicDisplay::dst_width
int dst_width
Definition: qwin_gui.h:93
GraphicDisplay_redraw
void GraphicDisplay_redraw(GraphicDisplay *const me)
Definition: qwin_gui.c:207
GraphicDisplay::src_height
int src_height
Definition: qwin_gui.h:91
BTN_PAINTED
@ BTN_PAINTED
Definition: qwin_gui.h:68
GraphicDisplay_xtor
void GraphicDisplay_xtor(GraphicDisplay *const me)
Definition: qwin_gui.c:187
GraphicDisplay_clear
void GraphicDisplay_clear(GraphicDisplay *const me)
Definition: qwin_gui.c:193
OwnerDrawnButton::itemID
UINT itemID
Definition: qwin_gui.h:59