use inline functions for --disable-cursor instead of macros

This commit is contained in:
Vincent Wei
2019-04-15 16:44:03 +08:00
parent 9eb7bec6d3
commit fda8b7975d

View File

@@ -2568,10 +2568,6 @@ MG_EXPORT void GUIAPI FreeFixStr (char* str);
* @{
*/
#ifndef _MGHAVE_CURSOR
static inline void do_nothing (void) { return; }
#endif
#ifdef _MGHAVE_CURSOR
/**
@@ -2733,13 +2729,35 @@ MG_EXPORT HCURSOR GUIAPI GetSystemCursor (int csrid);
* \return Handle to the current system cursor, zero means no current cursor.
*/
MG_EXPORT HCURSOR GUIAPI GetCurrentCursor (void);
#else
#define LoadCursorFromFile(filename) (do_nothing(), 0)
#define CreateCursor(x, y, w, h, ANDbs, XORbs, cr) (do_nothing(), 0)
#define DestroyCursor(hcsr) (do_nothing(), 0)
#define GetSystemCursor(csrid) (do_nothing(), 0)
#define GetCurrentCursor() (do_nothing(), 0)
#endif /* _MGHAVE_CURSOR */
#else /* _MGHAVE_CURSOR */
static inline HCURSOR LoadCursorFromFile(const char* filename) {
return (HCURSOR)0;
}
static inline HCURSOR CreateCursor(int xhotspot, int yhotspot, int w, int h,
const BYTE* pANDBits, const BYTE* pXORBits, int colornum) {
return (HCURSOR)0;
}
static inline HCURSOR GUIAPI CopyCursor (HCURSOR hcsr) {
return (HCURSOR)0;
}
static inline BOOL DestroyCursor (HCURSOR hcsr) {
return TRUE;
}
static inline HCURSOR GetSystemCursor (int csrid) {
return (HCURSOR)0;
}
static inline HCURSOR GUIAPI GetCurrentCursor (void) {
return (HCURSOR)0;
}
#endif /* !_MGHAVE_CURSOR */
#define MAX_SYSCURSORINDEX 22
@@ -2864,40 +2882,7 @@ MG_EXPORT void GUIAPI SetCursorPos (int x, int y);
*
* \sa SetCursor, SetDefaultCursor, GetDefaultCursor
*/
MG_EXPORT HCURSOR GUIAPI SetCursorEx (HCURSOR hcsr, BOOL set_def);
/**
* \def SetCursor(hcsr)
* \brief Changes the current cursor.
*
* This function changes the current cursor to be \a hcsr.
*
* \param hcsr The expected cursor handle.
* \return The old cursor handle.
*
* \note This function defined as a macro calling \a SetCursorEx with
* passing \a set_def as FALSE.
*
* \sa SetCursorEx, SetDefaultCursor
*/
#define SetCursor(hcsr) SetCursorEx (hcsr, FALSE)
/**
* \def SetDefaultCursor(hcsr)
* \brief Changes the current cursor, and set it as the default cursor.
*
* This function changes the current cursor to be \a hcsr, and set it as
* the default cursor.
*
* \param hcsr The expected cursor handle.
* \return The old cursor handle.
*
* \note This function defined as a macro calling \a SetCursorEx with
* passing \a set_def as TRUE.
*
* \sa SetCursorEx, SetCursor
*/
#define SetDefaultCursor(hcsr) SetCursorEx (hcsr, TRUE)
MG_EXPORT HCURSOR GUIAPI SetCursorEx (HCURSOR hcsr, BOOL set_def);
/**
* \fn HCURSOR GUIAPI GetDefaultCursor (void)
@@ -2911,15 +2896,6 @@ MG_EXPORT void GUIAPI SetCursorPos (int x, int y);
*/
MG_EXPORT HCURSOR GUIAPI GetDefaultCursor (void);
#else
#define SetCursorEx(hcsr, set_def) (do_nothing(), 0)
#define SetCursor(hcsr) (do_nothing(), 0)
#define SetDefaultCursor(hcsr) (do_nothing(), 0)
#define GetDefaultCursor() (do_nothing(), 0)
#endif /* _MGHAVE_CURSOR */
#ifdef _MGHAVE_CURSOR
/**
* \fn int GUIAPI ShowCursor (BOOL fShow)
* \brief Shows or hides cursor.
@@ -2935,9 +2911,55 @@ MG_EXPORT HCURSOR GUIAPI GetDefaultCursor (void);
* \return Cursor showing count value.
*/
MG_EXPORT int GUIAPI ShowCursor (BOOL fShow);
#else
#define ShowCursor(fShow) (do_nothing(), 0)
#endif /* _MGHAVE_CURSOR */
#else /* _MGHAVE_CURSOR */
static inline HCURSOR SetCursorEx(HCURSOR hcsr, BOOL set_def) {
return (HCURSOR)0;
}
static inline HCURSOR GetDefaultCursor(void) {
return (HCURSOR)0;
}
static inline int GUIAPI ShowCursor (BOOL fShow) {
return 0;
}
#endif /* !_MGHAVE_CURSOR */
/**
* \def SetCursor(hcsr)
* \brief Changes the current cursor.
*
* This function changes the current cursor to be \a hcsr.
*
* \param hcsr The expected cursor handle.
* \return The old cursor handle.
*
* \note This function defined as a macro calling \a SetCursorEx with
* passing \a set_def as FALSE.
*
* \sa SetCursorEx, SetDefaultCursor
*/
#define SetCursor(hcsr) SetCursorEx (hcsr, FALSE)
/**
* \def SetDefaultCursor(hcsr)
* \brief Changes the current cursor, and set it as the default cursor.
*
* This function changes the current cursor to be \a hcsr, and set it as
* the default cursor.
*
* \param hcsr The expected cursor handle.
* \return The old cursor handle.
*
* \note This function defined as a macro calling \a SetCursorEx with
* passing \a set_def as TRUE.
*
* \sa SetCursorEx, SetCursor
*/
#define SetDefaultCursor(hcsr) SetCursorEx (hcsr, TRUE)
/** @} end of cursor_fns */