QTools 6.9.3
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
qwin_gui.h
Go to the documentation of this file.
1 
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;
67 
73 };
74 
76  UINT itemID,
77  HBITMAP hBitmapUp, HBITMAP hBitmapDwn,
78  HCURSOR hCursor);
81  OwnerDrawnButton * const me,
82  LPDRAWITEMSTRUCT lpdis);
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;
94  HDC dst_hDC;
95  int dst_width;
97  HWND hItem;
98  HBITMAP hBitmap;
99  BYTE *bits;
100  BYTE bgColor[3];
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 */
132 
133 void SegmentDisplay_init(SegmentDisplay * const me,
134  UINT segNum, UINT bitmapNum);
135 void 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 .................................................*/
144 void 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
HBITMAP hBitmapUp
Definition: qwin_gui.h:62
void DrawBitmap(HDC hdc, HBITMAP hBitmap, int xStart, int yStart)
Definition: qwin_gui.c:288
HWND * hSegment
Definition: qwin_gui.h:127
HBITMAP * hBitmap
Definition: qwin_gui.h:129
void OwnerDrawnButton_init(OwnerDrawnButton *const me, UINT itemID, HBITMAP hBitmapUp, HBITMAP hBitmapDwn, HCURSOR hCursor)
Definition: qwin_gui.c:82
HCURSOR hCursor
Definition: qwin_gui.h:64
HBITMAP hBitmapDown
Definition: qwin_gui.h:63
void GraphicDisplay_redraw(GraphicDisplay *const me)
Definition: qwin_gui.c:209
BYTE * bits
Definition: qwin_gui.h:99
HBITMAP hBitmap
Definition: qwin_gui.h:98
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
UINT segmentNum
Definition: qwin_gui.h:128
void GraphicDisplay_clear(GraphicDisplay *const me)
Definition: qwin_gui.c:195
int dst_height
Definition: qwin_gui.h:96
UINT bitmapNum
Definition: qwin_gui.h:130
void GraphicDisplay_init(GraphicDisplay *const me, UINT width, UINT height, UINT itemID, BYTE const bgColor[3])
Definition: qwin_gui.c:153
int src_height
Definition: qwin_gui.h:93
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