?? cursor-sa.c
字號:
if(number <= 0) return TRUE; number = number < (MAX_SYSCURSORINDEX + 1) ? number : (MAX_SYSCURSORINDEX + 1); for(i = 0; i < number; i++) { if ( !(SysCursor[i] = LoadSystemCursor(i)) ) goto error; } return TRUE;error: TerminateCursor(); return FALSE;}// The following function must be called at last. void TerminateCursor( void ){ int i; if (!savedbits ) return; free(savedbits); free(cursorbits); savedbits = NULL; pCurCsr = NULL; nShowCount = 0; for(i = 0; i<= MAX_SYSCURSORINDEX; i++) { if( SysCursor[i] ) { free(SysCursor[i]->AndBits); free(SysCursor[i]->XorBits); free(SysCursor[i]); SysCursor[i] = NULL; } }}HCURSOR GUIAPI GetCurrentCursor(void){ return (HCURSOR)pCurCsr;}// Cursor pointer shape and hiding and showing.static inline int boxleft(void){ if(!pCurCsr) return -100; return curx - pCurCsr->xhotspot;}static inline int boxtop(void){ if(!pCurCsr) return -100; return cury - pCurCsr->yhotspot;}#ifdef _USE_NEWGALstatic GAL_Rect csr_rect = {0, 0, CURSORWIDTH, CURSORHEIGHT};static void hidecursor (void){ csr_rect.x = oldboxleft; csr_rect.y = oldboxtop; csr_bmp.bmBits = savedbits; GAL_SetClipRect (__gal_screen, NULL); GAL_PutBox (__gal_screen, &csr_rect, &csr_bmp); GAL_UpdateRects (__gal_screen, 1, &csr_rect);}static void showcursor (void){ int x, y; x = boxleft (); y = boxtop (); csr_rect.x = x; csr_rect.y = y; csr_bmp.bmBits = savedbits; GAL_SetClipRect (__gal_screen, NULL); GAL_GetBox (__gal_screen, &csr_rect, &csr_bmp); oldboxleft = x; oldboxtop = y; GAL_memcpy4 (cursorbits, savedbits, csrimgsize >> 2);#ifdef ASM_memandcpy4 ASM_memandcpy4 (cursorbits, pCurCsr->AndBits, csrimgsize >> 2); ASM_memxorcpy4 (cursorbits, pCurCsr->XorBits, csrimgsize >> 2);#else { int i; Uint32* andbits = (Uint32*) pCurCsr->AndBits; Uint32* xorbits = (Uint32*) pCurCsr->XorBits; Uint32* dst = (Uint32*) cursorbits; for (i = 0; i < csrimgsize >> 2; i++) { dst [i] &= andbits [i]; dst [i] ^= xorbits[i]; } }#endif csr_bmp.bmBits = cursorbits; GAL_PutBox (__gal_screen, &csr_rect, &csr_bmp); GAL_UpdateRects (__gal_screen, 1, &csr_rect);}#elsestatic void hidecursor (void){ GAL_SetGC (PHYSICALGC); GAL_DisableClipping (PHYSICALGC); GAL_PutBox (PHYSICALGC, oldboxleft, oldboxtop, CURSORWIDTH, CURSORHEIGHT, savedbits);}static void showcursor (void){ int x, y; GAL_SetGC (PHYSICALGC); x = boxleft (); y = boxtop (); GAL_DisableClipping (PHYSICALGC); GAL_GetBox (PHYSICALGC, x, y, CURSORWIDTH, CURSORHEIGHT, savedbits); oldboxleft = x; oldboxtop = y; memcpy (cursorbits, savedbits, csrimgsize); { int i; Uint32* dst = (Uint32*) cursorbits; Uint32* andbits = (Uint32*) pCurCsr->AndBits; Uint32* xorbits = (Uint32*) pCurCsr->XorBits; for (i = 0; i < csrimgsize >> 2; i++) { dst [i] &= andbits [i]; dst [i] ^= xorbits[i]; } } GAL_EnableClipping (PHYSICALGC); GAL_PutBox (PHYSICALGC, x, y, CURSORWIDTH, CURSORHEIGHT, cursorbits);}#endif /* _USE_NEWGAL */#endif /* _CURSOR_SUPPORT */// The return value indicates whether mouse has moved. // TRUE for moved.// NOTE that only server can call this function.BOOL RefreshCursor (int* x, int* y, int* button){ BOOL moved = FALSE; IAL_GetMouseXY (x, y); curx = *x; cury = *y; if (button) *button = IAL_GetMouseButton (); if (oldx != curx || oldy != cury) {#ifdef _CURSOR_SUPPORT if (nShowCount >= 0 && pCurCsr) { hidecursor (); showcursor (); }#endif /* _CURSOR_SUPPORT */ oldx = curx; oldy = cury; moved = TRUE; } return moved;}#ifdef _CURSOR_SUPPORT/* Always call with "setdef = FALSE" for clients at server side. */HCURSOR GUIAPI SetCursorEx (HCURSOR hcsr, BOOL setdef){ PCURSOR old, pcsr; if (setdef) { old = (PCURSOR) def_cursor; def_cursor = hcsr; } else old = pCurCsr; if ((PCURSOR)hcsr == pCurCsr) { return (HCURSOR) old; } pcsr = (PCURSOR)hcsr; if (pCurCsr) hidecursor(); pCurCsr = pcsr; if (pCurCsr && nShowCount >= 0) showcursor(); return (HCURSOR) old;}void ShowCursorForGDI (BOOL fShow, const RECT* prc){ int csrleft, csrright, csrtop, csrbottom; int intleft, intright, inttop, intbottom; csrleft = boxleft(); csrright = csrleft + CURSORWIDTH; csrtop = boxtop(); csrbottom = csrtop + CURSORHEIGHT; intleft = (csrleft > prc->left) ? csrleft : prc->left; inttop = (csrtop > prc->top) ? csrtop : prc->top; intright = (csrright < prc->right) ? csrright : prc->right; intbottom = (csrbottom < prc->bottom) ? csrbottom : prc->bottom; if (intleft >= intright || inttop >= intbottom) {#ifdef _USE_NEWGAL if (fShow) GAL_UpdateRect (__gal_screen, prc->left, prc->top, RECTWP(prc), RECTHP(prc));#endif return; } if (fShow && nShowCount >= 0 && pCurCsr) { showcursor(); } if (!fShow && nShowCount >= 0 && pCurCsr) { hidecursor(); }#ifdef _USE_NEWGAL if (fShow) GAL_UpdateRect (__gal_screen, prc->left, prc->top, RECTWP(prc), RECTHP(prc));#endif}int GUIAPI ShowCursor (BOOL fShow){ if (fShow) { nShowCount++; if (nShowCount == 0 && pCurCsr) showcursor(); } else { nShowCount--; if (nShowCount == -1 && pCurCsr) hidecursor(); } return nShowCount;}#elsevoid ShowCursorForGDI (BOOL fShow, const RECT* prc){#ifdef _USE_NEWGAL if (fShow) GAL_UpdateRect (__gal_screen, prc->left, prc->top, RECTWP(prc), RECTHP(prc));#endif}#endif /* _CURSOR_SUPPORT */void GUIAPI GetCursorPos (POINT* ppt){ ppt->x = curx; ppt->y = cury;}void GUIAPI SetCursorPos (int x, int y){ IAL_SetMouseXY (x, y); RefreshCursor (&x, &y, NULL);}// Cursor clipping support.void GUIAPI ClipCursor (const RECT* prc){ RECT rc; if (IsRectEmpty (&cliprc)) SetRect (&cliprc, 0, 0, WIDTHOFPHYGC - 1, HEIGHTOFPHYGC - 1); if (prc == NULL) { IAL_SetMouseRange (0,0,WIDTHOFPHYGC - 1, HEIGHTOFPHYGC - 1); SetRect (&cliprc, 0, 0, WIDTHOFPHYGC - 1, HEIGHTOFPHYGC - 1); return; } memcpy (&rc, prc, sizeof(RECT)); NormalizeRect (&rc); IntersectRect (&cliprc, &rc, &cliprc); NormalizeRect (&cliprc); IAL_SetMouseRange (cliprc.left, cliprc.top, cliprc.right, cliprc.bottom);}void GUIAPI GetClipCursor (RECT* prc){ memcpy (prc, &cliprc, sizeof(RECT));}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -