Beispiel #1
0
    def __init__(self, items, colspec):
        eventize(self)
        self.items = items
        self.colspec = colspec
        self.controller = ctrl = ak.NSArrayController.alloc().init()
        self.view = view = ak.NSTableView.alloc().init()
        self.scroll = scroll = ak.NSScrollView.alloc().init()
        scroll.setHasHorizontalScroller_(True)
        scroll.setHasVerticalScroller_(True)
        scroll.setAutohidesScrollers_(True)
        scroll.setAutoresizingMask_(ak.NSViewWidthSizable | ak.NSViewHeightSizable)
        scroll.setDocumentView_(view)

        ctrl.bind_toObject_withKeyPath_options_("contentArray", self.items, "items", None)
        view.bind_toObject_withKeyPath_options_("content", ctrl, "arrangedObjects", None)
        for spec in self.colspec:
            name = spec["name"]
            attr = spec["attr"] if "attr" in spec else name
            title = spec.get("title", name.title()) or ""
            keypath = "arrangedObjects" if attr is None else ("arrangedObjects." + attr)
            column = ak.NSTableColumn.alloc().initWithIdentifier_(name)
            column.bind_toObject_withKeyPath_options_(ak.NSValueBinding, ctrl, keypath, None)
            column.setResizingMask_(1) # NSTableColumnAutoresizingMask
            column.headerCell().setStringValue_(title)
            column.setEditable_(spec.get("editable", False))
            view.addTableColumn_(column)
        if all(c.get("title", 1) is None for c in self.colspec):
            view.setHeaderView_(None)

        self.delegate = TableDelegate.alloc().init_content_(view, ctrl)
        view.setDelegate_(self.delegate)
Beispiel #2
0
    def __init__(self):
        from editxt.platform.views import ListView

        eventize(self)
        self._items = KVOList()
        self.view = ListView(self._items, [{"name": "value", "title": None}])
        self.select_range = None
Beispiel #3
0
 def __new__(cls, editor, frame, container):
     self = cls.alloc().initWithFrame_textContainer_(frame, container)
     eventize(self)
     self.editor = editor
     self.app = editor.app
     self.delegate = TextViewDelegate.alloc().init()
     self.on.selection_changed(editor.on_selection_changed)
     self.setDelegate_(self.delegate)
     return self
Beispiel #4
0
    def __init__(self, items, colspec):
        eventize(self)
        self.items = items
        self.view = None
        self.frame = None
        self.scroll = None
        self.title = None
        self.selected_row = -1

        class delegate:
            on_selection_changed = None

            def setup_double_click(callback):
                pass

        self.delegate = delegate
Beispiel #5
0
 def __init__(self, setup_child=True):
     eventize(self)
     if setup_child:
         self.child = Obj(setup_child=False)
Beispiel #6
0
 def initWithFrame_(self, rect):
     super().initWithFrame_(rect)
     eventize(self)
     self.setTarget_(self)
     self.setAction_("onClick:")
     return self
Beispiel #7
0
 def __new__(cls, editor, text_data, rect=None):
     self = cls.alloc().init_frame_(editor.app, rect)
     self.editor = editor
     self.textview.text_data = text_data
     eventize(self)
     return self
Beispiel #8
0
 def __new__(cls, editor, text, rect=None):
     self = cls.alloc().init_(rect)
     self.editor = editor
     self.text = text
     eventize(self)
     return self
Beispiel #9
0
 def __init__(self, command, text, rect=None):
     self.command = command
     self.text = text
     self.rect = rect
     eventize(self)