mGNCS API Reference  v1.5.0
A new control set and a new framework for MiniGUI apps
mrdr.h
Go to the documentation of this file.
1 //
3 // IMPORTANT NOTICE
4 //
5 // The following open source license statement does not apply to any
6 // entity in the Exception List published by FMSoft.
7 //
8 // For more information, please visit:
9 //
10 // https://www.fmsoft.cn/exception-list
11 //
13 
54 #ifndef _MGNCS_RENDER_H
55 #define _MGNCS_RENDER_H
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 
71 #define NCS_TYPE_MASK WE_ATTR_TYPE_MASK
72 #define NCS_TYPE_COLOR_MASK WE_ATTR_TYPE_COLOR_MASK
73 #define NCS_TYPE_INDEX_MASK WE_ATTR_TYPE_INDEX_MASK
74 
75 #define NCS_TYPE_METRICS 0x6000
76 #define NCS_TYPE_COLOR 0x7000
77 #define NCS_TYPE_IMAGE 0x8000
78 #define NCS_TYPE_INT 0x9000
79 #define NCS_TYPE_FGC NCS_TYPE_COLOR
80 #define NCS_TYPE_BGC (NCS_TYPE_COLOR | 0x0100)
81 
82 #define NCS_TYPE_IS_IMAGE(id) (((id) & NCS_TYPE_MASK) == NCS_TYPE_IMAGE)
83 
84 #define NCS_METRICS_BASEID (NCS_TYPE_METRICS | 0)
85 #define NCS_FGC_BASEID (NCS_TYPE_FGC | 0)
86 #define NCS_BGC_BASEID (NCS_TYPE_BGC | 0)
87 #define NCS_INT_BASEID (NCS_TYPE_INT | 0)
88 #define NCS_IMAGE_BASEID (NCS_TYPE_IMAGE | 0)
89 
90 #define NCS_FONT_NUMBER 0
91 #define NCS_METRICS_NUMBER 2
92 #define NCS_COLORS_NUMBER 9
93 #define NCS_IMAGE_NUMBER 17
94 #define NCS_INT_NUMBER 5
95 
96 //common for all renderer
97 #define NCS_FGC_3DBODY NCS_FGC_BASEID
98 #define NCS_BGC_3DBODY NCS_BGC_BASEID
99 
100 #define NCS_FGC_WINDOW NCS_FGC_BASEID + 1
101 #define NCS_BGC_WINDOW NCS_BGC_BASEID + 1
102 
103 #define NCS_FGC_SELECTED_ITEM NCS_FGC_BASEID + 2
104 #define NCS_BGC_SELECTED_ITEM NCS_BGC_BASEID + 2
105 
106 #define NCS_FGC_HILIGHT_ITEM NCS_FGC_BASEID + 3
107 #define NCS_BGC_HILIGHT_ITEM NCS_BGC_BASEID + 3
108 
109 #define NCS_FGC_DISABLED_ITEM NCS_FGC_BASEID + 4
110 #define NCS_BGC_DISABLED_ITEM NCS_BGC_BASEID + 4
111 
112 #define NCS_BGC_SELITEM_NOFOCUS NCS_BGC_BASEID + 5
113 
114 #define NCS_IMAGE_BKGND NCS_IMAGE_BASEID
115 #define NCS_MODE_BKIMAGE NCS_INT_BASEID
116 
117 //flat
118 #define NCS_METRICS_BORDER_WIDTH (NCS_METRICS_BASEID)
119 #define NCS_METRICS_BORDER_RADIUS (NCS_METRICS_BASEID + 1)
120 
121 //fashion
122 #define NCS_METRICS_3DBODY_ROUNDX (NCS_METRICS_BASEID)
123 #define NCS_METRICS_3DBODY_ROUNDY (NCS_METRICS_BASEID + 1)
124 #define NCS_MODE_BGC NCS_INT_BASEID + 1
125 #define NCS_MODE_FGC NCS_INT_BASEID + 2
126 #define NCS_MODE_ITEM NCS_INT_BASEID + 3
127 #define NCS_MODE_USEFLAT NCS_INT_BASEID + 4
128 
129 //fashion.ProgressBar
130 #define NCS_BGC_PRGBAR_CHUNK NCS_BGC_BASEID + 6
131 //fashion.TrackBar
132 #define NCS_BGC_TRKBAR_SLIDER NCS_BGC_BASEID + 7
133 #define NCS_BGC_TRKBAR_THUMB NCS_BGC_BASEID + 8
134 
135 //flat
136 #define NCS_BGC_PRPSHT_NMLTAB NCS_BGC_BASEID + 9
137 
138 //skin
139 #define NCS_IMAGE_ARROWS NCS_IMAGE_BASEID + 1
140 #define NCS_IMAGE_ARROWSHELL NCS_IMAGE_BASEID + 2
141 //skin.Button
142 #define NCS_IMAGE_BUTTON NCS_IMAGE_BASEID + 3
143 //skin.CheckButton
144 #define NCS_IMAGE_CHKBTN NCS_IMAGE_BASEID + 4
145 //skin.RadioButton
146 #define NCS_IMAGE_RDOBTN NCS_IMAGE_BASEID + 5
147 //skin.ListView
148 #define NCS_IMAGE_LISTV_TREE NCS_IMAGE_BASEID + 6
149 #define NCS_IMAGE_LISTV_HDR NCS_IMAGE_BASEID + 7
150 //skin.PropSheet
151 #define NCS_IMAGE_PRPSHT_TAB NCS_IMAGE_BASEID + 8
152 //skin.ProgressBar
153 #define NCS_IMAGE_PRGBAR_HCHUNK NCS_IMAGE_BASEID + 9
154 #define NCS_IMAGE_PRGBAR_VCHUNK NCS_IMAGE_BASEID + 10
155 #define NCS_IMAGE_PRGBAR_HSLIDER NCS_IMAGE_BASEID + 11
156 #define NCS_IMAGE_PRGBAR_VSLIDER NCS_IMAGE_BASEID + 12
157 //skin.TrackBar
158 #define NCS_IMAGE_TRKBAR_HSLIDER NCS_IMAGE_BASEID + 13
159 #define NCS_IMAGE_TRKBAR_VSLIDER NCS_IMAGE_BASEID + 14
160 #define NCS_IMAGE_TRKBAR_HTHUMB NCS_IMAGE_BASEID + 15
161 #define NCS_IMAGE_TRKBAR_VTHUMB NCS_IMAGE_BASEID + 16
162 
217 MGNCS_EXPORT DWORD ncsGetElementEx (mWidget *self, const char* rdrName, int id);
218 
234 MGNCS_EXPORT DWORD ncsSetElementEx (mWidget* self, const char* rdrName, int id, DWORD value);
235 
236 typedef struct _NCS_RDR_ID_NAME {
237  const char* we_name;
238  int we_id;
239 }NCS_RDR_ID_NAME;
240 
241 // id_names can be NULL, or end with (NULL, -1)
242 MGNCS_EXPORT BOOL ncsLoadRdrElementsFromEtcFile(const char* etcfile, const char** rdrNames, int count, NCS_RDR_ID_NAME * id_names);
243 
244 MGNCS_EXPORT BOOL ncsLoadRdrElementsFromEtcHandle(GHANDLE hEtc, const char** rdrNames, int count, NCS_RDR_ID_NAME* id_names);
245 
254 MGNCS_EXPORT GHANDLE ncsLoadRdrEtcFile (const char* etcfile, const char** rdrName, int count);
255 
262 MGNCS_EXPORT int ncsUnloadRdrEtcFile(GHANDLE hEtcFile);
263 
264 /*
265  * \def var g_ncsEtcHandle
266  * \breif the MGNCS configuration handle
267  */
268 MGNCS_EXPORT extern GHANDLE g_ncsEtcHandle;
269 
270 /*
271  * \fn ncsSetEtcHandler(GHANDLE hEtc);
272  * \brief set the outside of etc handler of mgnc.cfg.
273  * can used for incore resource
274  *
275  * \sa g_ncsEtcHandler
276  */
277 static inline void ncsSetEtcHandle(GHANDLE hEtc)
278 {
279  g_ncsEtcHandle = hEtc;
280 }
281 
282 
283 
288 #define ncsGetElement(self, id) \
289  ncsGetElementEx((mWidget*)self, NULL, id)
290 
295 #define ncsSetElement(self, id, value) \
296  ncsSetElementEx((mWidget*)self, NULL, id, value)
297 
309 MGNCS_EXPORT mWidgetRenderer *ncsRetriveCtrlRDR (const char *rendererName, const char *className);
310 
326 MGNCS_EXPORT BOOL ncsRegisterCtrlRDR (const char *rendererName, const char *className,
327  mWidgetRenderer *renderer);
328 
338 MGNCS_EXPORT void ncsUnregisterCtrlRDRs(const char* rdrName/*=NULL*/, const char* className/*=NULL*/);
339 
345 typedef struct _NCS_RDR_ENTRY
346 {
350  const char *className;
355 } NCS_RDR_ENTRY;
356 
370 MGNCS_EXPORT BOOL ncsRegisterCtrlRDRs (const char *rendererName, NCS_RDR_ENTRY * entries,
371  int count);
372 
390 MGNCS_EXPORT BOOL ncsSetSystemRenderer(const char* name);
391 
399 MGNCS_EXPORT const char* ncsGetSystemRenderer(void);
400 
420 #define INVALID_RDR_VALUE ((DWORD)-1)
421 
422 static inline gal_pixel ncsColor2Pixel(HDC hdc, DWORD color)
423 {
424  return RGBA2Pixel(hdc,GetRValue(color),
425  GetGValue(color),
426  GetBValue(color),
427  GetAValue(color));
428 }
429 
430 MGNCS_EXPORT void ncsCommRDRDrawFocusFrame(HWND hWnd, HDC hdc, const RECT *rc);
431 MGNCS_EXPORT BOOL ncsCommRDRDrawBkgnd(HWND hWnd, HDC hdc, const RECT* inv_rc);
432 
433 MGNCS_EXPORT void ncsCommRDRDraw3dbox(HDC hdc, const RECT* rc, DWORD color, DWORD flag);
434 MGNCS_EXPORT void ncsCommRDRDraw3DRoundBox(HDC hdc, const RECT *rc, int rx, int ry, DWORD color, DWORD flag);
435 
436 #define NCS_ROUND_CORNER_LEFT_TOP (0x1)
437 #define NCS_ROUND_CORNER_LEFT_BOTTOM (0x2)
438 #define NCS_ROUND_CORNER_RIGHT_TOP (0x4)
439 #define NCS_ROUND_CORNER_RIGHT_BOTTOM (0x8)
440 #define NCS_ROUND_CORNER_LEFTS (NCS_ROUND_CORNER_LEFT_TOP|NCS_ROUND_CORNER_LEFT_BOTTOM)
441 #define NCS_ROUND_CORNER_RIGHTS (NCS_ROUND_CORNER_RIGHT_TOP|NCS_ROUND_CORNER_RIGHT_BOTTOM)
442 #define NCS_ROUND_CORNER_TOPS (NCS_ROUND_CORNER_LEFT_TOP|NCS_ROUND_CORNER_RIGHT_TOP)
443 #define NCS_ROUND_CORNER_BOTTOMS (NCS_ROUND_CORNER_LEFT_BOTTOM|NCS_ROUND_CORNER_RIGHT_BOTTOM)
444 #define NCS_ROUND_CORNER_ALL (NCS_ROUND_CORNER_LEFT_TOP|NCS_ROUND_CORNER_LEFT_BOTTOM| \
445  NCS_ROUND_CORNER_RIGHT_TOP|NCS_ROUND_CORNER_RIGHT_BOTTOM)
446 #define NCS_BORDER_LEFT 0x1000
447 #define NCS_BORDER_RIGHT 0x2000
448 #define NCS_BORDER_TOP 0x4000
449 #define NCS_BORDER_BOTTOM 0x8000
450 #define NCS_BORDER_ALL (NCS_BORDER_LEFT|NCS_BORDER_RIGHT|NCS_BORDER_TOP|NCS_BORDER_BOTTOM)
451 
452 MGNCS_EXPORT void ncsCommRDRDraw3DHalfRoundBox(HDC hdc, const RECT *rc, int rx, int ry, DWORD color, DWORD flag, DWORD part_flag);
453 MGNCS_EXPORT void ncsCommRDRDrawHalfRoundRect(HDC hdc, const RECT *rc, int rx, int ry, DWORD color, DWORD part_flag);
454 
455 MGNCS_EXPORT void ncsCommRDRFillHalfRoundRect(HDC hdc, const RECT *rc, int rx, int ry, DWORD color, DWORD part_flag);
456 
457 MGNCS_EXPORT void ncsCommRDRDraw3DEllipse(HDC hdc, const RECT *rc, DWORD color1, DWORD color2, DWORD flag);
458 
459 MGNCS_EXPORT void ncsCommRDRDrawCheckbox(HDC hdc, const RECT* rc, DWORD fgcolor, DWORD bgcolor, DWORD discolor, DWORD flag);
460 
461 MGNCS_EXPORT void ncsCommRDRDrawRadio(HDC hdc, const RECT* rc, DWORD fgcolor, DWORD bgcolor, DWORD discolor,DWORD flag);
462 
463 MGNCS_EXPORT void ncsCommRDRDrawArrow(HDC hdc, const RECT* rc, int arrow,DWORD color, BOOL bFill);
464 
465 MGNCS_EXPORT void ncsCommRDRDrawItem(HDC hdc, const RECT* rc, DWORD color);
466 
467 MGNCS_EXPORT void ncsCommRDRDrawSmallHalfRoundBox(HDC hdc, const RECT *rc, DWORD flags, BOOL bFill);
468 
469 enum ncsCommRDRColorCalc {
470  NCSR_COLOR_DARKER = -100,
471  NCSR_COLOR_DARKEST = -200 ,
472  NCSR_COLOR_LIGHTER = 100 ,
473  NCSR_COLOR_LIGHTEST = 200
474 };
475 
476 MGNCS_EXPORT DWORD ncsCommRDRCalc3dboxColor(DWORD color, int degree);
477 
478 //skin
479 
480 #define DI_FILL_TILE 0x01
481 #define DI_FILL_STRETCH 0x02
482 
483 /* Draw info */
484 typedef struct _DRAWINFO
485 {
486  /* The pointer to the whole bitmap. */
487  const BITMAP* bmp;
488 
489  /* The number of line in this bitmap. */
490  unsigned int nr_line;
491 
492  /* The number of colume in this bitmap. */
493  unsigned int nr_col;
494 
495  /* The index of line to current sub bitmap. */
496  unsigned int idx_line;
497 
498  /* The index of colume to current sub bitmap. */
499  unsigned int idx_col;
500 
501  /* The left/top margin value of current sub bitmap. */
502  unsigned int margin1;
503 
504  /* The right/bottom margin value of current sub bitmap. */
505  unsigned int margin2;
506 
507  /* The margin direct. FALSE for left-to-right (default),
508  * TRUE for top-to-bottom. */
509  BOOL direct;
510 
511  /* The flip flag. FALSE for not flip sub bitmap (default),
512  * TRUE for flip. It can be used by draw_tab function.*/
513  BOOL flip;
514 
515  /* The style of drawing bitmap. It can be one of the
516  * following value:
517  * - DI_FILL_TILE
518  * - DI_FILL_STRETCH
519  */
520  unsigned int style;
521 
522 } DRAWINFO;
523 
524 MGNCS_EXPORT void ncsSkinDraw(HDC hdc, const RECT* rc, const DRAWINFO *di);
525 
529 #ifdef __cplusplus
530 }
531 #endif
532 
533 #endif
NCS_RDR_ENTRY
struct _NCS_RDR_ENTRY NCS_RDR_ENTRY
ncsSetElementEx
MGNCS_EXPORT DWORD ncsSetElementEx(mWidget *self, const char *rdrName, int id, DWORD value)
Set the value of element id in specified window or renderer.
ncsUnloadRdrEtcFile
MGNCS_EXPORT int ncsUnloadRdrEtcFile(GHANDLE hEtcFile)
Unload renderer configuration file.
mWidget
define the mWidget members, inherit from mComponent
ncsUnregisterCtrlRDRs
MGNCS_EXPORT void ncsUnregisterCtrlRDRs(const char *rdrName, const char *className)
unregister a special rdr
_NCS_RDR_ENTRY::className
const char * className
Definition: mrdr.h:350
ncsGetSystemRenderer
const MGNCS_EXPORT char * ncsGetSystemRenderer(void)
get the system renderer name
ncsLoadRdrEtcFile
MGNCS_EXPORT GHANDLE ncsLoadRdrEtcFile(const char *etcfile, const char **rdrName, int count)
Load renderer configure file from file system or incore mode.
_NCS_RDR_ENTRY::renderer
mWidgetRenderer * renderer
Definition: mrdr.h:354
ncsRetriveCtrlRDR
MGNCS_EXPORT mWidgetRenderer * ncsRetriveCtrlRDR(const char *rendererName, const char *className)
get a renderer of special control
ncsRegisterCtrlRDR
MGNCS_EXPORT BOOL ncsRegisterCtrlRDR(const char *rendererName, const char *className, mWidgetRenderer *renderer)
register one of implemention of a special control into system
mWidgetRenderer
Widget class's Renderer interface.
ncsRegisterCtrlRDRs
MGNCS_EXPORT BOOL ncsRegisterCtrlRDRs(const char *rendererName, NCS_RDR_ENTRY *entries, int count)
register a group of renderers into system
ncsSetSystemRenderer
MGNCS_EXPORT BOOL ncsSetSystemRenderer(const char *name)
Set the System renderer. If a system renderer would be used by all the controls who haven't been set ...
_NCS_RDR_ENTRY
Definition: mrdr.h:345