コード例 #1
0
void VNCCanvas::onMouseAction(wxMouseEvent &event)
{
  if(event.Entering())
    {
      SetFocus();

      if(do_keyboard_grab)
	grab_keyboard();

      if(wxTheClipboard->Open()) 
	{
	  if(wxTheClipboard->IsSupported(wxDF_TEXT))
	    {
	      wxTextDataObject data;
	      wxTheClipboard->GetData(data);
	      wxString text = data.GetText();
	      wxLogDebug(wxT("VNCCanvas %p: setting cuttext: '%s'"), this, text.c_str());
	      conn->setCuttext(text);
	    }
	  wxTheClipboard->Close();
	}
    }

  if(event.Leaving())
    {
      if(do_keyboard_grab)
	ungrab_keyboard();
    }

  conn->sendPointerEvent(event);
}
コード例 #2
0
ファイル: colorArea.cpp プロジェクト: Reinis/wxmacmolplt
void colorPatternArea::OnMouse(wxMouseEvent &event) {
	if (mID < kNumPatterns && event.LeftDClick()) {
		patternSelectDlg selector(this);

		if (selector.ShowModal() == wxOK) {

		}
	}

	if (mID >= ID_BITMAP_SLT && mID < ID_BITMAP_SLT + kNumPatterns)  //exclude color areas in the left panel
	{

		if ( mID >= ID_BITMAP_SLT && (event.Entering() || mID == dynamic_cast<patternSelectDlg*>(mParent)->getSltId()) ) {
			//"distance" of two colors
			if ( pow((float)(mCurrentColor.Red()-defaultColor.Red()),2.0f) + pow((float)(mCurrentColor.Green()-defaultColor.Green()),2.0f) + pow((float)(mCurrentColor.Blue()-defaultColor.Blue()),2.0f) < 500)
				SetBackgroundColour(wxColour(68,68,68));
			else
				SetBackgroundColour(defaultColor);
		}

		if ( event.Leaving() && mID >= ID_BITMAP_SLT && mPatID != dynamic_cast<patternSelectDlg*>(mParent)->getSltPatId() )
			SetBackgroundColour(mCurrentColor);

		if (event.LeftDown() && mID >= ID_BITMAP_SLT) {
			dynamic_cast<patternSelectDlg*>(mParent)->setSltId(mID);
		}
	}
}
コード例 #3
0
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);
}
コード例 #4
0
ファイル: BmpCheckBox.cpp プロジェクト: DowerChest/codeblocks
void kwxBmpCheckBox::OnMouse(wxMouseEvent& event)
{
	if (m_stato == 0 && event.Entering())
	{
		m_stato = 1;	// mouse sul bottone
		wxCommandEvent ev(event.GetEventType(),GetId());
		ev.SetEventType(wxEVT_ENTER_WINDOW);
		event.SetEventObject(this);
		GetEventHandler()->ProcessEvent(ev);
	}
	else if (m_stato == 1 && event.LeftDown())
		m_stato = 2;	// uscita click sul bottone
	else if (m_stato >= 1 && event.Leaving())
	{
		m_stato = 0;	// uscita mouse dal bottone
		wxCommandEvent ev(event.GetEventType(),GetId());
		ev.SetEventType(wxEVT_LEAVE_WINDOW);
		event.SetEventObject(this);
		GetEventHandler()->ProcessEvent(ev);
	}
	else if (m_stato == 2 && event.LeftUp())
	{
		m_bPress = !m_bPress ;
		Click();		// rilascio sul bottone genera evento
		m_stato = 1;

	}


	if(m_oldstato != m_stato)
		Refresh();
	m_oldstato=m_stato;

	event.Skip();
}
コード例 #5
0
ファイル: slider.cpp プロジェクト: jhoggart/rt-tuner
void kwxLinearReg::OnMouse(wxMouseEvent& event)
{
	if (m_iStato == 0 && event.Entering())						//dentro nel controllo
		m_iStato = ENTERED ;
	else if (m_iStato >= ENTERED && event.Leaving())			//fuori dal controllo
		m_iStato = LEFT ;
	else if (m_iStato == ENTERED && event.GetWheelRotation())	// process wheel event
	{
		//SetValue(m_iRealVal + (event.GetWheelRotation() * (m_iMax-m_iMin)/kwxLinearReg::MOUSE_STEP / event.GetWheelDelta()) );    	
		SetValue(m_iRealVal + ( m_iBigStep * event.GetWheelRotation()  / event.GetWheelDelta()) );    	
    	vSendEvent();												// send event
		return;
	}
	else if (m_iStato == ENTERED && event.ButtonDClick())		// process double click
	{
//		wxLogTrace("Mouse Premuto") ;
		m_mousePosition = event.GetPosition();
		
		if( (m_iSnapRange<1) && 
			(m_iStyle & STYLE_SNAP_DOUBLE_CLK)	){				// if no snapping was set..
				vSetSnap2Tags(true);							// ..snap to next tag.
				DrawPosition() ;
				vSetSnap2Tags(false);
				return;
		}
		DrawPosition() ;
	}	
	else if (m_iStato == ENTERED && event.LeftDown())			//click o inizio trascinamento
	{
//		wxLogTrace("Mouse Premuto") ;
		m_iStato = DRAGED ;
		if( (m_bEditing) ){										// if control is currently in edit mode 
			if(m_cCurrentRect.Contains(m_mousePosition)){		// mouse click was within text sourrounding rectangle
				m_bEditing 		 = false;						// exit edit mode
				m_iCaretPosition = 0;							// reset edit caret position
				SetValue(iConvert(m_strCurrent));
				Refresh() ;
				vSendEvent() ;
				return;
			}
		}
		m_mousePosition = event.GetPosition();
		DrawPosition() ;
		
		
	}	
	else if (m_iStato == DRAGED && event.LeftIsDown())			//trascinamento
	{
//		wxLogTrace("Mouse trascinato") ;
		m_mousePosition = event.GetPosition();
		DrawPosition() ;
	}
	else if (m_iStato == DRAGED && event.LeftUp())				//fine trascinamento o rilascio click
	{
//		wxLogTrace("Mouse rilasciato") ;
		m_iStato = ENTERED ;
	}
	event.Skip(false);// 
}
コード例 #6
0
ファイル: sg_CustomControls.cpp プロジェクト: DanAurea/boinc
void CLinkButton::OnMouse(wxMouseEvent& event) {
    if (event.Entering()) {
        SetCursor(m_HandCursor);
    } else if (event.Leaving()) {
        SetCursor(*wxSTANDARD_CURSOR);
    }
    event.Skip();
}
コード例 #7
0
ファイル: ASlider.cpp プロジェクト: ruthmagnus/audacity
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;
   }
}
コード例 #8
0
void moTimelineRuler::OnMouseEvent( wxMouseEvent & event ) {

    //wxMessageBox("moTimelineRuler::Mouse event");

    if ( event.Entering() ) {
        //SHINE!!!

    }
    if (event.Button(wxMOUSE_BTN_RIGHT )) {
        SetValue( SlideValue( event.GetX() ) );
        Refresh();
    }

    if (event.Button(wxMOUSE_BTN_LEFT )) {
        SetPlayValue( GetSlideValueToPlayValue( SlideValue( event.GetX() ) ) );
        moSetDuration( m_play_value );
        moAbstract::MODebug2->Push( IntToStr(m_play_value) );
        Refresh();
    }

    if (event.Dragging()) {
        if (event.RightIsDown()) {
            if (m_bStartDragging==false) {
                m_bStartDragging = true;
                wxWindow::CaptureMouse();
            }
            SetValue( SlideValue( event.GetX() ) );
            Refresh();
        }

        if (event.LeftIsDown()) {
            if (m_bStartDragging==false) {
                m_bStartDragging = true;
                wxWindow::CaptureMouse();
            }
            SetPlayValue( GetSlideValueToPlayValue( SlideValue( event.GetX() ) ) );
            moSetDuration( m_play_value );
            Refresh();
        }
    }

    if (!event.Dragging()) {
        if (m_bStartDragging==true) {
            m_bStartDragging = false;
            wxWindow::ReleaseMouse();
        }
    }

    event.Skip();
}
コード例 #9
0
ファイル: AButton.cpp プロジェクト: Kirushanr/audacity
void AButton::OnMouseEvent(wxMouseEvent & event)
{
   if (mButtonIsDown || !mEnabled)
      return;

   if (event.ButtonUp()) {
      mIsClicking = false;

      ReleaseMouse();

      if (event.m_x >= 0 && event.m_y >= 0 &&
          event.m_x < mWidth && event.m_y < mHeight) {
         mButtonState = AButtonDown;
         mButtonIsDown = true;

         wxCommandEvent *e =
             new wxCommandEvent(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
         GetParent()->ProcessEvent(*e);
         delete e;
      }

      this->Refresh(false);
      return;
   }

   if (event.ButtonDown()) {
      mIsClicking = true;
      CaptureMouse();
   }

   if (mIsClicking) {
      if (event.m_x >= 0 && event.m_y >= 0 &&
          event.m_x < mWidth && event.m_y < mHeight) {
         mButtonState = AButtonDown;
      } else
         mButtonState = AButtonUp;
      this->Refresh(false);
   } else {
      if (event.Entering()) {
         mButtonState = AButtonOver;
         this->Refresh(false);
      }

      if (event.Leaving()) {
         mButtonState = AButtonUp;
         this->Refresh(false);
      }
   }
}
コード例 #10
0
void PortRepresentationBase::OnMouse(wxMouseEvent& event)
{
	if (event.Entering()) {
		m_hovered = true;
	}

	if (event.Leaving()) {
		m_hovered = false;
	}

	wxStaticText::SetBackgroundColour(m_hovered ? m_highlightedColour : m_passiveColour);

	wxStaticText::Refresh();
	wxStaticText::Update();
}
コード例 #11
0
ファイル: canvas.cpp プロジェクト: lealzhan/moged
void CanvasController::MoveCamera(wxMouseEvent& event)
{
	if(event.Entering() || event.Leaving()) {
		m_track_x.Reset();
		m_track_y.Reset();
		m_wheel_rot = 0;
	}
	m_track_x.Update( event.GetX() );
	m_track_y.Update( event.GetY() );

	if(event.Dragging())
	{
		if(event.LeftIsDown())
		{
			const float kYawRate = -0.2f;
			const float kPitchRate = -0.2f;
			m_camera.RotateYaw( m_track_x.GetRel() * kYawRate );
			m_camera.RotatePitch( m_track_y.GetRel() * kPitchRate );
		} 
		else if(event.RightIsDown())
		{
			// Move relative to the camera
			const Mat4& mat = m_camera.GetMatrix();
			Vec3 x_axis = get_column(mat, 0);
			Vec3 y_axis = get_column(mat, 1);
			
			const float kScale = 0.02f;
			Vec3 move_by = -m_track_x.GetRel() * kScale * x_axis +
				m_track_y.GetRel() * kScale * y_axis ;
			m_camera.MoveBy( move_by );
		}
	}
	else if(event.GetWheelRotation() != 0) 
	{
		m_wheel_rot += event.GetWheelRotation();
		while(m_wheel_rot > event.GetWheelDelta()) {
			m_wheel_rot -= event.GetWheelDelta();
			m_camera.ZoomBy(1.f);	 
		}
		while(m_wheel_rot < -event.GetWheelDelta()) {
			m_wheel_rot += event.GetWheelDelta();
			m_camera.ZoomBy(-1.f);
		}
	}
}
コード例 #12
0
void wxInputConsumer::OnMouse(wxMouseEvent& event)
{
    if ( m_inputHandler )
    {
        if ( event.Moving() || event.Dragging() ||
                event.Entering() || event.Leaving() )
        {
            if ( m_inputHandler->HandleMouseMove(this, event) )
                return;
        }
        else // a click action
        {
            if ( m_inputHandler->HandleMouse(this, event) )
                return;
        }
    }

    event.Skip();
}
コード例 #13
0
void kwxAngularRegulator::OnMouse(wxMouseEvent& event)
{
	if (m_nStato == 0 && event.Entering())	//dentro nel controllo
		m_nStato = 1 ;
	else if (m_nStato >= 1 && event.Leaving())	//fuori dal controllo
		m_nStato = 0 ;
	else if (m_nStato == 1 && event.LeftDown())	//click o inizio trascinamento
	{
		m_nStato = 2 ;
		m_mousePosition = event.GetPosition();
		SetPosition() ;
	}
	else if (m_nStato == 2 && event.LeftIsDown())	//trascinamento
	{
		m_mousePosition = event.GetPosition();
		SetPosition() ;
	}
	else if (m_nStato == 2 && event.LeftUp())	//fine trascinamento o rilascio click
		m_nStato = 1 ;
}
コード例 #14
0
void wxSpeedButton::OnMouseEvents(wxMouseEvent& event) {
wxWindow    *win;

// our underlying window

    win = (wxWindow *) this;

// any mouse button down

    if (event.LeftDown() || event.RightDown()) {
       if (!HasCapture()) CaptureMouse();
        mMouseDown = true;
        mButtonFocused = true;
        win->SetFocus();
        Redraw();
    }

// any mouse button up
// this is where we send a click event

    else if (event.LeftUp() || event.RightUp()) {
        if (HasCapture()) ReleaseMouse();
        mMouseDown = false;
        mButtonFocused = true;
        win->SetFocus();
        SetDown(! mButtonDown);
        SendEvent(event.LeftUp());
        Redraw();
    }

// mouse over

    else if (event.Entering()) {
        mMouseOver = true;
        Redraw();
    }
    else if (event.Leaving()) {
        mMouseOver = false;
        Redraw();
    };
}
コード例 #15
0
void kwxBitmapButton::OnMouse(wxMouseEvent& event)
{
	if (m_stato == 0 && event.Entering())
		m_stato = 1;	// mouse sul bottone	
	else if (m_stato == 1 && event.LeftDown())
		m_stato = 2;	// uscita click sul bottone
	else if (m_stato >= 1 && event.Leaving())
		m_stato = 0;	// uscita mouse dal bottone
	else if (m_stato == 2 && event.LeftUp())
	{
		Click();		// rilascio sul bottone genera evento
		m_stato = 1;
	}


	if(m_oldstato != m_stato)
		Refresh();
	m_oldstato=m_stato;

	event.Skip();
}
コード例 #16
0
bool wxStdButtonInputHandler::HandleMouseMove(wxInputConsumer *consumer,
                                              const wxMouseEvent& event)
{
    // we only have to do something when the mouse leaves/enters the pressed
    // button and don't care about the other ones
    if ( event.GetEventObject() == m_winCapture )
    {
        // leaving the button should remove its pressed state
        if ( event.Leaving() )
        {
            // remember that the mouse is now outside
            m_winHasMouse = false;

            // we do have a pressed button, so release it
            consumer->GetInputWindow()->SetCurrent(false);
            consumer->PerformAction(wxACTION_BUTTON_RELEASE);

            return true;
        }
        // and entering it back should make it pressed again if it had been
        // pressed
        else if ( event.Entering() )
        {
            // the mouse is (back) inside the button
            m_winHasMouse = true;

            // we did have a pressed button which we released when leaving the
            // window, press it again
            consumer->GetInputWindow()->SetCurrent(true);
            consumer->PerformAction(wxACTION_BUTTON_PRESS);

            return true;
        }
    }

    return wxStdInputHandler::HandleMouseMove(consumer, event);
}
コード例 #17
0
void LWSlider::OnMouseEvent(wxMouseEvent & event)
{
   if (event.Entering()) {
      #if wxUSE_TOOLTIPS // Not available in wxX11
      // Display the tooltip in the status bar
      if (mParent->GetToolTip()) 
      {
         wxString tip = mParent->GetToolTip()->GetTip();
         GetActiveProject()->TP_DisplayStatusMessage(tip);
         Refresh();
      }
      #endif
   }
   else if (event.Leaving())
   {
      GetActiveProject()->TP_DisplayStatusMessage(wxT(""));
      Refresh();
   }

   // Events other than mouse-overs are ignored when we are disabled
   if (!mEnabled)
      return;

   float prevValue = mCurrentValue;

   // Figure out the thumb position
   wxRect r;
   if (mOrientation == wxHORIZONTAL)
   {
      r.x = mLeft + ValueToPosition(mCurrentValue);
      r.y = mTop + (mCenterY - (mThumbHeight / 2));
   }
   else 
   {
      r.x = mLeft + (mCenterX - (mThumbWidth / 2));
      r.y = mTop + ValueToPosition(mCurrentValue);
   }
   r.width = mThumbWidth;
   r.height = mThumbHeight;

   wxRect tolerantThumbRect = r;
   tolerantThumbRect.Inflate(3, 3);

   // Should probably use a right click instead/also
   if( event.ButtonDClick() && mPopup )
   {
      //On a double-click, we should pop up a dialog.
      DoShowDialog(mParent->ClientToScreen(wxPoint(event.m_x,event.m_y)));
   }
   else if( event.ButtonDown() )
   {
      if( mDefaultShortcut && event.CmdDown() )
      {
         mCurrentValue = mDefaultValue;
      }

      if( event.RightDown() ) {
         mParent->SetFocus();
      }

      // Thumb clicked?
      //
      // Do not change position until first drag.  This helps
      // with unintended value changes.
      if( tolerantThumbRect.Contains( event.GetPosition() ) )
      {
         // Remember mouse position and current value
         mClickPos = (mOrientation == wxHORIZONTAL) ? event.m_x : event.m_y;
         mClickValue = mCurrentValue;

         mIsDragging = true;
      }
      // Clicked to set location?
      else
      {
         mCurrentValue = 
            ClickPositionToValue(
               (mOrientation == wxHORIZONTAL) ? event.m_x : event.m_y, 
               event.ShiftDown());
      }

      mParent->CaptureMouse();
      // wxSetCursor(wxCURSOR_BLANK);
      ((TipPanel*)LWSlider::sharedTipPanel)->SetTargetParent(mParent);
      FormatPopWin();
      SetPopWinPosition();
      LWSlider::sharedTipPanel->Show();
      //hide mouseover tooltip
      wxToolTip::Enable(false);
   }
   else if( event.ButtonUp() )
   {
      mIsDragging = false;
      if (mParent->HasCapture())
         mParent->ReleaseMouse();
      LWSlider::sharedTipPanel->Hide();
      //restore normal tooltip behavor for mouseovers
      wxToolTip::Enable(true);
      // wxSetCursor(wxNullCursor);
   }
   else if (event.Dragging() && mIsDragging)
   {
      if (mOrientation == wxHORIZONTAL)
      {
         if (event.m_y < (r.y - 2 * r.height) ||
             event.m_y > (r.y + 3 * r.height)) {
            // If the mouse y coordinate is relatively far from the slider,
            // snap back to the original position
            mCurrentValue = mClickValue;
         }
         else {
            // Otherwise, move the slider to the right position based
            // on the mouse position
            mCurrentValue = DragPositionToValue(event.m_x, event.ShiftDown());
         }
      }
      else // (mOrientation == wxVERTICAL)
      {
         if (event.m_x < (r.x - 2 * r.width) ||
             event.m_x > (r.x + 3 * r.width)) {
            // If the mouse x coordinate is relatively far from the slider,
            // snap back to the original position
            mCurrentValue = mClickValue;
         }
         else {
            // Otherwise, move the slider to the right position based
            // on the mouse position
            mCurrentValue = DragPositionToValue(event.m_y, event.ShiftDown());
         }
      }
   }
   else if( event.m_wheelRotation != 0 )
   {
      //Calculate the number of steps in a given direction this event
      //represents (allows for two or more clicks on a single event.)
      double steps =  event.m_wheelRotation /
         (event.m_wheelDelta > 0 ? (double)event.m_wheelDelta : 120.0);

      if( steps < 0.0 )
      {
         Decrease( (float)-steps );
      }
      else
      {
         Increase( (float)steps );
      }
      SendUpdate( mCurrentValue );
   }

   if( prevValue != mCurrentValue )
      SendUpdate( mCurrentValue );
}
コード例 #18
0
ファイル: splitter.cpp プロジェクト: CodeSmithyIDE/wxWidgets
void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
{
    int x = (int)event.GetX(),
        y = (int)event.GetY();

    if ( GetWindowStyle() & wxSP_NOSASH )
    {
        event.Skip();
        return;
    }

    bool isLive = IsLive(this);

    if (event.LeftDown())
    {
        if ( SashHitTest(x, y) )
        {
            // Start the drag now
            m_dragMode = wxSPLIT_DRAG_DRAGGING;

            // Capture mouse and set the cursor
            CaptureMouse();
            SetResizeCursor();

            if ( !isLive )
            {
                // remember the initial sash position and draw the initial
                // shadow sash
                m_sashPositionCurrent = m_sashPosition;

                m_oldX = (m_splitMode == wxSPLIT_VERTICAL ? m_sashPositionCurrent : x);
                m_oldY = (m_splitMode != wxSPLIT_VERTICAL ? m_sashPositionCurrent : y);
                DrawSashTracker(m_oldX, m_oldY);
            }

            m_ptStart = wxPoint(x,y);
            m_sashStart = m_sashPosition;
            return;
        }
    }
    else if (event.LeftUp() && m_dragMode == wxSPLIT_DRAG_DRAGGING)
    {
        // We can stop dragging now and see what we've got.
        m_dragMode = wxSPLIT_DRAG_NONE;

        // Release mouse and unset the cursor
        ReleaseMouse();
        SetCursor(* wxSTANDARD_CURSOR);

        // exit if unsplit after doubleclick
        if ( !IsSplit() )
        {
            return;
        }

        // Erase old tracker
        if ( !isLive )
        {
            DrawSashTracker(m_oldX, m_oldY);
        }

        // the position of the click doesn't exactly correspond to
        // m_sashPosition, rather it changes it by the distance by which the
        // mouse has moved
        int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_ptStart.x : y - m_ptStart.y;

        int posSashNew = OnSashPositionChanging(m_sashStart + diff);
        if ( posSashNew == -1 )
        {
            // change not allowed
            return;
        }

        if ( m_permitUnsplitAlways || m_minimumPaneSize == 0 )
        {
            // Deal with possible unsplit scenarios
            if ( posSashNew == 0 )
            {
                // We remove the first window from the view
                wxWindow *removedWindow = m_windowOne;
                m_windowOne = m_windowTwo;
                m_windowTwo = NULL;
                OnUnsplit(removedWindow);
                wxSplitterEvent eventUnsplit(wxEVT_SPLITTER_UNSPLIT, this);
                eventUnsplit.m_data.win = removedWindow;
                (void)DoSendEvent(eventUnsplit);
                SetSashPositionAndNotify(0);
            }
            else if ( posSashNew == GetWindowSize() )
            {
                // We remove the second window from the view
                wxWindow *removedWindow = m_windowTwo;
                m_windowTwo = NULL;
                OnUnsplit(removedWindow);
                wxSplitterEvent eventUnsplit(wxEVT_SPLITTER_UNSPLIT, this);
                eventUnsplit.m_data.win = removedWindow;
                (void)DoSendEvent(eventUnsplit);
                SetSashPositionAndNotify(0);
            }
            else
            {
                SetSashPositionAndNotify(posSashNew);
            }
        }
        else
        {
            SetSashPositionAndNotify(posSashNew);
        }

        SizeWindows();
    }  // left up && dragging
    else if ((event.Moving() || event.Leaving() || event.Entering()) && (m_dragMode == wxSPLIT_DRAG_NONE))
    {
        if ( event.Leaving() || !SashHitTest(x, y) )
            OnLeaveSash();
        else
            OnEnterSash();
    }
    else if (event.Dragging() && (m_dragMode == wxSPLIT_DRAG_DRAGGING))
    {
        int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_ptStart.x : y - m_ptStart.y;

        int posSashNew = OnSashPositionChanging(m_sashStart + diff);
        if ( posSashNew == -1 )
        {
            // change not allowed
            return;
        }

        if ( !isLive )
        {
            if ( posSashNew == m_sashPositionCurrent )
                return;

            m_sashPositionCurrent = posSashNew;

            // Erase old tracker
            DrawSashTracker(m_oldX, m_oldY);

            m_oldX = (m_splitMode == wxSPLIT_VERTICAL ? m_sashPositionCurrent : x);
            m_oldY = (m_splitMode != wxSPLIT_VERTICAL ? m_sashPositionCurrent : y);

#ifdef __WXMSW__
            // As we captured the mouse, we may get the mouse events from outside
            // our window - for example, negative values in x, y. This has a weird
            // consequence under MSW where we use unsigned values sometimes and
            // signed ones other times: the coordinates turn as big positive
            // numbers and so the sash is drawn on the *right* side of the window
            // instead of the left (or bottom instead of top). Correct this.
            if ( (short)m_oldX < 0 )
                m_oldX = 0;
            if ( (short)m_oldY < 0 )
                m_oldY = 0;
#endif // __WXMSW__

            // Draw new one
            DrawSashTracker(m_oldX, m_oldY);
        }
        else
        {
            if ( posSashNew == m_sashPosition )
                return;

            DoSetSashPosition(posSashNew);

            // in live mode, the new position is the actual sash position, clear requested position!
            m_requestedSashPosition = INT_MAX;
            m_needUpdating = true;
        }
    }
    else if ( event.LeftDClick() && m_windowTwo )
    {
        OnDoubleClickSash(x, y);
    }
    else
    {
        event.Skip();
    }
}
コード例 #19
0
void WinEDA_DrawPanel::OnMouseEvent(wxMouseEvent& event)
/*******************************************************/
// Called when the canvas receives a mouse event. //
{
int localrealbutt = 0, localbutt = 0, localkey = 0;
BASE_SCREEN * screen = GetScreen();
static WinEDA_DrawPanel * LastPanel;
	
	if ( event.Leaving() || event.Entering() )
	{
		m_CanStartBlock = -1;
	}

	if (GetScreen()->ManageCurseur == NULL ) // Pas de commande en cours
		m_AutoPAN_Request = FALSE;

	if ( m_Parent->m_FrameIsActive ) SetFocus();
	else return;

	// Mouse Wheel is a zoom command:
	if ( event.m_wheelRotation )
	{
		// This is a zoom in ou out command
		if ( event.GetWheelRotation() > 0 ) localkey = WXK_F1;
		else  localkey = WXK_F2;
	}

	if( !event.IsButton() && !event.Moving() &&
		!event.Dragging() && ! localkey )
	{
		return;
	}

	if( event.RightDown() )
	{
		OnRightClick(event); return;
	}

	if ( m_IgnoreMouseEvents ) return;

	if( event.LeftIsDown() ) localrealbutt |= GR_M_LEFT_DOWN;
	if( event.MiddleIsDown() ) localrealbutt |= GR_M_MIDDLE_DOWN;

	if( event.LeftDown()) localbutt = GR_M_LEFT_DOWN;

	if( event.ButtonDClick(1)) localbutt = GR_M_LEFT_DOWN|GR_M_DCLICK;
	if( event.MiddleDown()) localbutt = GR_M_MIDDLE_DOWN;
	if( event.ButtonDClick(2)) {};	// Unused


	localrealbutt |= localbutt;		/* compensation defaut wxGTK */

	screen->m_MousePosition = CalcAbsolutePosition(wxPoint(event.GetX(), event.GetY()));

wxClientDC DC(this);
int kbstat = 0;

	DC.SetBackground(*wxBLACK_BRUSH );
	PrepareGraphicContext(&DC);

	g_KeyPressed = localkey;

	if( event.ShiftDown() ) kbstat |= GR_KB_SHIFT;
	if( event.ControlDown() ) kbstat |= GR_KB_CTRL;
	if( event.AltDown() ) kbstat |= GR_KB_ALT;

	g_MouseOldButtons = localrealbutt;

	// Appel des fonctions liées au Double Click ou au Click
	if( localbutt == (int)(GR_M_LEFT_DOWN|GR_M_DCLICK) )
		m_Parent->OnLeftDClick(&DC, screen->m_MousePosition);

	else if ( event.LeftDown() )
		m_Parent->OnLeftClick(&DC, screen->m_MousePosition);

	if( event.ButtonUp(2) && (screen->BlockLocate.m_State == STATE_NO_BLOCK) )
	{	// The middle button has been relached, with no block command:
		// We use it for a zoom center command
		g_KeyPressed = localkey = WXK_F4;
	}
		

	/* Appel de la fonction generale de gestion des mouvements souris
	et commandes clavier */
	m_Parent->GeneralControle(&DC, screen->m_MousePosition);


	/*******************************/
	/* Control of block commands : */
	/*******************************/
	
	// Command block can't start if mouse is dragging a new panel
	if (LastPanel != this ) m_CanStartBlock = -1;

	// A new command block can start after a release buttons
	// Avoid a false start block when a dialog bos is demiss,
	// or when changing panels in hierachy navigation
	if ( !event.LeftIsDown() && !event.MiddleIsDown())
	{
		m_CanStartBlock = 0;
	}

	if( m_Block_Enable && !(localbutt & GR_M_DCLICK) )
	{
		if ( (screen->BlockLocate.m_Command == BLOCK_IDLE) ||
			(screen->BlockLocate.m_State == STATE_NO_BLOCK))
		{
			m_CursorStartPos = screen->m_Curseur;
			screen->BlockLocate.SetOrigin(m_CursorStartPos);
		}
		if ( event.LeftDown() || event.MiddleDown() )
		{
			m_CursorStartPos = screen->m_Curseur;
			if ( screen->BlockLocate.m_State == STATE_BLOCK_MOVE )
			{
				m_AutoPAN_Request = FALSE;
				m_Parent->HandleBlockPlace(&DC);
			}
		}
		else if( (m_CanStartBlock >= 0 ) &&
				( event.LeftIsDown() || event.MiddleIsDown() )
				&& screen->ManageCurseur == NULL
				&& screen->ForceCloseManageCurseur == NULL )
		{
			if ( screen->BlockLocate.m_State == STATE_NO_BLOCK )
			{
				int cmd_type = kbstat;
				if ( event.MiddleIsDown() )	cmd_type |= MOUSE_MIDDLE;
				if ( ! m_Parent->HandleBlockBegin(&DC, cmd_type, m_CursorStartPos) )
				{	// error
					m_Parent->DisplayToolMsg( wxT("WinEDA_DrawPanel::OnMouseEvent() Block Error") );
				}
				else
				{
					m_AutoPAN_Request = TRUE;
					SetCursor(m_PanelCursor = wxCURSOR_SIZING);
				}
			}
		}
		
		
		if( event.ButtonUp(1) || event.ButtonUp(2) )
		{ /* Relachement du bouton: fin de delimitation de block.
			La commande peut etre terminee (DELETE) ou continuer par le placement
			du block ainsi delimite (MOVE, COPY).
			Cependant bloc est annule si sa taille est trop petite*/
			bool BlockIsSmall =
				 ( ABS(screen->BlockLocate.GetWidth()/GetZoom()) < 3) &&
				 ( ABS(screen->BlockLocate.GetHeight()/GetZoom()) < 3);
			
			if ( (screen->BlockLocate.m_State != STATE_NO_BLOCK) && BlockIsSmall )
			{
				if( GetScreen()->ForceCloseManageCurseur )
				{
					GetScreen()->ForceCloseManageCurseur(m_Parent, &DC);
					m_AutoPAN_Request = FALSE;
				}
				SetCursor(m_PanelCursor = m_PanelDefaultCursor);
			}
			else if ( screen->BlockLocate.m_State == STATE_BLOCK_END )
			{
				m_AutoPAN_Request = FALSE;
				m_Parent->HandleBlockEnd(&DC);
				SetCursor(m_PanelCursor = m_PanelDefaultCursor);
				if ( screen->BlockLocate.m_State == STATE_BLOCK_MOVE )
				{
					m_AutoPAN_Request = TRUE;
					SetCursor(m_PanelCursor = wxCURSOR_HAND);
				}
			}
		}

	}

	// Arret de block sur un double click ( qui peut provoquer un move block
	// si on déplace la souris dans ce double click
	if ( localbutt == (int)(GR_M_LEFT_DOWN|GR_M_DCLICK) )
	{
		if ( screen->BlockLocate.m_Command != BLOCK_IDLE )
		{
			if( GetScreen()->ForceCloseManageCurseur )
			{
				GetScreen()->ForceCloseManageCurseur(m_Parent, &DC);
				m_AutoPAN_Request = FALSE;
			}
		}
	}


#if 0
	wxString msg_debug;
	msg_debug.Printf(" block state %d, cmd %d",
		screen->BlockLocate.m_State, screen->BlockLocate.m_Command);
	m_Parent->PrintMsg(msg_debug);
#endif

	LastPanel = this;
	m_Parent->SetToolbars();
}
コード例 #20
0
ファイル: TreeCanvas.cpp プロジェクト: CarlosGS/heekscad
void CTreeCanvas::OnMouse( wxMouseEvent& event )
{
	if(wxGetApp().m_property_grid_validation)return;

	if(event.Entering()){
		SetFocus(); // so middle wheel works
	}

	if(event.LeftDown())
	{
		const CTreeButton* button = HitTest(event.GetPosition());

		if(button)
		{
			switch(button->type)
			{
			case ButtonTypePlus:
			case ButtonTypeMinus:
				SetExpanded(button->obj, button->type == 0);
				SetVirtualSize(GetRenderSize());
				this->Refresh();
				break;

			case ButtonTypeLabelBefore:
			case ButtonTypeLabel:
			default:
				OnLabelLeftDown(button->obj, event);
				clicked_object = button->obj;
				break;
			}
		}
		else
		{
			wxGetApp().m_marked_list->Clear(true);
		}

		m_button_down_point = event.GetPosition();
	}

	if(event.LeftUp())
	{
		if(m_dragging)
		{
			m_dragging = false;

			// find the object to drop on to
			const CTreeButton* button = HitTest(event.GetPosition());

			if(button == NULL || !wxGetApp().m_marked_list->ObjectMarked(button->obj)) // can only drop on to an item other than one of the items being dragged
			{
				// test drop possible
				bool drag_possible = true;

				HeeksObj* add_to = &wxGetApp();
				if(button && button->paste_into)add_to = button->paste_into;
				for(std::list<HeeksObj*>::iterator It = m_dragged_list.begin(); It != m_dragged_list.end(); It++)
				{
					HeeksObj* object = *It;

					if(!add_to->CanAdd(object) || !object->CanAddTo(add_to))
					{
						drag_possible = false;
						break;
					}
				}

				if(drag_possible)
				{
					wxGetApp().CreateUndoPoint();

					// cut the objects
					wxGetApp().Remove(m_dragged_list);

					// paste the objects
					for(std::list<HeeksObj*>::iterator It = m_dragged_list.begin(); It != m_dragged_list.end(); It++)
					{
						HeeksObj* object = *It;
						{
							if(object->OneOfAKind())
							{
								bool one_found = false;
								for(HeeksObj* child = add_to->GetFirstChild(); child; child = add_to->GetNextChild())
								{
									if(child->GetType() == object->GetType())
									{
										child->CopyFrom(object);
										one_found = true;
										break;
									}
								}
								if(!one_found)
								{
									add_to->Add(object, button ? button->paste_before : NULL);
								}
							}
							else
							{
								add_to->Add(object, button ? button->paste_before : NULL);
							}
						}
					}
					wxGetApp().Changed();
				}
				else
				{
					Refresh();
				}
			}
			else
			{
				Refresh();
			}
		}
		else
		{
			if(m_waiting_until_left_up)
			{
				wxGetApp().m_marked_list->Clear(false);
				wxGetApp().m_marked_list->Add(clicked_object, true);
			}
		}
		m_waiting_until_left_up = false;
	}

	if(event.RightDown())
	{
		const CTreeButton* button = HitTest(event.GetPosition());
		clicked_object = NULL;
		if(button && (button->type == ButtonTypeLabelBefore || button->type == ButtonTypeLabel))
		{
			clicked_object = button->obj;
			OnLabelRightDown(button->obj, event);
		}
	}

	if(event.RightUp())
	{
		// do a context menu
		MarkedObjectOneOfEach marked_object(0, clicked_object, 1, 0, NULL);
		if(m_dragging)
		{
			m_dragging = false;

			// find the object to drop on to
			const CTreeButton* button = HitTest(event.GetPosition());

			if(button == NULL || !wxGetApp().m_marked_list->ObjectMarked(button->obj)) // can only drop on to an item other than one of the items being dragged
			{
				// make a Move or Copy context menu
				HeeksObj* paste_into = NULL;
				HeeksObj* paste_before = NULL;
				if(button)
				{
					paste_into = button->paste_into;
					paste_before = button->paste_before;
				}
				wxGetApp().DoMoveOrCopyDropDownMenu(this, event.GetPosition(), &marked_object, paste_into, paste_before);
			}
			else
			{
				Refresh();
			}
		}
		else
		{
			// do a standard drop down menu
			wxGetApp().DoDropDownMenu(this, event.GetPosition(), &marked_object, true, false);
		}
	}

	if(event.Dragging())
	{
		if(event.LeftIsDown() || event.RightIsDown())
		{
			if(!m_dragging && (abs(m_button_down_point.x - event.GetX())>2 || abs(m_button_down_point.y - event.GetY())>2))
			{
				m_dragging = true;
				m_dragged_list = wxGetApp().m_marked_list->list();
			}
			if(m_dragging)
			{
				m_drag_position = CalcUnscrolledPosition(event.GetPosition());
				const CTreeButton* button = HitTest(event.GetPosition());
				m_drag_paste_rect = wxRect(0, 0, 0, 0);
				if(button && button->type == ButtonTypeLabelBefore)m_drag_paste_rect = button->rect;
				Refresh();
			}
		}
	}

	if(event.LeftDClick())
	{
		const CTreeButton* button = HitTest(event.GetPosition());
		if(button)
		{
			if(button->obj)
			{
				bool(*callback)(HeeksObj*) = NULL;
				button->obj->GetOnEdit(&callback);
				if(callback)
				{
					(*callback)(button->obj);
				}
			}
		}
	}

	event.Skip();
}
コード例 #21
0
ファイル: AButton.cpp プロジェクト: jeevithag/audacity
void AButton::OnMouseEvent(wxMouseEvent & event)
{
    wxSize clientSize = GetClientSize();
    AButtonState prevState = GetState();

    if (event.Entering())
        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 (HasAlternateImages() && !mButtonIsDown)
        mAlternate = event.ShiftDown();

    if (mEnabled && event.IsButton()) {
        if (event.ButtonIsDown(wxMOUSE_BTN_ANY)) {
            mIsClicking = true;
            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) {
#if wxUSE_TOOLTIPS // Not available in wxX11
            // Display the tooltip in the status bar
            wxToolTip * pTip = this->GetToolTip();
            if( pTip ) {
                wxString tipText = pTip->GetTip();
                if (!mEnabled)
                    tipText += _(" (disabled)");
                GetActiveProject()->TP_DisplayStatusMessage(tipText);
            }
#endif
        }
        else {
            GetActiveProject()->TP_DisplayStatusMessage(wxT(""));
        }
    }
}
コード例 #22
0
ファイル: menubtn.cpp プロジェクト: erelh/gpac
void wxCustomButton::OnMouseEvents(wxMouseEvent& event)
{
    if (m_button_style & wxCUSTBUT_NOTOGGLE) return;

    if (event.LeftDown() || event.RightDown())
    {
        if (!HasCapture())
            CaptureMouse(); // keep depressed until up

        m_down++;
        Redraw();
    }
    else if (event.LeftDClick() || event.RightDClick())
    {
        m_down++; // GTK eats second down event
        Redraw();
    }
    else if (event.LeftUp())
    {
        if (HasCapture())
            ReleaseMouse();

        m_eventType = wxEVT_LEFT_UP;

#if (wxMINOR_VERSION<8)
        if (wxRect(wxPoint(0,0), GetSize()).Inside(event.GetPosition()))
#else
        if (wxRect(wxPoint(0,0), GetSize()).Contains(event.GetPosition()))
#endif
        {
            if ((m_button_style & wxCUSTBUT_BUTTON) && (m_down > 0))
            {
                m_down = 0;
                Redraw();
                SendEvent();
                return;
            }
            else
            {
                if (!m_timer)
                {
                    m_timer = new wxTimer(this, m_down+1);
                    m_timer->Start(200, TRUE);
                }
                else
                {
                    m_eventType = wxEVT_LEFT_DCLICK;
                }

                if ((m_button_style & wxCUSTBUT_TOGGLE) &&
                    (m_button_style & wxCUSTBUT_TOG_DCLICK_BUT)) m_down++;
            }
        }

        Redraw();
    }
    else if (event.RightUp())
    {
        if (HasCapture())
            ReleaseMouse();

        m_eventType = wxEVT_RIGHT_UP;

#if (wxMINOR_VERSION<8)
        if (wxRect(wxPoint(0,0), GetSize()).Inside(event.GetPosition()))
#else
        if (wxRect(wxPoint(0,0), GetSize()).Contains(event.GetPosition()))
#endif
        {
            if ((m_button_style & wxCUSTBUT_BUTTON) && (m_down > 0))
            {
                m_down = 0;
                Redraw();
                SendEvent();
                return;
            }
            else
            {
                m_down++;

                if (!m_timer)
                {
                    m_timer = new wxTimer(this, m_down);
                    m_timer->Start(250, TRUE);
                }
                else
                {
                    m_eventType = wxEVT_RIGHT_DCLICK;
                }
            }
        }

        Redraw();
    }
    else if (event.Entering())
    {
        m_focused = TRUE;
        if ((event.LeftIsDown() || event.RightIsDown()) && HasCapture())
            m_down++;

        Redraw();
    }
    else if (event.Leaving())
    {
        m_focused = FALSE;
        if ((event.LeftIsDown() || event.RightIsDown()) && HasCapture())
            m_down--;

        Redraw();
    }
}
コード例 #23
0
ファイル: AButton.cpp プロジェクト: RaphaelMarinier/audacity
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();
}
コード例 #24
0
void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
{
    int x = (int)event.GetX(),
        y = (int)event.GetY();

    if (GetWindowStyle() & wxSP_NOSASH)
        return;

    // with wxSP_LIVE_UPDATE style the splitter windows are always resized
    // following the mouse movement while it drags the sash, without it we only
    // draw the sash at the new position but only resize the windows when the
    // dragging is finished
#if defined( __WXMAC__ ) && TARGET_API_MAC_OSX == 1
    bool isLive = true ;
#else
    bool isLive = (GetWindowStyleFlag() & wxSP_LIVE_UPDATE) != 0;
#endif
    if (event.LeftDown())
    {
        if ( SashHitTest(x, y) )
        {
            // Start the drag now
            m_dragMode = wxSPLIT_DRAG_DRAGGING;

            // Capture mouse and set the cursor
            CaptureMouse();
            SetResizeCursor();

            if ( !isLive )
            {
                // remember the initial sash position and draw the initial
                // shadow sash
                m_sashPositionCurrent = m_sashPosition;

                DrawSashTracker(x, y);
            }

            m_oldX = x;
            m_oldY = y;

            SetResizeCursor();
            return;
        }
    }
    else if (event.LeftUp() && m_dragMode == wxSPLIT_DRAG_DRAGGING)
    {
        // We can stop dragging now and see what we've got.
        m_dragMode = wxSPLIT_DRAG_NONE;

        // Release mouse and unset the cursor
        ReleaseMouse();
        SetCursor(* wxSTANDARD_CURSOR);

        // exit if unsplit after doubleclick
        if ( !IsSplit() )
        {
            return;
        }

        // Erase old tracker
        if ( !isLive )
        {
            DrawSashTracker(m_oldX, m_oldY);
        }

        // the position of the click doesn't exactly correspond to
        // m_sashPosition, rather it changes it by the distance by which the
        // mouse has moved
        int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_oldX : y - m_oldY;

        int posSashOld = isLive ? m_sashPosition : m_sashPositionCurrent;
        int posSashNew = OnSashPositionChanging(posSashOld + diff);
        if ( posSashNew == -1 )
        {
            // change not allowed
            return;
        }

        if ( m_permitUnsplitAlways || m_minimumPaneSize == 0 )
        {
            // Deal with possible unsplit scenarios
            if ( posSashNew == 0 )
            {
                // We remove the first window from the view
                wxWindow *removedWindow = m_windowOne;
                m_windowOne = m_windowTwo;
                m_windowTwo = (wxWindow *) NULL;
                OnUnsplit(removedWindow);
                wxSplitterEvent event(wxEVT_COMMAND_SPLITTER_UNSPLIT, this);
                event.m_data.win = removedWindow;
                (void)DoSendEvent(event);
                SetSashPositionAndNotify(0);
            }
            else if ( posSashNew == GetWindowSize() )
            {
                // We remove the second window from the view
                wxWindow *removedWindow = m_windowTwo;
                m_windowTwo = (wxWindow *) NULL;
                OnUnsplit(removedWindow);
                wxSplitterEvent event(wxEVT_COMMAND_SPLITTER_UNSPLIT, this);
                event.m_data.win = removedWindow;
                (void)DoSendEvent(event);
                SetSashPositionAndNotify(0);
            }
            else
            {
                SetSashPositionAndNotify(posSashNew);
            }
        }
        else
        {
            SetSashPositionAndNotify(posSashNew);
        }

        SizeWindows();
    }  // left up && dragging
    else if ((event.Moving() || event.Leaving() || event.Entering()) && (m_dragMode == wxSPLIT_DRAG_NONE))
    {
        if ( event.Leaving() || !SashHitTest(x, y) )
            OnLeaveSash();
        else
            OnEnterSash();
    }
    else if (event.Dragging() && (m_dragMode == wxSPLIT_DRAG_DRAGGING))
    {
        int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_oldX : y - m_oldY;
        if ( !diff )
        {
            // nothing to do, mouse didn't really move far enough
            return;
        }

        int posSashOld = isLive ? m_sashPosition : m_sashPositionCurrent;
        int posSashNew = OnSashPositionChanging(posSashOld + diff);
        if ( posSashNew == -1 )
        {
            // change not allowed
            return;
        }

        if ( posSashNew == m_sashPosition )
            return;

        // Erase old tracker
        if ( !isLive )
        {
            DrawSashTracker(m_oldX, m_oldY);
        }

        if (m_splitMode == wxSPLIT_VERTICAL)
            x = posSashNew;
        else
            y = posSashNew;

        // Remember old positions
        m_oldX = x;
        m_oldY = y;

#ifdef __WXMSW__
        // As we captured the mouse, we may get the mouse events from outside
        // our window - for example, negative values in x, y. This has a weird
        // consequence under MSW where we use unsigned values sometimes and
        // signed ones other times: the coordinates turn as big positive
        // numbers and so the sash is drawn on the *right* side of the window
        // instead of the left (or bottom instead of top). Correct this.
        if ( (short)m_oldX < 0 )
            m_oldX = 0;
        if ( (short)m_oldY < 0 )
            m_oldY = 0;
#endif // __WXMSW__

        // Draw new one
        if ( !isLive )
        {
            m_sashPositionCurrent = posSashNew;

            DrawSashTracker(m_oldX, m_oldY);
        }
        else
        {
            DoSetSashPosition(posSashNew);
            m_needUpdating = true;
        }
    }
    else if ( event.LeftDClick() && m_windowTwo )
    {
        OnDoubleClickSash(x, y);
    }
}
コード例 #25
0
ファイル: AButton.cpp プロジェクト: ruthmagnus/audacity
void AButton::OnMouseEvent(wxMouseEvent & event)
{

  if (event.Leaving()){
      GetActiveProject()->TP_DisplayStatusMessage("",0);
   }


// In windows, Leave/Enter events appear to clobber each other,
// so the new enter event doesn't get processed.  If we change to a newer
// version of WXWINDOWS, (Post version 2), this may be fixed

#if defined __WXMSW__
   else {
#else
   else if (event.Entering()) {
#endif

   // Display the tooltip in the status bar
      wxString tip = this->GetToolTip()->GetTip();
      if (!mEnabled)
         tip += _(" (disabled)");
      GetActiveProject()->TP_DisplayStatusMessage(tip, 0);
   }

   //If the graphical button is disabled, or the button is down
   // the button can't process down events, get out of here.
   if (!mEnabled || (mButtonIsDown && !mProcessDownEvents) ) {
      this->Refresh(false);
      return;
   }

   //If the mouse button is released, the following stuff happens
   if (event.ButtonUp() ) {
      mIsClicking = false;
      ReleaseMouse();


      //Only process the event if you are releasing on the button--if you moved
      //off the button, dump the event.
      if (event.m_x >= 0 && event.m_y >= 0 &&
          event.m_x < mWidth && event.m_y < mHeight) {
      
         // Although this may be a little redundant, I'm segregating
         // two types of buttons for clarity
         // mProcessDownEvents=false buttons can only by pushed down-their pushing up must
         // be handled immediately, by the action of another button, or by
         // some other event (e.g., the file ending stops playing and pops up
         // the play button.
         // mProcessDownEvents=true buttons can be pushed down and then pushed up again
         // by clicking on them again once in the down state.
         if(mProcessDownEvents)
            {
               if(mButtonIsDown)
                  {
                     
                     //If the button is down, set the button state to up 
                     // and 'over'--highlighted.
                     mButtonState = AButtonOver;
                     mButtonIsDown = false;          
                  }
               else
                  {
                     //If the button is up, set the button state to down
                     mButtonState=AButtonDown;
                     mButtonIsDown=true;
                  }
            }
         else
            {
               //If it is a one-state button,
               //Set the button state to down undconditionally
               mButtonState = AButtonDown;
               mButtonIsDown = true;
            }

         mWasShiftDown = event.ShiftDown();

         //Create an event for the parent window to process.
         wxCommandEvent *e =
             new wxCommandEvent(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
         GetParent()->ProcessEvent(*e);
         delete e;
      }

      this->Refresh(false);
      return;
   }
      //This handles the mouse down event.
   else if (event.ButtonDown()) {
      mIsClicking = true;
      CaptureMouse();
   }


   //This following logic handles button in situations other than the 
   //up-click
   if (mProcessDownEvents)
      {
         if (mIsClicking) {
            if (event.m_x >= 0 && event.m_y >= 0 &&
                event.m_x < mWidth && event.m_y < mHeight) {
               mButtonState =  AButtonDown;
            } else
               mButtonState = mButtonIsDown ? AButtonDown: AButtonUp;
         }
         else {
            if (event.Entering())
               mButtonState = mButtonIsDown ? AButtonDown: AButtonOver;
            
            //If mouse leaves the button, put it in its previous state.
            else if (event.Leaving())
               mButtonState = mButtonIsDown ? AButtonDown: AButtonUp;
            
         }

      }
   else  //This is a push-down-only traditional button
      {
         if (mIsClicking) {
            if (event.m_x >= 0 && event.m_y >= 0 &&
                event.m_x < mWidth && event.m_y < mHeight) {
               mButtonState = AButtonDown;
            } else
               mButtonState = AButtonUp;
         }
         else {
            if (event.Entering())
               mButtonState = AButtonOver;
            else if (event.Leaving())
               mButtonState = AButtonUp;
         }
         
         
      }
   //Do a final Refresh() event
   this->Refresh(false);
   }

bool AButton::WasShiftDown()
{
   return mWasShiftDown;
}

void AButton::Enable()
{
   mEnabled = true;
   if (mButtonIsDown)
      mButtonState = AButtonDown;
   else
      mButtonState = AButtonUp;
   this->Refresh(false);
}
コード例 #26
0
void CGraphView::OnMouseEvent(wxMouseEvent &event)
{
	if(m_nMode==ARROW) {
		wxShapeCanvas::OnMouseEvent(event);
		return;
	}

	wxClientDC dc(this);
	PrepareDC(dc);
	int ch,cw;
	dc.GetSize(&cw,&ch);
	
	wxPoint logPos(event.GetLogicalPosition(dc));
	
	double x, y;
	x = (double) logPos.x;
	y = (double) logPos.y;
	
	int keys = 0;
	if (event.ShiftDown())
		keys = keys | KEY_SHIFT;
	if (event.ControlDown())
		keys = keys | KEY_CTRL;
	
	bool dragging = event.Dragging();
	
	
    // Find the nearest object
	if(event.IsButton()) {
		if(event.RightDown()) {
			
			if(m_pHoverShape) {
				CNodeEvent evt;
				evt.SetEventType(GV_NODE_MENU);
				evt.SetNode(m_pHoverShape->GetId());
				evt.SetPosition(event.GetPosition());
				AddPendingEvent(evt);
			}

		} else if(event.LeftDClick()) {

			if(m_pHoverShape) {

				CNodeEvent evt;
				evt.SetEventType(GV_NODE_ACTIVATED);
				evt.SetNode(m_pHoverShape->GetId());
				evt.SetPosition(event.GetPosition());
				AddPendingEvent(evt);
			}
			
		} else if(event.LeftDown()) {
			
			if(m_pHoverShape) {
				m_pClickShape=m_pHoverShape;
				return;

			} else {
				m_pClickShape=NULL;
			
				if(event.ShiftDown()) {
					//m_bZooming=true;
					//m_ptGrab=event.GetPosition();
					//UpdateCursor();
					//CaptureMouse();
				} else {
					m_bGrabbing=true;
					m_ptGrab=event.GetPosition();
					int vx,vy;
					GetViewStart(&vx,&vy);
					m_ptGrabLogical=wxPoint(vx,vy);
					UpdateCursor();
					CaptureMouse();
				}
				return;
			}
		} else if(event.LeftUp()) {

			if(m_pClickShape && (m_pClickShape==m_pHoverShape)) {	
				CNodeEvent evt;
				evt.SetEventType(GV_NODE_SELECTED);
				evt.SetNode(m_pHoverShape->GetId());
				evt.SetPosition(event.GetPosition());
				AddPendingEvent(evt);
				return;
			}

			if(m_bGrabbing || m_bZooming) {
				ReleaseMouse();
			}
			m_bZooming=false;
			m_bGrabbing=false;
			UpdateCursor();

		}
		
//		if(nearest_object) {
		

//		}

		return;
	} else if(event.Moving()) {
	
		if(m_bGrabbing) {
			int nx,ny;
			event.GetPosition(&nx,&ny);
			nx=nx-m_ptGrab.x;
			ny=ny-m_ptGrab.y;
			
			int vx,vy;
			vx=m_ptGrabLogical.x-nx;
			vy=m_ptGrabLogical.y-ny;

			Scroll(vx,vy);
			UpdateCursor();
		} else if(m_bZooming) {
		/*	int nx,ny;
			event.GetPosition(&nx,&ny);
			nx=nx-m_ptGrab.x;
			ny=ny-m_ptGrab.y;
			
			double scale;
			if(ny>0.0) {
				scale=1.0+3.0*(ny/(ch/2.0));
			} else {
				scale=1.0-0.75*(-ny/(ch/2.0));
			}
			
			int vsx,vsy;
			GetViewStart(&vsx,&vsy);
				
			vsx=vsx*scale/m_diag.GetZoomFactor();
			vsy=vsy*scale/m_diag.GetZoomFactor();

			m_diag.SetZoomFactor(scale);
			SetScrollbars(1,1,m_nGraphWidth*scale,m_nGraphHeight*scale,vsx,vsy,true);
			Refresh(true);
			*/
		} else {

			int attachment=0;
			wxShape *shape=FindShape(x,y,&attachment,NULL,NULL,CLASSINFO(wxLineShape));
			if(shape!=m_pHoverShape) {
				m_pHoverShape=shape;
				UpdateCursor();
			}
			

		}

	} else if(event.Entering()) {
		UpdateCursor();	
	}

	

}
コード例 #27
0
void wxMoldeoPinCtrl::OnMouseEvent( wxMouseEvent & event ) {

    //wxMessageBox("wxMoldeoPinCtrl::Mouse event");

    if ( event.Entering() ) {
        //SHINE!!!

    }

/*
    if (event.LeftDown() && !m_bLeftSizeDragging) {
        m_bLeftSizeDragging = (-1<=event.GetX() && event.GetX()<=3);
        Refresh();
    }
    if (event.LeftUp() && m_bLeftSizeDragging) {
        m_bLeftSizeDragging = false;
        Refresh();
    }

    if (event.LeftDown() && !m_bRightSizeDragging) {
        m_bRightSizeDragging = ( (GetSize().GetX()-5)<event.GetX() && event.GetX()<=(GetSize().GetX()+2) );
        Refresh();
    }
    if (event.LeftUp() && m_bRightSizeDragging) {
        m_bRightSizeDragging = false;
        Refresh();
    }
*/

    if (event.LeftDown() && !m_bMovingDragging) {
        m_bMovingDragging = ( 3<event.GetX() && event.GetX()<=(GetSize().GetX()-3) ) && ( 3<event.GetY() && event.GetY()<=(GetSize().GetY()-3) );
        Px = event.GetX();
        Py = event.GetY();
        Refresh();
    }
    if (event.LeftUp() && m_bMovingDragging) {
        m_bMovingDragging = false;
        Refresh();
    }

/*
    if ((0<event.GetX() && event.GetX()<=3) ||
    ( (GetSize().GetX()-3)<event.GetX() && event.GetX()<=(GetSize().GetX()+2) )) {
        //
        //m_bRightSizeDragging = false;
        //m_bLeftSizeDragging = true;
        this->SetCursor( wxCursor(wxCURSOR_SIZEWE) );

    } else this->SetCursor( wxCursor() );

    */
    /* else if ( (GetSize().GetX()-3)<event.GetX() && event.GetX()<=GetSize().GetX() ) {
            m_bRightSizeDragging = true;
            m_bLeftSizeDragging = false;
    } else {
        m_bRightSizeDragging = false;
        m_bLeftSizeDragging = false;
    }*/

    /*if ( m_bLeftSizeDragging || m_bRightSizeDragging ) {
        this->SetCursor( wxCursor(wxCURSOR_SIZEWE) );
    } else this->SetCursor( wxCursor() );
*/

    /*
    if (event.Button(wxMOUSE_BTN_RIGHT )) {
        SetValue( SlideValue( event.GetX() ) );
        Refresh();
    }

    if (event.Button(wxMOUSE_BTN_LEFT )) {
        SetPlayValue( GetSlideValueToPlayValue( SlideValue( event.GetX() ) ) );
        //moSetDuration( m_play_value );
        //moAbstract::MODebug2->Push( IntToStr(m_play_value) );
        Refresh();
    }*/

    if (event.Dragging()) {
        /*if (event.RightIsDown()) {

            (if (m_bStartDragging==false) {
                m_bStartDragging = true;
                wxWindow::CaptureMouse();
            }
            SetValue( SlideValue( event.GetX() ) );
            Refresh();
        }*/

        if (event.LeftIsDown()) {

            if (m_bStartDragging==false) {
                m_bStartDragging = true;

                //m_bRightSizeDragging = ( (GetSize().GetX()-3)<event.GetX() && event.GetX()<=GetSize().GetX() );
                //wxWindow::CaptureMouse();

                wxCommandEvent event( wxEVT_MOLDEOPIN_BEGINDRAGLEFT, m_windowId );
                event.SetClientData( NULL );
                event.SetEventObject( this );
#if wxMAJOR_VERSION>=3
#else
                GetParent()->GetParent()->AddPendingEvent( event );
#endif

/*
                wxDropSource dragSource( this );
                wxTextDataObject dobject;
                dobject.SetText("Drag an drop text");
                dragSource.SetData( dobject );
                wxDragResult result = dragSource.DoDragDrop( TRUE );
*/

            }

            /*

            wxCommandEvent event( wxEVT_MOLDEOPIN_DRAGLEFT, m_windowId );
            event.SetClientData( NULL );
            event.SetEventObject( this );
            GetParent()->GetParent()->AddPendingEvent( event );
            */

            wxPoint PW = GetPosition();
            wxSize  SW = GetSize();

/*
            if ( (SW.GetX()-event.GetX())>0 && m_bLeftSizeDragging) {
                SetSize( PW.x+event.GetX(), PW.y, SW.GetX()-event.GetX(), SW.GetY() );
            }
            if ( event.GetX()>0 && m_bRightSizeDragging) {
                SetSize( PW.x, PW.y, event.GetX(), SW.GetY() );
            }
            */
            //if ( m_bMovingDragging) {
                //SetSize( GetParent()->ScreenToClient(wxGetMousePosition()).x-Px, GetParent()->ScreenToClient(wxGetMousePosition()).y-Py, SW.GetX(), SW.GetY() );


            //}

            //SetPlayValue( GetSlideValueToPlayValue( SlideValue( event.GetX() ) ) );
            //moSetDuration( m_play_value );
            Refresh();
        }
    }

    /*if (!event.Dragging()) {
        if (m_bStartDragging==true) {
            m_bStartDragging = false;
            wxCommandEvent event( wxEVT_MOLDEOPIN_ENDDRAGLEFT, m_windowId );
            event.SetClientData( NULL );
            event.SetEventObject( this );
            GetParent()->GetParent()->AddPendingEvent( event );
            //wxWindow::ReleaseMouse();
        }
    }*/


    event.Skip();
}
コード例 #28
0
ファイル: slider_bar.cpp プロジェクト: alcoheca/sooperlooper
void
SliderBar::OnMouseEvents (wxMouseEvent &ev)
{
    if (!IsEnabled()) {
        ev.Skip();
        return;
    }

    if (ev.Entering() && !_dragging) {
        _barbrush.SetColour(_overbarcolor);
        do_redraw();
    }
    else if (ev.Leaving() && !_dragging) {
        _barbrush.SetColour(_barcolor);
        do_redraw();
    }



    if (ev.Dragging() && _dragging)
    {
        int delta = ev.GetX() - _last_x;
        float fdelta = delta * _val_scale;

        if (ev.ControlDown()) {
            fdelta *= 0.5f;
            if (ev.ShiftDown()) {
                fdelta *= 0.5f;
            }
        }

        float newval = _value + fdelta;

        //cerr << "dragging: " << ev.GetX() << "  " << delta << "  " << fdelta << "  "  << newval << endl;

        if (_snap_mode == IntegerSnap) {
            newval = nearbyintf (newval);
        }

        newval = max (min (newval, _upper_bound), _lower_bound);

        if (newval != _value) {
            _value = newval;

            value_changed (get_value()); // emit

            update_value_str();
            do_redraw();
            //cerr << "new val is: " << _value << endl;


            _last_x = ev.GetX();
        }
    }
    else if (ev.Moving()) {
        // do nothing
    }
    else if (ev.GetEventType() == wxEVT_MOUSEWHEEL)
    {
        float fscale = 0.02f * (ev.ControlDown() ? 0.5f: 1.0f);
        float newval;

        if (_snap_mode == IntegerSnap) {
            newval = _value + ((ev.GetWheelRotation() > 0) ? 1 : -1);
        }
        else {
            if (ev.GetWheelRotation() > 0) {
                newval = _value + (_upper_bound - _lower_bound) * fscale;
            }
            else {
                newval = _value - (_upper_bound - _lower_bound) * fscale;
            }
        }


        if (_snap_mode == IntegerSnap) {
            newval = nearbyintf (newval);
        }

        newval = max (min (newval, _upper_bound), _lower_bound);


        _value = newval;

        value_changed (get_value()); // emit

        update_value_str();
        do_redraw();
    }
    else if (ev.RightDown()) {
        this->PopupMenu ( _popup_menu, ev.GetX(), ev.GetY());
    }
    else if (ev.RightUp()) {
        //this->PopupMenu ( _popup_menu, ev.GetX(), ev.GetY());
    }
    else if (ev.ButtonDown())
    {
        CaptureMouse();
        _dragging = true;
        _last_x = ev.GetX();
        pressed(); // emit

        if (ev.MiddleDown() && !ev.ControlDown()) {
            // set immediately
            float newval = (ev.GetX() * _val_scale) + _lower_bound;

            if (_snap_mode == IntegerSnap) {
                newval = nearbyintf (newval);
            }

            _value = newval;

            value_changed (get_value()); // emit

            update_value_str();
            do_redraw();
        }
        else if (ev.LeftDown() && ev.ShiftDown()) {
            // set to default
            _value = max (min (_default_val, _upper_bound), _lower_bound);

            value_changed(get_value());
            update_value_str();
            do_redraw();
        }
    }
    else if (ev.ButtonUp())
    {
        _dragging = false;
        ReleaseMouse();

        if (_use_pending) {
            // This didn't really work
            //if (_pending_val != _value) {
            //	_value = _pending_val;
            //	update_value_str();
            //}
            _use_pending = false;
        }


        if (ev.GetX() >= _width || ev.GetX() < 0
                || ev.GetY() < 0 || ev.GetY() > _height) {
            _barbrush.SetColour(_barcolor);
            do_redraw();
        }
        else {
            _barbrush.SetColour(_overbarcolor);
            do_redraw();
        }

        if (ev.MiddleUp() && ev.ControlDown())
        {
            // binding click
            bind_request(); // emit
        }

        released(); // emit
    }
    else if (ev.ButtonDClick()) {
        // this got annoying
        //show_text_ctrl ();
    }
    else {
        ev.Skip();
    }
}
コード例 #29
0
ファイル: Meter.cpp プロジェクト: ruthmagnus/audacity
void Meter::OnMouse(wxMouseEvent &evt)
{
  #if wxUSE_TOOLTIPS // Not available in wxX11
   if (evt.Leaving()){
      GetActiveProject()->TP_DisplayStatusMessage(wxT(""));
   }
   else if (evt.Entering()) {
      // Display the tooltip in the status bar
      wxToolTip * pTip = this->GetToolTip();
      if( pTip ) {
         wxString tipText = pTip->GetTip();
         GetActiveProject()->TP_DisplayStatusMessage(tipText);
      }
   }
  #endif

   #if WANT_METER_MENU
      if (evt.RightDown() ||
          (evt.ButtonDown() && mMenuRect.Inside(evt.m_x, evt.m_y))) 
      {
         wxMenu *menu = new wxMenu();
         // Note: these should be kept in the same order as the enum
         if (mMeterDisabled)
            menu->Append(OnDisableMeterID, _("Enable Meter"));
         else
            menu->Append(OnDisableMeterID, _("Disable Meter"));
         if (mIsInput) {
            if (gAudioIO->IsMonitoring())
               menu->Append(OnMonitorID, _("Stop Monitoring"));
            else
               menu->Append(OnMonitorID, _("Start Monitoring"));
         }
         menu->AppendSeparator();

         menu->Append(OnHorizontalID, _("Horizontal Stereo"));
         menu->Append(OnVerticalID, _("Vertical Stereo"));
         //menu->Append(OnMultiID, _("Vertical Multichannel"));
         //menu->Append(OnEqualizerID, _("Equalizer"));
         //menu->Append(OnWaveformID, _("Waveform"));
         //menu->Enable(OnHorizontalID + mStyle, false);
         menu->Enable(mStyle==VerticalStereo? OnVerticalID: OnHorizontalID, false);
         menu->AppendSeparator();

         menu->Append(OnLinearID, _("Linear"));
         menu->Append(OnDBID, _("dB"));
         menu->Enable(mDB? OnDBID: OnLinearID, false);
         //menu->AppendSeparator();
         //menu->Append(OnClipID, _("Turn on clipping"));
         //menu->AppendSeparator();
         //menu->Append(OnFloatID, _("Float Window"));

         menu->AppendSeparator();
         menu->Append(OnPreferencesID, _("Preferences..."));


         if (evt.RightDown())
            PopupMenu(menu, evt.m_x, evt.m_y);
         #if WANT_METER_MENU
            else
               PopupMenu(menu, mMenuRect.x + 1, mMenuRect.y + mMenuRect.height + 1);
         #endif // WANT_METER_MENU
         delete menu;
      }       
      else 
   #endif // WANT_METER_MENU

   if (evt.ButtonDown()) {
      if (mIsInput)
         StartMonitoring();
   }
}
コード例 #30
0
ファイル: klsGLCanvas.cpp プロジェクト: T145/cygic
void klsGLCanvas::wxOnMouseEvent(wxMouseEvent& event) {
	reclaimViewport();
	
	isShiftDown = event.ShiftDown();
	isControlDown = event.ControlDown();
	
	// Always set the mouse coords to the current event:
	setMouseScreenCoords( event.GetPosition() );
	setMouseCoords();

	// Check all of the button events:
	if( event.LeftDown() ) {
		mouseOutOfWindow = false; // Assume that we clicked inside the window!
		beginDrag( BUTTON_LEFT );
		OnMouseDown( event ); // Call the event handler.
	} else if( event.LeftUp() || event.LeftDClick() ) {
		endDrag( BUTTON_LEFT );
		OnMouseUp( event );
	} else if( event.RightDown() || event.RightDClick() ) {
		beginDrag( BUTTON_RIGHT );
		OnMouseDown( event ); // Call the event handler.
	} else if( event.RightUp() ) {
		endDrag( BUTTON_RIGHT );
		OnMouseUp( event );
	} else if( event.MiddleDown() || event.MiddleDClick() ) {
		beginDrag( BUTTON_MIDDLE );
		OnMouseDown( event ); // Call the event handler.
		if( event.MiddleDClick() ) {
			// Debugging screen shot code.
			// I left it in because it was nifty to have around, especially
			// for writing documentation.	
			// Render the canvas to a bitmap and save it:
			wxSize sz = GetClientSize();
			wxImage screenShot = renderToImage(sz.GetWidth(), sz.GetHeight());
			wxBitmap myBMP( screenShot );
			myBMP.SaveFile( "screen_shot.bmp", wxBITMAP_TYPE_BMP );
		}
		
	} else if( event.MiddleUp() ) {
		endDrag( BUTTON_MIDDLE );
		OnMouseUp( event );
	} else {
		// It's not a button event, so check the others:
		if( event.Entering() ) {
			mouseOutOfWindow = false;
			scrollTimer->Stop();
			OnMouseEnter( event );
		} else if( event.Leaving() && !isDragging( BUTTON_MIDDLE ) ) { // Don't allow auto-scroll during pan-scrolling.
			// Flag the scroll event by telling it that the
			// mouse has left the window:
			mouseOutOfWindow = true;

			// Start the scroll timer:
			if( isAutoScrollOn() && isDragging( BUTTON_LEFT ) ) {
				scrollTimer->Start(SCROLL_TIMER_RATE);
			}

			// Call the event handler:
			OnMouseLeave( event );
		} else {
			// Handle the drag-pan event here if needed:
			if( isDragging( BUTTON_MIDDLE ) ) {
				GLPoint2f mouseDelta( getMouseCoords().x - getDragStartCoords( BUTTON_MIDDLE ).x,
										getMouseCoords().y - getDragStartCoords( BUTTON_MIDDLE ).y );

				translatePan( -mouseDelta.x, -mouseDelta.y );
			}
			
			// It's nothing else, so it must be a mouse motion event:
			GLPoint2f m = getMouseCoords();
			OnMouseMove(m.x, m.y, event.ShiftDown(), event.ControlDown());
		}
		
	}

// Refresh the canvas to show the mouse drag highlights if needed:
#ifdef CANVAS_DEBUG_TESTS_ON
	Refresh();
#endif

}