Example #1
0
    def _createWidgets(self):
        self.panel = wx.Panel(self.parent, wx.ID_ANY, style=wx.SIMPLE_BORDER)
        self.panel.SetBackgroundColour(u"#FFFFE6")  #$NON-NLS-1$
        self.filterLabel = wx.StaticText(
            self.panel, wx.ID_ANY,
            _extstr(u"blogselector.BlogName"))  #$NON-NLS-1$
        self.filterTextBox = wx.TextCtrl(self.panel,
                                         wx.ID_ANY,
                                         style=wx.TE_PROCESS_ENTER)
        self.filterTextBox.SetSizeHints(
            -1,
            getTextDimensions(u"Zoundry", self.filterTextBox)[1])  #$NON-NLS-1$
        self.filterAcctLabel = wx.StaticText(
            self.panel, wx.ID_ANY,
            _extstr(u"blogselector.Account"))  #$NON-NLS-1$
        self.filterAccountCombo = wx.ComboBox(self.panel,
                                              wx.ID_ANY,
                                              style=wx.CB_READONLY)
        self.separator = wx.StaticLine(self.panel, wx.HORIZONTAL)

        self.contentProvider = ZBlogListContentProvider(self.model)
        self.blogListView = ZPopupListView(self.contentProvider,
                                           self.panel,
                                           style=wx.LC_VIRTUAL | wx.LC_REPORT
                                           | wx.LC_SINGLE_SEL | wx.NO_BORDER
                                           | wx.LC_NO_HEADER)
        self.blogListView.SetBackgroundColour(u"#FFFFE6")  #$NON-NLS-1$
Example #2
0
 def _createWidgets(self):
     # FIXME (EPW) add a filter/nav bar to the popup to narrow down the search
     self.provider = ZTabSelectionListContentProvider(self.tabs)
     self.tabList = ZPopupListView(self.provider,
                                   self,
                                   style=wx.LC_VIRTUAL | wx.LC_REPORT
                                   | wx.LC_SINGLE_SEL | wx.LC_NO_HEADER
                                   | wx.NO_BORDER)
     self.tabList.SetBackgroundColour(u"#FFFFE6")  #$NON-NLS-1$
Example #3
0
    def _createWidgets(self):
        self.panel = wx.Panel(self.parent, wx.ID_ANY, style = wx.SIMPLE_BORDER)
        self.panel.SetBackgroundColour(u"#FFFFE6") #$NON-NLS-1$
        self.filterLabel = wx.StaticText(self.panel, wx.ID_ANY, _extstr(u"blogselector.BlogName")) #$NON-NLS-1$
        self.filterTextBox = wx.TextCtrl(self.panel, wx.ID_ANY, style = wx.TE_PROCESS_ENTER)
        self.filterTextBox.SetSizeHints(-1, getTextDimensions(u"Zoundry", self.filterTextBox)[1]) #$NON-NLS-1$
        self.filterAcctLabel = wx.StaticText(self.panel, wx.ID_ANY, _extstr(u"blogselector.Account")) #$NON-NLS-1$
        self.filterAccountCombo = wx.ComboBox(self.panel, wx.ID_ANY, style = wx.CB_READONLY)
        self.separator = wx.StaticLine(self.panel, wx.HORIZONTAL)

        self.contentProvider = ZBlogListContentProvider(self.model)
        self.blogListView = ZPopupListView(self.contentProvider, self.panel, style = wx.LC_VIRTUAL | wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.NO_BORDER | wx.LC_NO_HEADER)
        self.blogListView.SetBackgroundColour(u"#FFFFE6") #$NON-NLS-1$
Example #4
0
class ZBlogSelectorPopup(wx.combo.ComboPopup):
    def __init__(self, model, combo):
        self.model = model
        self.combo = combo

        wx.combo.ComboPopup.__init__(self)

    # end __init__()

    def Init(self):
        self.blog = None

    # end Init()

    def Create(self, parent):
        self.parent = parent
        self._createWidgets()
        self._populateWidgets()
        self._layoutWidgets()
        self._bindWidgetEvents()

    # end Create()

    def GetControl(self):
        return self.panel

    # end GetControl()

    def GetStringValue(self):
        if self.blog:
            return self.blog.getName()
        return u""  #$NON-NLS-1$

    # end GetStringValue()

    def OnPopup(self):
        self.blogListView._resizeColumns()
        self.filterTextBox.SetFocus()

    # end OnPopup()

    def SetStringValue(self, value):  #@UnusedVariable
        pass

    # end SetStringValue()

    def setBlog(self, blog):
        self.blog = blog

    # end setBlog()

    def _createWidgets(self):
        self.panel = wx.Panel(self.parent, wx.ID_ANY, style=wx.SIMPLE_BORDER)
        self.panel.SetBackgroundColour(u"#FFFFE6")  #$NON-NLS-1$
        self.filterLabel = wx.StaticText(
            self.panel, wx.ID_ANY,
            _extstr(u"blogselector.BlogName"))  #$NON-NLS-1$
        self.filterTextBox = wx.TextCtrl(self.panel,
                                         wx.ID_ANY,
                                         style=wx.TE_PROCESS_ENTER)
        self.filterTextBox.SetSizeHints(
            -1,
            getTextDimensions(u"Zoundry", self.filterTextBox)[1])  #$NON-NLS-1$
        self.filterAcctLabel = wx.StaticText(
            self.panel, wx.ID_ANY,
            _extstr(u"blogselector.Account"))  #$NON-NLS-1$
        self.filterAccountCombo = wx.ComboBox(self.panel,
                                              wx.ID_ANY,
                                              style=wx.CB_READONLY)
        self.separator = wx.StaticLine(self.panel, wx.HORIZONTAL)

        self.contentProvider = ZBlogListContentProvider(self.model)
        self.blogListView = ZPopupListView(self.contentProvider,
                                           self.panel,
                                           style=wx.LC_VIRTUAL | wx.LC_REPORT
                                           | wx.LC_SINGLE_SEL | wx.NO_BORDER
                                           | wx.LC_NO_HEADER)
        self.blogListView.SetBackgroundColour(u"#FFFFE6")  #$NON-NLS-1$

    # end _createWidgets()

    def _populateWidgets(self):
        self.filterAccountCombo.Append(_extstr(u"blogselector._AllAccounts_"),
                                       None)  #$NON-NLS-1$
        for account in self.model.getAllAccounts():
            self.filterAccountCombo.Append(account.getName(), account)

    # end _populateWidgets()

    def _layoutWidgets(self):
        self.sizer = wx.BoxSizer(wx.VERTICAL)

        filterBarSizer = wx.BoxSizer(wx.HORIZONTAL)
        filterBarSizer.Add(self.filterLabel, 0,
                           wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 5)
        filterBarSizer.Add(self.filterTextBox, 1, wx.EXPAND | wx.RIGHT, 5)
        filterBarSizer.Add(self.filterAcctLabel, 0,
                           wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 5)
        filterBarSizer.Add(self.filterAccountCombo, 0, wx.EXPAND | wx.RIGHT, 5)

        self.sizer.AddSizer(filterBarSizer, 0, wx.EXPAND | wx.ALL, 3)
        self.sizer.Add(self.separator, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 2)
        self.sizer.Add(self.blogListView, 1, wx.EXPAND | wx.ALL, 2)

        self.blogListView.SetSizeHints(-1, self._getNumBlogListItems() * 17)

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

    # end _layoutWidgets()

    def _bindWidgetEvents(self):
        self.panel.Bind(ZEVT_POPUP_LIST_SELECTION, self.onBlogSelection,
                        self.blogListView)
        self.panel.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onBlogSelection,
                        self.blogListView)
        self.panel.Bind(wx.EVT_TEXT, self.onBlogNameFilter, self.filterTextBox)
        self.panel.Bind(wx.EVT_COMBOBOX, self.onAccountFilter,
                        self.filterAccountCombo)

    # end _bindWidgetEvents()

    def _getNumBlogListItems(self):
        return self.contentProvider.getNumRows()

    # end _getNumBlogListItems()

    def onBlogNameFilter(self, event):
        self.contentProvider.setBlogNameFilter(self.filterTextBox.GetValue())
        self.blogListView.refresh()
        event.Skip()

    # end onBlogNameFilter()

    def onAccountFilter(self, event):
        selId = self.filterAccountCombo.GetCurrentSelection()
        account = self.filterAccountCombo.GetClientData(selId)
        self.contentProvider.setAccountFilter(account)
        self.blogListView.refresh()
        event.Skip()

    # end onAccountFilter()

    def onBlogSelection(self, event):  #@UnusedVariable
        selectionIdx = self.blogListView.getSelection()[0]
        self.blog = self.contentProvider.getBlogAtIdx(selectionIdx)
        self.Dismiss()
        event = ZBlogSelectorComboEvent(self.combo.GetId(), self.blog)
        self.combo.GetEventHandler().AddPendingEvent(event)
        event.Skip()

    # end onBlogSelection()

    def getPreferredHeight(self):
        return self.panel.GetBestSizeTuple()[1]
Example #5
0
class ZBlogSelectorPopup(wx.combo.ComboPopup):

    def __init__(self, model, combo):
        self.model = model
        self.combo = combo

        wx.combo.ComboPopup.__init__(self)
    # end __init__()

    def Init(self):
        self.blog = None
    # end Init()

    def Create(self, parent):
        self.parent = parent
        self._createWidgets()
        self._populateWidgets()
        self._layoutWidgets()
        self._bindWidgetEvents()
    # end Create()

    def GetControl(self):
        return self.panel
    # end GetControl()

    def GetStringValue(self):
        if self.blog:
            return self.blog.getName()
        return u"" #$NON-NLS-1$
    # end GetStringValue()

    def OnPopup(self):
        self.blogListView._resizeColumns()
        self.filterTextBox.SetFocus()
    # end OnPopup()

    def SetStringValue(self, value): #@UnusedVariable
        pass
    # end SetStringValue()

    def setBlog(self, blog):
        self.blog = blog
    # end setBlog()

    def _createWidgets(self):
        self.panel = wx.Panel(self.parent, wx.ID_ANY, style = wx.SIMPLE_BORDER)
        self.panel.SetBackgroundColour(u"#FFFFE6") #$NON-NLS-1$
        self.filterLabel = wx.StaticText(self.panel, wx.ID_ANY, _extstr(u"blogselector.BlogName")) #$NON-NLS-1$
        self.filterTextBox = wx.TextCtrl(self.panel, wx.ID_ANY, style = wx.TE_PROCESS_ENTER)
        self.filterTextBox.SetSizeHints(-1, getTextDimensions(u"Zoundry", self.filterTextBox)[1]) #$NON-NLS-1$
        self.filterAcctLabel = wx.StaticText(self.panel, wx.ID_ANY, _extstr(u"blogselector.Account")) #$NON-NLS-1$
        self.filterAccountCombo = wx.ComboBox(self.panel, wx.ID_ANY, style = wx.CB_READONLY)
        self.separator = wx.StaticLine(self.panel, wx.HORIZONTAL)

        self.contentProvider = ZBlogListContentProvider(self.model)
        self.blogListView = ZPopupListView(self.contentProvider, self.panel, style = wx.LC_VIRTUAL | wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.NO_BORDER | wx.LC_NO_HEADER)
        self.blogListView.SetBackgroundColour(u"#FFFFE6") #$NON-NLS-1$
    # end _createWidgets()

    def _populateWidgets(self):
        self.filterAccountCombo.Append(_extstr(u"blogselector._AllAccounts_"), None) #$NON-NLS-1$
        for account in self.model.getAllAccounts():
            self.filterAccountCombo.Append(account.getName(), account)
    # end _populateWidgets()

    def _layoutWidgets(self):
        self.sizer = wx.BoxSizer(wx.VERTICAL)

        filterBarSizer = wx.BoxSizer(wx.HORIZONTAL)
        filterBarSizer.Add(self.filterLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 5)
        filterBarSizer.Add(self.filterTextBox, 1, wx.EXPAND | wx.RIGHT, 5)
        filterBarSizer.Add(self.filterAcctLabel, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 5)
        filterBarSizer.Add(self.filterAccountCombo, 0, wx.EXPAND | wx.RIGHT, 5)

        self.sizer.AddSizer(filterBarSizer, 0, wx.EXPAND | wx.ALL, 3)
        self.sizer.Add(self.separator, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 2)
        self.sizer.Add(self.blogListView, 1, wx.EXPAND | wx.ALL, 2)

        self.blogListView.SetSizeHints(-1, self._getNumBlogListItems() * 17)

        self.panel.SetSizer(self.sizer)
        self.panel.SetAutoLayout(True)
        self.panel.Layout()
    # end _layoutWidgets()

    def _bindWidgetEvents(self):
        self.panel.Bind(ZEVT_POPUP_LIST_SELECTION, self.onBlogSelection, self.blogListView)
        self.panel.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onBlogSelection, self.blogListView)
        self.panel.Bind(wx.EVT_TEXT, self.onBlogNameFilter, self.filterTextBox)
        self.panel.Bind(wx.EVT_COMBOBOX, self.onAccountFilter, self.filterAccountCombo)
    # end _bindWidgetEvents()

    def _getNumBlogListItems(self):
        return self.contentProvider.getNumRows()
    # end _getNumBlogListItems()

    def onBlogNameFilter(self, event):
        self.contentProvider.setBlogNameFilter(self.filterTextBox.GetValue())
        self.blogListView.refresh()
        event.Skip()
    # end onBlogNameFilter()

    def onAccountFilter(self, event):
        selId = self.filterAccountCombo.GetCurrentSelection()
        account = self.filterAccountCombo.GetClientData(selId)
        self.contentProvider.setAccountFilter(account)
        self.blogListView.refresh()
        event.Skip()
    # end onAccountFilter()

    def onBlogSelection(self, event): #@UnusedVariable
        selectionIdx = self.blogListView.getSelection()[0]
        self.blog = self.contentProvider.getBlogAtIdx(selectionIdx)
        self.Dismiss()
        event = ZBlogSelectorComboEvent(self.combo.GetId(), self.blog)
        self.combo.GetEventHandler().AddPendingEvent(event)
        event.Skip()
    # end onBlogSelection()

    def getPreferredHeight(self):
        return self.panel.GetBestSizeTuple()[1]
Example #6
0
class ZTabSelectionPopupWindow(wx.PopupTransientWindow):
    def __init__(self, parent, tabs):
        self.parent = parent
        self.tabs = tabs

        wx.PopupTransientWindow.__init__(self, parent, style=wx.SIMPLE_BORDER)

        self.SetBackgroundColour(u"#FFFFE6")  #$NON-NLS-1$

        self._createWidgets()
        self._layoutWidgets()
        self._bindWidgetEvents()

        self.SetSize(self.GetBestSize())
        self.Layout()

    # end __init__()

    def _createWidgets(self):
        # FIXME (EPW) add a filter/nav bar to the popup to narrow down the search
        self.provider = ZTabSelectionListContentProvider(self.tabs)
        self.tabList = ZPopupListView(self.provider,
                                      self,
                                      style=wx.LC_VIRTUAL | wx.LC_REPORT
                                      | wx.LC_SINGLE_SEL | wx.LC_NO_HEADER
                                      | wx.NO_BORDER)
        self.tabList.SetBackgroundColour(u"#FFFFE6")  #$NON-NLS-1$

    # end _createWidgets()

    def _layoutWidgets(self):
        self.tabList.SetSizeHints(self._getPreferredWidth(),
                                  self._getPreferredHeight())

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.tabList, 1, wx.EXPAND | wx.ALL, 5)

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

    # end _layoutWidgets()

    def _bindWidgetEvents(self):
        self.Bind(ZEVT_POPUP_LIST_SELECTION, self.onTabSelected, self.tabList)

    # end _bindWidgetEvents()

    def onTabSelected(self, event):
        idx = event.getListId()
        tab = self.tabs[idx]
        self.parent._fireSelectedEvent(tab)
        self.Dismiss()
        event.Skip()

    # end onTabSelected()

    def _getPreferredWidth(self):
        largestW = 50
        largestBmpW = 0
        for tab in self.tabs:
            title = tab.getTabInfo().getTitle()
            (w, h) = getTextDimensions(title, self.tabList)  #@UnusedVariable
            largestW = max(w + 10, largestW)
            bitmap = tab.getTabInfo().getBitmap()
            if bitmap is not None:
                largestBmpW = max(largestBmpW, bitmap.GetWidth())
        return largestW + largestBmpW

    # end _getPreferredWidth()

    def _getPreferredHeight(self):
        # FIXME (EPW) this logic is not guaranteed to work well for all operating systems
        totalH = 0
        imageH = 0
        imageList = self.provider.getImageList()
        if imageList is not None:
            (ilW, imageH) = imageList.GetSize(0)  #@UnusedVariable
        for tab in self.tabs:
            (tabW, tabH) = getTextDimensions(tab.getTabInfo().getTitle(),
                                             self.tabList)  #@UnusedVariable
            tabH = max(tabH, imageH)
            totalH += tabH + 2
        return totalH