Example #1
0
void CBtnDownEvt::OnMouseMove( wxMouseEvent& event )
{
	if ( event.LeftIsDown() )
		pParent->SetBitmapLabel( *pBtnUp );
	event.Skip();
}
Example #2
0
void TASInputDlg::SetTurbo(wxMouseEvent& event)
{
	wxCheckBox* placeholder;

	switch (event.GetId())
	{
		case ID_A:
			placeholder = wx_a_button;
			A_turbo = !A_turbo;
			break;

		case ID_B:
			placeholder = wx_b_button;
			B_turbo = !B_turbo;
			break;

		case ID_X:
			placeholder = wx_x_button;
			X_turbo = !X_turbo;
			break;

		case ID_Y:
			placeholder = wx_y_button;
			Y_turbo = !Y_turbo;
			break;

		case ID_Z:
			placeholder = wx_z_button;
			Z_turbo = !Z_turbo;
			break;

		case ID_L:
			placeholder = wx_l_button;
			L_turbo = !L_turbo;
			break;

		case ID_R:
			placeholder = wx_r_button;
			R_turbo = !R_turbo;
			break;

		case ID_START:
			placeholder = wx_start_button;
			START_turbo = !START_turbo;
			break;

		case ID_UP:
			placeholder = wx_up_button;
			DU_turbo = !DU_turbo;
			break;

		case ID_DOWN:
			placeholder = wx_down_button;
			DD_turbo = !DD_turbo;
			break;

		case ID_LEFT:
			placeholder = wx_left_button;
			DL_turbo = !DL_turbo;
			break;

		case ID_RIGHT:
			placeholder = wx_right_button;
			DR_turbo = !DR_turbo;
			break;
		default:
			return;
	}
	placeholder->SetValue(true);
}
Example #3
0
void wxRibbonPanel::OnMotion(wxMouseEvent& evt)
{
    TestPositionForHover(evt.GetPosition());
}
Example #4
0
void wxRibbonBar::OnMouseLeftDown(wxMouseEvent& evt)
{
    wxRibbonPageTabInfo *tab = HitTestTabs(evt.GetPosition());
    SetFocus();
    if ( tab )
    {
        if ( m_ribbon_state == wxRIBBON_BAR_MINIMIZED )
        {
            ShowPanels();
            m_ribbon_state = wxRIBBON_BAR_EXPANDED;
        }
        else if ( (tab == &m_pages.Item(m_current_page)) && (m_ribbon_state == wxRIBBON_BAR_EXPANDED) )
        {
            HidePanels();
            m_ribbon_state = wxRIBBON_BAR_MINIMIZED;
        }
    }
    else
    {
        if ( m_ribbon_state == wxRIBBON_BAR_EXPANDED )
        {
            HidePanels();
            m_ribbon_state = wxRIBBON_BAR_MINIMIZED;
        }
    }
    if(tab && tab != &m_pages.Item(m_current_page))
    {
        wxRibbonBarEvent query(wxEVT_RIBBONBAR_PAGE_CHANGING, GetId(), tab->page);
        query.SetEventObject(this);
        ProcessWindowEvent(query);
        if(query.IsAllowed())
        {
            SetActivePage(query.GetPage());

            wxRibbonBarEvent notification(wxEVT_RIBBONBAR_PAGE_CHANGED, GetId(), m_pages.Item(m_current_page).page);
            notification.SetEventObject(this);
            ProcessWindowEvent(notification);
        }
    }
    else if(tab == NULL)
    {
        if(m_tab_scroll_left_button_rect.Contains(evt.GetPosition()))
        {
            m_tab_scroll_left_button_state |= wxRIBBON_SCROLL_BTN_ACTIVE | wxRIBBON_SCROLL_BTN_HOVERED;
            RefreshTabBar();
        }
        else if(m_tab_scroll_right_button_rect.Contains(evt.GetPosition()))
        {
            m_tab_scroll_right_button_state |= wxRIBBON_SCROLL_BTN_ACTIVE | wxRIBBON_SCROLL_BTN_HOVERED;
            RefreshTabBar();
        }
    }

    wxPoint position = evt.GetPosition();

    if(position.x >= 0 && position.y >= 0)
    {
        wxSize size = GetSize();
        if(position.x < size.GetWidth() && position.y < size.GetHeight())
        {
            if(m_toggle_button_rect.Contains(position))
            {
                bool pshown = ArePanelsShown();
                ShowPanels(!pshown);
                if ( pshown )
                    m_ribbon_state = wxRIBBON_BAR_MINIMIZED;
                else
                    m_ribbon_state = wxRIBBON_BAR_PINNED;
                wxRibbonBarEvent event(wxEVT_RIBBONBAR_TOGGLED, GetId());
                event.SetEventObject(this);
                ProcessWindowEvent(event);
            }
            if ( m_help_button_rect.Contains(position) )
            {
                wxRibbonBarEvent event(wxEVT_RIBBONBAR_HELP_CLICK, GetId());
                event.SetEventObject(this);
                ProcessWindowEvent(event);
            }
        }
    }
}
Example #5
0
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();
    }
}
Example #6
0
bool Envelope::HandleMouseButtonDown(wxMouseEvent & event, wxRect & r,
                                     double h, double pps, bool dB,
                                     float zoomMin, float zoomMax, float eMin, float eMax)
{
   bool upper;
   int ctr = (int)(r.height * zoomMax / (zoomMax - zoomMin));
   upper = (event.m_y - r.y < ctr);
   if(zoomMin == eMin)
	   upper = true;

   mButton = event.GetButton();
   int clip_y = event.m_y - r.y;
   if(clip_y < 0) clip_y = 0;	//keeps point in rect r, even if mouse isn't
   if(clip_y > r.height) clip_y = r.height;
   
   mIsDeleting = false;
   double tleft = h - mOffset;
   double tright = tleft + (r.width / pps);
   int bestNum = -1;
   int bestDist = 10; // Must be within 10 pixel radius.
   
   double dBr = gPrefs->Read(wxT("/GUI/EnvdBRange"), ENV_DB_RANGE);
   
   mContourOffset = false;
   
   //   wxLogDebug(wxT("Y:%i Height:%i Offset:%i"), y, height, mContourOffset );
   
   int len = mEnv.Count();
   for (int i = 0; i < len; i++) {	//search for control point nearest click
      if (mEnv[i]->t >= tleft && mEnv[i]->t <= tright) {
         
         int x = int ((mEnv[i]->t + mOffset - h) * pps) + r.x;
         int y[4];
         int numControlPoints;

         // Outer control points
         y[0] = GetWaveYPosNew( mEnv[i]->val, zoomMin, zoomMax, r.height,
                                dB, true, dBr, false);
         y[1] = GetWaveYPosNew( -mEnv[i]->val, zoomMin, zoomMax, r.height,
                                dB, true, dBr, false);

         // Inner control points(contour)
         y[2] = GetWaveYPosNew( mEnv[i]->val, zoomMin, zoomMax, r.height,
                                dB, false, dBr, false);
         y[3] = GetWaveYPosNew( -mEnv[i]->val-.00000001, zoomMin, zoomMax, 
                                r.height, dB, false, dBr, false);

         numControlPoints = 4;

         if (y[2] > y[3])
            numControlPoints = 2;

         if (!mMirror)
            numControlPoints = 1;
         
         for(int j=0; j<numControlPoints; j++){
            
            int d = (int)(sqrt((double)(SQR(x-event.m_x) + SQR(y[j]-(event.m_y-r.y)))) + 0.5);
            if (d < bestDist) {
               bestNum = i;
               bestDist = d;
               mContourOffset = (bool)(j > 1);
            }
         }
      }
   }

   if (bestNum >= 0) {
      mDragPoint = bestNum;
   }
   else {
      // Create new point
      double when = h + (event.m_x - r.x) / pps - mOffset;
      
      //      if (when <= 0 || when >= mTrackLen)
      //         return false;
      
      double v = GetValueAtX( event.m_x, r, h, pps );
      
      int ct = GetWaveYPosNew( v, zoomMin, zoomMax, r.height, dB, 
                               false, dBr, false) ;
      int cb = GetWaveYPosNew( -v-.000000001, zoomMin, zoomMax, r.height, dB, 
                               false, dBr, false) ;
      if( ct <= cb || !mMirror ){
         int t = GetWaveYPosNew( v, zoomMin, zoomMax, r.height, dB, 
                                 true, dBr, false) ;
         int b = GetWaveYPosNew( -v, zoomMin, zoomMax, r.height, dB, 
                                 true, dBr, false) ;
         
         ct = (t + ct) / 2;
         cb = (b + cb) / 2;
         
         if(mMirror &&
            (event.m_y - r.y) > ct &&
            ((event.m_y - r.y) < cb))
            mContourOffset = true;
         else
            mContourOffset = false;
      }
      
      double newVal = ValueOfPixel(clip_y, r.height, upper, dB,
                                   zoomMin, zoomMax, eMin);
      
      //float MaxAmplify = ( mContourOffset ) ? 1.4 : 1.0;

	  if(newVal > eMax)
		  newVal = eMax;
      
      mDragPoint = Insert(when, newVal);
      mDirty = true;
   }

   mUpper = upper;

   mInitialWhen = mEnv[mDragPoint]->t;
   mInitialVal = mEnv[mDragPoint]->val;

   mInitialX = event.m_x;
   mInitialY = event.m_y+mContourOffset;

   return true;
}
void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
{
    const double wheelPanSpeed = 0.001;

    if( aEvent.ControlDown() || aEvent.ShiftDown() || m_enableMousewheelPan )
    {
        // Scrolling
        VECTOR2D scrollVec = m_view->ToWorld( m_view->GetScreenPixelSize(), false ) *
                             ( (double) aEvent.GetWheelRotation() * wheelPanSpeed );
        int axis = aEvent.GetWheelAxis();
        double scrollX = 0.0;
        double scrollY = 0.0;

        if ( m_enableMousewheelPan )
        {
            if ( axis == wxMOUSE_WHEEL_HORIZONTAL )
                scrollX = scrollVec.x;
            else
                scrollY = -scrollVec.y;
        }
        else
        {
            if ( aEvent.ControlDown() )
                scrollX = -scrollVec.x;
            else
                scrollY = -scrollVec.y;
        }

        VECTOR2D delta( scrollX, scrollY );

        m_view->SetCenter( m_view->GetCenter() + delta );
    }
    else
    {
        // Zooming
        wxLongLong  timeStamp   = wxGetLocalTimeMillis();
        double      timeDiff    = timeStamp.ToDouble() - m_timeStamp.ToDouble();
        int         rotation    = aEvent.GetWheelRotation();
        double      zoomScale;

#ifdef __WXMAC__
        // The following is to support Apple pointer devices (MagicMouse &
        // Macbook touchpad), which send events more frequently, but with smaller
        // wheel rotation.
        //
        // It should not break other platforms, but I prefer to be safe than
        // sorry. If you find a device that behaves in the same way on another
        // platform, feel free to remove #ifdef directives.
        if( timeDiff > 0 && timeDiff < 100 && std::abs( rotation ) < 20 )
        {
            aEvent.Skip();
            return;
        }
#endif

        m_timeStamp = timeStamp;

        // Set scaling speed depending on scroll wheel event interval
        if( timeDiff < 500 && timeDiff > 0 )
        {
            zoomScale = 2.05 - timeDiff / 500;

            if( rotation < 0 )
                zoomScale = 1.0 / zoomScale;
        }
        else
        {
            zoomScale = ( rotation > 0 ) ? 1.05 : 0.95;
        }

        if( IsCursorWarpingEnabled() )
        {
            CenterOnCursor();
            m_view->SetScale( m_view->GetScale() * zoomScale );
        }
        else
        {
            VECTOR2D anchor = m_view->ToWorld( VECTOR2D( aEvent.GetX(), aEvent.GetY() ) );
            m_view->SetScale( m_view->GetScale() * zoomScale, anchor );
        }
    }

    aEvent.Skip();
}
Example #8
0
void wxHyperlinkCtrl::OnLeftDown(wxMouseEvent& event)
{
    // the left click must start from the hyperlink rect
    m_clicking = GetLabelRect().Contains(event.GetPosition());
}
Example #9
0
void wxHyperlinkCtrl::OnRightUp(wxMouseEvent& event)
{
    if( GetWindowStyle() & wxHL_CONTEXTMENU )
        if ( GetLabelRect().Contains(event.GetPosition()) )
            DoContextMenu(wxPoint(event.m_x, event.m_y));
}
Example #10
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;
		}
	}
}
void PipedProcessCtrl::OnDClick(wxMouseEvent &e)
{
    //First retrieve the link text
    if(!m_linkclicks)
        return;
    long pos=m_textctrl->PositionFromPoint(e.GetPosition());
    int style=m_textctrl->GetStyleAt(pos);
    if((style&PP_LINK_STYLE)!=PP_LINK_STYLE)
        return; //didn't click a link
    long start=pos;
    while(start>0)
    {
        style=m_textctrl->GetStyleAt(start-1);
        if((style&PP_LINK_STYLE)!=PP_LINK_STYLE)
            break;
        start--;
    }
    long end=pos;
    while(end<m_textctrl->PositionFromLine(m_textctrl->GetLineCount()-1))
    {
        style=m_textctrl->GetStyleAt(end+1);
        if((style&PP_LINK_STYLE)!=PP_LINK_STYLE)
            break;
        end++;
    }
    wxString text=m_textctrl->GetTextRange(start,end+1);

    //retrieve the file and line number parts of the link
    wxRegEx re(m_linkregex,wxRE_ADVANCED|wxRE_NEWLINE);
    wxString file;
    long line;
    if(!re.Matches(text))
        return;
    size_t ind,len;
    re.GetMatch(&ind,&len,0);
    if(re.GetMatch(&ind,&len,1))
        file=text.Mid(ind,len);
    else
        file=wxEmptyString;
    if(re.GetMatch(&ind,&len,3))
        text.Mid(ind,len).ToLong(&line);
    else
        line=0;

    //open the file in the editor
    wxFileName f(file);
    if(f.FileExists())
    {
        cbEditor* ed = Manager::Get()->GetEditorManager()->Open(f.GetFullPath());
        if (ed)
        {
            ed->Show(true);
//            if (!ed->GetProjectFile())
//                ed->SetProjectFile(f.GetFullPath());
            ed->GotoLine(line - 1, false);
            if(line>0)
                if(!ed->HasBookmark(line - 1))
                    ed->ToggleBookmark(line -1);
        }
    }

}
Example #12
0
/* Construct and display a popup menu when the right button is clicked.
 */
void EDA_3D_CANVAS::OnRightClick( wxMouseEvent& event )
{
    wxPoint     pos;
    wxMenu      PopUpMenu;

    pos.x = event.GetX();
    pos.y = event.GetY();

    wxMenuItem* item = new wxMenuItem( &PopUpMenu, ID_POPUP_ZOOMIN, _( "Zoom +" ) );
    item->SetBitmap( KiBitmap( zoom_in_xpm ));
    PopUpMenu.Append( item );

    item = new wxMenuItem( &PopUpMenu, ID_POPUP_ZOOMOUT, _( "Zoom -" ) );
    item->SetBitmap( KiBitmap( zoom_out_xpm ));
    PopUpMenu.Append( item );

    PopUpMenu.AppendSeparator();
    item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_ZPOS, _( "Top View" ) );
    item->SetBitmap( KiBitmap( axis3d_top_xpm ));
    PopUpMenu.Append( item );

    item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_ZNEG, _( "Bottom View" ) );
    item->SetBitmap( KiBitmap( axis3d_bottom_xpm ));
    PopUpMenu.Append( item );

    PopUpMenu.AppendSeparator();
    item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_XPOS, _( "Right View" ) );
    item->SetBitmap( KiBitmap( axis3d_right_xpm ));
    PopUpMenu.Append( item );

    item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_XNEG, _( "Left View" ) );
    item->SetBitmap( KiBitmap( axis3d_left_xpm ));
    PopUpMenu.Append( item );

    PopUpMenu.AppendSeparator();
    item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_YPOS, _( "Front View" ) );
    item->SetBitmap( KiBitmap( axis3d_front_xpm ));
    PopUpMenu.Append( item );

    item = new wxMenuItem( &PopUpMenu, ID_POPUP_VIEW_YNEG, _( "Back View" ) );
    item->SetBitmap( KiBitmap( axis3d_back_xpm ));
    PopUpMenu.Append( item );

    PopUpMenu.AppendSeparator();
    item = new wxMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_LEFT, _( "Move left <-" ) );
    item->SetBitmap( KiBitmap( left_xpm ));
    PopUpMenu.Append( item );

    item = new wxMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_RIGHT, _( "Move right ->" ) );
    item->SetBitmap( KiBitmap( right_xpm ));
    PopUpMenu.Append( item );

    item = new wxMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_UP, _( "Move Up ^" ) );
    item->SetBitmap( KiBitmap( up_xpm ));
    PopUpMenu.Append( item );

    item = new wxMenuItem( &PopUpMenu, ID_POPUP_MOVE3D_DOWN, _( "Move Down" ) );
    item->SetBitmap( KiBitmap( down_xpm ));
    PopUpMenu.Append( item );

    PopupMenu( &PopUpMenu, pos );
}
Example #13
0
void ImageFrameDyn::OnMouseRightUP(wxMouseEvent& event) {
    wxMenu menu(wxT("Au choix :"));
    menu.Append(ID_PopupMenuPhoto, wxT("&Zoom"));
    menu.Append(ID_PopupMenuPhotoAttrs, wxT("&Attributs"));
    PopupMenu(&menu, wxPoint(event.GetX(), event.GetY()));
}
Example #14
0
void CFilterDialog::OnMouseEvent(wxMouseEvent& event)
{
	m_shiftClick = event.ShiftDown();
	event.Skip();
}
Example #15
0
// Process a left mouse click by making a move attempt at the appropriate cell
void SimpleGoPanel::LMouseUp(wxMouseEvent& event)
{	int x, y;
	x = (event.GetPosition().x+8)/16;
	y = (event.GetPosition().y+8)/16;
	MakeMove(x, y);
}
Example #16
0
void CUIViewAgent::ProcessMouseEvent( wxMouseEvent& event )
{
    __super::ProcessMouseEvent(event);
    
    wxPoint MousePos = event.GetPosition();
    CRenderTarget* pRenderWnd = CRenderManager::GetInstance()->GetCurrentRenderTarget();
    wxGLRenderWindow* pSceneRenderWnd = down_cast<wxGLRenderWindow*>(pRenderWnd);
    BEATS_ASSERT(pSceneRenderWnd != NULL);
    float fScale = pSceneRenderWnd->IsFBOInUse() ? (float)pSceneRenderWnd->GetFBOViewPortWidth() / pSceneRenderWnd->GetWidth() : pSceneRenderWnd->GetScaleFactor();

    MousePos.x /= fScale;
    MousePos.y /= fScale;
    if(event.ButtonDown(wxMOUSE_BTN_LEFT))
    {
        if (m_pMainFrame->m_nCursorIconID == wxCURSOR_ARROW)
        {
            CComponentBase* pSelectedComponent = CWindowManager::GetInstance()->GetControl(MousePos.x, MousePos.y);
            CComponentProxy* pProxy = NULL;
            if (pSelectedComponent)
            {
                pProxy = (CComponentProxy*)CComponentProxyManager::GetInstance()->GetComponentInstance(pSelectedComponent->GetId(), pSelectedComponent->GetGuid());
            }

            if (m_pMainFrame->m_pSelectedComponentProxy != pProxy)
            {
                m_pMainFrame->SelectComponent(pProxy);
            }
        }

        if (m_pMainFrame->m_pSelectedComponentProxy != NULL)
        {
            kmVec2 kmVec2Pos;
            kmVec2Fill(&kmVec2Pos, 0, 0);
            ((CControl*)m_pMainFrame->m_pSelectedComponentProxy->GetHostComponent())->LocalToWorld(kmVec2Pos.x, kmVec2Pos.y);
            m_pMainFrame->m_activeGUIPosOffset = wxPoint(kmVec2Pos.x - MousePos.x, kmVec2Pos.y - MousePos.y);
        }
        UpdateCursorIcon(MousePos);
        ((wxWindow*)m_pMainFrame->m_pViewScreen)->SetCursor(m_pMainFrame->m_nCursorIconID);
    }
    else if(event.ButtonDown(wxMOUSE_BTN_RIGHT))
    {
        m_pMainFrame->SelectComponent(NULL);
        UpdateCursorIcon(MousePos);
        ((wxWindow*)m_pMainFrame->m_pViewScreen)->SetCursor(m_pMainFrame->m_nCursorIconID);
    }
    else if(event.Dragging())
    {
        if (m_pMainFrame->m_pSelectedComponentProxy)
        {
            wxString propertyName;
            int nHitTestRet = m_pMainFrame->m_nHitTestRet;
            if (nHitTestRet == CControl::eHTR_HIT_CONTENT || nHitTestRet == CControl::eHTR_HIT_EDGE)
            {
                propertyName = _T("m_pos");
            }
            else if (nHitTestRet > CControl::eHTR_HIT_CONTENT && nHitTestRet < CControl::eHTR_HIT_ANCHOR)
            {
                propertyName = _T("m_vecSize");
            }
            else
            {
                propertyName = _T("");
            }

            if (!propertyName.IsEmpty())
            {
                CWxwidgetsPropertyBase* pPropertyDescription = static_cast<CWxwidgetsPropertyBase*>(m_pMainFrame->m_pSelectedComponentProxy->GetPropertyDescription(propertyName));
                BEATS_ASSERT(pPropertyDescription != NULL);
                CControl* pWindow = dynamic_cast<CControl*>(m_pMainFrame->m_pSelectedComponentProxy->GetHostComponent());
                BEATS_ASSERT(pWindow != NULL);
                if (nHitTestRet == CControl::eHTR_HIT_CONTENT || nHitTestRet == CControl::eHTR_HIT_EDGE)
                {
                    kmScalar posX = MousePos.x + m_pMainFrame->m_activeGUIPosOffset.x;
                    kmScalar posY = MousePos.y + m_pMainFrame->m_activeGUIPosOffset.y;
                    kmVec2 pos = pWindow->CalcPosFromMouse(posX, posY);
                    SetkmVec2PropertyValue(pPropertyDescription, pos);
                }
                else if (nHitTestRet > CControl::eHTR_HIT_CONTENT && nHitTestRet < CControl::eHTR_HIT_ANCHOR)
                {
                    kmVec2 size = pWindow->CalcSizeFromMouse(MousePos.x, MousePos.y, (CControl::EHitTestResult)nHitTestRet);
                    SetkmVec2PropertyValue(pPropertyDescription, size);
                }
            }
        }
    }
    else if(event.Moving())
    {
        UpdateCursorIcon(MousePos);
    }
}
void wxCodeCompletionBox::StcLeftDown(wxMouseEvent& event)
{
    event.Skip();
    DoDestroy();
}
void tui::LayoutCanvas::OnMouseMotion(wxMouseEvent& event)
{
   ScrMARKold = ScrMARK;
   // get a current position
   ScrMARK = TP(event.GetX(),event.GetY()) * _LayCTM ;
   int4b stepDB = DATC->stepDB();
   ScrMARK.roundTO(stepDB);
   if (DATC->autopan() && mouse_input && !invalid_window)
   {
      CTM LayCTMR(_LayCTM.Reversed());
      TP sp_BL     =     lp_BL * LayCTMR;
      TP sp_TR     =     lp_TR * LayCTMR;
      TP s_ScrMARK = n_ScrMARK * LayCTMR;
      TP nsp;
      if      (abs(s_ScrMARK.x() - sp_BL.x()) < ap_trigger)
      {
         wxCommandEvent eventZOOM(wxEVT_CANVAS_ZOOM);
         eventZOOM.SetInt(ZOOM_LEFT);
         OnZoom(eventZOOM);
         nsp = ScrMARK * _LayCTM.Reversed();
         WarpPointer(nsp.x(),nsp.y());return;
      }
      else  if(abs(sp_TR.x() - s_ScrMARK.x()) < ap_trigger)
      {
         wxCommandEvent eventZOOM(wxEVT_CANVAS_ZOOM);
         eventZOOM.SetInt(ZOOM_RIGHT);
         OnZoom(eventZOOM);
         nsp = ScrMARK * _LayCTM.Reversed();
         WarpPointer(nsp.x(),nsp.y());return;
      }
      else  if(abs(sp_BL.y() - s_ScrMARK.y()) < ap_trigger)
      {
         wxCommandEvent eventZOOM(wxEVT_CANVAS_ZOOM);
         eventZOOM.SetInt(ZOOM_UP);
         OnZoom(eventZOOM);
         nsp = ScrMARK * _LayCTM.Reversed();
         WarpPointer(nsp.x(),nsp.y());return;
      }
      else  if(abs(s_ScrMARK.y() - sp_TR.y()) < ap_trigger)
      {
         wxCommandEvent eventZOOM(wxEVT_CANVAS_ZOOM);
         eventZOOM.SetInt(ZOOM_DOWN);
         OnZoom(eventZOOM);
         nsp = ScrMARK * _LayCTM.Reversed();
         WarpPointer(nsp.x(),nsp.y());return;
      }
   }
   // update movement indicators
   static int deltaX = abs(ScrMARKold.x() - ScrMARK.x());
   static int deltaY = abs(ScrMARKold.y() - ScrMARK.y());
   if (!(deltaX || deltaY)) return;
   //
   CursorControl(event.ShiftDown(), event.ControlDown());
   if (deltaX > 0) 
      UpdateCoordWin(ScrMARK.x(), CNVS_POS_X, (n_ScrMARK.x() - releasepoint.x()), CNVS_DEL_X);
   if (deltaY > 0) 
      UpdateCoordWin(ScrMARK.y(), CNVS_POS_Y, (n_ScrMARK.y() - releasepoint.y()), CNVS_DEL_Y);

//   drawInterim(ScrMARK);
   if (tmp_wnd || mouse_input || reperX || reperY) Refresh();//updateGL();
}
Example #19
0
void wxListCtrlEx::OnMouseWheel(wxMouseEvent& event)
{
	event.Skip();
	OnPreEmitPostScrollEvent();
}
Example #20
0
void GribGrabberWin::OnMouseEvent( wxMouseEvent& event )
{
    if( event.RightDown() ) {
        wxMouseEvent evt(event);
        ((wxEvtHandler*)GetParent())->ProcessEvent( evt );
        return;
    }

    static wxPoint s_gspt;
    int x, y;

    event.GetPosition( &x, &y );
    wxPoint spt = ClientToScreen( wxPoint( x, y ) );

#ifdef __WXOSX__
    if (!m_bLeftDown && event.LeftIsDown())
    {
        m_bLeftDown = true;
        s_gspt = spt;
        if (!HasCapture()) CaptureMouse();
    }
    else if (m_bLeftDown && !event.LeftIsDown())
    {
       // GetParent()->Move( GetParent()->GetPosition() );
        m_bLeftDown = false;
        if (HasCapture()) ReleaseMouse();
    }
#else

    if( event.LeftDown() ) {
        s_gspt = spt;
        CaptureMouse();
    }

    if( event.LeftUp() ) {
        //GetParent()->Move( GetParent()->GetPosition() );
        if( HasCapture() ) ReleaseMouse();
    }
#endif

    if( event.Dragging() ) {

        wxPoint par_pos_old = GetParent()->GetPosition();

        wxPoint par_pos = par_pos_old;
        par_pos.x += spt.x - s_gspt.x;
        par_pos.y += spt.y - s_gspt.y;

        wxPoint pos_in_parent = GetOCPNCanvasWindow()->ScreenToClient( par_pos );
        wxPoint pos_in_parent_old = GetOCPNCanvasWindow()->ScreenToClient( par_pos_old );

		// X
		if( pos_in_parent.x < pos_in_parent_old.x ) {           // moving left
			if( pos_in_parent.x < 10 ) {
				pos_in_parent.x = 0;
			}
		} else
        if( pos_in_parent.x > pos_in_parent_old.x ) {           // moving right
            int max_right = GetOCPNCanvasWindow()->GetClientSize().x - GetParent()->GetSize().x;
            if( pos_in_parent.x > ( max_right - 10 ) ) {
                pos_in_parent.x = max_right;
            }
        }

		// Y
		if( pos_in_parent.y < pos_in_parent_old.y ) {            // moving up
			if( pos_in_parent.y < 10 ) {
				pos_in_parent.y = 0;
			}
		} else
        if( pos_in_parent.y > pos_in_parent_old.y ) {            // moving dow
            int max_down = GetOCPNCanvasWindow()->GetClientSize().y - GetParent()->GetSize().y;
            if( pos_in_parent.y > ( max_down - 10 ) ) {
                pos_in_parent.y = max_down;
            }
        }

		wxPoint final_pos = GetOCPNCanvasWindow()->ClientToScreen( pos_in_parent );

		GetParent()->Move( final_pos );

        s_gspt = spt;

    }
}
Example #21
0
void wxRibbonBar::OnMouseMove(wxMouseEvent& evt)
{
    int x = evt.GetX();
    int y = evt.GetY();
    int hovered_page = -1;
    bool refresh_tabs = false;
    if(y < m_tab_height)
    {
        // It is quite likely that the mouse moved a small amount and is still over the same tab
        if(m_current_hovered_page != -1 && m_pages.Item((size_t)m_current_hovered_page).rect.Contains(x, y))
        {
            hovered_page = m_current_hovered_page;
            // But be careful, if tabs can be scrolled, then parts of the tab rect may not be valid
            if(m_tab_scroll_buttons_shown)
            {
                if(x >= m_tab_scroll_right_button_rect.GetX() || x < m_tab_scroll_left_button_rect.GetRight())
                {
                    hovered_page = -1;
                }
            }
        }
        else
        {
            HitTestTabs(evt.GetPosition(), &hovered_page);
        }
    }
    if(hovered_page != m_current_hovered_page)
    {
        if(m_current_hovered_page != -1)
        {
            m_pages.Item((int)m_current_hovered_page).hovered = false;
        }
        m_current_hovered_page = hovered_page;
        if(m_current_hovered_page != -1)
        {
            m_pages.Item((int)m_current_hovered_page).hovered = true;
        }
        refresh_tabs = true;
    }
    if(m_tab_scroll_buttons_shown)
    {
#define SET_FLAG(variable, flag) \
    { if(((variable) & (flag)) != (flag)) { variable |= (flag); refresh_tabs = true; }}
#define UNSET_FLAG(variable, flag) \
    { if((variable) & (flag)) { variable &= ~(flag); refresh_tabs = true; }}

        if(m_tab_scroll_left_button_rect.Contains(x, y))
            SET_FLAG(m_tab_scroll_left_button_state, wxRIBBON_SCROLL_BTN_HOVERED)
        else
            UNSET_FLAG(m_tab_scroll_left_button_state, wxRIBBON_SCROLL_BTN_HOVERED)

        if(m_tab_scroll_right_button_rect.Contains(x, y))
            SET_FLAG(m_tab_scroll_right_button_state, wxRIBBON_SCROLL_BTN_HOVERED)
        else
            UNSET_FLAG(m_tab_scroll_right_button_state, wxRIBBON_SCROLL_BTN_HOVERED)
#undef SET_FLAG
#undef UNSET_FLAG
    }
    if(refresh_tabs)
    {
        RefreshTabBar();
    }
    if ( m_flags & wxRIBBON_BAR_SHOW_TOGGLE_BUTTON )
        HitTestRibbonButton(m_toggle_button_rect, evt.GetPosition(), m_toggle_button_hovered);
    if ( m_flags & wxRIBBON_BAR_SHOW_HELP_BUTTON )
        HitTestRibbonButton(m_help_button_rect, evt.GetPosition(), m_help_button_hovered);
}
Example #22
0
void TCWin::MouseEvent( wxMouseEvent& event )
{
    event.GetPosition( &curs_x, &curs_y );

    if( !m_TCWinPopupTimer.IsRunning() ) m_TCWinPopupTimer.Start( 20, wxTIMER_ONE_SHOT );
}
Example #23
0
void Helium::ConvertEvent( wxMouseEvent& event, MouseButtonInput& input )
{
    new (&input) MouseButtonInput ();

    ConvertMouseEvent( event, input );

    if ( event.LeftUp() )           { input.SetEvent( MouseButtonEvents::Up ); input.SetButton( MouseButtons::Left ); }
    if ( event.MiddleUp() )         { input.SetEvent( MouseButtonEvents::Up ); input.SetButton( MouseButtons::Middle ); }
    if ( event.RightUp() )          { input.SetEvent( MouseButtonEvents::Up ); input.SetButton( MouseButtons::Right ); }
    if ( event.Aux1Up() )           { input.SetEvent( MouseButtonEvents::Up ); input.SetButton( MouseButtons::Forward ); }
    if ( event.Aux2Up() )           { input.SetEvent( MouseButtonEvents::Up ); input.SetButton( MouseButtons::Backward ); }

    if ( event.LeftDown() )         { input.SetEvent( MouseButtonEvents::Down ); input.SetButton( MouseButtons::Left ); }
    if ( event.MiddleDown() )       { input.SetEvent( MouseButtonEvents::Down ); input.SetButton( MouseButtons::Middle ); }
    if ( event.RightDown() )        { input.SetEvent( MouseButtonEvents::Down ); input.SetButton( MouseButtons::Right ); }
    if ( event.Aux1Down() )         { input.SetEvent( MouseButtonEvents::Down ); input.SetButton( MouseButtons::Forward ); }
    if ( event.Aux2Down() )         { input.SetEvent( MouseButtonEvents::Down ); input.SetButton( MouseButtons::Backward ); }

    if ( event.LeftDClick() )       { input.SetEvent( MouseButtonEvents::DoubleClick ); input.SetButton( MouseButtons::Left ); }
    if ( event.MiddleDClick() )     { input.SetEvent( MouseButtonEvents::DoubleClick ); input.SetButton( MouseButtons::Middle ); }
    if ( event.RightDClick() )      { input.SetEvent( MouseButtonEvents::DoubleClick ); input.SetButton( MouseButtons::Right ); }
    if ( event.Aux1DClick() )       { input.SetEvent( MouseButtonEvents::DoubleClick ); input.SetButton( MouseButtons::Forward ); }
    if ( event.Aux2DClick() )       { input.SetEvent( MouseButtonEvents::DoubleClick ); input.SetButton( MouseButtons::Backward ); }
}
Example #24
0
void GPSView::OnEnterWindow( wxMouseEvent& event )
{
    SetFocus();
    event.Skip();
}
Example #25
0
//----------------------------------------------------------------------------------------
void PgmCtrl::OnMouseMove(wxMouseEvent &event)
{
    TreePos = event.GetPosition();
}
void wxCustomHeightListCtrl::OnMouseEvent(wxMouseEvent& event)
{
	bool changed = false;
	if (event.ButtonDown() && m_allow_selection)
	{
		wxPoint pos = event.GetPosition();
		int x, y;
		CalcUnscrolledPosition(pos.x, pos.y, &x, &y);
		if (y > m_lineHeight * m_lineCount)
		{
			m_focusedLine = -1;
			m_selectedLines.clear();
			changed = true;
		}
		else
		{
			int line = y / m_lineHeight;
			if (event.ShiftDown())
			{
				if (line < m_focusedLine)
				{
					for (int i = line; i <= m_focusedLine; i++)
					{
						if (m_selectedLines.find(i) == m_selectedLines.end())
						{
							changed = true;
							m_selectedLines.insert(i);
						}
					}
				}
				else
				{
					for (int i = line; i >= m_focusedLine; i--)
					{
						if (m_selectedLines.find(i) == m_selectedLines.end())
						{
							changed = true;
							m_selectedLines.insert(i);
						}
					}
				}
			}
			else if (event.ControlDown())
			{
				if (m_selectedLines.find(line) == m_selectedLines.end())
					m_selectedLines.insert(line);
				else
					m_selectedLines.erase(line);
				changed = true;
			}
			else
			{
				m_selectedLines.clear();
				m_selectedLines.insert(line);
				changed = true;
			}

			m_focusedLine = line;				

		}
		Refresh();
	}

	event.Skip();

	if (changed)
	{
		wxCommandEvent evt(wxEVT_COMMAND_LISTBOX_SELECTED, GetId());
		ProcessEvent(evt);
	}
}
Example #27
0
void StripChart::OnMouseMove(wxMouseEvent &event){
	
	_mouseX = event.GetX();
	_mouseY = event.GetY();	
	Refresh();
}
Example #28
0
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);// 
}
Example #29
0
void CWxGLCanvasBase::OnMouseDown(wxMouseEvent& event)
{
	setMousePos(event.GetX(), event.GetY());
	setMouseClicked(true);
}
Example #30
0
void CBtnDownEvt::OnLeftUp( wxMouseEvent& event )
{
	pParent->SetBitmapLabel( *pBtnUp );
	pParent->Refresh();
	event.Skip();
}