def drawRect_(self, rect):
     gradient = NSGradient.alloc().initWithColors_([
         NSColor.colorWithDeviceRed_green_blue_alpha_(
             121 / 256.0, 121 / 256.0, 121 / 256.0, 1),
         NSColor.colorWithDeviceRed_green_blue_alpha_(
             111 / 256.0, 111 / 256.0, 111 / 256.0, 1)
     ])
     gradient.drawInRect_angle_(rect, 90.0)
     NSView.drawRect_(self, rect)
Пример #2
0
 def drawRect_(self, rect):
     gradient = NSGradient.alloc().initWithColors_(
                 [NSColor.colorWithDeviceRed_green_blue_alpha_(121/256.0, 121/256.0, 121/256.0, 1),
                  NSColor.colorWithDeviceRed_green_blue_alpha_(111/256.0, 111/256.0, 111/256.0, 1)])
     gradient.drawInRect_angle_(rect, 90.0)
     NSView.drawRect_(self, rect)
Пример #3
0
    def drawRect_(self, rect):
        r = self.bounds()
        r.size.width -= 0.5
        r.size.height += 4
        if self.draggedOut:
            NSColor.colorWithDeviceWhite_alpha_(0.4, 1.0).set()
            path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(r, 5, 5)
            path.fill()
        else:
            if self == self.switcher.activeItem():
                NSColor.controlColor().set()
            else:
                NSColor.colorWithDeviceWhite_alpha_(0.6, 1.0).set()
            path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(r, 5, 5)
            path.fill()
            NSColor.colorWithDeviceRed_green_blue_alpha_(0.3, 0.3, 0.3, 1.0).set()
            path.stroke()

        if self.badgeLabel and not self.mouseInside and not self.busyIndicator and not self.composing:
            # draw the number in redbadge indicator
            gradient = NSGradient.alloc().initWithStartingColor_endingColor_(
                          NSColor.colorWithDeviceRed_green_blue_alpha_(0.9, 0.2, 0.2, 1),
                          NSColor.colorWithDeviceRed_green_blue_alpha_(1.0, 0.2, 0.2, 1))
            size = self.badgeLabel.size()
            size.width += 4
            if size.width < 12:
                size.width = 12
            bez = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(NSMakeRect(3, 5, size.width, 12), 6, 6)
            gradient.drawInBezierPath_angle_(bez, 90+45)
            self.badgeLabel.drawInRect_(NSMakeRect(3, 5, size.width, 12))

        if not self.mouseInside and not self.busyIndicator and self.composing:
            rect = NSZeroRect.copy()
            rect.size = self.composeIcon.size()
            self.composeIcon.drawAtPoint_fromRect_operation_fraction_(NSMakePoint(1, 3), rect, NSCompositeSourceOver, 1)

        if not self.busyIndicator and self.screen_sharing_active:
            rect = NSZeroRect.copy()
            rect.size = self.screenIcon.size()
            self.screenIcon.drawAtPoint_fromRect_operation_fraction_(NSMakePoint(17, 3), rect, NSCompositeSourceOver, 1)

        if not self.draggedOut:
            shadow = NSShadow.alloc().init()
            shadow.setShadowOffset_(NSMakeSize(0, -1))
            if self == self.switcher.activeItem():
                shadow.setShadowColor_(NSColor.whiteColor())
            else:
                shadow.setShadowColor_(NSColor.colorWithDeviceWhite_alpha_(0.7, 1.0))
            para = NSParagraphStyle.defaultParagraphStyle().mutableCopy()
            para.setLineBreakMode_(NSLineBreakByTruncatingTail)
            para.setAlignment_(NSCenterTextAlignment)
            attribs = NSDictionary.dictionaryWithObjectsAndKeys_(NSFont.systemFontOfSize_(11), NSFontAttributeName,
                            shadow, NSShadowAttributeName,
                            para, NSParagraphStyleAttributeName)

            rect = self.bounds()
            rect.origin.y -= 3
            rect.origin.x += 20
            rect.origin.x = rect.origin.x + 12 if self.screen_sharing_active else rect.origin.x
            rect.size.width -= 46
            rect.size.width = rect.size.width - 12 if self.screen_sharing_active else rect.size.width
            self.label.drawInRect_withAttributes_(rect, attribs)
Пример #4
0
    def drawRect_(self, rect):
        rect = NSInsetRect(self.bounds(), 1.5, 1.5)
        if not self.conferencing:
            NSColor.whiteColor().set()
            path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(
                rect, 5.0, 5.0)
            path.fill()

        if self.conferencing:
            if self.draggedOut:
                NSColor.whiteColor().set()
            else:
                # bgcolor for conference area
                NSColor.colorWithDeviceRed_green_blue_alpha_(
                    196 / 255.0, 230 / 255.0, 254 / 255.0, 1.0).set()
            border = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(
                rect, 5.0, 5.0)
            border.setLineWidth_(1)
            border.fill()
            NSColor.grayColor().set()
            border.stroke()

            # hack: if we're the 1st item, draw the border around all conferenced boxes
            subviews = self.superview().subviews()
            if subviews.objectAtIndex_(0) == self:
                # first in conference list
                rect.size.height += 5
                rect.origin.y -= 5
                path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(
                    rect, 5.0, 5.0)
            else:
                prev = None
                last = True
                for view in subviews:
                    if prev == self:
                        last = not view.conferencing
                        break
                    prev = view
                # last in conference list
                if last:
                    rect.size.height += 5
                    path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(
                        rect, 5.0, 5.0)
                else:
                    rect.origin.y -= 5
                    rect.size.height += 10
                    path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(
                        rect, 5.0, 5.0)

            if self.selected or self.highlighted:
                path.setLineWidth_(3)
            else:
                path.setLineWidth_(1)
            if self.highlighted:
                NSColor.orangeColor().set()
            else:
                NSColor.grayColor().set()
            if self.selected or self.highlighted:
                path.stroke()
        elif self.highlighted:
            path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(
                rect, 5.0, 5.0)
            path.setLineWidth_(3)
            NSColor.orangeColor().set()
            path.stroke()
        elif self.selected:
            path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(
                rect, 5.0, 5.0)
            path.setLineWidth_(3)
            NSColor.grayColor().set()
            path.stroke()
        else:
            path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(
                rect, 5.0, 5.0)
            path.setLineWidth_(1)
            NSColor.grayColor().set()
            path.stroke()
    def drawRect_(self, rect):
        r = self.bounds()
        r.size.width -= 0.5
        r.size.height += 4
        if self.draggedOut:
            NSColor.colorWithDeviceWhite_alpha_(0.4, 1.0).set()
            path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(
                r, 5, 5)
            path.fill()
        else:
            if self == self.switcher.activeItem():
                NSColor.controlColor().set()
            else:
                NSColor.colorWithDeviceWhite_alpha_(0.6, 1.0).set()
            path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(
                r, 5, 5)
            path.fill()
            NSColor.colorWithDeviceRed_green_blue_alpha_(0.3, 0.3, 0.3,
                                                         1.0).set()
            path.stroke()

        if self.badgeLabel and not self.mouseInside and not self.busyIndicator and not self.composing:
            # draw the number in redbadge indicator
            gradient = NSGradient.alloc().initWithStartingColor_endingColor_(
                NSColor.colorWithDeviceRed_green_blue_alpha_(0.9, 0.2, 0.2, 1),
                NSColor.colorWithDeviceRed_green_blue_alpha_(1.0, 0.2, 0.2, 1))
            size = self.badgeLabel.size()
            size.width += 4
            if size.width < 12:
                size.width = 12
            bez = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(
                NSMakeRect(3, 5, size.width, 12), 6, 6)
            gradient.drawInBezierPath_angle_(bez, 90 + 45)
            self.badgeLabel.drawInRect_(NSMakeRect(3, 5, size.width, 12))

        if not self.mouseInside and not self.busyIndicator and self.composing:
            rect = NSZeroRect.copy()
            rect.size = self.composeIcon.size()
            self.composeIcon.drawAtPoint_fromRect_operation_fraction_(
                NSMakePoint(1, 3), rect, NSCompositeSourceOver, 1)

        if not self.busyIndicator and self.screen_sharing_active:
            rect = NSZeroRect.copy()
            rect.size = self.screenIcon.size()
            self.screenIcon.drawAtPoint_fromRect_operation_fraction_(
                NSMakePoint(17, 3), rect, NSCompositeSourceOver, 1)

        if not self.draggedOut:
            shadow = NSShadow.alloc().init()
            shadow.setShadowOffset_(NSMakeSize(0, -1))
            if self == self.switcher.activeItem():
                shadow.setShadowColor_(NSColor.whiteColor())
            else:
                shadow.setShadowColor_(
                    NSColor.colorWithDeviceWhite_alpha_(0.7, 1.0))
            para = NSParagraphStyle.defaultParagraphStyle().mutableCopy()
            para.setLineBreakMode_(NSLineBreakByTruncatingTail)
            para.setAlignment_(NSCenterTextAlignment)
            attribs = NSDictionary.dictionaryWithObjectsAndKeys_(
                NSFont.systemFontOfSize_(11), NSFontAttributeName, shadow,
                NSShadowAttributeName, para, NSParagraphStyleAttributeName)

            rect = self.bounds()
            rect.origin.y -= 3
            rect.origin.x += 20
            rect.origin.x = rect.origin.x + 12 if self.screen_sharing_active else rect.origin.x
            rect.size.width -= 46
            rect.size.width = rect.size.width - 12 if self.screen_sharing_active else rect.size.width
            self.label.drawInRect_withAttributes_(rect, attribs)
Пример #6
0
    def drawRect_(self, rect):
        rect = NSInsetRect(self.bounds(), 1.5, 1.5)
        if not self.conferencing:
            NSColor.whiteColor().set()
            path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0)
            path.fill()

        if self.conferencing:
            if self.draggedOut:
                NSColor.whiteColor().set()
            else:
                # bgcolor for conference area
                NSColor.colorWithDeviceRed_green_blue_alpha_(196/255.0, 230/255.0, 254/255.0, 1.0).set()
            border = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0)
            border.setLineWidth_(1)
            border.fill()
            NSColor.grayColor().set()
            border.stroke()

            # hack: if we're the 1st item, draw the border around all conferenced boxes
            subviews = self.superview().subviews()
            if subviews.objectAtIndex_(0) == self:
                # first in conference list
                rect.size.height += 5
                rect.origin.y -= 5
                path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0)
            else:
                prev = None
                last = True
                for view in subviews:
                    if prev == self:
                        last = not view.conferencing
                        break
                    prev = view
                # last in conference list
                if last:
                    rect.size.height += 5
                    path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0)
                else:
                    rect.origin.y -= 5
                    rect.size.height += 10
                    path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0)

            if self.selected or self.highlighted:
                path.setLineWidth_(3)
            else:
                path.setLineWidth_(1)
            if self.highlighted:
                NSColor.orangeColor().set()
            else:
                NSColor.grayColor().set()
            if self.selected or self.highlighted:
                path.stroke()
        elif self.highlighted:
            path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0)
            path.setLineWidth_(3)
            NSColor.orangeColor().set()
            path.stroke()
        elif self.selected:
            path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0)
            path.setLineWidth_(3)
            NSColor.grayColor().set()
            path.stroke()
        else:
            path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0)
            path.setLineWidth_(1)
            NSColor.grayColor().set()
            path.stroke()