python类Rect()的实例源码

FancyTabNotebook.py 文件源码 项目:fmc-dialer 作者: sguron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, strCaption="", imageIndex=-1, enabled=True):
        """
        Default class constructor.

        :param `strCaption`: the tab caption;
        :param `imageIndex`: the tab image index based on the assigned (set)
         :class:`ImageList` (if any);
        :param `enabled`: sets the tab as enabled or disabled.
        """

        self._pos = wx.Point()
        self._size = wx.Size()
        self._strCaption = strCaption
        self._ImageIndex = imageIndex
        self._captionRect = wx.Rect()
        self._bEnabled = enabled
IDEFrame.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def SaveTabLayout(self, notebook):
        tabs = []
        for child in notebook.GetChildren():
            if isinstance(child, wx.aui.AuiTabCtrl):
                if child.GetPageCount() > 0:
                    pos = child.GetPosition()
                    tab = {"pos": (pos.x, pos.y), "pages": []}
                    tab_size = child.GetSize()
                    for page_idx in xrange(child.GetPageCount()):
                        page = child.GetWindowFromIdx(page_idx)
                        if "size" not in tab:
                            tab["size"] = (tab_size[0], tab_size[1] + page.GetSize()[1])
                        tab_infos = self.GetTabInfos(page)
                        if tab_infos is not None:
                            tab["pages"].append((tab_infos, page_idx == child.GetActivePage()))
                    tabs.append(tab)
        tabs.sort(lambda x, y: cmp(x["pos"], y["pos"]))
        size = notebook.GetSize()
        return ComputeTabsLayout(tabs, wx.Rect(1, 1, size[0] - NOTEBOOK_BORDER, size[1] - NOTEBOOK_BORDER))
CustomTree.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def GetBitmapRect(self):
        client_size = self.GetClientSize()
        bitmap_size = self.BackgroundBitmap.GetSize()

        if self.BackgroundAlign & wx.ALIGN_RIGHT:
            x = client_size[0] - bitmap_size[0]
        elif self.BackgroundAlign & wx.ALIGN_CENTER_HORIZONTAL:
            x = (client_size[0] - bitmap_size[0]) / 2
        else:
            x = 0

        if self.BackgroundAlign & wx.ALIGN_BOTTOM:
            y = client_size[1] - bitmap_size[1]
        elif self.BackgroundAlign & wx.ALIGN_CENTER_VERTICAL:
            y = (client_size[1] - bitmap_size[1]) / 2
        else:
            y = 0

        return wx.Rect(x, y, bitmap_size[0], bitmap_size[1])
DebugVariableGraphicViewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def GetAxesBoundingBox(self, parent_coordinate=False):
        """
        Return figure bounding box in wx coordinate
        @param parent_coordinate: True if use parent coordinate (default False)
        """
        # Calculate figure bounding box. Y coordinate is inverted in matplotlib
        # figure comparing to wx panel
        width, height = self.GetSize()
        ax, ay, aw, ah = self.figure.gca().get_position().bounds
        bbox = wx.Rect(ax * width, height - (ay + ah) * height - 1,
                       aw * width + 2, ah * height + 1)

        # If parent_coordinate, add Viewer position in parent
        if parent_coordinate:
            xw, yw = self.GetPosition()
            bbox.x += xw
            bbox.y += yw

        return bbox
GraphButton.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def HitTest(self, x, y):
        """
        Test if point is inside button
        @param x: X coordinate of point
        @param y: Y coordinate of point
        @return: True if button is active and displayed and point is inside
        button
        """
        # Return immediately if button is hidden or inactive
        if not (self.IsShown() and self.IsEnabled()):
            return False

        # Test if point is inside button
        w, h = self.Bitmap.GetSize()
        rect = wx.Rect(self.Position.x, self.Position.y, w, h)
        return rect.InsideXY(x, y)
Viewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def Paste(self, bbx=None):
        if not self.Debug:
            element = self.ParentWindow.GetCopyBuffer()
            if bbx is None:
                mouse_pos = self.Editor.ScreenToClient(wx.GetMousePosition())
                middle = wx.Rect(0, 0, *self.Editor.GetClientSize()).InsideXY(mouse_pos.x, mouse_pos.y)
                if middle:
                    x, y = self.CalcUnscrolledPosition(mouse_pos.x, mouse_pos.y)
                else:
                    x, y = self.CalcUnscrolledPosition(0, 0)
                new_pos = [int(x / self.ViewScale[0]), int(y / self.ViewScale[1])]
            else:
                middle = True
                new_pos = [bbx.x, bbx.y]
            result = self.Controler.PasteEditedElementInstances(self.TagName, element, new_pos, middle, self.Debug)
            if not isinstance(result, (StringType, UnicodeType)):
                self.RefreshBuffer()
                self.RefreshView(selection=result)
                self.RefreshVariablePanel()
                self.ParentWindow.RefreshPouInstanceVariablesPanel()
            else:
                message = wx.MessageDialog(self.Editor, result, "Error", wx.OK | wx.ICON_ERROR)
                message.ShowModal()
                message.Destroy()
RubberBand.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def OnLeftDown(self, event, dc, scaling):
        """
        Called when left mouse is pressed on Viewer. Starts to edit a new
        rubberband bounding box
        @param event: Mouse event
        @param dc: Device Context of Viewer
        @param scaling: PLCOpen scaling applied on Viewer
        """
        # Save the point where mouse was pressed in Viewer unit, position may
        # be modified by scroll and zoom applied on viewer
        self.StartPoint = GetScaledEventPosition(event, dc, scaling)

        # Initialize rubberband bounding box
        self.CurrentBBox = wx.Rect(self.StartPoint.x, self.StartPoint.y, 0, 0)

        # Change viewer mouse cursor to reflect a rubberband bounding box is
        # edited
        self.DrawingSurface.SetCursor(wx.StockCursor(wx.CURSOR_CROSS))

        self.Redraw()
SFC_Objects.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def RefreshBoundingBox(self):
        # Calculate the bounding box size
        if self.Action:
            bbx_width = self.Size[0] + CONNECTOR_SIZE
        else:
            bbx_width = self.Size[0]
        if self.Initial:
            bbx_y = self.Pos.y
            bbx_height = self.Size[1]
            if self.Output:
                bbx_height += CONNECTOR_SIZE
        else:
            bbx_y = self.Pos.y - CONNECTOR_SIZE
            bbx_height = self.Size[1] + CONNECTOR_SIZE
            if self.Output:
                bbx_height += CONNECTOR_SIZE
        # self.BoundingBox = wx.Rect(self.Pos.x, bbx_y, bbx_width + 1, bbx_height + 1)
        self.BoundingBox = wx.Rect(self.Pos.x, self.Pos.y, self.Size[0] + 1, self.Size[1] + 1)

    # Refresh the positions of the step connectors
SFC_Objects.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def RefreshBoundingBox(self):
        bbx_x, bbx_y, bbx_width, bbx_height = self.Pos.x, self.Pos.y, self.Size[0], self.Size[1]
        if self.Priority != 0:
            bbx_y = self.Pos.y - self.PrioritySize[1] - 2
            bbx_width = max(self.Size[0], self.PrioritySize[0])
            bbx_height = self.Size[1] + self.PrioritySize[1] + 2
        if self.Type == "connection":
            bbx_x = self.Pos.x - CONNECTOR_SIZE
            bbx_width = bbx_width + CONNECTOR_SIZE
        else:
            text_width, text_height = self.ConditionSize
            # Calculate the bounding box size
            bbx_width = max(bbx_width, self.Size[0] + 5 + text_width)
            bbx_y = min(bbx_y, self.Pos.y - max(0, (text_height - self.Size[1]) / 2))
            bbx_height = max(bbx_height, self.Pos.y - bbx_y + (self.Size[1] + text_height) / 2)
        self.BoundingBox = wx.Rect(bbx_x, bbx_y, bbx_width + 1, bbx_height + 1)

    # Returns the connector connected to input
GraphicCommons.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def RefreshBoundingBox(self):
        if len(self.Elements) > 0:
            bbox = self.Elements[0].GetBoundingBox()
            minx, miny = bbox.x, bbox.y
            maxx = bbox.x + bbox.width
            maxy = bbox.y + bbox.height
            for element in self.Elements[1:]:
                bbox = element.GetBoundingBox()
                minx = min(minx, bbox.x)
                miny = min(miny, bbox.y)
                maxx = max(maxx, bbox.x + bbox.width)
                maxy = max(maxy, bbox.y + bbox.height)
            self.BoundingBox = wx.Rect(minx, miny, maxx - minx, maxy - miny)
        else:
            self.BoundingBox = wx.Rect(0, 0, 0, 0)
        self.Pos = wx.Point(self.BoundingBox.x, self.BoundingBox.y)
        self.Size = wx.Size(self.BoundingBox.width, self.BoundingBox.height)

    # Forbids to change the group position
GraphicCommons.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def TestPoint(self, pt, direction=None, exclude=True):
        inside = False
        check_point = (not exclude) and (direction is None or self.Direction == direction)

        if check_point:
            # Calculate a square around the end point of this connector
            parent_pos = self.ParentBlock.GetPosition()
            x = parent_pos[0] + self.Pos.x + self.Direction[0] * CONNECTOR_SIZE - ANCHOR_DISTANCE
            y = parent_pos[1] + self.Pos.y + self.Direction[1] * CONNECTOR_SIZE - ANCHOR_DISTANCE
            width = ANCHOR_DISTANCE * 2 + abs(self.Direction[0]) * CONNECTOR_SIZE
            height = ANCHOR_DISTANCE * 2 + abs(self.Direction[1]) * CONNECTOR_SIZE
            rect = wx.Rect(x, y, width, height)
            inside = rect.InsideXY(pt.x, pt.y)

        return inside

    # Draws the highlightment of this element if it is highlighted
LD_Objects.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def RefreshBoundingBox(self):
        # Calculate the size of the name outside the contact
        text_width, text_height = self.Parent.GetTextExtent(self.Name)
        # Calculate the bounding box size
        if self.Name != "":
            bbx_x = self.Pos.x - max(0, (text_width - self.Size[0]) / 2)
            bbx_width = max(self.Size[0], text_width)
            bbx_y = self.Pos.y - (text_height + 2)
            bbx_height = self.Size[1] + (text_height + 2)
        else:
            bbx_x = self.Pos.x
            bbx_width = self.Size[0]
            bbx_y = self.Pos.y
            bbx_height = self.Size[1]
        self.BoundingBox = wx.Rect(bbx_x, bbx_y, bbx_width + 1, bbx_height + 1)

    # Returns the block minimum size
FBD_Objects.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def RefreshBoundingBox(self):
        if self.Type in (OUTPUT, INOUT):
            bbx_x = self.Pos.x - CONNECTOR_SIZE
        else:
            bbx_x = self.Pos.x
        if self.Type == INOUT:
            bbx_width = self.Size[0] + 2 * CONNECTOR_SIZE
        else:
            bbx_width = self.Size[0] + CONNECTOR_SIZE
        bbx_x = min(bbx_x, self.Pos.x + (self.Size[0] - self.NameSize[0]) / 2)
        bbx_width = max(bbx_width, self.NameSize[0])
        bbx_height = self.Size[1]
        if self.ExecutionOrder != 0:
            bbx_x = min(bbx_x, self.Pos.x + self.Size[0] - self.ExecutionOrderSize[0])
            bbx_width = max(bbx_width, bbx_width + self.Pos.x + self.ExecutionOrderSize[0] - bbx_x - self.Size[0])
            bbx_height = bbx_height + (self.ExecutionOrderSize[1] + 2)
        self.BoundingBox = wx.Rect(bbx_x, self.Pos.y, bbx_width + 1, bbx_height + 1)

    # Refresh the position of the variable connector
face.py 文件源码 项目:Cognitive-Face-Python 作者: Microsoft 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, res, path, size=util.MAX_THUMBNAIL_SIZE):
        super(Face, self).__init__()
        self.path = path
        img = util.rotate_image(path)
        self.bmp = img.ConvertToBitmap()
        self.name = None
        if res.get('faceId'):
            self.id = res['faceId']
        if res.get('persistedFaceId'):
            self.persisted_id = res['persistedFaceId']
        if res.get('faceRectangle'):
            self.rect = Rect(res['faceRectangle'])
            self.bmp = self.bmp.GetSubBitmap(wx.Rect(
                self.rect.left,
                self.rect.top,
                self.rect.width,
                self.rect.height,
            ))
        if res.get('faceAttributes'):
            self.attr = Attribute(res['faceAttributes'])
        self.bmp = util.scale_image(
            self.bmp.ConvertToImage(),
            size=size,
        ).ConvertToBitmap()
base.py 文件源码 项目:Cognitive-Face-Python 作者: Microsoft 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def OnDrawItem(self, dc, rect, index):
        """OnDrawItem for Layout."""
        face = self.faces[index]
        dc.DrawBitmap(face.bmp, rect.x + 2,
                      ((rect.height - face.bmp.GetHeight()) / 2) + rect.y)

        textx = rect.x + 2 + face.bmp.GetWidth() + 2
        label_rect = wx.Rect(textx, rect.y, rect.width - textx, rect.height)
        label = util.LABEL_FACE.format(
            face.attr.gender,
            face.attr.age,
            face.attr.hair,
            face.attr.facial_hair,
            face.attr.makeup,
            face.attr.emotion,
            face.attr.occlusion,
            face.attr.exposure,
            face.attr.head_pose,
            face.attr.accessories
        )
        dc.DrawLabel(label, label_rect, wx.ALIGN_LEFT | wx.ALIGN_TOP)
formatframe.py 文件源码 项目:GRIPy 作者: giruenf 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def OnDrawItem(self, dc, rect, item, flags):
        if item == wx.NOT_FOUND:
            # painting the control, but there is no valid item selected yet
            return 
        font = wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, 'Segoe UI')             
        dc.SetFont(font)
        if flags == 3:
            margin = 3    
        else:
            margin = 1
        r = wx.Rect(*rect)  # make a copy
        r.Deflate(margin, margin)
        tam = self.OnMeasureItem(item)-2
        dc.SetPen(wx.Pen("grey", style=wx.TRANSPARENT))
        color_name = self.GetString(item)     
        color = self.colors.get(color_name)
        if not color:
            color = wx.NamedColour(color_name)
        dc.SetBrush(wx.Brush(color))
        dc.DrawRectangle(r.x, r.y, tam, tam)
        dc.DrawText(self.GetString(item), r.x + tam + 2, r.y)
Widgets.py 文件源码 项目:SpatialTool 作者: JRcard 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, x, y, c): 
        self.x = x
        self.y = y
        self.c = c
        self.rect = wx.Rect(self.x-self.c,self.y-self.c,self.c*2,self.c*2)
Widgets.py 文件源码 项目:SpatialTool 作者: JRcard 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, x, y, c): 
        self.x = x
        self.y = y
        self.c = c
        self.radius = INIT_SOUND_RADIUS
        self.rect = wx.Rect(self.x-self.c,self.y-self.c,self.c*2,self.c*2)
FancyTabNotebook.py 文件源码 项目:fmc-dialer 作者: sguron 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def SetTextRect(self, rect):
        """
        Sets the client rectangle available for the tab text.

        :param `rect`: the tab text client rectangle, an instance of :class:`Rect`.
        """

        self._captionRect = rect
IDEFrame.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def ComputeTabsLayout(tabs, rect):
    if len(tabs) == 0:
        return tabs
    if len(tabs) == 1:
        return tabs[0]
    split = None
    for idx, tab in enumerate(tabs):
        if len(tab["pages"]) == 0:
            raise ValueError("Not possible")
        if tab["size"][0] == rect.width:
            if tab["pos"][1] == rect.y:
                split = (wx.TOP, float(tab["size"][1]) / float(rect.height))
                split_rect = wx.Rect(rect.x, rect.y + tab["size"][1] + TAB_BORDER,
                                     rect.width, rect.height - tab["size"][1] - TAB_BORDER)
            elif tab["pos"][1] == rect.height + 1 - tab["size"][1]:
                split = (wx.BOTTOM, 1.0 - float(tab["size"][1]) / float(rect.height))
                split_rect = wx.Rect(rect.x, rect.y,
                                     rect.width, rect.height - tab["size"][1] - TAB_BORDER)
            break
        elif tab["size"][1] == rect.height:
            if tab["pos"][0] == rect.x:
                split = (wx.LEFT, float(tab["size"][0]) / float(rect.width))
                split_rect = wx.Rect(rect.x + tab["size"][0] + TAB_BORDER, rect.y,
                                     rect.width - tab["size"][0] - TAB_BORDER, rect.height)
            elif tab["pos"][0] == rect.width + 1 - tab["size"][0]:
                split = (wx.RIGHT, 1.0 - float(tab["size"][0]) / float(rect.width))
                split_rect = wx.Rect(rect.x, rect.y,
                                     rect.width - tab["size"][0] - TAB_BORDER, rect.height)
            break
    if split is not None:
        split_tab = tabs.pop(idx)
        return {"split": split,
                "tab": split_tab,
                "others": ComputeTabsLayout(tabs, split_rect)}
    else:
        if SimplifyTabLayout(tabs, rect):
            return ComputeTabsLayout(tabs, rect)
    return tabs
LogViewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def GetRangeRect(self):
        width, height = self.GetClientSize()
        return wx.Rect(0, width, width, height - 2 * width)
LogViewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def GetThumbRect(self):
        width, height = self.GetClientSize()
        range_rect = self.GetRangeRect()
        thumb_size = range_rect.height * THUMB_SIZE_RATIO
        thumb_range = range_rect.height - thumb_size
        thumb_center_position = (thumb_size + (self.ThumbPosition + 1) * thumb_range) / 2.
        thumb_start = int(thumb_center_position - thumb_size / 2.)
        thumb_end = int(thumb_center_position + thumb_size / 2.)
        return wx.Rect(0, range_rect.y + thumb_start, width, thumb_end - thumb_start)
LogViewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def HitTest(self, x, y):
        rect = wx.Rect(self.Position.x, self.Position.y,
                       self.Size.width, self.Size.height)
        if rect.InsideXY(x, y):
            return True
        return False
PouInstanceVariablesPanel.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def GetItemRightImagesBBox(self, item):
        rightimages = item.GetRightImages()
        if len(rightimages) > 0:
            w, h = self.GetClientSize()
            total_h = self.GetLineHeight(item)
            r_image_w, r_image_h = self._imageListRight.GetSize(rightimages[0])

            bbox_width = (r_image_w + 4) * len(rightimages) + 4
            bbox_height = r_image_h + 8
            bbox_x = w - bbox_width
            bbox_y = item.GetY() + ((total_h > r_image_h) and [(total_h-r_image_h)/2] or [0])[0]

            return wx.Rect(bbox_x, bbox_y, bbox_width, bbox_height)

        return None
PouInstanceVariablesPanel.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def IsOverItemRightImage(self, item, point):
        rightimages = item.GetRightImages()
        if len(rightimages) > 0:
            point = self.CalcUnscrolledPosition(point)
            r_image_w, r_image_h = self._imageListRight.GetSize(rightimages[0])
            images_bbx = self.GetItemRightImagesBBox(item)

            rect = wx.Rect(images_bbx.x + 4, images_bbx.y + 4,
                           r_image_w, r_image_h)
            for r_image in rightimages:
                if rect.Inside(point):
                    return r_image
                rect.x += r_image_w + 4

            return None
DebugVariablePanel.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def RefreshHighlight(self, x_mouse, y_mouse):
        for idx, panel in enumerate(self.GraphicPanels):
            x, y = panel.GetPosition()
            width, height = panel.GetSize()
            rect = wx.Rect(x, y, width, height)
            if rect.InsideXY(x_mouse, y_mouse) or \
               idx == 0 and y_mouse < 0 or \
               idx == len(self.GraphicPanels) - 1 and y_mouse > panel.GetPosition()[1]:
                panel.RefreshHighlight(x_mouse - x, y_mouse - y)
            else:
                panel.SetHighlight(HIGHLIGHT_NONE)
        if wx.Platform == "__WXMSW__":
            self.RefreshView()
        else:
            self.ForceRefresh()
DebugVariablePanel.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def GetDraggingAxesClippingRegion(self, panel):
        x, y = panel.GetPosition()
        width, height = panel.GetSize()
        bbox = wx.Rect(x, y, width, height)
        bbox = bbox.Intersect(self.DraggingAxesBoundingBox)
        bbox.x -= x
        bbox.y -= y
        return bbox
DebugVariableGraphicViewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def RefreshHighlight(self, x, y):
        """
        Refresh Viewer highlight according to mouse position
        @param x: X coordinate of mouse pointer
        @param y: Y coordinate of mouse pointer
        """
        width, height = self.GetSize()

        # Mouse is over Viewer figure and graph is not 3D
        bbox = self.GetAxesBoundingBox()
        if bbox.InsideXY(x, y) and not self.Is3DCanvas():
            rect = wx.Rect(bbox.x, bbox.y, bbox.width / 2, bbox.height)
            # Mouse is over Viewer left part of figure
            if rect.InsideXY(x, y):
                self.SetHighlight(HIGHLIGHT_LEFT)

            # Mouse is over Viewer right part of figure
            else:
                self.SetHighlight(HIGHLIGHT_RIGHT)

        # Mouse is over upper part of Viewer
        elif y < height / 2:
            # Viewer is upper one in Debug Variable Panel, show highlight
            if self.ParentWindow.IsViewerFirst(self):
                self.SetHighlight(HIGHLIGHT_BEFORE)

            # Viewer is not the upper one, show highlight in previous one
            # It prevents highlight to move when mouse leave one Viewer to
            # another
            else:
                self.SetHighlight(HIGHLIGHT_NONE)
                self.ParentWindow.HighlightPreviousViewer(self)

        # Mouse is over lower part of Viewer
        else:
            self.SetHighlight(HIGHLIGHT_AFTER)
DebugVariableTextViewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def OnLeftDown(self, event):
        """
        Function called when mouse left button is pressed
        @param event: wx.MouseEvent
        """
        # Get first item
        item = self.ItemsDict.values()[0]

        # Calculate item path bounding box
        width, height = self.GetSize()
        item_path = item.GetVariable(
                self.ParentWindow.GetVariableNameMask())
        w, h = self.GetTextExtent(item_path)

        # Test if mouse has been pressed in this bounding box. In that case
        # start a move drag'n drop of item variable
        x, y = event.GetPosition()
        item_path_bbox = wx.Rect(20, (height - h) / 2, w, h)
        if item_path_bbox.InsideXY(x, y):
            self.ShowButtons(False)
            data = wx.TextDataObject(str((item.GetVariable(), "debug", "move")))
            dragSource = wx.DropSource(self)
            dragSource.SetData(data)
            dragSource.DoDragDrop()

        # In other case handle event normally
        else:
            event.Skip()
TextCtrlAutoComplete.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def OnLeftDown(self, event):
        selected = self.ListBox.HitTest(wx.Point(event.GetX(), event.GetY()))
        parent_size = self.Parent.GetSize()
        parent_rect = wx.Rect(0, -parent_size[1], parent_size[0], parent_size[1])
        if selected != wx.NOT_FOUND:
            wx.CallAfter(self.Parent.SetValueFromSelected, self.ListBox.GetString(selected))
        elif parent_rect.InsideXY(event.GetX(), event.GetY()):
            result, x, y = self.Parent.HitTest(wx.Point(event.GetX(), event.GetY() + parent_size[1]))
            if result != wx.TE_HT_UNKNOWN:
                self.Parent.SetInsertionPoint(self.Parent.XYToPosition(x, y))
        else:
            wx.CallAfter(self.Parent.DismissListBox)
        event.Skip()


问题


面经


文章

微信
公众号

扫码关注公众号