mGNCS API Reference  v1.2.0
A new control set and a new framework for MiniGUI apps
mrdr.h
Go to the documentation of this file.
1 
42 #ifndef _MGNCS_RENDER_H
43 #define _MGNCS_RENDER_H
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 
59 #define NCS_TYPE_MASK WE_ATTR_TYPE_MASK
60 #define NCS_TYPE_COLOR_MASK WE_ATTR_TYPE_COLOR_MASK
61 #define NCS_TYPE_INDEX_MASK WE_ATTR_TYPE_INDEX_MASK
62 
63 #define NCS_TYPE_METRICS 0x6000
64 #define NCS_TYPE_COLOR 0x7000
65 #define NCS_TYPE_IMAGE 0x8000
66 #define NCS_TYPE_INT 0x9000
67 #define NCS_TYPE_FGC NCS_TYPE_COLOR
68 #define NCS_TYPE_BGC (NCS_TYPE_COLOR | 0x0100)
69 
70 #define NCS_TYPE_IS_IMAGE(id) (((id) & NCS_TYPE_MASK) == NCS_TYPE_IMAGE)
71 
72 #define NCS_METRICS_BASEID (NCS_TYPE_METRICS | 0)
73 #define NCS_FGC_BASEID (NCS_TYPE_FGC | 0)
74 #define NCS_BGC_BASEID (NCS_TYPE_BGC | 0)
75 #define NCS_INT_BASEID (NCS_TYPE_INT | 0)
76 #define NCS_IMAGE_BASEID (NCS_TYPE_IMAGE | 0)
77 
78 #define NCS_FONT_NUMBER 0
79 #define NCS_METRICS_NUMBER 2
80 #define NCS_COLORS_NUMBER 9
81 #define NCS_IMAGE_NUMBER 17
82 #define NCS_INT_NUMBER 5
83 
84 //common for all renderer
85 #define NCS_FGC_3DBODY NCS_FGC_BASEID
86 #define NCS_BGC_3DBODY NCS_BGC_BASEID
87 
88 #define NCS_FGC_WINDOW NCS_FGC_BASEID + 1
89 #define NCS_BGC_WINDOW NCS_BGC_BASEID + 1
90 
91 #define NCS_FGC_SELECTED_ITEM NCS_FGC_BASEID + 2
92 #define NCS_BGC_SELECTED_ITEM NCS_BGC_BASEID + 2
93 
94 #define NCS_FGC_HILIGHT_ITEM NCS_FGC_BASEID + 3
95 #define NCS_BGC_HILIGHT_ITEM NCS_BGC_BASEID + 3
96 
97 #define NCS_FGC_DISABLED_ITEM NCS_FGC_BASEID + 4
98 #define NCS_BGC_DISABLED_ITEM NCS_BGC_BASEID + 4
99 
100 #define NCS_BGC_SELITEM_NOFOCUS NCS_BGC_BASEID + 5
101 
102 #define NCS_IMAGE_BKGND NCS_IMAGE_BASEID
103 #define NCS_MODE_BKIMAGE NCS_INT_BASEID
104 
105 //flat
106 #define NCS_METRICS_BORDER_WIDTH (NCS_METRICS_BASEID)
107 #define NCS_METRICS_BORDER_RADIUS (NCS_METRICS_BASEID + 1)
108 
109 //fashion
110 #define NCS_METRICS_3DBODY_ROUNDX (NCS_METRICS_BASEID)
111 #define NCS_METRICS_3DBODY_ROUNDY (NCS_METRICS_BASEID + 1)
112 #define NCS_MODE_BGC NCS_INT_BASEID + 1
113 #define NCS_MODE_FGC NCS_INT_BASEID + 2
114 #define NCS_MODE_ITEM NCS_INT_BASEID + 3
115 #define NCS_MODE_USEFLAT NCS_INT_BASEID + 4
116 
117 //fashion.ProgressBar
118 #define NCS_BGC_PRGBAR_CHUNK NCS_BGC_BASEID + 6
119 //fashion.TrackBar
120 #define NCS_BGC_TRKBAR_SLIDER NCS_BGC_BASEID + 7
121 #define NCS_BGC_TRKBAR_THUMB NCS_BGC_BASEID + 8
122 
123 //flat
124 #define NCS_BGC_PRPSHT_NMLTAB NCS_BGC_BASEID + 9
125 
126 //skin
127 #define NCS_IMAGE_ARROWS NCS_IMAGE_BASEID + 1
128 #define NCS_IMAGE_ARROWSHELL NCS_IMAGE_BASEID + 2
129 //skin.Button
130 #define NCS_IMAGE_BUTTON NCS_IMAGE_BASEID + 3
131 //skin.CheckButton
132 #define NCS_IMAGE_CHKBTN NCS_IMAGE_BASEID + 4
133 //skin.RadioButton
134 #define NCS_IMAGE_RDOBTN NCS_IMAGE_BASEID + 5
135 //skin.ListView
136 #define NCS_IMAGE_LISTV_TREE NCS_IMAGE_BASEID + 6
137 #define NCS_IMAGE_LISTV_HDR NCS_IMAGE_BASEID + 7
138 //skin.PropSheet
139 #define NCS_IMAGE_PRPSHT_TAB NCS_IMAGE_BASEID + 8
140 //skin.ProgressBar
141 #define NCS_IMAGE_PRGBAR_HCHUNK NCS_IMAGE_BASEID + 9
142 #define NCS_IMAGE_PRGBAR_VCHUNK NCS_IMAGE_BASEID + 10
143 #define NCS_IMAGE_PRGBAR_HSLIDER NCS_IMAGE_BASEID + 11
144 #define NCS_IMAGE_PRGBAR_VSLIDER NCS_IMAGE_BASEID + 12
145 //skin.TrackBar
146 #define NCS_IMAGE_TRKBAR_HSLIDER NCS_IMAGE_BASEID + 13
147 #define NCS_IMAGE_TRKBAR_VSLIDER NCS_IMAGE_BASEID + 14
148 #define NCS_IMAGE_TRKBAR_HTHUMB NCS_IMAGE_BASEID + 15
149 #define NCS_IMAGE_TRKBAR_VTHUMB NCS_IMAGE_BASEID + 16
150 
205 MGNCS_EXPORT DWORD ncsGetElementEx (mWidget *self, const char* rdrName, int id);
206 
222 MGNCS_EXPORT DWORD ncsSetElementEx (mWidget* self, const char* rdrName, int id, DWORD value);
223 
224 typedef struct _NCS_RDR_ID_NAME {
225  const char* we_name;
226  int we_id;
227 }NCS_RDR_ID_NAME;
228 
229 // id_names can be NULL, or end with (NULL, -1)
230 MGNCS_EXPORT BOOL ncsLoadRdrElementsFromEtcFile(const char* etcfile, const char** rdrNames, int count, NCS_RDR_ID_NAME * id_names);
231 
232 MGNCS_EXPORT BOOL ncsLoadRdrElementsFromEtcHandle(GHANDLE hEtc, const char** rdrNames, int count, NCS_RDR_ID_NAME* id_names);
233 
242 MGNCS_EXPORT GHANDLE ncsLoadRdrEtcFile (const char* etcfile, const char** rdrName, int count);
243 
250 MGNCS_EXPORT int ncsUnloadRdrEtcFile(GHANDLE hEtcFile);
251 
252 /*
253  * \def var g_ncsEtcHandle
254  * \breif the MGNCS configuration handle
255  */
256 MGNCS_EXPORT extern GHANDLE g_ncsEtcHandle;
257 
258 /*
259  * \fn ncsSetEtcHandler(GHANDLE hEtc);
260  * \brief set the outside of etc handler of mgnc.cfg.
261  * can used for incore resource
262  *
263  * \sa g_ncsEtcHandler
264  */
265 static inline void ncsSetEtcHandle(GHANDLE hEtc)
266 {
267  g_ncsEtcHandle = hEtc;
268 }
269 
270 
271 
276 #define ncsGetElement(self, id) \
277  ncsGetElementEx((mWidget*)self, NULL, id)
278 
283 #define ncsSetElement(self, id, value) \
284  ncsSetElementEx((mWidget*)self, NULL, id, value)
285 
297 MGNCS_EXPORT mWidgetRenderer *ncsRetriveCtrlRDR (const char *rendererName, const char *className);
298 
314 MGNCS_EXPORT BOOL ncsRegisterCtrlRDR (const char *rendererName, const char *className,
315  mWidgetRenderer *renderer);
316 
326 MGNCS_EXPORT void ncsUnregisterCtrlRDRs(const char* rdrName/*=NULL*/, const char* className/*=NULL*/);
327 
333 typedef struct _NCS_RDR_ENTRY
334 {
338  const char *className;
343 } NCS_RDR_ENTRY;
344 
358 MGNCS_EXPORT BOOL ncsRegisterCtrlRDRs (const char *rendererName, NCS_RDR_ENTRY * entries,
359  int count);
360 
378 MGNCS_EXPORT BOOL ncsSetSystemRenderer(const char* name);
379 
387 MGNCS_EXPORT const char* ncsGetSystemRenderer(void);
388 
408 #define INVALID_RDR_VALUE ((DWORD)-1)
409 
410 static inline gal_pixel ncsColor2Pixel(HDC hdc, DWORD color)
411 {
412  return RGBA2Pixel(hdc,GetRValue(color),
413  GetGValue(color),
414  GetBValue(color),
415  GetAValue(color));
416 }
417 
418 MGNCS_EXPORT void ncsCommRDRDrawFocusFrame(HWND hWnd, HDC hdc, const RECT *rc);
419 MGNCS_EXPORT BOOL ncsCommRDRDrawBkgnd(HWND hWnd, HDC hdc, const RECT* inv_rc);
420 
421 MGNCS_EXPORT void ncsCommRDRDraw3dbox(HDC hdc, const RECT* rc, DWORD color, DWORD flag);
422 MGNCS_EXPORT void ncsCommRDRDraw3DRoundBox(HDC hdc, const RECT *rc, int rx, int ry, DWORD color, DWORD flag);
423 
424 #define NCS_ROUND_CORNER_LEFT_TOP (0x1)
425 #define NCS_ROUND_CORNER_LEFT_BOTTOM (0x2)
426 #define NCS_ROUND_CORNER_RIGHT_TOP (0x4)
427 #define NCS_ROUND_CORNER_RIGHT_BOTTOM (0x8)
428 #define NCS_ROUND_CORNER_LEFTS (NCS_ROUND_CORNER_LEFT_TOP|NCS_ROUND_CORNER_LEFT_BOTTOM)
429 #define NCS_ROUND_CORNER_RIGHTS (NCS_ROUND_CORNER_RIGHT_TOP|NCS_ROUND_CORNER_RIGHT_BOTTOM)
430 #define NCS_ROUND_CORNER_TOPS (NCS_ROUND_CORNER_LEFT_TOP|NCS_ROUND_CORNER_RIGHT_TOP)
431 #define NCS_ROUND_CORNER_BOTTOMS (NCS_ROUND_CORNER_LEFT_BOTTOM|NCS_ROUND_CORNER_RIGHT_BOTTOM)
432 #define NCS_ROUND_CORNER_ALL (NCS_ROUND_CORNER_LEFT_TOP|NCS_ROUND_CORNER_LEFT_BOTTOM| \
433  NCS_ROUND_CORNER_RIGHT_TOP|NCS_ROUND_CORNER_RIGHT_BOTTOM)
434 #define NCS_BORDER_LEFT 0x1000
435 #define NCS_BORDER_RIGHT 0x2000
436 #define NCS_BORDER_TOP 0x4000
437 #define NCS_BORDER_BOTTOM 0x8000
438 #define NCS_BORDER_ALL (NCS_BORDER_LEFT|NCS_BORDER_RIGHT|NCS_BORDER_TOP|NCS_BORDER_BOTTOM)
439 
440 MGNCS_EXPORT void ncsCommRDRDraw3DHalfRoundBox(HDC hdc, const RECT *rc, int rx, int ry, DWORD color, DWORD flag, DWORD part_flag);
441 MGNCS_EXPORT void ncsCommRDRDrawHalfRoundRect(HDC hdc, const RECT *rc, int rx, int ry, DWORD color, DWORD part_flag);
442 
443 MGNCS_EXPORT void ncsCommRDRFillHalfRoundRect(HDC hdc, const RECT *rc, int rx, int ry, DWORD color, DWORD part_flag);
444 
445 MGNCS_EXPORT void ncsCommRDRDraw3DEllipse(HDC hdc, const RECT *rc, DWORD color1, DWORD color2, DWORD flag);
446 
447 MGNCS_EXPORT void ncsCommRDRDrawCheckbox(HDC hdc, const RECT* rc, DWORD fgcolor, DWORD bgcolor, DWORD discolor, DWORD flag);
448 
449 MGNCS_EXPORT void ncsCommRDRDrawRadio(HDC hdc, const RECT* rc, DWORD fgcolor, DWORD bgcolor, DWORD discolor,DWORD flag);
450 
451 MGNCS_EXPORT void ncsCommRDRDrawArrow(HDC hdc, const RECT* rc, int arrow,DWORD color, BOOL bFill);
452 
453 MGNCS_EXPORT void ncsCommRDRDrawItem(HDC hdc, const RECT* rc, DWORD color);
454 
455 MGNCS_EXPORT void ncsCommRDRDrawSmallHalfRoundBox(HDC hdc, const RECT *rc, DWORD flags, BOOL bFill);
456 
457 enum ncsCommRDRColorCalc {
458  NCSR_COLOR_DARKER = -100,
459  NCSR_COLOR_DARKEST = -200 ,
460  NCSR_COLOR_LIGHTER = 100 ,
461  NCSR_COLOR_LIGHTEST = 200
462 };
463 
464 MGNCS_EXPORT DWORD ncsCommRDRCalc3dboxColor(DWORD color, int degree);
465 
466 //skin
467 
468 #define DI_FILL_TILE 0x01
469 #define DI_FILL_STRETCH 0x02
470 
471 /* Draw info */
472 typedef struct _DRAWINFO
473 {
474  /* The pointer to the whole bitmap. */
475  const BITMAP* bmp;
476 
477  /* The number of line in this bitmap. */
478  unsigned int nr_line;
479 
480  /* The number of colume in this bitmap. */
481  unsigned int nr_col;
482 
483  /* The index of line to current sub bitmap. */
484  unsigned int idx_line;
485 
486  /* The index of colume to current sub bitmap. */
487  unsigned int idx_col;
488 
489  /* The left/top margin value of current sub bitmap. */
490  unsigned int margin1;
491 
492  /* The right/bottom margin value of current sub bitmap. */
493  unsigned int margin2;
494 
495  /* The margin direct. FALSE for left-to-right (default),
496  * TRUE for top-to-bottom. */
497  BOOL direct;
498 
499  /* The flip flag. FALSE for not flip sub bitmap (default),
500  * TRUE for flip. It can be used by draw_tab function.*/
501  BOOL flip;
502 
503  /* The style of drawing bitmap. It can be one of the
504  * following value:
505  * - DI_FILL_TILE
506  * - DI_FILL_STRETCH
507  */
508  unsigned int style;
509 
510 } DRAWINFO;
511 
512 MGNCS_EXPORT void ncsSkinDraw(HDC hdc, const RECT* rc, const DRAWINFO *di);
513 
517 #ifdef __cplusplus
518 }
519 #endif
520 
521 #endif
MGNCS_EXPORT const char * ncsGetSystemRenderer(void)
get the system renderer name
MGNCS_EXPORT void ncsUnregisterCtrlRDRs(const char *rdrName, const char *className)
unregister a special rdr
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 ...
MGNCS_EXPORT GHANDLE ncsLoadRdrEtcFile(const char *etcfile, const char **rdrName, int count)
Load renderer configure file from file system or incore mode.
Definition: mrdr.h:333
define the mWidget members, inherit from mComponent
MGNCS_EXPORT DWORD ncsSetElementEx(mWidget *self, const char *rdrName, int id, DWORD value)
Set the value of element id in specified window or renderer.
MGNCS_EXPORT DWORD ncsGetElementEx(mWidget *self, const char *rdrName, int id)
Get the value of element id in specified window or renderer.
const char * className
Definition: mrdr.h:338
MGNCS_EXPORT mWidgetRenderer * ncsRetriveCtrlRDR(const char *rendererName, const char *className)
get a renderer of special control
MGNCS_EXPORT BOOL ncsRegisterCtrlRDRs(const char *rendererName, NCS_RDR_ENTRY *entries, int count)
register a group of renderers into system
struct _NCS_RDR_ENTRY NCS_RDR_ENTRY
MGNCS_EXPORT int ncsUnloadRdrEtcFile(GHANDLE hEtcFile)
Unload renderer configuration file.
Widget class's Renderer interface.
MGNCS_EXPORT BOOL ncsRegisterCtrlRDR(const char *rendererName, const char *className, mWidgetRenderer *renderer)
register one of implemention of a special control into system
mWidgetRenderer * renderer
Definition: mrdr.h:342