Example #1
0
 def _build_unused_keywords(self):
     panel_unused_kw = wx.Panel(self._notebook)
     sizer_unused_kw = wx.BoxSizer(wx.VERTICAL)
     panel_unused_kw.SetSizer(sizer_unused_kw)
     self._unused_kw_list = ResultListCtrl(panel_unused_kw,
                                           style=wx.LC_REPORT)
     self._unused_kw_list.InsertColumn(0, "Keyword", width=400)
     self._unused_kw_list.InsertColumn(1, "File", width=250)
     self._unused_kw_list.SetMinSize((650, 250))
     self._unused_kw_list.set_dialog(self)
     self._unused_kw_list.SetBackgroundColour(Colour(self.color_background))
     self._unused_kw_list.SetForegroundColour(Colour(self.color_foreground))
     self._delete_button = wx.Button(panel_unused_kw, wx.ID_ANY,
                                     'Delete marked keywords')
     self._delete_button.SetBackgroundColour(Colour(self.color_secondary_background))
     self._delete_button.SetForegroundColour(Colour(self.color_secondary_foreground))
     sizer_unused_kw.Add(self._unused_kw_list, 1, wx.ALL | wx.EXPAND, 3)
     unused_kw_controls = wx.BoxSizer(wx.HORIZONTAL)
     unused_kw_controls.AddStretchSpacer(1)
     if wx.VERSION < (4, 1, 0):
         unused_kw_controls.Add(self._delete_button, 0, wx.ALL | wx.ALIGN_RIGHT, 3)
     else:
         unused_kw_controls.Add(self._delete_button, 0, wx.ALL, 3)
     sizer_unused_kw.Add(unused_kw_controls, 0, wx.ALL | wx.EXPAND, 3)
     self._notebook.AddPage(panel_unused_kw, "Unused Keywords")
Example #2
0
File: core.py Project: nilanjan/map
    def drawElements(self, dc, canvas, tick):
        """
        Draw elements in the list to the given dc
        """
        elements = canvas.GetDrawPairs()  # Uses bounds
        xoff, yoff = canvas.GetRenderOffsets()
        _, reason_brushes = canvas.GetBrushes()
        vis_tick = canvas.GetVisibilityTick()

        needs_brush_purge = False
        for pair in elements:
            if pair.GetVisibilityTick() != vis_tick:
                continue  # Skip drawing - not visible (probably not on screen)

            string_to_display = pair.GetVal()
            e = pair.GetElement()

            # hack: probably should be handled during update calls
            if e.NeedsDatabase() and e.BrushCacheNeedsPurging():
                e.SetBrushesWerePurged()
                needs_brush_purge = True

            if not e.ShouldDraw():
                continue

            dr = e.GetDrawRoutine()
            if dr:
                # Custom routine.
                dr(e, pair, dc, canvas, tick)
                continue

            (c_x, c_y), (
                c_w,
                c_h) = e.GetProperty('position'), e.GetProperty('dimensions')
            (c_x, c_y) = (c_x - xoff, c_y - yoff)

            color = e.GetProperty('color')
            content_type = e.GetProperty('Content')

            c_color = Colour(color[0], color[1], color[2])

            color_rgb = c_color.GetRGB()
            if color_rgb in self.c_pens_map:
                dc.SetPen(self.c_pens_map[color_rgb])
            else:
                c_pen = Pen(c_color, 1)
                self.c_pens_map[color_rgb] = c_pen
                dc.SetPen(c_pen)

            dc.SetClippingRegion(c_x, c_y, c_w, c_h)
            self.drawInfoRectangle(dc, canvas,
                                   (c_x, c_y, c_w, c_h), string_to_display,
                                   pair.IsMissingLocation(), content_type,
                                   (e.GetProperty('color_basis_type'),
                                    e.GetProperty('auto_color_basis')),
                                   (c_x, c_w))
            dc.DestroyClippingRegion()

        if needs_brush_purge:
            canvas.PurgeBrushCache()  # will take care of new render call
Example #3
0
 def __init__(self,
              parent,
              size=wx.DefaultSize,
              text=None,
              color_background=None,
              color_foreground=None):
     html.HtmlWindow.__init__(self,
                              parent,
                              size=size,
                              style=html.HW_DEFAULT_STYLE)
     from ..preferences import RideSettings
     _settings = RideSettings()
     self.general_settings = _settings['General']
     self.color_background_help = color_background if color_background else self.general_settings[
         'background help']
     self.color_foreground_text = color_foreground if color_foreground else self.general_settings[
         'foreground text']
     # HTML_FONT_FACE = _settings.get('font face', '')
     # HTML_FONT_SIZE = _settings.get('font size', 11)
     self.SetBorders(2)
     self.SetStandardFonts(size=9)
     if text:
         self.set_content(text)
     self.SetHTMLBackgroundColour(Colour(self.color_background_help))
     # print(f"DEBUG: HTML init Dialog color: {Colour(self.general_settings['background help'])}")
     self.SetForegroundColour(Colour(self.color_foreground_text))
     self.font = self.GetFont()
     self.font.SetFaceName(self.general_settings['font face'])
     self.font.SetPointSize(self.general_settings['font size'])
     self.SetFont(self.font)
     self.Refresh(True)
     self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
     self.Bind(wx.EVT_CLOSE, self.close)
Example #4
0
 def _get_text_ctrl(self):
     editor = wx.TextCtrl(self, size=(600, -1))
     editor.SetBackgroundColour(Colour(self.color_secondary_background))
     editor.SetOwnBackgroundColour(Colour(self.color_secondary_background))
     editor.SetForegroundColour(Colour(self.color_secondary_foreground))
     editor.SetOwnForegroundColour(Colour(self.color_secondary_foreground))
     return editor
Example #5
0
 def __init__(self, parent, tree, controller):
     self._import_failed_shown = False
     _AbstractListEditor.__init__(self, parent, tree, controller)
     self.SetBackgroundColour(Colour(self.color_background))
     self.SetOwnBackgroundColour(Colour(self.color_background))
     self.SetForegroundColour(Colour(self.color_foreground))
     self.SetOwnForegroundColour(Colour(self.color_foreground))
Example #6
0
 def __init__(self, parent, controller, plugin, tree):
     wx.Panel.__init__(self, parent)
     from ..preferences import RideSettings
     _settings = RideSettings()
     self.general_settings = _settings['General']
     self.color_background = self.general_settings.get('background', 'light grey')
     self.color_foreground = self.general_settings.get('foreground', 'black')
     self.color_secondary_background = self.general_settings.get('secondary background', 'light grey')
     self.color_secondary_foreground = self.general_settings.get('secondary foreground', 'black')
     self.color_background_help = self.general_settings.get('background help', (240, 242, 80))
     self.color_foreground_text = self.general_settings.get('foreground text', (7, 0, 70))
     self.font_face = self.general_settings.get('font face', '')
     self.font_size = self.general_settings.get('font size', 11)
     self.SetBackgroundColour(Colour(self.color_background))
     self.SetOwnBackgroundColour(Colour(self.color_background))
     self.SetForegroundColour(Colour(self.color_foreground))
     self.SetOwnForegroundColour(Colour(self.color_foreground))
     self._controller = controller
     self.plugin = plugin
     self._datafile = controller.datafile
     self._create_controls()
     self._tree = tree
     self._editing = False
     self.font = self._tree.GetFont()
     self.font.SetFaceName(self.font_face)
     self.font.SetPointSize(self.font_size)
     self._tree.SetFont(self.font)
     self._tree.Refresh()
     self.plugin.subscribe(self._ps_on_update_value, RideImportSetting)
Example #7
0
 def _value_display_control(self):
     ctrl = HtmlWindow(self, (-1, 100), color_background=self.color_secondary_background,
                       color_foreground=self.color_secondary_foreground)
     ctrl.SetBackgroundColour(Colour(self.color_secondary_background))
     ctrl.SetForegroundColour(Colour(self.color_secondary_foreground))
     ctrl.Bind(wx.EVT_LEFT_DOWN, self.OnEdit)
     return ctrl
Example #8
0
 def _create_notebook(self):
     self._notebook = wx.Notebook(self, wx.ID_ANY, style=wx.NB_TOP)
     self._notebook.SetBackgroundColour(Colour(self.color_background))
     self._notebook.SetForegroundColour(Colour(self.color_foreground))
     self._notebook.AddPage(self._text_search_panel(), 'Search')
     self._notebook.AddPage(self._tag_pattern_search_panel(), 'Tag Search')
     return self._notebook
Example #9
0
 def createCharBitmaps(self):
     dc = MemoryDC()
     dc.SetFont(self.fonts['monospace'])
     cw, ch = dc.GetTextExtent(' ')
     self.charSize = cw, ch
     self.normalChars = {}
     for c in self.charSet:
         bitmap = Bitmap(cw, ch, BITMAP_SCREEN_DEPTH)
         dc.SelectObject(bitmap)
         dc.SetBackground(self.brushes['bkgd'])
         dc.Clear()
         dc.SetTextForeground(Colour(230, 230, 230))
         dc.DrawText(c, 0, 0)
         self.normalChars[c] = bitmap
     self.selectedChars = {}
     for c in self.charSet:
         bitmap = Bitmap(cw, ch, BITMAP_SCREEN_DEPTH)
         dc.SelectObject(bitmap)
         dc.SetBackground(Brush(Colour(70, 80, 90)))
         dc.Clear()
         dc.SetTextForeground(Colour(160, 160, 180))
         if c == ' ': dc.DrawText(c, 0, 0)
         else: dc.DrawText(c, 0, 0)
         self.selectedChars[c] = bitmap
     self.numberChars = {}
     for c in ' 0123456789':
         bitmap = Bitmap(cw, ch, BITMAP_SCREEN_DEPTH)
         dc.SelectObject(bitmap)
         dc.SetBackground(self.brushes['bkgd'])
         dc.Clear()
         dc.SetTextForeground(Colour(150, 150, 200))
         dc.DrawText(c, 0, 0)
         self.numberChars[c] = bitmap
     dc.SelectObject(NullBitmap)
     return
Example #10
0
 def __init__(self, parent, settings):
     self._parent = parent
     self._settings = settings
     self._section = self._settings._name
     self._selection_listeners = []
     title = "Save or Load Settings"
     RIDEDialog.__init__(self, parent=parent, title=title, size=(650, 400))
     # set Left to Right direction (while we don't have localization)
     self.SetLayoutDirection(wx.Layout_LeftToRight)
     main_sizer = wx.FlexGridSizer(rows=5, cols=1, vgap=10, hgap=10)
     buttons_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
     load = wx.Button(self, ID_LOAD, 'Load settings from file...')
     save = wx.Button(self, ID_SAVE, 'Save settings to file...')
     self.SetSizer(VerticalSizer())
     self.SetBackgroundColour(Colour(self.color_background))
     self.SetForegroundColour(Colour(self.color_foreground))
     self._default_path = os.path.join(SETTINGS_DIRECTORY, 'settings.cfg')
     directory = wx.StaticText(self, label=f"Current directory: {SETTINGS_DIRECTORY}")
     buttons_sizer.Add(load)
     buttons_sizer.AddSpacer(10)
     buttons_sizer.Add(save)
     main_sizer.Add(directory)
     main_sizer.AddSpacer(10)
     main_sizer.Add(buttons_sizer)
     self.SetSizerAndFit(main_sizer)
     self.Bind(wx.EVT_BUTTON, self.OnLoad)
     self.Bind(wx.EVT_BUTTON, self.OnSave)
Example #11
0
    def __init__(self, controller, frame):
        style = wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN | \
                wx.FRAME_FLOAT_ON_PARENT
        RIDEDialog.__init__(self, parent=frame, title="View all tags", size=(500, 400), style=style)
        self.SetBackgroundColour(Colour(self.color_background))
        self.SetForegroundColour(Colour(self.color_foreground))
        # set Left to Right direction (while we don't have localization)
        self.SetLayoutDirection(wx.Layout_LeftToRight)
        self.frame = frame
        self.tree = self.frame.tree
        self._controller = controller
        self._results = utils.NormalizedDict()
        self.selected_tests = list()
        self.tagged_test_cases = list()
        self.unique_tags = 0
        self.total_test_cases = 0
        self.itemDataMap = dict()
        self.sort_state = (0, 1)
        self._index = -1
        self._build_ui()
        self._make_bindings()

        # init ColumnSorterMixin at the end because it calls self.GetListCtrl
        # and therefore self._tags_list has to be declared
        listmix.ColumnSorterMixin.__init__(self, 2)
    def _parse_self(self) -> None:
        """
        Parse this css document and get the colors defined in it.
        :return: None
        """
        parser = tinycss.make_parser('page3')
        stylesheet = parser.parse_stylesheet_file(self._file_path)

        for rule in stylesheet.rules:
            if rule.selector.as_css().startswith('.'):
                if len(rule.declarations) == 2:
                    dec_names = []
                    dec_color = None
                    for declaration in rule.declarations:
                        dec_names.append(declaration.name)
                        if declaration.name == 'color':
                            dec_color = webcolors.hex_to_rgb(
                                declaration.value.as_css())
                    # This means we have a text color declaration
                    if dec_names == ['color', 'display']:
                        color = Colour(dec_color.red, dec_color.green,
                                       dec_color.blue)
                        if color == Colour(0, 0, 255, 255):
                            raise WrongFormatException(
                                Strings.exception_reserved_blue + ': ' +
                                str(color))
                        self._str_to_color_dict[rule.selector.as_css().lstrip(
                            '.')] = color
Example #13
0
 def __init__(self, parent, suggestion_source, size=wx.DefaultSize):
     wx.TextCtrl.__init__(self, parent, size=size, style=wx.WANTS_CHARS|wx.TE_NOHIDESEL)
     _ContentAssistTextCtrlBase.__init__(self, suggestion_source)
     self.SetBackgroundColour(Colour(self.color_background_help))
     self.SetOwnBackgroundColour(Colour(self.color_background_help))
     self.SetForegroundColour(Colour(self.color_foreground_text))
     self.SetOwnForegroundColour(Colour(self.color_foreground_text))
Example #14
0
 def __init__(self, parent, suggestion_source, pos, size=wx.DefaultSize):
     wx.TextCtrl.__init__(self, parent, -1, "", pos, size=size, style=wx.WANTS_CHARS|wx.BORDER_NONE|wx.WS_EX_TRANSIENT|wx.TE_PROCESS_ENTER|wx.TE_NOHIDESEL)
     _ContentAssistTextCtrlBase.__init__(self, suggestion_source)
     self.SetBackgroundColour(Colour(self.color_background_help))
     self.SetOwnBackgroundColour(Colour(self.color_background_help))
     self.SetForegroundColour(Colour(self.color_foreground_text))
     self.SetOwnForegroundColour(Colour(self.color_foreground_text))
     """
Example #15
0
 def paint_arrow_tip(self, gc: wx.Colour, fill: wx.Colour):
     assert len(self.arrow_adjusted_coords) == 4, \
         "Arrow adjusted coords is not of length 4: {}".format(self.arrow_adjusted_coords)
     gc.SetPen(gc.CreatePen(wx.GraphicsPenInfo(fill)))
     gc.SetBrush(wx.Brush(fill))
     gc.DrawLines([
         wx.Point2D(*(coord * cstate.scale))
         for coord in self.arrow_adjusted_coords
     ])
Example #16
0
 def _create_name_editor(self, sizer):
     name_editor = _CreationDialog._create_name_editor(self, sizer)
     name_editor.SetBackgroundColour(Colour(
         self.color_secondary_background))
     name_editor.SetForegroundColour(Colour(
         self.color_secondary_foreground))
     name_editor.SetValidator(
         SuiteFileNameValidator("Name", self._is_dir_type))
     return name_editor
Example #17
0
 def _add_keyword_details(self):
     self._details = HtmlWindow(self)
     self._add_to_sizer(self._details)
     self._find_usages_button = ButtonWithHandler(self, 'Find Usages')
     self._find_usages_button.SetBackgroundColour(
         Colour(self.color_secondary_background))
     self._find_usages_button.SetForegroundColour(
         Colour(self.color_secondary_foreground))
     self.Sizer.Add(self._find_usages_button, 0, wx.ALL, 3)
Example #18
0
 def add_result_unused_keyword(self, index, keyword):
     keyword_info = keyword.info
     self._unused_kw_list.InsertItem(index, keyword_info.name)
     filename = os.path.basename(keyword_info.item.source)
     self._unused_kw_list.SetItem(index, 1, filename)
     self._unused_kw_list.SetItemData(index, index)
     self._unused_kw_list.SetClientData(index, keyword)
     self._unused_kw_list.SetItemBackgroundColour(index, Colour(self.color_secondary_background))
     self._unused_kw_list.SetItemTextColour(index, Colour(self.color_secondary_foreground))
Example #19
0
 def _create_recursion_selector(self, sizer):
     if not self._controller.is_directory_suite():
         return None
     selector = wx.CheckBox(self, label="Change recursively")
     selector.SetBackgroundColour(Colour(self.color_secondary_background))
     selector.SetForegroundColour(Colour(self.color_secondary_foreground))
     selector.SetValue(True)
     sizer.Add(selector, flag=wx.ALL, border=5)
     return selector
Example #20
0
 def _add_pattern_filter(self, sizer, parent):
     self._search_control = wx.SearchCtrl(parent, value='', size=(200,-1),
                                          style=wx.TE_PROCESS_ENTER)
     self._search_control.SetBackgroundColour(Colour(self.color_secondary_background))
     self._search_control.SetForegroundColour(Colour(self.color_secondary_foreground))
     self._search_control.SetDescriptiveText('Search term')
     wrapped = lambda event: self._fuzzy_search_handler(self._search_control.GetValue())
     self._search_control.Bind(wx.EVT_TEXT_ENTER, wrapped)
     sizer.Add(self._search_control, 0, wx.ALL, 3)
Example #21
0
 def _create_switch_button(self, panel):
     sizer = self._vertical_sizer()
     img = ImageProvider().SWITCH_FIELDS_ICON
     button = wx.BitmapButton(panel, -1, img, pos=(10, 20))
     button.SetBackgroundColour(Colour(self.color_secondary_background))
     button.SetForegroundColour(Colour(self.color_secondary_foreground))
     self.Bind(wx.EVT_BUTTON, self.OnSwitchFields, button)
     sizer.Add(button)
     return sizer
Example #22
0
 def _build_ui(self):
     self.SetSize((800,600))
     self.SetBackgroundColour(Colour(self.color_background))
     self.SetForegroundColour(Colour(self.color_foreground))
     self.SetSizer(wx.BoxSizer(wx.VERTICAL))
     self._build_header()
     self._build_filter()
     self._build_notebook()
     self._build_unused_keywords()
     self._build_controls()
Example #23
0
def loadWebColors():
    F = open(wcFile)
    cm = {}
    ff = [line.strip() for line in F.readlines()]
    for line in ff:
        S = line.split('\t')
        C = Color(int(S[1], 0x10))
        r, g, b = C.Get(0)
        cm[S[0]] = Color(b, g, r)
    return cm
Example #24
0
 def _add_pattern_filter(self, sizer):
     sizer.Add(Label(self, label='Search term: '))
     self._search_control = wx.SearchCtrl(self,
                                          size=(200, -1),
                                          style=wx.TE_PROCESS_ENTER)
     self._search_control.SetBackgroundColour(
         Colour(self.color_secondary_background))
     self._search_control.SetForegroundColour(
         Colour(self.color_secondary_foreground))
     sizer.Add(self._search_control)
Example #25
0
 def _create_include_line(self, panel):
     include_line = self._horizontal_sizer()
     include_line.Add(Label(panel, label='Include', size=(80, -1)))
     self._tags_to_include_text = wx.TextCtrl(panel, value='', size=(400, -1),
                                              style=wx.TE_PROCESS_ENTER|wx.TE_NOHIDESEL)
     self._tags_to_include_text.SetBackgroundColour(Colour(self.color_secondary_background))
     self._tags_to_include_text.SetForegroundColour(Colour(self.color_secondary_foreground))
     self._tags_to_include_text.Bind(wx.EVT_TEXT_ENTER, self.OnSearchTags)
     include_line.Add(self._tags_to_include_text)
     return include_line
Example #26
0
 def _add_text_box(self, sizer):
     self._text_box = wx.TextCtrl(
         self,
         style=wx.TE_MULTILINE | wx.TE_NOHIDESEL,
         size=wx.Size(570, 100),
         value=self._settings.excludes.get_excludes())
     self._text_box.SetBackgroundColour(
         Colour(self.color_secondary_background))
     self._text_box.SetForegroundColour(
         Colour(self.color_secondary_foreground))
     sizer.Add(self._text_box, proportion=wx.EXPAND)
Example #27
0
 def __init__(self, parent, plugin):
     style = wx.LC_REPORT | wx.NO_BORDER | wx.LC_SINGLE_SEL | wx.LC_HRULES | wx.LC_VIRTUAL
     wx.ListCtrl.__init__(self, parent, style=style)
     ListCtrlAutoWidthMixin.__init__(self)
     self.SetBackgroundColour(Colour(parent.color_background))
     self.SetForegroundColour(Colour(parent.color_foreground))
     self._plugin = plugin
     self._create_headers()
     self._link_attribute = self._create_link_attribute()
     self._image_list = self._create_image_list()
     self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
Example #28
0
 def show_keywords(self, keywords, kw_selection):
     self._keywords = keywords
     self.SetItemCount(len(self._keywords))
     self.SetBackgroundColour(
         Colour(self.GetParent().color_secondary_background))
     self.SetForegroundColour(
         Colour(self.GetParent().color_secondary_foreground))
     if keywords:
         index = self._keywords.index(kw_selection)
         self.Select(index)
         self.Focus(index)
Example #29
0
 def _get_text_ctrl(self):
     editor = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_NOHIDESEL, size=(600, 400))
     editor.SetBackgroundColour(Colour(self.color_secondary_background))
     editor.SetForegroundColour(Colour(self.color_secondary_foreground))
     """
     editor.SetBackgroundColour(Colour(200, 222, 40))
     editor.SetOwnBackgroundColour(Colour(200, 222, 40))
     editor.SetForegroundColour(Colour(7, 0, 70))
     editor.SetOwnForegroundColour(Colour(7, 0, 70))
     """
     return editor
Example #30
0
    def __init__(self, configs, plugin):
        RIDEDialog.__init__(self, title='Manage Run Configurations')
        # set Left to Right direction (while we don't have localization)

        self.SetBackgroundColour(Colour(self.color_background))
        self.SetOwnBackgroundColour(Colour(self.color_background))
        self.SetForegroundColour(Colour(self.color_foreground))
        self.SetOwnForegroundColour(Colour(self.color_foreground))

        self.SetLayoutDirection(wx.Layout_LeftToRight)
        self.plugin = plugin
        self._create_ui(configs)