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


C++ wxGetMousePosition函数代码示例

本文整理汇总了C++中wxGetMousePosition函数的典型用法代码示例。如果您正苦于以下问题:C++ wxGetMousePosition函数的具体用法?C++ wxGetMousePosition怎么用?C++ wxGetMousePosition使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: ScreenToClient

void wxJigsawEditorCanvas::OnIdle( wxIdleEvent& event )
{	
	do
	{
		if(!HasCapture()) break;

		// get mouse in client coordinates
		wxPoint currentPos = ScreenToClient(wxGetMousePosition());

		//Update the offset to the next mouse down event
		if(m_View->GetSelectedObject())
		{
			wxPoint diagramPoint = PointToViewPoint(currentPos);
			wxPoint groupPosition = m_View->GetRealGroupPosition(m_View->GetSelectedObject());
			m_SelectedObjectOffset = wxSize(
				diagramPoint.x - groupPosition.x,
				diagramPoint.y - groupPosition.y);
		}

		// get scroll position
		wxPoint scrollPos = GetScrollPosition();
		

		// auto scroll
		// check current drag position and update scroll regularly
		if(AutoScroll(currentPos, scrollPos))
		{
			event.RequestMore();
		}
		FixViewOffset();
	}
	while(false);
}
开发者ID:cubemoon,项目名称:game-editor,代码行数:33,代码来源:wxJigsawEditorCanvas.cpp

示例2: GetScreenRect

void tabButton::updateMouse(wxMouseEvent& event)
{
	if (m_bSelected)
		return;

	wxRect panelRec = GetScreenRect();
	panelRec.x += 2;
	panelRec.y += 2;
	panelRec.width -= 4;
	panelRec.height -= 4;

	wxPoint mousePoint = wxGetMousePosition();

	bool t1 = panelRec.x <= mousePoint.x;
	bool t2 = panelRec.y <= mousePoint.y;
	bool t3 = (panelRec.x + panelRec.width ) >= mousePoint.x;
	bool t4 = (panelRec.y + panelRec.height) >= mousePoint.y;

	if (t1 && t2 && t3 && t4)
	{
		this->SetBackgroundColour( MOUSEOVER );
	}
	else
	{
		this->SetBackgroundColour( NORMAL );
	}

	this->Refresh();
}
开发者ID:EasyCoding,项目名称:desura-app,代码行数:29,代码来源:TabButton.cpp

示例3: wxMenu

/**< context menu */
void ImagePanel::OnContextMenu(wxContextMenuEvent& event)
{
	if (m_stMP.iState != 0)
		return;

	wxMenu* pMenu = new wxMenu();
	wxASSERT_MSG(pMenu != nullptr, _T("Create Popup Menu failed."));
	wxMenuItem* pMenuItem = nullptr;
	// group 1
	if (m_img.IsOk())
	{
		pMenuItem = new wxMenuItem(pMenu, ID_CMENU_SAVE, _("&Save Image"), _("Save the Image"));
		pMenu->Append(pMenuItem);
	}
	// popup
	if (pMenuItem != nullptr)
	{
		wxPoint pt = event.GetPosition();
		if (pt == wxDefaultPosition)
		{
			// position invalide, get the mouse position
			pt = wxGetMousePosition();
			wxRect rc = GetScreenRect();
			if (!rc.Contains(pt))
			{
				// mouse is't in the panel, get the panel center
				pt.x = rc.x + rc.width/2;
				pt.y = rc.y + rc.height/2;
			}
		}
		pt = ScreenToClient(pt);
		PopupMenu(pMenu, pt);
	}
	delete pMenu;
}
开发者ID:gxcast,项目名称:GEIM,代码行数:36,代码来源:ImagePanel.cpp

示例4: wxFillOtherKeyEventFields

static void wxFillOtherKeyEventFields(wxKeyEvent& event,
                                      wxWindowGTK *win,
                                      GdkEventKey *gdk_event)
{
    int x = 0;
    int y = 0;
    GdkModifierType state;
    if (gdk_event->window)
        gdk_window_get_pointer(gdk_event->window, &x, &y, &state);

    event.SetTimestamp( gdk_event->time );
    event.SetId(win->GetId());
    event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK) != 0;
    event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK) != 0;
    event.m_altDown = (gdk_event->state & GDK_MOD1_MASK) != 0;
    event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK) != 0;
#if wxMAJOR_VERSION == 2
    event.m_scanCode = gdk_event->keyval;
#endif
    event.m_rawCode = (wxUint32) gdk_event->keyval;
    event.m_rawFlags = 0;
#if wxUSE_UNICODE
    event.m_uniChar = gdk_keyval_to_unicode(gdk_event->keyval);
#endif
    wxGetMousePosition( &x, &y );
    win->ScreenToClient( &x, &y );
    event.m_x = x;
    event.m_y = y;
    event.SetEventObject( win );
}
开发者ID:JamesWCCheng,项目名称:wxMEdit,代码行数:30,代码来源:wxmedit_gtk.cpp

示例5: wxGetMouseState

wxMouseState wxGetMouseState()
{
    wxMouseState ms;

    wxPoint pt = wxGetMousePosition();
    ms.SetX(pt.x);
    ms.SetY(pt.y);

#if TARGET_API_MAC_OSX
    UInt32 buttons = GetCurrentButtonState();
    ms.SetLeftDown( (buttons & 0x01) != 0 );
    ms.SetMiddleDown( (buttons & 0x04) != 0 );
    ms.SetRightDown( (buttons & 0x02) != 0 );
#else
    ms.SetLeftDown( Button() );
    ms.SetMiddleDown( 0 );
    ms.SetRightDown( 0 );
#endif

    UInt32 modifiers = GetCurrentKeyModifiers();
    ms.SetControlDown(modifiers & controlKey);
    ms.SetShiftDown(modifiers & shiftKey);
    ms.SetAltDown(modifiers & optionKey);
    ms.SetMetaDown(modifiers & cmdKey);

    return ms;
}
开发者ID:hgwells,项目名称:tive,代码行数:27,代码来源:app.cpp

示例6: wxGetMousePosition

void wxPopupTransientWindow::OnIdle(wxIdleEvent& event)
{
    event.Skip();

    if (IsShown() && m_child)
    {
        // Store the last mouse position to minimize the number of calls to
        // wxFindWindowAtPoint() which are quite expensive.
        static wxPoint s_posLast;
        const wxPoint pos = wxGetMousePosition();
        if ( pos != s_posLast )
        {
            s_posLast = pos;

            wxWindow* const winUnderMouse = wxFindWindowAtPoint(pos);

            // We release the mouse capture while the mouse is inside the popup
            // itself to allow using it normally with the controls inside it.
            if ( wxGetTopLevelParent(winUnderMouse) == this )
            {
                if ( m_child->HasCapture() )
                {
                    m_child->ReleaseMouse();
                }
            }
            else // And we reacquire it as soon as the mouse goes outside.
            {
                if ( !m_child->HasCapture() )
                {
                    m_child->CaptureMouse();
                }
            }
        }
    }
}
开发者ID:lanurmi,项目名称:wxWidgets,代码行数:35,代码来源:popupcmn.cpp

示例7: Paint

    virtual void Paint( wxDC &dc )
    {
        wxCustomButton *dropBut = ((wxMenuButton*)GetParent())->GetDropDownButton();

        // pretend that both buttons have focus (for flat style)
        if (dropBut)
        {
            wxPoint p = GetParent()->ScreenToClient(wxGetMousePosition());

            if (GetRect().Contains(p) || dropBut->GetRect().Contains(p))
            {
                m_focused = true;

                if (!dropBut->GetFocused())
                    dropBut->SetFocused(true);
            }
            else
            {
                m_focused = false;

                if (dropBut->GetFocused())
                    dropBut->SetFocused(false);
            }
        }

        wxCustomButton::Paint(dc);
    }
开发者ID:DowerChest,项目名称:codeblocks,代码行数:27,代码来源:menubtn.cpp

示例8: Paint

    virtual void Paint( wxDC &dc )
    {
        wxCustomButton *labelBut = ((wxMenuButton*)GetParent())->GetLabelButton();

        // pretend that both buttons have focus (for flat style)
        if (labelBut)
        {
            wxPoint p = GetParent()->ScreenToClient(wxGetMousePosition());

            if (GetRect().Inside(p) || labelBut->GetRect().Inside(p))
            {
                m_focused = true;

                if (!labelBut->GetFocused())
                    labelBut->SetFocused(true);
            }
            else
            {
                m_focused = false;

                if (labelBut->GetFocused())
                    labelBut->SetFocused(false);
            }
        }

        wxCustomButton::Paint(dc);
    }
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:27,代码来源:menubtn.cpp

示例9: GetScreenRect

void StripMenuButton::updateMouse()
{
	wxRect panelRec = GetScreenRect(); 
	panelRec.x += 2;
	panelRec.y += 2;
	panelRec.width -= 4;
	panelRec.height -= 4;

	wxPoint mousePoint = wxGetMousePosition();

	bool t1 = panelRec.x <= mousePoint.x;
	bool t2 = panelRec.y <= mousePoint.y;
	bool t3 = (panelRec.x + panelRec.width ) >= mousePoint.x;
	bool t4 = (panelRec.y + panelRec.height) >= mousePoint.y;

	if (t1 && t2 && t3 && t4)
	{
		if (!m_bHovering)
		{
			SetForegroundColour( m_colHover );
			m_bHovering = true;
			invalidatePaint();
			this->Refresh();
		}
	}
	else if (m_bHovering)
	{
		SetForegroundColour( m_colNormal );
		m_bHovering = false;
		invalidatePaint();
		this->Refresh();
	}
}
开发者ID:CSRedRat,项目名称:desura-app,代码行数:33,代码来源:StripMenuButton.cpp

示例10: switch

void ActorSceneCanvas::OnMouseCaptureChanged(wxMouseCaptureChangedEvent& e)
{
    if (e.GetEventObject() == this && e.GetCapturedWindow() != this)
    {
        switch (mDragButton)
        {
        case wxMOUSE_BTN_MIDDLE:
            {
                wxASSERT(m_pCameraManip);
                wxPoint pt = wxGetMousePosition();
                pt = ScreenToClient(pt);
                m_pCameraManip->onEnd(pt.x, pt.y, true);
                m_pCameraManip = NULL;
                break;
            }

        case wxMOUSE_BTN_LEFT:
            {
                //wxASSERT(GetActiveAction());
                //wxPoint pt = wxGetMousePosition();
                //pt = ScreenToClient(pt);
                //GetActiveAction()->onEnd(pt.x, pt.y, true);
                m_pUpdateListener->disable();
            }
            break;
        }

        mDragButton = wxMOUSE_BTN_NONE;
    }
}
开发者ID:jjiezheng,项目名称:pap_full,代码行数:30,代码来源:WXSceneCanvas.cpp

示例11: wxGetMousePosition

void GraphicsWindowWX::grabFocusIfPointerInWindow()
{
    // focus this window, if the pointer is in the window
    wxPoint pos = wxGetMousePosition();
    if( wxFindWindowAtPoint( pos ) == _canvas )
        _canvas->SetFocus();
}
开发者ID:yaroslav-tarasov,项目名称:backdropfx,代码行数:7,代码来源:wxpick.cpp

示例12: wxGetMousePosition

void ggscfg_ColorEditSheet::on_timer(wxTimerEvent& event) {

  if (this->IsShown() == false) {
    return;
  }

    static int pulse = 0;
  pulse = pulse++ % 10;
  static bool oldinv = 0;

  wxPoint pt = wxGetMousePosition();

  // 選択パレット変更
  wxPoint pal_pt = ScreenToClient(pt);
  wxRect bounds = m_panel_palette->GetRect();
  bounds.Deflate(1, 1);
  if (bounds.Contains(pal_pt)) {
    m_select_palette = ((pal_pt.x - m_panel_palette->GetRect().GetLeft()) / 8) + ((pal_pt.y - m_panel_palette->GetRect().GetTop()) & ~7);
    if (m_select_palette < 0 || m_select_palette >= m_palette_size) {
      m_select_palette = -1;
    }
  } else {
    m_select_palette = -1;
  }

  // 画像からも選択パレット変更する
  wxPoint img_pt = m_scrolledWindow_sprite->ScreenToClient(pt);
  if (img_pt.x >= 0 && img_pt.x < m_image_w && img_pt.y >= 0 && img_pt.y < m_image_h) {
    if (m_palette_size == 16) {
      if (img_pt.x & 1) {
        m_select_palette = (m_image[img_pt.x / 2 + img_pt.y * m_image_w] >> 4) & 0x0f;
      } else {
        m_select_palette =  m_image[img_pt.x / 2 + img_pt.y * m_image_w] & 0x0f;
      }
    } else {
开发者ID:assick,项目名称:ggspc,代码行数:35,代码来源:ggscfg_ColorEditSheet.cpp

示例13: GetSize

void ColorPanel::onLeftDown( wxMouseEvent& event ) {
    int w = 0;
    int h = 0;
    GetSize(&w, &h);

    float w47 = (float)w / 47.0;

    int x = 0;
    int y = 0;
    int sx = 0;
    int sy = 0;

    wxGetMousePosition( &x, &y );
    GetScreenPosition(&sx, &sy);

    int l_selX = (x - sx);
    int l_selY = (y - sy);

    int section   = (int)(l_selX / w47);
    float rest    = l_selX - (section * w47);
    float demisec = w47 / 2.0;

    if( rest >= demisec  )
        section += 1.0;

    TraceOp.trc( "colorpanel", TRCLEVEL_INFO, __LINE__, 9999, "select even at %d,%d -> %d rest=%f demisec=%f w47=%f",
                 l_selX, l_selY, section, rest, demisec, w47 );

    if( m_Listener != NULL ) {
        iONode node = NodeOp.inst( wWeather.name(), NULL, ELEMENT_NODE );
        NodeOp.setInt(node, "section", section );
        m_Listener->handleEvent(node);
        NodeOp.base.del(node);
    }
}
开发者ID:pmansvelder,项目名称:Rocrail,代码行数:35,代码来源:colorpanel.cpp

示例14: Paint

    virtual void Paint( wxDC &dc )
    {
        wxCustomButton *labelBut = ((wxMenuButton*)GetParent())->GetLabelButton();

        // pretend that both buttons have focus (for flat style)
        if (labelBut)
        {
            wxPoint p = GetParent()->ScreenToClient(wxGetMousePosition());

#if (wxMINOR_VERSION<8)
            if (GetRect().Inside(p) || labelBut->GetRect().Inside(p))
#else
            if (GetRect().Contains(p) || labelBut->GetRect().Contains(p))
#endif
            {
                m_focused = TRUE;

                if (!labelBut->GetFocused())
                    labelBut->SetFocused(TRUE);
            }
            else
            {
                m_focused = FALSE;

                if (labelBut->GetFocused())
                    labelBut->SetFocused(FALSE);
            }
        }

        wxCustomButton::Paint(dc);
    }
开发者ID:erelh,项目名称:gpac,代码行数:31,代码来源:menubtn.cpp

示例15: wxASSERT_MSG

bool wxTaskBarIcon::PopupMenu(wxMenu *menu)
{
    wxASSERT_MSG( m_win != NULL, wxT("taskbar icon not initialized") );

    static bool s_inPopup = false;

    if (s_inPopup)
        return false;

    s_inPopup = true;

    int         x, y;
    wxGetMousePosition(&x, &y);

    m_win->Move(x, y);

    m_win->PushEventHandler(this);

    menu->UpdateUI();

    // the SetForegroundWindow() and PostMessage() calls are needed to work
    // around Win32 bug with the popup menus shown for the notifications as
    // documented at http://support.microsoft.com/kb/q135788/
    ::SetForegroundWindow(GetHwndOf(m_win));

    bool rval = m_win->PopupMenu(menu, 0, 0);

    ::PostMessage(GetHwndOf(m_win), WM_NULL, 0, 0L);

    m_win->PopEventHandler(false);

    s_inPopup = false;

    return rval;
}
开发者ID:EEmmanuel7,项目名称:wxWidgets,代码行数:35,代码来源:taskbar.cpp


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