コード例 #1
0
ファイル: getdata-0.2-py3.py プロジェクト: blacksong/getdata
    def OnMotion(self, evt):
        pos=evt.GetPosition()
        shape=self.shape
        enlargeWindow.setPos(shape.pos0,(pos.x,pos.y),(shape.img.GetWidth()*shape.rate,shape.img.GetHeight()*shape.rate),self.window.GetSize())
        # Ignore mouse movement if we're not dragging.
        if not self.dragShape  or not evt.RightIsDown():#or not evt.Dragging()
            return
        # if we have a shape, but haven't started dragging yet
        if self.dragShape and not self.dragImage0:
            # only start the drag after having moved a couple pixels
            # refresh the area of the window where the shape was so it
            # will get erased.
            wsize=self.window.GetSize()
            self.showMark=False
            self.dragShape.shown = False
            pw,ph=self.shape.pos
            x0=max((0,pw))
            y0=max((0,ph))
            x1=min((wsize[0],self.shape.bmp.GetWidth()+pw))
            y1=min((wsize[1],self.shape.bmp.GetHeight()+ph))
            self.window.RefreshRect(wx.Rect(x0,y0,x1-x0,y1-y0), True)
            self.window.Update()

            self.dragImage0 = wx.DragImage(self.dragShape.bmp,wx.Cursor(wx.CURSOR_HAND))
            hotspot = self.dragStartPos - self.dragShape.pos
            self.dragImage0.BeginDrag(hotspot, self.window, self.dragShape.fullscreen)
            self.dragImage0.Move(pos)
            self.dragImage0.Show()
        # if we have shape and image then move it, posibly highlighting another shape.
        if self.dragShape and self.dragImage0:
            self.dragImage0.Move(evt.GetPosition())
コード例 #2
0
ファイル: util.py プロジェクト: wangdyna/wxPython
    def CreateDragString(self, txt):
        """Creates a bitmap of the text that is being dragged
        @todo: possibly set colors to match highlighting of text
        @todo: generalize this to be usable by other widgets besides stc

        """
        if not issubclass(self.window.__class__, wx.stc.StyledTextCtrl):
            return

        stc = self.window
        txt = txt.split(stc.GetEOLChar())
        longest = (0, 0)
        for line in txt:
            ext = stc.GetTextExtent(line)
            if ext[0] > longest[0]:
                longest = ext

        cords = [(0, x * longest[1]) for x in xrange(len(txt))]
        mdc = wx.MemoryDC(
            wx.EmptyBitmap(longest[0] + 5, longest[1] * len(txt), 32))
        mdc.SetBackgroundMode(wx.TRANSPARENT)
        mdc.SetTextForeground(stc.GetDefaultForeColour())
        mdc.SetFont(stc.GetDefaultFont())
        mdc.DrawTextList(txt, cords)
        self._tmp = wx.DragImage(mdc.GetAsBitmap())
コード例 #3
0
ファイル: Motion2.py プロジェクト: winday00/WxPtrhon_Demo
    def OnMotion(self, evt):
        if not self.dragShape or not evt.Dragging() or not evt.MiddleIsDown:
            return

        if self.dragShape and not self.dragImage:

            tolerance = 2
            pt = evt.GetPosition()
            dx = abs(pt.x - self.dragStartPos.x)
            dy = abs(pt.y - self.dragStartPos.y)
            if dx <= tolerance and dy <= tolerance:
                return
            self.dragShape.shown = False
            self.RefreshRect(self.dragShape.GetRect(), True)
            self.Update()

            item = self.dragShape.text if self.dragShape.text else self.dragShape.bmp
            self.dragImage = wx.DragImage(item,
                                         wx.Cursor(wx.CURSOR_HAND))

            hotspot = self.dragStartPos - self.dragShape.pos
            self.dragImage.BeginDrag(hotspot, self, self.dragShape.fullscreen)

            self.dragImage.Move(pt)
            self.dragImage.Show()

        elif self.dragShape and self.dragImage:
            onShape = self.FindShape(evt.GetPosition())
            unhiliteOld = False
            hiliteNew = False

            if self.hiliteShape:
                if onShape is None or self.hiliteShape is not onShape:
                    unhiliteOld = True

            if onShape and onShape is not self.hiliteShape and onShape.shown:
                hiliteNew = True

            if unhiliteOld or hiliteNew:
                self.dragImage.Hide()

            if unhiliteOld:
                dc = wx.ClientDC(self)
                self.hiliteShape.Draw(dc)
                self.hiliteShape = None

            if hiliteNew:
                dc = wx.ClientDC(self)
                self.hiliteShape = onShape
                self.hiliteShape.Draw(dc, wx.INVERT)

            self.dragImage.Move(evt.GetPosition())
            if unhiliteOld or hiliteNew:
                self.dragImage.Show()
コード例 #4
0
ファイル: config_work.py プロジェクト: nigelcharman/Edware
    def on_mouse_motion(self, event):
        if (self.drag_loc < 0 or not event.Dragging()
                or not event.LeftIsDown()):
            return

        pt = event.GetPosition()

        if (not self.drag_image):
            # BED zooming support
            check_pt = wx.Point(pt.x / self.zoom, pt.y / self.zoom)

            tolerance = 4

            dx = abs(check_pt.x - self.drag_start_pos.x)
            dy = abs(check_pt.y - self.drag_start_pos.y)
            if (dx <= tolerance and dy <= tolerance):
                return

            # remove the old one but remember it if we have to put it back
            self.drag_start = (self.drag_loc, self.drag_name)
            win_data.config_move_start(self.drag_loc)
            # force the work area to redraw
            self.Refresh()
            self.Update()
            win_data.force_redraw('config')

            # get the selected variant since we had to click to get here
            bmp = device_data.get_device_bmap(self.drag_name, True)
            if (self.zoom != 1.0):
                image = bmp.ConvertToImage()
                w = image.GetWidth() * self.zoom
                h = image.GetHeight() * self.zoom
                image.Rescale(w, h)
                bmp = image.ConvertToBitmap()

            self.drag_image = wx.DragImage(bmp, wx.StockCursor(wx.CURSOR_HAND))
            #dev_x,dev_y = device_data.get_device_size()
            dev_x, dev_y = bmp.GetSize()
            hotspot = (dev_x / 2, dev_y / 2)
            #print "on_mouse_motion: hotspot", hotspot

            self.drag_image.BeginDrag(hotspot, self, False,
                                      self.GetClientRect())
            loc, update, dummy = self.local_move_centre_pt(
                pt, self.drag_name, self.drag_image)
            self.drag_image.Move(pt)
            self.drag_image.Show()
        else:
            loc, update, dummy = self.local_move_centre_pt(
                pt, self.drag_name, self.drag_image)
            self.drag_image.Move(pt)
            if (update):
                self.drag_image.Show()
コード例 #5
0
    def Motion(self, evt):
        # Ignore mouse movement if we're not dragging.
        if not self.dragShape or not evt.Dragging() or not evt.LeftIsDown():
            return

        # if we have a shape, but haven't started dragging yet
        if self.dragShape and not self.dragImage:
            pos = evt.Position

            # refresh map area where the drag zone was so it will get erased.
            self.dragShape.shown = False
            self.RefreshRect(self.zone.GetRect(), True)
            self.Update()

            img = self.dragShape.bmp

            #TODO, mask zone surface colour
            # mask = wx.Mask(img, '#FFE7CE')
            # img.SetMask(mask)
            # img.SetMaskColour('#FFE7CE')
            #TODO,
            # img = wx.Bitmap.FromRGBA(img.Width, img.Height, 0xFF, 0xE7, 0xCE, 0xFF,)
            #TODO,
            self.dragImage = wx.DragImage(img, wx.Cursor(wx.CURSOR_HAND))
            self.hotspot = self.dragStartPos - self.dragShape.pos

            self.dragImage.BeginDrag(self.hotspot, self, fullScreen=True)
            self.dragImage.Move(pos)
            self.dragImage.Show()
        # if we have shape and image then move drag zone
        elif self.dragShape and self.dragImage:
            self.CalcHeights()
            top_y = self.GetTopY(evt.Position[1])

            # align position with drag start
            pos = (self.dragStartPos[0], top_y + self.hotspot[1])
            top_line = self.GetTopLine(top_y)
            self.SyncDoc(top_line, top_y)
            self.SetFirstVisibleLine(top_line)  # in document map
            # show line number during drag
            self.SetToolTip('Top Line: %7d' % (self.doc.FirstVisibleLine + 1))

            # adjust mouse pointer position
            self.WarpPointer(*pos)

            self.dragImage.Move(pos)
            self.dragImage.Show()
コード例 #6
0
ファイル: base.py プロジェクト: yncat/falcon
    def BeginDrag(self, event):
        data = wx.FileDataObject()
        for f in self.GetSelectedItems():
            data.AddFile(f.fullpath)

        itemImage = self.hListCtrl.GetImageList(wx.IMAGE_LIST_SMALL)\
            .GetBitmap(self.hListCtrl.GetItem(self.GetSelectedItems(True)[0]).GetImage())\
            .ConvertToImage().Scale(128, 128).ConvertToBitmap()

        i = wx.DragImage(itemImage)
        i.BeginDrag((16, 16), globalVars.app.hMainView.hFrame, True, None)

        obj = DropSource(data, globalVars.app.hMainView.hFrame)
        obj.hImage = i
        i.Show()
        obj.GiveFeedback(None)  # 座標の計算などをしてi.Moveが呼ばれる
        obj.DoDragDrop()
        i.EndDrag()
コード例 #7
0
ファイル: net_view.py プロジェクト: rosejn/mantis
    def OnMotion(self, evt):
        # Ignore mouse movement if we're not dragging.
        if not self.dragNode or not evt.Dragging() or not evt.LeftIsDown():
            return

        # if we have a node, but haven't started dragging yet
        if self.dragNode and not self.dragImage:
            # only start the drag after having moved a couple pixels
            tolerance = 2
            pt = evt.GetPosition()
            dx = abs(pt.x - self.dragStartPos.x)
            dy = abs(pt.y - self.dragStartPos.y)
            if dx <= tolerance and dy <= tolerance:
                return

            # Create a DragImage to draw this node while it is moving
            # (The drag image will update even as the bitmap is updating.  Magical!)
            self.dragImage = wx.DragImage(self.dragNode.bmp,
                                          wx.StockCursor(wx.CURSOR_HAND))
            hotspot = self.dragStartPos - self.dragNode.model.pos + [
                self.dragNode.node_radius, self.dragNode.node_radius
            ]
            self.dragImage.BeginDrag(hotspot, self, False)
            self.dragImage.Move(pt)

            # erase the node since it will be drawn by the DragImage now
            dc = wx.ClientDC(self)
            for link in self.dragNode.model.incoming.itervalues():
                if link not in self.link_dict: continue
                l = self.link_dict[link]
                l.Erase(dc)
                l.src.Draw(dc)
            for link in self.dragNode.model.outgoing.itervalues():
                if link not in self.link_dict: continue
                l = self.link_dict[link]
                l.Erase(dc)
                l.dst.Draw(dc)
            self.dragNode.Erase(dc)
            self.dragNode.dragging = True
            self.dragImage.Show()

        # if we have node and image then move it
        elif self.dragNode and self.dragImage:
            self.dragImage.Move(evt.GetPosition())
コード例 #8
0
ファイル: pallete_win.py プロジェクト: nigelcharman/Edware
    def on_mouse_motion(self, event):
        if (not self.drag_bmap or not event.Dragging()
                or not event.LeftIsDown()):
            return

        raw_pt = event.GetPosition()
        screen_pt = self.ClientToScreen(raw_pt)
        check_pt = self.CalcUnscrolledPosition(raw_pt)

        if (self.drag_bmap and not self.drag_image):
            tolerance = 4
            dx = abs(check_pt.x - self.drag_start_pos.x)
            dy = abs(check_pt.y - self.drag_start_pos.y)
            if (dx <= tolerance and dy <= tolerance):
                return

            # BED scale the image if it is program_pallete
            zoom = win_data.get_zoom(self.name)
            if (zoom != 1.0):
                image = self.drag_bmap.ConvertToImage()
                w = image.GetWidth() * zoom
                h = image.GetHeight() * zoom
                image.Rescale(w, h)
                self.drag_bmap = image.ConvertToBitmap()

            self.drag_image = wx.DragImage(self.drag_bmap,
                                           wx.StockCursor(wx.CURSOR_HAND))
            dev_x, dev_y = self.drag_bmap.GetSize()
            hotspot = (dev_x / 2, dev_y / 2)
            #print "on_mouse_motion: hotspot", hotspot
            self.drag_image.BeginDrag(hotspot, self, True, self.frame_rect)
            loc, update, extra = win_data.inform_work_of_centre_pt(
                screen_pt, self.drag_name, self.drag_image)
            self.drag_image.Show()
            self.drag_image.Move(raw_pt)
        else:
            loc, update, extra = win_data.inform_work_of_centre_pt(
                screen_pt, self.drag_name, self.drag_image)
            if (update):
                self.drag_image.Show()
            self.drag_image.Move(raw_pt)
コード例 #9
0
ファイル: test_dragimag.py プロジェクト: jessjames541/Jessem
 def test_dragimag3(self):
     di = wx.DragImage(wx.Icon(icoFile))
コード例 #10
0
    def OnMotion(self, evt):
        # Ignore mouse movement if we're not dragging.
        if not self.dragShape or not evt.Dragging() or not evt.LeftIsDown():
            return

        # if we have a shape, but haven't started dragging yet
        if self.dragShape and not self.dragImage:

            # only start the drag after having moved a couple pixels
            tolerance = 2
            pt = evt.GetPosition()
            dx = abs(pt.x - self.dragStartPos.x)
            dy = abs(pt.y - self.dragStartPos.y)
            if dx <= tolerance and dy <= tolerance:
                return

            # refresh the area of the window where the shape was so it
            # will get erased.
            self.dragShape.shown = False
            self.RefreshRect(self.dragShape.GetRect(), True)
            self.Update()

            if self.dragShape.text:
                self.dragImage = wx.DragString(self.dragShape.text,
                                               wx.StockCursor(wx.CURSOR_HAND))
            else:
                self.dragImage = wx.DragImage(self.dragShape.bmp,
                                              wx.StockCursor(wx.CURSOR_HAND))

            hotspot = self.dragStartPos - self.dragShape.pos
            self.dragImage.BeginDrag(hotspot, self, self.dragShape.fullscreen)

            self.dragImage.Move(pt)
            self.dragImage.Show()

        # if we have shape and image then move it, posibly highlighting another shape.
        elif self.dragShape and self.dragImage:
            onShape = self.FindShape(evt.GetPosition())
            unhiliteOld = False
            hiliteNew = False

            # figure out what to hilite and what to unhilite
            if self.hiliteShape:
                if onShape is None or self.hiliteShape is not onShape:
                    unhiliteOld = True

            if onShape and onShape is not self.hiliteShape and onShape.shown:
                hiliteNew = True

            # if needed, hide the drag image so we can update the window
            if unhiliteOld or hiliteNew:
                self.dragImage.Hide()

            if unhiliteOld:
                dc = wx.ClientDC(self)
                self.hiliteShape.Draw(dc)
                self.hiliteShape = None

            if hiliteNew:
                dc = wx.ClientDC(self)
                self.hiliteShape = onShape
                self.hiliteShape.Draw(dc, wx.INVERT)

            # now move it and show it again if needed
            self.dragImage.Move(evt.GetPosition())
            if unhiliteOld or hiliteNew:
                self.dragImage.Show()
コード例 #11
0
    def on_mouse_motion(self, event):
        if (self.drag_id < 0 or not event.Dragging()
                or not event.LeftIsDown()):
            return

        ok_to_drag = win_data.program().check_drag(self.drag_id,
                                                   self.drag_name)
        if (not ok_to_drag):
            return

        raw_pt = event.GetPosition()
        check_pt = self.CalcUnscrolledPosition(raw_pt)

        if (not self.drag_image):
            # BED zooming support
            check_pt = wx.Point(check_pt.x / self.zoom, check_pt.y / self.zoom)
            #print "Move, raw:", raw_pt, "check:", check_pt

            tolerance = 4

            dx = abs(check_pt.x - self.drag_start_pos.x)
            dy = abs(check_pt.y - self.drag_start_pos.y)
            if (dx <= tolerance and dy <= tolerance):
                return

            #print "Start drag with movement:", dx, dy
            # remove the old one but remember it if we have to put it back
            self.drag_start = (self.drag_id, self.drag_name)
            win_data.program().start_move(self.drag_id, self.drag_which)
            # force the work area to redraw
            self.Refresh()
            self.Update()

            # get the selected variant since we had to click to get here
            bmp = bric_data.get_bric_bmap(self.drag_name,
                                          bric_data.BRIC_SELECTED)

            if (self.zoom != 1.0):
                image = bmp.ConvertToImage()
                w = image.GetWidth() * self.zoom
                h = image.GetHeight() * self.zoom
                image.Rescale(w, h)
                bmp = image.ConvertToBitmap()

            self.drag_image = wx.DragImage(bmp, wx.StockCursor(wx.CURSOR_HAND))
            dev_x, dev_y = bmp.GetSize()
            hotspot = (dev_x / 2, dev_y / 2)

            self.drag_image.BeginDrag(hotspot, self, False,
                                      self.GetClientRect())
            loc, update, which_id = self.local_move_centre_pt(
                raw_pt, self.drag_name, self.drag_image)
            self.drag_image.Move(raw_pt)
            self.drag_image.Show()

        else:

            loc, update, which_id = self.local_move_centre_pt(
                raw_pt, self.drag_name, self.drag_image)
            self.drag_image.Move(raw_pt)

            if (update):
                self.drag_image.Show()
コード例 #12
0
 def setup_dragging(self):
     self.drag_img = wx.DragImage(self.name)
     self.st.Bind(wx.EVT_MOTION, self.on_mouse)
     self.st.Bind(wx.EVT_LEFT_DOWN, self.on_left_down)
     self.st.Bind(wx.EVT_LEFT_UP, self.on_left_up)
コード例 #13
0
ファイル: test_dragimag.py プロジェクト: jessjames541/Jessem
 def test_dragimag6(self):
     ctrl = wx.ListCtrl(self.frame, style=wx.LC_REPORT)
     ctrl.AppendColumn('hello')
     idx = ctrl.InsertItem(0, "a list item")
     di = wx.DragImage(ctrl, idx)
コード例 #14
0
ファイル: test_dragimag.py プロジェクト: jessjames541/Jessem
 def test_dragimag5(self):
     ctrl = wx.TreeCtrl(self.frame)
     root = ctrl.AddRoot('root item')
     di = wx.DragImage(ctrl, root)
コード例 #15
0
ファイル: test_dragimag.py プロジェクト: jessjames541/Jessem
 def test_dragimag4(self):
     di = wx.DragImage("Some draggable text")
コード例 #16
0
    def Motion(self, evt):
        # print('Motion', self.doc.ClientSize, self.ClientSize)
        # Ignore mouse movement if we're not dragging.

        #TODO, show line number on hover
        # self.SetToolTip(str(self.FirstVisibleLine + evt.Position[1] // self.TextHeight(0)))
        # print(self.FirstVisibleLine + evt.Position[1] // self.TextHeight(0))
        #TODO,

        if not self.dragShape or not evt.Dragging() or not evt.LeftIsDown():
            return

        # if we have a shape, but haven't started dragging yet
        if self.dragShape and not self.dragImage:
            pos = evt.Position

            # refresh window area where the shape was so it will get erased.
            self.dragShape.shown = False
            self.RefreshRect(self.zone.GetRect(), True)
            self.Update()

            item = self.dragShape.bmp
            self.dragImage = wx.DragImage(item, wx.Cursor(wx.CURSOR_HAND))
            self.hotspot = self.dragStartPos - self.dragShape.pos

            self.dragImage.BeginDrag(self.hotspot, self, True,
                                     wx.Rect(0, 0, 300, 300))
            self.dragImage.Move(pos)
            self.dragImage.Show()
        elif self.dragShape and self.dragImage:
            # now move it and show it again if needed
            # keep position aligned with drag start
            pos = (self.dragStartPos[0], evt.Position[1])

            # drag zone's top/bottom Y coordinates
            self.SetHeights()
            top_y = self.dragShape.pos[1] + evt.Position[
                1] - self.dragStartPos[1]
            bot_y = top_y + self.zone_height

            # adjust position when dragging past top/bottom edge
            if top_y < 0:
                top_y = 0
                pos = (self.dragStartPos[0], self.hotspot[1])
            if bot_y > self.max_height:
                bot_y = self.max_height
                pos = (self.dragStartPos[0],
                       self.scroll_height + self.hotspot[1])

            top_line = int(top_y / self.scroll_height *
                           (self.LineCount - self.LinesOnScreen()))

            self.SetFirstVisibleLine(top_line)  # in document map

            if self.max_height < self.clt_height:
                top_line = 0

            self.doc.SetFirstVisibleLine(
                top_line + top_y // self.TextHeight(0))  # in editor

            # adjust mouse pointer position
            self.WarpPointer(*pos)

            self.dragImage.Move(pos)
            self.dragImage.Show()
コード例 #17
0
ファイル: test_dragimag.py プロジェクト: jessjames541/Jessem
 def test_dragimag2(self):
     di = wx.DragImage(wx.Bitmap(pngFile))
コード例 #18
0
ファイル: test_dragimag.py プロジェクト: jessjames541/Jessem
 def test_dragimag1(self):
     di = wx.DragImage()
コード例 #19
0
ファイル: example1.py プロジェクト: NPKompleet/electrosketch
    def OnMotion(self, evt):
        tool = self.GetParent().toolSelect
        dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
        print tool
        othrtools = (tool == "imageicons/polexdrawicon.png"
                     or tool == "imageicons/poledrawicon.png"
                     or tool == "imageicons/linedrawicon.png"
                     or tool == "imageicons/Hpolexdrawicon.png"
                     or tool == "imageicons/Hpoledrawicon.png")
        if evt.Dragging() and evt.LeftIsDown() and (
                tool == "imageicons/freehandicon2.png"):
            self.drawMotion(dc, evt)

        elif evt.Moving() and othrtools and not evt.RightIsDown():
            self.drawimaglineMotion(dc, evt)

        elif evt.Dragging() and othrtools and evt.RightIsDown():
            #print 'should drag!!!'
            # if we have a shape, but haven't started dragging yet
            if self.dragShape and not self.dragImage:
                # print'not yet moving'

                # only start the drag after having moved a couple pixels
                tolerance = 2
                pt = evt.GetPosition()
                dx = abs(pt.x - self.dragStartPos.x)
                dy = abs(pt.y - self.dragStartPos.y)
                if dx <= tolerance and dy <= tolerance:
                    return

                # refresh the area of the window where the shape was so it
                # will get erased.
                self.dragShape.shown = False
                self.RefreshRect(self.dragShape.GetRect(), True)
                self.Update()

                if self.dragShape.text:
                    self.dragImage = wx.DragString(
                        self.dragShape.text, wx.StockCursor(wx.CURSOR_HAND))
                else:
                    self.dragImage = wx.DragImage(
                        self.dragShape.bmp, wx.StockCursor(wx.CURSOR_HAND))

                hotspot = self.dragStartPos - self.dragShape.pos
                self.dragImage.BeginDrag(hotspot, self,
                                         self.dragShape.fullscreen)

                self.dragImage.Move(pt)
                self.dragImage.Show()

            # if we have shape and image then move it, posibly highlighting another shape.
            elif self.dragShape and self.dragImage:
                #print'moving'
                onShape = self.FindShape(evt.GetPosition())
                unhiliteOld = False
                hiliteNew = False

                # figure out what to hilite and what to unhilite
                if self.hiliteShape:
                    if onShape is None or self.hiliteShape is not onShape:
                        unhiliteOld = True

                if onShape and onShape is not self.hiliteShape and onShape.shown:
                    hiliteNew = True

                # if needed, hide the drag image so we can update the window
                if unhiliteOld or hiliteNew:
                    self.dragImage.Hide()

                if unhiliteOld:
                    dc = wx.ClientDC(self)
                    self.hiliteShape.Draw(dc)
                    self.hiliteShape = None

                if hiliteNew:
                    dc = wx.ClientDC(self)
                    self.hiliteShape = onShape
                    self.hiliteShape.Draw(dc, wx.INVERT)

                # now move it and show it again if needed
                pos = evt.GetPositionTuple()
                self.dragImage.Move(pos)
                self.shapedict[self.dragShape][0] = pos[0]
                self.shapedict[self.dragShape][1] = pos[1]

                if unhiliteOld or hiliteNew:
                    self.dragImage.Show()
            #self.InitBuffer()
        evt.Skip()