Ejemplo n.º 1
0
bool WTreeNode::triggerSlot(WObject *sender, const WSlot_ *slot, void **args)
{
    if (slot == slots_ + 0) {
        sender_ = sender;
        collapse();
        return true;
    }
    if (slot == slots_ + 1) {
        sender_ = sender;
        expand();
        return true;
    }
    if (slot == slots_ + 2) {
        sender_ = sender;
        select();
        return true;
    }
    if (slot == slots_ + 3) {
        sender_ = sender;
        OnTreeNodeCheck();
        return true;
    }
    if (slot == slots_ + 4) {
        sender_ = sender;
        OnRightClick();
        return true;
    }
    return WCompositeWidget::triggerSlot(sender, slot, args);
}
Ejemplo n.º 2
0
void CBCGPBreadcrumb::OnRClickReflect (NMHDR* pNmhdr, LRESULT*)
{
	NMCLICK* pClick = (NMCLICK*)pNmhdr;
	if (pClick != NULL)
	{
		OnRightClick (pClick->pt, (UINT)pClick->dwHitInfo, (HBREADCRUMBITEM)pClick->dwItemSpec);
	}
}
Ejemplo n.º 3
0
void GenericListControl::HandleNotify(LPARAM lParam)
{
	LPNMHDR mhdr = (LPNMHDR) lParam;

	if (mhdr->code == NM_DBLCLK)
	{
		LPNMITEMACTIVATE item = (LPNMITEMACTIVATE) lParam;
		if ((item->iItem != -1 && item->iItem < GetRowCount()) || sendInvalidRows)
			OnDoubleClick(item->iItem,item->iSubItem);
		return;
	}

	if (mhdr->code == NM_RCLICK)
	{
		const LPNMITEMACTIVATE item = (LPNMITEMACTIVATE)lParam;
		if ((item->iItem != -1 && item->iItem < GetRowCount()) || sendInvalidRows)
			OnRightClick(item->iItem,item->iSubItem,item->ptAction);
		return;
	}

	if (mhdr->code == LVN_GETDISPINFO)
	{
		NMLVDISPINFO* dispInfo = (NMLVDISPINFO*)lParam;

		stringBuffer[0] = 0;
		GetColumnText(stringBuffer,dispInfo->item.iItem,dispInfo->item.iSubItem);
		
		if (stringBuffer[0] == 0)
			wcscat(stringBuffer,L"Invalid");

		dispInfo->item.pszText = stringBuffer;
		return;
	}
	 
	// handle checkboxes
	if (mhdr->code == LVN_ITEMCHANGED && updating == false)
	{
		NMLISTVIEW* item = (NMLISTVIEW*) lParam;
		if (item->iItem != -1 && (item->uChanged & LVIF_STATE) != 0)
		{
			// image is 1 if unchcked, 2 if checked
			int oldImage = (item->uOldState & LVIS_STATEIMAGEMASK) >> 12;
			int newImage = (item->uNewState & LVIS_STATEIMAGEMASK) >> 12;
			if (oldImage != newImage)
				OnToggle(item->iItem,newImage == 2);
		}
Ejemplo n.º 4
0
void GuiIconCarousel::OnDPADClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
{
    if(trigger == &buttonATrigger){
        //! do not auto launch when wiimote is pointing to screen and presses A
        if((controller->chan & (GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5)) && controller->data.validPointer)
        {
            return;
        }
        OnLaunchClick(button,controller,trigger);
    }
    else if(trigger == &buttonLTrigger){
        OnLeftSkipClick(button,controller,trigger);
    }
    else if(trigger == &buttonRTrigger){
        OnRightSkipClick(button,controller,trigger);
    }
    else if(trigger == &buttonLeftTrigger){
        OnLeftClick(button,controller,trigger);
    }
    else if(trigger == &buttonRightTrigger){
        OnRightClick(button,controller,trigger);
    }
}
Ejemplo n.º 5
0
bool Control::NotificationMouseButton(const SDL_MouseButtonEvent& buttonEvent)
{
    // raise the mouse button event before the click event
    auto result = OnMouseButton(buttonEvent);

    if (buttonEvent.state == SDL_PRESSED)
    {
        m_flags |= State::MouseDown;
    }
    else if (m_flags & State::MouseDown && buttonEvent.state == SDL_RELEASED)
    {
        auto clickLoc = SDLPoint(buttonEvent.x, buttonEvent.y);
        if (buttonEvent.button == SDL_BUTTON_LEFT)
            OnLeftClick(clickLoc);
        else if (buttonEvent.button == SDL_BUTTON_RIGHT)
            OnRightClick(clickLoc);
        else if (buttonEvent.button == SDL_BUTTON_MIDDLE)
            OnMiddleClick(clickLoc);

        m_flags ^= State::MouseDown;
    }

    return result;
}
Ejemplo n.º 6
0
void wxShapeCanvas::OnMouseEvent(wxMouseEvent& event)
{
  wxClientDC dc(this);
  PrepareDC(dc);

  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();

  // Check if we're within the tolerance for mouse movements.
  // If we're very close to the position we started dragging
  // from, this may not be an intentional drag at all.
  if (dragging)
  {
    int dx = abs(dc.LogicalToDeviceX((long) (x - m_firstDragX)));
    int dy = abs(dc.LogicalToDeviceY((long) (y - m_firstDragY)));
    if (m_checkTolerance && (dx <= GetDiagram()->GetMouseTolerance()) && (dy <= GetDiagram()->GetMouseTolerance()))
    {
      return;
    }
    else
      // If we've ignored the tolerance once, then ALWAYS ignore
      // tolerance in this drag, even if we come back within
      // the tolerance range.
      m_checkTolerance = false;
  }

  // Dragging - note that the effect of dragging is left entirely up
  // to the object, so no movement is done unless explicitly done by
  // object.
  if (dragging && m_draggedShape && m_dragState == StartDraggingLeft)
  {
    m_dragState = ContinueDraggingLeft;

    // If the object isn't m_draggable, transfer message to canvas
    if (m_draggedShape->Draggable())
      m_draggedShape->GetEventHandler()->OnBeginDragLeft((double)x, (double)y, keys, m_draggedAttachment);
    else
    {
      m_draggedShape = NULL;
      OnBeginDragLeft((double)x, (double)y, keys);
    }

    m_oldDragX = x; m_oldDragY = y;
  }
  else if (dragging && m_draggedShape && m_dragState == ContinueDraggingLeft)
  {
    // Continue dragging
    m_draggedShape->GetEventHandler()->OnDragLeft(false, m_oldDragX, m_oldDragY, keys, m_draggedAttachment);
    m_draggedShape->GetEventHandler()->OnDragLeft(true, (double)x, (double)y, keys, m_draggedAttachment);
    m_oldDragX = x; m_oldDragY = y;
  }
  else if (event.LeftUp() && m_draggedShape && m_dragState == ContinueDraggingLeft)
  {
    m_dragState = NoDragging;
    m_checkTolerance = true;

    m_draggedShape->GetEventHandler()->OnDragLeft(false, m_oldDragX, m_oldDragY, keys, m_draggedAttachment);

    m_draggedShape->GetEventHandler()->OnEndDragLeft((double)x, (double)y, keys, m_draggedAttachment);
    m_draggedShape = NULL;
  }
  else if (dragging && m_draggedShape && m_dragState == StartDraggingRight)
  {
    m_dragState = ContinueDraggingRight;

    if (m_draggedShape->Draggable())
      m_draggedShape->GetEventHandler()->OnBeginDragRight((double)x, (double)y, keys, m_draggedAttachment);
    else
    {
      m_draggedShape = NULL;
      OnBeginDragRight((double)x, (double)y, keys);
    }
    m_oldDragX = x; m_oldDragY = y;
  }
  else if (dragging && m_draggedShape && m_dragState == ContinueDraggingRight)
  {
    // Continue dragging
    m_draggedShape->GetEventHandler()->OnDragRight(false, m_oldDragX, m_oldDragY, keys, m_draggedAttachment);
    m_draggedShape->GetEventHandler()->OnDragRight(true, (double)x, (double)y, keys, m_draggedAttachment);
    m_oldDragX = x; m_oldDragY = y;
  }
  else if (event.RightUp() && m_draggedShape && m_dragState == ContinueDraggingRight)
  {
    m_dragState = NoDragging;
    m_checkTolerance = true;

    m_draggedShape->GetEventHandler()->OnDragRight(false, m_oldDragX, m_oldDragY, keys, m_draggedAttachment);

    m_draggedShape->GetEventHandler()->OnEndDragRight((double)x, (double)y, keys, m_draggedAttachment);
    m_draggedShape = NULL;
  }

  // All following events sent to canvas, not object
  else if (dragging && !m_draggedShape && m_dragState == StartDraggingLeft)
  {
    m_dragState = ContinueDraggingLeft;
    OnBeginDragLeft((double)x, (double)y, keys);
    m_oldDragX = x; m_oldDragY = y;
  }
  else if (dragging && !m_draggedShape && m_dragState == ContinueDraggingLeft)
  {
    // Continue dragging
    OnDragLeft(false, m_oldDragX, m_oldDragY, keys);
    OnDragLeft(true, (double)x, (double)y, keys);
    m_oldDragX = x; m_oldDragY = y;
  }
  else if (event.LeftUp() && !m_draggedShape && m_dragState == ContinueDraggingLeft)
  {
    m_dragState = NoDragging;
    m_checkTolerance = true;

    OnDragLeft(false, m_oldDragX, m_oldDragY, keys);
    OnEndDragLeft((double)x, (double)y, keys);
    m_draggedShape = NULL;
  }
  else if (dragging && !m_draggedShape && m_dragState == StartDraggingRight)
  {
    m_dragState = ContinueDraggingRight;
    OnBeginDragRight((double)x, (double)y, keys);
    m_oldDragX = x; m_oldDragY = y;
  }
  else if (dragging && !m_draggedShape && m_dragState == ContinueDraggingRight)
  {
    // Continue dragging
    OnDragRight(false, m_oldDragX, m_oldDragY, keys);
    OnDragRight(true, (double)x, (double)y, keys);
    m_oldDragX = x; m_oldDragY = y;
  }
  else if (event.RightUp() && !m_draggedShape && m_dragState == ContinueDraggingRight)
  {
    m_dragState = NoDragging;
    m_checkTolerance = true;

    OnDragRight(false, m_oldDragX, m_oldDragY, keys);
    OnEndDragRight((double)x, (double)y, keys);
    m_draggedShape = NULL;
  }

  // Non-dragging events
  else if (event.IsButton())
  {
    m_checkTolerance = true;

    // Find the nearest object
    int attachment = 0;
    wxShape *nearest_object = FindShape(x, y, &attachment);
    if (nearest_object) // Object event
    {
      if (event.LeftDown())
      {
        m_draggedShape = nearest_object;
        m_draggedAttachment = attachment;
        m_dragState = StartDraggingLeft;
        m_firstDragX = x;
        m_firstDragY = y;
      }
      else if (event.LeftUp())
      {
        // N.B. Only register a click if the same object was
        // identified for down *and* up.
        if (nearest_object == m_draggedShape)
          nearest_object->GetEventHandler()->OnLeftClick((double)x, (double)y, keys, attachment);

        m_draggedShape = NULL;
        m_dragState = NoDragging;
      }
      else if (event.LeftDClick())
      {
        nearest_object->GetEventHandler()->OnLeftDoubleClick((double)x, (double)y, keys, attachment);

        m_draggedShape = NULL;
        m_dragState = NoDragging;
      }
      else if (event.RightDown())
      {
        m_draggedShape = nearest_object;
        m_draggedAttachment = attachment;
        m_dragState = StartDraggingRight;
        m_firstDragX = x;
        m_firstDragY = y;
      }
      else if (event.RightUp())
      {
        if (nearest_object == m_draggedShape)
          nearest_object->GetEventHandler()->OnRightClick((double)x, (double)y, keys, attachment);

        m_draggedShape = NULL;
        m_dragState = NoDragging;
      }
    }
    else // Canvas event (no nearest object)
    {
      if (event.LeftDown())
      {
        m_draggedShape = NULL;
        m_dragState = StartDraggingLeft;
        m_firstDragX = x;
        m_firstDragY = y;
      }
      else if (event.LeftUp())
      {
        OnLeftClick((double)x, (double)y, keys);

        m_draggedShape = NULL;
        m_dragState = NoDragging;
      }
      else if (event.RightDown())
      {
        m_draggedShape = NULL;
        m_dragState = StartDraggingRight;
        m_firstDragX = x;
        m_firstDragY = y;
      }
      else if (event.RightUp())
      {
        OnRightClick((double)x, (double)y, keys);

        m_draggedShape = NULL;
        m_dragState = NoDragging;
      }
    }
  }
}
Ejemplo n.º 7
0
void GUIControl::Process()
{
	__super::Process();

	if(IsVisible() && IsEnabled())
	{
		if(PointInBox(mouseX, mouseY, GetX(), GetY(), GetWidth(), GetHeight()))
		{

			int cursor = GetLastCursorPos();
			SetLastCursorPos(1); // mouse is in

			// here
			// 0 - init
			// 1 - mouse was IN control
			// 2 - mouse was OUT control

			if(cursor == 0 || cursor == 2)
			{
				OnMouseEnter();
			}
			else
			{
				OnMouseMove();
			}

			if(mouse[0] || mouse[1])
			{
				if(GetLastPressState() == 0)
				{
					OnMouseDown();

					if(mouse[0])
						SetLastPressState(1);
					else if(mouse[1])
						SetLastPressState(2);
				}
			}
			else
			{
				int press_state = GetLastPressState();
				SetLastPressState(0);

				// here
				// 0 - init
				// 1 - left mouse down
				// 2 - right mouse down
				// 3 - all up

				if(press_state == 1)
				{
					OnLeftClick();
					OnMouseUp();
				}
				else if(press_state == 2)
				{
					OnRightClick();
					OnMouseUp();
				}
			}
		}
		else
		{
			int cursor = GetLastCursorPos();
			SetLastCursorPos(2); // mouse is out

			if(cursor == 1)
			{
				OnMouseLeave();
				SetLastPressState(0);
			}
		}


		// TODO:
		// fix it somehow :(
		if(IsFocused())
		{
			static UCHAR count = 0;
			int delay = 0;
			for(UCHAR i = 0; i < 255; i++)
			{			
				if(GetAsyncKeyState(i) & 0x8000)
				{
					count++;
					static int prev;
					count == 1 ? delay = KEY_FIRST_DELAY : delay = KEY_DELAY;

					if(current_time - prev >= delay)
					{
						if(i != VK_SHIFT)
						{
							OnKeyDown(i);
							prev = current_time;
						}
					}
				}
			}
		}
	}
}
void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
{
    int          localbutt = 0;
    BASE_SCREEN* screen = GetScreen();

    if( !screen )
        return;

    /* Adjust value to filter mouse displacement before consider the drag
     * mouse is really a drag command, not just a movement while click
     */
#define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5

    if( event.Leaving() )
        m_canStartBlock = -1;

    if( !IsMouseCaptured() )          // No mouse capture in progress.
        SetAutoPanRequest( false );

    if( GetParent()->IsActive() )
        SetFocus();
    else
        return;

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

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

    if( m_ignoreMouseEvents )
        return;

    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;

    INSTALL_UNBUFFERED_DC( DC, this );
    DC.SetBackground( *wxBLACK_BRUSH );

    // Compute the cursor position in drawing (logical) units.
    GetParent()->SetMousePosition( event.GetLogicalPosition( DC ) );

    int kbstat = 0;

    if( event.ShiftDown() )
        kbstat |= GR_KB_SHIFT;

    if( event.ControlDown() )
        kbstat |= GR_KB_CTRL;

    if( event.AltDown() )
        kbstat |= GR_KB_ALT;

    // Calling Double Click and Click functions :
    if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
    {
        if( m_ClickTimer )
        {
            m_ClickTimer->Stop();
            wxDELETE( m_ClickTimer );
        }
        GetParent()->OnLeftDClick( &DC, GetParent()->RefPos( true ) );

        // inhibit a response to the mouse left button release,
        // because we have a double click, and we do not want a new
        // OnLeftClick command at end of this Double Click
        m_ignoreNextLeftButtonRelease = true;
    }
    else if( event.LeftUp() )
    {
        // A block command is in progress: a left up is the end of block
        // or this is the end of a double click, already seen
        // Note also m_ignoreNextLeftButtonRelease can be set by
        // the call to OnLeftClick(), so do not change it after calling OnLeftClick
        bool ignoreEvt = m_ignoreNextLeftButtonRelease;
        m_ignoreNextLeftButtonRelease = false;

        if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK && !ignoreEvt )
        {
            EDA_ITEM* item = screen->GetCurItem();
            m_CursorClickPos = GetParent()->RefPos( true );

            // If we have an item already selected, or we are using a tool,
            // we won't use the disambiguation menu so process the click immediately
            if( ( item && item->GetFlags() ) || GetParent()->GetToolId() != ID_NO_TOOL_SELECTED )
                GetParent()->OnLeftClick( &DC, m_CursorClickPos );
            else
            {
                wxDELETE( m_ClickTimer );
                m_ClickTimer = new wxTimer(this, ID_MOUSE_DOUBLECLICK);
                m_ClickTimer->StartOnce( m_doubleClickInterval );
            }
        }

    }
    else if( !event.LeftIsDown() )
    {
        /* be sure there is a response to a left button release command
         * even when a LeftUp event is not seen.  This happens when a
         * double click opens a dialog box, and the release mouse button
         * is made when the dialog box is opened.
         */
        m_ignoreNextLeftButtonRelease = false;
    }

    if( event.ButtonDown( wxMOUSE_BTN_MIDDLE ) )
    {
        m_PanStartCenter = GetParent()->GetScrollCenterPosition();
        m_PanStartEventPosition = event.GetPosition();

        INSTALL_UNBUFFERED_DC( dc, this );
        CrossHairOff( &dc );
        SetCursor( wxCURSOR_SIZING );
    }

    if( event.ButtonUp( wxMOUSE_BTN_MIDDLE ) )
    {
        INSTALL_UNBUFFERED_DC( dc, this );
        CrossHairOn( &dc );
        SetCursor( (wxStockCursor) m_currentCursor );
    }

    if( event.MiddleIsDown() )
    {
        wxPoint currentPosition = event.GetPosition();

        double scale = GetParent()->GetScreen()->GetScalingFactor();
        int x = m_PanStartCenter.x +
                KiROUND( (double) ( m_PanStartEventPosition.x - currentPosition.x ) / scale );
        int y = m_PanStartCenter.y +
                KiROUND( (double) ( m_PanStartEventPosition.y - currentPosition.y ) / scale );

        GetParent()->RedrawScreen( wxPoint( x, y ), false );
    }

    // Calling the general function on mouse changes (and pseudo key commands)
    GetParent()->GeneralControl( &DC, event.GetLogicalPosition( DC ), 0 );

    /*******************************/
    /* Control of block commands : */
    /*******************************/

    // Command block can't start if mouse is dragging a new panel
    static EDA_DRAW_PANEL* lastPanel;
    if( lastPanel != this )
    {
        m_minDragEventCount = 0;
        m_canStartBlock   = -1;
    }

    /* A new command block can start after a release buttons
     * and if the drag is enough
     * This is to avoid a false start block when a dialog box is dismissed,
     * or when changing panels in hierarchy navigation
     * or when clicking while and moving mouse
     */
    if( !event.LeftIsDown() && !event.MiddleIsDown() )
    {
        m_minDragEventCount = 0;
        m_canStartBlock   = 0;

        /* Remember the last cursor position when a drag mouse starts
         * this is the last position ** before ** clicking a button
         * this is useful to start a block command from the point where the
         * mouse was clicked first
         * (a filter creates a delay for the real block command start, and
         * we must remember this point)
         */
        m_CursorStartPos = GetParent()->GetCrossHairPosition();
    }

    if( m_enableBlockCommands && !(localbutt & GR_M_DCLICK) )
    {
        if( !screen->IsBlockActive() )
        {
            screen->m_BlockLocate.SetOrigin( m_CursorStartPos );
        }

        if( event.LeftDown() )
        {
            if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
            {
                SetAutoPanRequest( false );
                GetParent()->HandleBlockPlace( &DC );
                m_ignoreNextLeftButtonRelease = true;
            }
        }
        else if( ( m_canStartBlock >= 0 ) && event.LeftIsDown() && !IsMouseCaptured() )
        {
            // Mouse is dragging: if no block in progress,  start a block command.
            if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
            {
                //  Start a block command
                int cmd_type = kbstat;

                // A block command is started if the drag is enough.  A small
                // drag is ignored (it is certainly a little mouse move when
                // clicking) not really a drag mouse
                if( m_minDragEventCount < MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND )
                    m_minDragEventCount++;
                else
                {
                    auto cmd = (GetParent()->GetToolId() == ID_ZOOM_SELECTION) ? BLOCK_ZOOM : 0;

                    if( !GetParent()->HandleBlockBegin( &DC, cmd_type, m_CursorStartPos, cmd ) )
                    {
                        // should not occur: error
                        GetParent()->DisplayToolMsg(
                            wxT( "EDA_DRAW_PANEL::OnMouseEvent() Block Error" ) );
                    }
                    else
                    {
                        SetAutoPanRequest( true );
                        SetCursor( wxCURSOR_SIZING );
                    }
                }
            }
        }

        if( event.ButtonUp( wxMOUSE_BTN_LEFT ) )
        {
            /* Release the mouse button: end of block.
             * The command can finish (DELETE) or have a next command (MOVE,
             * COPY).  However the block command is canceled if the block
             * size is small because a block command filtering is already
             * made, this case happens, but only when the on grid cursor has
             * not moved.
             */
            #define BLOCK_MINSIZE_LIMIT 1
            bool BlockIsSmall =
                ( std::abs( screen->m_BlockLocate.GetWidth() ) < BLOCK_MINSIZE_LIMIT )
                && ( std::abs( screen->m_BlockLocate.GetHeight() ) < BLOCK_MINSIZE_LIMIT );

            if( (screen->m_BlockLocate.GetState() != STATE_NO_BLOCK) && BlockIsSmall )
            {
                if( m_endMouseCaptureCallback )
                {
                    m_endMouseCaptureCallback( this, &DC );
                    SetAutoPanRequest( false );
                }

                SetCursor( (wxStockCursor) m_currentCursor );
           }
            else if( screen->m_BlockLocate.GetState() == STATE_BLOCK_END )
            {
                SetAutoPanRequest( false );
                GetParent()->HandleBlockEnd( &DC );
                SetCursor( (wxStockCursor) m_currentCursor );
                if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
                {
                    SetAutoPanRequest( true );
                    SetCursor( wxCURSOR_HAND );
                }
           }
        }
    }

    // End of block command on a double click
    // To avoid an unwanted block move command if the mouse is moved while double clicking
    if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
    {
        if( !screen->IsBlockActive() && IsMouseCaptured() )
        {
            m_endMouseCaptureCallback( this, &DC );
        }
    }

    lastPanel = this;

#ifdef __WXGTK3__
    // Screen has to be updated on every operation, otherwise the cursor leaves a trail (when xor
    // operation is changed to copy) or is not updated at all.
    Refresh();
#endif
}
Ejemplo n.º 9
0
void wxToolBar::OnMouseEvent(
  wxMouseEvent&                     rEvent
)
{
    POINTL                          vPoint;
    HWND                            hWnd;
    wxCoord                         vX;
    wxCoord                         vY;
    HPOINTER                        hPtr = ::WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE);

    ::WinSetPointer(HWND_DESKTOP, hPtr);
    ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
    hWnd = ::WinWindowFromPoint(HWND_DESKTOP, &vPoint, TRUE);
    if (hWnd != (HWND)GetHwnd())
    {
        m_vToolTimer.Stop();
        return;
    }

    rEvent.GetPosition(&vX, &vY);

    wxToolBarTool*            pTool = (wxToolBarTool *)FindToolForPosition( vX
                                                                           ,vY
                                                                          );

    if (rEvent.LeftDown())
    {
        CaptureMouse();
    }
    if (rEvent.LeftUp())
    {
        ReleaseMouse();
    }

    if (!pTool)
    {
        m_vToolTimer.Stop();
        if (m_nCurrentTool > -1)
        {
            if (rEvent.LeftIsDown())
                SpringUpButton(m_nCurrentTool);
            pTool = (wxToolBarTool *)FindById(m_nCurrentTool);
            if (pTool && !pTool->IsToggled())
            {
                RaiseTool( pTool, FALSE );
            }
            m_nCurrentTool = -1;
            OnMouseEnter(-1);
        }
        return;
    }
    if (!rEvent.IsButton())
    {
        if (pTool->GetId() != m_nCurrentTool)
        {
            //
            // If the left button is kept down and moved over buttons,
            // press those buttons.
            //
            if (rEvent.LeftIsDown() && pTool->IsEnabled())
            {
                SpringUpButton(m_nCurrentTool);
                if (pTool->CanBeToggled())
                {
                    pTool->Toggle();
                }
                DrawTool(pTool);
            }
            wxToolBarTool*          pOldTool = (wxToolBarTool*)FindById(m_nCurrentTool);

            if (pOldTool && !pTool->IsToggled())
                RaiseTool( pOldTool, FALSE );
            m_nCurrentTool = pTool->GetId();
            OnMouseEnter(m_nCurrentTool);
            if (!pTool->GetShortHelp().empty())
            {
                if (m_pToolTip)
                    delete m_pToolTip;
                m_pToolTip = new wxToolTip(pTool->GetShortHelp());
                m_vXMouse = (wxCoord)vPoint.x;
                m_vYMouse = (wxCoord)vPoint.y;
                m_vToolTimer.Start(1000L, TRUE);
            }
            if (!pTool->IsToggled())
                RaiseTool(pTool);
        }
        return;
    }

    // Left button pressed.
    if (rEvent.LeftDown() && pTool->IsEnabled())
    {
        if (pTool->CanBeToggled())
        {
            pTool->Toggle();
        }
        DrawTool(pTool);
    }
    else if (rEvent.RightDown())
    {
        OnRightClick( pTool->GetId()
                     ,vX
                     ,vY
                    );
    }

    //
    // Left Button Released.  Only this action confirms selection.
    // If the button is enabled and it is not a toggle tool and it is
    // in the pressed state, then raise the button and call OnLeftClick.
    //
    if (rEvent.LeftUp() && pTool->IsEnabled() )
    {
        //
        // Pass the OnLeftClick event to tool
        //
        if (!OnLeftClick( pTool->GetId()
                         ,pTool->IsToggled()) &&
                          pTool->CanBeToggled())
        {
            //
            // If it was a toggle, and OnLeftClick says No Toggle allowed,
            // then change it back
            //
            pTool->Toggle();
        }
        DrawTool(pTool);
    }
} // end of wxToolBar::OnMouseEvent
Ejemplo n.º 10
0
void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
{
    int          localrealbutt = 0, localbutt = 0;
    BASE_SCREEN* screen = GetScreen();

    if( !screen )
        return;

    /* Adjust value to filter mouse displacement before consider the drag
     * mouse is really a drag command, not just a movement while click
     */
#define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5

    if( event.Leaving() )
        m_canStartBlock = -1;

    if( !IsMouseCaptured() )          // No mouse capture in progress.
        m_requestAutoPan = false;

    if( GetParent()->IsActive() )
        SetFocus();
    else
        return;

    if( !event.IsButton() && !event.Moving() && !event.Dragging() )
        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;

    localrealbutt |= localbutt;     // compensation default wxGTK

    INSTALL_UNBUFFERED_DC( DC, this );
    DC.SetBackground( *wxBLACK_BRUSH );

    // Compute the cursor position in drawing (logical) units.
    GetParent()->SetMousePosition( event.GetLogicalPosition( DC ) );

    int kbstat = 0;

    if( event.ShiftDown() )
        kbstat |= GR_KB_SHIFT;

    if( event.ControlDown() )
        kbstat |= GR_KB_CTRL;

    if( event.AltDown() )
        kbstat |= GR_KB_ALT;

    // Calling Double Click and Click functions :
    if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
    {
        GetParent()->OnLeftDClick( &DC, GetParent()->RefPos( true ) );

        // inhibit a response to the mouse left button release,
        // because we have a double click, and we do not want a new
        // OnLeftClick command at end of this Double Click
        m_ignoreNextLeftButtonRelease = true;
    }
    else if( event.LeftUp() )
    {
        // A block command is in progress: a left up is the end of block
        // or this is the end of a double click, already seen
        // Note also m_ignoreNextLeftButtonRelease can be set by
        // the call to OnLeftClick(), so do not change it after calling OnLeftClick
        bool ignoreEvt = m_ignoreNextLeftButtonRelease;
        m_ignoreNextLeftButtonRelease = false;

        if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK && !ignoreEvt )
            GetParent()->OnLeftClick( &DC, GetParent()->RefPos( true ) );

    }
    else if( !event.LeftIsDown() )
    {
        /* be sure there is a response to a left button release command
         * even when a LeftUp event is not seen.  This happens when a
         * double click opens a dialog box, and the release mouse button
         * is made when the dialog box is opened.
         */
        m_ignoreNextLeftButtonRelease = false;
    }

    if( event.ButtonDown( wxMOUSE_BTN_MIDDLE ) && m_enableMiddleButtonPan )
    {
        if( m_panScrollbarLimits )
        {
            int ppux, ppuy;
            GetScrollPixelsPerUnit( &ppux, &ppuy );
            GetViewStart( &m_PanStartCenter.x, &m_PanStartCenter.y );
            m_PanStartCenter.x *= ppux;
            m_PanStartCenter.y *= ppuy;
        }
        else
            m_PanStartCenter = GetParent()->GetScrollCenterPosition();

        m_PanStartEventPosition = event.GetPosition();

        INSTALL_UNBUFFERED_DC( dc, this );
        CrossHairOff( &dc );
    }

    if( event.ButtonUp( wxMOUSE_BTN_MIDDLE ) && m_enableMiddleButtonPan )
    {
        INSTALL_UNBUFFERED_DC( dc, this );
        CrossHairOn( &dc );
    }

    if( event.MiddleIsDown() && m_enableMiddleButtonPan )
    {
        wxPoint currentPosition = event.GetPosition();

        if( m_panScrollbarLimits )
        {
            int x, y;
            int tmpX, tmpY;
            int ppux, ppuy;
            int maxX, maxY;
            int vsizeX, vsizeY;
            int csizeX, csizeY;

            GetViewStart( &tmpX, &tmpY );
            GetScrollPixelsPerUnit( &ppux, &ppuy );
            GetVirtualSize( &vsizeX, &vsizeY );
            GetClientSize( &csizeX, &csizeY );

            maxX = vsizeX - csizeX;
            maxY = vsizeY - csizeY;

            x = m_PanStartCenter.x + m_PanStartEventPosition.x - currentPosition.x;
            y = m_PanStartCenter.y + m_PanStartEventPosition.y - currentPosition.y;

            bool shouldMoveCursor = false;

            if( x < 0 )
            {
                currentPosition.x += x;
                x = 0;
                shouldMoveCursor = true;
            }

            if( y < 0 )
            {
                currentPosition.y += y;
                y = 0;
                shouldMoveCursor = true;
            }

            if( x > maxX )
            {
                currentPosition.x += ( x - maxX );
                x = maxX;
                shouldMoveCursor = true;
            }

            if( y > maxY )
            {
                currentPosition.y += ( y - maxY );
                y = maxY;
                shouldMoveCursor = true;
            }

            if( shouldMoveCursor )
                WarpPointer( currentPosition.x, currentPosition.y );

            Scroll( x/ppux, y/ppuy );

            double scale = GetParent()->GetScreen()->GetScalingFactor();

            wxPoint center = GetParent()->GetScrollCenterPosition();
            center.x += KiROUND( (double) ( x - tmpX ) / scale ) / ppux;
            center.y += KiROUND( (double) ( y - tmpY ) / scale ) / ppuy;
            GetParent()->SetScrollCenterPosition( center );

            Refresh();
            Update();
        }
        else
        {
            double scale = GetParent()->GetScreen()->GetScalingFactor();
            int x = m_PanStartCenter.x +
                    KiROUND( (double) ( m_PanStartEventPosition.x - currentPosition.x ) / scale );
            int y = m_PanStartCenter.y +
                    KiROUND( (double) ( m_PanStartEventPosition.y - currentPosition.y ) / scale );

            GetParent()->RedrawScreen( wxPoint( x, y ), false );
        }
    }

    if( event.ButtonUp( wxMOUSE_BTN_MIDDLE ) && !m_enableMiddleButtonPan &&
        (screen->m_BlockLocate.GetState() == STATE_NO_BLOCK) )
    {
        // The middle button has been released, with no block command:
        // We use it for a zoom center at cursor position command
        wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_POPUP_ZOOM_CENTER );
        cmd.SetEventObject( this );
        GetEventHandler()->ProcessEvent( cmd );
    }

    // Calling the general function on mouse changes (and pseudo key commands)
    GetParent()->GeneralControl( &DC, event.GetLogicalPosition( DC ), 0 );

    /*******************************/
    /* Control of block commands : */
    /*******************************/

    // Command block can't start if mouse is dragging a new panel
    static EDA_DRAW_PANEL* lastPanel;
    if( lastPanel != this )
    {
        m_minDragEventCount = 0;
        m_canStartBlock   = -1;
    }

    /* A new command block can start after a release buttons
     * and if the drag is enough
     * This is to avoid a false start block when a dialog box is dismissed,
     * or when changing panels in hierarchy navigation
     * or when clicking while and moving mouse
     */
    if( !event.LeftIsDown() && !event.MiddleIsDown() )
    {
        m_minDragEventCount = 0;
        m_canStartBlock   = 0;

        /* Remember the last cursor position when a drag mouse starts
         * this is the last position ** before ** clicking a button
         * this is useful to start a block command from the point where the
         * mouse was clicked first
         * (a filter creates a delay for the real block command start, and
         * we must remember this point)
         */
        m_CursorStartPos = GetParent()->GetCrossHairPosition();
    }

    if( m_enableBlockCommands && !(localbutt & GR_M_DCLICK) )
    {
        if( !screen->IsBlockActive() )
        {
            screen->m_BlockLocate.SetOrigin( m_CursorStartPos );
        }

        if( event.LeftDown() || ( !m_enableMiddleButtonPan && event.MiddleDown() ) )
        {
            if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
            {
                m_requestAutoPan = false;
                GetParent()->HandleBlockPlace( &DC );
                m_ignoreNextLeftButtonRelease = true;
            }
        }
        else if( ( m_canStartBlock >= 0 )
                && ( event.LeftIsDown() || ( !m_enableMiddleButtonPan && event.MiddleIsDown() ) )
                && !IsMouseCaptured() )
        {
            // Mouse is dragging: if no block in progress,  start a block command.
            if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
            {
                //  Start a block command
                int cmd_type = kbstat;

                if( !m_enableMiddleButtonPan && event.MiddleIsDown() )
                    cmd_type |= MOUSE_MIDDLE;

                // A block command is started if the drag is enough.  A small
                // drag is ignored (it is certainly a little mouse move when
                // clicking) not really a drag mouse
                if( m_minDragEventCount < MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND )
                    m_minDragEventCount++;
                else
                {
                    if( !GetParent()->HandleBlockBegin( &DC, cmd_type, m_CursorStartPos ) )
                    {
                        // should not occur: error
                        GetParent()->DisplayToolMsg(
                            wxT( "EDA_DRAW_PANEL::OnMouseEvent() Block Error" ) );
                    }
                    else
                    {
                        m_requestAutoPan = true;
                        SetCursor( wxCURSOR_SIZING );
                    }
                }
            }
        }

        if( event.ButtonUp( wxMOUSE_BTN_LEFT ) ||
            ( !m_enableMiddleButtonPan && event.ButtonUp( wxMOUSE_BTN_MIDDLE ) ) )
        {
            /* Release the mouse button: end of block.
             * The command can finish (DELETE) or have a next command (MOVE,
             * COPY).  However the block command is canceled if the block
             * size is small because a block command filtering is already
             * made, this case happens, but only when the on grid cursor has
             * not moved.
             */
            #define BLOCK_MINSIZE_LIMIT 1
            bool BlockIsSmall =
                ( std::abs( screen->m_BlockLocate.GetWidth() ) < BLOCK_MINSIZE_LIMIT )
                && ( std::abs( screen->m_BlockLocate.GetHeight() ) < BLOCK_MINSIZE_LIMIT );

            if( (screen->m_BlockLocate.GetState() != STATE_NO_BLOCK) && BlockIsSmall )
            {
                if( m_endMouseCaptureCallback )
                {
                    m_endMouseCaptureCallback( this, &DC );
                    m_requestAutoPan = false;
                }

                SetCursor( (wxStockCursor) m_currentCursor );
           }
            else if( screen->m_BlockLocate.GetState() == STATE_BLOCK_END )
            {
                m_requestAutoPan = false;
                GetParent()->HandleBlockEnd( &DC );
                SetCursor( (wxStockCursor) m_currentCursor );
                if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
                {
                    m_requestAutoPan = true;
                    SetCursor( wxCURSOR_HAND );
                }
           }
        }
    }

    // End of block command on a double click
    // To avoid an unwanted block move command if the mouse is moved while double clicking
    if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
    {
        if( !screen->IsBlockActive() && IsMouseCaptured() )
        {
            m_endMouseCaptureCallback( this, &DC );
        }
    }

#if 0
    wxString msg_debug;
    msg_debug.Printf( " block state %d, cmd %d",
                      screen->m_BlockLocate.GetState(),
                      screen->m_BlockLocate.GetCommand() );
    GetParent()->PrintMsg( msg_debug );
#endif

    lastPanel = this;
}
Ejemplo n.º 11
0
WTreeNode::WTreeNode(const std::string labelText, const std::string nodeId, bool bCheck, bool bDevice,int nType, 
                     WText::Formatting labelFormatting,
                     WStateIcon *labelIcon,
                     WWidget *userContent, WContainerWidget *parent)
                     : parentNode_(0),
                     labelIcon_(labelIcon),
                     userContent_(userContent),
                     wasSelected_(false)
{

    bMExpand =false;
    bFirst = true;
    bFirstadjust=true;
    bFistundoCollapse =true;
    m_CheckBoxTreeView =NULL;
    treeCheckBox_ =NULL;
    nTreeType= nType;
    setImplementation(layout_ = new WTable(parent));
    layout_->setCellSpaceing(0);
	layout_->setCellSpaceing(0);
	layout_->setStyleClass("widthauto");
    
    strId = nodeId;
    expandIcon_ = new WStateIcon(imageFold_[OPEN], imageFold_[CLOSE ]);
    expandedContent_ = new WContainerWidget();
    if (userContent)
        expandedContent_->addWidget(userContent);

    labelText_ = new WText(labelText);
		labelText_->setStyleClass("hand");
    labelText_->setFormatting(labelFormatting);


    connect(labelText_ , SIGNAL(clicked()), this ,SLOT(OnRightClick()));

    noExpandIcon_ = new WImage("../Images/9bland.gif");

		WText *blank = new WText("&nbsp;");
		//layout_->elementAt(0, 1)->setStyleClass("tree_text");
		layout_->elementAt(0, 0)->setStyleClass("padding_right_2");
    layout_->elementAt(0, 0)->addWidget(expandIcon_);
    layout_->elementAt(0, 0)->addWidget(noExpandIcon_);
    layout_->elementAt(0, 0)->addWidget(blank);
    
    if( (false==bDevice)&&( Tree_DEVICE==nTreeType))//ajax --monitor
    {
        noExpandIcon_->hide();
    }else 
    {
        expandIcon_->hide();
	}

    treeCheckBox_ = new WCheckBox(labelText);
    treeCheckBox_->setStyleClass("smallcheckbox");

    if(nTreeType==Tree_MONITOR)
    {
        connect(treeCheckBox_,SIGNAL(clicked()),this,SLOT(OnTreeNodeCheck()));
        layout_->elementAt(0, 1)->setStyleClass("tree_text");
    }
    if (labelIcon_) 
    {
        if(bCheck)
        {
            layout_->elementAt(0, 0)->addWidget(treeCheckBox_);
        }
        layout_->elementAt(0, 1)->addWidget(labelIcon_);
        labelIcon_->setVerticalAlignment(AlignMiddle);
    }
    layout_->elementAt(0, 1)->addWidget(labelText_);
    layout_->elementAt(1, 1)->addWidget(expandedContent_);
    layout_->elementAt(0, 0)->setVerticalAlignment(AlignMiddle);
    layout_->elementAt(0, 0)->setContentAlignment(AlignMiddle);
    layout_->elementAt(0, 1)->setContentAlignment(AlignMiddle);
    layout_->elementAt(0, 1)->setVerticalAlignment(AlignMiddle);

	//add end
    connect(expandIcon_->icon1(), SIGNAL(clicked()), this, SLOT(expand()), STATIC);
    connect(expandIcon_->icon2(), SIGNAL(clicked()), this, SLOT(collapse()), STATIC);
}
Ejemplo n.º 12
0
BOOL CALLBACK Machines_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
   if (Display_HandleColumnNotify (hDlg, msg, wp, lp, &gr.viewMch))
      return FALSE;

   switch (msg)
      {
      case WM_INITDIALOG:
         {
         RECT rTab;
         GetClientRect (GetParent(hDlg), &rTab);
         TabCtrl_AdjustRect (GetParent (hDlg), FALSE, &rTab);
         ResizeWindow (hDlg, awdMachinesTab, rwaMoveToHere, &rTab);

         HIMAGELIST hSmall = AfsAppLib_CreateImageList (FALSE);
         HIMAGELIST hLarge = AfsAppLib_CreateImageList (TRUE);
         FastList_SetImageLists (GetDlgItem (hDlg, IDC_MACHINES_LIST), hSmall, hLarge);

         FastList_SetSortFunction (GetDlgItem (hDlg, IDC_MACHINES_LIST), General_ListSortFunction);

         FL_RestoreView (GetDlgItem (hDlg, IDC_MACHINES_LIST), &gr.viewMch);
         FastList_SetTextCallback (GetDlgItem (hDlg, IDC_MACHINES_LIST), Display_GetItemText, &gr.viewMch);
         SetDlgItemText (hDlg, IDC_MACHINES_PATTERN, g.szPatternMachines);
         Machines_EnableButtons(hDlg);
         Display_PopulateMachineList();

         l.dwTickLastType = 0;
         }
         break;

      case WM_HELP:
         WinHelp (hDlg, cszHELPFILENAME, HELP_FINDER, 0);
         break;

      case WM_DESTROY:
         FL_StoreView (GetDlgItem (hDlg, IDC_MACHINES_LIST), &gr.viewMch);
         break;

      case WM_SIZE:
         // if (lp==0), we're minimizing--don't call ResizeWindow().
         //
         if (lp != 0)
            ResizeWindow (hDlg, awdMachinesTab, rwaFixupGuts);
         break;

      case WM_TIMER:
         switch (wp)
            {
            case ID_SEARCH_TIMER:
               if ( (l.dwTickLastType) && (GetTickCount() > l.dwTickLastType + msecSEARCH_TIMER) )
                  {
                  KillTimer (hDlg, ID_SEARCH_TIMER);
                  Display_PopulateMachineList();
                  }
               break;
            }
         break;

      case WM_CONTEXTMENU:
         POINT ptScreen;
         ptScreen.x = LOWORD(lp);
         ptScreen.y = HIWORD(lp);
         OnRightClick (pmMACHINE, GetDlgItem (hDlg, IDC_MACHINES_LIST), &ptScreen);
         break;

      case WM_COMMAND:
         switch (LOWORD(wp))
            {
            case IDC_MACHINES_PATTERN:
               if (HIWORD(wp) == EN_UPDATE)
                  {
                  l.dwTickLastType = GetTickCount();
                  KillTimer (hDlg, ID_SEARCH_TIMER);
                  SetTimer (hDlg, ID_SEARCH_TIMER, msecSEARCH_TIMER +15, NULL);
                  }
               break;

            default:
               OnContextCommand (LOWORD(wp));
               break;
            }
         break;

      case WM_NOTIFY:
         switch (((LPNMHDR)lp)->code)
            {
            case FLN_ITEMSELECT:
               Main_SetMenus();
               Machines_EnableButtons(hDlg);
               break;

            case FLN_LDBLCLICK:
               PostMessage (hDlg, WM_COMMAND, MAKELONG(M_PROPERTIES,BN_CLICKED), (LPARAM)GetDlgItem (hDlg, M_PROPERTIES));
               break;
            }
         break;
      }

   return FALSE;
}
Ejemplo n.º 13
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();
}