Beispiel #1
0
    def __init__(self, parent, application):
        super().__init__(parent, style=wx.TAB_TRAVERSAL)
        self._application = application

        self.__pageView = None
        self.__currentPage = None
        self.__wikiroot = None

        self.__htmlRender = None
        self.__htmlRenderorrowed = False

        # Флаг обозначает, что выполняется метод Save
        self.__saveProcessing = False

        self.grayStarImage = getBuiltinImagePath("star_gray.png")
        self.goldStarImage = getBuiltinImagePath("star.png")

        self.tabsCtrl = TabsCtrl(self)
        self.bookmarkButton = wx.BitmapButton(
            self, -1,
            wx.Bitmap(getBuiltinImagePath("star_gray.png"),
                      wx.BITMAP_TYPE_ANY))

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.__onBookmark, self.bookmarkButton)

        self._application.onWikiOpen += self.__onWikiOpen
        self._application.onPageSelect += self.__onPageSelect
        self._application.onBookmarksChanged += self.__onBookmarksChanged
        self._application.onForceSave += self.__onForceSave

        self.Bind(wx.EVT_CLOSE, self.__onClose)
        self.__onPageSelect(None)
Beispiel #2
0
    def _addSearchTools(self):
        assert self.mainWindow is not None
        self.searchMenu = wx.Menu()
        mainMenu = self._application.mainWindow.menuController.getRootMenu()
        mainMenu.Insert(self.searchMenuIndex, self.searchMenu, _("Search"))

        toolbar = self.mainWindow.toolbars[TOOLBAR_GENERAL]

        # Начать поиск на странице
        self._application.actionController.appendMenuItem(
            SearchAction.stringId, self.searchMenu)
        self._application.actionController.appendToolbarButton(
            SearchAction.stringId,
            toolbar,
            getBuiltinImagePath("local_search.png"),
            fullUpdate=False)

        # Начать поиск и замену на странице
        self._application.actionController.appendMenuItem(
            SearchAndReplaceAction.stringId, self.searchMenu)

        self._application.actionController.appendToolbarButton(
            SearchAndReplaceAction.stringId,
            toolbar,
            getBuiltinImagePath("local_replace.png"),
            fullUpdate=False)

        # Продолжить поиск вперед на странице
        self._application.actionController.appendMenuItem(
            SearchNextAction.stringId, self.searchMenu)

        # Продолжить поиск назад на странице
        self._application.actionController.appendMenuItem(
            SearchPrevAction.stringId, self.searchMenu)
Beispiel #3
0
    def __createToolBar(self, parent, toolbar_id):
        toolbar = wx.ToolBar(parent, toolbar_id, style=wx.TB_DOCKABLE)
        self.ID_ATTACH = toolbar.AddTool(
            wx.ID_ANY, _(u"Attach Files…"),
            wx.Bitmap(getBuiltinImagePath("attach.png"), wx.BITMAP_TYPE_ANY),
            wx.NullBitmap, wx.ITEM_NORMAL, _(u"Attach Files…"), "").GetId()

        self.ID_REMOVE = toolbar.AddTool(
            wx.ID_ANY, _(u"Remove Files…"),
            wx.Bitmap(getBuiltinImagePath("delete.png"), wx.BITMAP_TYPE_ANY),
            wx.NullBitmap, wx.ITEM_NORMAL, _(u"Remove Files…"), "").GetId()

        toolbar.AddSeparator()

        self.ID_PASTE = toolbar.AddTool(
            wx.ID_ANY, _(u"Paste"),
            wx.Bitmap(getBuiltinImagePath("paste.png"), wx.BITMAP_TYPE_ANY),
            wx.NullBitmap, wx.ITEM_NORMAL, _(u"Paste"), "").GetId()

        self.ID_EXECUTE = toolbar.AddTool(
            wx.ID_ANY, _(u"Execute"),
            wx.Bitmap(getBuiltinImagePath("execute.png"), wx.BITMAP_TYPE_ANY),
            wx.NullBitmap, wx.ITEM_NORMAL, _(u"Execute"), "").GetId()

        self.ID_OPEN_FOLDER = toolbar.AddTool(
            wx.ID_ANY, _(u"Open Attachments Folder"),
            wx.Bitmap(getBuiltinImagePath("folder.png"),
                      wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL,
            _(u"Open Attachments Folder"), "").GetId()

        toolbar.Realize()
        return toolbar
Beispiel #4
0
    def _createTreeMenu(self):
        """
        Заполнить действиями меню Дерево
        """
        actionController = self._application.actionController
        menu = self.menuController[guidefines.MENU_TREE]
        toolbar = self.toolbars[guidefines.TOOLBAR_GENERAL]

        actionController.appendMenuItem(HistoryBackAction.stringId, menu)

        actionController.appendToolbarButton(HistoryBackAction.stringId,
                                             toolbar,
                                             getBuiltinImagePath("back.png"),
                                             True)

        actionController.enableTools(HistoryBackAction.stringId, False)

        actionController.appendMenuItem(HistoryForwardAction.stringId, menu)

        actionController.appendToolbarButton(
            HistoryForwardAction.stringId, toolbar,
            getBuiltinImagePath("forward.png"), True)

        actionController.enableTools(HistoryForwardAction.stringId, False)

        toolbar.AddSeparator()
        menu.AppendSeparator()

        actionController.appendMenuItem(AddSiblingPageAction.stringId, menu)
        actionController.appendMenuItem(AddChildPageAction.stringId, menu)

        menu.AppendSeparator()

        actionController.appendMenuItem(MovePageUpAction.stringId, menu)
        actionController.appendMenuItem(MovePageDownAction.stringId, menu)

        actionController.appendMenuItem(SortChildAlphabeticalAction.stringId,
                                        menu)

        actionController.appendMenuItem(
            SortSiblingsAlphabeticalAction.stringId, menu)

        menu.AppendSeparator()

        actionController.appendMenuItem(GoToParentAction.stringId, menu)
        actionController.appendMenuItem(GoToFirstChildAction.stringId, menu)
        actionController.appendMenuItem(GoToPrevSiblingAction.stringId, menu)
        actionController.appendMenuItem(GoToNextSiblingAction.stringId, menu)

        menu.AppendSeparator()

        actionController.appendMenuItem(RenamePageAction.stringId, menu)
        actionController.appendMenuItem(RemovePageAction.stringId, menu)

        menu.AppendSeparator()

        actionController.appendMenuItem(EditPagePropertiesAction.stringId,
                                        menu)
Beispiel #5
0
    def initialize(self):
        from outwiker.core.system import getBuiltinImagePath

        self._imageList.Add(
            wx.Bitmap(getBuiltinImagePath("file_icon_default.png"),
                      wx.BITMAP_TYPE_ANY))

        self._imageList.Add(
            wx.Bitmap(getBuiltinImagePath("folder.png"), wx.BITMAP_TYPE_ANY))
Beispiel #6
0
    def _createToolsMenu(self):
        toolbar = self.toolbars[guidefines.TOOLBAR_GENERAL]
        menu = self.menuController[guidefines.MENU_TOOLS]
        actionController = self._application.actionController

        actionController.appendMenuItem(AddTabAction.stringId, menu)
        actionController.appendMenuItem(CloseTabAction.stringId, menu)
        actionController.appendMenuItem(PreviousTabAction.stringId, menu)
        actionController.appendMenuItem(NextTabAction.stringId, menu)

        menu.AppendSeparator()

        actionController.appendMenuItem(GlobalSearchAction.stringId, menu)

        actionController.appendToolbarButton(
            GlobalSearchAction.stringId, toolbar,
            getBuiltinImagePath("global_search.png"), True)

        actionController.appendMenuItem(AttachFilesAction.stringId, menu)

        actionController.appendToolbarButton(AttachFilesAction.stringId,
                                             toolbar,
                                             getBuiltinImagePath("attach.png"),
                                             True)

        menu.AppendSeparator()

        actionController.appendMenuItem(clipboard.CopyPageTitleAction.stringId,
                                        menu)

        actionController.appendMenuItem(clipboard.CopyPagePathAction.stringId,
                                        menu)

        actionController.appendMenuItem(
            clipboard.CopyAttachPathAction.stringId, menu)

        actionController.appendMenuItem(clipboard.CopyPageLinkAction.stringId,
                                        menu)

        actionController.appendMenuItem(OpenAttachFolderAction.stringId, menu)

        menu.AppendSeparator()

        actionController.appendMenuItem(tags.AddTagsToBranchAction.stringId,
                                        menu)

        actionController.appendMenuItem(
            tags.RemoveTagsFromBranchAction.stringId, menu)

        actionController.appendMenuItem(tags.RenameTagAction.stringId, menu)

        menu.AppendSeparator()

        actionController.appendMenuItem(ReloadWikiAction.stringId, menu)
        actionController.appendMenuItem(SetStyleToBranchAction.stringId, menu)
Beispiel #7
0
    def __init__(self, parent: wx.Window):
        super().__init__(parent)
        self._columns = []                     # type: List[BaseColumn]
        self._pages = []                       # type: List[outwiker.core.tree.WikiPage]
        self._defaultIcon = getBuiltinImagePath("page.png")
        self._imageList = ImageListCache(self._defaultIcon)

        self._propagationLevel = 15
        self.SetBackgroundColour(wx.Colour(255, 255, 255))

        self._sizer = wx.FlexGridSizer(cols=1)
        self._sizer.AddGrowableCol(0)
        self._sizer.AddGrowableRow(0)

        self._listCtrl = ULC.UltimateListCtrl(
            self,
            agwStyle=ULC.ULC_REPORT | ULC.ULC_SINGLE_SEL | ULC.ULC_VRULES | ULC.ULC_HRULES | ULC.ULC_SHOW_TOOLTIPS | ULC.ULC_NO_HIGHLIGHT
        )

        self._listCtrl.Bind(ULC.EVT_LIST_ITEM_HYPERLINK,
                            handler=self._onPageClick)
        self._listCtrl.Bind(ULC.EVT_LIST_COL_CLICK,
                            handler=self._onColClick)
        self._listCtrl.SetHyperTextNewColour(wx.BLUE)
        self._listCtrl.SetHyperTextVisitedColour(wx.BLUE)
        self._listCtrl.AssignImageList(self._imageList.getImageList(),
                                       wx.IMAGE_LIST_SMALL)

        self._sizer.Add(self._listCtrl, flag=wx.EXPAND)
        self.SetSizer(self._sizer)
Beispiel #8
0
    def __init__(self, iconsPanel, application, dialog):
        super().__init__(application)
        self._dialog = dialog
        self._iconsPanel = iconsPanel
        self._groupsMaxWidth = 200
        self._page = None
        self._default_group_cover = getBuiltinImagePath(
            'icons_cover_default.png')
        self._default_icon_filename = os.path.abspath(
            os.path.join(getIconsDirList()[0], ICON_DEFAULT))

        guiconfig = GeneralGuiConfig(application.config)

        self._recentIconsList = RecentIconsList(
            guiconfig.iconsHistoryLength.value,
            application.config,
            getIconsDirList()[0])

        self._recentIconsList.load()

        self._iconsPanel.iconsList.Bind(EVT_ICON_SELECTED,
                                        handler=self._onIconSelected)
        self._iconsPanel.groupCtrl.Bind(EVT_SWITCH,
                                        handler=self._onGroupSelect)

        self._selectedIcon = self._default_icon_filename
        self._groupsInfo = self._getGroupsInfo()

        self._appendGroups()
        group_index = 0 if len(self._recentIconsList) else 1
        self._iconsPanel.groupCtrl.SetSelection(group_index)
Beispiel #9
0
    def __init__(self, currversion, parent):
        style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
        super().__init__(parent, style=style)

        self.titleLabel = wx.StaticText(self, -1, _("OutWiker"))
        self.versionTitleLabel = wx.StaticText(self, -1, _("Version:"))
        self.versionLabel = wx.StaticText(self, -1, "")
        self.notebook = wx.Notebook(self, -1, style=0)
        self.aboutPane = wx.Panel(self.notebook, -1)
        self.logo = wx.StaticBitmap(
            self.aboutPane, -1,
            wx.Bitmap(getBuiltinImagePath("outwiker_64x64.png"),
                      wx.BITMAP_TYPE_ANY))

        self.description = wx.StaticText(
            self.aboutPane, -1,
            _("OutWiker is personal wiki system and tree notes outliner."))

        self.license = wx.StaticText(self.aboutPane, -1, _("License: GPL 3"))

        self.siteLabel = wx.StaticText(self.aboutPane, -1,
                                       _("OutWiker's page:"))

        self.outwikerUrl = HyperLinkCtrl(
            self.aboutPane,
            -1,
            label=_("https://jenyay.net/Outwiker/English"),
            URL=_("https://jenyay.net/Outwiker/English"))

        self.contactsPane = wx.Panel(self.notebook, -1)

        self.email = HyperLinkCtrl(self.contactsPane,
                                   -1,
                                   label="*****@*****.**",
                                   URL=_(u"mailto:[email protected]"))

        self.facebook = HyperLinkCtrl(
            self.contactsPane,
            -1,
            label=_(u"Facebook page"),
            URL=_(u"https://www.facebook.com/outwiker"))

        self.twitter = HyperLinkCtrl(self.contactsPane,
                                     -1,
                                     label=_(u"Twitter"),
                                     URL=_(u"https://twitter.com/OutWiker"))

        self.vkontakte = HyperLinkCtrl(self.contactsPane,
                                       -1,
                                       label=_(u"Vkontakte group"),
                                       URL=_(u"https://vk.com/outwiker"))

        self.okButton = wx.Button(self, wx.ID_OK, "")

        self.__set_properties()
        self.__do_layout()

        self.currversion = currversion
        self.versionLabel.SetLabel(str(self.currversion))
Beispiel #10
0
    def _setIcon(self):
        """
        Установки иконки главного окна
        """
        icon = wx.Icon()
        icon.CopyFromBitmap(
            wx.Bitmap(getBuiltinImagePath("outwiker.ico"), wx.BITMAP_TYPE_ANY))

        self.SetIcon(icon)
Beispiel #11
0
def getTrayIconController(application, parentWnd):
    if os.name == "nt":
        fname = 'outwiker_16x16.png'
    else:
        fname = 'outwiker_64x64.png'

    return TrayIconController(application,
                              parentWnd,
                              getBuiltinImagePath(fname))
Beispiel #12
0
    def _createGui(self, parent):
        toolbar = wx.ToolBar(parent, wx.ID_ANY, style=wx.TB_DOCKABLE)
        actionController = self._application.actionController
        self._enableHotkeys()

        # Attach files
        actionController.appendToolbarButton(
            AttachFilesActionForAttachPanel.stringId,
            toolbar,
            getBuiltinImagePath("attach.png")
        )

        # Delete files
        actionController.appendToolbarButton(
            RemoveAttachesActionForAttachPanel.stringId,
            toolbar,
            getBuiltinImagePath("delete.png")
        )

        # Rename file
        actionController.appendToolbarButton(
            RenameAttachActionForAttachPanel.stringId,
            toolbar,
            getBuiltinImagePath("attach_rename.png")
        )

        # Select all files
        actionController.appendToolbarButton(
            AttachSelectAllAction.stringId,
            toolbar,
            getBuiltinImagePath("select_all.png")
        )

        toolbar.AddSeparator()

        # Paste link to files
        actionController.appendToolbarButton(
            AttachPasteLinkActionForAttachPanel.stringId,
            toolbar,
            getBuiltinImagePath("paste.png")
        )

        # Execute files
        actionController.appendToolbarButton(
            AttachExecuteFilesAction.stringId,
            toolbar,
            getBuiltinImagePath("execute.png")
        )

        # Open attach folder
        actionController.appendToolbarButton(
            OpenAttachFolderActionForAttachPanel.stringId,
            toolbar,
            getBuiltinImagePath("folder.png")
        )

        toolbar.Realize()
        return toolbar
Beispiel #13
0
    def _createFileMenu(self):
        """
        Заполнить действиями меню Файл
        """
        toolbar = self.toolbars[guidefines.TOOLBAR_GENERAL]
        menu = self.menuController[guidefines.MENU_FILE]
        actionController = self._application.actionController

        # Создать...
        actionController.appendMenuItem(NewAction.stringId, menu)

        actionController.appendToolbarButton(NewAction.stringId, toolbar,
                                             getBuiltinImagePath("new.png"),
                                             True)

        # Открыть...
        actionController.appendMenuItem(OpenAction.stringId, menu)

        actionController.appendToolbarButton(OpenAction.stringId, toolbar,
                                             getBuiltinImagePath("open.png"),
                                             True)

        # Открыть только для чтения
        actionController.appendMenuItem(OpenReadOnlyAction.stringId, menu)

        menu.AppendSeparator()
        toolbar.AddSeparator()

        # Закрыть
        actionController.appendMenuItem(CloseAction.stringId, menu)

        # Сохранить
        actionController.appendMenuItem(SaveAction.stringId, menu)

        menu.AppendSeparator()

        # Печать
        actionController.appendMenuItem(PrintAction.stringId, menu)

        # Выход
        actionController.appendMenuItem(ExitAction.stringId, menu)

        menu.AppendSeparator()
Beispiel #14
0
 def _addRecentIconsGroup(self, group_info_list):
     recent_title = _('Recent')
     recent_cover = getBuiltinImagePath('recent.png')
     recent_icons = self._recentIconsList.getRecentIcons()
     group_info_list.insert(0, IconsGroupInfo(
         recent_icons,
         recent_title,
         recent_cover,
         group_type=IconsGroupInfo.TYPE_OTHER,
         sort_key=None)
     )
Beispiel #15
0
    def addButtons(self):
        """
        Add the buttons to notes tree panel.
        """
        actionController = self._application.actionController

        actionController.appendToolbarButton(
            GoToParentAction.stringId,
            self.toolbar,
            getBuiltinImagePath("go_to_parent.png"),
            False)

        self.toolbar.AddSeparator()

        actionController.appendToolbarButton(
            MovePageDownAction.stringId,
            self.toolbar,
            getBuiltinImagePath("move_down.png"),
            False)

        actionController.appendToolbarButton(
            MovePageUpAction.stringId,
            self.toolbar,
            getBuiltinImagePath("move_up.png"),
            False)

        self.toolbar.AddSeparator()

        actionController.appendToolbarButton(
            AddSiblingPageAction.stringId,
            self.toolbar,
            getBuiltinImagePath("node-insert-next.png"),
            False)

        actionController.appendToolbarButton(
            AddChildPageAction.stringId,
            self.toolbar,
            getBuiltinImagePath("node-insert-child.png"),
            False)

        actionController.appendToolbarButton(
            RemovePageAction.stringId,
            self.toolbar,
            getBuiltinImagePath("node-delete.png"),
            False)

        self.toolbar.AddSeparator()

        actionController.appendToolbarButton(
            EditPagePropertiesAction.stringId,
            self.toolbar,
            getBuiltinImagePath("edit.png"),
            False)

        self.toolbar.Realize()
        self.Layout()
Beispiel #16
0
    def __getSystemIcon(self, ext):
        """
        Получить картинку по расширению или None, если такой картинки нет
        """
        from outwiker.core.system import getBuiltinImagePath
        iconfolder = "fileicons"
        filename = u"file_extension_{}.png".format(ext)

        imagePath = getBuiltinImagePath(iconfolder, filename)

        if os.path.exists(imagePath):
            return wx.Bitmap(imagePath, wx.BITMAP_TYPE_ANY)

        return None
Beispiel #17
0
    def _addSpellTools(self):
        generalToolbar = self.mainWindow.toolbars[TOOLBAR_GENERAL]
        editMenu = self._application.mainWindow.menuController[MENU_EDIT]
        self._application.actionController.getAction(SPELL_ON_OFF_ID).setFunc(
            self._spellOnOff)

        self._application.actionController.appendMenuCheckItem(
            SPELL_ON_OFF_ID, editMenu)

        self._application.actionController.appendToolbarCheckButton(
            SPELL_ON_OFF_ID,
            generalToolbar,
            getBuiltinImagePath("spellcheck.png"),
            fullUpdate=False)

        enableSpell = EditorConfig(self._application.config).spellEnabled.value
        self._application.actionController.check(SPELL_ON_OFF_ID, enableSpell)
Beispiel #18
0
    def __init__(self, parent, application):
        super().__init__(parent, style=wx.TAB_TRAVERSAL)
        self._application = application
        # Переключатель, устанавливается в True,
        # если "внезапно" изменяется текущая страница
        self.__externalPageSelect = False

        self.toolbar = wx.ToolBar(
            parent=self,
            style=wx.TB_HORIZONTAL | wx.TB_FLAT | wx.TB_DOCKABLE)

        treeStyle = (wx.TR_HAS_BUTTONS | wx.TR_EDIT_LABELS | wx.SUNKEN_BORDER)

        self.treeCtrl = wx.TreeCtrl(self, style=treeStyle)

        self.__set_properties()
        self.__do_layout()

        self.defaultIcon = getBuiltinImagePath("page.png")
        self.iconHeight = ICON_HEIGHT

        self.dragItem = None
        self.popupPage = None

        # Картинки для дерева
        self._iconsCache = ImageListCache(self.defaultIcon)
        self.treeCtrl.AssignImageList(self._iconsCache.getImageList())

        # Кеш для страниц, чтобы было проще искать элемент дерева по странице
        # Словарь. Ключ - страница, значение - элемент дерева wx.TreeItemId
        self._pageCache = {}

        self.popupMenu = None

        # Секция настроек куда сохраняем развернутость страницы
        self.pageOptionsSection = u"Tree"

        # Имя опции для сохранения развернутости страницы
        self.pageOptionExpand = "Expand"

        self.__BindApplicationEvents()
        self.__BindGuiEvents()
        self._dropTarget = NotesTreeDropFilesTarget(self._application,
                                                    self.treeCtrl,
                                                    self)
Beispiel #19
0
    def __createGui(self):
        mainSizer = wx.FlexGridSizer(cols=1)
        mainSizer.AddGrowableCol(0)
        mainSizer.AddGrowableRow(1)
        mainSizer.AddGrowableRow(2)

        self._messageCtrl = wx.StaticText(self, -1, u'')
        hintBitmap = wx.Bitmap(getBuiltinImagePath(u"wand.png"))
        self._formatCtrl = DateTimeFormatCtrl(self, hintBitmap)
        self._formatCtrl.SetMinSize((300, -1))

        okCancel = self.CreateButtonSizer(wx.OK | wx.CANCEL)

        mainSizer.Add(self._messageCtrl, 1, wx.ALL, border=2)
        mainSizer.Add(self._formatCtrl, 1, wx.ALL | wx.EXPAND, border=2)
        mainSizer.Add(okCancel, 1, wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM, border=2)

        self.SetSizer(mainSizer)
Beispiel #20
0
    def __init__(self, parent, multiselect=False, theme=None):
        wx.ScrolledWindow.__init__(self, parent, style=wx.BORDER_THEME)
        self._theme = theme
        self._propagationLevel = 20

        self._backgroundColor = wx.Colour(255, 255, 255)
        if self._theme is not None:
            self._backgroundColor = self._theme.colorBackground

        self._canvas = wx.Panel(self)
        self._canvas.SetSize((0, 0))
        self._canvas.SetBackgroundColour(self._backgroundColor)
        self._canvas.Bind(wx.EVT_PAINT, handler=self.__onPaint)
        self._canvas.Bind(wx.EVT_LEFT_DOWN, handler=self.__onCanvasClick)
        self._canvas.Bind(wx.EVT_LEFT_DCLICK,
                          handler=self.__onCanvasDoubleClick)
        self._canvas.Bind(wx.EVT_MOTION, handler=self.__onMouseMove)

        self.Bind(wx.EVT_SCROLLWIN, handler=self.__onScroll)

        self.cellWidth = 32
        self.cellHeight = 32
        self.margin = 1
        self.multiselect = multiselect

        # Size of the control before icons layout
        self._oldSize = (-1, -1)

        # Path to current page icon
        self._currentIcon = None

        self._lastClickedButton = None

        # self.SetScrollRate(0, 0)
        self.SetBackgroundColour(wx.Colour(255, 255, 255))

        # Список картинок, которые хранятся в окне
        self.buttons = []
        self._iconFileNames = []

        self.defaultIcon = getBuiltinImagePath("page.png")

        self.Bind(wx.EVT_SIZE, self.__onSize)
Beispiel #21
0
    def __init__(self, parent: wx.Window):
        treeStyle = (wx.TR_HAS_BUTTONS | wx.TR_EDIT_LABELS | wx.SUNKEN_BORDER)
        super().__init__(parent, style=treeStyle)

        self.defaultIcon = getBuiltinImagePath('page.png')
        self.iconHeight = ICON_HEIGHT

        # Картинки для дерева
        self._iconsCache = ImageListCache(self.defaultIcon)
        self.AssignImageList(self._iconsCache.getImageList())

        # Кеш для страниц, чтобы было проще искать элемент дерева по странице
        # Словарь. Ключ - страница, значение - элемент дерева wx.TreeItemId
        self._pageCache = {}

        # Имя опции для сохранения развернутости страницы
        self.pageOptionExpand = 'Expand'

        self.Bind(wx.EVT_CLOSE, self.__onClose)
Beispiel #22
0
    def __init__(self, parent):
        super(type(self), self).__init__(parent)

        self._default_group_cover = getBuiltinImagePath(
            'icons_cover_default.png')

        self.__createGuiElements()

        self._groups.Bind(wx.EVT_TREE_SEL_CHANGED,
                          handler=self.__onGroupSelect)

        self._groups.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT,
                          self.__onBeginLabelEdit)

        self._groups.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.__onEndLabelEdit)

        self._groups.Bind(wx.EVT_KEY_DOWN, handler=self.__onKeyDown)

        self.__updateGroups()
        self.SetupScrolling()
Beispiel #23
0
    def __init__(self, parent):
        super().__init__(parent)

        self.__tagsWidth = 350
        self.__tagsHeight = 150

        self.__tagBitmap = wx.Bitmap(getBuiltinImagePath("tag.png"),
                                     wx.BITMAP_TYPE_PNG)

        self.label_tags = wx.StaticText(self, -1, _(u"Tags (comma separated)"))

        self.tagsTextCtrl = wx.TextCtrl(self, -1, "")
        self.tagsTextCtrl.SetMinSize((250, -1))

        self.__tagsCloud = TagsCloud(self)
        self.__tagsCloud.SetMinSize((self.__tagsWidth, self.__tagsHeight))
        self.__tagsCloud.Bind(EVT_TAG_LEFT_CLICK, self.__onTagClick)
        self.tagsTextCtrl.Bind(wx.EVT_TEXT, handler=self.__onTagsChanged)

        self.__layout()
Beispiel #24
0
    def _createGui(self):
        # Поле для ввода искомой фразы
        self._searchText = wx.TextCtrl(self,
                                       -1,
                                       u"",
                                       style=wx.TE_PROCESS_ENTER)

        # Текст для замены
        self._replaceText = wx.TextCtrl(self,
                                        -1,
                                        u"",
                                        style=wx.TE_PROCESS_ENTER)

        # Элементы интерфейса, связанные с поиском
        self._findLabel = wx.StaticText(self, -1, _(u"Find what: "))

        # Кнопка "Найти далее"
        self._nextSearchBtn = wx.Button(self, -1, _(u"Next"))

        # Кнопка "Найти выше"
        self._prevSearchBtn = wx.Button(self, -1, _(u"Prev"))

        # Метка с результатом поиска
        self._resultLabel = wx.StaticText(self, -1, "")
        self._resultLabel.SetMinSize((150, -1))

        # Элементы интерфейса, связанные с заменой
        self._replaceLabel = wx.StaticText(self, -1, _(u"Replace with: "))

        # Кнопка "Заменить"
        self._replaceBtn = wx.Button(self, -1, _(u"Replace"))

        # Кнопка "Заменить все"
        self._replaceAllBtn = wx.Button(self, -1, _(u"Replace All"))

        self._closeBtn = wx.BitmapButton(
            self, -1,
            wx.Bitmap(getBuiltinImagePath("close-button.png"),
                      wx.BITMAP_TYPE_ANY))

        self._layout()
Beispiel #25
0
    def __createTemplatesGui(self, generalConfig):
        """
        Create GUI for selection date and time format
        and new page title template
        """
        # Config values
        initial_date_format = generalConfig.dateTimeFormat.value
        initial_page_title = generalConfig.pageTitleTemplate.value

        # Create labels
        dateTimeLabel = wx.StaticText(self, label=_("Date and time format"))
        pageTitleTemplateLabel = wx.StaticText(
            self, label=_("New page title template"))

        hintBitmap = wx.Bitmap(getBuiltinImagePath('wand.png'))

        # Create main controls
        self.dateTimeFormatCtrl = DateTimeFormatCtrl(
            self, hintBitmap, initial_date_format)

        self.pageTitleTemplateCtrl = DateTimeFormatCtrl(
            self, hintBitmap, initial_page_title)

        # Create common sizer
        self.templateSizer = wx.FlexGridSizer(cols=2)
        self.templateSizer.AddGrowableCol(1)

        self.templateSizer.Add(dateTimeLabel,
                               flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                               border=2)
        self.templateSizer.Add(self.dateTimeFormatCtrl,
                               flag=wx.ALL | wx.EXPAND,
                               border=2)

        self.templateSizer.Add(pageTitleTemplateLabel,
                               flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                               border=2)
        self.templateSizer.Add(self.pageTitleTemplateCtrl,
                               flag=wx.ALL | wx.EXPAND,
                               border=2)
Beispiel #26
0
    def create(root, phrase=u"", tags=[], strategy=AllTagsSearchStrategy):
        """
        Создать страницу с поиском. Если страница существует,
        то сделать ее активной
        """
        searchAlias = _("# Search")
        page = None

        for child_page in root.children:
            if child_page.getTypeString() == SearchWikiPage.getTypeString():
                page = child_page
                break

        if page is None:
            page = SearchPageFactory().create(root, searchAlias, [])
            page.icon = getBuiltinImagePath("global_search.png")

        page.phrase = phrase
        page.searchTags = [tag for tag in tags]
        page.strategy = strategy
        page.root.selectedPage = page

        return page
Beispiel #27
0
    def __init__(self, parent, fname, width, height, theme=None):
        self._parent = parent
        self._fname = fname
        self._width = width
        self._height = height

        self._invalidFileName = getBuiltinImagePath('cross.png')

        self._normalBackground = wx.Colour(255, 255, 255)
        self._selectedBackground = wx.Colour(160, 190, 255)
        self._borderColor = wx.Colour(0, 0, 255)

        if theme is not None:
            self._normalBackground = theme.colorBackground
            self._selectedBackground = theme.colorBackgroundSelected
            self._borderColor = theme.colorBorderSelected

        self._x = 0
        self._y = 0
        self._image = None

        # Выбрана ли данная иконка?
        self.__selected = False
Beispiel #28
0
    def _createTitleFormatGUI(self, main_sizer):
        """
        Создать элементы интерфейса, связанные с форматом заголовка
            главного окна
        """

        hints = [
            ("{file}", _("Wiki file name")),
            ("{page}", _("Page title")),
            ("{subpath}", _("Relative path to current page")),
        ]

        self.titleFormatLabel = wx.StaticText(self,
                                              -1,
                                              _("Main window title format"))

        hintBitmap = wx.Bitmap(getBuiltinImagePath("wand.png"))
        self.titleFormatText = FormatCtrl(
            self,
            self.mainWindowConfig.titleFormat.value,
            hints,
            hintBitmap)

        self.titleFormatSizer = wx.FlexGridSizer(1, 2, 0, 0)
        self.titleFormatSizer.Add(self.titleFormatLabel,
                                  0,
                                  wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                                  2)

        self.titleFormatSizer.Add(self.titleFormatText,
                                  0,
                                  wx.ALL | wx.EXPAND,
                                  2)

        self.titleFormatSizer.AddGrowableCol(1)
        main_sizer.Add(self.titleFormatSizer, 1, wx.EXPAND, 0)
Beispiel #29
0
    def __createGuiElements(self):
        mainSizer = wx.FlexGridSizer(cols=2, rows=1, vgap=0, hgap=0)
        mainSizer.AddGrowableCol(1)
        mainSizer.AddGrowableRow(0)

        #
        # Controls for groups
        groupsSizer = wx.FlexGridSizer(cols=1, rows=0, vgap=0, hgap=0)
        groupsSizer.AddGrowableCol(0)
        groupsSizer.AddGrowableRow(0)

        self._groups = wx.TreeCtrl(self,
                                   style=wx.TR_HAS_BUTTONS | wx.TR_EDIT_LABELS
                                   | wx.SUNKEN_BORDER)
        self._groups.SetMinSize((200, 200))

        self._imagelist = SafeImageList(ICON_WIDTH, ICON_HEIGHT)
        self._groups.AssignImageList(self._imagelist)

        # Buttons for groups
        groupButtonsSizer = wx.BoxSizer(wx.HORIZONTAL)

        # Add a group
        self.addGroupBtn = wx.BitmapButton(self,
                                           bitmap=wx.Bitmap(
                                               getBuiltinImagePath("add.png")))
        self.addGroupBtn.SetToolTip(_(u"Add new group"))
        self.addGroupBtn.Bind(wx.EVT_BUTTON, handler=self.__onAddGroup)

        # Remove a group
        self.removeGroupBtn = wx.BitmapButton(
            self, bitmap=wx.Bitmap(getBuiltinImagePath("remove.png")))
        self.removeGroupBtn.SetToolTip(_(u"Remove group"))
        self.removeGroupBtn.Bind(wx.EVT_BUTTON, handler=self.__onRemoveGroup)

        # Rename a group
        self.renameGroupBtn = wx.BitmapButton(
            self, bitmap=wx.Bitmap(getBuiltinImagePath("pencil.png")))
        self.renameGroupBtn.SetToolTip(_(u"Rename group"))
        self.renameGroupBtn.Bind(wx.EVT_BUTTON, handler=self.__onRenameGroup)

        groupButtonsSizer.Add(self.addGroupBtn, flag=wx.ALL, border=0)
        groupButtonsSizer.Add(self.removeGroupBtn, flag=wx.ALL, border=0)
        groupButtonsSizer.Add(self.renameGroupBtn, flag=wx.ALL, border=0)

        groupsSizer.Add(self._groups, 1, wx.RIGHT | wx.EXPAND, border=2)
        groupsSizer.Add(groupButtonsSizer, 1, wx.RIGHT | wx.EXPAND, border=2)

        #
        # Controls for icons in the group
        iconsSizer = wx.FlexGridSizer(cols=1, rows=0, vgap=0, hgap=0)
        iconsSizer.AddGrowableRow(0)
        iconsSizer.AddGrowableCol(0)

        self._iconsList = IconListCtrl(self, True)
        self._iconsList.SetMinSize((200, 150))

        # Buttons for icons in the group
        iconsButtonsSizer = wx.BoxSizer(wx.HORIZONTAL)

        # Add icons
        self.addIconsBtn = wx.BitmapButton(self,
                                           bitmap=wx.Bitmap(
                                               getBuiltinImagePath("add.png")))
        self.addIconsBtn.SetToolTip(_(u"Add icons"))
        self.addIconsBtn.Bind(wx.EVT_BUTTON, handler=self.__onAddIcons)

        # Remove icons
        self.removeIconsBtn = wx.BitmapButton(
            self, bitmap=wx.Bitmap(getBuiltinImagePath("remove.png")))
        self.removeIconsBtn.SetToolTip(_(u"Remove selected icons"))
        self.removeIconsBtn.Bind(wx.EVT_BUTTON, handler=self.__onRemoveIcons)

        # Set icon as group cover
        self.setCoverBtn = wx.BitmapButton(
            self, bitmap=wx.Bitmap(getBuiltinImagePath("picture.png")))
        self.setCoverBtn.SetToolTip(_(u"Set icon as group cover"))
        self.setCoverBtn.Bind(wx.EVT_BUTTON, handler=self.__onSetCover)

        iconsButtonsSizer.Add(self.addIconsBtn, flag=wx.ALL, border=0)
        iconsButtonsSizer.Add(self.removeIconsBtn, flag=wx.ALL, border=0)
        iconsButtonsSizer.Add(self.setCoverBtn, flag=wx.ALL, border=0)

        iconsSizer.Add(self._iconsList, 1, wx.LEFT | wx.EXPAND, border=2)
        iconsSizer.Add(iconsButtonsSizer, 1, wx.LEFT | wx.EXPAND, border=2)

        # Main sizer
        mainSizer.Add(groupsSizer, 1, wx.ALL | wx.EXPAND, border=0)
        mainSizer.Add(iconsSizer, 1, wx.ALL | wx.EXPAND, border=0)

        self.SetSizer(mainSizer)
        self.Layout()