Esempio n. 1
0
 def init(self, wizard):
     self = super(SetupWizardWindow, self).initWithContentRect_styleMask_backing_defer_(NSRect((0, 0), (580, 500)), NSTitledWindowMask | NSClosableWindowMask, NSBackingStoreBuffered, NO)
     if self is not None:
         self._wizard = wizard
         self._dropbox_app = wizard.dropbox_app
         self.setReleasedWhenClosed_(NO)
         self.center()
         self.setLevel_(NSFloatingWindowLevel)
         self._system_font = NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(NSRegularControlSize))
         self._small_system_font = NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(NSSmallControlSize))
         self.setTitle_(SetupWizardStrings.window_title)
         self._renderers = {Button: self._create_button,
          CenteredMultiControlLine: self._create_centered_multi_control_line,
          Checkbox: self._create_checkbox,
          Choice: self._create_choice,
          CreditCardType: self._create_credit_card_type,
          Date: self._create_date,
          ExampleText: self._create_example_text,
          FancyRadioGroup: self._create_fancy_radio_group,
          FlagChoice: self._create_flag_choice,
          HelpButton: self._create_help_button,
          Image: self._create_image,
          LocationChanger: self._create_location_changer,
          MultiControlLine: self._create_multi_control_line,
          MultiControlLineSimple: self._create_multi_control_line,
          TextBlock: self._create_text_block,
          TextInput: self._create_text_input,
          PlanChoices: self._create_plan_choices,
          RadioGroup: self._create_radio_group,
          SelectiveSync: self._create_selective_sync,
          Spacer: self._create_spacer}
         self._buttons = {}
     return self
Esempio n. 2
0
 def __init__(self,
              posSize,
              title=None,
              fillColor=None,
              borderColor=None,
              borderWidth=None,
              cornerRadius=None):
     self._setupView(self.nsBoxClass, posSize)
     if title:
         self._nsObject.setTitle_(title)
         if osVersionCurrent < osVersion10_10:
             self._nsObject.titleCell().setTextColor_(NSColor.blackColor())
         font = NSFont.systemFontOfSize_(
             NSFont.systemFontSizeForControlSize_(NSSmallControlSize))
         self._nsObject.setTitleFont_(font)
     else:
         self._nsObject.setTitlePosition_(NSNoTitle)
     if fillColor is not None:
         self.setFillColor(fillColor)
     if borderColor is not None:
         self.setBorderColor(borderColor)
     if borderWidth is not None:
         self.setBorderWidth(borderWidth)
     if cornerRadius is not None:
         self.setCornerRadius(cornerRadius)
Esempio n. 3
0
 def __init__(self, posSize, titles, isVertical=True, callback=None, sizeStyle="regular"):
     self._setupView(self.nsMatrixClass, posSize, callback=callback)
     self._isVertical = isVertical
     matrix = self._nsObject
     matrix.setMode_(NSRadioModeMatrix)
     matrix.setCellClass_(self.nsCellClass)
     # XXX! this does not work for vertical radio groups!
     matrix.setAutosizesCells_(True)
     # we handle the control size setting here
     # since the actual NS object is a NSMatrix
     cellSizeStyle = _sizeStyleMap[sizeStyle]
     font = NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(cellSizeStyle))
     # intercell spacing and cell spacing are based on the sizeStyle
     if sizeStyle == "regular":
         matrix.setIntercellSpacing_((4.0, 2.0))
         matrix.setCellSize_((posSize[2], 18))
     elif sizeStyle == "small":
         matrix.setIntercellSpacing_((3.5, 2.0))
         matrix.setCellSize_((posSize[2], 15))
     elif sizeStyle == "mini":
         matrix.setIntercellSpacing_((3.0, 2.0))
         matrix.setCellSize_((posSize[2], 12))
     else:
         raise ValueError("sizeStyle must be 'regular', 'small' or 'mini'")
     for _ in range(len(titles)):
         if isVertical:
             matrix.addRow()
         else:
             matrix.addColumn()
     for title, cell in zip(titles, matrix.cells()):
         cell.setButtonType_(NSRadioButton)
         cell.setTitle_(title)
         cell.setControlSize_(cellSizeStyle)
         cell.setFont_(font)
Esempio n. 4
0
    def init(self):
        self = super(LineNumberNSRulerView, self).init()
        self._font = NSFont.labelFontOfSize_(NSFont.systemFontSizeForControlSize_(NSMiniControlSize))
        self._textColor = NSColor.colorWithCalibratedWhite_alpha_(.42, 1)
        self._rulerBackgroundColor = None

        self._lineIndices = None
        return self
Esempio n. 5
0
def SmallTextListCell(editable=False):
    cell = NSTextFieldCell.alloc().init()
    size = NSSmallControlSize
    cell.setControlSize_(size)
    font = NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(size))
    cell.setFont_(font)
    cell.setEditable_(editable)
    return cell
Esempio n. 6
0
def SmallTextListCell(editable=False):
    cell = NSTextFieldCell.alloc().init()
    size = NSSmallControlSize
    cell.setControlSize_(size)
    font = NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(size))
    cell.setFont_(font)
    cell.setEditable_(editable)
    return cell
Esempio n. 7
0
	def settings(self):
		self.name = Glyphs.localize({
			'en': 'Alignment',
			'de': 'Ausrichtung',
			'es': 'Alineación',
			'fr': 'Alignement',
			'pt': 'Alinhamento',
		})
		width = 150
		self.marginTop = 7
		self.marginLeft = 7
		self.lineSpacing = 21
		smallSize = NSFont.systemFontSizeForControlSize_( NSFont.smallSystemFontSize() )
		textFieldHeight = smallSize + 7
		textFieldWidth = 50
		# lockHeight = textFieldHeight
		innerWidth = width - 2 * self.marginLeft
		height = ( MAX_ZONES + 4 ) * self.lineSpacing + self.marginTop * 3
		self.posx_TextField = width - textFieldWidth - self.marginLeft

		# Create Vanilla window and group with controls
		self.paletteView = Window( (width, height), minSize=(width, height - 10), maxSize=(width, height + 200 ) )
		self.paletteView.group = Group( (0, 0, width, height ) )

		posy = self.marginTop
		# set up fields for center
		headlineBbox = NSAttributedString.alloc().initWithString_attributes_( 'Bounding box', { NSFontAttributeName:NSFont.boldSystemFontOfSize_( smallSize ) } )
		self.paletteView.group.headlineBbox = TextBox( ( 10, posy, innerWidth, 18 ), headlineBbox, sizeStyle='small' )
		posy += self.lineSpacing
		self.paletteView.group.centerXLabel = TextBox( ( 10, posy + 3, innerWidth, 18 ), 'center x', sizeStyle='small' )
		self.posy_centerX = posy
		# self.paletteView.group.lockX = ImageButton( ( self.posx_TextField - lockHeight - 5, posy, lockHeight, lockHeight ), imageNamed='GSLockUnlockedTemplate', bordered=False, imagePosition='top', callback=self.lockCallback, sizeStyle='regular' )
		# self.lockXlocked = False
		self.paletteView.group.centerX = ArrowEditText( ( self.posx_TextField, posy, textFieldWidth, textFieldHeight ), callback=self.editTextCallback, continuous=False, readOnly=False, formatter=None, placeholder='multiple', sizeStyle='small' )
		posy += self.lineSpacing
		self.paletteView.group.centerYLabel = TextBox( ( 10, posy + 3, innerWidth, 18 ), 'center y', sizeStyle='small' )
		self.posy_centerY = posy
		# self.paletteView.group.lockY = ImageButton( ( self.posx_TextField - lockHeight - 5, posy, lockHeight, lockHeight ), imageNamed='GSLockUnlockedTemplate', bordered=False, imagePosition='top', callback=self.lockCallback, sizeStyle='regular' )
		# self.lockYlocked = False
		self.paletteView.group.centerY = ArrowEditText( ( self.posx_TextField, posy, textFieldWidth, textFieldHeight ), callback=self.editTextCallback, continuous=False, readOnly=False, formatter=None, placeholder='multiple', sizeStyle='small' )
		posy += self.lineSpacing + self.marginTop
		# set up fields for overshoot
		headlineOvershoot = NSAttributedString.alloc().initWithString_attributes_( 'Overshoot', { NSFontAttributeName:NSFont.boldSystemFontOfSize_( NSFont.systemFontSizeForControlSize_( smallSize ) ) } )
		self.paletteView.group.headlineOvershoot = TextBox( ( 10, posy, innerWidth, 18 ), headlineOvershoot, sizeStyle='small' )
		posy += self.lineSpacing
		self.paletteView.group, 'lineAbove', HorizontalLine( ( self.marginLeft, posy - 3, innerWidth, 1 ) )
		for i in range( MAX_ZONES ):
			setattr( self.paletteView.group, 'name' + str( i ), TextBox( ( 10, posy, innerWidth, 18 ), '', sizeStyle='small' ) )
			setattr( self.paletteView.group, 'value' + str( i ), TextBox( ( self.posx_TextField, posy, textFieldWidth - 3, textFieldHeight ), '', sizeStyle='small', alignment='right' ) )
			posy += self.lineSpacing
			setattr( self.paletteView.group, 'line' + str( i ), HorizontalLine( ( self.marginLeft, posy - 3, innerWidth, 1 ) ) )
		# set dialog to NSView
		self.dialog = self.paletteView.group.getNSView()
		# set self.font
		self.font = None
		windowController = self.windowController()
		if windowController:
			self.font = windowController.document().font
    def init(self):
        self = super(LineNumberNSRulerView, self).init()
        self._font = NSFont.labelFontOfSize_(
            NSFont.systemFontSizeForControlSize_(NSMiniControlSize))
        self._textColor = NSColor.colorWithCalibratedWhite_alpha_(.42, 1)
        self._rulerBackgroundColor = None

        self._lineIndices = None
        return self
def text_Bold(text):
    size = NSRegularControlSize
    attrs = {}
    string = NSMutableAttributedString.alloc().initWithString_attributes_(
        text, attrs)
    attrs[NSFontAttributeName] = NSFont.boldSystemFontOfSize_(
        NSFont.systemFontSizeForControlSize_(size))
    attributedString = NSMutableAttributedString.alloc(
    ).initWithString_attributes_(text, attrs)
    return attributedString
Esempio n. 10
0
 def __init__(self, posSize, title=None):
     self._setupView(self.nsBoxClass, posSize)
     if title:
         self._nsObject.setTitle_(title)
         if osVersionCurrent < osVersion10_10:
             self._nsObject.titleCell().setTextColor_(NSColor.blackColor())
         font = NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(NSSmallControlSize))
         self._nsObject.setTitleFont_(font)
     else:
         self._nsObject.setTitlePosition_(NSNoTitle)
Esempio n. 11
0
 def __init__(self, posSize, title=None):
     self._setupView(self.nsBoxClass, posSize)
     if title:
         self._nsObject.setTitle_(title)
         if osVersionCurrent < osVersion10_10:
             self._nsObject.titleCell().setTextColor_(NSColor.blackColor())
         font = NSFont.systemFontOfSize_(
             NSFont.systemFontSizeForControlSize_(NSSmallControlSize))
         self._nsObject.setTitleFont_(font)
     else:
         self._nsObject.setTitlePosition_(NSNoTitle)
def text_Gray(text):
    size = NSRegularControlSize
    attrs = {}
    attrs[NSForegroundColorAttributeName] = NSColor.grayColor()
    string = NSMutableAttributedString.alloc().initWithString_attributes_(
        text, attrs)
    #attrs[NSFontAttributeName] = NSFont.boldSystemFontOfSize_(NSFont.systemFontSizeForControlSize_(size))
    attrs[NSFontAttributeName] = NSFont.systemFontOfSize_(
        NSFont.systemFontSizeForControlSize_(size))
    attributedString = NSMutableAttributedString.alloc(
    ).initWithString_attributes_(text, attrs)
    return attributedString
Esempio n. 13
0
    def initWithFrame_imageDir_(self, frame, imageDir):
        self = super(IntroView, self).initWithFrame_(frame)
        if not self:
            return None
        dropboxImage = NSImage.alloc().initWithContentsOfFile_(os.path.join(imageDir, u'box_stroked_150.png'))
        iW, iH = dropboxImage.size()
        newHeight = iH * 300.0 / iW
        self.dropboxViewFinalPosition = NSRect((25, frame.size[1] - 43 - newHeight), (300, newHeight))
        self.dropboxView = ShadowedImage.alloc().initWithFrame_(self.dropboxViewFinalPosition)
        self.dropboxView.setImageScaling_(NSScaleToFit)
        self.dropboxView.setImage_(dropboxImage)
        self.dropboxView.setShadowColor_(NSColor.colorWithCalibratedRed_green_blue_alpha_(0, 0, 0, 0.5))
        self.dropboxView.setShadowOffset_((0.0, -2.0))
        self.dropboxView.setShadowBlurRadius_(5.0)
        logoImage = NSImage.alloc().initWithContentsOfFile_(os.path.join(imageDir, u'dropboxlogo.png'))
        iW, iH = logoImage.size()
        newHeight = iH * 300.0 / iW
        self.logoViewFinalPosition = NSRect((25, frame.size[1] - 334 - newHeight), (300, newHeight))
        self.logoView = NSImageView.alloc().initWithFrame_(self.logoViewFinalPosition)
        self.logoView.setImage_(logoImage)
        self.versionView = NSTextView.alloc().initWithFrame_(NSRect((0, 0), frame.size))
        self.versionView.setDrawsBackground_(NO)
        self.versionView.setEditable_(NO)
        self.versionView.setSelectable_(NO)
        self.versionView.textStorage().mutableString().setString_(u'Version %s' % build_number.VERSION)
        self.versionView.textStorage().setFont_(NSFont.labelFontOfSize_(14))
        self.versionView.layoutManager().glyphRangeForTextContainer_(self.versionView.textContainer())
        textSize1 = self.versionView.layoutManager().usedRectForTextContainer_(self.versionView.textContainer()).size
        textAnchor1 = 5
        self.versionView2 = NSTextView.alloc().initWithFrame_(NSRect((0, 0), frame.size))
        self.versionView2.setDrawsBackground_(NO)
        self.versionView2.setEditable_(NO)
        self.versionView2.setSelectable_(NO)
        self.versionView2.textStorage().mutableString().setString_(u'Copyright \xa9 2007-2010 Dropbox Inc.')
        self.versionView2.setFont_(NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(NSSmallControlSize)))
        self.versionView2.layoutManager().glyphRangeForTextContainer_(self.versionView2.textContainer())
        textSize2 = self.versionView2.layoutManager().usedRectForTextContainer_(self.versionView2.textContainer()).size
        textAnchor2 = 4
        bottomToLogoViewBaseline = self.logoView.frame().origin[1] + 17
        textSeparation = 10
        combinedHeight = textSize1[1] + textSize2[1] + textSeparation
        self.versionView2FinalPosition = NSRect(((frame.size[0] - textSize2[0]) / 2.0, (bottomToLogoViewBaseline - combinedHeight) / 2.0), (textSize2[0], textSize2[1] + textAnchor2))
        self.versionView2.setFrame_(self.versionView2FinalPosition)
        self.versionViewFinalPosition = NSRect(((frame.size[0] - textSize1[0]) / 2.0, self.versionView2.frame().origin[1] + textSeparation + self.versionView2.frame().size[1]), (textSize1[0], textSize1[1] + textAnchor1))
        self.versionView.setFrame_(self.versionViewFinalPosition)
        for _view in (self.dropboxView,
         self.logoView,
         self.versionView,
         self.versionView2):
            self.addSubview_(_view)

        return self
Esempio n. 14
0
 def __init__(self,
              posSize,
              titles,
              isVertical=True,
              callback=None,
              sizeStyle="regular"):
     self._setupView(self.nsMatrixClass, posSize, callback=callback)
     self._isVertical = isVertical
     matrix = self._nsObject
     matrix.setMode_(NSRadioModeMatrix)
     matrix.setCellClass_(self.nsCellClass)
     # XXX! this does not work for vertical radio groups!
     matrix.setAutosizesCells_(True)
     # we handle the control size setting here
     # since the actual NS object is a NSMatrix
     cellSizeStyle = _sizeStyleMap[sizeStyle]
     font = NSFont.systemFontOfSize_(
         NSFont.systemFontSizeForControlSize_(cellSizeStyle))
     # intercell spacing and cell spacing are based on the sizeStyle
     if posSize == "auto":
         w = 0
     else:
         w = posSize[2]
     if sizeStyle == "regular":
         matrix.setIntercellSpacing_((4.0, 2.0))
         matrix.setCellSize_((w, 18))
     elif sizeStyle == "small":
         matrix.setIntercellSpacing_((3.5, 2.0))
         matrix.setCellSize_((w, 15))
     elif sizeStyle == "mini":
         matrix.setIntercellSpacing_((3.0, 2.0))
         matrix.setCellSize_((w, 12))
     else:
         raise ValueError("sizeStyle must be 'regular', 'small' or 'mini'")
     for _ in range(len(titles)):
         if isVertical:
             matrix.addRow()
         else:
             matrix.addColumn()
     for title, cell in zip(titles, matrix.cells()):
         cell.setButtonType_(NSRadioButton)
         cell.setTitle_(title)
         cell.setControlSize_(cellSizeStyle)
         cell.setFont_(font)
Esempio n. 15
0
 def _setSizeStyle(self, value):
     value = _sizeStyleMap[value]
     self._nsObject.cell().setControlSize_(value)
     font = NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(value))
     self._nsObject.setFont_(font)
        self.w.close()

    def okCallback(self, sender):
        self.w.close()
        value = self.w.lineInput.get()
        if value is not None:
            self._callback(value)
        self._callback = None


# -----------------
# Line Number Ruler
# -----------------

rulerFont = NSFont.labelFontOfSize_(
    NSFont.systemFontSizeForControlSize_(NSMiniControlSize))


class DefconAppKitLineNumberView(NSRulerView):
    def init(self):
        self = super(DefconAppKitLineNumberView, self).init()
        self._existingText = None
        self._existingClientViewWidth = None
        self._lineRects = []
        return self

    def dealloc(self):
        notificationCenter = NSNotificationCenter.defaultCenter()
        notificationCenter.removeObserver_(self)
        super(DefconAppKitLineNumberView, self).dealloc()
Esempio n. 17
0
        self._callback = None
        self.w.close()

    def okCallback(self, sender):
        self.w.close()
        value = self.w.lineInput.get()
        if value is not None:
            self._callback(value)
        self._callback = None


# -----------------
# Line Number Ruler
# -----------------

rulerFont = NSFont.labelFontOfSize_(NSFont.systemFontSizeForControlSize_(NSMiniControlSize))


class DefconAppKitLineNumberView(NSRulerView):

    def init(self):
        self = super(DefconAppKitLineNumberView, self).init()
        self._existingText = None
        self._existingClientViewWidth = None
        self._lineRects = []
        return self

    def dealloc(self):
        notificationCenter = NSNotificationCenter.defaultCenter()
        notificationCenter.removeObserver_(self)
        super(DefconAppKitLineNumberView, self).dealloc()
Esempio n. 18
0
 def _setSizeStyle(self, value):
     value = _sizeStyleMap[value]
     self._nsObject.setControlSize_(value)
     font = NSFont.systemFontOfSize_(
         NSFont.systemFontSizeForControlSize_(value))
     self._nsObject.setFont_(font)
class DefconAppKitTopAnchoredNSView(NSView):

    def isFlipped(self):
        return True


# title attributes
shadow = NSShadow.alloc().init()
shadow.setShadowColor_(NSColor.colorWithCalibratedWhite_alpha_(1, 1))
shadow.setShadowBlurRadius_(1.0)
shadow.setShadowOffset_((1.0, -1.0))
titleControlAttributes = {
    NSForegroundColorAttributeName: NSColor.colorWithCalibratedWhite_alpha_(.4, 1),
    NSShadowAttributeName: shadow,
    NSFontAttributeName: NSFont.boldSystemFontOfSize_(NSFont.systemFontSizeForControlSize_(NSSmallControlSize))
}


# all script and language tags
_scriptTags = """arab
armn
beng
bopo
brai
byzm
cans
cher
hani
cyrl
DFLT
Esempio n. 20
0
def _setSizeStyle(obj, value):
    value = _sizeStyleMap[value]
    obj.setControlSize_(value)
    font = NSFont.systemFontOfSize_(
        NSFont.systemFontSizeForControlSize_(value))
    obj.setFont_(font)