def __init__(self):
        self.w = vanilla.FloatingWindow((250, 300),
                                        "Ramsay St. Settings",
                                        minSize=(250, 250),
                                        maxSize=(400, 700))

        self.w.showPreview = vanilla.CheckBox(
            (10, 10, -10, 22),
            "Show Preview",
            value=RamsayStData.showPreview,
            callback=self.showPreviewCallback)

        self.w.fillColorText = vanilla.TextBox((10, 40, 110, 22),
                                               "Fill Color:")
        self.w.fillColor = vanilla.ColorWell((10, 60, 110, 40),
                                             color=RamsayStData.fillColor,
                                             callback=self.fillColorCallback)

        self.w.strokeColorText = vanilla.TextBox((130, 40, -10, 22),
                                                 "Stroke Color:")
        self.w.strokeColor = vanilla.ColorWell(
            (130, 60, -10, 40),
            color=RamsayStData.strokeColor,
            callback=self.strokeColorCallback)

        items = RamsayStData.getItems()
        columnDescriptions = [
            dict(title="Glyph Name", key="glyphName"),
            dict(title="Left", key="left"),
            dict(title="Right", key="right"),
        ]

        self.w.dataList = vanilla.List((10, 110, -10, -40),
                                       items,
                                       columnDescriptions=columnDescriptions,
                                       editCallback=self.dataListEditCallback)

        segmentDescriptions = [dict(title="+"), dict(title="-")]
        self.w.addDel = vanilla.SegmentedButton((12, -30, 60, 20),
                                                segmentDescriptions,
                                                selectionStyle="momentary",
                                                callback=self.addDelCallback)
        self.w.addDel.getNSSegmentedButton().setSegmentStyle_(
            NSSegmentStyleSmallSquare)

        self.w.okButton = vanilla.Button((-70, -30, -15, 20),
                                         "Apply",
                                         callback=self.okCallback,
                                         sizeStyle="small")

        self.w.setDefaultButton(self.w.okButton)

        self.w.closeButton = vanilla.Button((-140, -30, -80, 20),
                                            "Cancel",
                                            callback=self.closeCallback,
                                            sizeStyle="small")
        self.w.closeButton.bind(".", ["command"])
        self.w.closeButton.bind(unichr(27), [])

        self.w.open()
Exemplo n.º 2
0
    def __init__(self,
                 posSize,
                 font=None,
                 initialMode="cell",
                 listColumnDescriptions=None,
                 listShowColumnTitles=False,
                 showPlacard=True,
                 showModePlacard=True,
                 placardActionItems=None,
                 cellRepresentationName="defconAppKit.GlyphCell",
                 glyphDetailWindowClass=GlyphInformationPopUpWindow,
                 selectionCallback=None,
                 doubleClickCallback=None,
                 deleteCallback=None,
                 editCallback=None,
                 enableDelete=False,
                 selfDropSettings=None,
                 selfWindowDropSettings=None,
                 selfDocumentDropSettings=None,
                 selfApplicationDropSettings=None,
                 otherApplicationDropSettings=None,
                 allowDrag=False,
                 dragAndDropType="DefconAppKitSelectedGlyphIndexesPboardType"):

        self._holdCallbacks = True
        super(GlyphCollectionView, self).__init__(posSize)

        if showModePlacard or placardActionItems is not None:
            showPlacard = True
        bottom = 0
        if showPlacard:
            bottom = -19
        self._selectionCallback = selectionCallback
        self._doubleClickCallback = doubleClickCallback
        self._deleteCallback = deleteCallback
        self._dragAndDropType = dragAndDropType
        self._enableDelete = enableDelete
        # set up the list
        self._listEditChangingAttribute = None
        self._listEditChangingGlyph = None
        enableDelete = deleteCallback is not None

        # prep for drag and drop
        if selfDropSettings is not None:
            selfDropSettings = dict(selfDropSettings)
        if selfWindowDropSettings is not None:
            selfWindowDropSettings = dict(selfWindowDropSettings)
        if selfDocumentDropSettings is not None:
            selfDocumentDropSettings = dict(selfDocumentDropSettings)
        if selfApplicationDropSettings is not None:
            selfApplicationDropSettings = dict(selfApplicationDropSettings)
        if otherApplicationDropSettings is not None:
            otherApplicationDropSettings = dict(otherApplicationDropSettings)
        dropSettings = [
            (selfDropSettings, self._selfDropCallback),
            (selfWindowDropSettings, self._selfWindowDropCallback),
            (selfDocumentDropSettings, self._selfDocumentDropCallback),
            (selfApplicationDropSettings, self._selfApplicationDropCallback),
            (otherApplicationDropSettings, self._otherApplicationDropCallback)
        ]
        for d, internalCallback in dropSettings:
            if d is None:
                continue
            d["type"] = dragAndDropType
            d["finalCallback"] = d["callback"]
            d["callback"] = internalCallback
        dragSettings = None
        if allowDrag:
            dragSettings = dict(type=dragAndDropType,
                                callback=self._packListRowsForDrag)
        if listColumnDescriptions is None:
            listColumnDescriptions = [dict(title="Name", attribute="name")]

        self._glyphCellView = self.glyphCellViewClass.alloc(
        ).initWithFont_cellRepresentationName_detailWindowClass_(
            font, cellRepresentationName, glyphDetailWindowClass)
        self._glyphCellView.vanillaWrapper = weakref.ref(self)
        self._glyphCellView.setAllowsDrag_(allowDrag)

        dropTypes = []
        for d in (selfDropSettings, selfWindowDropSettings,
                  selfDocumentDropSettings, selfApplicationDropSettings,
                  otherApplicationDropSettings):
            if d is not None:
                dropTypes.append(d["type"])
        self._glyphCellView.registerForDraggedTypes_(dropTypes)

        self._list = self.glyphListViewVanillaClass(
            (0, 0, 0, bottom),
            None,
            dataSource=self._arrayController,
            columnDescriptions=listColumnDescriptions,
            editCallback=editCallback,
            selectionCallback=self._listSelectionCallback,
            doubleClickCallback=doubleClickCallback,
            showColumnTitles=listShowColumnTitles,
            enableTypingSensitivity=True,
            enableDelete=enableDelete,
            autohidesScrollers=True,
            selfDropSettings=selfDropSettings,
            selfWindowDropSettings=selfWindowDropSettings,
            selfDocumentDropSettings=selfDocumentDropSettings,
            selfApplicationDropSettings=selfApplicationDropSettings,
            otherApplicationDropSettings=otherApplicationDropSettings,
            dragSettings=dragSettings)

        # set up the placard
        if showPlacard:
            self._placard = vanilla.Group((0, -21, 0, 21))
            self._placard.base = GradientButtonBar((0, 0, 0, 0))
            extensionLeft = 0
            extensionWidth = 0
            # mode
            if showModePlacard:
                extensionLeft += 42
                modeButton = vanilla.SegmentedButton(
                    (0, 0, 43, 0), [
                        dict(imageNamed="defconAppKitPlacardCellImage",
                             width=20),
                        dict(imageNamed="defconAppKitPlacardListImage",
                             width=20)
                    ],
                    callback=self._placardSelection)
                modeButton.frameAdjustments = dict(regular=(0, 0, 0, 0))
                modeButton.getNSSegmentedButton().setSegmentStyle_(
                    NSSegmentStyleSmallSquare)
                modeButton.set(0)
                self._placard.button = modeButton
            # action button
            if placardActionItems is not None:
                extensionWidth -= 35
                actionButton = vanilla.ActionButton((-35, 0, 45, 21),
                                                    placardActionItems,
                                                    sizeStyle="small",
                                                    bordered=False)
                actionButton.frameAdjustments = dict(regular=(0, 0, 0, 0))
                button = actionButton.getNSPopUpButton()
                button.setBezelStyle_(NSSmallSquareBezelStyle)
                self._placard.actionButton = actionButton
            # extension
            self._placard.extension = vanilla.Group(
                (extensionLeft, 0, extensionWidth, 0))
        else:
            self._placard = None
        # tweak the scroll view
        self._list.getNSScrollView().setBackgroundColor_(
            DefconAppKitGlyphCellNSView.gridColor)
        # set the mode
        self._mode = None
        self.setMode(initialMode)
        self._holdCallbacks = False
Exemplo n.º 3
0
    def __init__(self, parentWindow, callback=None, debug=False):

        self._callback = callback
        self._shouldCallCallback = False

        if debug:
            self.w = vanilla.Window((400, 420))
        else:
            self.w = vanilla.Sheet((400, 420), parentWindow=parentWindow)

        y = 10
        self.w.checkForUpdate = vanilla.CheckBox(
            (10, y, -10, 22), "Check for Updates on Startup.")
        y += 30

        self.w.h1 = vanilla.HorizontalLine((0, y, 0, 1))
        y += 10

        columnDescriptions = [
            dict(title="extensions json url stream", key="url")
        ]
        self.w.urls = vanilla.List(
            (10, y, -10, 120),
            [],
            columnDescriptions=columnDescriptions,
            selfDropSettings=dict(type=genericListPboardType,
                                  operation=AppKit.NSDragOperationMove,
                                  callback=self.genericDropSelfCallback),
            dragSettings=dict(type=genericListPboardType,
                              callback=self.genericDragCallback),
        )
        y += 130
        segmentDescriptions = [dict(title="+"), dict(title="-")]
        self.w.addURL = vanilla.SegmentedButton(
            (12, y, 100, 20),
            segmentDescriptions,
            selectionStyle="momentary",
            callback=self.addDelURLCallback)
        self.w.addURL.getNSSegmentedButton().setSegmentStyle_(
            AppKit.NSSegmentStyleSmallSquare)
        y += 30

        self.w.h2 = vanilla.HorizontalLine((0, y, 0, 1))
        y += 10

        columnDescriptions = [
            dict(title="single extension items", key="extensionName")
        ]
        self.w.singleExtenions = vanilla.List(
            (10, y, -10, 120),
            [],
            columnDescriptions=columnDescriptions,
            selfDropSettings=dict(type=genericListPboardType,
                                  operation=AppKit.NSDragOperationMove,
                                  callback=self.genericDropSelfCallback),
            dragSettings=dict(type=genericListPboardType,
                              callback=self.genericDragCallback),
        )
        y += 130
        segmentDescriptions = [dict(title="+"), dict(title="-")]
        self.w.addSingleExtenions = vanilla.SegmentedButton(
            (12, y, 100, 20),
            segmentDescriptions,
            selectionStyle="momentary",
            callback=self.addDelSingleExtensionCallback)
        self.w.addSingleExtenions.getNSSegmentedButton().setSegmentStyle_(
            AppKit.NSSegmentStyleSmallSquare)
        y += 30

        self.w.resetButton = vanilla.Button((10, -30, 60, 20),
                                            "Reset",
                                            callback=self.resetCallback,
                                            sizeStyle="small")

        self.w.cancelButton = vanilla.Button((-170, -30, -80, 20),
                                             "Cancel",
                                             callback=self.closeCallback,
                                             sizeStyle="small")
        self.w.cancelButton.bind(".", ["command"])
        self.w.cancelButton.bind(chr(27), [])

        self.w.okButton = vanilla.Button((-70, -30, -10, 20),
                                         "OK",
                                         callback=self.okCallback,
                                         sizeStyle="small")
        self.w.setDefaultButton(self.w.okButton)

        self.getFromDefaults()
        self.w.open()
Exemplo n.º 4
0
    def __init__(self):
        self.w = vanilla.Window((0, 0))

        columnDescriptions = [
            dict(columnPlacement="trailing"),
            dict(width=300, columnPlacement="fill")
        ]

        self.editText = vanilla.EditText("auto",
                                         "Type to test callback.",
                                         callback=self.editTextCallback)
        rows = [
            (vanilla.TextBox("auto",
                             "TextBox:"), vanilla.TextBox("auto", "Hello")),
            (vanilla.TextBox("auto", "EditText:"), self.editText),
            (vanilla.TextBox("auto",
                             "Button:"), vanilla.Button("auto", "Button")),
            (vanilla.TextBox("auto", "PopUpButton:"),
             vanilla.PopUpButton("auto", ["PopUpButton"])),
            (vanilla.TextBox("auto", "ComboBox:"),
             vanilla.ComboBox("auto", ["ComboBox"])),
            (vanilla.TextBox("auto", "CheckBox:"),
             vanilla.CheckBox("auto", "CheckBox 1")),
            dict(rowPadding=(0, 0),
                 cells=(None, vanilla.CheckBox("auto", "CheckBox 2"))),
            dict(rowPadding=(0, 0),
                 cells=(None, vanilla.CheckBox("auto", "CheckBox 3"))),
            (vanilla.TextBox("auto", "SegmentedButton:"),
             vanilla.SegmentedButton(
                 "auto",
                 [dict(title="One"),
                  dict(title="Two"),
                  dict(title="Three")],
                 sizeStyle="regular")),
            (vanilla.TextBox("auto", "Slider:"),
             vanilla.Slider("auto", minValue=0, maxValue=100, value=50)),
            dict(height=100,
                 cells=(vanilla.TextBox("auto", "RadioGroup:"),
                        dict(rowAlignment="none",
                             view=vanilla.RadioGroup(
                                 "auto", ["One", "Two", "Three"])))),
            dict(height=100,
                 cells=(vanilla.TextBox("auto", "ColorWell:"),
                        dict(width=50,
                             height=75,
                             view=vanilla.ColorWell(
                                 "auto", color=AppKit.NSColor.redColor())))),
            dict(height=100,
                 cells=(vanilla.TextBox("auto", "List:"),
                        dict(columnPlacement="fill",
                             rowPlacement="fill",
                             view=vanilla.List("auto",
                                               ["One", "Two", "Three"])))),
            dict(height=100,
                 cells=(vanilla.TextBox("auto", "TextEditor:"),
                        vanilla.TextEditor("auto", "TextEditor"))),
            dict(height=100,
                 cells=(vanilla.TextBox("auto", "Box:"),
                        vanilla.Box("auto",
                                    fillColor=AppKit.NSColor.blueColor(),
                                    cornerRadius=20))),
        ]
        self.w.gridView = vanilla.GridView(
            "auto",
            rows,
            columnDescriptions=columnDescriptions,
            columnWidth=150,
            columnSpacing=10,
            rowHeight=25,
            rowPadding=(15, 0))
        self.columnCount = len(columnDescriptions)
        self.rowCount = len(rows)

        # append, insert, etc. buttons

        self.appendColumnButton = vanilla.Button(
            "auto", "Append", callback=self.appendColumnButtonCallback)
        self.insertColumnButton = vanilla.Button(
            "auto", "Insert", callback=self.insertColumnButtonCallback)
        self.removeColumnButton = vanilla.Button(
            "auto", "Remove", callback=self.removeColumnButtonCallback)
        self.moveColumnButton = vanilla.Button(
            "auto", "Move", callback=self.moveColumnButtonCallback)
        self.showColumnButton = vanilla.Button(
            "auto", "Show/Hide", callback=self.showColumnButtonCallback)

        self.appendRowButton = vanilla.Button(
            "auto", "Append", callback=self.appendRowButtonCallback)
        self.insertRowButton = vanilla.Button(
            "auto", "Insert", callback=self.insertRowButtonCallback)
        self.removeRowButton = vanilla.Button(
            "auto", "Remove", callback=self.removeRowButtonCallback)
        self.moveRowButton = vanilla.Button(
            "auto", "Move", callback=self.moveRowButtonCallback)
        self.showRowButton = vanilla.Button(
            "auto", "Show/Hide", callback=self.showRowButtonCallback)

        rows = [[
            vanilla.TextBox("auto", "Column:"), self.appendColumnButton,
            self.insertColumnButton, self.removeColumnButton,
            self.moveColumnButton, self.showColumnButton
        ],
                [
                    vanilla.TextBox("auto", "Row:"), self.appendRowButton,
                    self.insertRowButton, self.removeRowButton,
                    self.moveRowButton, self.showRowButton
                ]]
        columnDescriptions = [dict(width=60, columnPlacement="trailing")]
        for i in range(len(rows[0]) - 1):
            columnDescriptions.append({})

        self.w.line = vanilla.HorizontalLine("auto")
        self.w.testButtonGrid = vanilla.GridView(
            "auto",
            rows,
            columnDescriptions=columnDescriptions,
            columnWidth=100,
            columnSpacing=5,
            columnPlacement="fill",
            rowHeight=25)

        rules = [
            "H:|-margin-[gridView]-margin-|", "H:|[line]|",
            "H:|-margin-[testButtonGrid]-margin-|", "V:|"
            "-margin-"
            "[gridView]"
            "-margin-"
            "[line]"
            "-margin-"
            "[testButtonGrid]"
            "-margin-"
            "|"
        ]
        metrics = dict(margin=15)
        self.w.addAutoPosSizeRules(rules, metrics)
        self.w.open()