本文整理汇总了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);
}
示例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();
}
示例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;
}
示例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 );
}
示例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;
}
示例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();
}
}
}
}
}
示例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);
}
示例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);
}
示例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();
}
}
示例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;
}
}
示例11: wxGetMousePosition
void GraphicsWindowWX::grabFocusIfPointerInWindow()
{
// focus this window, if the pointer is in the window
wxPoint pos = wxGetMousePosition();
if( wxFindWindowAtPoint( pos ) == _canvas )
_canvas->SetFocus();
}
示例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 {
示例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);
}
}
示例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);
}
示例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;
}