Beispiel #1
0
bool Interactor2D::ProcessMouseDownEvent( wxMouseEvent& event, RenderView* renderview )
{
  RenderView2D* view = ( RenderView2D* )renderview;

  m_nMousePosX = event.GetX();
  m_nMousePosY = event.GetY();

  view->UpdateAnnotation();

  if ( event.CmdDown() && !event.ShiftDown() )
  {
    if ( event.LeftDown() )
    {
      view->ZoomAtCursor( m_nMousePosX, m_nMousePosY, true );
      return false;
    }
    else if ( event.RightDown() )
    {
      view->ZoomAtCursor( m_nMousePosX, m_nMousePosY, false );
      return false;
    }
  }

  if ( event.LeftDown() )
  {
    m_nDownPosX = m_nMousePosX;
    m_nDownPosY = m_nMousePosY;

    if ( event.ShiftDown() && !event.CmdDown() )
    {
      m_bWindowLevel = true;
    }
    else
    {
      m_bMovingCursor = true;
      view->UpdateCursorRASPosition( m_nMousePosX, m_nMousePosY );
      view->NeedRedraw();
    }
  }
  else if ( event.MiddleDown() && event.ShiftDown() )
  {
      m_bSelecting = true;
      view->StartSelection( m_nMousePosX, m_nMousePosY );
  }
  else if ( event.RightDown() && event.ShiftDown() && !event.CmdDown() )
  {
    m_bWindowLevel = true;
  }
  else
  {
    return Interactor::ProcessMouseDownEvent( event, renderview ); // pass down the event
  }

  return false; // do not pass down the event
}
void PicViewCtrl::OnMouseWheel(wxMouseEvent& event)
{
    if(m_bClearFlag)
    {
        event.Skip();
        return;
    }
    int direction = event.GetWheelRotation();
    int delta     = event.GetWheelDelta();
    if(event.CmdDown()) // scale
    {
        double bigger = (direction/delta)*m_dScaleRateStep;
        double rate   = ((m_dScaleRate + bigger) > m_dMaxScaleRate ? m_dMaxScaleRate : (m_dScaleRate + bigger));
        rate          = rate < m_dMinScaleRate ? m_dMinScaleRate : rate;
        if(fabs(rate - m_dScaleRate) > MINDIFF)
            m_bFitMode = false;
        ChangeScaleRate(rate);
        SetRulerCtrlFited();
    }
    else
    {
        if(m_bMouseWheelPageUpDown)
        {
            int pages = -(direction/delta);
            ShowPageByDiffNumber(pages);
        }
        else
            event.Skip();
    }
}
Beispiel #3
0
/* InputKeyCtrl::onMouseDown
 * Called when a mouse button is clicked in the control
 *******************************************************************/
void InputKeyCtrl::onMouseDown(wxMouseEvent& e)
{
	// Middle button
	if (e.GetEventType() == wxEVT_MIDDLE_DOWN)
		key.key = "mouse3";

	// Button 4
	else if (e.GetEventType() == wxEVT_AUX1_DOWN)
		key.key = "mouse4";

	// Button 5
	else if (e.GetEventType() == wxEVT_AUX2_DOWN)
		key.key = "mouse5";

	// Mouse wheel
	else if (e.GetEventType() == wxEVT_MOUSEWHEEL)
	{
		if (e.GetWheelRotation() > 0)
			key.key = "mwheelup";
		else if (e.GetWheelRotation() < 0)
			key.key = "mwheeldown";
	}

	key.alt = e.AltDown();
	key.ctrl = e.CmdDown();
	key.shift = e.ShiftDown();
	SetValue(key.as_string());
}
Beispiel #4
0
void ctlSQLGrid::OnMouseWheel(wxMouseEvent &event)
{
	if (event.ControlDown() || event.CmdDown())
	{
		wxFont fontlabel = GetLabelFont();
		wxFont fontcells = GetDefaultCellFont();
		if (event.GetWheelRotation() > 0)
		{
			fontlabel.SetPointSize(fontlabel.GetPointSize() - 1);
			fontcells.SetPointSize(fontcells.GetPointSize() - 1);
		}
		else
		{
			fontlabel.SetPointSize(fontlabel.GetPointSize() + 1);
			fontcells.SetPointSize(fontcells.GetPointSize() + 1);
		}
		SetLabelFont(fontlabel);
		SetDefaultCellFont(fontcells);
		SetColLabelSize(fontlabel.GetPointSize() * 4);
		SetDefaultRowSize(fontcells.GetPointSize() * 2);
		for (int index = 0; index < GetNumberCols(); index++)
			SetColSize(index, -1);
		ForceRefresh();
	}
	else
		event.Skip();
}
Beispiel #5
0
void AudioBox::OnMouseWheel(wxMouseEvent &evt) {
	if (!ForwardMouseWheelEvent(audioDisplay, evt))
		return;

	bool zoom = evt.CmdDown() != OPT_GET("Audio/Wheel Default to Zoom")->GetBool();
	if (!zoom)
	{
		int amount = -evt.GetWheelRotation() * GetClientSize().GetWidth() / (evt.GetWheelDelta() * 3);
		// If the user did a horizontal scroll the amount should be inverted
		// for it to be natural.
		if (evt.GetWheelAxis() == 1) amount = -amount;

		// Reset any accumulated zoom
		mouse_zoom_accum = 0;

		audioDisplay->ScrollBy(amount);
	}
	else if (evt.GetWheelAxis() == 0)
	{
		mouse_zoom_accum += evt.GetWheelRotation();
		int zoom_delta = mouse_zoom_accum / evt.GetWheelDelta();
		mouse_zoom_accum %= evt.GetWheelDelta();
		int new_zoom = audioDisplay->GetZoomLevel() + zoom_delta;
		audioDisplay->SetZoomLevel(new_zoom);
		HorizontalZoom->SetValue(-new_zoom);
		OPT_SET("Audio/Zoom/Horizontal")->SetInt(new_zoom);
	}
}
Beispiel #6
0
void DendrogramPanel::OnEvent( wxMouseEvent& event )
{
    if (event.LeftDown()) {
        isLeftDown = true;
        
        startPos = event.GetPosition();
        // test SplitLine
        if (split_line) {
            if (split_line->contains(startPos)) {
                isMovingSplitLine = true;
            }
        }
        if (!isMovingSplitLine) {
			// test end_nodes
            if ( !event.ShiftDown() && !event.CmdDown() ) {
                hl_ids.clear();
            }
			for (int i=0;i<end_nodes.size();i++) {
				if (end_nodes[i]->contains(startPos)) {
                    hl_ids.push_back(end_nodes[i]->idx);
				}
			}
            // highlight i selected
            wxWindow* parent = GetParent();
            while (parent) {
                wxWindow* w = parent;
                HClusterDlg* dlg = dynamic_cast<HClusterDlg*>(w);
                if (dlg) {
                    dlg->Highlight(hl_ids);
                    break;
                }
                parent = w->GetParent();
            }
        }
    } else if (event.Dragging()) {
        if (isLeftDown) {
            isLeftMove = true;
            // moving
            if (isMovingSplitLine && split_line) {
                split_line->move(event.GetPosition(), startPos);
                int x = split_line->getX();
                Refresh();
                OnSplitLineChange(x);
            }
            startPos = event.GetPosition();
        }
    } else if (event.LeftUp()) {
        if (isLeftMove) {
            isLeftMove = false;
            // stop move
            isMovingSplitLine = false;
        } else {
            // only left click
        }
        isLeftDown = false;
    }
}
bool Interactor3DMeasure::ProcessMouseDownEvent( wxMouseEvent& event, RenderView* renderview )
{
  RenderView3D* view = ( RenderView3D* )renderview;

  bool ret = Interactor3D::ProcessMouseDownEvent( event, renderview );

  if ( m_nAction == MM_SurfaceRegion && !Interactor3D::IsInAction() && event.LeftDown() )
  {
    if ( event.CmdDown() && !event.ShiftDown() )
    {
      if ( view->InitializeSelectRegion( event.GetX(), event.GetY() ) )
      {
        m_bSelectRegion = true;
        return false;   // do not pass down the event
      }
    }
    else if ( event.CmdDown() && event.ShiftDown() )
    {
      LayerMRI* mri = (LayerMRI*)MainWindow::GetMainWindowPointer()->GetActiveLayer( "MRI" );
      if ( mri && mri->GetCurrentSurfaceRegion() )
      {
        mri->GetCurrentSurfaceRegion()->ResetOutline();
        m_bSelectRegion = true;
        return false;
      }
    }
    else if ( !event.CmdDown() && event.ShiftDown() )
    {
      LayerMRI* mri = (LayerMRI*)MainWindow::GetMainWindowPointer()->GetActiveLayer( "MRI" );
      if ( mri && mri->GetCurrentSurfaceRegion() )
      {
        if ( mri->GetCurrentSurfaceRegion()->DeleteCell( view, event.GetX(), event.GetY() ) )
          view->NeedRedraw();
        return false;
      }
    }
  }
   
  return ret;
}
Beispiel #8
0
void ParameterPanel::OnMouseWheel(wxMouseEvent &event)
{
    double change = 1e-5 * event.GetWheelRotation();
    if (event.ShiftDown())
        change *= 10;
    if (event.CmdDown())
        change *= 100;
    if (event.AltDown())
        change /= 20;
    int n = find_in_rows(event.GetEventObject());
    double new_value = values_[n] + fabs(values_[n]) * change;
    set_value(n, new_value);
    observer_->on_parameter_changed(n);
}
void PanosphereOverviewCameraTool::MouseButtonEvent(wxMouseEvent &e)
{
//    DEBUG_DEBUG("mouse ov drag button");
    if ((e.ButtonDown() && (!helper->IsMouseOverPano() || e.CmdDown() || e.AltDown())) || e.MiddleDown()) {
        down = true;
        hugin_utils::FDiff2D pos = helper->GetMouseScreenPosition();
        start_x = pos.x;
        start_y = pos.y;
        PanosphereOverviewVisualizationState*  state = (PanosphereOverviewVisualizationState*) helper->GetVisualizationStatePtr();
        start_angx = state->getAngX();
        start_angy = state->getAngY();
    }
    if (e.ButtonUp()) {
        if (down) {
            down = false;
        }
    }
}
void PlaneOverviewCameraTool::MouseButtonEvent(wxMouseEvent &e)
{
    PlaneOverviewToolHelper * thelper = (PlaneOverviewToolHelper*) helper;
    PlaneOverviewVisualizationState*  state = (PlaneOverviewVisualizationState*) helper->GetVisualizationStatePtr();
//    DEBUG_DEBUG("mouse ov drag button");
    if (((e.CmdDown() || e.AltDown()) && e.LeftDown()) || e.MiddleDown()) {
        down = true;
        start_x = thelper->getPlaneX();
        start_y = thelper->getPlaneY();
        start_pos_x = state->getX();
        start_pos_y = state->getY();
    }
    if (e.LeftUp() || e.MiddleUp()) {
        if (down) {
            down = false;
        }
    }
}
Beispiel #11
0
void Waveform::mouseWheelMoved(wxMouseEvent& event)
{
    if(event.CmdDown())
    {
        int i = event.GetWheelRotation();
        if(i<0)
        {
            wxCommandEvent eventZoom(EVT_ZOOM);
            eventZoom.SetInt(ZOOM_OUT);
            wxPostEvent(mParent, eventZoom);
        }
        else
        {
            wxCommandEvent eventZoom(EVT_ZOOM);
            eventZoom.SetInt(ZOOM_IN);
            wxPostEvent(mParent, eventZoom);
        }
    }
    else if(event.ShiftDown())
    {
        int i = event.GetWheelRotation();
        if(i<0)
        {
            wxCommandEvent eventScroll(EVT_GSCROLL);
            eventScroll.SetInt(SCROLL_RIGHT);
            wxPostEvent(mParent, eventScroll);
        }
        else
        {
            wxCommandEvent eventScroll(EVT_GSCROLL);
            eventScroll.SetInt(SCROLL_LEFT);
            wxPostEvent(mParent, eventScroll);
        }
    }
    else
    {
        wxPostEvent(GetParent()->GetEventHandler(), event);
        event.Skip();
    }
}
Beispiel #12
0
PlatformMouseEvent::PlatformMouseEvent(const wxMouseEvent& event, const wxPoint& globalPoint)
    : m_position(event.GetPosition())
    , m_globalPosition(globalPoint)
    , m_shiftKey(event.ShiftDown())
    , m_ctrlKey(event.CmdDown())
    , m_altKey(event.AltDown())
    , m_metaKey(event.MetaDown()) // FIXME: We'll have to test other browsers
{
    wxEventType type = event.GetEventType();
    m_eventType = MouseEventMoved;
    
    if (type == wxEVT_LEFT_DOWN || type == wxEVT_MIDDLE_DOWN || type == wxEVT_RIGHT_DOWN)
        m_eventType = MouseEventPressed;
    
    else if (type == wxEVT_LEFT_UP || type == wxEVT_MIDDLE_UP || type == wxEVT_RIGHT_UP || 
                type == wxEVT_LEFT_DCLICK || type == wxEVT_MIDDLE_DCLICK || type == wxEVT_RIGHT_DCLICK)
        m_eventType = MouseEventReleased;

    else if (type == wxEVT_MOTION)
        m_eventType = MouseEventMoved;

    if (event.Button(wxMOUSE_BTN_LEFT))
        m_button = LeftButton;
    else if (event.Button(wxMOUSE_BTN_RIGHT))
        m_button = RightButton;
    else if (event.Button(wxMOUSE_BTN_MIDDLE))
        m_button = MiddleButton;
    else if (!m_eventType == MouseEventMoved)
        ASSERT_NOT_REACHED();


    if (m_eventType == MouseEventMoved)
        m_clickCount = 0;
    else
        m_clickCount = event.ButtonDClick() ? 2 : 1;

    m_timestamp = WebCore::currentTime();
}
void CMusikListCtrl::SelectClickedItem(wxMouseEvent &event)
{
	int HitFlags = 0;
	long item = HitTest(event.GetPosition(),HitFlags);
	if(item != -1)
	{
        if((wxLIST_STATE_SELECTED & GetItemState(item,wxLIST_STATE_SELECTED)) != wxLIST_STATE_SELECTED) // bug in MSW GetItemState (mask param is ignored)
        {    
            if(!event.CmdDown())
            {
                int i = -1;
                while ( -1 != (i = GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED)))
                {
                    if(i != item)
                        SetItemState( i, 0, wxLIST_STATE_SELECTED );
                }

            }
            SetItemState(item,wxLIST_STATE_SELECTED,wxLIST_STATE_SELECTED);
            wxTheApp->Yield(true);   // call yield to let the SetItemState changes go through the system.
        }
    }
}
Beispiel #14
0
void SpectraDocumentFrame::HandleMouseMotion(const wxMouseEvent& event)
{
	wxSize size = gl_canvas->GetSize();
	wxPoint new_mouse_position = event.GetPosition();

	int new_x = ClampMouseCoord(new_mouse_position.x, size.GetWidth());
	int new_y = ClampMouseCoord(new_mouse_position.y, size.GetHeight());
	if(event.Dragging())
	{
		int old_x = ClampMouseCoord(old_mouse_position.x, size.GetWidth());
		int old_y = ClampMouseCoord(old_mouse_position.y, size.GetHeight());

		if(event.CmdDown())
		{
			if(event.LeftIsDown())
			{
				if(event.AltDown())
				{
					document_view.StretchRange(new_x, new_y, old_x, old_y);
				}
				else
				{
					document_view.StretchDomain(new_x, new_y, old_x, old_y);
				}
			}
		}
		else
		{
			if(event.LeftIsDown())
			{
				if(event.AltDown())
				{
					document_view.Elevate(new_x, new_y, old_x, old_y);
				}
				else
				{
					document_view.Slide(new_x, new_y, old_x, old_y);
				}
			}
			else if(event.MiddleIsDown())
			{
				document_view.Scale(new_x, new_y, old_x, old_y);
			}
			else if(event.RightIsDown())
			{
				document_view.Orbit(new_x, new_y, old_x, old_y);
			}
		}
	}
	else
	{
		float t = 0.0f;
		if(event.AltDown())
		{
			t = document_view.PickOnWall(new_x, new_y).x();
		}
		else
		{
			t = document_view.PickOnGround(new_x, new_y).x();
		}
		t /= document_view.TimeStretch();
		SetStatus(wxString::Format(wxGetTranslation(wxT("Time: %f [s]")), t));
		document_vis->SelectedTime(t);
	}
}
Beispiel #15
0
void VisualTool<FeatureType>::OnMouseEvent(wxMouseEvent &event) {
	bool left_click = event.LeftDown();
	bool left_double = event.LeftDClick();
	shift_down = event.ShiftDown();
	ctrl_down = event.CmdDown();
	alt_down = event.AltDown();

	mouse_pos = event.GetPosition();

	if (event.Leaving()) {
		mouse_pos = Vector2D();
		parent->Render();
		return;
	}

	if (!dragging) {
		int max_layer = INT_MIN;
		active_feature = nullptr;
		for (auto& feature : features) {
			if (feature.IsMouseOver(mouse_pos) && feature.layer >= max_layer) {
				active_feature = &feature;
				max_layer = feature.layer;
			}
		}
	}

	if (dragging) {
		// continue drag
		if (event.LeftIsDown()) {
			for (auto sel : sel_features)
				sel->UpdateDrag(mouse_pos - drag_start, shift_down);
			for (auto sel : sel_features)
				UpdateDrag(sel);
			Commit();
		}
		// end drag
		else {
			dragging = false;

			// mouse didn't move, fiddle with selection
			if (active_feature && !active_feature->HasMoved()) {
				// Don't deselect stuff that was selected in this click's mousedown event
				if (!sel_changed) {
					if (ctrl_down)
						RemoveSelection(active_feature);
					else
						SetSelection(active_feature, true);
				}
			}

			active_feature = nullptr;
			parent->ReleaseMouse();
			parent->SetFocus();
		}
	}
	else if (holding) {
		if (!event.LeftIsDown()) {
			holding = false;

			parent->ReleaseMouse();
			parent->SetFocus();
		}

		UpdateHold();
		Commit();

	}
	else if (left_click) {
		drag_start = mouse_pos;

		// start drag
		if (active_feature) {
			if (!sel_features.count(active_feature)) {
				sel_changed = true;
				SetSelection(active_feature, !ctrl_down);
			}
			else
				sel_changed = false;

			if (active_feature->line)
				c->selectionController->SetActiveLine(active_feature->line);

			if (InitializeDrag(active_feature)) {
				for (auto sel : sel_features) sel->StartDrag();
				dragging = true;
				parent->CaptureMouse();
			}
		}
		// start hold
		else {
			if (!alt_down && features.size() > 1) {
				sel_features.clear();
				c->selectionController->SetSelectedSet({ c->selectionController->GetActiveLine() });
			}
			if (active_line && InitializeHold()) {
				holding = true;
				parent->CaptureMouse();
			}
		}
	}

	if (active_line && left_double)
		OnDoubleClick();

	parent->Render();

	// Only coalesce the changes made in a single drag
	if (!event.LeftIsDown())
		commit_id = -1;
}
bool Interactor2DMeasure::ProcessMouseDownEvent( wxMouseEvent& event, RenderView* renderview )
{
  RenderView2D* view = ( RenderView2D* )renderview;
// UpdateCursor( event, view );

  if ( m_region && !m_bDrawing && !m_bEditing )
    m_region->Highlight( false );
  
  if ( event.LeftDown() )
  {
    if ( event.CmdDown() && event.ShiftDown() )
      return Interactor2D::ProcessMouseDownEvent( event, renderview );

    LayerCollection* lc = MainWindow::GetMainWindowPointer()->GetLayerCollectionManager()->GetLayerCollection( "MRI" );
    LayerVolumeBase* mri = ( LayerVolumeBase* )lc->GetActiveLayer();
    if ( mri )
    {
      m_nMousePosX = event.GetX();
      m_nMousePosY = event.GetY();
      
      Region2D* reg = view->GetRegion( m_nMousePosX, m_nMousePosY, &m_nPointIndex );
      if ( m_region && m_bDrawing )
      {       
        ((Region2DPolyline*)m_region)->AddPoint( m_nMousePosX, m_nMousePosY );
      }
      else if ( !reg )   // drawing
      {
        if ( m_nAction == MM_Line )
        {
          Region2DLine* reg_line = new Region2DLine( view );
          reg_line->SetLine( m_nMousePosX, m_nMousePosY, m_nMousePosX, m_nMousePosY ); 
          view->AddRegion( reg_line );
          m_region = reg_line;
        }
        else if ( m_nAction == MM_Spline || m_nAction == MM_Polyline )
        {
          Region2DPolyline* reg_polyline = new Region2DPolyline( view, m_nAction == MM_Spline );
          reg_polyline->AddPoint( m_nMousePosX, m_nMousePosY ); 
          reg_polyline->AddPoint( m_nMousePosX, m_nMousePosY ); // add second point
          view->AddRegion( reg_polyline );
          m_region = reg_polyline;
        }
        else if ( m_nAction == MM_Rectangle )
        {
          Region2DRectangle* reg_rect = new Region2DRectangle( view );
          reg_rect->SetRect( m_nMousePosX, m_nMousePosY, 1, 1 );
          view->AddRegion( reg_rect );
          m_region = reg_rect;
        }
        m_bDrawing = true;
      }
      else      // editing
      {
        m_region = reg;
        m_bEditing = true;
        m_region->Highlight();
        view->SendBroadcast( "RegionSelected", m_region );
        view->NeedRedraw();
      }
      return false;
    }
  }
  else if ( event.RightDown() )
  {
    if ( m_bDrawing && m_region )
    {
      m_bDrawing = false;
      m_bEditing = false;
      if ( m_nAction == MM_Spline || m_nAction == MM_Polyline )
        ((Region2DPolyline*)m_region)->RemoveLastPoint();
      view->NeedRedraw();
      return false;
    }
  }
  
  return Interactor2D::ProcessMouseDownEvent( event, renderview ); // pass down the event
}
bool Interactor2DVolumeEdit::ProcessMouseDownEvent( wxMouseEvent& event, RenderView* renderview )
{
  RenderView2D* view = ( RenderView2D* )renderview;
// UpdateCursor( event, view );

  if ( event.LeftDown() || ( event.RightDown() && event.LeftIsDown() ) )
  {
    if ( event.CmdDown() && event.ShiftDown() )
      return Interactor2D::ProcessMouseDownEvent( event, renderview );

    LayerCollection* lc = MainWindow::GetMainWindowPointer()->GetLayerCollectionManager()->GetLayerCollection( m_strLayerTypeName.c_str() );
    LayerVolumeBase* mri = ( LayerVolumeBase* )lc->GetActiveLayer();
    if ( (!mri || !mri->IsVisible()) ) //&& ( event.CmdDown() || m_nAction == EM_Polyline ) )
    {
      SendBroadcast( m_strLayerTypeName + "NotVisible", this );
    }
    else if ( !mri->IsEditable() ) //&& ( event.CmdDown() || m_nAction == EM_Polyline ) )
    {
      SendBroadcast( m_strLayerTypeName + "NotEditable", this );
    }
    else if ( m_strLayerTypeName == "MRI" && ((LayerMRI*)mri)->IsTransformed() )
    {
      SendBroadcast( m_strLayerTypeName + "NotEditableForTransformation", this );
    }
    else
    {
      m_nMousePosX = event.GetX();
      m_nMousePosY = event.GetY();

      double ras[3];
      view->MousePositionToRAS( m_nMousePosX, m_nMousePosY, ras );
      if ( m_nAction == EM_Freehand ) //&& ( event.CmdDown() ) )
      {
        mri->SaveForUndo( view->GetViewPlane() );
        if ( event.CmdDown() )
        {
          mri->FloodFillByRAS( ras, view->GetViewPlane(), !event.ShiftDown() && !event.RightIsDown() );
        }
        else
        {
          m_bEditing = true;
          mri->SetVoxelByRAS( ras, view->GetViewPlane(), !event.ShiftDown() && !event.RightIsDown() );
        }
      }
      else if ( m_nAction == EM_Fill ) //&& ( event.CmdDown() ) )
      {
        mri->SaveForUndo( view->GetViewPlane() );
        mri->FloodFillByRAS( ras, view->GetViewPlane(), !event.ShiftDown() && !event.RightIsDown() );
      }
      else if ( m_nAction == EM_Polyline || m_nAction == EM_Livewire )
      {
        mri->SaveForUndo( view->GetViewPlane() );
        if ( event.CmdDown() )
        {
          mri->FloodFillByRAS( ras, view->GetViewPlane(), !event.ShiftDown() && !event.RightIsDown() );
        }
        else
        {
          m_bEditing = true;
          double ras2[3];
          view->GetCursor2D()->ClearInterpolationPoints();
          view->GetCursor2D()->GetPosition( ras2 );
          view->GetCursor2D()->SetPosition( ras );
          view->GetCursor2D()->SetPosition2( ras );
          if ( m_dPolylinePoints.size() > 0 )
          {
            if ( m_nAction == EM_Polyline )
              mri->SetVoxelByRAS( ras, ras2, view->GetViewPlane(), !event.ShiftDown() && !event.RightIsDown() );
            else
              mri->SetLiveWireByRAS( ras, ras2, view->GetViewPlane() );
          }
          else
          {
            // mri->SaveForUndo( view->GetViewPlane() );
            m_dPolylinePoints.push_back( ras[0] );
            m_dPolylinePoints.push_back( ras[1] );
            m_dPolylinePoints.push_back( ras[2] );
            view->GetCursor2D()->SetPosition( ras );
          }
  
          if ( view->GetCapture() == view )
            view->ReleaseMouse();
          view->CaptureMouse();
        }
      }
      else if ( m_nAction == EM_ColorPicker && mri->IsTypeOf( "MRI" ) )
      {
        if ( event.CmdDown() )
        {
          mri->SaveForUndo( view->GetViewPlane() );
          mri->FloodFillByRAS( ras, view->GetViewPlane(), !event.ShiftDown() && !event.RightIsDown() );
        }
        else
        {
          double dValue = ((LayerMRI*)mri)->GetVoxelValue( ras );
          if ( dValue != 0 )
          {
            mri->SetFillValue( (float)dValue );
            mri->SendBroadcast( "LayerActorUpdated", mri );
          }
        }
      }
      else if ( m_nAction == EM_Contour && mri->IsTypeOf( "MRI" ) )
      {
        LayerMRI* mri_ref = (LayerMRI*)MainWindow::GetMainWindowPointer()->GetBrushProperty()->GetReferenceLayer();
        if ( !mri_ref )
        {
          SendBroadcast( m_strLayerTypeName + "ReferenceNotSet", this );
          return false;
        }
          
        Contour2D* c2d = view->GetContour2D();
        if ( event.CmdDown() && event.AltDown() )
        {
          double dValue = mri_ref->GetVoxelValue( ras );
          if ( dValue != 0 )
          {
            m_bEditing = true;
            c2d->SetInput( mri_ref->GetSliceImageData( view->GetViewPlane() ), dValue, ras[view->GetViewPlane()], mri_ref->GetActiveFrame() );
            c2d->SetVisible( true );
            view->NeedRedraw();
          }
          else if ( c2d->IsVisible() )
          {
            m_bEditing = true;
          }
        }
        else if ( event.CmdDown() && !event.AltDown() )
        {
          mri->SaveForUndo( view->GetViewPlane() );
          ((LayerMRI*)mri)->FloodFillByContour2D( ras, c2d );
        }
        else if ( event.ShiftDown() )
        {
          m_bEditing = true;
          c2d->RemoveLine( ras, ras );
          view->NeedRedraw();
        }
        else
        {
          m_bEditing = true;
          c2d->AddLine( ras, ras );
          view->NeedRedraw();
        }
        
      }
      else
        return Interactor2D::ProcessMouseDownEvent( event, renderview );
    }

    return false;
  }
  else if ( m_bEditing )
  {
    m_bEditing = false;
    if ( m_nAction == EM_Polyline || m_nAction == EM_Livewire )
    {
      if ( event.MiddleDown() )
      {
        view->GetCursor2D()->Update();
        view->NeedRedraw();
      }
      else if ( event.RightDown() )
      {
        if ( m_dPolylinePoints.size() > 0 && m_nAction == EM_Polyline )
        {
          LayerCollection* lc = MainWindow::GetMainWindowPointer()->GetLayerCollection( m_strLayerTypeName.c_str() );
          LayerVolumeBase* mri = ( LayerVolumeBase* )lc->GetActiveLayer();

          double ras1[3] = { m_dPolylinePoints[0], m_dPolylinePoints[1], m_dPolylinePoints[2] };
          double ras2[3];
          view->GetCursor2D()->GetPosition( ras2 );
          view->GetCursor2D()->SetPosition2( ras2 );
          view->GetCursor2D()->SetPosition( ras1 );
          mri->SetVoxelByRAS( ras1, ras2, view->GetViewPlane(), !event.ShiftDown() );
        }
        else
        {
          // mri->SetLiveWireByRAS( ras1, ras2, view->GetViewPlane() );
          view->GetCursor2D()->Update();
          view->NeedRedraw();
        }
      }
    }

    m_dPolylinePoints.clear();
    if ( view->GetCapture() == view )
      view->ReleaseMouse();

    return false;
  }
  return Interactor2D::ProcessMouseDownEvent( event, renderview ); // pass down the event
}
bool Interactor2DVolumeEdit::ProcessMouseMoveEvent( wxMouseEvent& event, RenderView* renderview )
{
  RenderView2D* view = ( RenderView2D* )renderview;

  if ( m_bEditing )
  {
    UpdateCursor( event, view );
    int posX = event.GetX();
    int posY = event.GetY();

    LayerCollection* lc = MainWindow::GetMainWindowPointer()->GetLayerCollection( m_strLayerTypeName.c_str() );
    LayerVolumeBase* mri = ( LayerVolumeBase* )lc->GetActiveLayer();

    if ( m_nAction == EM_Freehand )
    {
      double ras1[3], ras2[3];
      view->MousePositionToRAS( m_nMousePosX, m_nMousePosY, ras1 );
      view->MousePositionToRAS( posX, posY, ras2 );

      mri->SetVoxelByRAS( ras1, ras2, view->GetViewPlane(), !event.ShiftDown() && !event.RightIsDown() );
    }
    else if ( m_nAction == EM_Polyline || m_nAction == EM_Livewire )
    {
      double ras[3];
      view->MousePositionToRAS( posX, posY, ras );
      view->GetCursor2D()->SetPosition2( ras );
      if ( m_nAction == EM_Livewire )
      {
        view->GetCursor2D()->SetInterpolationPoints(
          mri->GetLiveWirePointsByRAS( ras,
                                       view->GetCursor2D()->GetPosition(),
                                       view->GetViewPlane() ) );
      }
      view->GetCursor2D()->SetPosition( view->GetCursor2D()->GetPosition(), true );
      view->NeedRedraw();
    }
    else if ( m_nAction == EM_Contour )
    {
      LayerMRI* mri_ref = (LayerMRI*)MainWindow::GetMainWindowPointer()->GetBrushProperty()->GetReferenceLayer();
      Contour2D* c2d = view->GetContour2D();
      if ( event.ShiftDown() )
      {
        double ras1[3], ras2[3];
        view->MousePositionToRAS( m_nMousePosX, m_nMousePosY, ras1 );
        view->MousePositionToRAS( posX, posY, ras2 );
        c2d->RemoveLine( ras1, ras2 );
      }
      else if ( event.CmdDown() && event.AltDown() )
      {
        double scale = 0.2;
        if ( mri_ref )
        {
          double dMin = mri_ref->GetProperties()->GetMinValue();
          double dMax = mri_ref->GetProperties()->GetMaxValue();
          scale = ( dMax - dMin ) * 0.0005;
        }
        c2d->SetContourValue( c2d->GetContourValue() + scale * ( posY - m_nMousePosY ) ); 
      }
      else 
      {
        double ras1[3], ras2[3];
        view->MousePositionToRAS( m_nMousePosX, m_nMousePosY, ras1 );
        view->MousePositionToRAS( posX, posY, ras2 );
        c2d->AddLine( ras1, ras2 );
      }
      
      view->NeedRedraw();
    }

    m_nMousePosX = posX;
    m_nMousePosY = posY;

    return false;
  }
  else
  {
    return Interactor2D::ProcessMouseMoveEvent( event, renderview );
  }
}
Beispiel #19
0
int bmx_wxmouseevent_cmddown(wxMouseEvent & event) {
	return static_cast<int>(event.CmdDown());
}
Beispiel #20
0
void C3DPlotCanvas::OnMouse( wxMouseEvent& event )
{
	wxPoint pt(event.GetPosition());
	wxClientDC dc(this);
	PrepareDC(dc);

	wxPoint point(event.GetLogicalPosition(dc));

	if (event.RightDown()) {
		m_bRButton = true;
		int where[2];
		where[0] = point.x;
		where[1] = point.y;
		last[0] = point.x;
		last[1] = point.y;
		ball->mouse_down(where,3);
	}
	
	if (event.RightUp()) {
		m_bRButton = false;
		int where[2];
		where[0] = point.x;
		where[1] = point.y;
		ball->mouse_up(where,3);
	}
	
	if (event.LeftDown()) {
		if ((event.CmdDown()) && this->m_d && this->b_select) {
			m_brush = true;
			last[0] = point.x;
			last[1] = point.y;
		} else {
			m_bLButton = true;
			int where[2];
			where[0] = point.x;
			where[1] = point.y;
			last[0] = point.x;
			last[1] = point.y;
			ball->mouse_down(where,1);
		}
	}
	
	if (event.LeftUp()) {
		if (bSelect && this->m_d ) {
			bSelect = false;
			SelectByRect();
		} else if (m_brush) {
			m_brush = false;
		} else {
			m_bLButton = false;
			int where[2];
			where[0] = point.x;
			where[1] = point.y;
			ball->mouse_up(where,1);
		}
	}
	
	if (event.Dragging()) {
		int where[2];
		where[0] = point.x;
		where[1] = point.y;
		if (m_brush) {
			float vp[4];
			glGetFloatv(GL_VIEWPORT, vp);
			float W=vp[2], H=vp[3];
			float diam = 2*(ball->radius);
			
			ball->apply_transform();
			
			int pix1[2], pix2[2], pix3[2];
			pix1[0] = (int)(W/2);
			pix1[1] = (int)(H/2);
			pix2[0] = (int)(W/2-1);
			pix2[1] = (int)(H/2);
			pix3[0] = (int)(W/2);
			pix3[1] = (int)(H/2-1);
			double world1[3], world2[3],world3[3];
			unproject_pixel(pix1, world1, 0.0);
			unproject_pixel(pix2, world2, 0.0);
			unproject_pixel(pix3, world3, 0.0);

			ball->unapply_transform();

			Vec3f w1(world1);
			Vec3f w2(world2);
			Vec3f w3(world3);

			Vec3f screen_x = w1-w2;
			unitize(screen_x);
			Vec3f screen_y = w3-w1;
			unitize(screen_y);

			Vec3f XX(1,0,0);
			Vec3f YY(0,1,0);
			Vec3f ZZ(0,0,1);

			xp += diam * (where[0] - last[0]) / W *(XX*screen_x);
			yp += diam * (where[0] - last[0]) / W *(YY*screen_x);
			zp += diam * (where[0] - last[0]) / W *(ZZ*screen_x); 

			xp += diam * (last[1] - where[1]) / H *(XX*screen_y);
			yp += diam * (last[1] - where[1]) / H *(YY*screen_y);
			zp += diam * (last[1] - where[1]) / H *(ZZ*screen_y);

			if (xp < -1.0) xp = -1.0;
			if (xp > 1.0) xp = 1.0;
			if (yp < -1.0) yp = -1.0;
			if (yp > 1.0) yp = 1.0;
			if (zp < -1.0) zp = -1.0;
			if (zp > 1.0) zp = 1.0;

			last[0] = where[0];
			last[1] = where[1];

			c3d_plot_frame->control->m_xp->SetValue((int)((xp+1)*10000));
			c3d_plot_frame->control->m_yp->SetValue((int)((yp+1)*10000));
			c3d_plot_frame->control->m_zp->SetValue((int)((zp+1)*10000));

			this->UpdateSelect();
		} else {
			bSelect = false;
			if (m_bLButton & m_bRButton) {
				ball->mouse_drag(where,last,2);
				last[0] = where[0];
				last[1] = where[1];
			} else if (m_bLButton) {
				ball->mouse_drag(where,last,1);
				last[0] = where[0];
				last[1] = where[1];
			} else if (m_bRButton) {
				ball->mouse_drag(where,last,3);
				last[0] = where[0];
				last[1] = where[1];
			}
		}
	}
	
	Refresh();
}
bool Interactor2DRegionEdit::ProcessMouseDownEvent( wxMouseEvent& event, RenderView* renderview )
{
  RenderView2D* view = ( RenderView2D* )renderview;
// UpdateCursor( event, view );

  if ( event.LeftDown() )
  {
    // if ( event.CmdDown() )
    //  return Interactor2D::ProcessMouseDownEvent( event, renderview );

    LayerCollection* lc = MainWindow::GetMainWindowPointer()->GetLayerCollectionManager()->GetLayerCollection( "MRI" );
    LayerMRI* mri = ( LayerMRI* )lc->GetActiveLayer();
    if ( (!mri || !mri->IsVisible()) ) //&& ( event.CmdDown() || m_nAction == EM_Polyline ) )
    {
      SendBroadcast( "MRINotVisible", this );
    }
    else if ( !mri->IsEditable() ) //&& ( event.CmdDown() || m_nAction == EM_Polyline ) )
    {
      SendBroadcast( "MRINotEditable", this );
    }
    else
    {
      m_nMousePosX = event.GetX();
      m_nMousePosY = event.GetY();

      double ras[3];
      view->MousePositionToRAS( m_nMousePosX, m_nMousePosY, ras );
      if ( m_nAction == EM_Freehand ) //&& ( event.CmdDown() ) )
      {
        mri->SaveForUndo( view->GetViewPlane() );
        if ( event.CmdDown() )
        {
          mri->FloodFillByRAS( ras, view->GetViewPlane(), !event.ShiftDown() );
        }
        else
        {
          m_bEditing = true;
          mri->SetVoxelByRAS( ras, view->GetViewPlane(), !event.ShiftDown() );
        }
      }
      else if ( m_nAction == EM_Fill ) //&& ( event.CmdDown() ) )
      {
        mri->SaveForUndo( view->GetViewPlane() );
        mri->FloodFillByRAS( ras, view->GetViewPlane(), !event.ShiftDown() );
      }
      else if ( m_nAction == EM_Polyline )
      {
        m_bEditing = true;
        double ras2[3];
        view->GetCursor2D()->GetPosition( ras2 );
        view->GetCursor2D()->SetPosition( ras );
        view->GetCursor2D()->SetPosition2( ras );
        if ( m_dPolylinePoints.size() > 0 )
        {
          mri->SetVoxelByRAS( ras, ras2, view->GetViewPlane(), !event.ShiftDown() );
        }
        else
        {
          mri->SaveForUndo( view->GetViewPlane() );
          m_dPolylinePoints.push_back( ras[0] );
          m_dPolylinePoints.push_back( ras[1] );
          m_dPolylinePoints.push_back( ras[2] );
        }

        if ( view->GetCapture() == view )
          view->ReleaseMouse();
        view->CaptureMouse();
      }
      else
        return Interactor2D::ProcessMouseDownEvent( event, renderview );
    }

    return false;
  }
  else if ( m_bEditing )
  {
    m_bEditing = false;
    if ( m_nAction == EM_Polyline )
    {
      if ( event.MiddleDown() )
      {
        view->GetCursor2D()->Update();
        view->NeedRedraw();
      }
      else if ( event.RightDown() )
      {
        if ( m_dPolylinePoints.size() > 0 )
        {
          LayerCollection* lc = MainWindow::GetMainWindowPointer()->GetLayerCollection( "MRI" );
          LayerMRI* mri = ( LayerMRI* )lc->GetActiveLayer();

          double ras1[3] = { m_dPolylinePoints[0], m_dPolylinePoints[1], m_dPolylinePoints[2] };
          double ras2[3];
          view->GetCursor2D()->GetPosition( ras2 );
          view->GetCursor2D()->SetPosition2( ras2 );
          view->GetCursor2D()->SetPosition( ras1 );
          mri->SetVoxelByRAS( ras1, ras2, view->GetViewPlane(), !event.ShiftDown() );
        }
      }
    }

    m_dPolylinePoints.clear();
    if ( view->GetCapture() == view )
      view->ReleaseMouse();

    return false;
  }
  return Interactor2D::ProcessMouseDownEvent( event, renderview ); // pass down the event
}
Beispiel #22
0
void AudioDisplay::OnMouseEvent(wxMouseEvent& event)
{
	// If we have focus, we get mouse move events on Mac even when the mouse is
	// outside our client rectangle, we don't want those.
	if (event.Moving() && !GetClientRect().Contains(event.GetPosition()))
	{
		event.Skip();
		return;
	}

	if (event.IsButton())
		SetFocus();

	const int mouse_x = event.GetPosition().x;

	// Scroll the display after a mouse-up near one of the edges
	if ((event.LeftUp() || event.RightUp()) && OPT_GET("Audio/Auto/Scroll")->GetBool())
	{
		const int width = GetClientSize().GetWidth();
		if (mouse_x < width / 20) {
			ScrollBy(-width / 3);
		}
		else if (width - mouse_x < width / 20) {
			ScrollBy(width / 3);
		}
	}

	if (ForwardMouseEvent(event))
		return;

	if (event.MiddleIsDown())
	{
		context->videoController->JumpToTime(TimeFromRelativeX(mouse_x), agi::vfr::EXACT);
		return;
	}

	if (event.Moving() && !controller->IsPlaying())
	{
		SetTrackCursor(scroll_left + mouse_x, OPT_GET("Audio/Display/Draw/Cursor Time")->GetBool());
	}

	AudioTimingController *timing = controller->GetTimingController();
	if (!timing) return;
	const int drag_sensitivity = int(OPT_GET("Audio/Start Drag Sensitivity")->GetInt() * ms_per_pixel);
	const int snap_sensitivity = OPT_GET("Audio/Snap/Enable")->GetBool() != event.ShiftDown() ? int(OPT_GET("Audio/Snap/Distance")->GetInt() * ms_per_pixel) : 0;

	// Not scrollbar, not timeline, no button action
	if (event.Moving())
	{
		const int timepos = TimeFromRelativeX(mouse_x);

		if (timing->IsNearbyMarker(timepos, drag_sensitivity))
			SetCursor(wxCursor(wxCURSOR_SIZEWE));
		else
			SetCursor(wxNullCursor);
		return;
	}

	const int old_scroll_pos = scroll_left;
	if (event.LeftDown() || event.RightDown())
	{
		const int timepos = TimeFromRelativeX(mouse_x);
		std::vector<AudioMarker*> markers = event.LeftDown() ?
			timing->OnLeftClick(timepos, event.CmdDown(), drag_sensitivity, snap_sensitivity) :
			timing->OnRightClick(timepos, event.CmdDown(), drag_sensitivity, snap_sensitivity);

		// Clicking should never result in the audio display scrolling
		ScrollPixelToLeft(old_scroll_pos);

		if (markers.size())
		{
			RemoveTrackCursor();
			audio_marker.reset(new AudioMarkerInteractionObject(markers, timing, this, controller, (wxMouseButton)event.GetButton()));
			SetDraggedObject(audio_marker.get());
			return;
		}
	}
}
Beispiel #23
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 );
}
Beispiel #24
0
void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
	int h = GetClientSize().GetHeight();
	bool shift = event.ShiftDown();
	bool alt = event.AltDown();
	bool ctrl = event.CmdDown();

	// Row that mouse is over
	bool click = event.LeftDown();
	bool dclick = event.LeftDClick();
	int row = event.GetY() / lineHeight + yPos - 1;
	if (holding && !click) {
		row = mid(0,row,GetRows()-1);
	}
	AssDialogue *dlg = GetDialogue(row);
	if (!dlg) row = 0;

	if (event.ButtonDown() && OPT_GET("Subtitle/Grid/Focus Allow")->GetBool())
		SetFocus();

	if (holding) {
		if (!event.LeftIsDown()) {
			if (dlg)
				MakeCellVisible(row, 0, false);
			holding = false;
			ReleaseMouse();
		}
		else {
			// Only scroll if the mouse has moved to a different row to avoid
			// scrolling on sloppy clicks
			if (row != extendRow) {
				if (row <= yPos)
					ScrollTo(yPos - 3);
				// When dragging down we give a 3 row margin to make it easier
				// to see what's going on, but we don't want to scroll down if
				// the user clicks on the bottom row and drags up
				else if (row > yPos + h / lineHeight - (row > extendRow ? 3 : 1))
					ScrollTo(yPos + 3);
			}
		}
	}
	else if (click && dlg) {
		holding = true;
		CaptureMouse();
	}

	if ((click || holding || dclick) && dlg) {
		int old_extend = extendRow;

		// SetActiveLine will scroll the grid if the row is only half-visible,
		// but we don't want to scroll until the mouse moves or the button is
		// released, to avoid selecting multiple lines on a click
		int old_y_pos = yPos;
		SetActiveLine(dlg);
		ScrollTo(old_y_pos);

		// Toggle selected
		if (click && ctrl && !shift && !alt) {
			bool isSel = !!selection.count(dlg);
			if (isSel && selection.size() == 1) return;
			SelectRow(row, true, !isSel);
			return;
		}

		// Normal click
		if ((click || dclick) && !shift && !ctrl && !alt) {
			if (dclick) {
				context->audioBox->ScrollToActiveLine();
				context->videoController->JumpToTime(dlg->Start);
			}
			SelectRow(row, false);
			return;
		}

		// Change active line only
		if (click && !shift && !ctrl && alt)
			return;

		// Block select
		if ((click && shift && !alt) || holding) {
			extendRow = old_extend;
			int i1 = row;
			int i2 = extendRow;

			if (i1 > i2)
				std::swap(i1, i2);

			// Toggle each
			Selection newsel;
			if (ctrl) newsel = selection;
			for (int i = i1; i <= i2; i++) {
				newsel.insert(GetDialogue(i));
			}
			SetSelectedSet(newsel);
			return;
		}

		return;
	}

	// Mouse wheel
	if (event.GetWheelRotation() != 0) {
		if (ForwardMouseWheelEvent(this, event)) {
			int step = shift ? h / lineHeight - 2 : 3;
			ScrollTo(yPos - step * event.GetWheelRotation() / event.GetWheelDelta());
		}
		return;
	}

	event.Skip();
}