亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? rubberband.py

?? Wxpython Implemented on Windows CE, Source code
?? PY
字號:
#---------------------------------------------------------------------------
# Name:        wxPython.lib.mixins.rubberband
# Purpose:     A mixin class for doing "RubberBand"-ing on a window.
#
# Author:      Robb Shecter and members of wxPython-users
#
# Created:     11-September-2002
# RCS-ID:      $Id: rubberband.py,v 1.5 2003/12/17 00:33:45 RD Exp $
# Copyright:   (c) 2002 by db-X Corporation
# Licence:     wxWindows license
#---------------------------------------------------------------------------
# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o 2.5 compatability update.
# o Tested, but there is an anomaly between first use and subsequent uses.
#   First use is odd, subsequent uses seem to be OK. Init error?
#   -- No, the first time it uses an aspect ratio, but after the reset it doesn't.
#

"""
A mixin class for doing "RubberBand"-ing on a window.
"""

import  wx

#
# Some miscellaneous mathematical and geometrical functions
#

def isNegative(aNumber):
    """
    x < 0:   1
    else:    0
    """
    return aNumber < 0


def normalizeBox(box):
    """
    Convert any negative measurements in the current
    box to positive, and adjust the origin.
    """
    x, y, w, h = box
    if w < 0:
        x += (w+1)
        w *= -1
    if h < 0:
        y += (h+1)
        h *= -1
    return (x, y, w, h)


def boxToExtent(box):
    """
    Convert a box specification to an extent specification.
    I put this into a seperate function after I realized that
    I had been implementing it wrong in several places.
    """
    b = normalizeBox(box)
    return (b[0], b[1], b[0]+b[2]-1, b[1]+b[3]-1)


def pointInBox(x, y, box):
    """
    Return True if the given point is contained in the box.
    """
    e = boxToExtent(box)
    return x >= e[0] and x <= e[2] and y >= e[1] and y <= e[3]


def pointOnBox(x, y, box, thickness=1):
    """
    Return True if the point is on the outside edge
    of the box.  The thickness defines how thick the
    edge should be.  This is necessary for HCI reasons:
    For example, it's normally very difficult for a user
    to manuever the mouse onto a one pixel border.
    """
    outerBox = box
    innerBox = (box[0]+thickness, box[1]+thickness, box[2]-(thickness*2), box[3]-(thickness*2))
    return pointInBox(x, y, outerBox) and not pointInBox(x, y, innerBox)


def getCursorPosition(x, y, box, thickness=1):
    """
    Return a position number in the range 0 .. 7 to indicate
    where on the box border the point is.  The layout is:

              0    1    2
              7         3
              6    5    4
    """
    x0, y0, x1, y1 = boxToExtent(box)
    w, h  = box[2], box[3]
    delta = thickness - 1
    p     = None

    if pointInBox(x, y, (x0, y0, thickness, thickness)):
        p = 0
    elif pointInBox(x, y, (x1-delta, y0, thickness, thickness)):
        p = 2
    elif pointInBox(x, y, (x1-delta, y1-delta, thickness, thickness)):
        p = 4
    elif pointInBox(x, y, (x0, y1-delta, thickness, thickness)):
        p = 6
    elif pointInBox(x, y, (x0+thickness, y0, w-(thickness*2), thickness)):
        p = 1
    elif pointInBox(x, y, (x1-delta, y0+thickness, thickness, h-(thickness*2))):
        p = 3
    elif pointInBox(x, y, (x0+thickness, y1-delta, w-(thickness*2), thickness)):
        p = 5
    elif pointInBox(x, y, (x0, y0+thickness, thickness, h-(thickness*2))):
        p = 7

    return p




class RubberBand:
    """
    A stretchable border which is drawn on top of an
    image to define an area.
    """
    def __init__(self, drawingSurface, aspectRatio=None):
        self.__THICKNESS     = 5
        self.drawingSurface  = drawingSurface
        self.aspectRatio     = aspectRatio
        self.hasLetUp        = 0
        self.currentlyMoving = None
        self.currentBox      = None
        self.__enabled       = 1
        self.__currentCursor = None

        drawingSurface.Bind(wx.EVT_MOUSE_EVENTS, self.__handleMouseEvents)
        drawingSurface.Bind(wx.EVT_PAINT, self.__handleOnPaint)

    def __setEnabled(self, enabled):
        self.__enabled = enabled

    def __isEnabled(self):
        return self.__enabled

    def __handleOnPaint(self, event):
        #print 'paint'
        event.Skip()

    def __isMovingCursor(self):
        """
        Return True if the current cursor is one used to
        mean moving the rubberband.
        """
        return self.__currentCursor == wx.CURSOR_HAND

    def __isSizingCursor(self):
        """
        Return True if the current cursor is one of the ones
        I may use to signify sizing.
        """
        sizingCursors = [wx.CURSOR_SIZENESW,
                         wx.CURSOR_SIZENS,
                         wx.CURSOR_SIZENWSE,
                         wx.CURSOR_SIZEWE,
                         wx.CURSOR_SIZING,
                         wx.CURSOR_CROSS]
        try:
            sizingCursors.index(self.__currentCursor)
            return 1
        except ValueError:
            return 0


    def __handleMouseEvents(self, event):
        """
        React according to the new event.  This is the main
        entry point into the class.  This method contains the
        logic for the class's behavior.
        """
        if not self.enabled:
            return

        x, y = event.GetPosition()

        # First make sure we have started a box.
        if self.currentBox == None and not event.LeftDown():
            # No box started yet.  Set cursor to the initial kind.
            self.__setCursor(wx.CURSOR_CROSS)
            return

        if event.LeftDown():
            if self.currentBox == None:
                # No RB Box, so start a new one.
                self.currentBox = (x, y, 0, 0)
                self.hasLetUp   = 0
            elif self.__isSizingCursor():
                # Starting a sizing operation.  Change the origin.
                position = getCursorPosition(x, y, self.currentBox, thickness=self.__THICKNESS)
                self.currentBox = self.__denormalizeBox(position, self.currentBox)

        elif event.Dragging() and event.LeftIsDown():
            # Use the cursor type to determine operation
            if self.__isMovingCursor():
                if self.currentlyMoving or pointInBox(x, y, self.currentBox):
                    if not self.currentlyMoving:
                        self.currentlyMoving = (x - self.currentBox[0], y - self.currentBox[1])
                    self.__moveTo(x - self.currentlyMoving[0], y - self.currentlyMoving[1])
            elif self.__isSizingCursor():
                self.__resizeBox(x, y)

        elif event.LeftUp():
            self.hasLetUp = 1
            self.currentlyMoving = None
            self.__normalizeBox()

        elif event.Moving() and not event.Dragging():
            # Simple mouse movement event
            self.__mouseMoved(x,y)

    def __denormalizeBox(self, position, box):
        x, y, w, h = box
        b = box
        if position == 2 or position == 3:
            b = (x, y + (h-1), w, h * -1)
        elif position == 0 or position == 1 or position == 7:
            b = (x + (w-1), y + (h-1), w * -1, h * -1)
        elif position == 6:
            b = (x + (w-1), y, w * -1, h)
        return b

    def __resizeBox(self, x, y):
        """
        Resize and repaint the box based on the given mouse
        coordinates.
        """
        # Implement the correct behavior for dragging a side
        # of the box:  Only change one dimension.
        if not self.aspectRatio:
            if self.__currentCursor == wx.CURSOR_SIZENS:
                x = None
            elif self.__currentCursor == wx.CURSOR_SIZEWE:
                y = None

        x0,y0,w0,h0 = self.currentBox
        currentExtent = boxToExtent(self.currentBox)
        if x == None:
            if w0 < 1:
                w0 += 1
            else:
                w0 -= 1
            x = x0 + w0
        if y == None:
            if h0 < 1:
                h0 += 1
            else:
                h0 -= 1
            y = y0 + h0
        x1,y1 = x, y
        w, h = abs(x1-x0)+1, abs(y1-y0)+1
        if self.aspectRatio:
            w = max(w, int(h * self.aspectRatio))
            h = int(w / self.aspectRatio)
        w *= [1,-1][isNegative(x1-x0)]
        h *= [1,-1][isNegative(y1-y0)]
        newbox = (x0, y0, w, h)
        self.__drawAndErase(boxToDraw=normalizeBox(newbox), boxToErase=normalizeBox(self.currentBox))
        self.currentBox = (x0, y0, w, h)

    def __normalizeBox(self):
        """
        Convert any negative measurements in the current
        box to positive, and adjust the origin.
        """
        self.currentBox = normalizeBox(self.currentBox)

    def __mouseMoved(self, x, y):
        """
        Called when the mouse moved without any buttons pressed
        or dragging being done.
        """
        # Are we on the bounding box?
        if pointOnBox(x, y, self.currentBox, thickness=self.__THICKNESS):
            position = getCursorPosition(x, y, self.currentBox, thickness=self.__THICKNESS)
            cursor   = [
                wx.CURSOR_SIZENWSE,
                wx.CURSOR_SIZENS,
                wx.CURSOR_SIZENESW,
                wx.CURSOR_SIZEWE,
                wx.CURSOR_SIZENWSE,
                wx.CURSOR_SIZENS,
                wx.CURSOR_SIZENESW,
                wx.CURSOR_SIZEWE
                ] [position]
            self.__setCursor(cursor)
        elif pointInBox(x, y, self.currentBox):
            self.__setCursor(wx.CURSOR_HAND)
        else:
            self.__setCursor()

    def __setCursor(self, id=None):
        """
        Set the mouse cursor to the given id.
        """
        if self.__currentCursor != id:  # Avoid redundant calls
            if id:
                self.drawingSurface.SetCursor(wx.StockCursor(id))
            else:
                self.drawingSurface.SetCursor(wx.NullCursor)
            self.__currentCursor = id

    def __moveCenterTo(self, x, y):
        """
        Move the rubber band so that its center is at (x,y).
        """
        x0, y0, w, h = self.currentBox
        x2, y2 = x - (w/2), y - (h/2)
        self.__moveTo(x2, y2)

    def __moveTo(self, x, y):
        """
        Move the rubber band so that its origin is at (x,y).
        """
        newbox = (x, y, self.currentBox[2], self.currentBox[3])
        self.__drawAndErase(boxToDraw=newbox, boxToErase=self.currentBox)
        self.currentBox = newbox

    def __drawAndErase(self, boxToDraw, boxToErase=None):
        """
        Draw one box shape and possibly erase another.
        """
        dc = wx.ClientDC(self.drawingSurface)
        dc.BeginDrawing()
        dc.SetPen(wx.Pen(wx.WHITE, 1, wx.DOT))
        dc.SetBrush(wx.TRANSPARENT_BRUSH)
        dc.SetLogicalFunction(wx.XOR)
        if boxToErase:
            r = wx.Rect(*boxToErase)
            dc.DrawRectangleRect(r)

        r = wx.Rect(*boxToDraw)
        dc.DrawRectangleRect(r)
        dc.EndDrawing()

    def __dumpMouseEvent(self, event):
        print 'Moving:          ',event.Moving()
        print 'Dragging:        ',event.Dragging()
        print 'LeftDown:        ',event.LeftDown()
        print 'LeftisDown:      ',event.LeftIsDown()
        print 'LeftUp:          ',event.LeftUp()
        print 'Position:        ',event.GetPosition()
        print 'x,y:             ',event.GetX(),event.GetY()
        print


    #
    # The public API:
    #

    def reset(self, aspectRatio=None):
        """
        Clear the existing rubberband
        """
        self.currentBox   = None
        self.aspectRatio  = aspectRatio
        self.drawingSurface.Refresh()

    def getCurrentExtent(self):
        """
        Return (x0, y0, x1, y1) or None if
        no drawing has yet been done.
        """
        if not self.currentBox:
            extent = None
        else:
            extent = boxToExtent(self.currentBox)
        return extent

    enabled = property(__isEnabled, __setEnabled, None, 'True if I am responding to mouse events')



if __name__ == '__main__':
    app   = wx.PySimpleApp()
    frame = wx.Frame(None, -1, title='RubberBand Test', size=(300,300))

    # Add a panel that the rubberband will work on.
    panel = wx.Panel(frame, -1)
    panel.SetBackgroundColour(wx.BLUE)

    # Create the rubberband
    frame.rubberBand = RubberBand(drawingSurface=panel)
    frame.rubberBand.reset(aspectRatio=0.5)

    # Add a button that creates a new rubberband
    def __newRubberBand(event):
        frame.rubberBand.reset()
    button = wx.Button(frame, 100, 'Reset Rubberband')
    frame.Bind(wx.EVT_BUTTON, __newRubberBand, button)

    # Layout the frame
    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(panel,  1, wx.EXPAND | wx.ALL, 5)
    sizer.Add(button, 0, wx.ALIGN_CENTER | wx.ALL, 5)
    frame.SetAutoLayout(1)
    frame.SetSizer(sizer)
    frame.Show(1)
    app.MainLoop()

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美主播一区二区三区| 久久蜜桃av一区二区天堂 | 久久夜色精品国产欧美乱极品| 欧美xxxx老人做受| 国产日韩欧美制服另类| 亚洲色图在线看| 午夜久久久久久久久| 国产自产视频一区二区三区| 国产成a人亚洲精品| 91免费看`日韩一区二区| 欧美日韩一区中文字幕| 亚洲精品一区二区三区香蕉| 中文字幕一区二区不卡| 日产国产高清一区二区三区| 国产成人精品亚洲日本在线桃色| 在线亚洲人成电影网站色www| 欧美一区二区三区视频免费 | 欧美在线免费视屏| 91麻豆精品国产91久久久资源速度 | 国产欧美精品一区二区三区四区| 一区二区三区中文字幕在线观看| 久久精品国产一区二区三| 99国内精品久久| 日韩精品一区二区三区在线观看| 国产精品久久久久久久久久免费看| 亚洲风情在线资源站| 国产一区二区三区不卡在线观看| 色偷偷久久人人79超碰人人澡| 精品久久久久99| 亚洲一二三四区| 成人av中文字幕| 日韩视频一区在线观看| 天天综合日日夜夜精品| 国精产品一区一区三区mba视频| 91免费观看视频在线| 久久精品人人做人人综合| 亚洲成人av福利| av午夜一区麻豆| 精品久久人人做人人爱| 天天影视涩香欲综合网| 91黄视频在线观看| 国产69精品久久99不卡| 99久久99久久精品免费看蜜桃| 日韩一级黄色大片| 亚洲一区二区精品久久av| 成人国产电影网| 久久亚洲一级片| 日韩电影免费在线观看网站| 在线视频国内自拍亚洲视频| 中文欧美字幕免费| 久久99精品国产麻豆婷婷| 欧美日韩国产精选| 欧美一级搡bbbb搡bbbb| 日韩福利视频导航| 91小视频在线免费看| 中文字幕一区二区在线观看| 欧美日本一区二区三区| 亚洲成年人影院| 日韩视频一区二区三区在线播放| 国产在线国偷精品产拍免费yy| 波多野结衣一区二区三区 | 一区二区三区在线免费观看| 亚洲尤物在线视频观看| 91亚洲精品一区二区乱码| 欧美国产精品专区| 蜜桃视频一区二区| 99精品欧美一区二区三区小说 | 国产性色一区二区| 国产一区二区三区精品欧美日韩一区二区三区 | 久久精品综合网| 国产成人精品影院| 免费观看成人鲁鲁鲁鲁鲁视频| 色系网站成人免费| 一区二区三区小说| 欧美色精品天天在线观看视频| 一卡二卡三卡日韩欧美| 日本电影亚洲天堂一区| 亚洲自拍另类综合| 欧美日韩美少妇| 午夜影院久久久| 91精品在线一区二区| 蜜桃视频一区二区三区| 欧美精品一区二区精品网| 国产又黄又大久久| 中文字幕乱码亚洲精品一区| av高清久久久| 亚洲精品成人少妇| 欧美日韩精品专区| 免费在线成人网| 久久久国产一区二区三区四区小说| 一区二区高清视频在线观看| 欧美三级欧美一级| 免费在线观看不卡| 亚洲国产成人私人影院tom| 不卡在线视频中文字幕| 亚洲欧美日韩国产一区二区三区| 欧美天堂一区二区三区| 日韩av不卡在线观看| 久久影视一区二区| 成人免费不卡视频| 亚洲图片一区二区| 中文字幕不卡在线观看| 色综合天天综合色综合av | 欧美一级久久久久久久大片| 激情成人午夜视频| 国产精品久久久久影院色老大 | 日韩av电影一区| 国产欧美日韩精品一区| 91蜜桃免费观看视频| 成人免费电影视频| 欧美大度的电影原声| 丁香天五香天堂综合| 亚洲综合在线第一页| 日韩欧美美女一区二区三区| 成人精品免费看| 亚洲国产一区在线观看| 成人福利视频在线| 视频一区视频二区在线观看| 久久人人97超碰com| 色噜噜夜夜夜综合网| 蜜桃视频一区二区三区| 亚洲视频一区在线| 日韩免费观看2025年上映的电影| 成人免费黄色大片| 日本va欧美va精品发布| 色综合中文字幕国产 | 国产麻豆成人精品| 一区二区三区小说| 国产日韩欧美综合在线| 欧美久久一区二区| 成人av高清在线| 蜜臀av性久久久久蜜臀aⅴ四虎 | 色综合久久88色综合天天6| 青青青伊人色综合久久| 亚洲欧洲中文日韩久久av乱码| 日韩欧美一级在线播放| 一本到高清视频免费精品| 国产专区欧美精品| 亚洲一区二区三区影院| 欧美国产日本韩| 精品国产一区二区三区久久影院| 色偷偷久久人人79超碰人人澡| 国产乱子伦一区二区三区国色天香| 欧美一区二区黄| 在线视频欧美区| 成人国产精品免费观看视频| 狠狠色伊人亚洲综合成人| 亚洲电影第三页| 亚洲欧美日韩综合aⅴ视频| 久久先锋资源网| 3d成人动漫网站| 欧洲一区在线电影| 成人免费看黄yyy456| 欧美群妇大交群的观看方式| 国产米奇在线777精品观看| 日精品一区二区| 亚洲一区二区3| 综合中文字幕亚洲| 亚洲国产精品99久久久久久久久| 精品999在线播放| 91精品国产全国免费观看| 欧美在线观看禁18| 91麻豆免费看| av电影一区二区| 岛国精品在线观看| 国产精品99久久久久| 激情综合五月天| 美女被吸乳得到大胸91| 日韩中文字幕区一区有砖一区| 亚洲一区在线观看视频| 日韩激情视频网站| 国产日韩亚洲欧美综合| 久久久五月婷婷| 久久综合一区二区| 精品国产91亚洲一区二区三区婷婷| 日韩一区二区三区四区| 国产成人亚洲综合a∨婷婷| 狠狠色丁香婷综合久久| 精品一区二区在线观看| 久久99国内精品| 久久激情五月激情| 精品一区二区三区免费观看| 精品一区二区三区蜜桃| 九九**精品视频免费播放| 精品夜夜嗨av一区二区三区| 九色综合国产一区二区三区| 国产一区二区看久久| 国产福利电影一区二区三区| 国产精品123| 久久蜜臀中文字幕| 欧美一二三区在线| 日韩久久免费av| 精品国产乱码久久久久久老虎| 精品理论电影在线观看| 久久久亚洲欧洲日产国码αv| 久久久久久久久久久久久久久99| 国产三级精品在线| 中文字幕在线免费不卡| 樱花影视一区二区| 天天综合网天天综合色|