Ejemplo n.º 1
0
    def initlist(self):
        #create imagelist
        imagelist = self.mainframe.ftp_imagelist
        _imagel = wx.ImageList(16, 16)
        _imagel.Add(common.getpngimage(imagelist['close']))
        _imagel.Add(common.getpngimage(imagelist['document']))
        _imagel.Add(common.getpngimage(imagelist['parentfold']))
        self.images = _imagel

        self.list.SetImageList(self.images, wx.IMAGE_LIST_SMALL)
Ejemplo n.º 2
0
    def initlist(self):
        #create imagelist
        imagelist = self.mainframe.ftp_imagelist
        _imagel = wx.ImageList(16, 16)
        _imagel.Add(common.getpngimage(imagelist['close']))
        _imagel.Add(common.getpngimage(imagelist['document']))
        _imagel.Add(common.getpngimage(imagelist['parentfold']))
        self.images = _imagel

        self.list.SetImageList(self.images, wx.IMAGE_LIST_SMALL)
Ejemplo n.º 3
0
 def add_image(self, name, imagefile):
     if not self.imagefiles.has_key(name):
         self.imagefiles[name] = imagefile
     if not self.imageids.has_key(name):
         image = common.getpngimage(imagefile)
         self.imageids[name] = self.code_snippet_imagelist.Add(image)
         if name in ('close', 'open'):
             imgfile = common.getpngimage('images/TortoiseModified.gif')
             bmp = common.merge_bitmaps(image, imgfile)
             index = self.code_snippet_imagelist.Add(bmp)
             self.imageids[name+'_modified'] = index
Ejemplo n.º 4
0
    def _create(self, replace):
        from modules.wxctrl import FlatButtons

        self.sizer = sizer = ui.HBox(
            padding=0, namebinding='widget').create(self).auto_layout()

        box1 = ui.HBox(2)
        sizer.add(box1, proportion=0, flag=0)
        btn = FlatButtons.FlatBitmapButton(
            self, -1, common.getpngimage('images/closewin.gif'))
        btn.SetToolTip(wx.ToolTip(tr("Close")))
        box1.add(btn).bind('click', self.OnClose)
        self.btnToggleReplace = btn = FlatButtons.FlatBitmapButton(
            self, -1, common.getpngimage('images/replace.gif'))
        btn.SetToolTip(wx.ToolTip(tr("Show Replace Pane")))
        box1.add(btn).bind('click', self.OnOpenReplace)

        box2 = ui.VBox(0)
        sizer.add(box2, name='box2')

        box = ui.HBox(2)
        box2.add(box)

        #add find widgets

        box.add(ui.ComboBox, name='findtext').bind('enter', self.OnNext1)\
            .bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        btn = FlatButtons.FlatBitmapButton(
            self, -1, common.getpngimage('images/next.gif'))
        btn.SetToolTip(wx.ToolTip(tr("Next")))
        box.add(btn, name='btn_next').bind('click', self.OnNext)
        btn = FlatButtons.FlatBitmapButton(
            self, -1, common.getpngimage('images/prev.gif'))
        btn.SetToolTip(wx.ToolTip(tr("Prev")))
        box.add(btn).bind('click', self.OnPrev)
        box.add(ui.Check(False, tr("Match case")), name="chkCase")
        box.add(ui.Check(False, tr("Whole word")), name="chkWhole")
        box.add(ui.Check(False, tr("Regular expression")), name="chkRe")
        box.add(ui.Check(False, tr("Wrap search")), name="chkWrap")

        #add replace widgets
        if replace:
            self._create_replace()
            self.btnToggleReplace.SetToolTip(
                wx.ToolTip(tr("Hide Replace Pane")))

        # last_controls tracks the control / controls that are last in
        # navigation.
        self.last_controls = []
        self._navigation_hack()
Ejemplo n.º 5
0
def add_image(imagelist, image, imgindex):
    global _image_ids
    m = [
        ('modified', common.getpngimage('images/TortoiseModified.gif')),
        ('added', common.getpngimage('images/TortoiseAdded.gif')),
        ('conflicted', common.getpngimage('images/TortoiseConflict.gif')),
        ('deleted', common.getpngimage('images/TortoiseDeleted.gif')),
        ('normal', common.getpngimage('images/TortoiseInSubVersion.gif')),
    ]

    _image_ids[imgindex] = {}
    for f, imgfile in m:
        bmp = common.merge_bitmaps(image, imgfile)
        index = imagelist.Add(bmp)
        _image_ids[imgindex][f] = index
Ejemplo n.º 6
0
def add_image(imagelist, image, imgindex):
    global _image_ids
    m = [
        ('modified', common.getpngimage('images/TortoiseModified.gif')),
        ('added', common.getpngimage('images/TortoiseAdded.gif')),
        ('conflicted', common.getpngimage('images/TortoiseConflict.gif')),
        ('deleted', common.getpngimage('images/TortoiseDeleted.gif')),
        ('normal', common.getpngimage('images/TortoiseInSubVersion.gif')),
    ]

    _image_ids[imgindex] = {}
    for f, imgfile in m:
        bmp = common.merge_bitmaps(image, imgfile)
        index = imagelist.Add(bmp)
        _image_ids[imgindex][f] = index
Ejemplo n.º 7
0
def git_add_image(imagelist, image, imgindex):
    global _git_image_ids
    m = [
        ('M', common.getpngimage('images/TortoiseModified.gif')),
        ('A', common.getpngimage('images/TortoiseAdded.gif')),
        ('U', common.getpngimage('images/TortoiseConflict.gif')),
        ('D', common.getpngimage('images/TortoiseDeleted.gif')),
        (' ', common.getpngimage('images/TortoiseInSubVersion.gif')),
    ]

    _git_image_ids[imgindex] = {}
    for f, imgfile in m:
        bmp = common.merge_bitmaps(image, imgfile)
        index = imagelist.Add(bmp)
        _git_image_ids[imgindex][f] = index
Ejemplo n.º 8
0
def git_add_image(imagelist, image, imgindex):
    global _git_image_ids
    m = [
        ('M', common.getpngimage('images/TortoiseModified.gif')),
        ('A', common.getpngimage('images/TortoiseAdded.gif')),
        ('C', common.getpngimage('images/TortoiseConflict.gif')),
        ('D', common.getpngimage('images/TortoiseDeleted.gif')),
        (' ', common.getpngimage('images/TortoiseInSubVersion.gif')),
    ]

    _git_image_ids[imgindex] = {}
    for f, imgfile in m:
        bmp = common.merge_bitmaps(image, imgfile)
        index = imagelist.Add(bmp)
        _git_image_ids[imgindex][f] = index
Ejemplo n.º 9
0
def init(win):
    icon = wx.EmptyIcon()
    iconfile = common.uni_work_file('ulipad.ico')
#    icon.LoadFile(iconfile, wx.BITMAP_TYPE_ICO)
    bmp = common.getpngimage(iconfile)
#    win.SetIcon(icon.CopyFromBitmap(bmp))
    win.SetIcon(wx.Icon(iconfile, wx.BITMAP_TYPE_ICO))
Ejemplo n.º 10
0
def insertmenu(mlist,
               insertmlist,
               sortedmenukey,
               win,
               accel=None,
               imagelist=None):
    #    debug.info('[makemenu] Inserting dynamic menu...')
    #    makemenu.printmenu(insertmlist)

    keys = sortedmenukey[:]
    while len(keys) > 0:
        key = keys[0]
        if key == None:
            for order, idname, caption, kind, func, message in insertmlist[
                    key]:
                id = Id.makeid(win, idname)
                menu = makemenu.makesubmenu(insertmlist, win, idname, accel,
                                            imagelist)
                makemenu.setmenutext(win, accel)
                win.menubar.Insert(findpos(mlist, key, idname), menu, caption)
                win.menuitems[idname] = menu
            removekey(insertmlist, keys, key)
        else:
            menu = win.menuitems[key]
            for order, idname, caption, kind, func, message in insertmlist[
                    key]:
                pos = findpos(mlist, key, idname)
                if insertmlist.has_key(idname):  #submenu
                    id = Id.makeid(win, idname)
                    submenu = makemenu.makesubmenu(mlist, win, idname, accel,
                                                   imagelist)
                    menu.InsertMenu(pos, id, caption, submenu)
                    win.menuitems[idname] = submenu
                else:
                    if kind == wx.ITEM_SEPARATOR:
                        menu.InsertSeparator(pos)
                    else:
                        id = Id.makeid(win, idname)
                        mitem = wx.MenuItem(menu, id, caption, message, kind)
                        if imagelist and makemenu.disableimage == False:
                            imagename = imagelist.get(idname, '')
                            if imagename:
                                image = common.getpngimage(imagename)
                                if kind == wx.ITEM_CHECK:
                                    mitem.SetBitmaps(image)
                                else:
                                    mitem.SetBitmap(image)
                        menu.InsertItem(pos, mitem)
                        win.menuitems[idname] = mitem

                    if kind in (wx.ITEM_NORMAL, wx.ITEM_CHECK, wx.ITEM_RADIO):
                        if func:
                            try:
                                f = getattr(win, func)
                                wx.EVT_MENU(win, id, f)
                            except:
                                debug.error(
                                    "[makemenu] Can't find function [%s] in class %s"
                                    % (func, win.__class__.__name__))
            removekey(insertmlist, keys, key)
Ejemplo n.º 11
0
def init(win):
    icon = wx.EmptyIcon()
    iconfile = common.uni_work_file('ulipad.ico')
    #    icon.LoadFile(iconfile, wx.BITMAP_TYPE_ICO)
    bmp = common.getpngimage(iconfile)
    #    win.SetIcon(icon.CopyFromBitmap(bmp))
    win.SetIcon(wx.Icon(iconfile, wx.BITMAP_TYPE_ICO))
Ejemplo n.º 12
0
    def __init__(self, parent, mainframe):
        self.initmixin()

        wx.stc.StyledTextCtrl.__init__(self, parent, -1)
        self.parent = parent
        self.mainframe = mainframe
        self.SetMarginWidth(0, 0)
        self.SetMarginWidth(1, 0)
        self.SetMarginWidth(2, 0)

        #add default font settings in config.ini
        x = common.get_config_file_obj()
        font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        fontname = x.default.get('message_font', font.GetFaceName())
        fontsize = x.default.get('message_fontsize', 10)
        #todo fontsize maybe changed for mac
        if wx.Platform == '__WXMAC__':
            fontsize = 13
        #add chinese simsong support, because I like this font
        if not x.default.has_key('message_font') and locale.getdefaultlocale()[0] == 'zh_CN':
            fontname = u'宋体'
        self.defaultfaces = {
            'name':fontname,
            'size':fontsize,
        }

        self.StyleSetSpec(wx.stc.STC_STYLE_DEFAULT, "face:%(name)s,size:%(size)d" % self.defaultfaces)
        self.StyleClearAll()
        
        self.SetScrollWidth(1)
        self.maxline = 'WWWW'

        #disable popup
        self.UsePopUp(0)

        for key in MessageWindow.imagelist.keys():
            f = MessageWindow.imagelist[key]
            MessageWindow.imagelist[key] = common.getpngimage(f)

        self.popmenu = makemenu.makepopmenu(self, self.popmenulist, self.imagelist)

        wx.stc.EVT_STC_MODIFIED(self, self.GetId(), self.OnModified)
        wx.EVT_RIGHT_DOWN(self, self.OnPopUp)

        self.init_update_ui()

#        self.SetCaretForeground(')
        if x.default.has_key('message_caretlineback'):
            self.SetCaretLineBack(x.default.message_caretlineback)
        else:
            self.SetCaretLineBack('#FF8000')
        self.SetCaretLineVisible(True)
        if self.mainframe.pref.message_wrap:
            self.SetWrapMode(wx.stc.STC_WRAP_WORD)
        else:
            self.SetWrapMode(wx.stc.STC_WRAP_NONE)
        self.SetScrollWidth(5000)

        self.callplugin('init', self)
Ejemplo n.º 13
0
def create_new(win, toolbar):
    _id = Id.makeid(win, "IDM_FILE_NEW")
    btnNew = FlatButtons.FlatBitmapMenuButton(toolbar, _id, common.getpngimage("images/new.gif"))
    btnNew.SetRightClickFunc(win.OnFileNews)
    btnNew.SetToolTip(wx.ToolTip(tr("New File")))
    wx.EVT_BUTTON(btnNew, _id, win.OnFileNew)

    return btnNew
Ejemplo n.º 14
0
    def __init__(self, parent, mainframe):
        self.initmixin()

        self.parent = parent
        self.mainframe = mainframe
        self.pref = self.mainframe.pref
        self.app = self.mainframe.app
        self.mainframe.editctrl = self
        self.document = None
        self.lastfilename = None
        self.lastlanguagename = ''
        self.lastdocument = None

        if self.pref.notebook_direction == 0:
            style = 0
        else:
            style = FNB.FNB_BOTTOM
        FNB.FlatNotebook.__init__(self, parent, -1, 
            style=style|FNB.FNB_SMART_TABS|FNB.FNB_VC8|FNB.FNB_X_ON_TAB|
                FNB.FNB_NO_X_BUTTON|FNB.FNB_DROPDOWN_TABS_LIST|FNB.FNB_MOUSE_MIDDLE_CLOSES_TABS)
        self.id = self.GetId()


        #make popup menu
        #@add_menu menulist
        self.callplugin_once('add_menu', EditorFactory.popmenulist)
        #@add_menu_image_list imagelist
        self.callplugin_once('add_menu_image_list', EditorFactory.imagelist)
        #@add_panel_list panellist
        self.callplugin_once('add_panel_list', EditorFactory.panellist)

        self.popmenu = makemenu.makepopmenu(self, EditorFactory.popmenulist, EditorFactory.imagelist)
#        self.SetRightClickMenu(self.popmenu)
        FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED(self, self.id, self.OnChanged)
        FNB.EVT_FLATNOTEBOOK_PAGE_CLOSING(self, self.id, self.OnClose)
        wx.EVT_LEFT_DCLICK(self._pages, self.OnDClick)
        FNB.EVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU(self, self.id, self.OnPopup)

        self.imageindex = {}
        pageimages = wx.ImageList(16, 16)
        for i, v in enumerate(self.pageimagelist.items()):
            name, imagefilename = v
            image = common.getpngimage(imagefilename)
            pageimages.Add(image)
            self.imageindex[name] = i
        self.pageimages = pageimages

#        self.AssignImageList(self.pageimages)
        self.SetImageList(self.pageimages)
        self.skip_closing = False
        self.skip_page_change = False
        self.full = False
        self.last_side_panel_status = None

        #set FlatNotebook style
        x = common.get_config_file_obj()
        tab_color = x.default.get('editor_tab_color', '#98FB98')
        self.SetActiveTabColour(tab_color)
Ejemplo n.º 15
0
def create_next(win, toolbar):
    ID_NEXT = Id.makeid(win, 'IDM_SEARCH_NAV_NEXT')
    btnNext = FlatButtons.FlatBitmapMenuButton(toolbar, ID_NEXT, common.getpngimage('images/nav_right.gif'))
    btnNext.SetRightClickFunc(win.OnSmartNavNextFiles)
    btnNext.SetToolTip(wx.ToolTip(tr('Next File')))
    wx.EVT_BUTTON(btnNext, ID_NEXT, win.OnSmartNavNext)
    wx.EVT_UPDATE_UI(win, win.IDM_SEARCH_NAV_NEXT, win.OnUpdateUI)

    return btnNext
Ejemplo n.º 16
0
def create_prev(win, toolbar):
    ID_PREV = Id.makeid(win, 'IDM_SEARCH_NAV_PREV')
    btnPrev = FlatButtons.FlatBitmapMenuButton(toolbar, ID_PREV, common.getpngimage('images/nav_left.gif'))
    btnPrev.SetRightClickFunc(win.OnSmartNavPrevFiles)
    btnPrev.SetToolTip(wx.ToolTip(tr('Previous File')))
    wx.EVT_BUTTON(btnPrev, ID_PREV, win.OnSmartNavPrev)
    wx.EVT_UPDATE_UI(win, win.IDM_SEARCH_NAV_PREV, win.OnUpdateUI)

    return btnPrev
Ejemplo n.º 17
0
def create_new(win, toolbar):
    _id = Id.makeid(win, 'IDM_FILE_NEW')
    btnNew = FlatButtons.FlatBitmapMenuButton(
        toolbar, _id, common.getpngimage('images/new.gif'))
    btnNew.SetRightClickFunc(win.OnFileNews)
    btnNew.SetToolTip(wx.ToolTip(tr('New File')))
    wx.EVT_BUTTON(btnNew, _id, win.OnFileNew)

    return btnNew
Ejemplo n.º 18
0
    def _create(self, replace):
        from modules.wxctrl import FlatButtons

        self.sizer = sizer = ui.HBox(padding=0, namebinding='widget').create(self).auto_layout()

        box1 = ui.HBox(2)
        sizer.add(box1, proportion=0, flag=0)
        btn = FlatButtons.FlatBitmapButton(self, -1, common.getpngimage('images/closewin.gif'))
        btn.SetToolTip(wx.ToolTip(tr("Close")))
        box1.add(btn).bind('click', self.OnClose)
        self.btnToggleReplace = btn = FlatButtons.FlatBitmapButton(self, -1, common.getpngimage('images/replace.gif'))
        btn.SetToolTip(wx.ToolTip(tr("Show Replace Pane")))
        box1.add(btn).bind('click', self.OnOpenReplace)

        box2 = ui.VBox(0)
        sizer.add(box2, name='box2')

        box = ui.HBox(2)
        box2.add(box)

        #add find widgets

        box.add(ui.ComboBox, name='findtext').bind('enter', self.OnNext1)\
            .bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        btn = FlatButtons.FlatBitmapButton(self, -1, common.getpngimage('images/next.gif'))
        btn.SetToolTip(wx.ToolTip(tr("Next")))
        box.add(btn, name='btn_next').bind('click', self.OnNext)
        btn = FlatButtons.FlatBitmapButton(self, -1, common.getpngimage('images/prev.gif'))
        btn.SetToolTip(wx.ToolTip(tr("Prev")))
        box.add(btn).bind('click', self.OnPrev)
        box.add(ui.Check(False, tr("Match case")), name="chkCase")
        box.add(ui.Check(False, tr("Whole word")), name="chkWhole")
        box.add(ui.Check(False, tr("Regular expression")), name="chkRe")
        box.add(ui.Check(False, tr("Wrap search")), name="chkWrap")

        #add replace widgets
        if replace:
            self._create_replace()
            self.btnToggleReplace.SetToolTip(wx.ToolTip(tr("Hide Replace Pane")))
            
        # last_controls tracks the control / controls that are last in
        # navigation.
        self.last_controls = []
        self._navigation_hack()
Ejemplo n.º 19
0
def add_image(imagelist, imageids, name, image):
    if name not in ('close', 'open'):
        return

    m = [
        ('modified', common.getpngimage('images/TortoiseModified.gif')),
    ]

    for f, imgfile in m:
        bmp = common.merge_bitmaps(image, imgfile)
        index = imagelist.Add(bmp)
        imageids[name+f] = index
Ejemplo n.º 20
0
def insertmenu(mlist, insertmlist, sortedmenukey, win, accel=None, imagelist=None):
#    debug.info('[makemenu] Inserting dynamic menu...')
#    makemenu.printmenu(insertmlist)
    
    keys = sortedmenukey[:]
    while len(keys) > 0:
        key = keys[0]
        if key == None:
            for     order, idname, caption, kind, func, message in insertmlist[key]:
                id = Id.makeid(win, idname)
                menu = makemenu.makesubmenu(insertmlist, win, idname, accel, imagelist)
                makemenu.setmenutext(win, accel)
                win.menubar.Insert(findpos(mlist, key, idname), menu, caption)
                win.menuitems[idname] = menu
            removekey(insertmlist, keys, key)
        else:
            menu = win.menuitems[key]
            for     order, idname, caption, kind, func, message in insertmlist[key]:
                pos = findpos(mlist, key, idname)
                if insertmlist.has_key(idname): #submenu
                    id = Id.makeid(win, idname)
                    submenu = makemenu.makesubmenu(mlist, win, idname, accel, imagelist)
                    menu.InsertMenu(pos, id, caption, submenu)
                    win.menuitems[idname] = submenu
                else:
                    if kind == wx.ITEM_SEPARATOR:
                        menu.InsertSeparator(pos)
                    else:
                        id = Id.makeid(win, idname)
                        mitem = wx.MenuItem(menu, id, caption, message, kind)
                        if imagelist and makemenu.disableimage == False:
                            imagename = imagelist.get(idname, '')
                            if imagename:
                                image = common.getpngimage(imagename)
                                if kind == wx.ITEM_CHECK:
                                    mitem.SetBitmaps(image)
                                else:
                                    mitem.SetBitmap(image)
                        menu.InsertItem(pos, mitem)
                        win.menuitems[idname] = mitem

                    if kind in (wx.ITEM_NORMAL, wx.ITEM_CHECK, wx.ITEM_RADIO):
                        if func:
                            try:
                                f = getattr(win, func)
                                wx.EVT_MENU(win, id, f)
                            except:
                                debug.error("[makemenu] Can't find function [%s] in class %s" % (func, win.__class__.__name__))
            removekey(insertmlist, keys, key)
Ejemplo n.º 21
0
def makesubmenu(mlist, win, pid, accel=None, imagelist=None):
    menu = wx.Menu()
    if not mlist.has_key(pid):
        return menu
    for m in mlist[pid]:
        order, idname, caption, kind, func, message = m
        if mlist.has_key(idname):
            id = Id.makeid(win, idname)
            submenu = makesubmenu(mlist, win, idname, accel, imagelist)
            menu.AppendMenu(id, caption, submenu)
            win.menuitems[idname] = submenu
        else:
            if kind == wx.ITEM_SEPARATOR:
                menu.AppendSeparator()
            else:
                id = Id.makeid(win, idname)
                if accel and accel.has_key(idname):
                    caption = caption.split('\t')[0]
                    mitem = wx.MenuItem(menu, id, caption, message, kind)
                    #mitem.SetText(caption + '\t' + accel[idname][0])
                else:
                    pos = caption.find('\t')
                    if pos > -1:
                        a, b = caption.split('\t')
                        #caption = a + '\t' + b.replace('+', ',')
                    mitem = wx.MenuItem(menu, id, caption, message, kind)
                if imagelist and disableimage == False:
                    imagename = imagelist.get(idname, '')
                    if imagename:
                        image = common.getpngimage(imagename)
                        if kind == wx.ITEM_CHECK:
                            mitem.SetBitmaps(image)
                        else:
                            mitem.SetBitmap(image)
#                else:
#                    print 'nobitmap'
#                    if wx.Platform == '__WXMSW__':
#                        mitem.SetBitmap(common.getpngimage('images/empty.gif'))
                menu.AppendItem(mitem)
                win.menuitems[idname] = mitem

            if kind in (wx.ITEM_NORMAL, wx.ITEM_CHECK, wx.ITEM_RADIO):
                if func:
                    try:
                        f = getattr(win, func)
                        wx.EVT_MENU(win, id, f)
                    except:
                        debug.error("[makemenu] Can't find function [%s] in class %s" % (func, win.__class__.__name__))
    return menu
Ejemplo n.º 22
0
 def __init__(self, parent):
     wx.Panel.__init__(self, parent)
     self.parent = parent
     
     self.sizer = sizer = ui.VBox(padding=0, namebinding='widget').create(self).auto_layout()
     box = sizer.add(ui.HBox(padding=2))
     self.btnRefresh = FlatButtons.FlatBitmapButton(self, -1, 
         common.getpngimage('images/classbrowserrefresh.gif'))
     box.add(self.btnRefresh)
     self.code = TextEditor(self, None, 'canvas test', 'texteditor', True)
     self.code.cansavefileflag = False
     self.code.needcheckfile = False
     self.code.savesession = False
     sizer.add(self.code, proportion=1, flag=wx.EXPAND|wx.ALL, border=3)
     sizer.auto_fit(0)
Ejemplo n.º 23
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.parent = parent

        self.sizer = sizer = ui.VBox(
            padding=0, namebinding='widget').create(self).auto_layout()
        box = sizer.add(ui.HBox(padding=2))
        self.btnRefresh = FlatButtons.FlatBitmapButton(
            self, -1, common.getpngimage('images/classbrowserrefresh.gif'))
        box.add(self.btnRefresh)
        self.code = TextEditor(self, None, 'canvas test', 'texteditor', True)
        self.code.cansavefileflag = False
        self.code.needcheckfile = False
        self.code.savesession = False
        sizer.add(self.code, proportion=1, flag=wx.EXPAND | wx.ALL, border=3)
        sizer.auto_fit(0)
Ejemplo n.º 24
0
    def __init__(self, parent, panel, side, style=0):
        self.initmixin()

        FNB.FlatNotebook.__init__(self,
                                  parent,
                                  -1,
                                  style=style | FNB.FNB_VC8 | FNB.FNB_X_ON_TAB
                                  | FNB.FNB_NO_X_BUTTON,
                                  size=(0, 0))
        self.parent = parent
        self.panel = panel
        self.side = side
        self.mainframe = self.panel.mainframe

        #@add_menu menulist
        self.callplugin_once('add_menu', Notebook.popmenulist)
        #@add_menu_image_list imagelist
        self.callplugin_once('add_menu_image_list', Notebook.imagelist)
        #@add_page_image_list imagelist
        self.callplugin_once('add_page_image_list', Notebook.pageimagelist)
        self.popmenu = makemenu.makepopmenu(self, self.popmenulist,
                                            self.imagelist)
        self.SetRightClickMenu(self.popmenu)
        FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED(self, self.GetId(),
                                          self.OnPageChanged)
        #        wx.EVT_LEFT_UP(self, self.OnPageChanged)
        wx.EVT_LEFT_DCLICK(self._pages, self.OnDClick)
        #        wx.EVT_RIGHT_DOWN(self, self.OnPopUp)
        FNB.EVT_FLATNOTEBOOK_PAGE_CLOSING(self, self.GetId(), self.OnClose)
        self.SetActiveTabColour('#7FFFD4')

        self.pageimageindex = {}
        pageimages = wx.ImageList(16, 16)
        for i, v in enumerate(self.pageimagelist.items()):
            name, imagefilename = v
            image = common.getpngimage(imagefilename)
            pageimages.Add(image)
            self.pageimageindex[name] = i
        self.pageimages = pageimages

        self.SetImageList(self.pageimages)

        self.delete_must = False
        self.old_size = None
        self.full = False

        self.callplugin('init', self)
Ejemplo n.º 25
0
    def __init__(self, parent, mainframe):
        self.initmixin()

        #add default font settings in config.ini
        x = common.get_config_file_obj()
        font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        fontname = x.default.get('shell_font', font.GetFaceName())
        fontsize = x.default.get('shell_fontsize', 10)
        #todo fontsize maybe changed for mac
        if wx.Platform == '__WXMAC__':
            fontsize = 13
        #add chinese simsong support, because I like this font
        if not x.default.has_key('shell_font') and locale.getdefaultlocale(
        )[0] == 'zh_CN':
            fontname = u'宋体'

        import wx.py.editwindow as edit
        edit.FACES['mono'] = fontname
        edit.FACES['size'] = fontsize

        wx.py.shell.Shell.__init__(self, parent, -1, InterpClass=NEInterpreter)

        #disable popup
        self.UsePopUp(0)

        self.parent = parent
        self.mainframe = mainframe
        wx.EVT_KILL_FOCUS(self, self.OnKillFocus)

        for key in ShellWindow.imagelist.keys():
            f = ShellWindow.imagelist[key]
            ShellWindow.imagelist[key] = common.getpngimage(f)

        self.popmenu = makemenu.makepopmenu(self, ShellWindow.popmenulist,
                                            ShellWindow.imagelist)

        wx.EVT_RIGHT_DOWN(self, self.OnPopUp)

        wx.EVT_UPDATE_UI(self, self.IDPM_UNDO, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_REDO, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_CUT, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_COPY, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_COPY_CLEAR, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_PASTE, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_PASTE_RUN, self._OnUpdateUI)
Ejemplo n.º 26
0
    def __init__(self, parent, mainframe):
        self.initmixin()

        #add default font settings in config.ini
        x = common.get_config_file_obj()
        font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        fontname = x.default.get('shell_font', font.GetFaceName())
        fontsize = x.default.get('shell_fontsize', 10)
        #todo fontsize maybe changed for mac
        if wx.Platform == '__WXMAC__':
            fontsize = 13
        #add chinese simsong support, because I like this font
        if not x.default.has_key('shell_font') and locale.getdefaultlocale()[0] == 'zh_CN':
            fontname = u'宋体'

        import wx.py.editwindow as edit
        edit.FACES['mono'] = fontname
        edit.FACES['size'] = fontsize

        wx.py.shell.Shell.__init__(self, parent, -1, InterpClass=NEInterpreter)

        #disable popup
        self.UsePopUp(0)
        
        self.parent = parent
        self.mainframe = mainframe
        wx.EVT_KILL_FOCUS(self, self.OnKillFocus)
        
        for key in ShellWindow.imagelist.keys():
            f = ShellWindow.imagelist[key]
            ShellWindow.imagelist[key] = common.getpngimage(f)
        
        self.popmenu = makemenu.makepopmenu(self, ShellWindow.popmenulist, ShellWindow.imagelist)
        
        wx.EVT_RIGHT_DOWN(self, self.OnPopUp)
        
        wx.EVT_UPDATE_UI(self, self.IDPM_UNDO, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_REDO, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_CUT, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_COPY, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_COPY_CLEAR, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_PASTE, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_PASTE_RUN, self._OnUpdateUI)
Ejemplo n.º 27
0
    def deal_file_images(self):
        self.fileimages = {}
        self.fileimages['.py'] = 'file_py.gif'
        self.fileimages['.pyw'] = 'file_py.gif'
        self.fileimages['.txt'] = 'file_txt.gif'
        self.fileimages['.html'] = 'file_html.gif'
        self.fileimages['.htm'] = 'file_html.gif'
        self.fileimages['.ini'] = 'file_txt.gif'
        self.fileimages['.bat'] = 'file_txt.gif'
        self.fileimages['.xml'] = 'file_xml.gif'
        ini = common.get_config_file_obj()
        self.fileimages.update(ini.fileimages)
        ini.fileimages = self.fileimages
        ini.save()

        self.fileimageindex = {}
        for image in self.fileimages.values():
            if not self.fileimageindex.has_key(image):
                obj = common.getpngimage(os.path.join(self.mainframe.userpath, 'images', image))
                self.fileimageindex[image] = self.add_image(obj)
Ejemplo n.º 28
0
    def deal_file_images(self):
        self.fileimages = {}
        self.fileimages['.py'] = 'file_py.gif'
        self.fileimages['.pyw'] = 'file_py.gif'
        self.fileimages['.txt'] = 'file_txt.gif'
        self.fileimages['.html'] = 'file_html.gif'
        self.fileimages['.htm'] = 'file_html.gif'
        self.fileimages['.ini'] = 'file_txt.gif'
        self.fileimages['.bat'] = 'file_txt.gif'
        self.fileimages['.xml'] = 'file_xml.gif'
        ini = common.get_config_file_obj()
        self.fileimages.update(ini.fileimages)
        ini.fileimages = self.fileimages
        ini.save()

        self.fileimageindex = {}
        for image in self.fileimages.values():
            if not self.fileimageindex.has_key(image):
                obj = common.getpngimage(
                    os.path.join(self.mainframe.userpath, 'images', image))
                self.fileimageindex[image] = self.add_image(obj)
Ejemplo n.º 29
0
    def __init__(self, parent, panel, side, style=0):
        self.initmixin()

        FNB.FlatNotebook.__init__(self, parent, -1, style=style|FNB.FNB_VC8|FNB.FNB_X_ON_TAB|FNB.FNB_NO_X_BUTTON, size=(0, 0))
        self.parent = parent
        self.panel = panel
        self.side = side
        self.mainframe = self.panel.mainframe

        #@add_menu menulist
        self.callplugin_once('add_menu', Notebook.popmenulist)
        #@add_menu_image_list imagelist
        self.callplugin_once('add_menu_image_list', Notebook.imagelist)
        #@add_page_image_list imagelist
        self.callplugin_once('add_page_image_list', Notebook.pageimagelist)
        self.popmenu = makemenu.makepopmenu(self, self.popmenulist, self.imagelist)
        self.SetRightClickMenu(self.popmenu)
        FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)
#        wx.EVT_LEFT_UP(self, self.OnPageChanged)
        wx.EVT_LEFT_DCLICK(self._pages, self.OnDClick)
#        wx.EVT_RIGHT_DOWN(self, self.OnPopUp)
        FNB.EVT_FLATNOTEBOOK_PAGE_CLOSING(self, self.GetId(), self.OnClose)
        self.SetActiveTabColour('#7FFFD4')

        self.pageimageindex = {}
        pageimages = wx.ImageList(16, 16)
        for i, v in enumerate(self.pageimagelist.items()):
            name, imagefilename = v
            image = common.getpngimage(imagefilename)
            pageimages.Add(image)
            self.pageimageindex[name] = i
        self.pageimages = pageimages
        
        self.SetImageList(self.pageimages)
        
        self.delete_must = False
        self.old_size = None
        self.full = False
        
        self.callplugin('init', self)
Ejemplo n.º 30
0
    def __init__(self, parent, editor, autoexpand=True):
        self.initmixin()

        wx.Panel.__init__(self, parent, -1)
        self.parent = parent
        self.editor = editor
        self.autoexpand = autoexpand

        self.activeflag = False

        self.sizer = ui.VBox(namebinding='widget').create(self).auto_layout()
        self.btnRefresh = FlatButtons.FlatBitmapButton(
            self, -1, common.getpngimage('images/classbrowserrefresh.gif'))
        self.sizer.add(self.btnRefresh).bind('click', self.OnRefresh)

        self.imagelist = wx.ImageList(16, 16)

        #add share image list
        self.imagefilenames = []
        self.imageids = {}
        self.callplugin('add_images', self.imagefilenames)
        for name, imagefile in self.imagefilenames:
            self.add_image(name, imagefile)

        style = wx.TR_SINGLE | wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS | wx.TR_TWIST_BUTTONS
        if wx.Platform == '__WXMSW__':
            style = style | wx.TR_ROW_LINES
        elif wx.Platform == '__WXGTK__':
            style = style | wx.TR_NO_LINES

        self.tree = wx.TreeCtrl(self, -1, style=style)
        self.tree.AssignImageList(self.imagelist)

        self.sizer.add(self.tree, proportion=1, flag=wx.EXPAND)
        self.root = self.tree.AddRoot('OutlineBrowser')

        self.nodes = {}
        self.ID = 1

        #        wx.EVT_TREE_SEL_CHANGING(self.tree, self.tree.GetId(), self.OnChanging)
        #        wx.EVT_TREE_SEL_CHANGED(self.tree, self.tree.GetId(), self.OnChanged)
        #        wx.EVT_TREE_BEGIN_LABEL_EDIT(self.tree, self.tree.GetId(), self.OnBeginChangeLabel)
        #        wx.EVT_TREE_END_LABEL_EDIT(self.tree, self.tree.GetId(), self.OnChangeLabel)
        wx.EVT_TREE_ITEM_ACTIVATED(self.tree, self.tree.GetId(),
                                   self.OnChanged)
        #        wx.EVT_TREE_ITEM_RIGHT_CLICK(self.tree, self.tree.GetId(), self.OnRClick)
        #        wx.EVT_RIGHT_UP(self.tree, self.OnRClick)
        wx.EVT_TREE_DELETE_ITEM(self.tree, self.tree.GetId(),
                                self.OnDeleteItem)
        #        wx.EVT_LEFT_DCLICK(self.tree, self.OnDoubleClick)
        #        wx.EVT_TREE_ITEM_EXPANDING(self.tree, self.tree.GetId(), self.OnExpanding)
        wx.EVT_LEFT_DOWN(self.tree, self.OnLeftDown)
        wx.EVT_TREE_ITEM_GETTOOLTIP(self.tree, self.tree.GetId(),
                                    self.OnGetToolTip)
        wx.EVT_LEFT_DCLICK(self.tree, self.OnDoubleClick)
        self.tooltip_func = None

        #add init process
        self.callplugin('init', self)

        #        self.SetSizer(self.sizer)
        #        self.SetAutoLayout(True)
        self.sizer.auto_fit(0)

        self.popmenus = None
Ejemplo n.º 31
0
 def add_image(self, name, imagefile):
     if not self.imagefiles.has_key(name):
         self.imagefiles[name] = imagefile
     if not self.imageids.has_key(name):
         image = common.getpngimage(imagefile)
         self.imageids[name] = self.shareimagelist.Add(image)
Ejemplo n.º 32
0
 def add_image(self, name, imagefile):
     if not self.imagefiles.has_key(name):
         self.imagefiles[name] = imagefile
     if not self.imageids.has_key(name):
         image = common.getpngimage(imagefile)
         self.imageids[name] = self.shareimagelist.Add(image)
Ejemplo n.º 33
0
    def __init__(self, parent, mainframe):
        self.initmixin()

        self.parent = parent
        self.mainframe = mainframe
        self.pref = self.mainframe.pref
        self.app = self.mainframe.app
        self.mainframe.editctrl = self
        self.document = None
        self.lastfilename = None
        self.lastlanguagename = ''
        self.lastdocument = None

        if self.pref.notebook_direction == 0:
            style = 0
        else:
            style = FNB.FNB_BOTTOM
        FNB.FlatNotebook.__init__(
            self,
            parent,
            -1,
            style=style | FNB.FNB_SMART_TABS | FNB.FNB_VC8 | FNB.FNB_X_ON_TAB
            | FNB.FNB_NO_X_BUTTON | FNB.FNB_DROPDOWN_TABS_LIST
            | FNB.FNB_MOUSE_MIDDLE_CLOSES_TABS)
        self.id = self.GetId()

        #make popup menu
        #@add_menu menulist
        self.callplugin_once('add_menu', EditorFactory.popmenulist)
        #@add_menu_image_list imagelist
        self.callplugin_once('add_menu_image_list', EditorFactory.imagelist)
        #@add_panel_list panellist
        self.callplugin_once('add_panel_list', EditorFactory.panellist)

        self.popmenu = makemenu.makepopmenu(self, EditorFactory.popmenulist,
                                            EditorFactory.imagelist)
        #        self.SetRightClickMenu(self.popmenu)
        FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED(self, self.id, self.OnChanged)
        FNB.EVT_FLATNOTEBOOK_PAGE_CLOSING(self, self.id, self.OnClose)
        wx.EVT_LEFT_DCLICK(self._pages, self.OnDClick)
        FNB.EVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU(self, self.id, self.OnPopup)

        self.imageindex = {}
        pageimages = wx.ImageList(16, 16)
        for i, v in enumerate(self.pageimagelist.items()):
            name, imagefilename = v
            image = common.getpngimage(imagefilename)
            pageimages.Add(image)
            self.imageindex[name] = i
        self.pageimages = pageimages

        #        self.AssignImageList(self.pageimages)
        self.SetImageList(self.pageimages)
        self.skip_closing = False
        self.skip_page_change = False
        self.full = False
        self.last_side_panel_status = None

        #set FlatNotebook style
        x = common.get_config_file_obj()
        tab_color = x.default.get('editor_tab_color', '#98FB98')
        self.SetActiveTabColour(tab_color)
Ejemplo n.º 34
0
    def __init__(self, parent, editor, autoexpand=True):
        self.initmixin()

        wx.Panel.__init__(self, parent, -1)
        self.parent = parent
        self.editor = editor
        self.autoexpand = autoexpand

        self.activeflag = False

        self.sizer = ui.VBox(namebinding="widget").create(self).auto_layout()
        self.btnRefresh = FlatButtons.FlatBitmapButton(self, -1, common.getpngimage("images/classbrowserrefresh.gif"))
        self.sizer.add(self.btnRefresh).bind("click", self.OnRefresh)

        self.imagelist = wx.ImageList(16, 16)

        # add share image list
        self.imagefilenames = []
        self.imageids = {}
        self.callplugin("add_images", self.imagefilenames)
        for name, imagefile in self.imagefilenames:
            self.add_image(name, imagefile)

        style = wx.TR_SINGLE | wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS | wx.TR_TWIST_BUTTONS
        if wx.Platform == "__WXMSW__":
            style = style | wx.TR_ROW_LINES
        elif wx.Platform == "__WXGTK__":
            style = style | wx.TR_NO_LINES

        self.tree = wx.TreeCtrl(self, -1, style=style)
        self.tree.AssignImageList(self.imagelist)

        self.sizer.add(self.tree, proportion=1, flag=wx.EXPAND)
        self.root = self.tree.AddRoot("OutlineBrowser")

        self.nodes = {}
        self.ID = 1

        #        wx.EVT_TREE_SEL_CHANGING(self.tree, self.tree.GetId(), self.OnChanging)
        #        wx.EVT_TREE_SEL_CHANGED(self.tree, self.tree.GetId(), self.OnChanged)
        #        wx.EVT_TREE_BEGIN_LABEL_EDIT(self.tree, self.tree.GetId(), self.OnBeginChangeLabel)
        #        wx.EVT_TREE_END_LABEL_EDIT(self.tree, self.tree.GetId(), self.OnChangeLabel)
        wx.EVT_TREE_ITEM_ACTIVATED(self.tree, self.tree.GetId(), self.OnChanged)
        #        wx.EVT_TREE_ITEM_RIGHT_CLICK(self.tree, self.tree.GetId(), self.OnRClick)
        #        wx.EVT_RIGHT_UP(self.tree, self.OnRClick)
        wx.EVT_TREE_DELETE_ITEM(self.tree, self.tree.GetId(), self.OnDeleteItem)
        #        wx.EVT_LEFT_DCLICK(self.tree, self.OnDoubleClick)
        #        wx.EVT_TREE_ITEM_EXPANDING(self.tree, self.tree.GetId(), self.OnExpanding)
        wx.EVT_LEFT_DOWN(self.tree, self.OnLeftDown)
        wx.EVT_TREE_ITEM_GETTOOLTIP(self.tree, self.tree.GetId(), self.OnGetToolTip)
        wx.EVT_LEFT_DCLICK(self.tree, self.OnDoubleClick)
        self.tooltip_func = None

        # add init process
        self.callplugin("init", self)

        #        self.SetSizer(self.sizer)
        #        self.SetAutoLayout(True)
        self.sizer.auto_fit(0)

        self.popmenus = None
Ejemplo n.º 35
0
    def __init__(self, parent, mainframe):
        self.initmixin()
        wx.Panel.__init__(self, parent, -1)
        
        self.parent = parent
        self.mainframe = mainframe
        self.pref = mainframe.pref

        self.sizer = ui.VBox(padding=2, namebinding='widget').create(self).auto_layout()
        box = self.sizer.add(ui.HBox(padding=2))
        self.btnSave = FlatButtons.FlatBitmapButton(self, -1, 
            common.getpngimage('images/save.gif'))
        box.add(self.btnSave).bind('click', self.OnSaveSnippet).tooltip(tr('Save'))
        self.btnSaveAll = FlatButtons.FlatBitmapButton(self, -1, 
            common.getpngimage('images/saveall.gif'))
        box.add(self.btnSaveAll).bind('click', self.OnSaveAllSnippet).tooltip(tr('Save All'))
        self.code_snippet_imagelist = imagelist = wx.ImageList(16, 16)

        #add share image list
        self.imagefiles = {}
        self.imageids = {}
        self.callplugin('add_images', self.imagefiles)
        for name, imagefile in self.imagefiles.items():
            self.add_image(name, imagefile)
        
        style = wx.TR_EDIT_LABELS|wx.TR_SINGLE|wx.TR_HIDE_ROOT|wx.TR_HAS_BUTTONS|wx.TR_TWIST_BUTTONS
        if wx.Platform == '__WXMSW__':
            style = style | wx.TR_ROW_LINES
        elif wx.Platform == '__WXGTK__':
            style = style | wx.TR_NO_LINES
        self.tree = DragTreeCtrl(self, -1, style = style)
        self.tree.AssignImageList(self.code_snippet_imagelist)

        self.sizer.add(self.tree, proportion=1, flag=wx.EXPAND)
        self.root = self.tree.AddRoot('Code Snippet')

        self.nodes = {}
        self.ID = 1
        self.cache = None
        self.changing = False

#        wx.EVT_TREE_SEL_CHANGING(self.tree, self.tree.GetId(), self.OnChanging)
#        wx.EVT_TREE_SEL_CHANGED(self.tree, self.tree.GetId(), self.OnChanged)
#        wx.EVT_TREE_BEGIN_LABEL_EDIT(self.tree, self.tree.GetId(), self.OnBeginChangeLabel)
        wx.EVT_TREE_END_LABEL_EDIT(self.tree, self.tree.GetId(), self.OnChangeLabel)
        wx.EVT_TREE_ITEM_ACTIVATED(self.tree, self.tree.GetId(), self.OnSelected)
#        wx.EVT_TREE_ITEM_RIGHT_CLICK(self.tree, self.tree.GetId(), self.OnRClick)
        wx.EVT_LEFT_DOWN(self.tree, self.OnLeftDown)
        wx.EVT_RIGHT_UP(self.tree, self.OnRClick)
        wx.EVT_RIGHT_DOWN(self.tree, self.OnRightDown)
#        wx.EVT_TREE_DELETE_ITEM(self.tree, self.tree.GetId(), self.OnDeleteItem)
        wx.EVT_LEFT_DCLICK(self.tree, self.OnDoubleClick)
        wx.EVT_TREE_ITEM_EXPANDING(self.tree, self.tree.GetId(), self.OnExpanding)
        wx.EVT_KEY_DOWN(self.tree, self.OnKeyDown)
        wx.EVT_CHAR(self.tree, self.OnChar)
        wx.EVT_TREE_ITEM_GETTOOLTIP(self.tree, self.tree.GetId(), self.OnGetToolTip)
        
        pop_menus = copy.deepcopy(CodeSnippetWindow.popmenulist)
        self.popmenus = makemenu.makepopmenu(self, pop_menus)
        self.recentmenu_ids = [self.IDPM_snippet_recents]

        wx.EVT_UPDATE_UI(self, self.IDPM_CUT, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_COPY, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_PASTE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_PASTE_BEFORE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_SAVE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_SAVEAS, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_CLOSE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_DELETE_ENTRY, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_EDIT_CAPTION, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_PREFERENCES, self.OnUpdateUI)

        #add init process
        self.callplugin('init', self)

        self.sizer.auto_fit(0)

        self.popmenus = None
        
        #process last opened dirs
        for f in self.pref.snippet_files:
            self.addsnippet(f, expand=False)
Ejemplo n.º 36
0
    def __init__(self, parent, mainframe, dirs=None):
        self.initmixin()
        wx.Panel.__init__(self, parent, -1)
        self.parent = parent
        self.mainframe = mainframe
        self.pref = mainframe.pref

        self.sizer = wx.BoxSizer(wx.VERTICAL)

        imagelist = mainframe.dirbrowser_imagelist
        self.dirbrowserimagelist = wx.ImageList(16, 16)
        self.close_image = self.add_image(
            common.getpngimage(imagelist['close']))
        self.open_image = self.add_image(common.getpngimage(imagelist['open']))
        self.item_image = self.add_image(common.getpngimage(imagelist['item']))

        self.deal_file_images()

        style = wx.TR_EDIT_LABELS | wx.TR_SINGLE | wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS | wx.TR_TWIST_BUTTONS
        if wx.Platform == '__WXMSW__':
            style = style | wx.TR_ROW_LINES
        elif wx.Platform == '__WXGTK__':
            style = style | wx.TR_NO_LINES

        self.tree = wx.TreeCtrl(self, -1, style=style)
        self.tree.SetImageList(self.dirbrowserimagelist)

        self.sizer.Add(self.tree, 1, wx.EXPAND)
        self.root = self.tree.AddRoot('DirBrowser')

        #add drop target
        self.SetDropTarget(MyFileDropTarget(self))

        #        wx.EVT_TREE_SEL_CHANGED(self.tree, self.tree.GetId(), self.OnChanged)
        wx.EVT_TREE_BEGIN_LABEL_EDIT(self.tree, self.tree.GetId(),
                                     self.OnBeginChangeLabel)
        wx.EVT_TREE_END_LABEL_EDIT(self.tree, self.tree.GetId(),
                                   self.OnChangeLabel)
        wx.EVT_TREE_ITEM_ACTIVATED(self.tree, self.tree.GetId(),
                                   self.OnSelected)
        #        wx.EVT_TREE_ITEM_RIGHT_CLICK(self.tree, self.tree.GetId(), self.OnRClick)
        wx.EVT_RIGHT_UP(self.tree, self.OnRClick)
        wx.EVT_RIGHT_DOWN(self.tree, self.OnRightDown)
        wx.EVT_TREE_DELETE_ITEM(self.tree, self.tree.GetId(),
                                self.OnDeleteItem)
        wx.EVT_LEFT_DCLICK(self.tree, self.OnDoubleClick)
        wx.EVT_TREE_ITEM_EXPANDING(self.tree, self.tree.GetId(),
                                   self.OnExpanding)
        wx.EVT_KEY_DOWN(self.tree, self.OnKeyDown)
        wx.EVT_CHAR(self.tree, self.OnChar)

        self.SetSizer(self.sizer)
        self.SetAutoLayout(True)

        self.nodes = {}
        self.ID = 1
        self.cache = None

        #@add_project
        self.callplugin_once('add_project', DirBrowser.project_names)

        pop_menus = copy.deepcopy(DirBrowser.popmenulist)
        self.popmenus = makemenu.makepopmenu(self, pop_menus)

        self.dirmenu_ids = [self.IDPM_ADD_DIRS]

        wx.EVT_UPDATE_UI(self, self.IDPM_CUT, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_COPY, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_PASTE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_CLOSE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_ADDFILE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_ADDPATH, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_DELETE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_REFRESH, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_RENAME, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_IGNORETHIS, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_IGNORETHISTYPE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_OPENDEFAULT, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_SETPROJ, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_COMMANDLINE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_PRINTDIR, self.OnUpdateUI)

        self.popmenus = None

        if dirs:
            for i in dirs:
                self.addpath(i, False)

        self.callplugin('init', self)
Ejemplo n.º 37
0
    def __init__(self, parent, mainframe, dirs=None):
        self.initmixin()
        wx.Panel.__init__(self, parent, -1)
        self.parent = parent
        self.mainframe = mainframe
        self.pref = mainframe.pref

        self.sizer = wx.BoxSizer(wx.VERTICAL)

        imagelist = mainframe.dirbrowser_imagelist
        self.dirbrowserimagelist = wx.ImageList(16, 16)
        self.close_image = self.add_image(common.getpngimage(imagelist['close']))
        self.open_image = self.add_image(common.getpngimage(imagelist['open']))
        self.item_image = self.add_image(common.getpngimage(imagelist['item']))

        self.deal_file_images()

        style = wx.TR_EDIT_LABELS|wx.TR_SINGLE|wx.TR_HIDE_ROOT|wx.TR_HAS_BUTTONS|wx.TR_TWIST_BUTTONS
        if wx.Platform == '__WXMSW__':
            style = style | wx.TR_ROW_LINES
        elif wx.Platform == '__WXGTK__':
            style = style | wx.TR_NO_LINES

        self.tree = wx.TreeCtrl(self, -1, style = style)
        self.tree.SetImageList(self.dirbrowserimagelist)

        self.sizer.Add(self.tree, 1, wx.EXPAND)
        self.root = self.tree.AddRoot('DirBrowser')

        #add drop target
        self.SetDropTarget(MyFileDropTarget(self))


#        wx.EVT_TREE_SEL_CHANGED(self.tree, self.tree.GetId(), self.OnChanged)
        wx.EVT_TREE_BEGIN_LABEL_EDIT(self.tree, self.tree.GetId(), self.OnBeginChangeLabel)
        wx.EVT_TREE_END_LABEL_EDIT(self.tree, self.tree.GetId(), self.OnChangeLabel)
        wx.EVT_TREE_ITEM_ACTIVATED(self.tree, self.tree.GetId(), self.OnSelected)
#        wx.EVT_TREE_ITEM_RIGHT_CLICK(self.tree, self.tree.GetId(), self.OnRClick)
        wx.EVT_RIGHT_UP(self.tree, self.OnRClick)
        wx.EVT_RIGHT_DOWN(self.tree, self.OnRightDown)
        wx.EVT_TREE_DELETE_ITEM(self.tree, self.tree.GetId(), self.OnDeleteItem)
        wx.EVT_LEFT_DCLICK(self.tree, self.OnDoubleClick)
        wx.EVT_TREE_ITEM_EXPANDING(self.tree, self.tree.GetId(), self.OnExpanding)
        wx.EVT_KEY_DOWN(self.tree, self.OnKeyDown)
        wx.EVT_CHAR(self.tree, self.OnChar)

        self.SetSizer(self.sizer)
        self.SetAutoLayout(True)

        self.nodes = {}
        self.ID = 1
        self.cache = None

        #@add_project
        self.callplugin_once('add_project', DirBrowser.project_names)

        pop_menus = copy.deepcopy(DirBrowser.popmenulist)
        self.popmenus = makemenu.makepopmenu(self, pop_menus)

        self.dirmenu_ids = [self.IDPM_ADD_DIRS]

        wx.EVT_UPDATE_UI(self, self.IDPM_CUT, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_COPY, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_PASTE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_CLOSE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_ADDFILE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_ADDPATH, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_DELETE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_REFRESH, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_RENAME, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_IGNORETHIS, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_IGNORETHISTYPE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_OPENDEFAULT, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_SETPROJ, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_COMMANDLINE, self.OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_PRINTDIR, self.OnUpdateUI)

        self.popmenus = None

        if dirs:
            for i in dirs:
                self.addpath(i, False)

        self.callplugin('init', self)