| 55 | #------------------------------------------------------------------------------- |
| 56 | |
| 57 | class NavigationBar(wx.Panel): |
| 58 | def __init__(self, parent, *args, **kwargs): |
| 59 | wx.Panel.__init__(self, parent, *args, **kwargs) |
| 60 | |
| 61 | self.bitmapDir = os.path.join(os.path.dirname( |
| 62 | os.path.abspath(__file__)), "images") |
| 63 | |
| 64 | self._InitComponents() |
| 65 | self._LayoutComponents() |
| 66 | self._InitEventHandlers() |
| 67 | |
| 68 | def _InitComponents(self): |
| 69 | self.backBtn = buttons.GenBitmapButton(self, -1, |
| 70 | wx.Bitmap(os.path.join(self.bitmapDir, "back.png"), |
| 71 | wx.BITMAP_TYPE_PNG), style=wx.BORDER_NONE) |
| 72 | self.forwardBtn = buttons.GenBitmapButton(self, -1, |
| 73 | wx.Bitmap(os.path.join(self.bitmapDir, "forward.png"), |
| 74 | wx.BITMAP_TYPE_PNG), style=wx.BORDER_NONE) |
| 75 | self.reloadBtn = buttons.GenBitmapButton(self, -1, |
| 76 | wx.Bitmap(os.path.join(self.bitmapDir, "reload_page.png"), |
| 77 | wx.BITMAP_TYPE_PNG), style=wx.BORDER_NONE) |
| 78 | |
| 79 | self.url = wx.TextCtrl(self, id=-1, style=0) |
| 80 | |
| 81 | self.historyPopup = wx.Menu() |
| 82 | |
| 83 | def _LayoutComponents(self): |
| 84 | sizer = wx.BoxSizer(wx.HORIZONTAL) |
| 85 | sizer.Add(self.backBtn, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL| |
| 86 | wx.ALL, 0) |
| 87 | sizer.Add(self.forwardBtn, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL| |
| 88 | wx.ALL, 0) |
| 89 | sizer.Add(self.reloadBtn, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL| |
| 90 | wx.ALL, 0) |
| 91 | |
| 92 | sizer.Add(self.url, 1, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 12) |
| 93 | |
| 94 | self.SetSizer(sizer) |
| 95 | self.Fit() |
| 96 | |
| 97 | def _InitEventHandlers(self): |
| 98 | self.backBtn.Bind(wx.EVT_CONTEXT_MENU, self.OnButtonContext) |
| 99 | |
| 100 | def __del__(self): |
| 101 | self.historyPopup.Destroy() |
| 102 | |
| 103 | def GetBackButton(self): |
| 104 | return self.backBtn |
| 105 | |
| 106 | def GetForwardButton(self): |
| 107 | return self.forwardBtn |
| 108 | |
| 109 | def GetReloadButton(self): |
| 110 | return self.reloadBtn |
| 111 | |
| 112 | def GetUrlCtrl(self): |
| 113 | return self.url |
| 114 | |