def initWithFrame_(self, frame):
        self = NSView.initWithFrame_(self, frame)
        if self:
            self.items = []

            self.leftButton = NSButton.alloc().initWithFrame_(
                NSMakeRect(0, 0, 20, 20))
            self.leftButton.setTarget_(self)
            self.leftButton.setAction_("scrollLeft:")
            self.leftButton.setImage_(
                NSImage.imageNamed_("NSLeftFacingTriangleTemplate"))
            self.leftButton.setHidden_(True)
            self.leftButton.cell().setBezelStyle_(NSShadowlessSquareBezelStyle)
            self.addSubview_(self.leftButton)

            self.rightButton = NSButton.alloc().initWithFrame_(
                NSMakeRect(0, 0, 20, 20))
            self.rightButton.setTarget_(self)
            self.rightButton.setAction_("scrollRight:")
            self.rightButton.setImage_(
                NSImage.imageNamed_("NSRightFacingTriangleTemplate"))
            self.rightButton.setHidden_(True)
            self.rightButton.cell().setBezelStyle_(
                NSShadowlessSquareBezelStyle)
            self.addSubview_(self.rightButton)

        return self
Exemplo n.º 2
0
    def _NH_BlinkFileTransferNewOutgoing(self, sender, data):
        try:
            item = next((item for item in self.listView.subviews().copy()
                         if item.file_path == sender.ft_info.file_path
                         and item.remote_uri == sender.ft_info.remote_uri))
            item.replaceWithTransfer_(sender)
            self.listView.relayout()

        except StopIteration:
            item = FileTransferItemView.alloc().initWithFrame_transfer_(
                NSMakeRect(0, 0, 100, 100), sender)
            self.listView.addItemView_(item)
            h = NSHeight(self.listView.frame())
            self.listView.scrollRectToVisible_(NSMakeRect(0, h - 1, 100, 1))

        file_path = sender.ft_info.file_path.decode() if isinstance(
            sender.ft_info.file_path, bytes) else sender.ft_info.file_path
        if 'screencapture' not in file_path:
            self.window.orderFront_(None)

        count = len(self.listView.subviews())
        if count == 1:
            self.bottomLabel.setStringValue_(
                NSLocalizedString("1 item", "Label"))
        else:
            self.bottomLabel.setStringValue_(
                NSLocalizedString("%i items", "Label") % count)
Exemplo n.º 3
0
    def __init__(self, message='', title='', default_text='', ok=None, cancel=None, dimensions=(320, 160),
                 secure=False):
        message = text_type(message)
        message = message.replace('%', '%%')
        title = text_type(title)

        self._cancel = bool(cancel)
        self._icon = None

        _internal.require_string_or_none(ok)
        if not isinstance(cancel, string_types):
            cancel = 'Cancel' if cancel else None

        self._alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
            title, ok, cancel, None, message)
        self._alert.setAlertStyle_(0)  # informational style

        if secure:
            self._textfield = NSSecureTextField.alloc().initWithFrame_(NSMakeRect(0, 0, *dimensions))
        else:
            self._textfield = NSTextField.alloc().initWithFrame_(NSMakeRect(0, 0, *dimensions))
        self._textfield.setSelectable_(True)
        self._alert.setAccessoryView_(self._textfield)

        self.default_text = default_text
Exemplo n.º 4
0
    def show(self):
        BlinkLogger().log_debug('Show %s' % self)
        aspect_ratio = self.videoView.aspect_ratio
        self.visible = True
        self.videoView.show()

        if self.close_timer is not None and self.close_timer.isValid():
            self.close_timer.invalidate()
            self.close_timer = None

        self.window().setAlphaValue_(ALPHA)
        userdef = NSUserDefaults.standardUserDefaults()
        savedFrame = userdef.stringForKey_(self.window().frameAutosaveName())

        if savedFrame:
            x, y, w, h = str(savedFrame).split()[:4]
            frame = NSMakeRect(int(x), int(y), int(w), int(h))
            self.window().setFrame_display_(frame, True)

        frame = self.window().frame()
        currentSize = frame.size
        scaledSize = currentSize

        if aspect_ratio is not None:
            scaledSize.height = scaledSize.width / aspect_ratio
            frame.size = scaledSize
            self.window().setFrame_display_animate_(frame, True, False)
        self.window().orderFront_(None)
Exemplo n.º 5
0
    def render_previous_transfers(self, transfers):
        last_displayed_item = self.listView.subviews().lastObject()

        for transfer in transfers:
            item = FileTransferItemView.alloc().initWithFrame_oldTransfer_(
                NSMakeRect(0, 0, 100, 100), transfer)
            if last_displayed_item:
                self.listView.insertItemView_before_(item, last_displayed_item)
            else:
                self.listView.addItemView_(item)

            self.listView.relayout()
            self.listView.display()
            h = self.listView.minimumHeight()
            self.listView.scrollRectToVisible_(NSMakeRect(0, h - 1, 100, 1))

        count = len(self.listView.subviews())
        if count == 1:
            self.bottomLabel.setStringValue_(
                NSLocalizedString("1 item", "Label"))
        else:
            self.bottomLabel.setStringValue_(
                NSLocalizedString("%i items", "Label") %
                count if count else "")

        self.loaded = True
Exemplo n.º 6
0
 def drawIcon(self, icon, origin_x, origin_y, size_x, size_y):
     size = icon.size()
     if not size or not size.height:
         return
     rect = NSMakeRect(0, 0, size.width, size.height)
     trect = NSMakeRect(origin_x, origin_y,
                        (size_y / size.height) * size.width, size_x)
     icon.drawInRect_fromRect_operation_fraction_respectFlipped_hints_(
         trect, rect, NSCompositeSourceOver, 1.0, True, None)
Exemplo n.º 7
0
    def setCropSize_(self, size=None):
        if size is None:
            self.cropRectangle = self.frame()
        elif size == 'default':
            self.cropRectangle = NSMakeRect(0, 0, 220, 220)
        else:
            self.cropRectangle = NSMakeRect(0, 0, size, size)

        self.cropRectangle.origin.x = 0
        self.cropRectangle.origin.y = 0
        self.setNeedsDisplay_(True)
    def __init__(self, videoWindowController):
        self.videoWindowController = videoWindowController
        self.log_debug('Init %s' % self)
        if self.finished:
            self._finish_close()
            return
        
        from VideoWindowController import TitleBarView

        NSBundle.loadNibNamed_owner_("VideoLocalWindow", self)
        self.window().center()
        title = NSLocalizedString("Video with %s", "Window title") % self.videoWindowController.title
        NSApplication.sharedApplication().addWindowsItem_title_filename_(self.window(), title, False)
        self.window().setTitle_(title)
        self.window().setLevel_(NSFloatingWindowLevel)
        themeFrame = self.window().contentView().superview()
        self.titleBarView = LocalTitleBarView.alloc().init()
        topmenu_frame = self.titleBarView.view.frame()
        self.disconnectLabel.superview().hide()

        newFrame = NSMakeRect(
                                0,
                                themeFrame.frame().size.height - topmenu_frame.size.height,
                                themeFrame.frame().size.width,
                                topmenu_frame.size.height)

        self.titleBarView.view.setFrame_(newFrame)
        themeFrame.addSubview_(self.titleBarView.view)
        self.titleBarView.textLabel.setHidden_(False)
        self.updateTrackingAreas()
        
        self.videoView.setProducer(SIPApplication.video_device.producer)
        self.notification_center =  NotificationCenter()
        self.notification_center.add_observer(self, name="VideoDeviceDidChangeCamera")
Exemplo n.º 9
0
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()
Exemplo n.º 10
0
 def drawSecondLine(self):
     frame = self.frame
     frame.origin.y += 15
     if self.contact.detail:
         rect = NSMakeRect(frame.origin.x, frame.origin.y,
                           frame.size.width - 25, frame.size.height)
         attrs = self.secondLineAttributes if not self.isHighlighted(
         ) else self.secondLineAttributes_highlighted
         self.contact.detail.drawInRect_withAttributes_(rect, attrs)
Exemplo n.º 11
0
    def initWithSwitcher_item_(self, switcher, item):
        self = NSView.initWithFrame_(self, NSMakeRect(0, 2, 100, 18))
        if self:
            self.closeIcon.setSize_(NSMakeSize(12, 12))
            self.closeButton = NSButton.alloc().initWithFrame_(
                NSMakeRect(3, 5, 12, 14))
            self.closeButton.setImagePosition_(NSImageOnly)
            self.closeButton.setButtonType_(NSMomentaryChangeButton)
            self.closeButton.cell().setBezelStyle_(NSSmallSquareBezelStyle)
            self.closeButton.setBordered_(False)
            self.closeButton.setImage_(self.closeIcon)
            self.closeButton.setAutoresizingMask_(NSViewMaxXMargin
                                                  | NSViewMaxYMargin)
            self.closeButton.setHidden_(True)
            self.addSubview_(self.closeButton)

            self.switcher = switcher
            self.item = item
        return self
Exemplo n.º 12
0
    def rearrange(self):
        if not self.items:
            return

        frame = self.frame()
        x = 5
        h = NSHeight(frame)

        if len(self.items) * MIN_TAB_WIDTH > NSWidth(frame) - 15 - 20:
            # some tabs don't fit, show what we can
            self.fitTabCount = max(
                int(NSWidth(frame) - 15 - 40) / MIN_TAB_WIDTH, 1)
            tab_width = int(NSWidth(frame) - 15 - 40) / self.fitTabCount

            self.leftButton.setFrame_(NSMakeRect(0, 3, 24, 20))
            self.rightButton.setFrame_(
                NSMakeRect(NSWidth(frame) - 31, 3, 24, 20))
            self.leftButton.setHidden_(False)
            self.rightButton.setHidden_(False)

            x += 20
            for item in self.items[self.firstVisible:self.firstVisible +
                                   self.fitTabCount]:
                item.setHidden_(False)
                item.setFrame_(NSMakeRect(x, 2, tab_width, h))
                x += tab_width

            for item in self.items[self.firstVisible + self.fitTabCount:]:
                item.setHidden_(True)

            for item in self.items[:self.firstVisible]:
                item.setHidden_(True)

        else:
            self.leftButton.setHidden_(True)
            self.rightButton.setHidden_(True)

            tab_width = min(TAB_WIDTH, (NSWidth(frame) - 15) / len(self.items))
            for item in self.items:
                w = tab_width
                item.setFrame_(NSMakeRect(x, 2, w, h))
                item.setHidden_(False)
                x += w
Exemplo n.º 13
0
    def drawFirstLine(self):
        frame = self.frame
        frame.origin.x = 35
        frame.origin.y += 2

        rect = NSMakeRect(frame.origin.x, frame.origin.y,
                          frame.size.width - 10, frame.size.height)
        attrs = self.firstLineAttributes if not self.isHighlighted(
        ) else self.firstLineAttributes_highlighted
        self.stringValue().drawInRect_withAttributes_(rect, attrs)
Exemplo n.º 14
0
  def bounds(self):
    minx, maxx, miny, maxy = None, None, None, None
    if len(self) < 1: return None
    for p in self.nodes:
      pos = p.position
      if minx == None or pos.x < minx: minx = pos.x
      if maxx == None or pos.x > maxx: maxx = pos.x
      if miny == None or pos.y < minx: miny = pos.y
      if maxy == None or pos.y > maxx: maxy = pos.y

    return NSMakeRect(minx, miny, maxx-minx, maxy-miny)
Exemplo n.º 15
0
    def getCropped(self):
        image = self.image()

        cropped = NSImage.alloc().initWithSize_(self.cropRectangle.size)
        cropped.lockFocus()

        image.drawInRect_fromRect_operation_fraction_(
            NSMakeRect(0, 0, NSWidth(self.cropRectangle),
                       NSHeight(self.cropRectangle)), self.cropRectangle,
            NSCompositeCopy, 1.0)
        cropped.unlockFocus()
        return cropped
Exemplo n.º 16
0
def openNotices():
    global notices
    if not notices:
        notices = NSWindow.alloc()
        rect = Foundation.NSMakeRect(100,100,570,800)
        styleMask = NSTitledWindowMask | NSClosableWindowMask | \
            NSResizableWindowMask | NSMiniaturizableWindowMask
        notices.initWithContentRect_styleMask_backing_defer_(rect, styleMask, NSBackingStoreBuffered, False)
        notices.setFrameTopLeftPoint_( NSPoint(300, NSHeight(notices.screen().frame()) - 200) )
        notices.setTitle_('Otto Notices')
        #notices.setFrameAutosaveName_('noticesWindow')

        scrollview = NSScrollView.alloc().initWithFrame_(notices.contentView().frame())
        contentSize = scrollview.contentSize()
 
        scrollview.setBorderType_(NSNoBorder)
        scrollview.setHasVerticalScroller_(True)
        scrollview.setHasHorizontalScroller_(False)
        scrollview.setAutoresizingMask_(NSViewWidthSizable | NSViewHeightSizable)

        textview = NSTextView.alloc()
        textview.initWithFrame_( NSMakeRect(0, 0, contentSize.width, contentSize.height) )
        textview.setMaxSize_(NSMakeSize(FLT_MAX, FLT_MAX))
        textview.setVerticallyResizable_(True)
        textview.setHorizontallyResizable_(False)
        textview.setAutoresizingMask_(NSViewWidthSizable)
        textview.textContainer().setContainerSize_(NSMakeSize(contentSize.width, FLT_MAX))
        textview.textContainer().setWidthTracksTextView_(True)
        textview.setEditable_(False)
        textview.setSelectable_(True)
        #textview.setBackgroundColor_(NSColor.blueColor())

        scrollview.setDocumentView_(textview)

        respath = os.environ['RESOURCEPATH']
        try:
            with codecs.open( os.path.join(respath, 'THIRD-PARTY-NOTICES'), 'r', 'utf-8') as f:
                noticestext = f.read()
        except IOError:
            noticestext = 'Could not read THIRD-PARTY-NOTICES file.'
        storage = textview.textStorage()
        nsstring = NSAttributedString.alloc().initWithString_(noticestext)
        storage.insertAttributedString_atIndex_(nsstring, 0)

        notices.setReleasedWhenClosed_(False)
        notices.setContentView_(scrollview)

    #if not notices.isVisible():
    #  notices.center()
    #  #notices.display()
    notices.orderFrontRegardless()
    notices.makeKeyAndOrderFront_(None)
    def updateIcon(self, icon):
        image = NSImage.alloc().initWithSize_(NSMakeSize(48, 48))
        image.lockFocus()
        size = icon.size()
        icon.drawAtPoint_fromRect_operation_fraction_(
            NSMakePoint((48 - size.width) / 2, (48 - size.height) / 2),
            NSMakeRect(0, 0, size.width, size.height), NSCompositeSourceOver,
            1)

        # overlay file transfer direction icon
        if type(self.transfer) == OutgoingPushFileTransferHandler or (
                self.oldTransferInfo
                and self.oldTransferInfo.direction == "outgoing"):
            icon = NSImage.imageNamed_("outgoing_file")
        else:
            icon = NSImage.imageNamed_("incoming_file")
        icon.drawAtPoint_fromRect_operation_fraction_(
            NSMakePoint(2, 4), NSMakeRect(0, 0, size.width, size.height),
            NSCompositeSourceOver, 1)
        image.unlockFocus()

        self.icon.setImage_(image)
Exemplo n.º 18
0
 def __init__(self, **kwds):
     width, height = default_size
     ns_frame = NSMakeRect(0, 0, width, height)
     ns_tableview = PyNSTableView.alloc().initWithFrame_(ns_frame)
     ns_tableview.pygui_component = self
     ns_tableview.setColumnAutoresizingStyle_(0)
     ns_scrollview = NSScrollView.alloc().initWithFrame_(ns_frame)
     ns_scrollview.setDocumentView_(ns_tableview)
     ns_scrollview.setAutoresizingMask_(ns_table_autoresizing_mask)
     GTableView.__init__(self,
                         _ns_view=ns_scrollview,
                         _ns_inner_view=ns_tableview)
     self.set(**kwds)
     ns_tableview.setDataSource_(ns_tableview)
Exemplo n.º 19
0
class ScrollableView(GScrollableView):

    _ns_scrollable = True

    def __init__(self,
                 extent=default_extent,
                 line_scroll_amount=default_line_scroll_amount,
                 scrolling=default_scrolling,
                 **kwds):
        GScrollableView.__init__(self,
                                 extent=extent,
                                 line_scroll_amount=line_scroll_amount,
                                 scrolling=scrolling,
                                 **kwds)

    def get_hscrolling(self):
        return self._ns_view.hasHorizontalScroller()

    def set_hscrolling(self, value):
        self._ns_view.setHasHorizontalScroller_(value)

    def get_vscrolling(self):
        return self._ns_view.hasVerticalScroller()

    def set_vscrolling(self, value):
        self._ns_view.setHasVerticalScroller_(value)

#	def get_extent(self):
#		(l, t), (w, h) = self._ns_inner_view.bounds()
#		return (l, t, l + w, t + h)

    def get_extent(self):
        return self._ns_inner_view.bounds().size


#	def set_extent(self, (l, t, r, b)):
#		w = r - l
#		h = b - t
#		ns_docview = self._ns_inner_view
#		ns_docview.setFrame_(NSMakeRect(0, 0, w, h))
#		ns_docview.setBounds_(NSMakeRect(l, t, w, h))
#		self.invalidate()

    def set_extent(self, (w, h)):
        r = NSMakeRect(0, 0, w, h)
        ns_docview = self._ns_inner_view
        ns_docview.setFrame_(r)
        ns_docview.setBounds_(r)
        self.invalidate()
Exemplo n.º 20
0
 def __init__(self, **kwds):
     width, height = default_size
     ns_frame = NSMakeRect(0, 0, width, height)
     ns_inner_view = PyGUI_User_NSView.alloc().initWithFrame_(ns_frame)
     if self._ns_scrollable:
         ns_view = NSScrollView.alloc().initWithFrame_(ns_frame)
         ns_view.setDocumentView_(ns_inner_view)
         ns_view.setBackgroundColor_(ns_gray)
     else:
         ns_view = ns_inner_view
     ns_inner_view.pygui_component = self
     GDrawableContainer.__init__(self,
                                 _ns_view=ns_view,
                                 _ns_inner_view=ns_inner_view)
     self.set(**kwds)
Exemplo n.º 21
0
    def reorderByPosition_(self, sender):
        def centerx(rect):
            return rect.origin.x + rect.size.width / 2

        self.items.sort(
            key=lambda a, b: int(centerx(a.frame()) - centerx(b.frame())))

        frame = self.frame()
        x = 5
        h = NSHeight(frame)
        for item in self.items:
            w = item.idealWidth()
            if item != sender:
                item.setFrame_(NSMakeRect(x, 2, w, h))
            x += w
Exemplo n.º 22
0
    def __init__(self, message, title='', default_text='', ok=None, cancel=False, dimensions=(320, 160)):
        message = str(message)
        title = str(title)
        self._default_text = default_text
        self._cancel = bool(cancel)
        self._icon = None

        self._alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
            title, ok, 'Cancel' if cancel else None, None, message)
        self._alert.setAlertStyle_(0)  # informational style

        self._textfield = NSTextField.alloc().initWithFrame_(NSMakeRect(0, 0, *dimensions))
        self._textfield.setSelectable_(True)
        if default_text:
            self._textfield.setStringValue_(default_text)
        self._alert.setAccessoryView_(self._textfield)
Exemplo n.º 23
0
 def __init__(self):
     text = "Python " + sys.version + "\n\n" + sys.copyright
     title = "HalfCaff " + halfcaff.version.version
     if halfcaff.util.is_dev_mode():
         title += '-dev'
     super(AboutWindow, self).__init__(title=title,
                                       message=_message,
                                       default_text=_text)
     self.icon = halfcaff.util.icon('halfcaff.icns')
     #self._textfield.dealloc()
     self._textfield = NSTextView.alloc().initWithFrame_(
         NSMakeRect(0, 0, 320, 160))
     self._textfield.setSelectable_(True)
     #self._textfield.usesRuler_(True)
     self._alert.setAccessoryView_(self._textfield)
     self._textfield.setString_(rumps.compat.text_type(_text))
Exemplo n.º 24
0
 def updateDockTile(self):
     if self.missedCalls > 0 or self.missedChats > 0:
         icon = NSImage.imageNamed_("Blink")
         image = NSImageView.alloc().initWithFrame_(NSMakeRect(0, 0, 32, 32))
         image.setImage_(icon)
         if self.missedCalls > 0 and self.missedChats > 0:
             NSApp.dockTile().setBadgeLabel_("%i / %i" % (self.missedCalls, self.missedChats))
         else:
             NSApp.dockTile().setBadgeLabel_("%i" % (self.missedCalls + self.missedChats))
         NSApp.dockTile().setContentView_(image)
     else:
         NSApp.dockTile().setBadgeLabel_("")
         NSApp.dockTile().setContentView_(None)
         icon = None
     NSApp.setApplicationIconImage_(icon)
     NSApp.dockTile().display()
Exemplo n.º 25
0
def drawrect(x1, y1, x2, y2, fillcolour, strokecolour, strokewidth, dashed,
             rounded):
    Rect = NSMakeRect(x1, y1, x2 - x1, y2 - y1)
    Path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(
        Rect, rounded, rounded)
    if fillcolour:
        NSColor.colorWithDeviceCyan_magenta_yellow_black_alpha_(
            fillcolour[0], fillcolour[1], fillcolour[2], fillcolour[3],
            1).set()
        Path.fill()
    if strokecolour:
        Path.setLineWidth_(strokewidth)
        if dashed:
            Path.setLineDash_count_phase_(dashed, 2, 0.0)
        NSColor.colorWithDeviceCyan_magenta_yellow_black_alpha_(
            strokecolour[0], strokecolour[1], strokecolour[2], strokecolour[3],
            1).set()
        Path.stroke()
Exemplo n.º 26
0
 def setBusy_(self, flag):
     if flag:
         if not self.busyIndicator:
             self.busyIndicator = NSProgressIndicator.alloc(
             ).initWithFrame_(NSMakeRect(3, 4, 15, 15))
             self.busyIndicator.setControlSize_(NSSmallControlSize)
             self.busyIndicator.setIndeterminate_(True)
             self.busyIndicator.setStyle_(NSProgressIndicatorSpinningStyle)
             self.busyIndicator.startAnimation_(None)
             self.busyIndicator.setAutoresizingMask_(NSViewMaxXMargin
                                                     | NSViewMaxYMargin)
             self.addSubview_(self.busyIndicator)
             self.closeButton.setHidden_(True)
     else:
         if self.busyIndicator:
             self.busyIndicator.stopAnimation_(None)
             self.busyIndicator.removeFromSuperview()
             self.busyIndicator = None
             self.closeButton.setHidden_(not self.mouseInside)
Exemplo n.º 27
0
    def preferences(self, _):
        if 'prefController' not in self.__dict__:
            # Initialize preference window
            rect = NSMakeRect(0, 0, 500, 500)
            window = NSWindow.alloc(
            ).initWithContentRect_styleMask_backing_defer_(
                rect, NSTitledWindowMask | NSClosableWindowMask,
                NSBackingStoreBuffered, False)
            window.setTitle_('Preference')
            window.center()
            self.prefController = PreferenceController.alloc().initWithWindow_(
                window)
            self.prefController.window().makeKeyWindow()
            # self.prefController.window().setLevel_(NSFloatingWindowLevel)
            self.prefController.window().orderFront_(self)
            self.prefController.setSettingChangedCallback_withArgs_(
                self.reloadSettings, [])

        if not self.prefController.window().isVisible():
            self.prefController.window().makeKeyAndOrderFront_(self)
Exemplo n.º 28
0
    def mouseDragged_(self, event):
        if self.cropRectangle and self.dragPos:
            p = self.convertPoint_fromView_(event.locationInWindow(), None)
            dx = self.dragPos.x - p.x
            dy = self.dragPos.y - p.y

            newRect = NSMakeRect(self.initialPos.x - dx,
                                 self.initialPos.y - dy,
                                 NSWidth(self.cropRectangle),
                                 NSHeight(self.cropRectangle))
            if NSMinX(newRect) < 0:
                newRect.origin.x = 0
            if NSMinY(newRect) < 0:
                newRect.origin.y = 0
            if NSMaxX(newRect) > NSWidth(self.frame()):
                newRect.origin.x = NSWidth(self.frame()) - NSWidth(newRect)
            if NSMaxY(newRect) > NSHeight(self.frame()):
                newRect.origin.y = NSHeight(self.frame()) - NSHeight(newRect)
            self.cropRectangle = newRect
            self.setNeedsDisplay_(True)
Exemplo n.º 29
0
 def __init__(self, config=None, share_group=None, **kwds):
     pf = GLConfig._from_args(config, kwds)
     ns_pf = pf._ns_get_pixel_format()
     width, height = GGLView._default_size
     ns_rect = NSMakeRect(0, 0, width, height)
     ns_view = _PyGUI_NSOpenGLView.alloc().initWithFrame_pixelFormat_(
         ns_rect, ns_pf)
     ns_view.pygui_component = self
     GGLView.__init__(self, _ns_view=ns_view)
     GLContext.__init__(self,
                        share_group=share_group,
                        _ns_pixel_format=ns_pf)
     ns_context = self._ns_context
     ns_view.setOpenGLContext_(ns_context)
     #ns_context.setView_(ns_view) # Docs say this is needed, but
     # prints warning and seems to work without.
     if pf.double_buffer:
         self._ns_flush = ns_context.flushBuffer
     else:
         self._ns_flush = glFlush
     self.set(**kwds)
     self.with_context(self._init_context)
Exemplo n.º 30
0
def DrawTableLines(list, colour, thickness):

    global myDialog
    for i, point in enumerate(list):

        try:
            drawline(list[i][1] * mm, list[i][2] * mm, list[i + 1][1] * mm,
                     list[i + 1][2] * mm, colour, thickness, None)
        except:
            pass

        NSColor.colorWithDeviceCyan_magenta_yellow_black_alpha_(
            colour[0], colour[1], colour[2], colour[3], 1).set()
        Rect = NSMakeRect(point[1] * mm - (thickness),
                          point[2] * mm - (thickness), thickness * 2,
                          thickness * 2)
        NSBezierPath.bezierPathWithOvalInRect_(Rect).fill()
        if Glyphs.boolDefaults["com_yanone_Autopsy_drawpointsvalues"]:
            DrawText(pdffont['Regular'], pointsvaluefontsize, glyphcolour,
                     point[1] * mm + (thickness / 6 + 1) * mm,
                     point[2] * mm - (thickness / 6 + 2.5) * mm,
                     str(int(round(point[0]))))