Exemple #1
0
    def tryDraw(self):

        # this function is called by class 'self.usergraph'

        dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
        dc.SetBackground(wx.Brush(wx.ColorRGB(0x000000)))
        dc.Clear()
        pen = wx.Pen(wx.ColorRGB(0xffffff), 1, wx.SOLID)
        dc.SetPen(pen)

        disGraph(dc, self.theGraph, self.offsetTuple)
Exemple #2
0
def disGraph(dc, theGraph, offsetTuple, axisUtilInst=0):
    for k in theGraph:
        if k[0] == 'backColor':
            dc.SetBackground(wx.Brush(wx.ColorRGB(k[1])))
        elif k[0] == 'foreColor':
            pen = wx.Pen(wx.ColorRGB(k[1]), 1, wx.SOLID)
            dc.SetPen(pen)
        elif k[0] == 'rect':
            pass
        elif k[0] == 'line' or k[0] == FG_LINE:
            tpu = k[1]
            ut = axisUtil()
            ut.setScreenPixOffset(offsetTuple)
            tpu = ut.turnToScreen(tpu[0:2]) + ut.turnToScreen(tpu[2:4])
            dc.DrawLine(*ut.FlipAndCenter(tpu))
Exemple #3
0
    def DoSearch(self, next=True):
        """Do the search and move the selection
        @keyword next: search next or previous

        """
        s_cmd = wx.wxEVT_COMMAND_FIND
        if next:
            self.SetSearchFlag(wx.FR_DOWN)
        else:
            if wx.FR_DOWN & self._flags:
                self.ClearSearchFlag(wx.FR_DOWN)

        if self.GetValue() == self._last:
            s_cmd = wx.wxEVT_COMMAND_FIND_NEXT
        self.InsertHistoryItem(self.GetValue())

        self._last = self.GetValue()
        self.FindService.SetQueryString(self.GetValue())
        self.FindService.SetSearchFlags(self._flags)
        self.FindService.OnFind(wx.FindDialogEvent(s_cmd))

        # Give feedback on whether text was found or not
        if self.FindService.GetLastFound() < 0 and len(self.GetValue()) > 0:
            self.SetForegroundColour(wx.RED)
            wx.Bell()
        else:
            # ?wxBUG? cant set text back to black after changing color
            # But setting it to this almost black color works. Most likely its
            # due to bit masking but I havent looked at the source so I am not
            # sure
            self.SetForegroundColour(wx.ColorRGB(0 | 1 | 0))
        self.Refresh()
Exemple #4
0
    def _create_node_with_handler(self, parent_node, controller, index=None):
        handler_class = action_handler_class(controller)
        with_checkbox = (handler_class == TestCaseHandler
                         and self._checkboxes_for_tests)

        node = self._create_node(parent_node,
                                 controller.display_name,
                                 self._images[controller],
                                 index,
                                 with_checkbox=with_checkbox)

        if isinstance(controller, ResourceFileController):
            if not controller.is_used():
                self.SetItemTextColour(node, wx.ColorRGB(0xA9A9A9))
        action_handler = handler_class(controller, self, node,
                                       self._controller.settings)
        self.SetPyData(node, action_handler)

        # if we have a TestCase node we have to make sure that
        # we retain the checked state
        if (handler_class == TestCaseHandler and self._checkboxes_for_tests) \
                and self._test_selection_controller.is_test_selected(
                    controller):
            self.CheckItem(node, True)
        if controller.is_excluded():
            self._set_item_excluded(node)
        return node
Exemple #5
0
    def DoSearch(self, next=True):
        """Do the search and move the selection
        @keyword next: search next or previous

        """
        s_cmd = finddlg.edEVT_FIND
        if not next:
            self.SetSearchFlag(finddlg.AFR_UP)
        else:
            if finddlg.AFR_UP & self._flags:
                self.ClearSearchFlag(finddlg.AFR_UP)

        if self.GetValue() == self._last:
            s_cmd = finddlg.edEVT_FIND_NEXT

        evt = finddlg.FindEvent(s_cmd, flags=self._flags)
        self._last = self.GetValue()
        evt.SetFindString(self.GetValue())
        self.FindService.OnFind(evt)

        # Give feedback on whether text was found or not
        if self.FindService.GetLastFound() < 0 and len(self.GetValue()) > 0:
            self.SetForegroundColour(wx.RED)
            wx.Bell()
        else:
            # ?wxBUG? cant set text back to black after changing color
            # But setting it to this almost black color works. Most likely its
            # due to bit masking but I havent looked at the source so I am not
            # sure
            self.SetForegroundColour(wx.ColorRGB(0 | 1 | 0))
        self.Refresh()
Exemple #6
0
    def DrawLines(self, dc):

        linedata = self.linedata

        #print linedata;
        (xmin, xmax, ymin, ymax) = get4m(linedata)

        xmin, xmax, ymin, ymax = forceAxis(self.forceaxis,
                                           [xmin, xmax, ymin, ymax])

        # Get hdc Size (pixel)
        size = self.GetClientSize()
        wwidth, wheight = size[0], size[1]

        # axis set
        self.current_axis = [2, 0, xmin, xmax, ymin, ymax, wwidth, wheight]

        # draw rect represent month length

        dc.SetPen(wx.Pen(wx.ColorRGB(0x0F1F)))
        dc.SetBrush(wx.Brush('0xFF0000', wx.TRANSPARENT))

        for ff in range(-120, 200):
            px1 = zoom_out_axis(0 + 25 + (ff * 365.24 / 12), 0,
                                self.current_axis)[0]
            px2 = zoom_out_axis(0 + 25 + ((ff + 1) * 365.24 / 12), 0,
                                self.current_axis)[0]
            if ff % 12 == 8:
                dc.SetPen(wx.Pen(wx.ColorRGB(0xFF0F1F)))
            else:
                dc.SetPen(wx.Pen(wx.ColorRGB(0x000F1F)))
            dc.DrawRectangle(px1, 10, px2 - px1, 1000)

        dc.SetPen(wx.Pen(wx.ColorRGB(0xFFFFFF)))

        if not linedata:
            return

        rec, px, py, px1, py1 = 0, 0, 0, 0, 0

        px1, py1 = linedata[0]
        [px1, py1] = zoom_out_axis(px1, py1, self.current_axis)

        for px, py in linedata:
            [px, py] = zoom_out_axis(px, py, self.current_axis)
            dc.DrawLine(px, py, px1, py1)
            px1, py1 = px, py
 def _create_node_with_handler(self, parent_node, controller, index=None):
     handler_class = action_handler_class(controller)
     node = self._create_node(parent_node, controller.display_name, self._images[controller],
                              index, with_checkbox=(handler_class == TestCaseHandler and self._checkboxes_for_tests))
     if isinstance(controller, ResourceFileController):
         if not controller.is_used():
             self.SetItemTextColour(node, wx.ColorRGB(0xA9A9A9))
     self.SetPyData(node, handler_class(controller, self, node, self._controller.settings))
     if controller.is_excluded():
         self._set_item_excluded(node)
     return node
Exemple #8
0
    def ProcessEvent(self, evt):
        """Processes Events for the Search Control
        @param evt: the event that called this handler

        """
        e_type = evt.GetEventType()
        if e_type == wx.wxEVT_KEY_UP:
            e_key = evt.GetKeyCode()
            if e_key == wx.WXK_ESCAPE:
                # HACK change to more safely determine the context
                # Currently control is only used in command bar
                self.GetParent().Hide()
                return
            elif e_key == wx.WXK_SHIFT:
                self.SetSearchFlag(wx.FR_DOWN)
                return
            else:
                pass

            tmp = self.GetValue()
            # Dont do search
            if tmp == wx.EmptyString or \
               evt.CmdDown() or \
               e_key in [wx.WXK_COMMAND, wx.WXK_LEFT, wx.WXK_RIGHT,
                         wx.WXK_UP, wx.WXK_DOWN]:
                return

            if wx.Platform != '__WXMSW__' and len(self.GetValue()) > 0:
                self.ShowCancelButton(True)
            else:
                self.ShowCancelButton(False)

            if e_key == wx.WXK_RETURN:
                if evt.ShiftDown():
                    if wx.FR_DOWN & self._flags:
                        self.ClearSearchFlag(wx.FR_DOWN)
                else:
                    self.SetSearchFlag(wx.FR_DOWN)

                if self.GetValue() != self._last:
                    s_cmd = wx.wxEVT_COMMAND_FIND
                else:
                    s_cmd = wx.wxEVT_COMMAND_FIND_NEXT
                self.InsertHistoryItem(self.GetValue())
            else:
                self.SetSearchFlag(wx.FR_DOWN)
                s_cmd = wx.wxEVT_COMMAND_FIND

            self._last = self.GetValue()
            self.FindService.SetQueryString(self.GetValue())
            self.FindService.SetSearchFlags(self._flags)
            self.FindService.OnFind(wx.FindDialogEvent(s_cmd))
        else:
            evt.Skip()
            return

        # Give feedback on whether text was found or not
        if self.FindService.GetLastFound() < 0 and len(self.GetValue()) > 0:
            chgd = self.SetForegroundColour(wx.RED)
            if chgd:
                wx.Bell()  # Beep on the first not found char

        else:
            # ?wxBUG? cant set text back to black after changing color
            # But setting it to this almost black color works. Most likely its
            # due to bit masking but I havent looked at the source so I am not
            # sure
            chgd = self.SetForegroundColour(wx.ColorRGB(0 | 1 | 0))
        self.Refresh()
Exemple #9
0
def CreatePen(pen_tuple, def_pen):
    result = wx.Pen(def_pen.Colour, def_pen.Width, def_pen.Style)
    if len(pen_tuple): result.SetColour(wx.ColorRGB(pen_tuple[0]))
    if len(pen_tuple) > 1: result.Width = pen_tuple[1]
    if len(pen_tuple) > 2: result.Style = pen_tuple[2]
    return result
Exemple #10
0
def CreateBrush(brush_tuple, def_brush):
    result = wx.Brush(def_brush.Colour, def_brush.Style)
    if len(brush_tuple): result.SetColour(wx.ColorRGB(brush_tuple[0]))
    if len(brush_tuple) > 1: result.Style = brush_tuple[1]
    return result
Exemple #11
0
    def DrawLines(self, dc):

        # get parameters

        lpre = self.linedata

        if len(lpre) > 0:
            linedata = lpre[0][1:]
        else:
            return

        (xmin, xmax, ymin, ymax) = get4m(linedata)

        xmin, xmax, ymin, ymax = forceAxis(self.forceaxis,
                                           [xmin, xmax, ymin, ymax])

        # Get hdc Size (pixel)
        size = self.GetClientSize()
        wwidth, wheight = size[0], size[1]

        # Axis set

        x_per_step = 1

        self.current_axis = [
            x_per_step, 0, xmin, xmax, ymin, ymax, wwidth, wheight
        ]

        # Show Month Rect

        dc.SetPen(wx.Pen(wx.ColorRGB(0x0F1F)))
        dc.SetBrush(wx.Brush('0xFF0000', wx.TRANSPARENT))

        for ff in range(-120, 200):
            px1 = zoom_out_axis(0 + 25 + (ff * 365.24 / 12), 0,
                                self.current_axis)[0]
            px2 = zoom_out_axis(0 + 25 + ((ff + 1) * 365.24 / 12), 0,
                                self.current_axis)[0]
            dc.DrawRectangle(px1, 10, px2 - px1, 1000)

        # Draw Other Linedatas

        dc.SetPen(wx.Pen(wx.ColorRGB(0x0000FF)))

        for k in lpre[1:]:
            ddline(dc, k[1:], copy.deepcopy(self.current_axis))

        # Draw LineData

        dc.SetPen(wx.Pen(wx.ColorRGB(0xFFFFFF)))

        if not linedata:
            return

        rec, px, py, px1, py1 = 0, 0, 0, 0, 0

        px1, py1 = linedata[0]
        [px1, py1] = zoom_out_axis(px1, py1, self.current_axis)

        for px, py in linedata:
            [px, py] = zoom_out_axis(px, py, self.current_axis)
            dc.DrawLine(px, py, px1, py1)
            px1, py1 = px, py