| 19 | | placardWidth = self.placard.frame().size[0] |
|---|
| 20 | | scroller = self.horizontalScroller() |
|---|
| 21 | | (x, y), (w, h) = scroller.frame() |
|---|
| 22 | | if w > 0 and h > 0: |
|---|
| 23 | | scroller.setFrame_(((x + placardWidth, y), (w - placardWidth, h))) |
|---|
| 24 | | self.placard.setFrame_(((x, y), (placardWidth, h))) |
|---|
| | 19 | if hasattr(self, "placard"): |
|---|
| | 20 | placardWidth = self.placard.frame().size[0] |
|---|
| | 21 | scroller = self.horizontalScroller() |
|---|
| | 22 | (x, y), (w, h) = scroller.frame() |
|---|
| | 23 | if w > 0 and h > 0: |
|---|
| | 24 | scroller.setFrame_(((x + placardWidth, y), (w - placardWidth, h))) |
|---|
| | 25 | self.placard.setFrame_(((x, y), (placardWidth, h))) |
|---|
| | 117 | |
|---|
| | 118 | # ------------ |
|---|
| | 119 | # PopUp Button |
|---|
| | 120 | # ------------ |
|---|
| | 121 | |
|---|
| | 122 | class DefconAppKitPlacardNSPopUpButtonCell(NSPopUpButtonCell): |
|---|
| | 123 | |
|---|
| | 124 | def drawBorderAndBackgroundWithFrame_inView_(self, frame, view): |
|---|
| | 125 | # draw background |
|---|
| | 126 | try: |
|---|
| | 127 | gradient = NSGradient.alloc().initWithColors_([placardGradientColor1, placardGradientColor2]) |
|---|
| | 128 | gradient.drawInRect_angle_(frame, 90) |
|---|
| | 129 | except NameError: |
|---|
| | 130 | placardGradientColorFallback.set() |
|---|
| | 131 | NSRectFill(frame) |
|---|
| | 132 | # draw border |
|---|
| | 133 | (x, y), (w, h) = frame |
|---|
| | 134 | path = NSBezierPath.bezierPath() |
|---|
| | 135 | path.moveToPoint_((x + w - .5, h)) |
|---|
| | 136 | path.lineToPoint_((x + w - .5, .5)) |
|---|
| | 137 | path.lineToPoint_((x, .5)) |
|---|
| | 138 | path.setLineWidth_(1.0) |
|---|
| | 139 | NSColor.colorWithCalibratedWhite_alpha_(.5, .7).set() |
|---|
| | 140 | path.stroke() |
|---|
| | 141 | # let the super do the rest |
|---|
| | 142 | super(DefconAppKitPlacardNSPopUpButtonCell, self).drawBorderAndBackgroundWithFrame_inView_(frame, view) |
|---|
| | 143 | |
|---|
| | 144 | |
|---|
| | 145 | class PlacardPopUpButton(vanilla.PopUpButton): |
|---|
| | 146 | |
|---|
| | 147 | nsPopUpButtonCellClass = DefconAppKitPlacardNSPopUpButtonCell |
|---|
| | 148 | |
|---|
| | 149 | def __init__(self, posSize, items, **kwargs): |
|---|
| | 150 | super(PlacardPopUpButton, self).__init__(posSize, items, **kwargs) |
|---|
| | 151 | self._nsObject.setBordered_(False) |
|---|
| | 152 | self._nsObject.cell().setGradientType_(NSGradientConvexStrong) |
|---|
| | 153 | |
|---|