mGNCS API Reference  v1.2.0
A new control set and a new framework for MiniGUI apps
mcommon.h
Go to the documentation of this file.
1 
42 #ifndef MINICOMMON_H
43 #define MINICOMMON_H
44 
45 #if defined (WIN32)
46 
47 #ifdef __MGNCS_LIB__
48  #define MGNCS_EXPORT __declspec(dllexport)
49 #else
50  #define MGNCS_EXPORT __declspec(dllimport)
51 #endif
52 #else
53  #define MGNCS_EXPORT
54 #endif
55 
56 typedef struct Allocator{
57  void *(*alloc)(void* pold, size_t new_size);
58  size_t (*getsize)(void* p);
59  void (*free)(void* p);
60 }Allocator;
61 
62 Allocator * ncsGetDefaultAllocator(void);
63 
64 
68 enum enumNCSAlign{
69  NCS_ALIGN_LEFT = 0,
70  NCS_ALIGN_RIGHT,
71  NCS_ALIGN_CENTER
72 };
73 
77 enum enumNCSVAlign{
78  NCS_VALIGN_TOP = 0,
79  NCS_VALIGN_BOTTOM,
80  NCS_VALIGN_CENTER
81 };
82 
86 enum enumNCSImageDrawMode{
87  NCS_DM_NORMAL = 0,
88  NCS_DM_SCALED,
89  NCS_DM_TILED
90 };
91 
92 //support alloca
93 #ifdef HAVE_ALLOCA
94 #define ALLOCA(size) alloca(size)
95 #define FREEA(p)
96 #else
97 #define ALLOCA(size) malloc(size)
98 #define FREEA(p) free(p)
99 #endif
100 
101 MGNCS_EXPORT void ncsDrawImage(HDC hdc, PBITMAP pbmp, const RECT * rc, int mode, int align, int valign);
102 
103 #define IMG_TYPE_UNKNOWN 0
104 #define IMG_TYPE_BITMAP 1
105 #define IMG_TYPE_ICON 2
106 #define IMG_TYPE_MYBITMAP 4
107 
108 #define IMG_FLAG_IGNORE 0
109 #define IMG_FLAG_UNLOAD 1
110 #define IMG_FLAG_RELEASE_RES 2
111 typedef struct _ImageDrawInfo{
112  unsigned char img_type;
113  unsigned char flag;
114  unsigned char drawMode;
115  unsigned char revert;
116  union{
117  PBITMAP pbmp;
118  HICON hIcon;
119  PMYBITMAP pmybmp;
120  RES_KEY key;
121  }img;
122 }ImageDrawInfo;
123 
124 MGNCS_EXPORT void ncsInitDrawInfo(ImageDrawInfo *idi);
125 
126 MGNCS_EXPORT void ncsCleanImageDrawInfo(ImageDrawInfo * idi);
127 
128 MGNCS_EXPORT BOOL ncsSetImageDrawInfoByFile(ImageDrawInfo *idi, const char* image_file, int drawMode, BOOL bas_mybitmp);
129 
130 MGNCS_EXPORT BOOL ncsSetImageDrawInfoByRes(ImageDrawInfo *idi, RES_KEY key, int drawMode, int res_type);
131 
132 MGNCS_EXPORT BOOL ncsSetImageDrawInfo(ImageDrawInfo *idi, void* pimg, int drawMode, int img_type);
133 
134 
135 MGNCS_EXPORT void ncsImageDrawInfoDraw(ImageDrawInfo *idi, HDC hdc, const RECT* prc, int align, int valign);
136 
137 MGNCS_EXPORT BOOL ncsImageDrawInfoGetImageSize(ImageDrawInfo *idi, int *px, int *py);
138 
139 #endif
140