static LRESULT CALLBACK RulerWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_SETCURSOR && g_actionInProgress && g_actionInProgress->SetMouseCursor) { if (HCURSOR cursor = g_actionInProgress->SetMouseCursor(BR_ContinuousAction::RULER)) { SetCursor(cursor); return 1; } } else if (uMsg == WM_MOUSEMOVE && g_actionInProgress && g_actionInProgress->SetTooltip) { WDL_FastString tooltip = g_actionInProgress->SetTooltip(BR_ContinuousAction::RULER); if (tooltip.GetLength()) { POINT p = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; ClientToScreen(hwnd, &p); SetTooltip(tooltip.Get(), &p); } else { SetTooltip(NULL, NULL); } } return g_rulerWndProc(hwnd, uMsg, wParam, lParam); }
void Render( int realX, int realY, bool highlighted, bool clicked ) { if( g_app->GetGame()->m_winner != -1 ) return; if( g_app->GetWorld()->AmISpectating() ) return; int permitDefection = g_app->GetGame()->GetOptionValue( "PermitDefection" ); if( permitDefection ) { AlliancesWindow *parent = (AlliancesWindow *)m_parent; int teamId = parent->m_selectionTeamId; if( teamId == -1 ) return; Team *myTeam = g_app->GetWorld()->GetMyTeam(); Team *thisTeam = g_app->GetWorld()->GetTeam(teamId); if( myTeam && thisTeam ) { if( myTeam->m_allianceId == thisTeam->m_allianceId ) { if( myTeam == thisTeam ) { // This is my team if( g_app->GetWorld()->CountAllianceMembers(myTeam->m_allianceId) == 1 ) { // I am the only member of this alliance, so theres nothing to do here return; } SetCaption( "dialog_alliance_leave", true ); SetTooltip( "tooltip_alliance_leave", true ); } else { // Another member of the same alliance SetCaption( "dialog_alliance_kick", true ); SetTooltip( "tooltip_alliance_kick", true ); } } else if( myTeam->m_allianceId != thisTeam->m_allianceId ) { // A different (enemy) alliance SetCaption( "dialog_alliance_join", true ); SetTooltip( "tooltip_alliance_join", true ); } } InterfaceButton::Render( realX, realY, highlighted, clicked ); } }
/** * Konstruktor von @p ctrlButton. * * @author OLiver */ ctrlButton::ctrlButton(Window *parent, unsigned int id, unsigned short x, unsigned short y, unsigned short width, unsigned short height, TextureColor tc, const std::string& tooltip) : Window(x, y, id, parent, width, height), tc(tc), state(BUTTON_UP), border(true), check(false), illuminated(false), enabled(true) { SetTooltip(tooltip); }
int Window_( lua_State* L ) { UIWindow* window = new UIWindow; SetName(L, window); SetTopLeftWidthHeight(L, window); SetTooltip(L, window); SetAnim(L, window, UIPanel::NORMAL_ANIM_, "normalAnim"); SetAnim(L, window, UIPanel::DISABLED_ANIM_, "disabledAnim"); SetTextUserData(L, window); AddWidget(L, window); // 配置关闭按钮 if (util::HasField(L, "closeBtn")) { lua_pushstring(L, "closeBtn"); lua_gettable(L, -2); if (lua_istable(L, -1)) SetButton(L, window->GetCloseButton()); lua_pop(L, 1); } SetAlpha(L, window); lua_pushlightuserdata(L, window); return 1; }
void EclButton::SetProperties ( const char *_name, int _x, int _y, int _w, int _h, const UnicodeString &_caption, const UnicodeString &_tooltip ) { if ( strlen(_name) > SIZE_ECLBUTTON_NAME ) { } else { strcpy ( m_name, _name ); } m_x = _x; m_y = _y; m_w = _w; m_h = _h; if ( !&_caption ) { // Could use LANGUAGEPHRASE here instead, but that's cross projecs, so probably shouldn't... SetCaption( UnicodeString(_name) ); } else { SetCaption ( _caption ); } SetTooltip ( _tooltip ); }
BOOL CToolbarHelper::SetTooltip(UINT nBtnCmdID, UINT nIDTip) { CString sTip; if (sTip.LoadString(nIDTip)) return SetTooltip(nBtnCmdID, sTip); return FALSE; }
EclButton::EclButton () : m_x(0), m_y(0), m_w(0), m_h(0), m_parent(NULL), m_inactive(false) { strcpy ( m_name, "New Button" ); SetTooltip ( UnicodeString(" ") ); }
int Line(lua_State* L) { UILine* line = new UILine; SetName(L, line); SetTopLeftWidthHeight(L, line); SetTooltip(L, line); SetTextUserData(L, line); SetAlpha(L, line); lua_pushlightuserdata(L, line); return 1; }
void TUrlLink::EnableTooltip(bool enable) { if (!Tooltip) { // Create and initialize tooltip // SetTooltip(new TTooltip(this)); } else { if (Tooltip->GetHandle()) Tooltip->Activate(enable); } }
int Panel(lua_State* L) { UIPanel* panel = new UIPanel; SetName(L, panel); SetTopLeftWidthHeight(L, panel); SetTooltip(L, panel); SetAnim(L, panel, UIPanel::NORMAL_ANIM_, "normalAnim"); SetAnim(L, panel, UIPanel::DISABLED_ANIM_, "disabledAnim"); SetTextUserData(L, panel); AddWidget(L, panel); SetAlpha(L, panel); lua_pushlightuserdata(L, panel); return 1; }
static void ContinuousActionTimer () { if (g_actionInProgress && g_actionInProgress->cmd) { // Don't let other windows steal our keyboard accelerator SetFocus(GetArrangeWnd()); // Make sure tooltip is not displayed if mouse is over another window (tooltip only follows mouse movements in arrange/ruler) if (g_actionInProgress->SetTooltip) { POINT p; GetCursorPos(&p); HWND hwnd = WindowFromPoint(p); if (hwnd != GetArrangeWnd() && hwnd != GetRulerWnd()) SetTooltip(NULL, NULL); } Main_OnCommand(g_actionInProgress->cmd, ACTION_FLAG); } }
int Progressbar(lua_State* L) { UIProgressbar* progressbar = new UIProgressbar; SetName(L, progressbar); SetTopLeftWidthHeight(L, progressbar); SetTooltip(L, progressbar); SetAnim(L, progressbar, UIProgressbar::BOTTOM_ANIM_, "bottomAnim"); SetAnim(L, progressbar, UIProgressbar::MID_ANIM_, "midAnim"); SetAnim(L, progressbar, UIProgressbar::TOP_ANIM_, "topAnim"); SetTextUserData(L, progressbar); AddWidget(L, progressbar); SetAlpha(L, progressbar); lua_pushlightuserdata(L, progressbar); return 1; }
int Button(lua_State* L) { UIButton* btn = new UIButton; SetName(L, btn); SetTopLeftWidthHeight(L, btn); SetTooltip(L, btn); SetAnim(L, btn, UIButton::NORMAL_ANIM_, "normalAnim"); SetAnim(L, btn, UIButton::HOVERED_ANIM_, "hoveredAnim"); SetAnim(L, btn, UIButton::PRESSED_ANIM_, "pressedAnim"); SetAnim(L, btn, UIButton::DISABLED_ANIM_, "disabledAnim"); SetTextUserData(L, btn); SetPressedSoundKey(L, btn); AddWidget(L, btn); SetAlpha(L, btn); lua_pushlightuserdata(L, btn); return 1; }
TrayIcon::TrayIcon(HWND hwnd, UINT id, HICON icon, bool isBalooned, TCHAR *toolTip, TCHAR *toolTipTitle) { this->hwnd = hwnd; oldIconData = Shell32Version < MAKEDLLVERULL(5, 0, 0, 0); if (Shell32Version >= MAKEDLLVERULL(6, 0, 0, 0)) { iconDataSize = sizeof(NOTIFYICONDATA); this->isBalooned = isBalooned; } else if (Shell32Version >= MAKEDLLVERULL(5, 0, 0, 0)) { iconDataSize = NOTIFYICONDATA_V2_SIZE; this->isBalooned = isBalooned; } else { iconDataSize = NOTIFYICONDATA_V1_SIZE; this->isBalooned = false; } ZeroMemory(&nid, iconDataSize); nid.cbSize = iconDataSize; nid.uID = id; nid.hWnd = hwnd; nid.hIcon = icon; nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; if (this->isBalooned) { nid.uFlags |= NIF_INFO; _tcsncpy(nid.szInfoTitle, toolTipTitle, 63); nid.szInfoTitle[64] = NULL; } nid.uCallbackMessage = WM_TRAYICON; visible = false; SetTooltip(toolTip); }
int Label(lua_State* L) { UILabel* label = new UILabel; SetName(L, label); SetTopLeftWidthHeight(L, label); SetTooltip(L, label); SetTextUserData(L, label); SetPressedSoundKey(L, label); if (util::HasField(L, "hoveredStyle")) { int style = util::GetField_Number(L, "hoveredStyle"); label->SetHoveredStyle(style); } if (util::HasField(L, "stringKey")) { std::string stringKey = util::GetField_String(L, "stringKey"); if (!stringKey.empty()) label->SetString(StringManager::GetInstance().GetString(stringKey)); } if (util::HasField(L, "color")) { String& str = label->GetString(); Color& color = const_cast<Color&>(str.GetColor()); lua_getfield(L, -1, "color"); SetColor(L, color); lua_pop(L, 1); } SetAlpha(L, label); lua_pushlightuserdata(L, label); return 1; }
// 设置单元格的Tooltip void CDuiGridCtrl::SetGridTooltip(int nRow, int nItem, CString strTooltip) { if((nRow < 0) || (nRow >= (int)m_vecRowInfo.size())) { return; } if((m_nTipRow != nRow) || (m_nTipItem != nItem) || (m_nTipVirtualTop != m_nVirtualTop)) { GridItemInfo* pGridInfo = GetItemInfo(nRow, nItem); if(pGridInfo && (pGridInfo->bNeedTitleTip || pGridInfo->bNeedContentTip)) { CRect rc = pGridInfo->rcItem; rc.OffsetRect(m_rc.left, m_rc.top-m_nVirtualTop+m_nHeaderHeight); SetTooltip(this, strTooltip, rc, TRUE); }else { ClearTooltip(); } m_nTipRow = nRow; m_nTipItem = nItem; m_nTipVirtualTop = m_nVirtualTop; } }
static LRESULT CALLBACK RichEditSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { RichEditData* rdt = g_RichEditList.find((RichEditData*)&hwnd); if (rdt == NULL) return 0; CHARRANGE sel; switch(uMsg) { case WM_COPY: case WM_CUT: SmileyToTextCutPrep(rdt); break; case WM_PAINT: SetPosition(hwnd); break; case EM_STREAMOUT: if (wParam & SFF_SELECTION) SmileyToTextCutPrep(rdt); else { sel = allsel; ReplaceContactSmileysWithText(rdt, sel, true); } break; case WM_KEYDOWN: if ((wParam == 'C' || wParam == VK_INSERT) && (GetKeyState(VK_CONTROL) & 0x8000)) SmileyToTextCutPrep(rdt); else if ((wParam == 'X' && (GetKeyState(VK_CONTROL) & 0x8000)) || (wParam == VK_DELETE && (GetKeyState(VK_SHIFT) & 0x8000))) SmileyToTextCutPrep(rdt); else if (wParam == VK_TAB && ((GetKeyState(VK_CONTROL) | GetKeyState(VK_SHIFT)) & 0x8000) == 0) { SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel); sel.cpMin = max(sel.cpMin - 20, 0); ReplaceContactSmileysWithText(rdt, sel, true); } break; } LRESULT result = mir_callNextSubclass(hwnd, RichEditSubclass, uMsg, wParam, lParam); switch(uMsg) { case WM_MOUSEMOVE: SetTooltip(LOWORD(lParam), HIWORD(lParam), hwnd, rdt); break; case WM_PAINT: case WM_HSCROLL: case WM_VSCROLL: SetPosition(hwnd); break; case WM_COPY: case WM_CUT: SmileyToTextCutRest(rdt); break; case EM_STREAMOUT: if (wParam & SFF_SELECTION) SmileyToTextCutRest(rdt); else ReplaceContactSmileys(rdt, allsel, false, true); break; case WM_KEYDOWN: if ((wParam == 'C' || wParam == VK_INSERT) && (GetKeyState(VK_CONTROL) & 0x8000)) SmileyToTextCutRest(rdt); else if ((wParam == 'X' && (GetKeyState(VK_CONTROL) & 0x8000)) || (wParam == VK_DELETE && (GetKeyState(VK_SHIFT) & 0x8000))) SmileyToTextCutRest(rdt); else if (wParam == VK_TAB && ((GetKeyState(VK_CONTROL) | GetKeyState(VK_SHIFT)) & 0x8000) == 0) { sel.cpMax = LONG_MAX; bool hascont = rdt->hContact != NULL; ReplaceContactSmileys(rdt, sel, false, hascont); } break; case WM_CHAR: if (!rdt->inputarea || (rdt->inputarea && !opt.InputSmileys)) break; if (lParam & (1 << 28)) // ALT key break; if ((lParam & 0xFF) > 2) // Repeat rate break; if (wParam > ' ' && opt.EnforceSpaces) break; if (wParam == 0x16) { ReplaceContactSmileys(rdt, allsel, false, false); break; } if (opt.DCursorSmiley) ReplaceContactSmileys(rdt, allsel, true, true); else if (wParam >= ' ' || wParam == '\n' || wParam == '\r') { SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel); sel.cpMin = max(sel.cpMin - 20, 0); sel.cpMax += 20; ReplaceContactSmileysWithText(rdt, sel, true); ReplaceContactSmileys(rdt, sel, false, true); } break; case EM_PASTESPECIAL: case WM_PASTE: case EM_REPLACESEL: case WM_SETTEXT: case EM_SETTEXTEX: if (rdt->inputarea) ReplaceContactSmileys(rdt, allsel, false, false); break; case WM_REMAKERICH: ReplaceContactSmileys(rdt, allsel, false, false); break; } return result; }
// 鼠标移动事件处理 BOOL CControlBase::OnMouseMove(UINT nFlags, CPoint point) { if(!m_bIsVisible || !m_bRresponse) return false; // 保存原始的鼠标位置,并进行位置变换 CPoint oldPoint = point; OnMousePointChange(point); BOOL bRresponse = false; if(m_pControl) { CPoint pt = point; // 如果是控件内置滚动条子控件,则不进行位置变换,因为滚动条位置是不需要变换的 UINT uControlID = m_pControl->GetControlID(); if((SCROLL_V == uControlID) || (SCROLL_H == uControlID)) { pt = oldPoint; } if((m_pControl->PtInRect(pt) && m_pControl->OnCheckMouseResponse(nFlags, pt)) || m_bMouseDown) { if(m_pControl->OnMouseMove(nFlags, pt)) { return true; } return false; } } CControlBase * pOldControl = m_pControl; m_pControl = NULL; if(!m_strTooltip.IsEmpty() && PtInRect(point) && OnCheckMouseResponse(nFlags, point)) { // 如果当前控件有Tooltip,并且当前Tooltip设置的是其他控件,则设置Tooltip if(GetTooltipCtrlID() != GetID()) { SetTooltip(this, m_strTooltip, m_rc, FALSE, m_nTipWidth); SetTooltipCtrlID(GetID()); } } // 调用控件的设置鼠标光标函数 OnControlSetCursor(nFlags, point); // 调用控件的鼠标移动函数 bRresponse = OnControlMouseMove(nFlags, point); // 发送鼠标移动的DUI消息 if(m_bDuiMsgMouseMove) { if(PtInRect(point)) { // 发送鼠标在控件范围内移动的消息 SendMessage(MSG_MOUSE_MOVE, (WPARAM)nFlags, (LPARAM)(&point)); m_bMouseLeave = FALSE; }else { if(!m_bMouseLeave) { // 发送鼠标离开控件的消息(离开之后仅发送一次离开消息) SendMessage(MSG_MOUSE_LEAVE, (WPARAM)nFlags, (LPARAM)(&point)); m_bMouseLeave = TRUE; } } } if(!m_bMouseDown) { for (size_t i = 0; i < m_vecControl.size(); i++) { CControlBase * pControlBase = m_vecControl.at(i); if (pControlBase) { CPoint pt = point; // 如果是控件内置滚动条子控件,则不进行位置变换,因为滚动条位置是不需要变换的 UINT uControlID = pControlBase->GetControlID(); if((SCROLL_V == uControlID) || (SCROLL_H == uControlID)) { pt = oldPoint; } if(pControlBase->OnMouseMove(nFlags, pt)) { if(pControlBase->PtInRect(pt)) { m_pControl = pControlBase; } bRresponse = true; } } } if (pOldControl) { bRresponse = true; } if (m_pControl) { bRresponse = true; } } return bRresponse; }
static bool ContinuousActionInit (bool init, int cmd, BR_ContinuousAction* action) { static accelerator_register_t s_accelerator = { ContinuousActionTranslateAccel, TRUE, NULL }; bool initSuccessful = true; if (init) { GetConfig("tooltips", g_tooltips); g_actionInProgress = action; if (g_actionInProgress) { if (g_actionInProgress->Init) initSuccessful = g_actionInProgress->Init(true); } else initSuccessful = false; if (initSuccessful) { if (g_actionInProgress->SetMouseCursor || g_actionInProgress->SetTooltip) { SetConfig("tooltips", SetBit(SetBit(SetBit(g_tooltips, 0), 1), 2)); if (!g_arrangeWndProc && GetArrangeWnd()) { if (g_actionInProgress->SetTooltip) { WDL_FastString tooltip = g_actionInProgress->SetTooltip(BR_ContinuousAction::ARRANGE); if (tooltip.GetLength()) { POINT p; GetCursorPos(&p); SetTooltip(tooltip.Get(), &p); } } g_arrangeWndProc = (WNDPROC)SetWindowLongPtr(GetArrangeWnd(), GWLP_WNDPROC, (LONG_PTR)ArrangeWndProc); if (g_actionInProgress->SetMouseCursor && g_actionInProgress->SetMouseCursor(BR_ContinuousAction::ARRANGE)) SendMessage(GetArrangeWnd(), WM_SETCURSOR, (WPARAM)GetArrangeWnd(), 0); InvalidateRect(GetArrangeWnd(), NULL, TRUE); // kill existing native tooltip, if any } if (!g_rulerWndProc && GetRulerWndAlt()) { if (g_actionInProgress->SetTooltip) { WDL_FastString tooltip = g_actionInProgress->SetTooltip(BR_ContinuousAction::RULER); if (tooltip.GetLength()) { POINT p; GetCursorPos(&p); SetTooltip(tooltip.Get(), &p); } } g_rulerWndProc = (WNDPROC)SetWindowLongPtr(GetRulerWndAlt(), GWLP_WNDPROC, (LONG_PTR)RulerWndProc); if (g_actionInProgress->SetMouseCursor && g_actionInProgress->SetMouseCursor(BR_ContinuousAction::RULER)) SendMessage(GetRulerWndAlt(), WM_SETCURSOR, (WPARAM)GetRulerWndAlt(), 0); InvalidateRect(GetRulerWndAlt(), NULL, TRUE); } } plugin_register("accelerator", &s_accelerator); plugin_register("timer", (void*)ContinuousActionTimer); } else { g_actionInProgress = NULL; } } else { SetConfig("tooltips", g_tooltips); if (g_arrangeWndProc && GetArrangeWnd()) { SetWindowLongPtr(GetArrangeWnd(), GWLP_WNDPROC, (LONG_PTR)g_arrangeWndProc); SendMessage(GetArrangeWnd(), WM_SETCURSOR, (WPARAM)GetArrangeWnd(), 0); InvalidateRect(GetArrangeWnd(), NULL, FALSE); g_arrangeWndProc = NULL; } if (g_rulerWndProc && GetRulerWndAlt()) { SetWindowLongPtr(GetRulerWndAlt(), GWLP_WNDPROC, (LONG_PTR)g_rulerWndProc); SendMessage(GetRulerWndAlt(), WM_SETCURSOR, (WPARAM)GetRulerWndAlt(), 0); InvalidateRect(GetRulerWndAlt(), NULL, FALSE); g_rulerWndProc = NULL; } SetTooltip(NULL, NULL); plugin_register("-accelerator", &s_accelerator); plugin_register("-timer", (void*)ContinuousActionTimer); if (g_actionInProgress->Init) g_actionInProgress->Init(false); g_actionInProgress = NULL; } return initSuccessful; }