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