def __init__(self, parent, overlay, display, displayCtx, listBox, showVis=True, showGroup=True, showSave=True, propagateSelect=True): """Create a ``ListItemWidget``. :arg parent: The :mod:`wx` parent object. :arg overlay: The overlay associated with this ``ListItemWidget``. :arg display: The :class:`.Display` associated with the overlay. :arg displayCtx: The :class:`.DisplayContext` instance. :arg listBox: The :class:`.EditableListBox` that contains this ``ListItemWidget``. :arg showVis: If ``True`` (the default), a button will be shown allowing the user to toggle the overlay visibility. :arg showGroup: If ``True`` (the default), a button will be shown allowing the user to toggle overlay grouping. :arg showSave: If ``True`` (the default), a button will be shown allowing the user to save the overlay (if it is not saved). :arg propagateSelect: If ``True`` (the default), when an overlay is selected in the list, the :attr:`.DisplayContext.selectedOverlay` is updated accordingly. """ wx.Panel.__init__(self, parent) self.__overlay = overlay self.__display = display self.__displayCtx = displayCtx self.__listBox = listBox self.__propagateSelect = propagateSelect self.__name = '{}_{}'.format(self.__class__.__name__, id(self)) self.__sizer = wx.BoxSizer(wx.HORIZONTAL) self.SetSizer(self.__sizer) self.Bind(wx.EVT_WINDOW_DESTROY, self.__onDestroy) btnStyle = wx.BU_EXACTFIT | wx.BU_NOTEXT if showSave: self.__saveButton = wx.Button(self, style=btnStyle) self.__saveButton.SetBitmapLabel(icons.loadBitmap('floppydisk16')) self.__saveButton.SetToolTip( wx.ToolTip(fsltooltips.actions[self, 'save'])) self.__sizer.Add(self.__saveButton, flag=wx.EXPAND, proportion=1) if isinstance(overlay, fslimage.Image): overlay.register(self.__name, self.__saveStateChanged, 'saveState') self.__saveButton.Bind(wx.EVT_BUTTON, self.__onSaveButton) else: self.__saveButton.Enable(False) self.__saveStateChanged() if showGroup: self.__lockButton = bmptoggle.BitmapToggleButton( self, style=btnStyle) self.__lockButton.SetBitmap( icons.loadBitmap('chainlinkHighlight16'), icons.loadBitmap('chainlink16')) self.__lockButton.SetToolTip( wx.ToolTip(fsltooltips.actions[self, 'group'])) self.__sizer.Add(self.__lockButton, flag=wx.EXPAND, proportion=1) # There is currently only one overlay # group in the application. In the # future there may be multiple groups. group = displayCtx.overlayGroups[0] group .addListener('overlays', self.__name, self.__overlayGroupChanged) self.__lockButton.Bind(wx.EVT_TOGGLEBUTTON, self.__onLockButton) self.__overlayGroupChanged() # Set up the show/hide button if needed if showVis: self.__visibility = bmptoggle.BitmapToggleButton( self, trueBmp=icons.loadBitmap('eyeHighlight16'), falseBmp=icons.loadBitmap('eye16'), style=btnStyle) self.__visibility.SetToolTip( wx.ToolTip(fsltooltips.properties[display, 'enabled'])) self.__sizer.Add(self.__visibility, flag=wx.EXPAND, proportion=1) display.addListener('enabled', self.__name, self.__displayVisChanged) self.__visibility.Bind(bmptoggle.EVT_BITMAP_TOGGLE, self.__onVisButton) self.__displayVisChanged()
def __init__(self, parent, overlayList, displayCtx, frame, height=32, orient=wx.HORIZONTAL, *args, **kwargs): """Create a ``FSLeyesToolBar``. :arg parent: The :mod:`wx` parent object. :arg overlayList: The :class:`.OverlayList`, containing all overlays being displayed. :arg displayCtx: A :class:`.DisplayContext`, which defines how the overlays are to be displayed. :arg frame: The :class:`.FSLeyesFrame` object. :arg height: Desired toolbar height in pixels. This value is used to look up appropriately sized left/right arrow icons. :arg actionz: A dictionary of actions passed through to the :meth:`.ActionProvider.__init__`. All other arguments are passed through to :meth:`.FSLeyesPanel.__init__`. """ if orient not in (wx.HORIZONTAL, wx.VERTICAL): raise ValueError('Invalid orientation: {}'.format(orient)) fslpanel.FSLeyesPanel.__init__(self, parent, overlayList, displayCtx, frame, *args, **kwargs) self.__tools = [] self.__index = 0 self.__numVisible = None self.__height = height self.__orient = orient font = self.GetFont() self.SetFont(font.Smaller()) style = wx.BU_EXACTFIT | wx.BU_NOTEXT if orient == wx.HORIZONTAL: lBmp = icons.loadBitmap('thinLeftArrow{}'.format(height)) rBmp = icons.loadBitmap('thinRightArrow{}'.format(height)) else: lBmp = icons.loadBitmap('thinUpArrow{}'.format(height)) rBmp = icons.loadBitmap('thinDownArrow{}'.format(height)) self.__leftButton = wx.Button(self, style=style) self.__rightButton = wx.Button(self, style=style) self.__leftButton.SetBitmapLabel(lBmp) self.__rightButton.SetBitmapLabel(rBmp) self.__sizer = wx.BoxSizer(orient) self.SetSizer(self.__sizer) self.__leftButton.Bind(wx.EVT_BUTTON, self.__onLeftButton) self.__rightButton.Bind(wx.EVT_BUTTON, self.__onRightButton) self.Bind(wx.EVT_MOUSEWHEEL, self.__onMouseWheel) self.Bind(wx.EVT_SIZE, self.__drawToolBar)