diff --git a/src/ial/ial.c b/src/ial/ial.c
index f76362e2..594566ab 100644
--- a/src/ial/ial.c
+++ b/src/ial/ial.c
@@ -56,6 +56,7 @@
#include "common.h"
#include "minigui.h"
+#include "constants.h"
#include "misc.h"
#include "ial.h"
@@ -133,9 +134,6 @@
#include "linux-libinput.h"
#endif
-#define LEN_ENGINE_NAME 16
-#define LEN_MTYPE_NAME 16
-
static INPUT inputs [] =
{
/* General IAL engines ... */
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index b9b68875..f94b655b 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -1,5 +1,5 @@
noinst_HEADERS = \
- accelkey.h bidi.h bitmap.h cliprect.h ctrlclass.h \
+ accelkey.h bidi.h bitmap.h cliprect.h constants.h ctrlclass.h \
cursor.h dc.h event.h list.h element.h \
ial.h inline.h internals.h zorder.h menu.h misc.h \
msgstr.h sysfont.h timer.h devfont.h fontname.h \
diff --git a/src/include/constants.h b/src/include/constants.h
new file mode 100644
index 00000000..fbeb9818
--- /dev/null
+++ b/src/include/constants.h
@@ -0,0 +1,102 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT NOTICE
+//
+// The following open source license statement does not apply to any
+// entity in the Exception List published by FMSoft.
+//
+// For more information, please visit:
+//
+// https://www.fmsoft.cn/exception-list
+//
+//////////////////////////////////////////////////////////////////////////////
+/*
+ * This file is part of MiniGUI, a mature cross-platform windowing
+ * and Graphics User Interface (GUI) support system for embedded systems
+ * and smart IoT devices.
+ *
+ * Copyright (C) 2002~2020, Beijing FMSoft Technologies Co., Ltd.
+ * Copyright (C) 1998~2002, WEI Yongming
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * Or,
+ *
+ * As this program is a library, any link to this program must follow
+ * GNU General Public License version 3 (GPLv3). If you cannot accept
+ * GPLv3, you need to be licensed from FMSoft.
+ *
+ * If you have got a commercial license of this program, please use it
+ * under the terms and conditions of the commercial license.
+ *
+ * For more information about the commercial license, please refer to
+ * .
+ */
+/*
+** constants.h: this head file declares common internal constants.
+**
+** Create date: 2020/01/06
+*/
+
+#ifndef GUI_CONSTANTS_H
+ #define GUI_CONSTANTS_H
+
+#include "common.h"
+
+#define DEF_NR_TIMERS NR_BITS_DWORD
+
+// constants for clip rects heap and message heap
+#if defined (__NOUNIX__) || defined (__uClinux__)
+ #define DEF_MSGQUEUE_LEN 32
+ #define SIZE_CLIPRECTHEAP 16
+ #define SIZE_INVRECTHEAP 32
+ #define SIZE_QMSG_HEAP 32
+#else
+ #ifndef _MGRM_THREADS
+ #define DEF_MSGQUEUE_LEN 32
+ #define SIZE_CLIPRECTHEAP 16
+ #define SIZE_INVRECTHEAP 32
+ #define SIZE_QMSG_HEAP 32
+ #else
+ #define DEF_MSGQUEUE_LEN 32
+ #define SIZE_CLIPRECTHEAP 32
+ #define SIZE_INVRECTHEAP 64
+ #define SIZE_QMSG_HEAP 32
+ #endif
+#endif
+
+// constants for fix string module
+#if defined (__NOUNIX__) || defined (__uClinux__)
+ #define MAX_LEN_FIXSTR 64
+ #define NR_HEAP 5
+ #define LEN_BITMAP (1+2+4+8+16)
+#else
+ #ifdef _MGRM_THREADS
+ #define MAX_LEN_FIXSTR 2048
+ #define NR_HEAP 10
+ #define LEN_BITMAP (1+2+4+8+16+32+64+128+256+512)
+ #else
+ #define MAX_LEN_FIXSTR 64
+ #define NR_HEAP 5
+ #define LEN_BITMAP (1+2+4+8+16)
+ #endif
+#endif
+
+// constants for engine name and video mode
+#define LEN_ENGINE_NAME 23
+#define LEN_VIDEO_MODE 31
+#define LEN_MTYPE_NAME 23
+
+#endif // GUI_CONSTANTS_H
+
diff --git a/src/include/internals.h b/src/include/internals.h
index 8f9ed49f..03c24d72 100644
--- a/src/include/internals.h
+++ b/src/include/internals.h
@@ -52,6 +52,8 @@
#ifndef GUI_INTERNALS_H
#define GUI_INTERNALS_H
+#include "constants.h"
+
/******************* Internal data *******************************************/
/* Internal window message. */
@@ -63,6 +65,7 @@ __attribute__ ((visibility ("hidden"))) void screensaver_hide(void);
#else
void screensaver_hide(void);
#endif
+
#endif
/* Internal use extended style. */
@@ -75,50 +78,6 @@ void screensaver_hide(void);
*/
#define WS_EX_CTRLASMAINWIN 0x20000000L
-#define DEF_NR_TIMERS NR_BITS_DWORD
-
-#if defined (__NOUNIX__) || defined (__uClinux__)
- #define DEF_MSGQUEUE_LEN 32
- #define SIZE_CLIPRECTHEAP 16
- #define SIZE_INVRECTHEAP 32
- #define SIZE_QMSG_HEAP 32
-#else
- #ifndef _MGRM_THREADS
- #define DEF_MSGQUEUE_LEN 32
- #define SIZE_CLIPRECTHEAP 16
- #define SIZE_INVRECTHEAP 32
- #define SIZE_QMSG_HEAP 32
- #else
- #define DEF_MSGQUEUE_LEN 32
- #define SIZE_CLIPRECTHEAP 32
- #define SIZE_INVRECTHEAP 64
- #define SIZE_QMSG_HEAP 32
- #endif
-#endif
-
-/* IME info define.*/
-#define IME_SET_STATUS 1
-#define IME_GET_STATUS 2
-#define IME_SET_POS 3
-#define IME_GET_POS 4
-
-/******************* Internal data of fix string module **********************/
-#if defined (__NOUNIX__) || defined (__uClinux__)
- #define MAX_LEN_FIXSTR 64
- #define NR_HEAP 5
- #define LEN_BITMAP (1+2+4+8+16)
-#else
- #ifdef _MGRM_THREADS
- #define MAX_LEN_FIXSTR 2048
- #define NR_HEAP 10
- #define LEN_BITMAP (1+2+4+8+16+32+64+128+256+512)
- #else
- #define MAX_LEN_FIXSTR 64
- #define NR_HEAP 5
- #define LEN_BITMAP (1+2+4+8+16)
- #endif
-#endif
-
/******************** Handle type and child type. ***************************/
#define TYPE_HWND 0x01
#define TYPE_MAINWIN 0x11
@@ -139,13 +98,6 @@ void screensaver_hide(void);
#define TYPE_WINTODEL 0xF1
#define TYPE_UNDEFINED 0xFF
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-struct _MAINWIN;
-typedef struct _MAINWIN* PMAINWIN;
-
#include "zorder.h"
typedef struct _SCROLLWINDOWINFO
@@ -247,6 +199,13 @@ struct _MSGQUEUE
int loop_depth; /* message loop depth, for dialog boxes. */
};
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct _MAINWIN;
+typedef struct _MAINWIN* PMAINWIN;
+
BOOL mg_InitFreeQMSGList (void);
void mg_DestroyFreeQMSGList (void);
BOOL mg_InitMsgQueue (PMSGQUEUE pMsgQueue, int iBufferLen);
diff --git a/src/include/misc.h b/src/include/misc.h
index 2eb85791..788c946c 100644
--- a/src/include/misc.h
+++ b/src/include/misc.h
@@ -15,7 +15,7 @@
* and Graphics User Interface (GUI) support system for embedded systems
* and smart IoT devices.
*
- * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd.
+ * Copyright (C) 2002~2020, Beijing FMSoft Technologies Co., Ltd.
* Copyright (C) 1998~2002, WEI Yongming
*
* This program is free software: you can redistribute it and/or modify
diff --git a/src/include/newgal.h b/src/include/newgal.h
index 5e5688b2..58ddb792 100644
--- a/src/include/newgal.h
+++ b/src/include/newgal.h
@@ -11,44 +11,44 @@
//
//////////////////////////////////////////////////////////////////////////////
/*
- * This file is part of MiniGUI, a mature cross-platform windowing
+ * This file is part of MiniGUI, a mature cross-platform windowing
* and Graphics User Interface (GUI) support system for embedded systems
* and smart IoT devices.
- *
- * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd.
+ *
+ * Copyright (C) 2002~2020, Beijing FMSoft Technologies Co., Ltd.
* Copyright (C) 1998~2002, WEI Yongming
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
+ *
* Or,
- *
+ *
* As this program is a library, any link to this program must follow
* GNU General Public License version 3 (GPLv3). If you cannot accept
* GPLv3, you need to be licensed from FMSoft.
- *
+ *
* If you have got a commercial license of this program, please use it
* under the terms and conditions of the commercial license.
- *
+ *
* For more information about the commercial license, please refer to
* .
*/
/*
** newgal.h: the head file of New Graphics Abstraction Layer.
-**
+**
** Note: The architechture of new GAL is borrowed from SDL.
** Thank Sam Lantinga and many others for their great work.
-**
+**
** Created date: 2001/10/03
*/
@@ -229,7 +229,7 @@ extern GAL_Surface * GAL_GetVideoSurface (void);
*/
extern const GAL_VideoInfo * GAL_GetVideoInfo (void);
-/*
+/*
* Check to see if a particular video mode is supported.
* It returns 0 if the requested mode is not supported under any bit depth,
* or returns the bits-per-pixel of the closest available mode with the
@@ -244,11 +244,11 @@ extern int GAL_VideoModeOK (int width, int height, int bpp, Uint32 flags);
/*
* Return a pointer to an array of available screen dimensions for the
- * given format and video flags, sorted largest to smallest. Returns
- * NULL if there are no dimensions available for a particular format,
+ * given format and video flags, sorted largest to smallest. Returns
+ * NULL if there are no dimensions available for a particular format,
* or (GAL_Rect **)-1 if any dimension is okay for the given format.
*
- * If 'format' is NULL, the mode list will be for the format given
+ * If 'format' is NULL, the mode list will be for the format given
* by GAL_GetVideoInfo()->vfmt
*/
extern GAL_Rect ** GAL_ListModes (GAL_PixelFormat *format, Uint32 flags);
@@ -277,21 +277,21 @@ extern GAL_Rect ** GAL_ListModes (GAL_PixelFormat *format, Uint32 flags);
* Otherwise, in 8-bit mode, GAL_SetColors() may not be able to set all
* of the colors exactly the way they are requested, and you should look
* at the video surface structure to determine the actual palette.
- * If GAL cannot guarantee that the colors you request can be set,
+ * If GAL cannot guarantee that the colors you request can be set,
* i.e. if the colormap is shared, then the video surface may be created
* under emulation in system memory, overriding the GAL_HWSURFACE flag.
*
* If GAL_FULLSCREEN is set in 'flags', the GAL library will try to set
* a fullscreen video mode. The default is to create a windowed mode
* if the current graphics system has a window manager.
- * If the GAL library is able to set a fullscreen video mode, this flag
+ * If the GAL library is able to set a fullscreen video mode, this flag
* will be set in the surface that is returned.
*
* If GAL_DOUBLEBUF is set in 'flags', the GAL library will try to set up
- * two surfaces in video memory and swap between them when you call
+ * two surfaces in video memory and swap between them when you call
* GAL_Flip(). This is usually slower than the normal single-buffering
- * scheme, but prevents "tearing" artifacts caused by modifying video
- * memory while the monitor is refreshing. It should only be used by
+ * scheme, but prevents "tearing" artifacts caused by modifying video
+ * memory while the monitor is refreshing. It should only be used by
* applications that redraw the entire screen on every update.
*
* If GAL_RESIZABLE is set in 'flags', the GAL library will allow the
@@ -353,13 +353,13 @@ extern int GAL_Flip (GAL_Surface *screen);
* determine the actual color palette.
*
* When 'surface' is the surface associated with the current display, the
- * display colormap will be updated with the requested colors. If
+ * display colormap will be updated with the requested colors. If
* GAL_HWPALETTE was set in GAL_SetVideoMode() flags, GAL_SetColors()
* will always return 1, and the palette is guaranteed to be set the way
* you desire, even if the window colormap has to be warped or run under
* emulation.
*/
-extern int GAL_SetColors (GAL_Surface *surface,
+extern int GAL_SetColors (GAL_Surface *surface,
GAL_Color *colors, int firstcolor, int ncolors);
/*
@@ -433,7 +433,7 @@ extern Uint8 GAL_FindColor(GAL_Palette *pal, Uint8 r, Uint8 g, Uint8 b);
* two surfaces in video memory, GAL will try to place the surface in
* video memory. If this isn't possible or if there is no hardware
* acceleration available, the surface will be placed in system memory.
- * GAL_SRCALPHA means that the surface will be used for alpha blits and
+ * GAL_SRCALPHA means that the surface will be used for alpha blits and
* if the hardware supports hardware acceleration of alpha blits between
* two surfaces in video memory, to place the surface in video memory
* if possible, otherwise it will be placed in system memory.
@@ -448,7 +448,7 @@ extern Uint8 GAL_FindColor(GAL_Palette *pal, Uint8 r, Uint8 g, Uint8 b);
*/
#define GAL_AllocSurface GAL_CreateRGBSurface
extern GAL_Surface *GAL_CreateRGBSurface
- (Uint32 flags, int width, int height, int depth,
+ (Uint32 flags, int width, int height, int depth,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
extern GAL_Surface *GAL_CreateRGBSurfaceFrom (void *pixels,
int width, int height, int depth, int pitch,
@@ -510,8 +510,8 @@ extern void GAL_RequestHWSurface (const REQ_HWSURFACE* request, REP_HWSURFACE* r
/*
* GAL_LockSurface() sets up a surface for directly accessing the pixels.
* Between calls to GAL_LockSurface()/GAL_UnlockSurface(), you can write
- * to and read from 'surface->pixels', using the pixel format stored in
- * 'surface->format'. Once you are done accessing the surface, you should
+ * to and read from 'surface->pixels', using the pixel format stored in
+ * 'surface->format'. Once you are done accessing the surface, you should
* use GAL_UnlockSurface() to release it.
*
* Not all surfaces require locking. If GAL_MUSTLOCK(surface) evaluates
@@ -519,7 +519,7 @@ extern void GAL_RequestHWSurface (const REQ_HWSURFACE* request, REP_HWSURFACE* r
* pixel format of the surface will not change. In particular, if the
* GAL_HWSURFACE flag is not given when calling GAL_SetVideoMode(), you
* will not need to lock the display surface before accessing it.
- *
+ *
* No operating system or library calls should be made between lock/unlock
* pairs, as critical system locks may be held during this time.
*
@@ -531,7 +531,7 @@ extern void GAL_UnlockSurface (GAL_Surface *surface);
/*
* Sets the color key (transparent pixel) in a blittable surface.
- * If 'flag' is GAL_SRCCOLORKEY (optionally OR'd with GAL_RLEACCEL),
+ * If 'flag' is GAL_SRCCOLORKEY (optionally OR'd with GAL_RLEACCEL),
* 'key' will be the transparent pixel in the source image of a blit.
* GAL_RLEACCEL requests RLE acceleration for the surface if present,
* and removes RLE acceleration if absent.
@@ -577,11 +577,11 @@ extern GAL_bool GAL_SetClipRect (GAL_Surface *surface, GAL_Rect *rect);
extern void GAL_GetClipRect (GAL_Surface *surface, GAL_Rect *rect);
/*
- * Creates a new surface of the specified format, and then copies and maps
- * the given surface to it so the blit of the converted surface will be as
+ * Creates a new surface of the specified format, and then copies and maps
+ * the given surface to it so the blit of the converted surface will be as
* fast as possible. If this function fails, it returns NULL.
*
- * The 'flags' parameter is passed to GAL_CreateRGBSurface() and has those
+ * The 'flags' parameter is passed to GAL_CreateRGBSurface() and has those
* semantics. You can also pass GAL_RLEACCEL in the flags parameter and
* GAL will try to RLE accelerate colorkey and alpha blits in the resulting
* surface.
@@ -613,7 +613,7 @@ extern GAL_Surface *GAL_ConvertSurface
* if GAL_SRCCOLORKEY set, only copy the pixels matching the
* RGB values of the source colour key, ignoring alpha in the
* comparison.
- *
+ *
* RGB->RGBA:
* GAL_SRCALPHA set:
* alpha-blend (using the source per-surface alpha value);
@@ -623,7 +623,7 @@ extern GAL_Surface *GAL_ConvertSurface
* both:
* if GAL_SRCCOLORKEY set, only copy the pixels matching the
* source colour key.
- *
+ *
* RGBA->RGBA:
* GAL_SRCALPHA set:
* alpha-blend (using the source alpha channel) the RGB values;
@@ -634,8 +634,8 @@ extern GAL_Surface *GAL_ConvertSurface
* if GAL_SRCCOLORKEY set, only copy the pixels matching the
* RGB values of the source colour key, ignoring alpha in the
* comparison.
- *
- * RGB->RGB:
+ *
+ * RGB->RGB:
* GAL_SRCALPHA set:
* alpha-blend (using the source per-surface alpha value).
* GAL_SRCALPHA not set:
@@ -645,7 +645,7 @@ extern GAL_Surface *GAL_ConvertSurface
* source colour key.
*
* If either of the surfaces were in video memory, and the blit returns -2,
- * the video memory was lost, so it should be reloaded with artwork and
+ * the video memory was lost, so it should be reloaded with artwork and
* re-blitted:
while ( GAL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
while ( GAL_LockSurface(image) < 0 )
@@ -678,7 +678,7 @@ extern int GAL_LowerBlit (GAL_Surface *src, GAL_Rect *srcrect,
* The given rectangle is clipped to the destination surface clip area
* and the final fill rectangle is saved in the passed in pointer.
* If 'dstrect' is NULL, the whole surface will be filled with 'color'
- * The color should be a pixel of the format used by the surface, and
+ * The color should be a pixel of the format used by the surface, and
* can be generated by the GAL_MapRGB() function.
* This function returns 0 on success, or -1 on error.
*/
@@ -710,7 +710,7 @@ extern int GAL_GetBox (GAL_Surface *src, const GAL_Rect* srcrect, BITMAP* box);
*/
extern int GAL_PutBox (GAL_Surface *dst, const GAL_Rect* dstrect, BITMAP* box);
-/*
+/*
* This function takes a surface and copies it to a new surface of the
* pixel format and colors of the video framebuffer, suitable for fast
* blitting onto the display surface. It calls GAL_ConvertSurface()
@@ -723,7 +723,7 @@ extern int GAL_PutBox (GAL_Surface *dst, const GAL_Rect* dstrect, BITMAP* box);
*/
extern GAL_Surface * GAL_DisplayFormat (GAL_Surface *surface);
-/*
+/*
* This function takes a surface and copies it to a new surface of the
* pixel format and colors of the video framebuffer (if possible),
* suitable for fast alpha blitting onto the display surface.
diff --git a/src/newgal/newgal.c b/src/newgal/newgal.c
index 307a4ed1..206141a2 100644
--- a/src/newgal/newgal.c
+++ b/src/newgal/newgal.c
@@ -57,16 +57,13 @@
#include "common.h"
#include "minigui.h"
+#include "constants.h"
#include "newgal.h"
#include "misc.h"
#include "license.h"
-
GAL_Surface* __gal_screen;
-#define LEN_ENGINE_NAME 10
-#define LEN_MODE 20
-
BOOL GAL_ParseVideoMode (const char* mode, int* w, int* h, int* depth)
{
const char* tmp;
@@ -92,7 +89,7 @@ int mg_InitGAL (void)
int i;
int w, h, depth;
char engine [LEN_ENGINE_NAME + 1];
- char mode [LEN_MODE + 1];
+ char mode [LEN_VIDEO_MODE + 1];
#if defined (WIN32) || !defined(__NOUNIX__)
char* env_value;
@@ -127,13 +124,13 @@ int mg_InitGAL (void)
#if defined (WIN32) || !defined(__NOUNIX__)
if ((env_value = getenv ("MG_DEFAULTMODE"))) {
- strncpy (mode, env_value, LEN_MODE);
- mode [LEN_MODE] = '\0';
+ strncpy (mode, env_value, LEN_VIDEO_MODE);
+ mode [LEN_VIDEO_MODE] = '\0';
}
else
#endif
- if (GetMgEtcValue (engine, "defaultmode", mode, LEN_MODE) < 0)
- if (GetMgEtcValue ("system", "defaultmode", mode, LEN_MODE) < 0)
+ if (GetMgEtcValue (engine, "defaultmode", mode, LEN_VIDEO_MODE) < 0)
+ if (GetMgEtcValue ("system", "defaultmode", mode, LEN_VIDEO_MODE) < 0)
return ERR_CONFIG_FILE;
if (!GAL_ParseVideoMode (mode, &w, &h, &depth)) {