Пример #1
0
        public static string AttributeGetName(Atk.TextAttribute attr)
        {
            IntPtr raw_ret = atk_text_attribute_get_name((int)attr);
            string ret     = GLib.Marshaller.Utf8PtrToString(raw_ret);

            return(ret);
        }
Пример #2
0
        public static string AttributeGetValue(Atk.TextAttribute attr, int index_)
        {
            IntPtr raw_ret = atk_text_attribute_get_value((int)attr, index_);
            string ret     = GLib.Marshaller.Utf8PtrToString(raw_ret);

            return(ret);
        }
Пример #3
0
        public static Atk.TextAttribute AttributeRegister(string name)
        {
            IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup(name);
            int    raw_ret     = atk_text_attribute_register(native_name);

            Atk.TextAttribute ret = (Atk.TextAttribute)raw_ret;
            GLib.Marshaller.Free(native_name);
            return(ret);
        }
Пример #4
0
        private void AddTextAttribute(CG.List <Atk.Attribute> attrs,
                                      Atk.TextAttribute atkAttr,
                                      ITextRangeProvider textRange)
        {
            if (textRange == null)
            {
                return;
            }

            string name = Atk.TextAdapter.AttributeGetName(atkAttr);
            string val  = null;
            object tmp;

            switch (atkAttr)
            {
            case Atk.TextAttribute.Style:
                if (IsAttrNotNullOrMultiValued(TextPattern.IsItalicAttribute.Id,
                                               textRange, out tmp))
                {
                    val = ((bool)tmp) ? "italic" : "normal";
                }
                break;

            case Atk.TextAttribute.Justification:
                if (!IsAttrNotNullOrMultiValued(TextPattern.HorizontalTextAlignmentAttribute.Id,
                                                textRange, out tmp))
                {
                    break;
                }

                HorizontalTextAlignment align = (HorizontalTextAlignment)tmp;
                if (align == HorizontalTextAlignment.Left)
                {
                    val = "left";
                }
                else if (align == HorizontalTextAlignment.Right)
                {
                    val = "right";
                }
                else if (align == HorizontalTextAlignment.Centered)
                {
                    val = "center";
                }
                else if (align == HorizontalTextAlignment.Justified)
                {
                    val = "fill";
                }
                break;

            case Atk.TextAttribute.FgColor:
                if (IsAttrNotNullOrMultiValued(TextPattern.ForegroundColorAttribute.Id,
                                               textRange, out tmp))
                {
                    Color fgColor = Color.FromArgb((int)tmp);
                    val = String.Format("{0},{1},{2}", fgColor.R, fgColor.G, fgColor.B);
                }
                break;

            case Atk.TextAttribute.BgColor:
                if (IsAttrNotNullOrMultiValued(TextPattern.BackgroundColorAttribute.Id,
                                               textRange, out tmp))
                {
                    Color fgColor = Color.FromArgb((int)tmp);
                    val = String.Format("{0},{1},{2}", fgColor.R, fgColor.G, fgColor.B);
                }
                break;

            case Atk.TextAttribute.FamilyName:
                if (IsAttrNotNullOrMultiValued(TextPattern.FontNameAttribute.Id,
                                               textRange, out tmp))
                {
                    val = (string)tmp;
                }
                break;

            case Atk.TextAttribute.Weight:
                if (IsAttrNotNullOrMultiValued(TextPattern.FontWeightAttribute.Id,
                                               textRange, out tmp))
                {
                    val = ((int)tmp).ToString();
                }
                break;

            case Atk.TextAttribute.Strikethrough:
                if (IsAttrNotNullOrMultiValued(TextPattern.StrikethroughStyleAttribute.Id,
                                               textRange, out tmp))
                {
                    TextDecorationLineStyle strikeStyle = (TextDecorationLineStyle)tmp;
                    val = strikeStyle == TextDecorationLineStyle.None ? "false" : "true";
                }
                break;

            case Atk.TextAttribute.Underline:
                if (!IsAttrNotNullOrMultiValued(TextPattern.UnderlineStyleAttribute.Id,
                                                textRange, out tmp))
                {
                    break;
                }

                TextDecorationLineStyle underlineStyle = (TextDecorationLineStyle)tmp;
                if (underlineStyle == TextDecorationLineStyle.None)
                {
                    val = "none";
                }
                else if (underlineStyle == TextDecorationLineStyle.Double ||
                         underlineStyle == TextDecorationLineStyle.DoubleWavy)
                {
                    val = "double";
                }
                else
                {
                    val = "single";
                }
                break;

            case Atk.TextAttribute.PixelsBelowLines:
                if (IsAttrNotNullOrMultiValued(TextPattern.IndentationTrailingAttribute.Id,
                                               textRange, out tmp))
                {
                    val = ((int)tmp).ToString();
                }
                break;

            case Atk.TextAttribute.PixelsAboveLines:
                if (IsAttrNotNullOrMultiValued(TextPattern.IndentationLeadingAttribute.Id,
                                               textRange, out tmp))
                {
                    val = ((int)tmp).ToString();
                }
                break;

            case Atk.TextAttribute.Editable:
                if (IsAttrNotNullOrMultiValued(TextPattern.IsReadOnlyAttribute.Id,
                                               textRange, out tmp))
                {
                    val = !((bool)tmp) ? "true" : "false";
                }
                break;

            case Atk.TextAttribute.Invisible:
                if (IsAttrNotNullOrMultiValued(TextPattern.IsHiddenAttribute.Id,
                                               textRange, out tmp))
                {
                    val = ((bool)tmp) ? "true" : "false";
                }
                break;

            case Atk.TextAttribute.Indent:
                if (IsAttrNotNullOrMultiValued(TextPattern.IndentationFirstLineAttribute.Id,
                                               textRange, out tmp))
                {
                    val = ((int)tmp).ToString();
                }
                break;
            }

            if (val != null)
            {
                attrs.Add(new Atk.Attribute {
                    Name = name, Value = val
                });
            }
        }