Example #1
0
        public new void addWindowsItem_title_filename(NSWindow window, NSString title, bool isFileName)
        {
            Unused.Value = SuperCall(NSApplication.Class, "addWindowsItem:title:filename:", window, title, isFileName);

            // Make directory windows bold.
            NSObject controller = window.windowController();
            if (controller.class_().Name == "DirectoryController")
            {
                NSMenuItem item = DoGetMenuItem(window);
                if (item != null)
                {
                    var dict = NSMutableDictionary.Create();
                    dict.setObject_forKey(NSFont.menuBarFontOfSize(0.0f), Externs.NSFontAttributeName);
                    dict.setObject_forKey(NSNumber.Create(-5.0f), Externs.NSStrokeWidthAttributeName);

                    var str = NSAttributedString.Alloc().initWithString_attributes(title, dict);
                    str.autorelease();
                    item.setAttributedTitle(str);
                }
            }

            // I tried making the path component of reversed paths gray, but it didn't always work and,
            // when it did, it was only for the first window name. Cocoa does adjust the attributes for
            // the menu item when it does things like underline dirty documents and I think that this
            // is resetting the foreground color.
        }
Example #2
0
        public new void updateWindowsItem(NSWindow window)
        {
            Unused.Value = SuperCall(NSApplication.Class, "updateWindowsItem:", window);

            NSWindowController controller = window.windowController();
            NSObject obj = controller;

            // Underline dirty documents.
            if (obj.class_().Name == "TextController")
            {
                NSMenuItem item = DoGetMenuItem(window);
                if (item != null)
                {
                    var dict = NSMutableDictionary.Create();
                    dict.setObject_forKey(NSFont.menuBarFontOfSize(0.0f), Externs.NSFontAttributeName);
                    if (controller.document().isDocumentEdited())		// note that we have to set the title even if the document isn't dirty to clear the underline
                        dict.setObject_forKey(NSNumber.Create(1), Externs.NSUnderlineStyleAttributeName);

                    var str = NSAttributedString.Alloc().initWithString_attributes(item.title(), dict);
                    str.autorelease();
                    item.setAttributedTitle(str);
                }
            }
        }