Example #1
0
 def layout(self):
     height = self.BORDER + self.IMAGE_PADDING
     width = self.VIEW_SIZE[0] - self.BORDER * 2
     image = NonBlurryImageView.alloc().initWithFrame_(NSZeroRect)
     image.setImage_(self.image)
     image.setFrameSize_(self.image.size())
     self.addSubview_(image)
     image.setFrameOrigin_((0, height))
     image.centerHorizontallyInSuperview()
     height += NSHeight(image.frame()) + self.HEADER_PADDING
     label1 = NSTextField.createLabelWithText_font_maxWidth_origin_(self.header, NSFont.boldSystemFontOfSize_(self.HEADER_SIZE) if self.BOLD_HEADER else NSFont.systemFontOfSize_(self.HEADER_SIZE), width, NSPoint(0, height))
     self.addSubview_(label1)
     label1.centerHorizontallyInSuperview()
     label1.setTextColor_(self.HEADER_COLOR)
     height += NSHeight(label1.frame()) + self.SUBHEADER_PADDING
     label2 = NSTextField.createLabelWithText_font_maxWidth_origin_(NSAttributedString.boldify(self.subheader, font=NSFont.systemFontOfSize_(self.SUBHEADER_SIZE), bold_font=NSFont.boldSystemFontOfSize_(self.SUBHEADER_SIZE), center=True, line_height=self.SUBHEADER_LINE_HEIGHT), NSFont.systemFontOfSize_(self.SUBHEADER_SIZE), width, NSPoint(0, height))
     self.addSubview_(label2)
     label2.setAlignment_(NSCenterTextAlignment)
     label2.setTextColor_(self.SUBHEADER_COLOR)
     label2.balancedWrapToWidth_(width)
     label2.centerHorizontallyInSuperview()
     if self.checkbox_text:
         checkbox = NSButton.alloc().initWithFrame_(NSZeroRect)
         self.addSubview_(checkbox)
         checkbox.setButtonType_(NSSwitchButton)
         checkbox.setAttributedTitle_(NSAttributedString.boldify(self.checkbox_text, font=NSFont.systemFontOfSize_(self.CHECKBOX_SIZE), bold_font=NSFont.boldSystemFontOfSize_(self.CHECKBOX_SIZE)))
         checkbox.setTextColor_(Colors.camera_font)
         checkbox.sizeToFit()
         if NSWidth(checkbox.frame()) > width:
             checkbox.setAttributedTitle_(CameraStrings.splash_always_import_no_name)
             checkbox.setTextColor_(Colors.camera_font)
             checkbox.sizeToFit()
         checkbox.setState_(True)
         checkbox.centerHorizontallyInSuperview()
         checkbox.alignBottomInSuperview(self.BORDER - checkbox.flippedBaselineOffset())
         self.checkbox = checkbox
     else:
         self.checkbox = None
     height += NSHeight(label2.frame()) + self.FINE_PRINT_PADDING
     if self.fine_print:
         fine_print = NSTextField.createLabelWithText_font_maxWidth_origin_(self.fine_print, NSFont.systemFontOfSize_(self.FINE_PRINT_SIZE), width, NSPoint(0, height))
         self.addSubview_(fine_print)
         fine_print.setAlignment_(NSCenterTextAlignment)
         fine_print.setTextColor_(Colors.fine_print)
         fine_print.balancedWrapToWidth_(width)
         fine_print.centerHorizontallyInSuperview()
         self.fine_print_label = fine_print
     else:
         self.fine_print_label = None
     self.combo = None
     if self.choice_selector:
         subview = NSView.alloc().initWithFrame_(NSZeroRect)
         combo_descriptor = NSTextField.createLabelWithText_(NSAttributedString.boldify(self.choice_selector.text, font=NSFont.systemFontOfSize_(NSRegularControlSize), bold_font=NSFont.boldSystemFontOfSize_(NSRegularControlSize)))
         combo_descriptor.setTextColor_(self.SUBHEADER_COLOR)
         subview.addSubview_(combo_descriptor)
         combo = NSPopUpButton.createNormalPopUpButtonWithChoices_default_(self.choice_selector.selections, self.choice_selector.default_index)
         combo.sizeToFit()
         subview.addSubview_(combo)
         descriptor_frame = combo_descriptor.frame()
         half = combo.frame().size.height / 2.0
         descriptor_half = descriptor_frame.size.height / 2.0
         combo_descriptor.setFrameOrigin_(NSPoint(descriptor_frame.origin.x, half - descriptor_half + 2.0))
         combo.setFrameOrigin_(NSPoint(descriptor_frame.origin.x + descriptor_frame.size.width, 0))
         subview.setFrameSize_((combo.frame().size.width + descriptor_frame.size.width, combo.frame().size.height))
         self.addSubview_(subview)
         subview.centerHorizontallyInSuperview()
         subview.alignBottomInSuperview(CONTENT_BORDER + self.CHOICE_SELECTOR_PADDING)
         self.combo = combo