class _PopupWindowBase(object):

    def __init__(self, size, detachable=True, autohide=False):
        # print("DEBUG: PopupWindow at init")
        self.panel = self._create_ui(size)
        if autohide:
            self._set_auto_hiding()
        if detachable:
            self._set_detachable()
        self.SetSize(size)

    def _create_ui(self, size):
        if wx.VERSION >= (3, 0, 3, ''):  # DEBUG wxPhoenix
            panel = wx.MiniFrame(self)  # DEBUG wx.Panel would not detach on wxPython 4
        else:
            panel = wx.Panel(self)
        panel.SetBackgroundColour(POPUP_BACKGROUND)
        szr = VerticalSizer()
        self._details = HtmlWindow(self, size=size)
        szr.add_expanding(self._details)
        panel.SetSizer(szr)
        panel.Fit()
        return panel

    def _set_detachable(self):
        # print("DEBUG: PopupWindow at Binding mouse on help")
        self._details.Bind(wx.EVT_LEFT_UP, self._detach)
        self._details.Bind(wx.EVT_LEFT_DCLICK, self._detach) # DEBUG add double-click

    def _detach(self, event):
        # print("DEBUG: PopupWindow at detached call")
        self.hide()
        dlg = HtmlDialog(self._detached_title, self._current_details)
        dlg.SetPosition((wx.GetMouseState().x, wx.GetMouseState().y))
        dlg.Show()
        event.Skip()

    def show_at(self, position):
        if self.GetPosition() != position:
            self.SetPosition(position)
        if not self.IsShown():
            self.Show()

    def hide(self, event=None):
        self.Show(False)

    @property
    def screen_position(self):
        return self.ScreenPosition

    @property
    def size(self):
        return self.Size

    def set_content(self, content, title=None):
        color = ''.join(hex(item)[2:] for item in POPUP_BACKGROUND)
        self._current_details = '<body bgcolor=#%s>%s</body>' % \
            (color, content)
        self._details.SetPage(self._current_details)
        self._detached_title = title
예제 #2
0
 def _create_ui(self, size):
     panel = wx.MiniFrame(self)
     panel.SetBackgroundColour(POPUP_BACKGROUND)
     szr = VerticalSizer()
     self._details = HtmlWindow(self, size=size)
     szr.add_expanding(self._details)
     panel.SetSizer(szr)
     panel.Fit()
     return panel
 def _create_ui(self, size):
     if wx.VERSION >= (3, 0, 3, ''):  # DEBUG wxPhoenix
         panel = wx.MiniFrame(self)  # DEBUG wx.Panel would not detach on wxPython 4
     else:
         panel = wx.Panel(self)
     panel.SetBackgroundColour(POPUP_BACKGROUND)
     szr = VerticalSizer()
     self._details = HtmlWindow(self, size=size)
     szr.add_expanding(self._details)
     panel.SetSizer(szr)
     panel.Fit()
     return panel
예제 #4
0
class _PopupWindowBase(object):
    def __init__(self, size, detachable=True, autohide=False):
        self.panel = self._create_ui(size)
        if autohide:
            self._set_auto_hiding()
        if detachable:
            self._set_detachable()
        self.SetSize(size)

    def _create_ui(self, size):
        panel = wx.Panel(self)
        panel.SetBackgroundColour(POPUP_BACKGROUND)
        szr = VerticalSizer()
        self._details = HtmlWindow(self, size=size)
        szr.add_expanding(self._details)
        panel.SetSizer(szr)
        panel.Fit()
        return panel

    def _set_detachable(self):
        self._details.Bind(wx.EVT_LEFT_UP, self._detach)

    def _detach(self, event):
        self.hide()
        dlg = HtmlDialog(self._detached_title, self._current_details)
        dlg.SetPosition((wx.GetMouseState().x, wx.GetMouseState().y))
        dlg.Show()
        if IS_WINDOWS:
            event.Skip()

    def show_at(self, position):
        if not self.IsShown():
            self.SetPosition(position)
            self.Show()

    def hide(self, event=None):
        self.Show(False)

    @property
    def screen_position(self):
        return self.ScreenPosition

    @property
    def size(self):
        return self.Size

    def set_content(self, content, title=None):
        color = ''.join(hex(item)[2:] for item in POPUP_BACKGROUND)
        self._current_details = '<body bgcolor=#%s>%s</body>' % \
            (color, content)
        self._details.SetPage(self._current_details)
        self._detached_title = title
예제 #5
0
 def __init__(self):
     Dialog.__init__(self, title='Help: excludes')
     sizer = wx.BoxSizer(wx.VERTICAL)
     sizer.Add(HtmlWindow(self, (800, 600), self.help),
               1,
               flag=wx.EXPAND)
     self.SetSizerAndFit(sizer)
예제 #6
0
 def __init__(self):
     Dialog.__init__(self, title='RIDE')
     # set Left to Right direction (while we don't have localization)
     self.SetLayoutDirection(wx.Layout_LeftToRight)
     sizer = wx.BoxSizer(wx.VERTICAL)
     sizer.Add(HtmlWindow(self, (650, 200), ABOUT_RIDE), 1, flag=wx.EXPAND)
     self.SetSizerAndFit(sizer)
 def __init__(self):
     Dialog.__init__(self, title='Help: excludes')
     # set Left to Right direction (while we don't have localization)
     self.SetLayoutDirection(wx.Layout_LeftToRight)
     sizer = wx.BoxSizer(wx.VERTICAL)
     sizer.Add(HtmlWindow(self, (800, 600), self.help), 1, flag=wx.EXPAND)
     self.SetSizerAndFit(sizer)
예제 #8
0
 def __init__(self):
     Dialog.__init__(self, title="Shortcut keys for RIDE")
     sizer = wx.BoxSizer(wx.HORIZONTAL)
     sizer.Add(HtmlWindow(self, (350, 400),
                          self._get_platform_specific_shortcut_keys()),
               1,
               flag=wx.EXPAND)
     self.SetSizerAndFit(sizer)
예제 #9
0
 def __init__(self):
     Dialog.__init__(self, title="Shortcut keys for RIDE")
     # set Left to Right direction (while we don't have localization)
     self.SetLayoutDirection(wx.Layout_LeftToRight)
     sizer = wx.BoxSizer(wx.HORIZONTAL)
     sizer.Add(HtmlWindow(self, (350, 400),
                          self._get_platform_specific_shortcut_keys()), 1,
               flag=wx.EXPAND)
     self.SetSizerAndFit(sizer)
예제 #10
0
 def __init__(self, parent):
     HtmlWindow.__init__(self, parent, text=context.ABOUT_RIDE)
예제 #11
0
 def __init__(self):
     Dialog.__init__(self, title='RIDE')
     sizer = wx.BoxSizer(wx.VERTICAL)
     sizer.Add(HtmlWindow(self, (450, 200), ABOUT_RIDE), 1, flag=wx.EXPAND)
     self.SetSizerAndFit(sizer)
예제 #12
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.Sizer.Add(self._find_usages_button, 0, wx.ALL, 3)
예제 #13
0
class KeywordSearchDialog(wx.Frame):

    def __init__(self, parent, searcher):
        wx.Frame.__init__(self, parent, title="Search Keywords",
                          style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT)
        self._plugin = searcher
        self._create_components()
        self._make_bindings()
        self._sort_order = _SortOrder()
        self._last_selected_kw = None
        self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE))
        self.CenterOnParent()

    def _create_components(self):
        self.SetSizer(wx.BoxSizer(wx.VERTICAL))
        self._add_search_control()
        self._add_keyword_list()
        self._add_keyword_details()
        self.SetSize((700,500))

    def _add_search_control(self):
        line1 = self._horizontal_sizer()
        self._add_pattern_filter(line1)
        self._add_doc_filter(line1)
        self.Sizer.Add(line1, 0, wx.ALL, 3)
        line2 = self._horizontal_sizer()
        self._add_source_filter(line2)
        self.Sizer.Add(line2, 0, wx.ALL, 3)

    def _horizontal_sizer(self):
        return wx.BoxSizer(wx.HORIZONTAL)

    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)
        sizer.Add(self._search_control)

    def _add_doc_filter(self, sizer):
        self._use_doc = wx.CheckBox(self, label='Search documentation')
        self._use_doc.SetValue(True)
        sizer.Add(self._use_doc)

    def _add_source_filter(self, sizer):
        sizer.Add(Label(self, label='Source: '))
        self._source_filter = wx.ComboBox(self, value=ALL_KEYWORDS, size=(300, -1),
                                          choices=self._get_sources(), style=wx.CB_READONLY)
        sizer.Add(self._source_filter)

    def _get_sources(self):
        sources = []
        for kw in self._plugin.all_keywords:
            if kw.source not in sources:
                sources.append(kw.source)
        return [ALL_KEYWORDS, ALL_USER_KEYWORDS, ALL_LIBRARY_KEYWORDS] + sorted(sources)

    def _add_keyword_list(self):
        self._list = _KeywordList(self, self._plugin)
        self._list.SetSize(self.Size)
        self._add_to_sizer(self._list)

    def _add_keyword_details(self):
        self._details = HtmlWindow(self)
        self._add_to_sizer(self._details)
        self._find_usages_button = ButtonWithHandler(self, 'Find Usages')
        self.Sizer.Add(self._find_usages_button, 0, wx.ALL, 3)

    def _add_to_sizer(self, component):
        self.Sizer.Add(component, 1, wx.EXPAND | wx.ALL, 3)

    def OnFindUsages(self, event):
        Usages(self._plugin.model, self._plugin.tree.highlight, self._last_selected_kw.name,  self._last_selected_kw).show()

    def _make_bindings(self):
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self._list)
        self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.OnSearch,
                  self._search_control)
        self.Bind(wx.EVT_TEXT_ENTER, self.OnSearch, self._search_control)
        self.Bind(wx.EVT_ACTIVATE, self.OnActivate)
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self.Bind(wx.EVT_CHECKBOX, self.OnUseDocChange, self._use_doc)
        self.Bind(wx.EVT_COMBOBOX, self.OnSourceFilterChange, self._source_filter)
        self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick)

    def OnColClick(self,event):
        col = event.GetColumn()
        if self._sort_order.is_sortable_column(col):
            self._sort_order.sort(col)
            self._populate_search()
        event.Skip()

    def OnActivate(self, event):
        if self._plugin.have_keywords_changed():
            self._update_sources()
            self._populate_search()

    def OnUseDocChange(self, event):
        self._populate_search()

    def OnSearch(self, event):
        self._sort_order.searched(self._get_search_text())
        self._populate_search()

    def OnSourceFilterChange(self, event):
        self._populate_search()

    def OnKey(self, event):
        # Needed for HtmlWindow callback
        pass

    def OnItemSelected(self, event):
        self._last_selected_kw = self._keywords[event.Index]
        self._update_details()

    def _update_sources(self):
        selection = self._source_filter.GetValue()
        self._source_filter.Clear()
        for source in self._get_sources():
            self._source_filter.Append(source)
        self._source_filter.SetValue(selection)
        if self._source_filter.GetValue() != selection:
            self._source_filter.SetValue(ALL_KEYWORDS)

    def OnClose(self, event):
        self.Hide()

    def _populate_search(self):
        self._keywords = _KeywordData(self._plugin.search(*self._get_search_criteria()),
                                      self._sort_order, self._get_search_text())
        self._update_keyword_selection()
        self._list.show_keywords(self._keywords, self._last_selected_kw)
        self.Refresh()

    def _get_search_criteria(self):
        return self._get_search_text(), self._use_doc.GetValue(), self._source_filter.GetValue()

    def _get_search_text(self):
        return self._search_control.GetValue().lower()

    def _update_keyword_selection(self):
        if not self._last_selected_kw in self._keywords and self._keywords:
            self._last_selected_kw = self._keywords[0]
        self._update_details()

    def _update_details(self):
        if self._last_selected_kw in self._keywords:
            self._details.SetPage(self._last_selected_kw.details)
            self._find_usages_button.Enable()
        else:
            self._details.clear()
            self._find_usages_button.Disable()

    def show_search_with_criteria(self, pattern='', search_docs=True, source=ALL_KEYWORDS):
        self._update_widgets(pattern, search_docs, source)
        self._populate_search()
        self._show()
        self._search_control.SetFocus()

    def _update_widgets(self, pattern, search_docs, source):
        self._search_control.SetValue(pattern)
        self._use_doc.SetValue(search_docs)
        self._source_filter.SetValue(source)

    def _show(self):
        if not self.IsShown():
            self.Show()
        self.Raise()
예제 #14
0
 def _value_display_control(self):
     ctrl = HtmlWindow(self, (-1, 100))
     ctrl.Bind(wx.EVT_LEFT_DOWN, self.OnEdit)
     return ctrl
예제 #15
0
파일: editors.py 프로젝트: abrain/RIDE
 def __init__(self, parent):
     HtmlWindow.__init__(self, parent, text=context.ABOUT_RIDE)
 def __init__(self, title, content):
     Dialog.__init__(self, title)
     szr = VerticalSizer()
     szr.add_expanding(HtmlWindow(self, text=content, size=self.Size))
     self.SetSizer(szr)