def OnMouseMove(self, event): 'Mouse over event handling.' mp = self.ScreenToClient(GetMousePosition()) items = self.items if self.ClientRect.Contains(mp): n = self.HitTest(mp) if self.Selection != n: do( item.menu.Show(False) for item in self.items if item.menu and item.menu.IsShown()) if items[n].id != -1: self.SetSelection(n) if items[n].menu: items[n].menu.DelayedDisplay(self.GetItemRect(n), self) else: self.SetSelection(-1) elif self.Rect.Contains(mp): self.Parent.CascadeRelease() self.recaptimer = RecapTimer(self) else: self.SetSelection(-1) gp = self.GrandParent if isinstance(gp, SimpleMenu) and gp.CheckParentalContact( GetMousePosition()): gp.spine.AddPendingEvent(event)
def OnMouseMove(self, event): rect = RectS(self.Size) pos = self.ScreenToClient(GetMousePosition()) if not rect.Contains(pos): self.OnMouseLeave(event) elif not self.hover: self.OnMouseEnter(event)
def Up(self, prevRect, newSize, user_action): border, padding = self.border, self.padding if prevRect is None: if LEFT & self.corner: pt = self.ScreenRect.BottomLeft + (border.x + padding.x + self.offset[0], -border.y - self.offset[1]) else: pt = self.ScreenRect.BottomRight - (newSize.width + border.x + padding.x + self.offset[0], border.y + self.offset[1]) else: pt = prevRect.TopLeft - Point(0, border.y + padding.y) r = RectPS(pt - Point(0, newSize.height), newSize) if AVOID_MOUSE and not user_action and r.Contains(GetMousePosition()): r.y -= r.Bottom - GetMousePosition().y + AVOID_MOUSE_PIXELS return r
def UploadMax(self): pos = GetMousePosition() pos = (pos[0]+15,pos[1]) self.frame5.SetPosition(pos) def timestop(): self.frame5.Show(False) timer.cancel() self.frame5.Show(True) timer = Timer(5.0, timestop) timer.start()
def on_motion(self, e=None, forcednewpos=None): if self.dragging is not False: newpos = forcednewpos or GetMousePosition() delta = newpos - Point(*self.dragging) diff = (float(delta.x) / self.bitmap.Width, float(delta.y) / self.bitmap.Height) self.adjustment = (self.adjustment[0] + diff[0], self.adjustment[1] + diff[1]) self.dragging = newpos self.Refresh() self._image_changed = True self._image_bytes = None
def PopupMenu(self, pos=None, submenu=False, event=None): if not submenu: self.dismiss_old() if event is not None: # mark a WX event as handled event.Skip(False) self._set_menu_event(event) if 'wxMSW' in wx.PlatformInfo and self.Windowless: from gui.native.win.wineffects import _smokeFrame if _smokeFrame: _smokeFrame.SetFocus() self._menuevent = event try: onshow = self._onshow except AttributeError: pass else: onshow(self) finally: del self._menuevent with traceguard: if self.skin.get('native', False): if pos is None: pos = GetMousePosition() elif len(pos) == 4: # if a rectangle was passed in, get the bottom left coordinate # since we can only pass a point to the native PopupMenu pos = pos.BottomLeft # wx.Window.PopupMenu expects coordinates relative to the control popup = lambda pos: self.Window.PopupMenu( self, self.Window.ScreenToClient(pos)) else: popup = lambda pos: self.popup.PopupMenu(pos, submenu=submenu) # keep a weak reference to the last skinned menu so we can # Dismiss it later, if needed. UMenu.last_menu = ref(self) return popup(pos)
def Notify(self): try: mp = GetMousePosition() ms = GetMouseState() except Exception: return if not (ms.LeftDown() or ms.RightDown() or ms.MiddleDown()): return menu = self.umenu while menu != None: if menu.ScreenRect.Contains(mp): return else: submenu = menu.menu._childmenu menu = submenu.popup.vlist if submenu is not None else None self.Stop() self.umenu.Dismiss()
class Monitor(object): def __init__(self, hmonitor): self.hmonitor = hmonitor def GetClientArea(self): try: return self._clientarea except AttributeError: self._getinfo() return self._clientarea ClientArea = property(GetClientArea) def GetGeometry(self): try: return self._geometry except AttributeError: self._getinfo() return self._geometry Geometry = property(GetGeometry) def GetDeviceId(self): try: return self._deviceid except AttributeError: self._getinfo() return self._deviceid DeviceId = property(GetDeviceId) GetFromPoint = staticmethod(Monitor_FromPoint) GetFromPointer = staticmethod(lambda: Monitor_FromPoint(GetMousePosition(), find_near = True)) GetFromWindow = staticmethod(Monitor_FromWindow) GetFromRect = staticmethod(Monitor_FromRect) GetFromHandle = staticmethod(Monitor_FromHandle) GetFromDeviceId = staticmethod(Monitor_FromDeviceId) @staticmethod def GetCount(): return len(get_hmonitors()) @staticmethod def All(): return [Monitor(hmonitor) for hmonitor in get_hmonitors()] if hasattr(cgui, 'GetMonitorInfo'): def _getinfo(self): work, mon, self._deviceid = cgui.GetMonitorInfo(self.hmonitor) self._clientarea = RECTtuple_to_rect(work) self._geometry = RECTtuple_to_rect(mon) else: def _getinfo(self): info = MONITORINFOEX() info.cbSize = MONITORINFOEX_size if not GetMonitorInfo(self.hmonitor, byref(info)): raise WinError() self._clientarea = wxRectFromRECT(info.rcWork) self._geometry = wxRectFromRECT(info.rcMonitor) self._deviceid = wstring_at(info.szDevice) def IsPrimary(self): pos = self.Geometry.Position # Primary monitor is always at (0, 0) if pos.x == pos.y == 0: return True return False Primary = property(IsPrimary)
def on_mouse_down(self, e): e.Skip() if e.LeftDown(): self.startdrag = self.dragging = GetMousePosition() self.CaptureMouse()