当前位置: 首页>>代码示例>>C++>>正文


C++ wxMouseEvent::ButtonDown方法代码示例

本文整理汇总了C++中wxMouseEvent::ButtonDown方法的典型用法代码示例。如果您正苦于以下问题:C++ wxMouseEvent::ButtonDown方法的具体用法?C++ wxMouseEvent::ButtonDown怎么用?C++ wxMouseEvent::ButtonDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wxMouseEvent的用法示例。


在下文中一共展示了wxMouseEvent::ButtonDown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnMouseEvent

void TrackPanel::OnMouseEvent(wxMouseEvent& event)
{
  if (event.m_x < view->labelWidth) {
	//	Group panel stuff

	if (event.ButtonDClick())
	  view->DClickLabel(event);  
	else if (event.ButtonDown())
	  view->ClickLabel(event);
	else if (event.ButtonUp())
	  SetCursor(*mainCursor);
  }
  else {
	if (event.ButtonDown()) {
	  CaptureMouse();
	  if (event.ControlDown())
		SetCursor(*dragCursor);
	  view->ClickTrack(event);
	}
	else if (event.Dragging())
	  view->DragTrack(event);
	else if (event.ButtonUp()) {
	  ReleaseMouse();
	  SetCursor(*mainCursor);
	  view->ButtonUpTrack();
	}
	else if (event.Moving()) {
	  view->TrackSetCursor(event);
	}
  }
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:31,代码来源:AudioView.cpp

示例2: OnMouse

void Canvas::OnMouse(wxMouseEvent& evt)
{
	// Capture on button-down, so we can respond even when the mouse
	// moves off the window
	if (!m_MouseCaptured && evt.ButtonDown())
	{
		m_MouseCaptured = true;
		CaptureMouse();
	}
	// Un-capture when all buttons are up
	else if (m_MouseCaptured && evt.ButtonUp() &&
		! (evt.ButtonIsDown(wxMOUSE_BTN_LEFT) || evt.ButtonIsDown(wxMOUSE_BTN_MIDDLE) || evt.ButtonIsDown(wxMOUSE_BTN_RIGHT))
		)
	{
		m_MouseCaptured = false;
		ReleaseMouse();
	}

	// Set focus when clicking
	if (evt.ButtonDown())
		SetFocus();

	// Reject motion events if the mouse has not actually moved
	if (evt.Moving() || evt.Dragging())
	{
		if (m_LastMousePos == evt.GetPosition())
			return;
		m_LastMousePos = evt.GetPosition();
	}

	HandleMouseEvent(evt);
}
开发者ID:Gallaecio,项目名称:0ad,代码行数:32,代码来源:Canvas.cpp

示例3: OnMouse

void CFCEditorGLWindow::OnMouse(wxMouseEvent& event)
{
    if(event.ButtonDown(wxMOUSE_BTN_RIGHT))
    {
        if (!HasCapture())
        {
            CaptureMouse();
        }
        HideCursor();
        SetFocus();//Call this for catch the EVT_MOUSEWHEEL event, in left mouse button down event is not necessary to call this
        m_startPosition = event.GetPosition();
        m_bRightDown = true;
    }
    else if(event.ButtonUp(wxMOUSE_BTN_RIGHT))
    {
        if (!m_bLeftDown && HasCapture())
        {
            ReleaseMouse();
        }
        ShowCursor();
        m_bRightDown = false;
    }
    else if(event.ButtonDown(wxMOUSE_BTN_LEFT))
    {
        if (!HasCapture())
        {
            CaptureMouse();
        }
        HideCursor();
        m_startPosition = event.GetPosition();
        m_bLeftDown = true;
    }
    else if(event.ButtonUp(wxMOUSE_BTN_LEFT))
    {
        if (!m_bRightDown && HasCapture())
        {
            ReleaseMouse();
        }
        ShowCursor();
        m_bLeftDown = false;
    }
    else if(event.Dragging())
    {
        if (m_bRightDown || m_bLeftDown)
        {
            wxPoint curPos = event.GetPosition();
            wxPoint pnt = ClientToScreen(m_startPosition);
            SetCursorPos(pnt.x, pnt.y);
            if (m_bRightDown)
            {
                int nDeltaX = curPos.x - m_startPosition.x;
                int nDeltaY = curPos.y - m_startPosition.y;
                wxSize clientSize = GetClientSize();
                m_pCamera->Yaw((float)nDeltaX / clientSize.x);
                m_pCamera->Pitch((float)nDeltaY / clientSize.y);
            }
        }
    }
    event.Skip();
}
开发者ID:nobitalwm,项目名称:FCEngine,代码行数:60,代码来源:FCEditorGLWindow.cpp

示例4: mouseEvent

void VIICanvas::mouseEvent(wxMouseEvent& event)
{
	if(event.ButtonDown(wxMOUSE_BTN_LEFT))
	{
		mLeftClicked = true;
		mStartPoint = event.GetPosition();
	}
	if(event.ButtonUp(wxMOUSE_BTN_LEFT))
	{
		mLeftClicked = false;
	}
	if(event.ButtonDown(wxMOUSE_BTN_RIGHT))
	{
		mRightClicked = true;
		mStartPoint = event.GetPosition();
	}
	if(event.ButtonUp(wxMOUSE_BTN_RIGHT))
	{
		mRightClicked = false;
	}

	if(event.Dragging())
	{
		if(mLeftClicked)
		{
			wxPoint delta = event.GetPosition() - mStartPoint;
			mAngleY += delta.x;
			mAngleX += delta.y;
			
			if(mAngleX < 0)
			{
				mAngleX = 360 + mAngleX;
			}
			
			if(mAngleY < 0)
			{
				mAngleY = 360 + mAngleY;
			}
			
			mAngleX %= 360;
			mAngleY %= 360;
			
			
			//std::cout << "AngleX: " << mAngleX << " angleY: " << mAngleY << std::endl;
			mStartPoint = event.GetPosition();
			Refresh();
		}
		else if(mRightClicked)
		{
			wxPoint delta = event.GetPosition() - mStartPoint;
			mDistanceOrigin += delta.y;
			//std::cout << "Distance: "<< mDistanceOrigin <<std::endl;
			mStartPoint = event.GetPosition();
			Refresh();
		}
	}
	
}
开发者ID:GFHund,项目名称:LII,代码行数:58,代码来源:VIICanvas.cpp

示例5: OnMouseEvent

// Internal functions
void wxGenericColourDialog::OnMouseEvent(wxMouseEvent& event)
{
  if (event.ButtonDown(wxMOUSE_BTN_LEFT))
  {
    int x = (int)event.GetX();
    int y = (int)event.GetY();

    if ((x >= m_standardColoursRect.x && x <= (m_standardColoursRect.x + m_standardColoursRect.width)) &&
        (y >= m_standardColoursRect.y && y <= (m_standardColoursRect.y + m_standardColoursRect.height)))
    {
      int selX = (int)(x - m_standardColoursRect.x)/(m_smallRectangleSize.x + m_gridSpacing);
      int selY = (int)(y - m_standardColoursRect.y)/(m_smallRectangleSize.y + m_gridSpacing);
      int ptr = (int)(selX + selY*8);
      OnBasicColourClick(ptr);
    }
    // wxStaticBitmap (used to ARGB preview) events are handled in the dedicated handler.
#if !wxCLRDLGG_USE_PREVIEW_WITH_ALPHA
    else if ((x >= m_customColoursRect.x && x <= (m_customColoursRect.x + m_customColoursRect.width)) &&
        (y >= m_customColoursRect.y && y <= (m_customColoursRect.y + m_customColoursRect.height)))
    {
      int selX = (int)(x - m_customColoursRect.x)/(m_smallRectangleSize.x + m_gridSpacing);
      int selY = (int)(y - m_customColoursRect.y)/(m_smallRectangleSize.y + m_gridSpacing);
      int ptr = (int)(selX + selY*8);
      OnCustomColourClick(ptr);
    }
#endif
    else
        event.Skip();
  }
  else
      event.Skip();
}
开发者ID:Teodorrrro,项目名称:wxWidgets,代码行数:33,代码来源:colrdlgg.cpp

示例6: OnMouseEvent

// Internal functions
void wxGenericColourDialog::OnMouseEvent(wxMouseEvent& event)
{
  if (event.ButtonDown(1))
  {
    int x = (int)event.GetX();
    int y = (int)event.GetY();

    if ((x >= m_standardColoursRect.x && x <= (m_standardColoursRect.x + m_standardColoursRect.width)) &&
        (y >= m_standardColoursRect.y && y <= (m_standardColoursRect.y + m_standardColoursRect.height)))
    {
      int selX = (int)(x - m_standardColoursRect.x)/(m_smallRectangleSize.x + m_gridSpacing);
      int selY = (int)(y - m_standardColoursRect.y)/(m_smallRectangleSize.y + m_gridSpacing);
      int ptr = (int)(selX + selY*8);
      OnBasicColourClick(ptr);
    }
    else if ((x >= m_customColoursRect.x && x <= (m_customColoursRect.x + m_customColoursRect.width)) &&
        (y >= m_customColoursRect.y && y <= (m_customColoursRect.y + m_customColoursRect.height)))
    {
      int selX = (int)(x - m_customColoursRect.x)/(m_smallRectangleSize.x + m_gridSpacing);
      int selY = (int)(y - m_customColoursRect.y)/(m_smallRectangleSize.y + m_gridSpacing);
      int ptr = (int)(selX + selY*8);
      OnCustomColourClick(ptr);
    }
    else
        event.Skip();
  }
  else
      event.Skip();
}
开发者ID:Asmodean-,项目名称:Ishiiruka,代码行数:30,代码来源:colrdlgg.cpp

示例7: OnMouse

void TestGLCanvas::OnMouse( wxMouseEvent& event )
{
    
    static bool useLightTrack=false;

    if ( event.m_rightDown || event.m_leftDown || event.m_middleDown ) {
      if (!HasCapture()) CaptureMouse();
    }
    else if (HasCapture()) ReleaseMouse();
    
    useLightTrack=event.m_rightDown;

    bool consumed=false;
    if (useLightTrack) {
      MovingLightMode=true;
      if (wxConsumeTrackBallEvent( event, lightTrack)) {
        SetFocus();
        consumed=true;
      }
    } else {
      MovingLightMode=false;
      if (wxConsumeTrackBallEvent( event, track)) {
        SetFocus();
        consumed=true;
      }
    }
    
    if ((consumed) && (!event.ButtonUp()) && (!event.ButtonDown())) SceneChanged();
    
/*   if ( event.m_rightUp ) {
      useLightTrack=false;
    }*/

}
开发者ID:zulman,项目名称:qutemol,代码行数:34,代码来源:main.cpp

示例8: OnMouse

void wxsItemEditorContent::OnMouse(wxMouseEvent& event)
{
    // Anti-recursion lock
    static bool IsRunning = false;
    if ( IsRunning ) return;
    IsRunning = true;

    if ( event.ButtonDown() )
    {
        SetFocus();
    }
    else if ( m_MouseState == msWaitForIdle )
    {
        m_MouseState = msIdle;
    }

    int NewX = event.m_x;
    int NewY = event.m_y;
    CalcUnscrolledPosition(NewX,NewY,&NewX,&NewY);
    event.m_x = NewX;
    event.m_y = NewY;
    switch ( m_MouseState )
    {
        case msDraggingPointInit: OnMouseDraggingPointInit (event); break;
        case msDraggingPoint:     OnMouseDraggingPoint     (event); break;
        case msDraggingItemInit:  OnMouseDraggingItemInit  (event); break;
        case msDraggingItem:      OnMouseDraggingItem      (event); break;
        case msTargetSearch:      OnMouseTargetSearch      (event); break;
        case msWaitForIdle:                                         break;
        default:                  OnMouseIdle              (event); break;
    }

    IsRunning = false;
}
开发者ID:simple-codeblocks,项目名称:Codeblocks,代码行数:34,代码来源:wxsitemeditorcontent.cpp

示例9: OnMouse

void ToolBarGrabber::OnMouse(wxMouseEvent &event)
{
   int prevState = mState;

   // Handle hilighting the image if the mouse is over it

   if (event.Entering())
      mState = 1;
   else if (event.Leaving())
      mState = 0;
   else {
      wxSize clientSize = GetClientSize();

      if (event.m_x >= 0 && event.m_y >= 0 &&
          event.m_x < clientSize.x && event.m_y < clientSize.y)
         mState = 1;
      else
         mState = 0;
   }

   if (event.ButtonDown())
      mOwnerToolBar->StartMoving();

   if (mState != prevState)
      Refresh(false);
}
开发者ID:disinteger1,项目名称:audacity,代码行数:26,代码来源:ExpandingToolBar.cpp

示例10: OnMouseUpOrDown

void MiniStyledTextCtrl::OnMouseUpOrDown(wxMouseEvent& event)
{
    if( event.ButtonDown(wxMOUSE_BTN_LEFT) )
    {
        SetFocus();
        int line = GetLineFromPosition(event.GetPosition());
        MiniStyledTextCtrlLineClickedEvent evt(MiniStyledTextCtrlCommandEvent, GetId());
        evt.SetLine(line);
        wxPostEvent(this, evt);
    }
    if ( event.ButtonDown(wxMOUSE_BTN_RIGHT) )
    {
        SetFocus();
    }
    event.Skip(false);
}
开发者ID:danselmi,项目名称:MiniDoc,代码行数:16,代码来源:MiniStyledTextCtrl.cpp

示例11: OnMouse

void wxsToolSpace::OnMouse(wxMouseEvent& event)
{
    if ( event.ButtonDown() )
    {
        SetFocus();
    }
    event.Skip();
}
开发者ID:DowerChest,项目名称:codeblocks,代码行数:8,代码来源:wxstoolspace.cpp

示例12: OnMouse

void CGradientCtrl::OnMouse(wxMouseEvent& event)
{
    ECursorType eType = eCT_Invalid;
    wxPoint pos = event.GetPosition();
    if (event.ButtonDown(wxMOUSE_BTN_LEFT))
    {
        if (m_pSelectedCursor)
        {
            m_pSelectedCursor->Select(false);
        }
        m_pSelectedCursor = GetGradientCursor(pos);
        if (m_pSelectedCursor)
        {
            eType = m_pSelectedCursor->GetType();
            if (eType == eCT_Color)
            {
                m_pColoutPicker->SetColour(m_pSelectedCursor->GetColor());
            }
            else
            {
                m_pMaskSlider->SetValue(m_pSelectedCursor->GetColor().Red());
            }
            m_pSelectedCursor->Select(true);
        }
        ShowCtrl(m_pSelectedCursor == NULL ? eCT_Invalid : m_pSelectedCursor->GetType());
        Refresh(true);
        UpdateSelectedCursorPos();
    }
    else if (event.Dragging())
    {
        if (event.LeftIsDown())
        {
            if (m_pSelectedCursor)
            {
                SetSelectedCursorPos(pos);
                UpdateSelectedCursorPos();
                float fPos = GetNearestCursorPos(m_pSelectedCursor);
                if (fPos >= 0)
                {
                    m_pSelectedCursor->SetPos(fPos);
                }
                Refresh(true);
            }
        }
    }
    else if (event.ButtonUp(wxMOUSE_BTN_LEFT))
    {
        if (m_pSelectedCursor)
        {
            if (GetNearestCursorPos(m_pSelectedCursor) > 0)
            {
                DeleteCursor(m_pSelectedCursor);
                m_pSelectedCursor = NULL;
            }
        }
    }
    
}
开发者ID:hejiero,项目名称:BeyondEngine,代码行数:58,代码来源:GradientCtrl.cpp

示例13: OnMouseEvent

void LWSlider::OnMouseEvent(wxMouseEvent & event)
{
   if (event.Entering()) {
      // Display the tooltip in the status bar
      if (mParent->GetToolTip()) {
         wxString tip = mParent->GetToolTip()->GetTip();
         GetActiveProject()->TP_DisplayStatusMessage(tip, 0);
         Refresh();
      }
   }
   else if (event.Leaving()) {
      GetActiveProject()->TP_DisplayStatusMessage("",0);
      Refresh();
   }
   
   float prevValue = mCurrentValue;

   if (event.ButtonDown()) {

      //This jumps the thumb to clicked position
      if (!mIsDragging) {
         mCurrentValue = PositionToValue(event.m_x, event.ShiftDown());

         mIsDragging = true;
         mParent->CaptureMouse();

         FormatPopWin();
         SetPopWinPosition();
         mPopWin->Show();
      }

      // Don't generate notification yet
      return;

   } else if (event.ButtonUp() && mIsDragging) {
      mIsDragging = false;
      mParent->ReleaseMouse();
      mPopWin->Hide();
      ((TipPanel *)mPopWin)->SetPos(wxPoint(-1000, -1000));
   } else if (event.Dragging() && mIsDragging) {
      mCurrentValue = PositionToValue(event.m_x, event.ShiftDown());
   }

   if (prevValue != mCurrentValue) {
      FormatPopWin();
      mPopWin->Refresh();
      Refresh();

      wxCommandEvent *e =
         new wxCommandEvent(wxEVT_COMMAND_SLIDER_UPDATED, mID);
      int intValue =
         (int)((mCurrentValue - mMinValue) * 1000.0f
         / (mMaxValue - mMinValue));
      e->SetInt( intValue );
      mParent->ProcessEvent(*e);
      delete e;
   }
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:58,代码来源:ASlider.cpp

示例14: OnMouseEvent

void wxCustomHeightListCtrl::OnMouseEvent(wxMouseEvent& event)
{
	bool changed = false;
	if (event.ButtonDown() && m_allow_selection) {
		wxPoint pos = event.GetPosition();
		int x, y;
		CalcUnscrolledPosition(pos.x, pos.y, &x, &y);
		if (y < 0 || y > static_cast<int>(m_lineHeight * m_rows.size())) {
			m_focusedLine = npos;
			m_selectedLines.clear();
			changed = true;
		}
		else {
			size_t line = static_cast<size_t>(y / m_lineHeight);

			if (event.ShiftDown()) {
				if (m_focusedLine == npos) {
					changed |= m_selectedLines.insert(line).second;
				}
				else if (line < m_focusedLine) {
					for (size_t i = line; i <= m_focusedLine; ++i) {
						changed |= m_selectedLines.insert(i).second;
					}
				}
				else {
					for (size_t i = line; i >= m_focusedLine && i != npos; --i) {
						changed |= m_selectedLines.insert(i).second;
					}
				}
			}
			else if (event.ControlDown()) {
				if (m_selectedLines.find(line) == m_selectedLines.end()) {
					m_selectedLines.insert(line);
				}
				else {
					m_selectedLines.erase(line);
				}
				changed = true;
			}
			else {
				m_selectedLines.clear();
				m_selectedLines.insert(line);
				changed = true;
			}

			m_focusedLine = line;
		}
		Refresh();
	}

	event.Skip();

	if (changed) {
		wxCommandEvent evt(wxEVT_COMMAND_LISTBOX_SELECTED, GetId());
		ProcessEvent(evt);
	}
}
开发者ID:comutt,项目名称:FileZilla3,代码行数:57,代码来源:customheightlistctrl.cpp

示例15: OnMouseEvent

void VideoDisplay::OnMouseEvent(wxMouseEvent& event) {
	if (event.ButtonDown())
		SetFocus();

	last_mouse_pos = mouse_pos = event.GetPosition();

	if (tool)
		tool->OnMouseEvent(event);
}
开发者ID:Aegisub,项目名称:Aegisub,代码行数:9,代码来源:video_display.cpp


注:本文中的wxMouseEvent::ButtonDown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。