/********************************************************************* * * GUI_CURSOR_Select */ const GUI_CURSOR GUI_UNI_PTR * GUI_CURSOR_Select(const GUI_CURSOR GUI_UNI_PTR * pCursor) { int AllocSize; const GUI_BITMAP GUI_UNI_PTR * pBM; const GUI_CURSOR GUI_UNI_PTR * pOldCursor; GUI_LOCK(); pOldCursor = _pCursor; if (pCursor != _pCursor) { int i; pBM = pCursor->pBitmap; i = pBM->pPal->NumEntries > 4 ? 4 : pBM->pPal->NumEntries; while (i--) { LCD_COLOR Color = *(pBM->pPal->pPalEntries + i); _ColorIndex[i] = LCD_Color2Index(Color); } _Hide(); AllocSize = pBM->XSize * pBM->YSize * sizeof(LCD_PIXELINDEX); if (AllocSize != _AllocSize) { GUI_ALLOC_Free(_hBuffer); _hBuffer = 0; } _hBuffer = GUI_ALLOC_AllocZero(AllocSize); _CursorOn = 1; _pCursor = pCursor; _CalcRect(); _Show(); } GUI_UNLOCK(); return pOldCursor; }
/********************************************************************* * * GUI_CURSOR_Hide */ void GUI_CURSOR_Hide(void) { GUI_LOCK(); _Hide(); _CursorOn = 0; /* Set function pointer which window manager can use */ GUI_CURSOR_pfTempHide = NULL; GUI_CURSOR_pfTempUnhide = NULL; GUI_UNLOCK(); }
/********************************************************************* * * _TempHide * * Purpose: * Hide cursor if a part of the given rectangle is located in the * rectangle used for the cursor. This routine is called automatically * by the window manager. This way the window manager can * automatically make sure that the cursor is always displayed * correctly. * * Params: * pRect Rectangle under consideration * * Return value: * 0: No action taken * Cursor was not visible or not affected because rectangles * did not overlap * 1: Cursor hidden -> WM needs to restore cursor after * drawing operation */ static char _TempHide(const GUI_RECT* pRect) { if (!_CursorIsVis) { return 0; /* Cursor not visible -> nothing to do */ } if ((pRect == NULL) || GUI_RectsIntersect(pRect, &_Rect)) { _Hide(); /* Cursor needs to be hidden */ return 1; } return 0; /* Cursor not affected -> nothing to do */ }
void bbTooltip::MouseEvent(POINT pos, UINT message) { // grischka TipStruct *t = m_TipList, *tx = NULL, *ty = NULL; while (t) { if ( PtInRect(&t->rect, pos)) { tx = t; // there is the mouse over } else if (t->shown) { ty = t; // there's not, but it is currently displayed t->shown = 0; } else if (t->clicked) { t->clicked = 0; // none of above, reset clicked flag } t = t->next; } if (message == WM_MOUSEMOVE) { if (tx) { // show the tip under the mouse, if necessary if (m_pInfo->bSetLabel) { PostMessage(m_hCore, BB_SETTOOLBARLABEL, 0, (LPARAM)tx->text); } if (tx->showTip) { if (!tx->clicked && !tx->shown) { _Activate(&tx->rect, tx->text); tx->shown = 1; } return; } } if (ty) { RECT r = { ty->rect.left - m_pInfo->activation_rect_pad - 1, // prevent tip from hiding between rects ty->rect.top, ty->rect.right + m_pInfo->activation_rect_pad + 1, ty->rect.bottom }; if (PtInRect(&r, pos)) { ty->shown = 1; return; } } } if (ty) goto ty_true; if (tx) { tx->clicked = 1; tx->shown = 0; ty_true: _Hide(); } }
/********************************************************************* * * GUI_CURSOR_Show */ void GUI_CURSOR_Show(void) { GUI_LOCK(); LCDDEV_L0_GetRect(&_ClipRect); _Hide(); _CursorOn = 1; /* Set function pointer which window manager can use */ GUI_CURSOR_pfTempHide = _TempHide; GUI_CURSOR_pfTempUnhide = _TempUnhide; if (!_pCursor) { GUI_CURSOR_Select(GUI_DEFAULT_CURSOR); } else { _Show(); } GUI_UNLOCK(); }
void bbTooltip::ClearList() // grischka { TipStruct *t, **tp = &m_TipList; // search the list for unused tips and remove them while (t = *tp) { if (t->used_flg) { t->used_flg = 0; tp = &t->next; } else { if (t->shown) _Hide(); *tp = t->next; delete t; } } }
/********************************************************************* * * GUI_CURSOR_Deactivate */ void GUI_CURSOR_Deactivate(void) { GUI_LOCK(); if (_CursorDeActCnt++ ==0) _Hide(); GUI_UNLOCK(); }