mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-02-07 11:01:57 +08:00
Merge branch 'master' of github.com:VincentWei/minigui
This commit is contained in:
114
include/common.h
114
include/common.h
@@ -436,11 +436,11 @@ typedef signed char SBYTE;
|
||||
#endif
|
||||
|
||||
#if SIZEOF_PTR == 8
|
||||
# define NR_BITS_BYTE (16)
|
||||
# define NR_BITS_BYTE (8)
|
||||
# define NR_BITS_WORD (32)
|
||||
# define NR_BITS_DWORD (64)
|
||||
|
||||
# define BITMASK_BYTE (0xFFFF)
|
||||
# define BITMASK_BYTE (0xFF)
|
||||
# define BITMASK_WORD (0xFFFFFFFF)
|
||||
# define BITMASK_DWORD (0xFFFFFFFFFFFFFFFF)
|
||||
|
||||
@@ -661,34 +661,64 @@ typedef UINT_PTR LPARAM;
|
||||
* \def MAKEWORD(low, high)
|
||||
* \brief Makes a word from \a low byte and \a high byte.
|
||||
*
|
||||
* \sa MAKEWORD16
|
||||
* \sa LOBYTE, HIBYTE
|
||||
*/
|
||||
#define MAKEWORD(low, high) ((WORD)(((BYTE)(low)) | (((WORD)((BYTE)(high))) << NR_BITS_BYTE)))
|
||||
|
||||
/**
|
||||
* \def LOBYTE_WORD16(w)
|
||||
* \brief Returns the low byte of the 16-bit word \a w.
|
||||
*
|
||||
* \sa MAKEWORD16
|
||||
*/
|
||||
#define LOBYTE_WORD16(w) ((BYTE)(w))
|
||||
|
||||
/**
|
||||
* \def HIBYTE_WORD16(w)
|
||||
* \brief Returns the high byte of the 16-bit word \a w.
|
||||
*
|
||||
* \sa MAKEWORD16
|
||||
*/
|
||||
#define HIBYTE_WORD16(w) ((BYTE)(((WORD16)(w) >> 8) & 0xFF))
|
||||
|
||||
/**
|
||||
* \def MAKEWORD16(low, high)
|
||||
* \brief Makes a 16-bit word from \a low byte and \a high byte.
|
||||
*
|
||||
* \sa MAKEWORD
|
||||
* \sa LOBYTE, HIBYTE
|
||||
*/
|
||||
#define MAKEWORD16(low, high) ((WORD16)(((BYTE)(low)) | (((WORD16)((BYTE)(high))) << 8)))
|
||||
|
||||
/**
|
||||
* \def MAKEWPARAM(first, second, third, fourth)
|
||||
* \brief Makes a WPARAM value with four bytes.
|
||||
*
|
||||
* \sa MAKEWORD, FIRSTBYTE, SECONDBYTE, THIRDBYTE, FOURTHBYTE
|
||||
*/
|
||||
#define MAKEWPARAM(first, second, third, fourth) \
|
||||
((WPARAM)( \
|
||||
((BYTE)(first)) | \
|
||||
(((WPARAM)((BYTE)(second))) << 8) | \
|
||||
(((WPARAM)((BYTE)(third))) << 16) | \
|
||||
(((WPARAM)((BYTE)(fourth))) << 24) \
|
||||
))
|
||||
|
||||
/**
|
||||
* \def FIRSTBYTE(w)
|
||||
* \brief Returns the first byte of the WPARAM \a w.
|
||||
*
|
||||
* \sa MAKEWPARAM
|
||||
*/
|
||||
#define FIRSTBYTE(w) ((BYTE)(w))
|
||||
|
||||
/**
|
||||
* \def SECONDBYTE(w)
|
||||
* \brief Returns the second byte of the WPARAM \a w.
|
||||
*
|
||||
* \sa MAKEWPARAM
|
||||
*/
|
||||
#define SECONDBYTE(w) ((BYTE)(((DWORD32)(w)) >> 8))
|
||||
|
||||
/**
|
||||
* \def THIRDBYTE(w)
|
||||
* \brief Returns the third byte of the WPARAM \a w.
|
||||
*
|
||||
* \sa MAKEWPARAM
|
||||
*/
|
||||
#define THIRDBYTE(w) ((BYTE)(((DWORD32)(w)) >> 16))
|
||||
|
||||
/**
|
||||
* \def FOURTHBYTE(w)
|
||||
* \brief Returns the fourth byte of the WPARAM \a w.
|
||||
*
|
||||
* \sa MAKEWPARAM
|
||||
*/
|
||||
#define FOURTHBYTE(w) ((BYTE)(((DWORD32)(w)) >> 24))
|
||||
|
||||
/**
|
||||
* \def LOWORD(l)
|
||||
* \brief Returns the low word of the double word \a l
|
||||
@@ -719,9 +749,17 @@ typedef UINT_PTR LPARAM;
|
||||
*/
|
||||
#define HISWORD(l) ((SWORD)((((DWORD)(l)) >> NR_BITS_WORD) & BITMASK_WORD))
|
||||
|
||||
/**
|
||||
* \def MAKELONG32(low, high)
|
||||
* \brief Makes a 32-bit double word from \a low word and \a high word which are both in 16-bit.
|
||||
* \sa MAKELONG
|
||||
*/
|
||||
#define MAKELONG32(low, high) ((DWORD32)(((WORD16)(low)) | (((DWORD32)((WORD16)(high))) << 16)))
|
||||
|
||||
/**
|
||||
* \def MAKELONG(low, high)
|
||||
* \brief Makes a double word from \a low word and \a high word.
|
||||
* \brief Makes a double word with pointer precision from \a low word and \a high word.
|
||||
* \sa MAKELONG32
|
||||
*/
|
||||
#define MAKELONG(low, high) ((DWORD)(((WORD)(low)) | (((DWORD)((WORD)(high))) << NR_BITS_WORD)))
|
||||
|
||||
@@ -1934,8 +1972,12 @@ int init_minigui_printf (int (*output_char) (int ch),
|
||||
#if defined(__GNUC__)
|
||||
# define _ERR_PRINTF(fmt...) fprintf (stderr, fmt)
|
||||
# ifdef _DEBUG
|
||||
# define _MG_PRINTF(fmt...) fprintf (stderr, fmt)
|
||||
# define _DBG_PRINTF(fmt...) fprintf (stdout, fmt)
|
||||
# define _MG_PRINTF(fmt...) fprintf (stdout, fmt)
|
||||
# ifdef DEBUG
|
||||
# define _DBG_PRINTF(fmt...) fprintf (stdout, fmt)
|
||||
# else
|
||||
# define _DBG_PRINTF(fmt...)
|
||||
# endif
|
||||
# else
|
||||
# define _MG_PRINTF(fmt...)
|
||||
# define _DBG_PRINTF(fmt...)
|
||||
@@ -1952,7 +1994,18 @@ static inline void _ERR_PRINTF(const char* fmt, ...)
|
||||
}
|
||||
static inline void _MG_PRINTF(const char* fmt, ...)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef DEBUG
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
vfprintf (stdout, fmt, ap);
|
||||
fprintf (stdout, "\n");
|
||||
va_end (ap);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void _DBG_PRINTF(const char* fmt, ...)
|
||||
{
|
||||
#if defined(DEBUG) && defined(_DEBUG)
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
@@ -1960,18 +2013,7 @@ static inline void _MG_PRINTF(const char* fmt, ...)
|
||||
va_end(ap);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void _DBG_PRINTF(const char* fmt, ...)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stdout, fmt, ap);
|
||||
fprintf(stdout, "\n");
|
||||
va_end(ap);
|
||||
#endif
|
||||
}
|
||||
#endif /* __GNUC__ */
|
||||
#endif /* !__GNUC__ */
|
||||
|
||||
#ifdef _MGRM_THREADS
|
||||
|
||||
|
||||
@@ -420,13 +420,21 @@ extern "C" {
|
||||
*
|
||||
* \code
|
||||
* MSG_CHAR
|
||||
* int ch = (int)wParam;
|
||||
* unsigned char ch_buff [4];
|
||||
* unsigned char ch_buff [0] = FIRSTBYTE(wParam);
|
||||
* unsigned char ch_buff [1] = SECONDBYTE(wParam);
|
||||
* unsigned char ch_buff [2] = THIRDBYTE(wParam);
|
||||
* unsigned char ch_buff [3] = FOURTHBYTE(wParam);
|
||||
* DWORD key_flags = (DWORD)lParam;
|
||||
* \endcode
|
||||
*
|
||||
* \param ch The ASCII code of the pressed key.
|
||||
* \param ch_buff The buffer to store the bytes of the character.
|
||||
* \param key_flags The shift key status when this message occurred.
|
||||
*
|
||||
* \note Please use \a FIRSTBYTE ~ \a FOURTHBYTE to get the bytes
|
||||
* if the character is a multi-byte character. Use MSG_UTF8CHAR
|
||||
* to handle the characters encoded in UTF-8.
|
||||
*
|
||||
* \sa MSG_SYSCHAR, TranslateMessage, key_defs
|
||||
*/
|
||||
#define MSG_CHAR 0x0011
|
||||
@@ -557,7 +565,31 @@ extern "C" {
|
||||
*
|
||||
* \sa MSG_SYSCHAR, TranslateMessage, key_defs
|
||||
*/
|
||||
#define MSG_KEYSYM 0x0018
|
||||
#define MSG_KEYSYM 0x0018
|
||||
|
||||
/**
|
||||
* \def MSG_UTF8CHAR
|
||||
* \brief A character translated from MSG_KEYDOWN message.
|
||||
*
|
||||
* This message generally sent by a IME window to the current active window.
|
||||
* The chararcter will be encoded in UTF-8.
|
||||
*
|
||||
* \code
|
||||
* MSG_UTF8CHAR
|
||||
* unsigned char ch_utf8 [6];
|
||||
* unsigned char ch_utf8 [0] = FIRSTBYTE(wParam);
|
||||
* unsigned char ch_utf8 [1] = SECONDBYTE(wParam);
|
||||
* unsigned char ch_utf8 [2] = THIRDBYTE(wParam);
|
||||
* unsigned char ch_utf8 [3] = FOURTHBYTE(wParam);
|
||||
* unsigned char ch_utf8 [4] = FIRSTBYTE(lParam);
|
||||
* unsigned char ch_utf8 [5] = SECONDBYTE(lParam);
|
||||
* \endcode
|
||||
*
|
||||
* \param ch_utf8 The buffer to save the character in UTF-8.
|
||||
*
|
||||
* \sa MSG_CHAR, key_defs
|
||||
*/
|
||||
#define MSG_UTF8CHAR 0x0019
|
||||
|
||||
/**
|
||||
* \def DEF_LPRESS_TIME
|
||||
|
||||
Reference in New Issue
Block a user