void wxExStatusBar::Handle(wxMouseEvent& event, const wxExStatusBarPane& pane) { if (event.LeftUp()) { m_Frame->StatusBarClicked(pane.GetName()); } else if (event.RightUp()) { m_Frame->StatusBarClickedRight(pane.GetName()); } // Show tooltip if tooltip is available, and not yet presented. else if (event.Moving()) { #if wxUSE_TOOLTIPS const wxString tooltip = GetToolTipText(); if (pane.GetHelpText().empty()) { if (!tooltip.empty()) { UnsetToolTip(); } } else if (tooltip != pane.GetHelpText()) { SetToolTip(pane.GetHelpText()); } #endif } }
// // Handle mouse enter events // void Grabber::OnEnter(wxMouseEvent & WXUNUSED(event)) { // Bug 1201: On Mac, unsetting and re-setting the tooltip may be needed // to make it pop up when we want it. const auto text = GetToolTipText(); UnsetToolTip(); SetToolTip(text); if( mAsSpacer ) return; // Redraw highlighted mOver = true; Refresh(false); }
void AButton::OnMouseEvent(wxMouseEvent & event) { wxSize clientSize = GetClientSize(); AButtonState prevState = GetState(); if (event.Entering()) { // Bug 1201: On Mac, unsetting and re-setting the tooltip may be needed // to make it pop up when we want it. auto text = GetToolTipText(); UnsetToolTip(); SetToolTip(text); mCursorIsInWindow = true; } else if (event.Leaving()) mCursorIsInWindow = false; else mCursorIsInWindow = (event.m_x >= 0 && event.m_y >= 0 && event.m_x < clientSize.x && event.m_y < clientSize.y); if (mEnabled && event.IsButton()) { if (event.ButtonIsDown(wxMOUSE_BTN_ANY)) { mIsClicking = true; if (event.ButtonDClick()) mIsDoubleClicked = true; if( !HasCapture() ) CaptureMouse(); } else if (mIsClicking) { mIsClicking = false; if (HasCapture()) ReleaseMouse(); if (mCursorIsInWindow && (mToggle || !mButtonIsDown)) { if (mToggle) mButtonIsDown = !mButtonIsDown; else mButtonIsDown = true; mWasShiftDown = event.ShiftDown(); mWasControlDown = event.ControlDown(); Click(); } } } // Only redraw and change tooltips if the state has changed. AButtonState newState = GetState(); if (newState != prevState) { Refresh(false); if (mCursorIsInWindow) UpdateStatus(); else { GetActiveProject()->TP_DisplayStatusMessage(wxT("")); } } else event.Skip(); }
void wxRibbonButtonBar::OnMouseMove(wxMouseEvent& evt) { wxPoint cursor(evt.GetPosition()); wxRibbonButtonBarButtonInstance* new_hovered = NULL; wxRibbonButtonBarButtonInstance* tooltipButton = NULL; long new_hovered_state = 0; wxRibbonButtonBarLayout* layout = m_layouts.Item(m_current_layout); size_t btn_count = layout->buttons.Count(); size_t btn_i; for(btn_i = 0; btn_i < btn_count; ++btn_i) { wxRibbonButtonBarButtonInstance& instance = layout->buttons.Item(btn_i); wxRibbonButtonBarButtonSizeInfo& size = instance.base->sizes[instance.size]; wxRect btn_rect; btn_rect.SetTopLeft(m_layout_offset + instance.position); btn_rect.SetSize(size.size); if(btn_rect.Contains(cursor)) { if((instance.base->state & wxRIBBON_BUTTONBAR_BUTTON_DISABLED) == 0) { tooltipButton = &instance; new_hovered = &instance; new_hovered_state = instance.base->state; new_hovered_state &= ~wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK; wxPoint offset(cursor); offset -= btn_rect.GetTopLeft(); if(size.normal_region.Contains(offset)) { new_hovered_state |= wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED; } if(size.dropdown_region.Contains(offset)) { new_hovered_state |= wxRIBBON_BUTTONBAR_BUTTON_DROPDOWN_HOVERED; } break; } else if (m_show_tooltips_for_disabled) { tooltipButton = &instance; } } } #if wxUSE_TOOLTIPS if(tooltipButton == NULL && GetToolTip()) { UnsetToolTip(); } if(tooltipButton) { SetToolTip(tooltipButton->base->help_string); } #endif if(new_hovered != m_hovered_button || (m_hovered_button != NULL && new_hovered_state != m_hovered_button->base->state)) { if(m_hovered_button != NULL) { m_hovered_button->base->state &= ~wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK; } m_hovered_button = new_hovered; if(m_hovered_button != NULL) { m_hovered_button->base->state = new_hovered_state; } Refresh(false); } if(m_active_button && !m_lock_active_state) { long new_active_state = m_active_button->base->state; new_active_state &= ~wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK; wxRibbonButtonBarButtonSizeInfo& size = m_active_button->base->sizes[m_active_button->size]; wxRect btn_rect; btn_rect.SetTopLeft(m_layout_offset + m_active_button->position); btn_rect.SetSize(size.size); if(btn_rect.Contains(cursor)) { wxPoint offset(cursor); offset -= btn_rect.GetTopLeft(); if(size.normal_region.Contains(offset)) { new_active_state |= wxRIBBON_BUTTONBAR_BUTTON_NORMAL_ACTIVE; } if(size.dropdown_region.Contains(offset)) { new_active_state |= wxRIBBON_BUTTONBAR_BUTTON_DROPDOWN_ACTIVE; } } if(new_active_state != m_active_button->base->state) { m_active_button->base->state = new_active_state; Refresh(false); } } }
void wxRibbonToolBar::OnMouseMove(wxMouseEvent& evt) { wxPoint pos(evt.GetPosition()); wxRibbonToolBarToolBase *new_hover = NULL; size_t group_count = m_groups.GetCount(); size_t g, t; for(g = 0; g < group_count; ++g) { wxRibbonToolBarToolGroup* group = m_groups.Item(g); if(group->position.x <= pos.x && pos.x < group->position.x + group->size.x && group->position.y <= pos.y && pos.y < group->position.y + group->size.y) { size_t tool_count = group->tools.GetCount(); pos -= group->position; for(t = 0; t < tool_count; ++t) { wxRibbonToolBarToolBase* tool = group->tools.Item(t); if(tool->position.x <= pos.x && pos.x < tool->position.x + tool->size.x && tool->position.y <= pos.y && pos.y < tool->position.y + tool->size.y) { pos -= tool->position; new_hover = tool; break; } } break; } } #if wxUSE_TOOLTIPS if(new_hover) { SetToolTip(new_hover->help_string); } else if(GetToolTip()) { UnsetToolTip(); } #endif if(new_hover && new_hover->state & wxRIBBON_TOOLBAR_TOOL_DISABLED) { new_hover = NULL; // A disabled tool can not be hilighted } if(new_hover != m_hover_tool) { if(m_hover_tool) { m_hover_tool->state &= ~(wxRIBBON_TOOLBAR_TOOL_HOVER_MASK | wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK); } m_hover_tool = new_hover; if(new_hover) { long what = wxRIBBON_TOOLBAR_TOOL_NORMAL_HOVERED; if(new_hover->dropdown.Contains(pos)) what = wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED; new_hover->state |= what; if(new_hover == m_active_tool) { new_hover->state &= ~wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK; new_hover->state |= (what << 2); } } Refresh(false); } else if(m_hover_tool && m_hover_tool->kind == wxRIBBON_BUTTON_HYBRID) { long newstate = m_hover_tool->state &~wxRIBBON_TOOLBAR_TOOL_HOVER_MASK; long what = wxRIBBON_TOOLBAR_TOOL_NORMAL_HOVERED; if(m_hover_tool->dropdown.Contains(pos)) what = wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED; newstate |= what; if(newstate != m_hover_tool->state) { m_hover_tool->state = newstate; if(m_hover_tool == m_active_tool) { m_hover_tool->state &= ~wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK; m_hover_tool->state |= (what << 2); } Refresh(false); } } }
void BuildGraph::OnMouseEvent(wxMouseEvent &event) { //SetToolTip("My tips"); if (event.ButtonDown()) SetFocus(); if (event.GetPosition().x>=StartPixelsWidth-12/*-GetScrollPos(wxHORIZONTAL)*/ && event.GetPosition().x<=StartPixelsWidth-8/*-GetScrollPos(wxHORIZONTAL)*/) { SetCursor(wxCURSOR_SIZEWE); if (event.ButtonDown(wxMOUSE_BTN_LEFT)) DragBorder=true; }else{ SetCursor(NULL); } //ToolTip EventsAccess.Wait(); int posX=event.GetPosition().x; int posY=event.GetPosition().y; bool OverEvent=false; for (unsigned int i=0;i<Events.Count();i++) { if (Events[i] && Events[i]->StartTime<Events[i]->FinishTime) { float sec = (float)(Events[i]->StartTime-StartTime)/1000.0; float BlockWidth = (Events[i]->FinishTime-Events[i]->StartTime)*TimeRatio/1000.0 - 1; float x=StartPixelsWidth+TimeRatio*sec+1; float y=StartPixelsHeight+AgentsSpace+(AgentsSpace+BlockHeight)*Events[i]->AgentId; if (posX>=x && posY>=y && posX<=x+BlockWidth && posY<=y+BlockHeight) { SetToolTip(Events[i]->Name); OverEvent=true; break; } } } if (OverEvent==false) { UnsetToolTip(); } EventsAccess.Post(); if (DragBorder==false) { if (event.GetWheelRotation()!=0) // Zoom { int sign=(abs(event.GetWheelRotation())/event.GetWheelRotation()); //TimeRatio+=sign*TimeRatio/10; TimeRatioTarget=TimeRatioTarget+sign*TimeRatio/10; if (TimeRatioTarget<0.001) TimeRatioTarget=0.001f; Timer.Start(RefreshTime); Refresh(); } }else{ if (event.ButtonUp(wxMOUSE_BTN_LEFT)) DragBorder=false; else{ StartPixelsWidth=event.GetPosition().x+10/*+GetScrollPos(wxHORIZONTAL)*/; if (StartPixelsWidth<70) StartPixelsWidth=70; Refresh(); } } }
void GLCanvas::OnMouseMove(wxMouseEvent &event) { wxSize size = GetSize(); wxPoint pos = event.GetPosition(); if (pos.x > size.x - _buttonSize && pos.y < _numButtons * _buttonSize) { wxString tooltip; int index = pos.y / _buttonSize; switch (index) { case 0: tooltip = _("Show grid"); break; case 1: tooltip = _("Show bounding box"); break; case 2: tooltip = _("Show coordinate system"); break; case 3: tooltip = _("Show joint constraints"); break; case 4: tooltip = _("Show rotation axis"); break; case 5: tooltip = _("Show label"); break; case 6: tooltip = _("Move to skeleton"); break; case 7: tooltip = _("Settings"); break; default: tooltip = _(""); break; } wxToolTip* prevToolTip = GetToolTip(); if (prevToolTip == nullptr || prevToolTip->GetTip() != tooltip) { SetToolTip(tooltip); } } else if (GetToolTip() != nullptr) { UnsetToolTip(); } if (_style & SINGLE_SENSOR_MODE) { return; } // get the delta of the mouse movement wxPoint delta = pos - _prevMousePos; _prevMousePos = pos; if (_rClicked) { _xRotation -= 0.1f * M_PI/180.0f * float(delta.y); if (_xRotation > M_PI/2.0) { _xRotation = M_PI/2.0; } else if (_xRotation < -M_PI/2.0) { _xRotation = -M_PI/2.0; } _yRotation -= 0.1f * M_PI/180.0f * float(delta.x); _cameraFront = Vector3(cos(_xRotation) * sin(_yRotation), sin(_xRotation), cos(_xRotation) * cos(_yRotation)).normalized(); _cameraUp = Vector3(sin(_yRotation - M_PI/2.0f), 0.0f, cos(_yRotation - M_PI/2.0f)).cross(_cameraFront).normalized(); _cameraRight = _cameraFront.cross(_cameraUp).normalized(); //_prevMousePos = event.GetPosition(); // wxPoint cursorPos = ClientToScreen(_prevMousePos); // WarpPointer(_prevMousePos.x, _prevMousePos.y); // SetCursorPos(cursorPos.x, cursorPos.y); Refresh(); } if (_lClicked) { _cameraPosition -= _cameraSpeed * float(delta.x) * _cameraRight; _cameraPosition += _cameraSpeed * float(delta.y) * _cameraUp; //_cameraPosition.y() += _cameraSpeed * float(delta.y); // _prevMousePos = event.GetPosition(); // warp pointer causes glcanvas to freeze (under linux). Consider not hiding the cursor // WarpPointer(_prevMousePos.x, _prevMousePos.y); Refresh(); } }