diff options
-rw-r--r-- | lvc/widgets/osx/control.py | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/lvc/widgets/osx/control.py b/lvc/widgets/osx/control.py index 63419d5..10de2a8 100644 --- a/lvc/widgets/osx/control.py +++ b/lvc/widgets/osx/control.py @@ -38,6 +38,7 @@ import wrappermap from .base import Widget from .helpers import NotificationForwarder + class SizedControl(Widget): def set_size(self, size): if size == widgetconst.SIZE_NORMAL: @@ -54,8 +55,10 @@ class SizedControl(Widget): self.font_size = NSFont.systemFontSize() * size self.view.setFont_(font) + class BaseTextEntry(SizedControl): - """See https://develop.participatoryculture.org/index.php/WidgetAPI for a description of the API for this class.""" + """See https://develop.participatoryculture.org/index.php/WidgetAPI + for a description of the API for this class.""" def __init__(self, initial_text=None): SizedControl.__init__(self) self.view = self.make_view() @@ -90,9 +93,10 @@ class BaseTextEntry(SizedControl): def viewport_created(self): SizedControl.viewport_created(self) - self.notifications.connect(self.on_changed, 'NSControlTextDidChangeNotification') + self.notifications.connect(self.on_changed, + 'NSControlTextDidChangeNotification') self.notifications.connect(self.on_end_editing, - 'NSControlTextDidEndEditingNotification') + 'NSControlTextDidEndEditingNotification') def remove_viewport(self): SizedControl.remove_viewport(self) @@ -133,15 +137,18 @@ class BaseTextEntry(SizedControl): SizedControl.disable(self) self.view.setEnabled_(False) + class MiroTextField(NSTextField): def textDidEndEditing_(self, notification): wrappermap.wrapper(self).emit('activate') return NSTextField.textDidEndEditing_(self, notification) + class TextEntry(BaseTextEntry): def make_view(self): return MiroTextField.alloc().init() + class NumberEntry(BaseTextEntry): def make_view(self): return MiroTextField.alloc().init() @@ -167,21 +174,24 @@ class NumberEntry(BaseTextEntry): self._filter_value() return BaseTextEntry.get_text(self) + class MiroSecureTextField(NSSecureTextField): def textDidEndEditing_(self, notification): wrappermap.wrapper(self).emit('activate') return NSSecureTextField.textDidEndEditing_(self, notification) + class SecureTextEntry(BaseTextEntry): def make_view(self): return MiroSecureTextField.alloc().init() + class MultilineTextEntry(Widget): def __init__(self, initial_text=None): Widget.__init__(self) if initial_text is None: initial_text = "" - self.view = NSTextView.alloc().initWithFrame_(NSRect((0,0),(50,50))) + self.view = NSTextView.alloc().initWithFrame_(NSRect((0, 0), (50, 50))) self.view.setMaxSize_((1.0e7, 1.0e7)) self.view.setHorizontallyResizable_(NO) self.view.setVerticallyResizable_(YES) @@ -203,9 +213,10 @@ class MultilineTextEntry(Widget): def viewport_created(self): Widget.viewport_created(self) - self.notifications.connect(self.on_changed, 'NSTextDidChangeNotification') + self.notifications.connect(self.on_changed, + 'NSTextDidChangeNotification') self.notifications.connect(self.on_end_editing, - 'NSControlTextDidEndEditingNotification') + 'NSControlTextDidEndEditingNotification') self.invalidate_size_request() def remove_viewport(self): @@ -258,8 +269,10 @@ class MiroButton(NSButton): wrappermap.wrapper(self).emit(self.signal) return YES + class Checkbox(SizedControl): - """See https://develop.participatoryculture.org/index.php/WidgetAPI for a description of the API for this class.""" + """See https://develop.participatoryculture.org/index.php/WidgetAPI + for a description of the API for this class.""" def __init__(self, text="", bold=False, color=None): SizedControl.__init__(self) self.create_signal('toggled') @@ -284,7 +297,7 @@ class Checkbox(SizedControl): NSFontAttributeName: NSFont.systemFontOfSize_(self.font_size) } string = NSAttributedString.alloc().initWithString_attributes_( - self.title, attributes) + self.title, attributes) self.view.setAttributedTitle_(string) def calc_size_request(self): @@ -327,8 +340,10 @@ class Checkbox(SizedControl): # XXX FIXME return 18 + class Button(SizedControl): - """See https://develop.participatoryculture.org/index.php/WidgetAPI for a description of the API for this class.""" + """See https://develop.participatoryculture.org/index.php/WidgetAPI + for a description of the API for this class.""" def __init__(self, label, style='normal', width=0): SizedControl.__init__(self) self.color = None @@ -357,7 +372,7 @@ class Button(SizedControl): NSFontAttributeName: self.view.font() } string = NSAttributedString.alloc().initWithString_attributes_( - self.title, attributes) + self.title, attributes) self.view.setAttributedTitle_(string) def setup_style(self, style): @@ -393,6 +408,7 @@ class Button(SizedControl): SizedControl.disable(self) self.view.setEnabled_(False) + class MiroPopupButton(NSPopUpButton): def init(self): @@ -404,6 +420,7 @@ class MiroPopupButton(NSPopUpButton): def handleChange_(self, sender): wrappermap.wrapper(self).emit('changed', self.indexOfSelectedItem()) + class OptionMenu(SizedControl): def __init__(self, options): SizedControl.__init__(self) @@ -440,6 +457,7 @@ class OptionMenu(SizedControl): # TODO pass + class RadioButtonGroup: def __init__(self): self._buttons = [] @@ -470,6 +488,7 @@ class RadioButtonGroup: else: mem.view.setState_(NSOffState) + class RadioButton(SizedControl): def __init__(self, label, group=None, bold=False, color=None): SizedControl.__init__(self) @@ -502,7 +521,7 @@ class RadioButton(SizedControl): NSFontAttributeName: NSFont.systemFontOfSize_(self.font_size) } string = NSAttributedString.alloc().initWithString_attributes_( - self.title, attributes) + self.title, attributes) self.view.setAttributedTitle_(string) def calc_size_request(self): |