示例#1
0
    public void BadStruct()
    {
        NSObject str = new Class("NSString").Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto("the quick brown fox")).To<NSObject>();

        NSRect r = new NSRect();
        str.Call("substringWithRange:", r);
    }
示例#2
0
        public WarningWindow()
        {
            // Interface Builder won't allow us to create a window with no title bar
            // so we have to create it manually. But we could use IB if we display
            // the window with a sheet...
            NSRect rect = new NSRect(0, 0, 460, 105);
            m_window = NSWindow.Alloc().initWithContentRect_styleMask_backing_defer(rect, 0, Enums.NSBackingStoreBuffered, false);

            m_window.setHasShadow(false);

            // Initialize the text attributes.
            var dict = NSMutableDictionary.Create();

            NSFont font = NSFont.fontWithName_size(NSString.Create("Georgia"), 64.0f);
            dict.setObject_forKey(font, Externs.NSFontAttributeName);

            NSMutableParagraphStyle style = NSMutableParagraphStyle.Create();
            style.setAlignment(Enums.NSCenterTextAlignment);
            dict.setObject_forKey(style, Externs.NSParagraphStyleAttributeName);

            m_attrs = dict.Retain();

            // Initialize the background bezier.
            m_background = NSBezierPath.Create().Retain();
            m_background.appendBezierPathWithRoundedRect_xRadius_yRadius(m_window.contentView().bounds(), 20.0f, 20.0f);

            m_color = NSColor.colorWithDeviceRed_green_blue_alpha(250/255.0f, 128/255.0f, 114/255.0f, 1.0f).Retain();

            ActiveObjects.Add(this);
        }
		public override void drawRect(NSRect dirtyRect)
		{
			NSRect f = this.bounds();
			//  DEFINED: START ()  0.8
			//  DEFINED: END ()  0.9
			NSImage i = TPSlightGradientBackgroundView.createGradientImageWidth(f.size.width) height(f.size.height) fromColor(NSColor.colorWithCalibratedRed(0.8D) green(0.8D) blue(0.8D) alpha(1D)) toColor(NSColor.colorWithCalibratedRed(0.9D) green(0.9D) blue(0.9D) alpha(1D));
			i.drawInRect(f) fromRect(f) operation(NSCompositeCopy) fraction(1D);
		}
示例#4
0
        public new void setFrame_display(NSRect frame, bool display)
        {
            // Do the default sizing.
            this.SuperCall(NSWindow.Class, "setFrame:display:", frame, display);

            // Constrain the result to the screen.
            NSRect current = this.frame();
            NSRect constrained = DoConstrainToScreen(current);
            if (constrained != current)
                this.SuperCall(NSWindow.Class, "setFrame:display:", constrained, display);
        }
示例#5
0
        // This is called by our parent's window_willPositionSheet_usingRect method.
        public NSRect positionSheet(NSRect usingRect)
        {
            // This will center the sheet on the text we're completing. It might
            // be better to align the left side of the sheet on the text instead,
            // but this seems tricky to do.
            float x = m_loc.x;

            return new NSRect(
                x,						// this is the origin of the sheet in parent window coordinates
                m_loc.y - 4.0f,
                0.0f,					// if this is smaller then the window the sheet genies out, else it slides out
                0.0f);					// this is reserved
        }
示例#6
0
        public new void drawRect(NSRect dirtyRect)
        {
            SuperCall(NSTextView.Class, "drawRect:", dirtyRect);

            if (m_boss != null)
            {
                var overlay = m_boss.Get<ITextOverlay>();
                if (overlay.Text != null)
                {
                    NSRect rect = visibleRect();
                    DoCacheOverlay(overlay, rect);

                    if (m_overlay != null)
                    {
                        NSPoint center = rect.Center;
                        NSRect temp = new NSRect(center.x - m_overlaySize.width/2, center.y - m_overlaySize.height/2, m_overlaySize.width, m_overlaySize.height);
                        m_overlay.drawInRect(temp);
                    }
                }
            }
        }
示例#7
0
 public static void NSFrameRectWithWidthUsingOperation(NSRect rect, float width, int op)
 {
     NativeMethods.NSFrameRectWithWidthUsingOperation(rect, width, op);
 }
示例#8
0
        public new void drawRect(NSRect dirtyRect)
        {
            NSRect rect = bounds();

            NSBezierPath path = NSBezierPath.Create();
            path.appendBezierPathWithRoundedRect_xRadius_yRadius(rect, 7.0f, 7.0f);

            m_color.setFill();
            path.fill();

            if (!NSObject.IsNullOrNil(m_text))
            {
                // TODO: may need to use NSLineBreakByWordWrapping once we support
                // multi-line annotations
                int options = Enums.NSStringDrawingUsesLineFragmentOrigin;	// this makes the vertical centering a bit better
                NSRect r = new NSRect(rect.Left + LeftMargin, rect.Bottom + LeftMargin, rect.size.width - 2*LeftMargin, rect.size.height);
                m_text.drawWithRect_options(r, options);
            }
        }
示例#9
0
 public void DrawHover(NSRect aRect)
 {
     Draw(aRect, Properties.Resources.ImageBoxOverLeft,
          Properties.Resources.ImageBoxOverRight,
          Properties.Resources.ImageBoxOverFiller);
 }
示例#10
0
 public new void drawRect(NSRect dirtyRect)
 {
     m_gradient.drawInRect_angle(bounds(), 0.0f);
 }
示例#11
0
        // We can't make a borderless window in IB so we need to use a subclass
        // so that we can still use IB to set our window up.
        public new NSWindow initWithContentRect_styleMask_backing_defer(NSRect contentRect, uint style, uint backing, bool defer)
        {
            NSWindow result = SuperCall(NSWindow.Class, "initWithContentRect:styleMask:backing:defer:",
                NSRect.Empty, (uint) Enums.NSBorderlessWindowMask, (uint) Enums.NSBackingStoreBuffered, false).To<NSWindow>();

            result.setAcceptsMouseMovedEvents(true);
            result.setBackgroundColor(NSColor.clearColor());
            result.setDelegate(result);
            result.setExcludedFromWindowsMenu(true);
            result.setOpaque(false);
            result.setMovableByWindowBackground(true);

            return result;
        }
示例#12
0
文件: NSView.cs 项目: afrog33k/mobjc
 public NSRect ConvertRectToBase(NSRect rect)
 {
     return Call("convertRectToBase:", rect).To<NSRect>();
 }
示例#13
0
    public NSObject MungeRect(NSRect r)
    {
        NSObject str = (NSObject) new Class("NSMutableString").Call("alloc").Call("init");

        str.Call("appendString:", DoCreateStr(((int) r.origin.x).ToString()));
        str.Call("appendString:", DoCreateStr(((int) r.origin.y).ToString()));
        str.Call("appendString:", DoCreateStr(((int) r.size.width).ToString()));
        str.Call("appendString:", DoCreateStr(((int) r.size.height).ToString()));

        return str;
    }
示例#14
0
 public static extern void NSRectFill(NSRect rect);
示例#15
0
 public static extern void NSRectFillList(NSRect[] rects, int count);
示例#16
0
 public static extern void NSFrameRectWithWidth(NSRect rect, float width);
示例#17
0
 public static extern void NSFrameRectWithWidthUsingOperation(NSRect rect, float width, int op);
示例#18
0
 public static extern void NSFrameRect(NSRect rect);
示例#19
0
 private static extern void SendRect(out NSRect retval, IntPtr receiver, IntPtr selector, NSRect rect1);
示例#20
0
 public void SetWidth(float aWidth, bool aClampLeft)
 {
     Frame = new NSRect(aClampLeft ? Frame.MinX : Frame.MaxX - aWidth,
                        Frame.MinY,
                        aWidth, Frame.Height);
 }
示例#21
0
 public static void NSRectFill(NSRect rect)
 {
     NativeMethods.NSRectFill(rect);
 }
示例#22
0
 public static extern void NSRectFillListUsingOperation(NSRect[] rects, int count, int op);
示例#23
0
 public static void NSRectFillList(NSRect[] rects)
 {
     NativeMethods.NSRectFillList(rects, rects.Length);
 }
示例#24
0
 public static extern void NSRectFillListWithColors(NSRect[] rects, NSColor[] colors, int count);
示例#25
0
    public NSRect GetRect()
    {
        NSRect result = new NSRect();
        result.origin.x = 1.0f;
        result.origin.y = 2.0f;
        result.size.width = 3.0f;
        result.size.height = 4.0f;

        return result;
    }
示例#26
0
 public extern static void SendVoid(IntPtr receiver, IntPtr selector, NSRect rect1, IntPtr intPtr1);
示例#27
0
 private static extern NSRect NSIntegralRect(NSRect aRect);
示例#28
0
        public OptionDialogMonobjc(IList <IOptionPage> aOptionPages)
        {
            // create a list of option pages
            iPages = new List <OptionPageMonobjc>();

            NSRect windowRect     = new NSRect(0, 0, kWidth, kHeight);
            float  division       = kWidth / 4;
            NSRect scrollViewRect = new NSRect(kPadding, kPadding, division - (kPadding * 2), kHeight - (kPadding * 2));
            NSRect pageRect       = new NSRect(division + kPadding, kPadding, kWidth - division - (kPadding * 2), kHeight - (kPadding * 2));

            foreach (IOptionPage page in aOptionPages)
            {
                iPages.Add(new OptionPageMonobjc(page, pageRect));
            }

            // create main window for the dialog
            iWindow = new NSWindow(windowRect,
                                   NSWindowStyleMasks.NSClosableWindowMask |
                                   NSWindowStyleMasks.NSTitledWindowMask,
                                   NSBackingStoreType.NSBackingStoreBuffered,
                                   false);
            iWindow.Title = NSString.StringWithUTF8String("User Options");
            iWindow.SetDelegate(d =>
            {
                d.WindowShouldClose += delegate(Id aSender) { return(true); };
                d.WindowWillClose   += delegate(NSNotification aNotification) { NSApplication.NSApp.AbortModal(); };
            });
            iWindow.IsReleasedWhenClosed = false;

            // create a view for the window content
            NSView view = new NSView();

            iWindow.ContentView = view;

            NSScrollView scrollView = new NSScrollView();

            scrollView.HasVerticalScroller   = true;
            scrollView.HasHorizontalScroller = true;
            scrollView.AutohidesScrollers    = true;

            NSTableColumn tableColumn = new NSTableColumn();

            tableColumn.ResizingMask = NSTableColumnResizingMasks.NSTableColumnAutoresizingMask | NSTableColumnResizingMasks.NSTableColumnUserResizingMask;
            tableColumn.IsEditable   = false;

            iTableDelegate   = new OptionDialogMonobjcDelegate(iPages);
            iTableDataSource = new OptionDialogMonobjcDataSource(iPages);

            iTableDelegate.EventSelectedPage += EventSelectedPageHandler;

            iTableView            = new NSTableView();
            iTableView.DataSource = iTableDataSource;
            iTableView.HeaderView = null;
            iTableView.UsesAlternatingRowBackgroundColors = true;
            iTableView.AddTableColumn(tableColumn);
            iTableView.Delegate                = iTableDelegate;
            iTableView.AllowsEmptySelection    = false;
            iTableView.AllowsMultipleSelection = false;

            scrollView.Frame  = scrollViewRect;
            iTableView.Frame  = scrollView.ContentView.Bounds;
            tableColumn.Width = iTableView.Bounds.Width - 3;

            scrollView.DocumentView = iTableView;


            view.AddSubview(scrollView);

            iTableView.ReloadData();

            // view have been added to the window so they can be released
            view.Release();
            tableColumn.Release();
            scrollView.Release();
        }
示例#29
0
 public NSRect window_willPositionSheet_usingRect(NSWindow window, NSWindow sheet, NSRect usingRect)
 {
     if (sheet.respondsToSelector("positionSheet:"))
         return sheet.Call("positionSheet:", usingRect).To<NSRect>();
     else
         return usingRect;
 }
示例#30
0
 public static void NSFrameRect(NSRect rect)
 {
     NativeMethods.NSFrameRect(rect);
 }
示例#31
0
        private NSRect DoGetFrame(NSSize size)
        {
            NSRect bbox = m_editor.GetBoundingBox(new NSRange(m_range.Index, m_range.Length));
            NSPoint origin = m_parent.convertBaseToScreen(bbox.origin);

            if (m_alignment == AnnotationAlignment.Bottom)
                origin.y -= size.height;
            else if (m_alignment == AnnotationAlignment.Top)
                origin.y += size.height;

            NSRect frame = new NSRect(origin, size);
            return frame;
        }
示例#32
0
 public static void NSFrameRectWithWidth(NSRect rect, float width)
 {
     NativeMethods.NSFrameRectWithWidth(rect, width);
 }
示例#33
0
 public static extern void NSRectFillListWithColorsUsingOperation(NSRect[] rects, NSColor[] colors, int count, int op);
示例#34
0
 public void DrawNoHover(NSRect aRect)
 {
     Draw(aRect, Properties.Resources.ImageBoxLeft,
          Properties.Resources.ImageBoxRight,
          Properties.Resources.ImageBoxFiller);
 }
示例#35
0
        // Cocoa doesn't provide a way to set the initial size of a sheet and
        // it doesn't do a very good job when the sheet is near the edge of
        // the screen so we'll try and fix things up here.
        private NSRect DoConstrainToScreen(NSRect frame)
        {
            NSRect result = frame;

            NSScreen s = this.screen();
            if (!NSObject.IsNullOrNil(s))
            {
                NSRect screen = s.frame();

                // The sheet cannot be larger than the screen.
                result.size.width = Math.Min(result.size.width, screen.size.width);
                result.size.height = Math.Min(result.size.height, screen.size.height);

                // The sheet's origin (aka the bottom-left corner) can't be
                // off screen.
                result.origin.x = Math.Max(result.origin.x, screen.origin.x);
                result.origin.y = Math.Max(result.origin.y, screen.origin.y);
            }

            return result;
        }
示例#36
0
 public static extern void NSRectFillUsingOperation(NSRect rect, int op);