Esempio n. 1
0
 def _createChoiceMenu(self):
     menuModel = self._createChoiceMenuModel()
     menuContext = ZMenuActionContext(self)
     contentProvider = ZModelBasedMenuContentProvider(
         menuModel, menuContext)
     eventHandler = ZModelBasedMenuEventHandler(menuModel, menuContext)
     self.menu = ZMenu(self, menuModel.getRootNode(), contentProvider,
                       eventHandler)
Esempio n. 2
0
    def __init__(self, tab):
        self.tab = tab

        menuContext = self._createMenuContext()
        menuNode = self._createMenuNode()
        contentProvider = ZActiveModelBasedMenuContentProvider(menuNode, menuContext)
        eventHandler = ZActiveModelBasedMenuEventHandler(menuContext)
        ZMenu.__init__(self, tab, menuNode, contentProvider, eventHandler)
Esempio n. 3
0
    def __init__(self, tab):
        self.tab = tab

        menuContext = self._createMenuContext()
        menuNode = self._createMenuNode()
        contentProvider = ZActiveModelBasedMenuContentProvider(
            menuNode, menuContext)
        eventHandler = ZActiveModelBasedMenuEventHandler(menuContext)
        ZMenu.__init__(self, tab, menuNode, contentProvider, eventHandler)
Esempio n. 4
0
 def runDropDownAction(self, toolBarActionContext, toolPosition, toolSize):
     menuModel = self._createMenuModel(toolBarActionContext)
     menuContext = self._createContext(toolBarActionContext)
     provider = ZModelBasedMenuContentProvider(menuModel, menuContext)
     handler = ZModelBasedMenuEventHandler(menuModel, menuContext)
     menu = ZMenu(toolBarActionContext.getParentWindow(),
                  menuModel.getRootNode(), provider, handler)
     menu.refresh()
     parentWindow = toolBarActionContext.getParentWindow()
     (x, y) = self._getPopupPosition(toolPosition, toolSize, parentWindow)
     toolBarActionContext.getParentWindow().PopupMenuXY(menu, x, y)
Esempio n. 5
0
 def _popupGlyphMenu(self, menuNode, glyph):
     context = ZMenuActionContext(self)
     provider = ZActiveModelBasedMenuContentProvider(menuNode, context)
     handler = ZActiveModelBasedMenuEventHandler(context)
     menu = ZMenu(self, menuNode, provider, handler)
     (x, y) = glyph.GetPositionTuple()  #@UnusedVariable
     (w, h) = glyph.GetSizeTuple()  #@UnusedVariable
     self.PopupMenuXY(menu, x, y + h - 1)
Esempio n. 6
0
 def _createItemContextMenu(self):
     menuContext = self._createMenuActionContext()
     menuModel = ZPluginMenuModel(
         u"zoundry.blogapp.ui.core.menu.dialogs.mediastoragemanager.mediastorage"
     )  #$NON-NLS-1$
     provider = ZModelBasedMenuContentProvider(menuModel, menuContext)
     eventHandler = ZModelBasedMenuEventHandler(menuModel, menuContext)
     return ZMenu(self, menuModel.getRootNode(), provider, eventHandler)
Esempio n. 7
0
 def onRightClick(self, event):
     menuContext = ZToolBarMenuContext(self)
     menuProvider = ZModelBasedMenuContentProvider(self.contextMenuModel,
                                                   menuContext)
     eventHandler = ZModelBasedMenuEventHandler(self.contextMenuModel,
                                                menuContext)
     menu = ZMenu(self, self.contextMenuModel.getRootNode(), menuProvider,
                  eventHandler)
     self.PopupMenu(menu)
     event.Skip()
Esempio n. 8
0
 def onEntryRightClick(self, event):
     index = event.GetIndex()
     docIDO = self.blogPostsListQueryModel.getDocumentIDO(index)
     actionContext = ZBlogPostActionContext(self, docIDO)
     provider = ZModelBasedMenuContentProvider(self.blogPostContextMenu,
                                               actionContext)
     handler = ZModelBasedMenuEventHandler(self.blogPostContextMenu,
                                           actionContext)
     menu = ZMenu(self, self.blogPostContextMenu.getRootNode(), provider,
                  handler)
     self.PopupMenu(menu)
     event.Skip()
Esempio n. 9
0
 def onEntryRightClick(self, event):
     index = event.GetIndex()
     docIDO = self.model.getEntry(index)
     blogId = None
     if self.blog is not None:
         blogId = self.blog.getId()
     actionContext = ZBlogPostActionContext(self, docIDO, blogId)
     provider = ZModelBasedMenuContentProvider(self.blogPostContextMenu,
                                               actionContext)
     handler = ZModelBasedMenuEventHandler(self.blogPostContextMenu,
                                           actionContext)
     menu = ZMenu(self, self.blogPostContextMenu.getRootNode(), provider,
                  handler)
     self.PopupMenu(menu)
     event.Skip()
Esempio n. 10
0
    def onContextMenu(self, event):
        linkCtx = self.getLinkContext()
        imageCtx = self.getImageContext()
        tableCtx = self.getTableContext()
        removeExtMarker = False
        if self.hasCapability(IZBlogPostEditControl.ZCAPABILITY_EXTENDED_ENTRY_MARKER) \
            and self._getContentEditControl().canRemoveExtendedEntryMarker():
            removeExtMarker = True

        menuModel = ZBlogContentEditorContextMenuModel()
        menuModel.initialize(linkCtx, imageCtx, tableCtx, removeExtMarker)

        menuContext = self.zblogPostEditor.getMenuActionContext()
        contentProvider = ZModelBasedMenuContentProvider(
            menuModel, menuContext)
        eventHandler = ZModelBasedMenuEventHandler(menuModel, menuContext)
        menu = ZMenu(event.getParentWindow(), menuModel.getRootNode(),
                     contentProvider, eventHandler)
        try:
            event.getParentWindow().PopupMenu(menu, event.getXYPoint())
        except Exception, e:
            getLoggerService().exception(e)
Esempio n. 11
0
 def CreatePopupMenu(self):
     menuContext = ZMenuActionContext(self.mainWindow)
     provider = ZModelBasedMenuContentProvider(self.menuModel, menuContext)
     handler = ZModelBasedMenuEventHandler(self.menuModel, menuContext)
     return ZMenu(self, self.menuModel.getRootNode(), provider, handler)
Esempio n. 12
0
 def _createChoiceMenu(self):
     menuModel = self._createChoiceMenuModel()
     menuContext = ZMenuActionContext(self)
     contentProvider = ZModelBasedMenuContentProvider(menuModel, menuContext)
     eventHandler = ZModelBasedMenuEventHandler(menuModel, menuContext)
     self.menu = ZMenu(self, menuModel.getRootNode(), contentProvider, eventHandler)
Esempio n. 13
0
 def _createBlogCtxMenu(self, blog):
     menuContext = ZBlogMenuActionContext(self, blog)
     menuModel = ZBlogMenuModel()
     provider = ZModelBasedMenuContentProvider(menuModel, menuContext)
     eventHandler = ZModelBasedMenuEventHandler(menuModel, menuContext)
     return ZMenu(self, menuModel.getRootNode(), provider, eventHandler)
Esempio n. 14
0
class ZAdvancedTextBox(wx.Panel):

    def __init__(self, parent, bitmap, choices, multiSelect = False):
        self.bitmap = bitmap
        self.choices = choices
        self.selectedChoices = []
        self.multiSelect = multiSelect
        self.backgroundColor = getDefaultControlBackgroundColor()
        self.borderColor = getDefaultControlBorderColor()

        wx.Panel.__init__(self, parent, wx.ID_ANY, style = wx.NO_BORDER)
        
        self.SetBackgroundColour(self.backgroundColor)

        self._createWidgets()
        self._layoutWidgets()
        self._bindWidgetEvents()
    # end __init__()

    def GetValue(self):
        return self.textBox.GetValue()
    # end GetValue()

    def SetValue(self, value):
        self.textBox.SetValue(value)
    # end SetValue()
    
    def SetToolTipString(self, tooltip):
        self.textBox.SetToolTipString(tooltip)
    # end SetToolTipString()

    def setCurrentChoice(self, choiceId):
        self.selectedChoices = [choiceId]
    # end setCurrentChoice()
    
    def setCurrentChoices(self, choiceIds):
        self.selectedChoices = choiceIds
    # end setCurrentChoices()
    
    def getCurrentChoice(self):
        if self.multiSelect:
            raise ZAppFrameworkException(u"Attempted to get a single choice from an advanced text box configured for multiple selection.") #$NON-NLS-1$
        if self.selectedChoices:
            return self.selectedChoices[0]
        return None
    # end getCurrentChoice()
    
    def getCurrentChoices(self):
        if not self.multiSelect:
            raise ZAppFrameworkException(u"Attempted to get multiple choices from an advanced text box configured for single selection.") #$NON-NLS-1$
        return self.selectedChoices
    # end getCurrentChoice()

    def _createWidgets(self):
        self.textBox = wx.TextCtrl(self, wx.ID_ANY, style = wx.NO_BORDER | wx.TE_PROCESS_ENTER)
        hasChoices = len(self.choices) > 1
        self.bitmapButton = ZImageButton(self, self.bitmap, hasChoices, None, hasChoices)
        self.staticBitmap = ZStaticBitmap(self, self.bitmap)
        self.clearButton = self._createClearButton()
        self._createChoiceMenu()
    # end _createWidgets()
    
    def _createChoiceMenu(self):
        menuModel = self._createChoiceMenuModel()
        menuContext = ZMenuActionContext(self)
        contentProvider = ZModelBasedMenuContentProvider(menuModel, menuContext)
        eventHandler = ZModelBasedMenuEventHandler(menuModel, menuContext)
        self.menu = ZMenu(self, menuModel.getRootNode(), contentProvider, eventHandler)
    # end _createChoiceMenu()
    
    def _createChoiceMenuModel(self):
        model = ZMenuModel()
        for (label, bitmap, id) in self.choices:
            action = ZTextBoxChoiceAction(id)
            menuId = model.addMenuItemWithAction(label, 0, action)
            model.setMenuItemCheckbox(menuId, True)
            model.setMenuItemBitmap(menuId, bitmap)
        return model
    # end _createChoiceMenuModel()
    
    def _createClearButton(self):
        registry = getResourceRegistry()
        clearBmp = registry.getBitmap(u"images/widgets/textbox/clear.png") #$NON-NLS-1$
        clearHoverBmp = registry.getBitmap(u"images/widgets/textbox/clear-hover.png") #$NON-NLS-1$
        return ZImageButton(self, clearBmp, False, clearHoverBmp, False)
    # end _createClearButton()
    
    def _layoutWidgets(self):
        (w, h) = getTextDimensions(u"Zoundry", self.textBox) #$NON-NLS-1$ @UnusedVariable
        self.textBox.SetSizeHints(-1, h + 2)

        box = wx.BoxSizer(wx.HORIZONTAL)
        box.Add(self.staticBitmap, 0, wx.ALIGN_CENTER | wx.RIGHT | wx.LEFT, 3)
        box.Add(self.bitmapButton, 0, wx.ALIGN_CENTER | wx.RIGHT | wx.LEFT, 3)
        box.Add( (3, -1) )
        box.Add(self.textBox, 1, wx.EXPAND | wx.TOP, 3)
        box.Add(self.clearButton, 0, wx.ALIGN_CENTER | wx.RIGHT | wx.LEFT, 3)
        
        self.clearButton.Show(False)
        if self.choices is None or len(self.choices) == 0:
            self.staticBitmap.Show(True)
            self.bitmapButton.Show(False)
        else:
            self.staticBitmap.Show(False)
            self.bitmapButton.Show(True)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.AddSizer(box, 1, wx.EXPAND | wx.ALL, 2)
        self.SetAutoLayout(True)
        self.SetSizer(sizer)
        self.Layout()
    # end _layoutWidgets()
    
    def _bindWidgetEvents(self):
        self.Bind(wx.EVT_PAINT, self.onPaint, self)
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.onEraseBackground, self)
        self.Bind(wx.EVT_BUTTON, self.onButtonClicked, self.bitmapButton)
        self.Bind(wx.EVT_TEXT, self.onText, self.textBox)
        self.Bind(wx.EVT_TEXT_ENTER, self.onPropagateEvent, self.textBox)
        self.Bind(wx.EVT_BUTTON, self.onClearButtonClicked, self.clearButton)
    # end _bindWidgetEvents()
    
    def onButtonClicked(self, event):
        if len(self.choices) > 1:
            (w, h) = self.GetSizeTuple() #@UnusedVariable
            pos = wx.Point(1, h - 2)
            self.menu.refresh()
            self.PopupMenu(self.menu, pos)
        event.Skip
    # end onButtonClicked()
    
    def onClearButtonClicked(self, event):
        self.SetValue(u"") #$NON-NLS-1$
        self.clearButton.Show(False)
        txtEvent = wx.CommandEvent(wxEVT_COMMAND_TEXT_ENTER, self.GetId())
        self.GetEventHandler().AddPendingEvent(txtEvent)
        event.Skip()
    # end onClearButtonClicked()

    def onText(self, event):
        if self.clearButton.IsShown() and not self.textBox.GetValue():
            self.clearButton.Show(False)
            self.Layout()
        elif not self.clearButton.IsShown() and self.textBox.GetValue():
            self.clearButton.Show(True)
            self.Layout()
        self.onPropagateEvent(event)
    # end onText()

    def onPropagateEvent(self, event):
        # Propagate the event
        event = event.Clone()
        event.SetId(self.GetId())
        self.GetEventHandler().AddPendingEvent(event) 
    # end onPropagateEvent()
    
    def onEraseBackground(self, event): #@UnusedVariable
        pass
    # end onEraseBackground()

    def onPaint(self, event):
        (width, height) = self.GetSizeTuple()
        paintDC = wx.BufferedPaintDC(self)
        paintDC.SetBackground(wx.Brush(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE), wx.SOLID))
        paintDC.Clear()

        # Draw the background white
        brush = wx.Brush(self.backgroundColor)
        paintDC.SetPen(wx.Pen(self.borderColor, 1, wx.SOLID))
        paintDC.SetBrush(brush)
        paintDC.DrawRectangle(0, 0, width, height)
        
        del paintDC
        event.Skip()
    # end onPaint
    
    def onChoice(self, choiceId):
        # Update the internal selection state.
        if self.multiSelect:
            if not choiceId in self.selectedChoices:
                self.selectedChoices.append(choiceId)
        else:
            self.selectedChoices = [choiceId]

        event = ZAdvTextBoxOptionEvent(self.GetId(), choiceId)
        self.GetEventHandler().AddPendingEvent(event)
    # end onChoice()

    def onUnChoice(self, choiceId):
        if choiceId in self.selectedChoices:
            self.selectedChoices.remove(choiceId)
Esempio n. 15
0
 def _createAccountCtxMenu(self, account):
     menuContext = ZAccountMenuActionContext(self, account)
     menuModel = ZBlogAccountMenuModel()
     provider = ZModelBasedMenuContentProvider(menuModel, menuContext)
     eventHandler = ZModelBasedMenuEventHandler(menuModel, menuContext)
     return ZMenu(self, menuModel.getRootNode(), provider, eventHandler)
Esempio n. 16
0
class ZAdvancedTextBox(wx.Panel):
    def __init__(self, parent, bitmap, choices, multiSelect=False):
        self.bitmap = bitmap
        self.choices = choices
        self.selectedChoices = []
        self.multiSelect = multiSelect
        self.backgroundColor = getDefaultControlBackgroundColor()
        self.borderColor = getDefaultControlBorderColor()

        wx.Panel.__init__(self, parent, wx.ID_ANY, style=wx.NO_BORDER)

        self.SetBackgroundColour(self.backgroundColor)

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

    # end __init__()

    def GetValue(self):
        return self.textBox.GetValue()

    # end GetValue()

    def SetValue(self, value):
        self.textBox.SetValue(value)

    # end SetValue()

    def SetToolTipString(self, tooltip):
        self.textBox.SetToolTipString(tooltip)

    # end SetToolTipString()

    def setCurrentChoice(self, choiceId):
        self.selectedChoices = [choiceId]

    # end setCurrentChoice()

    def setCurrentChoices(self, choiceIds):
        self.selectedChoices = choiceIds

    # end setCurrentChoices()

    def getCurrentChoice(self):
        if self.multiSelect:
            raise ZAppFrameworkException(
                u"Attempted to get a single choice from an advanced text box configured for multiple selection."
            )  #$NON-NLS-1$
        if self.selectedChoices:
            return self.selectedChoices[0]
        return None

    # end getCurrentChoice()

    def getCurrentChoices(self):
        if not self.multiSelect:
            raise ZAppFrameworkException(
                u"Attempted to get multiple choices from an advanced text box configured for single selection."
            )  #$NON-NLS-1$
        return self.selectedChoices

    # end getCurrentChoice()

    def _createWidgets(self):
        self.textBox = wx.TextCtrl(self,
                                   wx.ID_ANY,
                                   style=wx.NO_BORDER | wx.TE_PROCESS_ENTER)
        hasChoices = len(self.choices) > 1
        self.bitmapButton = ZImageButton(self, self.bitmap, hasChoices, None,
                                         hasChoices)
        self.staticBitmap = ZStaticBitmap(self, self.bitmap)
        self.clearButton = self._createClearButton()
        self._createChoiceMenu()

    # end _createWidgets()

    def _createChoiceMenu(self):
        menuModel = self._createChoiceMenuModel()
        menuContext = ZMenuActionContext(self)
        contentProvider = ZModelBasedMenuContentProvider(
            menuModel, menuContext)
        eventHandler = ZModelBasedMenuEventHandler(menuModel, menuContext)
        self.menu = ZMenu(self, menuModel.getRootNode(), contentProvider,
                          eventHandler)

    # end _createChoiceMenu()

    def _createChoiceMenuModel(self):
        model = ZMenuModel()
        for (label, bitmap, id) in self.choices:
            action = ZTextBoxChoiceAction(id)
            menuId = model.addMenuItemWithAction(label, 0, action)
            model.setMenuItemCheckbox(menuId, True)
            model.setMenuItemBitmap(menuId, bitmap)
        return model

    # end _createChoiceMenuModel()

    def _createClearButton(self):
        registry = getResourceRegistry()
        clearBmp = registry.getBitmap(
            u"images/widgets/textbox/clear.png")  #$NON-NLS-1$
        clearHoverBmp = registry.getBitmap(
            u"images/widgets/textbox/clear-hover.png")  #$NON-NLS-1$
        return ZImageButton(self, clearBmp, False, clearHoverBmp, False)

    # end _createClearButton()

    def _layoutWidgets(self):
        (w, h) = getTextDimensions(u"Zoundry",
                                   self.textBox)  #$NON-NLS-1$ @UnusedVariable
        self.textBox.SetSizeHints(-1, h + 2)

        box = wx.BoxSizer(wx.HORIZONTAL)
        box.Add(self.staticBitmap, 0, wx.ALIGN_CENTER | wx.RIGHT | wx.LEFT, 3)
        box.Add(self.bitmapButton, 0, wx.ALIGN_CENTER | wx.RIGHT | wx.LEFT, 3)
        box.Add((3, -1))
        box.Add(self.textBox, 1, wx.EXPAND | wx.TOP, 3)
        box.Add(self.clearButton, 0, wx.ALIGN_CENTER | wx.RIGHT | wx.LEFT, 3)

        self.clearButton.Show(False)
        if self.choices is None or len(self.choices) == 0:
            self.staticBitmap.Show(True)
            self.bitmapButton.Show(False)
        else:
            self.staticBitmap.Show(False)
            self.bitmapButton.Show(True)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.AddSizer(box, 1, wx.EXPAND | wx.ALL, 2)
        self.SetAutoLayout(True)
        self.SetSizer(sizer)
        self.Layout()

    # end _layoutWidgets()

    def _bindWidgetEvents(self):
        self.Bind(wx.EVT_PAINT, self.onPaint, self)
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.onEraseBackground, self)
        self.Bind(wx.EVT_BUTTON, self.onButtonClicked, self.bitmapButton)
        self.Bind(wx.EVT_TEXT, self.onText, self.textBox)
        self.Bind(wx.EVT_TEXT_ENTER, self.onPropagateEvent, self.textBox)
        self.Bind(wx.EVT_BUTTON, self.onClearButtonClicked, self.clearButton)

    # end _bindWidgetEvents()

    def onButtonClicked(self, event):
        if len(self.choices) > 1:
            (w, h) = self.GetSizeTuple()  #@UnusedVariable
            pos = wx.Point(1, h - 2)
            self.menu.refresh()
            self.PopupMenu(self.menu, pos)
        event.Skip

    # end onButtonClicked()

    def onClearButtonClicked(self, event):
        self.SetValue(u"")  #$NON-NLS-1$
        self.clearButton.Show(False)
        txtEvent = wx.CommandEvent(wxEVT_COMMAND_TEXT_ENTER, self.GetId())
        self.GetEventHandler().AddPendingEvent(txtEvent)
        event.Skip()

    # end onClearButtonClicked()

    def onText(self, event):
        if self.clearButton.IsShown() and not self.textBox.GetValue():
            self.clearButton.Show(False)
            self.Layout()
        elif not self.clearButton.IsShown() and self.textBox.GetValue():
            self.clearButton.Show(True)
            self.Layout()
        self.onPropagateEvent(event)

    # end onText()

    def onPropagateEvent(self, event):
        # Propagate the event
        event = event.Clone()
        event.SetId(self.GetId())
        self.GetEventHandler().AddPendingEvent(event)

    # end onPropagateEvent()

    def onEraseBackground(self, event):  #@UnusedVariable
        pass

    # end onEraseBackground()

    def onPaint(self, event):
        (width, height) = self.GetSizeTuple()
        paintDC = wx.BufferedPaintDC(self)
        paintDC.SetBackground(
            wx.Brush(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE),
                     wx.SOLID))
        paintDC.Clear()

        # Draw the background white
        brush = wx.Brush(self.backgroundColor)
        paintDC.SetPen(wx.Pen(self.borderColor, 1, wx.SOLID))
        paintDC.SetBrush(brush)
        paintDC.DrawRectangle(0, 0, width, height)

        del paintDC
        event.Skip()

    # end onPaint

    def onChoice(self, choiceId):
        # Update the internal selection state.
        if self.multiSelect:
            if not choiceId in self.selectedChoices:
                self.selectedChoices.append(choiceId)
        else:
            self.selectedChoices = [choiceId]

        event = ZAdvTextBoxOptionEvent(self.GetId(), choiceId)
        self.GetEventHandler().AddPendingEvent(event)

    # end onChoice()

    def onUnChoice(self, choiceId):
        if choiceId in self.selectedChoices:
            self.selectedChoices.remove(choiceId)
Esempio n. 17
0
 def __init__(self, model, context, parent):
     provider = ZModelBasedMenuContentProvider(model, context)
     eventHandler = ZModelBasedMenuEventHandler(model, context)
     ZMenu.__init__(self, parent, model.getRootNode(), provider, eventHandler)