mGNCS API Reference  v1.5.0
A new control set and a new framework for MiniGUI apps
mcommon.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 MINICOMMON_H
55 #define MINICOMMON_H
56 
57 #if defined (WIN32)
58 
59 #ifdef __MGNCS_LIB__
60  #define MGNCS_EXPORT __declspec(dllexport)
61 #else
62  #define MGNCS_EXPORT __declspec(dllimport)
63 #endif
64 #else
65  #define MGNCS_EXPORT
66 #endif
67 
68 typedef struct Allocator{
69  void *(*alloc)(void* pold, size_t new_size);
70  size_t (*getsize)(void* p);
71  void (*free)(void* p);
72 }Allocator;
73 
74 Allocator * ncsGetDefaultAllocator(void);
75 
76 
80 enum enumNCSAlign{
81  NCS_ALIGN_LEFT = 0,
82  NCS_ALIGN_RIGHT,
83  NCS_ALIGN_CENTER
84 };
85 
89 enum enumNCSVAlign{
90  NCS_VALIGN_TOP = 0,
91  NCS_VALIGN_BOTTOM,
92  NCS_VALIGN_CENTER
93 };
94 
98 enum enumNCSImageDrawMode{
99  NCS_DM_NORMAL = 0,
100  NCS_DM_SCALED,
101  NCS_DM_TILED
102 };
103 
104 //support alloca
105 #ifdef HAVE_ALLOCA
106 #define ALLOCA(size) alloca(size)
107 #define FREEA(p)
108 #else
109 #define ALLOCA(size) malloc(size)
110 #define FREEA(p) free(p)
111 #endif
112 
113 MGNCS_EXPORT void ncsDrawImage(HDC hdc, PBITMAP pbmp, const RECT * rc, int mode, int align, int valign);
114 
115 #define IMG_TYPE_UNKNOWN 0
116 #define IMG_TYPE_BITMAP 1
117 #define IMG_TYPE_ICON 2
118 #define IMG_TYPE_MYBITMAP 4
119 
120 #define IMG_FLAG_IGNORE 0
121 #define IMG_FLAG_UNLOAD 1
122 #define IMG_FLAG_RELEASE_RES 2
123 typedef struct _ImageDrawInfo{
124  unsigned char img_type;
125  unsigned char flag;
126  unsigned char drawMode;
127  unsigned char revert;
128  union{
129  PBITMAP pbmp;
130  HICON hIcon;
131  PMYBITMAP pmybmp;
132  RES_KEY key;
133  }img;
134 }ImageDrawInfo;
135 
136 MGNCS_EXPORT void ncsInitDrawInfo(ImageDrawInfo *idi);
137 
138 MGNCS_EXPORT void ncsCleanImageDrawInfo(ImageDrawInfo * idi);
139 
140 MGNCS_EXPORT BOOL ncsSetImageDrawInfoByFile(ImageDrawInfo *idi, const char* image_file, int drawMode, BOOL bas_mybitmp);
141 
142 MGNCS_EXPORT BOOL ncsSetImageDrawInfoByRes(ImageDrawInfo *idi, RES_KEY key, int drawMode, int res_type);
143 
144 MGNCS_EXPORT BOOL ncsSetImageDrawInfo(ImageDrawInfo *idi, void* pimg, int drawMode, int img_type);
145 
146 
147 MGNCS_EXPORT void ncsImageDrawInfoDraw(ImageDrawInfo *idi, HDC hdc, const RECT* prc, int align, int valign);
148 
149 MGNCS_EXPORT BOOL ncsImageDrawInfoGetImageSize(ImageDrawInfo *idi, int *px, int *py);
150 
151 #endif
152