Esempio n. 1
0
        public override void DrawRect(NSRect aRect)
        {
            // draw background
            NSRect slotRect = RectForPart(NSScrollerPart.NSScrollerKnobSlot);

            NSColor.BlackColor.Set();
            AppKitFramework.NSRectFill(slotRect);
            AppKitFramework.NSRectFill(aRect);

            NSColor.ColorWithCalibratedWhiteAlpha(0.1f, 1.0f).Set();

            NSBezierPath path = new NSBezierPath();

            path.AppendBezierPathWithRoundedRectXRadiusYRadius(slotRect, 2.0f, 2.0f);
            path.LineWidth = 3.0f;
            path.Stroke();
            path.Release();

            // draw know
            DrawKnob();

            // draw the arrow button backgrounds
            DrawArrow(NSScrollerPart.NSScrollerIncrementLine);
            DrawArrow(NSScrollerPart.NSScrollerDecrementLine);
        }
Esempio n. 2
0
        private void DrawArrow(NSScrollerPart aScrollPart)
        {
            NSRect rect = RectForPart(aScrollPart);

            // draw background
            NSColor.BlackColor.Set();
            AppKitFramework.NSRectFill(rect);

            // draw button background
            if (aScrollPart == HitPart)
            {
                NSColor.WhiteColor.Set();
            }
            else
            {
                NSColor.ColorWithCalibratedWhiteAlpha(0.1f, 1.0f).Set();
            }

            NSBezierPath path = new NSBezierPath();

            path.AppendBezierPathWithRoundedRectXRadiusYRadius(rect.InsetRect(1.0f, 1.0f), 2.0f, 2.0f);
            path.LineWidth = 2.0f;
            path.Stroke();
            path.Release();

            // draw arrow
            NSColor.WhiteColor.Set();

            float arrowSize = 6.0f;

            NSRect arrowRect = new NSRect(rect.MidX - (arrowSize * 0.5f),
                                          rect.MidY - (arrowSize * 0.5f),
                                          arrowSize,
                                          arrowSize);

            path = new NSBezierPath();
            if (aScrollPart == NSScrollerPart.NSScrollerDecrementLine)
            {
                path.MoveToPoint(new NSPoint(arrowRect.MinX, arrowRect.MaxY));
                path.LineToPoint(new NSPoint(arrowRect.MaxX, arrowRect.MaxY));
                path.LineToPoint(new NSPoint(arrowRect.MidX, arrowRect.MinY));
                path.LineToPoint(new NSPoint(arrowRect.MinX, arrowRect.MaxY));
            }
            else
            {
                path.MoveToPoint(new NSPoint(arrowRect.MinX, arrowRect.MinY));
                path.LineToPoint(new NSPoint(arrowRect.MaxX, arrowRect.MinY));
                path.LineToPoint(new NSPoint(arrowRect.MidX, arrowRect.MaxY));
                path.LineToPoint(new NSPoint(arrowRect.MinX, arrowRect.MinY));
            }
            path.ClosePath();
            path.Fill();
            path.Release();
        }
Esempio n. 3
0
        public override void DrawRect(NSRect aRect)
        {
            float left   = Bounds.MinX + iPadding;
            float right  = Bounds.MaxX - iPadding;
            float top    = Bounds.MaxY - iPadding - iAnchorHeight;
            float bottom = Bounds.MinY + iPadding + iAnchorHeight;

            NSBezierPath path = new NSBezierPath();

            // start the path in the bottom left corner, just past the arc of the corner and go clockwise
            path.MoveToPoint(new NSPoint(left, bottom + iCornerRadius));
            path.LineToPoint(new NSPoint(left, top - iCornerRadius));
            path.AppendBezierPathWithArcFromPointToPointRadius(new NSPoint(left, top),
                                                               new NSPoint(left + iCornerRadius, top),
                                                               iCornerRadius);
            if (iAnchorOnTop)
            {
                path.LineToPoint(new NSPoint(iAnchorApex - iAnchorWidth * 0.5f, top));
                path.LineToPoint(new NSPoint(iAnchorApex, top + iAnchorHeight));
                path.LineToPoint(new NSPoint(iAnchorApex + iAnchorWidth * 0.5f, top));
            }
            path.LineToPoint(new NSPoint(right - iCornerRadius, top));
            path.AppendBezierPathWithArcFromPointToPointRadius(new NSPoint(right, top),
                                                               new NSPoint(right, top - iCornerRadius),
                                                               iCornerRadius);
            path.LineToPoint(new NSPoint(right, bottom + iCornerRadius));
            path.AppendBezierPathWithArcFromPointToPointRadius(new NSPoint(right, bottom),
                                                               new NSPoint(right - iCornerRadius, bottom),
                                                               iCornerRadius);
            if (!iAnchorOnTop)
            {
                path.LineToPoint(new NSPoint(iAnchorApex + iAnchorWidth * 0.5f, bottom));
                path.LineToPoint(new NSPoint(iAnchorApex, bottom - iAnchorHeight));
                path.LineToPoint(new NSPoint(iAnchorApex - iAnchorWidth * 0.5f, bottom));
            }
            path.LineToPoint(new NSPoint(left + iCornerRadius, bottom));
            path.AppendBezierPathWithArcFromPointToPointRadius(new NSPoint(left, bottom),
                                                               new NSPoint(left, bottom + iCornerRadius),
                                                               iCornerRadius);
            path.ClosePath();

            NSColor.WhiteColor.SetStroke();
            path.LineWidth = 4.0f;
            path.Stroke();

            NSColor.ColorWithCalibratedWhiteAlpha(0.0f, 0.9f).SetFill();
            path.Fill();

            path.Release();
        }