コード例 #1
0
ファイル: Otto.py プロジェクト: mcanthony/otto
def openSplash():
    global splash
    splash = NSWindow.alloc()
    rect = NSMakeRect(0,0,240,420)
    styleMask = 0
    splash.initWithContentRect_styleMask_backing_defer_(rect, styleMask, NSBackingStoreBuffered, False)

    # http://stackoverflow.com/questions/19437580/splash-screen-in-osx-cocoa-app

    splashImage = NSImageView.alloc().initWithFrame_(rect)
    splashImage.setImageScaling_(NSScaleToFit)
    splashImage.setImage_(NSImage.imageNamed_('ottosplash.png'))
    #[customView addSubview:splashImage];

    #splash.setContentView_(webview)
    splash.setContentView_(splashImage)
    splash.setHasShadow_(True)
    splash.setOpaque_(False)
    splash.setBackgroundColor_(NSColor.clearColor())

    # xPos = NSWidth([[splashWindow screen] frame])/2 - NSWidth([splashWindow frame])/2;
    #CGFloat yPos = NSHeight([[splashWindow screen] frame])/2 - NSHeight([splashWindow frame])/2;
    #[splashWindow setFrame:NSMakeRect(xPos, yPos, NSWidth([splashWindow frame]), NSHeight([splashWindow frame])) display:YES];
    splash.center()
    splash.orderFrontRegardless()
コード例 #2
0
ファイル: Simple.py プロジェクト: ferguson/otto
def openSplash():
    global splash
    splash = NSWindow.alloc()
    rect = NSMakeRect(0,0,240,420)
    styleMask = 0
    splash.initWithContentRect_styleMask_backing_defer_(rect, styleMask, NSBackingStoreBuffered, False)

    # http://stackoverflow.com/questions/19437580/splash-screen-in-osx-cocoa-app

    splashImage = NSImageView.alloc().initWithFrame_(rect)
    splashImage.setImageScaling_(NSScaleToFit)
    splashImage.setImage_(NSImage.imageNamed_('ottosplash.png'))
    #[customView addSubview:splashImage];

    #splash.setContentView_(webview)
    splash.setContentView_(splashImage)
    splash.setHasShadow_(True)
    splash.setOpaque_(False)
    splash.setBackgroundColor_(NSColor.clearColor())

    # xPos = NSWidth([[splashWindow screen] frame])/2 - NSWidth([splashWindow frame])/2;
    #CGFloat yPos = NSHeight([[splashWindow screen] frame])/2 - NSHeight([splashWindow frame])/2;
    #[splashWindow setFrame:NSMakeRect(xPos, yPos, NSWidth([splashWindow frame]), NSHeight([splashWindow frame])) display:YES];
    splash.center()
    splash.orderFrontRegardless()
コード例 #3
0
    def isWindowOnDockingSide(self, dockingWindow):
        '''
            checks whenever dragged docking window is above any dock bar
        '''

        winX, winY, winW, winH = dockingWindow.getPosSize()

        titleBarHeight = self._calculateParentWindowTitlebarHeight()

        x, y = (winX + winW / 2, winY - titleBarHeight / 2)
        px, py, pw, ph = self.getParentWindowPosSize()
        titleBarMiddlePoint = NSPoint(pw - (px - x) - pw, (py - y) + ph)
        isDockingWindowAbove = False
        dockingPosition = None
        for position in self.dockingRectPosSizes.keys():
            dockingSideObj = getattr(self, f'{position}_dockbar', None)
            if dockingSideObj is not None:
                view = dockingSideObj.getNSView().hitTest_(titleBarMiddlePoint)
                if view is not None:
                    dockingSideObj.getNSView().layer().setBackgroundColor_(
                        NSColor.orangeColor().CGColor())
                    dockingPosition = position
                    isDockingWindowAbove = True
                else:
                    dockingSideObj.getNSView().layer().setBackgroundColor_(
                        NSColor.clearColor().CGColor())
        if isDockingWindowAbove:
            dockingWindow.getNSWindow().setAlphaValue_(.4)
        else:
            dockingWindow.getNSWindow().setAlphaValue_(1)
        return dockingPosition, self
コード例 #4
0
 def init(self, app, controller):
     self._app = app
     self._controller = controller
     self._controller.window = self
     self._when_done = None
     self._dropbox_app = controller.dropbox_app
     self._cancelled = None
     self.screen_frame = get_main_screen_rect()
     center = get_origin_of_centered_window(self.screen_frame, NSMakeSize(self.BASE_WIDTH, self.BASE_HEIGHT))
     rect = NSMakeRect(center.x, center.y, self.BASE_WIDTH, self.BASE_HEIGHT)
     mask = NSClosableWindowMask | NSTitledWindowMask
     self.host = WizkitView.alloc().initWithFrame_controller_(rect, controller)
     self = super(WizkitWindow, self).initWithContentRect_styleMask_view_(rect, mask, self.host)
     self.setHasShadow_(objc.YES)
     self.setDelegate_(self)
     self.setBackgroundColor_(NSColor.clearColor())
     self.setOpaque_(objc.NO)
     self.host.setDrawsBackground_(objc.NO)
     self.setMovableByWindowBackground_(objc.NO)
     self.setMovable_(objc.YES)
     self.window_frame = self.frame()
     self.setAcceptsMouseMovedEvents_(objc.YES)
     self._hasLoaded = False
     self._visible = False
     self._firstDrag = True
     self._firstDragOffset = None
     self._dragOnInputNode = False
     self.setLevel_(NSFloatingWindowLevel)
     NSApp().activateIgnoringOtherApps_(True)
     NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, self.frameHasLoaded_, WebViewProgressFinishedNotification, self.host)
     return self
コード例 #5
0
 def __init__(self, posSize, url, editable=False, callback=None, sizeStyle="regular"):
     self._setupView(self.nsPathControlClass, posSize, callback=callback)
     self._nsObject.setPathStyle_(self.nspathStyle)
     self._setSizeStyle(sizeStyle)
     self._nsObject.setURL_(url)
     self._nsObject.setBackgroundColor_(NSColor.clearColor())
     self._nsObject.setFocusRingType_(NSFocusRingTypeNone)
コード例 #6
0
 def __init__(self, posSize, url, callback=None, pathStyle="standard", sizeStyle="regular"):
     self._setupView(self.nsPathControlClass, posSize, callback=callback)
     self._nsObject.setPathStyle_(_pathStylesMap[pathStyle])
     self._setSizeStyle(sizeStyle)
     self._nsObject.setBackgroundColor_(NSColor.clearColor())
     self._nsObject.setFocusRingType_(NSFocusRingTypeNone)
     self._nsObject.cell().setBordered_(True)
     self._nsObject.cell().setBezelStyle_(NSRoundedBezelStyle)
     self.set(url)
コード例 #7
0
    def drawHistogramImage(self):
        width = int(self.tool.histWidth)
        height = int(self.tool.histHeight)

        image = NSImage.alloc().initWithSize_((width, height))
        image.lockFocus()
        image.setBackgroundColor_(NSColor.clearColor())
        self.drawHistogram(0, 0, width, height)
        image.unlockFocus()
        self.prefwindow.w.histogramImage.setImage(imageObject=image)
    def mouseExited(self, event):
        g = self.w.getGlyph()
        if g is None:
            return
        f = g.font
        if f is None:
            return
        self.showButtons = False
        sbui = windowViewManger.get(self.w)
        sbui.L.Lminus.show(False)
        sbui.L.Lround.show(False)
        sbui.L.Lplus.show(False)
        sbui.L.Lright.show(False)
        sbui.R.Rminus.show(False)
        sbui.R.Rround.show(False)
        sbui.R.Rplus.show(False)
        sbui.R.Rleft.show(False)
        sbui.C.Cminus.show(False)
        sbui.C.Cround.show(False)
        sbui.C.Ccenter.show(False)
        sbui.C.Cplus.show(False)

        sbui.L.Ltext.getNSTextField().setBackgroundColor_(NSColor.clearColor())
        sbui.R.Rtext.getNSTextField().setBackgroundColor_(NSColor.clearColor())
        sbui.C.Ctext.getNSTextField().setBackgroundColor_(NSColor.clearColor())

        uniquecomponents = []
        for c in g.components:
            if c.baseGlyph not in uniquecomponents:
                uniquecomponents.append(c.baseGlyph)
        for i, c in enumerate(uniquecomponents):
            try:
                this = getattr(sbui.L, 'buttobj_%s' % i)
                this.show(False)
                this = getattr(sbui.R, 'buttobj_%s' % i)
                this.show(False)
                this = getattr(sbui.C, 'buttobj_%s' % i)
                this.show(False)
            except:
                return

        sbui.update()
コード例 #9
0
 def __init__(self, posSize, screen=None):
     super(InformationPopUpWindow, self).__init__(posSize, "", minSize=None,
             maxSize=None, textured=False, autosaveName=None,
             closable=False, initiallyVisible=False, screen=screen)
     contentView = DefconAppKitInformationPopUpWindowContentView.alloc().init()
     self._window.setContentView_(contentView)
     self._window.setBackgroundColor_(NSColor.clearColor())
     self._window.setAlphaValue_(0.0)
     self._window.setOpaque_(False)
     self._window.setHasShadow_(True)
     self._window.setMovableByWindowBackground_(False)
コード例 #10
0
 def __createDockingSide(self, position):
     '''
         creates dockbar, which are next to the  edges of the content view
     '''
     dockingSideObj = Group(self.dockingRectPosSizes[position],
                            blendingMode=None)
     objBarView = dockingSideObj.getNSView()
     objBarView.dockingSidePositionName = position
     objBarView.setWantsLayer_(True)
     objBarView.layer().setBackgroundColor_(NSColor.clearColor().CGColor())
     objName = f"{position}_dockbar"
     setattr(self, objName, dockingSideObj)
コード例 #11
0
    def __init__(self, posSize, screen=None):
        super(InteractivePopUpWindow, self).__init__(posSize, screen=screen)
        self._window.setMovableByWindowBackground_(True)

        # set the background
        contentView = self.contentViewClass.alloc().init()
        self._window.setContentView_(contentView)
        self._window.setAlphaValue_(0.0)
        self._window.setOpaque_(False)
        self._window.setBackgroundColor_(NSColor.clearColor())

        # set up the window to close when it loses focus
        self.bind("resigned key", self.windowDeselectCallback_)
        self._closing = False
コード例 #12
0
 def __init__(self,
              posSize,
              url,
              callback=None,
              pathStyle="standard",
              sizeStyle="regular"):
     self._setupView(self.nsPathControlClass, posSize, callback=callback)
     self._nsObject.setPathStyle_(_pathStylesMap[pathStyle])
     self._setSizeStyle(sizeStyle)
     self._nsObject.setBackgroundColor_(NSColor.clearColor())
     self._nsObject.setFocusRingType_(NSFocusRingTypeNone)
     self._nsObject.cell().setBordered_(True)
     self._nsObject.cell().setBezelStyle_(NSRoundedBezelStyle)
     self.set(url)
コード例 #13
0
    def addOverlapValueUI(self, window):
        if not self.bar:
            return
        if hasattr(self.bar, "interpolationStatusLabel"):
            del self.bar.interpolationStatusLabel
        if hasattr(self.bar, "interpolationStatusMenu"):
            del self.bar.interpolationStatusMenu

        # get window name to see if were in singlewindowmode
        try:
            windowType = self.wwwindow.window().getNSWindow().windowName()
        except AttributeError:
            windowType = None
        swmshift = -15

        xywh = [-17, 0, 14, 16]
        if windowType == 'SingleFontWindow':  # if single window mode
            xywh[0] += swmshift
        self.bar.interpolationStatusLabel = TextBox(xywh, '⋉')
        self.bar.interpolationStatusLabel.getNSTextField().setAlignment_(
            NSTextAlignmentLeft)

        xywh = [-56, 4, 40, 12]
        if windowType == 'SingleFontWindow':  # if single window mode
            xywh[0] += swmshift
        self.bar.interpolationStatusMenu = EditText(
            xywh,
            self.toolValue,
            sizeStyle='mini',
            continuous=True,
            callback=self.editTextCallback)
        self.bar.interpolationStatusMenu.getNSTextField().setBezeled_(False)
        self.bar.interpolationStatusMenu.getNSTextField().setBackgroundColor_(
            NSColor.clearColor())
        self.bar.interpolationStatusMenu.getNSTextField().setAlignment_(
            NSTextAlignmentRight)
コード例 #14
0
 def _clearColors(self):
     for position in self.dockingRectPosSizes.keys():
         dockingSideObj = getattr(self, f'{position}_dockbar', None)
         dockingSideObj.getNSView().layer().setBackgroundColor_(
             NSColor.clearColor().CGColor())
コード例 #15
0
    def addInterface(self, notification):
        self.window = notification['window']
        # self.cleanup(self.window)

        # CONTAINER
        xywh = (margin, -55, -margin, height)
        self.sbui = CanvasGroup(xywh, delegate=CanvasStuff(self.window))

        # LEFT
        x, y, w, h = xywh = (0, -height, dfltLwidth, height)
        this = self.sbui.L = Group(xywh)

        # text input
        xywh = (x, y + 3, width * 1.5, height * .75)
        this.Ltext = EditText(xywh,
                              placeholder='angledLeftMargin',
                              sizeStyle='mini',
                              continuous=False,
                              callback=self.setSB)
        # quick mod buttons
        xywh = (x + width * 1.5 + (gap * 1), y, width, height)
        this.Lminus = Button(xywh,
                             iconminus,
                             sizeStyle='mini',
                             callback=self.setLminus)
        this.Lminus.getNSButton().setToolTip_('Adjust LSB -' + str(unit))
        xywh = (x + width * 2.5 + (gap * 2), y, width, height)
        this.Lplus = Button(xywh,
                            iconplus,
                            sizeStyle='mini',
                            callback=self.setLplus)
        this.Lplus.getNSButton().setToolTip_('Adjust LSB +' + str(unit))
        xywh = (x + width * 3.5 + (gap * 3), y, width, height)
        this.Lround = Button(xywh,
                             iconround,
                             sizeStyle='mini',
                             callback=self.setLround)
        this.Lround.getNSButton().setToolTip_('Round LSB to ' + str(unit))
        xywh = (x + width * 4.5 + (gap * 4), y, width, height)
        this.Lright = Button(xywh,
                             iconcopyR,
                             sizeStyle='mini',
                             callback=self.setLright)
        this.Lright.getNSButton().setToolTip_('Copy Right Value')
        # stylize
        this.Ltext.getNSTextField().setBezeled_(False)
        this.Ltext.getNSTextField().setBackgroundColor_(NSColor.clearColor())
        self.flatButt(this.Lminus)
        self.flatButt(this.Lplus)
        self.flatButt(this.Lround)
        self.flatButt(this.Lright)

        # RIGHT
        x, y, w, h = xywh = (-dfltRwidth, y, dfltRwidth, h)
        this = self.sbui.R = Group(xywh)
        # text input
        xywh = (-x - width * 1.5, y + 3, width * 1.5, height * .75)
        this.Rtext = EditText(xywh,
                              placeholder='angledRightMargin',
                              sizeStyle='mini',
                              continuous=False,
                              callback=self.setSB)
        # quick mod buttons
        xywh = (-x - width * 5.5 - (gap * 4), y, width, height)
        this.Rleft = Button(xywh,
                            iconcopyL,
                            sizeStyle='mini',
                            callback=self.setRleft)
        this.Rleft.getNSButton().setToolTip_('Copy Left Value')
        xywh = (-x - width * 4.5 - (gap * 3), y, width, height)
        this.Rround = Button(xywh,
                             iconround,
                             sizeStyle='mini',
                             callback=self.setRround)
        this.Rround.getNSButton().setToolTip_('Round RSB to ' + str(unit))
        xywh = (-x - width * 3.5 - (gap * 2), y, width, height)
        this.Rminus = Button(xywh,
                             iconminus,
                             sizeStyle='mini',
                             callback=self.setRminus)
        this.Rminus.getNSButton().setToolTip_('Adjust RSB -' + str(unit))
        xywh = (-x - width * 2.5 - (gap * 1), y, width, height)
        this.Rplus = Button(xywh,
                            iconplus,
                            sizeStyle='mini',
                            callback=self.setRplus)
        this.Rplus.getNSButton().setToolTip_('Adjust RSB +' + str(unit))
        # stylize
        this.Rtext.getNSTextField().setBezeled_(False)
        this.Rtext.getNSTextField().setBackgroundColor_(NSColor.clearColor())
        this.Rtext.getNSTextField().setAlignment_(NSTextAlignmentRight)
        self.flatButt(this.Rminus)
        self.flatButt(this.Rplus)
        self.flatButt(this.Rround)
        self.flatButt(this.Rleft)

        # CENTER
        winX, winY, winW, winH = self.window.getVisibleRect()
        winW = winW - margin * 5
        x, y, w, h = xywh = ((winW / 2) - (dfltCwidth / 2), y, dfltCwidth, h)
        this = self.sbui.C = Group(xywh)
        x = 0

        # text input
        c = (dfltCwidth / 2)
        xywh = (c - (width * .75), y + 3, width * 1.5, height * .75)
        this.Ctext = EditText(xywh,
                              placeholder='width',
                              sizeStyle='mini',
                              continuous=False,
                              callback=self.setSB)
        # quick mod buttons
        xywh = (c - (width * .75) - width * 2 - (gap * 2), y, width, height)
        this.Ccenter = Button(xywh,
                              iconcenter,
                              sizeStyle='mini',
                              callback=self.setCcenter)
        this.Ccenter.getNSButton().setToolTip_('Center on Width')
        xywh = (c - (width * .75) - width - (gap * 1), y, width, height)
        this.Cround = Button(xywh,
                             iconround,
                             sizeStyle='mini',
                             callback=self.setCround)
        this.Cround.getNSButton().setToolTip_('Round Width to ' + str(unit))
        xywh = (c + (width * .75) + (gap * 1), y, width, height)
        this.Cminus = Button(xywh,
                             iconminus,
                             sizeStyle='mini',
                             callback=self.setCminus)
        this.Cminus.getNSButton().setToolTip_('Adjust Width -' + str(2 * unit))
        xywh = (c + (width * .75) + width + (gap * 2), y, width, height)
        this.Cplus = Button(xywh,
                            iconplus,
                            sizeStyle='mini',
                            callback=self.setCplus)
        this.Cplus.getNSButton().setToolTip_('Adjust Width +' + str(2 * unit))
        # stylize
        this.Ctext.getNSTextField().setBezeled_(False)
        this.Ctext.getNSTextField().setBackgroundColor_(NSColor.clearColor())
        this.Ctext.getNSTextField().setAlignment_(NSTextAlignmentCenter)
        self.flatButt(this.Cminus)
        self.flatButt(this.Cplus)
        self.flatButt(this.Cround)
        self.flatButt(this.Ccenter)

        # hide
        self.sbui.L.Lminus.show(False)
        self.sbui.L.Lround.show(False)
        self.sbui.L.Lplus.show(False)
        self.sbui.L.Lright.show(False)
        self.sbui.R.Rminus.show(False)
        self.sbui.R.Rround.show(False)
        self.sbui.R.Rplus.show(False)
        self.sbui.R.Rleft.show(False)
        self.sbui.C.Cminus.show(False)
        self.sbui.C.Cround.show(False)
        self.sbui.C.Ccenter.show(False)
        self.sbui.C.Cplus.show(False)

        # make it real
        self.sbWatcherInitialize()
        self.window.addGlyphEditorSubview(self.sbui)
        self.updateValues()
        self.buildMatchBase()
        windowViewManger[self.window] = self.sbui
コード例 #16
0
ファイル: colors.py プロジェクト: PageBot/PageBotNano

def rgba(r, g, b, a=1.0):
    """rgb values between 0 and 1"""
    return getRGBA(r * 255, b * 255, g * 255, a)


rgb = rgba

# Preset colors.

blackColor = NSColor.blackColor()
opaqueBlackColor = getRGBA(0, 0, 0, 0.5)
blueColor = NSColor.blueColor()
brownColor = NSColor.brownColor()
clearColor = NSColor.clearColor()
cyanColor = NSColor.cyanColor()
darkGrayColor = getRGBA(80, 80, 80)
darkGreyColor = darkGrayColor
grayColor = NSColor.grayColor()
greyColor = grayColor
grayColor = NSColor.grayColor()
greenColor = NSColor.greenColor()
lightGreenColor = getRGBA(75, 211, 154)
darkGreenColor = getRGBA(41, 120, 37)
lightestGrayColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(
    0.98, 0.98, 0.98, 1)
lightestGreyColor = lightestGrayColor
lightGrayColor = NSColor.lightGrayColor()
lightGreyColor = lightGrayColor
magentaColor = NSColor.magentaColor()