Beispiel #1
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, style=wx.NO_BORDER)

        # Attributes
        self._saved = ed_menu.EdMenu()
        self._rmpath = ed_menu.EdMenu()
        self._ids = list()  # List of ids of menu items
        self._rids = list()  # List of remove menu item ids

        key = u'Ctrl'
        if wx.Platform == '__WXMAC__':
            key = u'Cmd'

        tt = wx.ToolTip(
            _("To open multiple files at once %s+Click to select "
              "the desired files/folders then hit Enter to open "
              "them all at once") % key)
        self.SetToolTip(tt)

        # Build Menus
        menu = ed_menu.EdMenu()
        menu.Append(self.ID_MARK_PATH, _("Save Selected Paths"))
        menu.AppendMenu(self.ID_OPEN_MARK, _("Jump to Saved Path"),
                        self._saved)
        menu.AppendSeparator()
        menu.AppendMenu(self.ID_REMOVE_MARK, _("Remove Saved Path"),
                        self._rmpath)

        # Button
        bmp = wx.ArtProvider.GetBitmap(str(ed_glob.ID_ADD_BM), wx.ART_MENU)
        self.menub = platebtn.PlateButton(self,
                                          bmp=bmp,
                                          style=platebtn.PB_STYLE_NOBG)
        self.menub.SetToolTipString(_("Pathmarks"))
        self.menub.SetMenu(menu)

        # Layout bar
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add((1, 1))
        men_sz = wx.BoxSizer(wx.HORIZONTAL)
        men_sz.Add((6, 6))
        men_sz.Add(self.menub, 0, wx.ALIGN_LEFT)
        sizer.Add(men_sz)
        sizer.Add((1, 1))
        self.SetSizer(sizer)

        # Event Handlers
        ed_msg.Subscribe(self.OnThemeChanged, ed_msg.EDMSG_THEME_CHANGED)
        self.Bind(wx.EVT_BUTTON, lambda evt: self.menub.ShowMenu(), self.menub)
        # Due to transparency issues dont do painting on gtk
        if wx.Platform != '__WXGTK__':
            self.Bind(wx.EVT_PAINT, self.OnPaint)
Beispiel #2
0
class Generator(plugin.Plugin):
    """Plugin Interface Extension Point for Generator
    type plugin objects. Generator objects are used
    to generate a document/code from one type to another.

    """
    observers = plugin.ExtensionPoint(GeneratorI)

    def InstallMenu(self, menu):
        """Appends the menu of available Generators onto
        the given menu.
        @param menu: menu to install entries into
        @type menu: wx.Menu

        """
        # Fetch all the menu items for each generator object
        menu_items = list()
        for observer in self.observers:
            try:
                menu_i = observer.GetMenuEntry(menu)
                if menu_i:
                    menu_items.append((menu_i.GetItemLabel(), menu_i))
            except Exception, msg:
                util.Log("[generator][err] %s" % str(msg))

        # Construct the menu
        menu_items.sort()
        genmenu = ed_menu.EdMenu()
        for item in menu_items:
            genmenu.AppendItem(item[1])
        menu.AppendMenu(ed_glob.ID_GENERATOR, _("Generator"), genmenu,
                        _("Generate Code and Documents"))
Beispiel #3
0
    def __init__(self, parent):
        ctrlbox.ControlBar.__init__(self,
                                    parent,
                                    style=ctrlbox.CTRLBAR_STYLE_GRADIENT)

        if wx.Platform == '__WXGTK__':
            self.SetWindowStyle(ctrlbox.CTRLBAR_STYLE_DEFAULT)

        # Attributes
        self._saved = ed_menu.EdMenu()
        self._rmpath = ed_menu.EdMenu()
        self._ids = list()  # List of ids of menu items
        self._rids = list()  # List of remove menu item ids

        key = u'Ctrl'
        if wx.Platform == '__WXMAC__':
            key = u'Cmd'

        tt = wx.ToolTip(
            _("To open multiple files at once %s+Click to select "
              "the desired files/folders then hit Enter to open "
              "them all at once") % key)
        self.SetToolTip(tt)

        # Build Menus
        menu = ed_menu.EdMenu()
        menu.Append(ID_MARK_PATH, _("Save Selected Paths"))
        menu.AppendMenu(ID_OPEN_MARK, _("Jump to Saved Path"), self._saved)
        menu.AppendSeparator()
        menu.AppendMenu(ID_REMOVE_MARK, _("Remove Saved Path"), self._rmpath)

        # Button
        bmp = wx.ArtProvider.GetBitmap(str(ed_glob.ID_ADD_BM), wx.ART_MENU)
        self.menub = platebtn.PlateButton(self,
                                          bmp=bmp,
                                          style=platebtn.PB_STYLE_NOBG)
        self.menub.SetToolTipString(_("Pathmarks"))
        self.menub.SetMenu(menu)

        # Layout bar
        self.AddControl(self.menub, wx.ALIGN_LEFT)

        # Event Handlers
        ed_msg.Subscribe(self.OnThemeChanged, ed_msg.EDMSG_THEME_CHANGED)
        self.Bind(wx.EVT_BUTTON, lambda evt: self.menub.ShowMenu(), self.menub)
Beispiel #4
0
    def OnContextMenu(self, evt):
        """Handle right click menu events in the buffer"""
        self._menu.Clear()

        menu = ed_menu.EdMenu()
        menu.Append(ed_glob.ID_UNDO, _("Undo"))
        menu.Append(ed_glob.ID_REDO, _("Redo"))
        menu.AppendSeparator()
        menu.Append(ed_glob.ID_CUT, _("Cut"))
        menu.Append(ed_glob.ID_COPY, _("Copy"))
        menu.Append(ed_glob.ID_PASTE, _("Paste"))
        menu.AppendSeparator()
        menu.Append(ed_glob.ID_TO_UPPER, _("To Uppercase"))
        menu.Append(ed_glob.ID_TO_LOWER, _("To Lowercase"))
        menu.AppendSeparator()
        menu.Append(ed_glob.ID_SELECTALL, _("Select All"))

        # Allow clients to customize the context menu
        self._menu.SetMenu(menu)
        pos = evt.GetPosition()
        bpos = self.PositionFromPoint(self.ScreenToClient(pos))
        self._menu.SetPosition(bpos)
        self._menu.SetUserData('buffer', self)
        ed_msg.PostMessage(ed_msg.EDMSG_UI_STC_CONTEXT_MENU, self._menu,
                           self.GetId())

        # Spell checking
        # TODO: de-couple to the forthcoming buffer service interface
        menu.InsertSeparator(0)
        words = self.GetWordFromPosition(bpos)
        self._spell_data['word'] = words
        sugg = self._spell.getSuggestions(words[0])

        # Don't give suggestions if the selected word is in the suggestions list
        if words[0] in sugg:
            sugg = list()

        if not len(sugg):
            item = menu.Insert(0, EdEditorView.ID_NO_SUGGEST,
                               _("No Suggestions"))
            item.Enable(False)
        else:
            sugg = reversed(sugg[:min(len(sugg), 3)])
            ids = (ID_SPELL_1, ID_SPELL_2, ID_SPELL_3)
            del self._spell_data['choices']
            self._spell_data['choices'] = list()
            for idx, sug in enumerate(sugg):
                id_ = ids[idx]
                self._menu.AddHandler(id_, self.OnSpelling)
                self._spell_data['choices'].append((id_, sug))
                menu.Insert(0, id_, sug)

        self.PopupMenu(self._menu.Menu)
        evt.Skip()
Beispiel #5
0
    def __init__(self, parent):
        super(BrowserMenuBar,
              self).__init__(parent, style=eclib.CTRLBAR_STYLE_GRADIENT)

        if wx.Platform == '__WXGTK__':
            self.SetWindowStyle(eclib.CTRLBAR_STYLE_DEFAULT)

        # Attributes
        self._saved = ed_menu.EdMenu()
        self._rmpath = ed_menu.EdMenu()
        self._ids = list()  # List of ids of menu items
        self._rids = list()  # List of remove menu item ids

        # Build Menus
        menu = ed_menu.EdMenu()
        menu.Append(ID_MARK_PATH, _("Save Selected Paths"))
        menu.AppendMenu(ID_OPEN_MARK, _("Jump to Saved Path"), self._saved)
        menu.AppendSeparator()
        menu.AppendMenu(ID_REMOVE_MARK, _("Remove Saved Path"), self._rmpath)

        # Button
        bmp = wx.ArtProvider.GetBitmap(str(ed_glob.ID_PREF), wx.ART_MENU)
        self.prefb = eclib.PlateButton(self,
                                       bmp=bmp,
                                       style=eclib.PB_STYLE_NOBG)
        bmp = wx.ArtProvider.GetBitmap(str(ed_glob.ID_ADD_BM), wx.ART_MENU)
        self.menub = eclib.PlateButton(self,
                                       bmp=bmp,
                                       style=eclib.PB_STYLE_NOBG)
        self.menub.SetToolTipString(_("Pathmarks"))
        self.menub.SetMenu(menu)

        # Layout bar
        self.AddControl(self.prefb, wx.ALIGN_LEFT)
        self.AddControl(self.menub, wx.ALIGN_LEFT)

        # Event Handlers
        ed_msg.Subscribe(self.OnThemeChanged, ed_msg.EDMSG_THEME_CHANGED)
        self.Bind(wx.EVT_BUTTON, self.OnPref, self.prefb)
        self.Bind(wx.EVT_BUTTON, lambda evt: self.menub.ShowMenu(), self.menub)
        self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy, self)
Beispiel #6
0
    def __init__(self, base):
        """Initializes the perspective manager. The auimgr parameter is
        a reference to the windows AuiManager instance, base is the base
        path to where perspectives should be loaded from and saved to.
        @param base: path to configuration cache

        """
        super(PerspectiveManager, self).__init__()

        hint = wx.aui.AUI_MGR_TRANSPARENT_HINT
        if wx.Platform == '__WXGTK__':
            # Use venetian blinds style as transparent can cause crashes
            # on linux when desktop compositing is used.
            hint = wx.aui.AUI_MGR_VENETIAN_BLINDS_HINT

        self._mgr = wx.aui.AuiManager(flags=wx.aui.AUI_MGR_DEFAULT
                                      | wx.aui.AUI_MGR_TRANSPARENT_DRAG | hint
                                      | wx.aui.AUI_MGR_ALLOW_ACTIVE_PANE)
        self._mgr.SetManagedWindow(self)

        # Attributes
        self._ids = list()  # List of menu ids
        self._base = os.path.join(base, DATA_FILE)  # Path to config
        self._viewset = dict()  # Set of Views
        self.LoadPerspectives()
        self._menu = ed_menu.EdMenu()  # Control menu
        self._currview = Profile_Get('DEFAULT_VIEW')  # Currently used view

        # Setup Menu
        self._menu.Append(ID_SAVE_PERSPECTIVE, _("Save Current View"),
                          _("Save the current window layout"))
        self._menu.Append(ID_DELETE_PERSPECTIVE, _("Delete Saved View"))
        self._menu.AppendSeparator()
        self._menu.Append(
            ID_AUTO_PERSPECTIVE, _("Automatic"),
            _("Automatically save/use window state from last session"),
            wx.ITEM_CHECK)
        self._menu.AppendSeparator()
        for name in self._viewset:
            self.AddPerspectiveMenuEntry(name)

        # Restore the managed windows previous position preference if available.
        pos = Profile_Get('WPOS', "size_tuple", False)
        if Profile_Get('SET_WPOS') and pos:
            # Ensure window is on screen
            if not self.IsPositionOnScreen(pos):
                pos = self.GetPrimaryDisplayOrigin()
            self.SetPosition(pos)

        # Event Handlers
        self.Bind(wx.EVT_MENU, self.OnPerspectiveMenu)
Beispiel #7
0
def MakeMenu():
    """Make the buffers context menu"""
    menu = ed_menu.EdMenu()
    menu.Append(ed_glob.ID_UNDO, _("Undo"))
    menu.Append(ed_glob.ID_REDO, _("Redo"))
    menu.AppendSeparator()
    menu.Append(ed_glob.ID_CUT, _("Cut"))
    menu.Append(ed_glob.ID_COPY, _("Copy"))
    menu.Append(ed_glob.ID_PASTE, _("Paste"))
    menu.AppendSeparator()
    menu.Append(ed_glob.ID_TO_UPPER, _("To Uppercase"))
    menu.Append(ed_glob.ID_TO_LOWER, _("To Lowercase"))
    menu.AppendSeparator()
    menu.Append(ed_glob.ID_SELECTALL, _("Select All"))
    return menu
Beispiel #8
0
    def __init__(self, auimgr, base):
        """Initializes the perspective manager. The auimgr parameter is
        a reference to the windows AuiManager instance, base is the base
        path to where perspectives should be loaded from and saved to.
        @param auimgr: AuiManager to use
        @param base: path to configuration cache

        """
        object.__init__(self)

        # Attributes
        self._window = auimgr.GetManagedWindow()  # Managed Window
        self._mgr = auimgr  # Window Manager
        self._ids = list()  # List of menu ids
        self._base = os.path.join(base, DATA_FILE)  # Path to config
        self._viewset = dict()  # Set of Views
        self.LoadPerspectives()
        self._menu = ed_menu.EdMenu()  # Control menu
        self._currview = Profile_Get('DEFAULT_VIEW')  # Currently used view

        # Setup Menu
        self._menu.Append(ID_SAVE_PERSPECTIVE, _("Save Current View"),
                          _("Save the current window layout"))
        self._menu.Append(ID_DELETE_PERSPECTIVE, _("Delete Saved View"))
        self._menu.AppendSeparator()
        self._menu.Append(
            ID_AUTO_PERSPECTIVE, _(AUTO_PERSPECTIVE),
            _("Automatically save/use window state from last session"),
            wx.ITEM_CHECK)
        self._menu.AppendSeparator()
        for name in self._viewset:
            self.AddPerspectiveMenuEntry(name)

        # Restore the managed windows previous position and alpha
        # preferences if they are available.
        level = max(100, Profile_Get('ALPHA', default=255))
        self._window.SetTransparent(level)
        pos = Profile_Get('WPOS', "size_tuple", False)
        if Profile_Get('SET_WPOS') and pos:
            # Ensure window is on screen
            if pos[0] < 0 or pos[1] < 0:
                pos = (0, 0)
            self._window.SetPosition(pos)

        # Event Handlers
        self._window.Bind(wx.EVT_MENU, self.OnPerspectiveMenu)
Beispiel #9
0
    def GetTabMenu(self):
        """Get the tab menu
        @return: wx.Menu
        @todo: move logic from notebook to here

        """
        ptxt = self.GetTabLabel()

        menu = ed_menu.EdMenu()
        menu.Append(ed_glob.ID_NEW, _("New Tab"))
        menu.AppendSeparator()
        menu.Append(ed_glob.ID_SAVE, _("Save \"%s\"") % ptxt)
        menu.Append(ed_glob.ID_CLOSE, _("Close \"%s\"") % ptxt)
        menu.Append(ed_glob.ID_CLOSEALL, _("Close All"))
        menu.AppendSeparator()
        menu.Append(ed_glob.ID_COPY_PATH, _("Copy Full Path"))
        return menu
Beispiel #10
0
    def GetShelfObjectMenu(self):
        """Get the minimal menu that lists all Shelf objects
        without the 'Show Shelf' item.
        @return: ed_menu.EdMenu

        """
        menu = ed_menu.EdMenu()
        menu_items = list()
        open_items = self._shelf.GetOpen()
        for observer in self.observers:
            # Register Observers
            open_items[observer.GetName()] = 0
            try:
                menu_i = observer.GetMenuEntry(menu)
                if menu_i is not None:
                    menu_items.append((menu_i.GetItemLabel(), menu_i))
            except Exception, msg:
                self._log("[shelf][err] %s" % str(msg))
Beispiel #11
0
 def OnTabRightUp(self, evt):
     """Tab right click handler"""
     self._menu.Clear()
     if self.MenuCallback:
         sel = self.GetPageIndex(evt.Page)
         s_lbl = self.GetPageText(sel)
         s_lbl = s_lbl.rsplit('-')[0].strip()
         tab_menu = ed_menu.EdMenu()
         tab_menu.Append(EdShelfBook.ID_CLOSE_LIKE_TABS,
                         _("Close All '%s'") % s_lbl)
         self._menu.AddHandler(EdShelfBook.ID_CLOSE_LIKE_TABS,
                               lambda tab, evt: self.CloseAll(s_lbl))
         tab_menu.AppendSeparator()
         shelf_menu = self.MenuCallback()
         tab_menu.AppendMenu(EdShelfBook.ID_SHELF_SUBMENU, _("Open"),
                             shelf_menu)
         self._menu.Menu = tab_menu
         self.PopupMenu(self._menu.Menu)
Beispiel #12
0
    def _GetMenu(self):
        """Return the menu of this object
        @return: ed_menu.EdMenu()

        """
        menu = ed_menu.EdMenu()
        menu.Append(ed_glob.ID_SHOW_SHELF,
                    _("Show Shelf") + "\tCtrl+Alt+S", _("Show the Shelf"))
        menu.AppendSeparator()
        menu_items = list()
        for observer in self.observers:
            # Register Observers
            self._open[observer.GetName()] = 0
            try:
                menu_i = observer.GetMenuEntry(menu)
                if menu_i:
                    menu_items.append((menu_i.GetItemLabel(), menu_i))
            except Exception, msg:
                self._log("[shelf][err] %s" % str(msg))
    def GetTabMenu(self):
        """Get the tab menu
        @return: wx.Menu
        @todo: move logic from notebook to here
        @todo: generalize generic actions to base class (close, new, etc..)

        """
        ptxt = self.GetTabLabel()

        menu = ed_menu.EdMenu()
        menu.Append(ed_glob.ID_NEW, _("New Tab"))
        menu.Append(ed_glob.ID_MOVE_TAB, _("Move Tab to New Window"))
        menu.AppendSeparator()
        menu.Append(ed_glob.ID_SAVE, _("Save \"%s\"") % ptxt)
        menu.Append(ed_glob.ID_CLOSE, _("Close \"%s\"") % ptxt)
        menu.Append(ed_glob.ID_CLOSE_OTHERS, _("Close Other Tabs"))
        menu.Append(ed_glob.ID_CLOSEALL, _("Close All"))
        menu.AppendSeparator()
        menu.Append(ed_glob.ID_COPY_PATH, _("Copy Full Path"))
        return menu
Beispiel #14
0
    def OnTabMenu(self, evt):
        """Show the tab context menu"""
        # Destroy any existing menu
        if self._menu is not None:
            self._menu.Destroy()
            self._menu = None
        cidx = self.GetSelection()
        ptxt = self.GetPageText(cidx)

        # Construct the menu
        self._menu = ed_menu.EdMenu()
        self._menu.Append(ed_glob.ID_NEW, _("New Tab"))
        self._menu.AppendSeparator()
        self._menu.Append(ed_glob.ID_SAVE, _("Save \"%s\"") % ptxt)
        self._menu.Append(ed_glob.ID_CLOSE, _("Close \"%s\"") % ptxt)
        self._menu.Append(ed_glob.ID_CLOSEALL, _("Close All"))
        self._menu.AppendSeparator()
        self._menu.Append(ed_glob.ID_COPY_PATH, _("Copy Full Path"))
        #self._menu.AppendSeparator()

        self.PopupMenu(self._menu)
Beispiel #15
0
    def GetMenu(self):
        """Return the menu of this object
        @return: ed_menu.EdMenu()

        """
        menu = ed_menu.EdMenu()
        menu.Append(ed_glob.ID_SHOW_SHELF, _("Show Shelf") + \
                    ed_menu.EdMenuBar.keybinder.GetBinding(ed_glob.ID_SHOW_SHELF),
                    _("Show the Shelf"))
        menu.AppendSeparator()
        menu_items = list()
        open_items = self._shelf.GetOpen()
        for observer in self.observers:
            # Register Observers
            open_items[observer.GetName()] = 0
            try:
                menu_i = observer.GetMenuEntry(menu)
                if menu_i is not None:
                    menu_items.append((menu_i.GetItemLabel(), menu_i))
            except Exception, msg:
                self._log("[shelf][err] %s" % str(msg))