Пример #1
0
 public virtual void Recache()
 {
     namedColorLock.Lock();
     _cached_name_space = null;
     _cached_color = null;
     namedColorLock.Unlock();
 }
Пример #2
0
        public override NSColor ColorUsingColorSpaceName(NSString colorSpace, NSDictionary deviceDescription)
        {
            NSColorList list;
            NSColor real;

            if (colorSpace == null)
            {
                if (deviceDescription != null)
                    colorSpace = (NSString)deviceDescription.ObjectForKey(NSColorSpace.NSDeviceColorSpaceName);
                // FIXME: If the deviceDescription is nil, we should get it from the
                // current view or printer
                if (colorSpace == null)
                    colorSpace = NSColorSpace.NSCalibratedRGBColorSpace;
            }
            if (colorSpace.IsEqualToString(this.ColorSpaceName))
            {
                return this;
            }

            namedColorLock.Lock();
            if (false == colorSpace.IsEqualToString(_cached_name_space))
            {
                list = NSColorList.ColorListNamed(_catalog_name);
                real = list.ColorWithKey(_color_name);
                _cached_color = real.ColorUsingColorSpaceName(colorSpace, deviceDescription);
                _cached_name_space = colorSpace;
            }
            real = _cached_color;
            namedColorLock.Unlock();

            return real;
        }
Пример #3
0
        public virtual NSColor BlendedColorWithFraction(double fraction, NSColor aColor)
        {
            NSColor myColor = ColorUsingColorSpaceName(NSColorSpace.NSCalibratedRGBColorSpace);
            NSColor other = aColor.ColorUsingColorSpaceName(NSColorSpace.NSCalibratedRGBColorSpace);
            double mr, mg, mb, ma, or, og, ob, oa, red, green, blue, alpha;

            if (fraction <= 0.0f)
            {
                return this;
            }
            if (fraction >= 1.0f)
            {
                return aColor;
            }
            if (myColor == null || other == null)
            {
                return null;
            }

            mr = mg = mb = ma = 0;
            myColor.GetRedGreenBlueAlpha(ref mr, ref mg, ref mb, ref ma);
            or = og = ob = oa = 0;
            other.GetRedGreenBlueAlpha(ref or, ref og, ref ob, ref oa);
            red = fraction * or + (1 - fraction) * mr;
            green = fraction * og + (1 - fraction) * mg;
            blue = fraction * ob + (1 - fraction) * mb;
            alpha = fraction * oa + (1 - fraction) * ma;
            return ColorWithCalibratedRed(red, green, blue, alpha);
            //  return [NSColorClass colorWithCalibratedRed: red green: green blue: blue alpha: alpha];
        }
Пример #4
0
        public override id InitWithCoder(NSCoder aDecoder)
        {
            base.InitWithCoder(aDecoder);

            if (aDecoder.AllowsKeyedCoding)
            {
                BackgroundColor = (NSColor)aDecoder.DecodeObjectForKey("NSBackgroundColor");
                TextColor = (NSColor)aDecoder.DecodeObjectForKey("NSTextColor");
            }

            return this;
        }
Пример #5
0
        public override id InitTextCell(NSString aString)
        {
            id self = this;

             if (base.InitTextCell(aString) == null)
                return null;

            _text_color = NSColor.TextColor;
            _background_color = NSColor.TextBackgroundColor;
            //  _textfieldcell_draws_background = NO;
            _action_mask = (uint)(NSEventMask.NSKeyUpMask | NSEventMask.NSKeyDownMask);

            return self;
        }
Пример #6
0
        public virtual void SetColor(NSColor aColor, NSString key)
        {
            NSNotification n = null;

            if (_is_editable == false)
                throw new Exception(@"Color list cannot be edited");
            _colorDictionary.SetObjectForKey(aColor, key);

            if (_orderedColorKeys.ContainsObject(key) == false)
                _orderedColorKeys.AddObject(key);

            // We don't support notifs for now ...
            //n = NSNotification.NotificationWithName(@"NSColorListDidChangeNotification", this, null);
            //NSNotificationQueue.DefaultQueue.EnqueueNotification(n, NSPostASAP, NSNotificationCoalescingOnSender, null);
        }