Enable customization of layout of pdfviewer button panel

This commit is contained in:
Jorge Moraleda
2021-11-21 18:11:14 -08:00
parent 2bbf0cc423
commit 672ec886b8

View File

@@ -49,6 +49,30 @@ class pdfButtonPanel(bp.ButtonPanel):
agwStyle=bp.BP_USE_GRADIENT, alignment=bp.BP_ALIGN_LEFT)
self.SetProperties()
self.CreateButtons()
def GetPanelItems(self):
"""
Return the buttons that should be displayed. A subclass can customize this
"""
return [
('btn', images.PrintIt.GetBitmap(), wx.ITEM_NORMAL, "Print", self.OnPrint),
('sep',),
('btn', images.SaveIt.GetBitmap(), wx.ITEM_NORMAL, "Save", self.OnSave),
('sep',),
('btn', images.First.GetBitmap(), wx.ITEM_NORMAL, "First page", self.OnFirst),
('btn', images.Prev.GetBitmap(), wx.ITEM_NORMAL, "Previous page", self.OnPrev),
('btn', images.Next.GetBitmap(), wx.ITEM_NORMAL, "Next page", self.OnNext),
('btn', images.Last.GetBitmap(), wx.ITEM_NORMAL, "Last page", self.OnLast),
('Ctrl', self.pagelabel),
('ctrl', self.page),
('ctrl', self.maxlabel),
('sep',),
('btn', images.ZoomOut.GetBitmap(), wx.ITEM_NORMAL, "Zoom out", self.OnZoomOut),
('btn', images.ZoomIn.GetBitmap(), wx.ITEM_NORMAL, "Zoom in", self.OnZoomIn),
('ctrl', self.zoom),
('btn', images.Width.GetBitmap(), wx.ITEM_NORMAL, "Fit page width", self.OnWidth),
('btn', images.Height.GetBitmap(), wx.ITEM_NORMAL, "Fit page height", self.OnHeight),
]
def CreateButtons(self):
"""
@@ -73,25 +97,7 @@ class pdfButtonPanel(bp.ButtonPanel):
self.zoom.Append(item[0], item[1]) # string value and client data
self.Bind(wx.EVT_COMBOBOX, self.OnZoomSet, self.zoom)
self.Bind(wx.EVT_TEXT_ENTER, self.OnZoomSet, self.zoom)
panelitems = [
('btn', images.PrintIt.GetBitmap(), wx.ITEM_NORMAL, "Print", self.OnPrint),
('sep',),
('btn', images.SaveIt.GetBitmap(), wx.ITEM_NORMAL, "Save", self.OnSave),
('sep',),
('btn', images.First.GetBitmap(), wx.ITEM_NORMAL, "First page", self.OnFirst),
('btn', images.Prev.GetBitmap(), wx.ITEM_NORMAL, "Previous page", self.OnPrev),
('btn', images.Next.GetBitmap(), wx.ITEM_NORMAL, "Next page", self.OnNext),
('btn', images.Last.GetBitmap(), wx.ITEM_NORMAL, "Last page", self.OnLast),
('Ctrl', self.pagelabel),
('ctrl', self.page),
('ctrl', self.maxlabel),
('sep',),
('btn', images.ZoomOut.GetBitmap(), wx.ITEM_NORMAL, "Zoom out", self.OnZoomOut),
('btn', images.ZoomIn.GetBitmap(), wx.ITEM_NORMAL, "Zoom in", self.OnZoomIn),
('ctrl', self.zoom),
('btn', images.Width.GetBitmap(), wx.ITEM_NORMAL, "Fit page width", self.OnWidth),
('btn', images.Height.GetBitmap(), wx.ITEM_NORMAL, "Fit page height", self.OnHeight),
]
panelitems = self.GetPanelItems()
self.Freeze()
for item in panelitems: