Beispiel #1
0
def IShouldCatchShortcutEvent(evt_handler,
                              child_tlp_classes_who_can_pass_up=None):

    if HC.PLATFORM_WINDOWS and FLASHWIN_OK:

        window = wx.FindWindowAtPointer()

        if window is not None and isinstance(window,
                                             wx.lib.flashwin.FlashWindow):

            return False

    if not ClientGUIFunctions.WindowOrSameTLPChildHasFocus(evt_handler):

        if child_tlp_classes_who_can_pass_up is not None:

            child_tlp_has_focus = ClientGUIFunctions.WindowOrAnyTLPChildHasFocus(
                evt_handler) and isinstance(ClientGUIFunctions.GetFocusTLP(),
                                            child_tlp_classes_who_can_pass_up)

            if not child_tlp_has_focus:

                return False

        else:

            return False

    return True
Beispiel #2
0
    def MouseLeftUp(self, event):
        if self.dragging and self.dragged:
            self.OnMouseCaptureLost(event)

            targetWnd, _ = wx.FindWindowAtPointer()

            if not targetWnd:
                return

            wnd = targetWnd
            while wnd is not None:
                handler = getattr(wnd, "handleDrag", None)
                if handler:
                    handler("fit", self.fitID)
                    break
                else:
                    wnd = wnd.Parent
            event.Skip()
            return

        if self.dragging:
            self.dragging = False

        if self.tcFitName.IsShown():
            self.RestoreEditButton()
        else:
            activeFitID = self.mainFrame.getActiveFit()
            if activeFitID != self.fitID:
                self.selectFit()
Beispiel #3
0
 def OnLeftDown(self, evt):
     self.ReleaseMouse()
     wnd, pt = wx.FindWindowAtPointer()
     if wnd is not None:
         self.SetObj(wnd)
     else:
         wx.Bell()
     self.OnCaptureLost(evt)
Beispiel #4
0
 def ShowInspectionTool(self):
     """
     Show the Inspection tool, creating it if neccesary, setting it
     to display the widget under the cursor.
     """
     # get the current widget under the mouse
     wnd, pt = wx.FindWindowAtPointer()
     InspectionTool().Show(wnd)
Beispiel #5
0
    def openWXInspectTool(self, event):
        if not InspectionTool().initialized:
            InspectionTool().Init()

        # Find a widget to be selected in the tree.  Use either the
        # one under the cursor, if any, or this frame.
        wnd, _ = wx.FindWindowAtPointer()
        if not wnd:
            wnd = self
        InspectionTool().Show(wnd, True)
Beispiel #6
0
 def OnActivate(self, event):
     if not event.GetActive():
         wnd = wx.FindWindowAtPointer()
         if wnd:
             wnd = wnd[0]
         while wnd:
             if wnd == self:
                 return
             wnd = wnd.GetParent()
         self.Cancel()
     event.Skip()
Beispiel #7
0
    def __paint(self, e):
        dc2 = wx.PaintDC(self)
        r = self.SplitRect

        if r is None: return e.Skip()

        bg = 'bg'
        if wx.FindWindowAtPointer() is self:
            bg = 'bgactive' if wx.LeftDown() else 'bghover'

        wx.CallAfter(
            lambda: getattr(self, bg).Draw(wx.ClientDC(self), self.SplitRect))
Beispiel #8
0
    def OnOpenWidgetInspector(self, event):
        """
        Activate the widget inspection tool,
        giving it a widget to preselect in the tree.
        Use either the one under the cursor,
        if any, or this frame.
        """

        from wx.lib.inspection import InspectionTool
        wnd = wx.FindWindowAtPointer()
        if not wnd:
            wnd = self
        InspectionTool().Show(wnd, True)
Beispiel #9
0
 def ShowShell(self):
     """
     Show the PyCrust window.
     """
     if not self._crust:
         self._crust = wx.py.crust.CrustFrame(self.GetTopWindow(),
                                              pos=self._pos,
                                              size=self._size)
         self._crust.shell.interp.locals['app'] = self
         self._crust.shell.interp.locals['wx'] = wx
     win = wx.FindWindowAtPointer()
     self._crust.shell.interp.locals['win'] = win
     self._crust.Show()
Beispiel #10
0
    def OnOpenWidgetInspector(self, evt):
        "borrowed from the wxPython demo (from Main.py)"
        # Activate the widget inspection tool
        from wx.lib.inspection import InspectionTool
        if not InspectionTool().initialized:
            InspectionTool().Init()

        # Find a widget to be selected in the tree.  Use either the
        # one under the cursor, if any, or this frame.
        wnd = wx.FindWindowAtPointer()
        if not wnd:
            wnd = self
        InspectionTool().Show(wnd, True)
Beispiel #11
0
def _onpopupshown(self, menu):
    'Invoked just before the conversation area menu is shown.'

    # Should we show the paste item?
    ctrl = wx.FindWindowAtPointer()

    # Retarget "edit" menu items
    for name, item in self.edit_items.iteritems():
        #TODO: why does removing "Paste" cause a hard crash?
        method = getattr(ctrl, name, None)

        capable_method = getattr(ctrl, 'Can%s' % name, None)
        try:
            should_enable = False
            if capable_method is not None:
                should_enable = capable_method()
        except Exception:
            traceback.print_exc()
            item.Enable(method is not None
                        and (ctrl is not getattr(self, 'message_area', None)
                             or name != 'Paste'))
        else:
            item.Enable(should_enable)

        if method is not None:
            item.SetCallback(method)

    # "always on top" checkbox: checked if on top
    self.keep_on_top.Check(self.Top.OnTop)

    # menu items for capabilities (Info, IM, SMS, ...)
    # "active" if ImWin is in that mode
    Button = self.capsbar.GetButton
    buddy = self.Buddy

    from common import caps

    for bname, menuitem in self.capsbuttons.iteritems():
        if menuitem.IsCheckable():
            menuitem.Check(self.mode == bname)

        if bname == 'files':
            menuitem.Enable(buddy is not None and buddy.online
                            and caps.FILES in buddy.caps)
        elif bname == 'sms':
            menuitem.Enable(buddy is not None and caps.SMS in buddy.caps)
        elif bname == 'email':
            menuitem.Enable(buddy is not None and caps.EMAIL in buddy.caps)

    self.roomlist_item.Check(self.is_roomlist_shown())
Beispiel #12
0
    def OnPaint(self, event):
        dc = wx.AutoBufferedPaintDC(self)
        s, icon = self.Size, self.icon
        rect = wx.RectS(s)

        if self.dpoint:
            self.activebg.Draw(dc, rect)
        elif wx.FindWindowAtPointer() is self:
            self.hoverbg.Draw(dc, rect)
        else:
            self.normalbg.Draw(dc, rect)

        if icon:
            dc.DrawBitmap(icon, (s.width - icon.Width) / 2,
                          (s.height - icon.Height) / 2, True)
Beispiel #13
0
    def OnMotion(self,event):
        rect = wx.RectS(self.ClientSize)
        wap = wx.FindWindowAtPointer()
        mp = event.Position

        if not rect.Contains(mp) or wap != self:
            while self.HasCapture():
                self.ReleaseMouse()

            self.Hovered = -1
            return

        elif not self.HasCapture():
            self.CaptureMouse()

        self.Hovered = self.HitTest(mp)
Beispiel #14
0
    def OnPaint(self,event):
        dc = wx.AutoBufferedPaintDC(self)

        rect = wx.RectS(self.Size)

        if wx.FindWindowAtPointer() is self:
            self.hoverbg.Draw(dc, rect)
        else:
            self.normalbg.Draw(dc, rect)

        W, H = self.GetSize()
        w, h = self.bitmap.GetSize()

        # drawing it centered on the box
        if self.bitmap is not None:
            dc.DrawBitmap(self.bitmap, W/2 - w/2, H/2 - h/2, True)
Beispiel #15
0
 def _on_mousewheel(self, e):
     if e.RightIsDown():
         self._menu_ok = False
         ib = self.infobox
         rot = e.WheelRotation
         if rot < 0:
             ib.SelectNext()
         elif rot > 0:
             ib.SelectLast()
     else:
         # forward the mousewheel event to the infobox
         win = wx.FindWindowAtPointer()
         if isinstance(win, tuple(self.infobox_scrollers)):
             self.infobox.on_mousewheel(e)
         else:
             super(BuddyList, self)._on_mousewheel(e)
Beispiel #16
0
    def ShowInspectionTool(self):
        """
        Show the Inspection tool, creating it if neccesary.
        """
        if not self._tool:
            self._tool = InspectionFrame(parent=self.GetTopWindow(),
                                         pos=self._pos,
                                         size=self._size,
                                         config=self._config,
                                         locals=self._locals,
                                         app=self)
        # get the current widget under the mouse
        wnd = wx.FindWindowAtPointer()
        self._tool.SetObj(wnd)

        self._tool.Show()
        self._tool.Raise()
Beispiel #17
0
        def __init__(self, title):
            super().__init__(None, title=title, size=(500, 500))
            main_sizer = wx.BoxSizer(wx.VERTICAL)

            self.statsPane = MainPanel(self)
            main_sizer.Add(self.statsPane, 0, wx.EXPAND)

            self.SetSizerAndFit(main_sizer)

            if not InspectionTool().initialized:
                InspectionTool().Init()

            # Find a widget to be selected in the tree.  Use either the
            # one under the cursor, if any, or this frame.
            wnd, _ = wx.FindWindowAtPointer()
            if not wnd:
                wnd = self
            InspectionTool().Show(wnd, True)
Beispiel #18
0
    def OnMotion(self, event):
        rect = self.ClientRect
        wap = wx.FindWindowAtPointer()
        mp = event.Position
        hit = self.HitTest(mp)
        dragging = event.Dragging()
        selection = self.Selection
        thelist = self.thelist
        checked = self.checked

        if hit != -1:
            cursor = wx.CURSOR_ARROW if self._over_checkbox(
                mp, hit) else wx.CURSOR_HAND
            self.SetCursor(wx.StockCursor(cursor))

        if not dragging:
            if not rect.Contains(mp) or not wap == self:
                while self.HasCapture():
                    self.ReleaseMouse()

                self.Hovered = -1
                return

            elif not self.HasCapture():
                self.CaptureMouse()

        if dragging and -1 not in (selection, hit) and hit != selection:
            self.Selection = hit
            item = thelist[selection]

            if checked is not None:
                item_checked = checked[selection]

            thelist.pop(selection)
            thelist.insert(hit, item)

            if checked is not None:
                checked.pop(selection)
                checked.insert(hit, item_checked)

            self.Refresh()

        self.Hovered = hit
def IShouldCatchShortcutEvent( evt_handler, event = None, child_tlp_classes_who_can_pass_up = None ):
    
    if HC.PLATFORM_WINDOWS and FLASHWIN_OK:
        
        window = wx.FindWindowAtPointer()
        
        if window is not None and isinstance( window, wx.lib.flashwin.FlashWindow ):
            
            return False
            
        
    
    do_focus_test = True
    
    if event is not None and isinstance( event, wx.MouseEvent ):
        
        if event.GetEventType() == wx.wxEVT_MOUSEWHEEL:
            
            do_focus_test = False
            
        
    
    if do_focus_test:
        
        if not ClientGUIFunctions.WindowOrSameTLPChildHasFocus( evt_handler ):
            
            if child_tlp_classes_who_can_pass_up is not None:
                
                child_tlp_has_focus = ClientGUIFunctions.WindowOrAnyTLPChildHasFocus( evt_handler ) and isinstance( ClientGUIFunctions.GetFocusTLP(), child_tlp_classes_who_can_pass_up )
                
                if not child_tlp_has_focus:
                    
                    return False
                    
                
            else:
                
                return False
                
            
        
    
    return True
Beispiel #20
0
def IShouldCatchCharHook(evt_handler):

    if HC.PLATFORM_WINDOWS and FLASHWIN_OK:

        window = wx.FindWindowAtPointer()

        if window is not None and isinstance(window,
                                             wx.lib.flashwin.FlashWindow):

            return False

    if HG.client_controller.MenuIsOpen():

        return False

    if not ClientGUICommon.WindowOrSameTLPChildHasFocus(evt_handler):

        return False

    return True
Beispiel #21
0
    def OnMouseMotion(self,event):
        """
            Insures mouse in and mouse out capture events occure, also handels
            hover for the button and link
        """

        #If the left mouse button is not down, make sure the panel gets/losses
        # capture accordingly
        if not event.LeftIsDown():
            mouseisin = wx.FindWindowAtPointer() is self

            if mouseisin and not self.HasCapture():
                self.OnMouseIn(event)

            elif not mouseisin and self.HasCapture():
                self.OnMouseOut(event)

        #handle link mouseover
        if self.link:
            mouseinl = self.linkhovered = self.linkrect.Contains(event.Position)
            self.SetCursor(wx.StockCursor(wx.CURSOR_HAND if mouseinl else wx.CURSOR_DEFAULT))
Beispiel #22
0
        def onkillfocus(e):
            e.Skip()

            # dismiss on focus lost, unless we're clicking the popup itself
            if wx.FindWindowAtPointer() is not a:
                a.Dismiss()
Beispiel #23
0
def GetMenu(self):
    try:
        self._menu.Destroy()
    except AttributeError:
        pass

    from gui.uberwidgets.umenu import UMenu
    m = UMenu(self, onshow=self._onpopupshown)

    self._menu = m
    self._topid = id(self.Top)

    self.keep_on_top = m.AddCheckItem(_('&Keep on Top'),
                                      callback=self.Top.ToggleOnTop)
    self.view_past_chats_item = m.AddItem(_('&View Past Chats'),
                                          callback=self._on_view_past_chats)

    m.AddSep()

    add, addcheck, setmode = m.AddItem, m.AddCheckItem, self.set_mode

    c = self.capsbuttons = {}
    buddy = self.Buddy
    for bname, caption in buttons:
        if bname == 'files':
            c[bname] = add(caption, callback=lambda: self.Buddy.send_file())
        else:
            if buddy is None or (bname == 'sms' and 'SMS' not in buddy.caps):
                continue

            c[bname] = addcheck(
                caption,
                callback=lambda b=bname: setmode(b, toggle_tofrom=b == 'im'))

    m.AddSep()

    self.edit_items = {}
    self.edit_items['Copy'] = add(_('Copy\tCtrl+C'), id=wx.ID_COPY)

    # add a "Copy Link" item if the mouse is hovering over a link
    message_area = getattr(self, 'message_area', None)
    if message_area is not None:  # may not be created yet.
        ctrl = wx.FindWindowAtPointer()
        if ctrl is message_area:
            info = ctrl.HitTest(ctrl.ScreenToClient(wx.GetMousePosition()))
            if info.Link:
                add(_('Copy &Link'),
                    callback=lambda: clipboard.copy(info.Link))

    self.paste_item = self.edit_items['Paste'] = add(_('Paste\tCtrl+V'),
                                                     id=wx.ID_PASTE)
    self.paste_index = len(self._menu) - 1

    if pref('debug.message_area.show_edit_source', False):
        add(_('Edit Source'), callback=lambda: self.message_area.EditSource())
    if pref('debug.message_area.show_jsconsole', False):
        from gui.browser import jsconsole
        add(_('&Javascript Console'),
            callback=lambda: jsconsole.show_console())

    # text size menu
    if message_area is not None and message_area.IsShownOnScreen():
        textsize_menu = UMenu(self)
        self.textbigger = textsize_menu.AddItem(
            _('&Increase Text Size\tCtrl+='),
            callback=message_area.IncreaseTextSize)
        self.textsmaller = textsize_menu.AddItem(
            _('&Decrease Text Size\tCtrl+-'),
            callback=message_area.DecreaseTextSize)
        textsize_menu.AddSep()
        textsize_menu.AddItem(_('&Reset Text Size\tCtrl+0'),
                              callback=message_area.ResetTextSize)

        m.AddSubMenu(textsize_menu, _('&Text Size'))

    m.AddSep()

    # these checkboxes affect a global preference that immediately takes effect in
    # all open ImWins
    self.roomlist_item = m.AddCheckItem(_('Show &Room List'),
                                        callback=self.toggle_roomlist)
    self.actions_item = m.AddPrefCheck('messaging.show_actions_bar',
                                       _('Show &Actions Bar'))
    self.formatting_item = m.AddPrefCheck('messaging.show_formatting_bar',
                                          _('Show &Formatting Bar'))

    return self._menu
Beispiel #24
0
    def autohidden_mouseover(self):
        if self.Enabled and self.autohidden and self.motiontrigger and wx.FindWindowAtPointer() is self.win:

            self.ComeBack()
Beispiel #25
0
def 程序_取鼠标处组件跟坐标():
    '取当前鼠标下面的组件及坐标,返回格式:(组件,(x,y)),返回的坐标是相对于桌面的坐标'
    return wx.FindWindowAtPointer()
Beispiel #26
0
    def DragCalc(self,point):
        """
            This does the dragging calculations for the tabs
        """

        sidetabs = self.side_tabs

        # if here is no local origin tab but there is a remote source identified in TabMan
        if not self.dragorigin and self.Manager.source:
            #setting a local drag origin
            master = self.Manager.source
            dragorigin=master.tabbar.dragorigin
            # announcing to TabMan it is expecting a tab
            self.Manager.Request(self.Notebook)
        # if there is a local origin use that
        else:
            dragorigin=self.dragorigin

        # if dragtarget is out of date find what you're dragging to
        if not self.dragtarget or not self.dragtarget.Rect.Contains(point):

            wap = wx.FindWindowAtPointer()
            self.dragtarget = wap if isinstance(wap,Tab) else None
            self.dragside   = None

        # if there is a tab as target
        if self.dragtarget and self.dragtarget != dragorigin:
            dtrect=self.dragtarget.Rect
            # data to decide what side the tab would be dropped on
            if not sidetabs:
                x  = point[0] - dtrect.x
                x2 = dtrect.width / 2
            else:
                x  = point[1] - dtrect.y
                x2 = dtrect.height / 2
            # make the left/top or right/bottom decision
            if x <= x2:#left/top
                if self.dragside!=False:
                    self.dragside=False
                    if not sidetabs:
                        self.DrawDropMarker(dtrect.x, dtrect.y)# + (dtrect.height // 2)
                    else:
                        self.DrawDropMarker(dtrect.x, dtrect.y)# + dtrect.width // 2

            elif not self.dragside:#right/bottom
                self.dragside=True
                if not sidetabs:
                    self.DrawDropMarker(dtrect.x+dtrect.width,dtrect.y)#+(dtrect.height//2)
                else: self.DrawDropMarker(dtrect.x,dtrect.y+dtrect.height)#+dtrect.width//2
            self.SetFocus()
        # if being dropped in the whitespace of the TabBar
        elif (dragorigin and self.dragtarget!=dragorigin) or (dragorigin==None and self.dragtarget==None) and self.Rect.Contains(point):
            # find what row the tab is being dropped in
            if not sidetabs:
                row=self.rows[(point[1]//self.rowheight)+self.rowindex]
                tab=row[len(row)-1]
                self.dragside=True
            # or in vertical if at the beginning or end
            else:
                if point.y>self.rowheight:
                    tab=self.rows[0][len(self.rows[0])-1]
                    self.dragside=True
                else:
                    tab=self.rows[0][0]
                    self.dragside=False
            dtrect=tab.Rect
            #Place marker
            if not sidetabs: self.DrawDropMarker(dtrect.x+dtrect.width,dtrect.y)#+(dtrect.height//2)
            elif self.dragside==True: self.DrawDropMarker(dtrect.x,dtrect.y+dtrect.height)#+dtrect.width//2
            else: self.DrawDropMarker(dtrect.x+dtrect.width/2,dtrect.y)
            self.SetFocus()
            #cleanup
            self.dragtarget=tab

        else:#if not in tabbar anymore don't show arrow
            self.dropmarker.Show(False)