From b9fd4b917850f4dc7caf09ba39e49bb1939eb90c Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Wed, 15 May 2019 11:58:48 +0800 Subject: [PATCH] New API: GetNextUChar --- include/gdi.h | 28 ++++++++++++++++++++++++++-- src/font/logfont.c | 3 +++ src/gui/window.c | 5 +---- src/kernel/message.c | 5 +++-- src/kernel/timer.c | 2 ++ src/newgdi/achar-uchar.c | 8 ++++---- 6 files changed, 39 insertions(+), 12 deletions(-) diff --git a/include/gdi.h b/include/gdi.h index 0d1132de..e4184c6c 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -11624,6 +11624,30 @@ typedef Uint32 Glyph32; MG_EXPORT Achar32 GUIAPI GetACharValue (LOGFONT* logfont, const char* mchar, int mchar_len, const char* pre_mchar, int pre_len); +#ifdef _MGCHARSET_UNICODE + +/** + * \fn int GUIAPI GetNextUChar (LOGFONT* logfont, const char* mchar, + * int mchar_len, Uchar32* uc) + * \brief Get the Uchar32 value (Unicode code point) of a multi-byte character + * in specified LOGFONT object. + * + * This function get the Uchar32 value of a mutil-byte character in specified + * LOGFONT object \a logfont, which is under speicific charset/encoding. + * + * \param logfont The logical font. + * \param mchar The pointer to the multi-byte character. + * \param mchar_len The length of \a mchar in bytes. + * \param uc The buffer to receive the Uchar32 value. + * + * \return The number of bytes consumed, i.e., the lenght of the + * multi-byte character. + */ +MG_EXPORT int GUIAPI GetNextUChar(LOGFONT* logfont, const char* mchar, + int mchar_len, Uchar32* uc); + +#endif /* _MGCHARSET_UNICODE */ + /** * \fn Uint32 GUIAPI GetACharType (LOGFONT* logfont, Achar32 chv) * \brief Retrieve the basic type, the general cateory of Unicode, and @@ -12348,7 +12372,7 @@ MG_EXPORT int GUIAPI GetUCharsUntilParagraphBoundary(LOGFONT* logfont, /** * \fn AChar2UChar(LOGFONT* logfont, Achar32 chv) - * \brief Get Uchar32 value (Unicode whide character value) from + * \brief Get Uchar32 value (Unicode wide character value) from * a LOGFONT abstract character value. * * Only valid for UNICODE. @@ -12356,7 +12380,7 @@ MG_EXPORT int GUIAPI GetUCharsUntilParagraphBoundary(LOGFONT* logfont, * \param logfont The LOGFONT object * \param chv The LOGFONT character value. * - * \return The Uchar32 value (Unicode code point) of the glyph. + * \return The Uchar32 value (Unicode code point) of the abstract character. * * \note Only available when support for UNICODE is enabled. * diff --git a/src/font/logfont.c b/src/font/logfont.c index a16ee0a4..c78decc0 100644 --- a/src/font/logfont.c +++ b/src/font/logfont.c @@ -503,6 +503,9 @@ void GUIAPI DestroyLogFont (PLOGFONT logfont) { int i; + if (!logfont) + return; + for (i = 0; i < MAXNR_DEVFONTS; i++) { DEVFONT* df = logfont->devfonts[i]; if (df && df->font_ops->delete_instance) diff --git a/src/gui/window.c b/src/gui/window.c index 14300dfc..4dc67ddc 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -5408,9 +5408,7 @@ BOOL GUIAPI DestroyWindow (HWND hWnd) if (!IsControl (hWnd)) return FALSE; - if (SendMessage (hWnd, MSG_DESTROY, 0, 0)) - { - + if (SendMessage (hWnd, MSG_DESTROY, 0, 0)) { return FALSE; } @@ -5499,7 +5497,6 @@ BOOL GUIAPI DestroyWindow (HWND hWnd) --pCtrl->we_rdr->refcount; free (pCtrl); - return TRUE; } diff --git a/src/kernel/message.c b/src/kernel/message.c index dd485af4..b64d1259 100644 --- a/src/kernel/message.c +++ b/src/kernel/message.c @@ -1230,8 +1230,9 @@ int GUIAPI ThrowAwayMessages (HWND hWnd) for (slot = 0; slot < DEF_NR_TIMERS; slot++) { if (pMsgQueue->TimerMask & (0x01UL << slot)) { HWND timer_wnd = __mg_get_timer_hwnd (slot); - if (timer_wnd == hWnd - || gui_GetMainWindowPtrOfControl (timer_wnd) == (PMAINWIN)hWnd){ + if (timer_wnd == hWnd + || (MG_IS_MAIN_WINDOW (hWnd) && + gui_GetMainWindowPtrOfControl (timer_wnd) == (PMAINWIN)hWnd)) { RemoveMsgQueueTimerFlag (pMsgQueue, slot); } } diff --git a/src/kernel/timer.c b/src/kernel/timer.c index f8e10de0..27d1dad7 100644 --- a/src/kernel/timer.c +++ b/src/kernel/timer.c @@ -431,6 +431,8 @@ BOOL GUIAPI SetTimerEx (HWND hWnd, LINT id, DWORD speed, timerstr[slot]->tick_count = 0; timerstr[slot]->msg_queue = pMsgQueue; + _MG_PRINTF ("KERNEL>Timer: setup a new timer for window (%p) at slot (%d)\n", hWnd, slot); + #ifdef _MGRM_PROCESSES if (!mgIsServer) __mg_set_select_timeout (USEC_10MS * speed); diff --git a/src/newgdi/achar-uchar.c b/src/newgdi/achar-uchar.c index 95cb9e1d..a05fdd17 100644 --- a/src/newgdi/achar-uchar.c +++ b/src/newgdi/achar-uchar.c @@ -377,7 +377,7 @@ static int usctxt_push_back(struct ustr_ctxt* ctxt, Uchar32 uc) return ctxt->n; } -static int get_next_uchar(LOGFONT* lf, const char* mstr, int mstr_len, +int GetNextUChar(LOGFONT* lf, const char* mstr, int mstr_len, Uchar32* uc) { int mclen = 0; @@ -426,7 +426,7 @@ static int is_next_mchar_bt(LOGFONT* lf, { int mclen; - mclen = get_next_uchar(lf, mstr, mstr_len, uc); + mclen = GetNextUChar(lf, mstr, mstr_len, uc); if (mclen > 0 && UCharGetBreakType(*uc) == bt) return mclen; @@ -449,7 +449,7 @@ static int collapse_space(LOGFONT* lf, const char* mstr, int mstr_len) do { int mclen; - mclen = get_next_uchar(lf, mstr, mstr_len, &uc); + mclen = GetNextUChar(lf, mstr, mstr_len, &uc); if (mclen == 0) break; @@ -504,7 +504,7 @@ int GUIAPI GetUCharsUntilParagraphBoundary(LOGFONT* logfont, int next_mclen; int cosumed_one_loop = 0; - mclen = get_next_uchar(logfont, mstr, mstr_len, &uc); + mclen = GetNextUChar(logfont, mstr, mstr_len, &uc); if (mclen == 0) { // badly encoded or end of text break;