コード例 #1
0
        Gtk.Widget AddFeature(ISolutionItemFeature feature)
        {
            Gtk.HBox    cbox  = new Gtk.HBox();
            CheckButton check = null;

            Label fl = new Label();

            fl.Wrap         = true;
            fl.WidthRequest = 630;
            fl.Markup       = "<b>" + feature.Title + "</b>\n<small>" + feature.Description + "</small>";
            bool enabledByDefault = feature.GetSupportLevel(parentCombine, entry) == FeatureSupportLevel.Enabled;

            if (enabledByDefault)
            {
                Alignment al = new Alignment(0, 0, 0, 0);
                al.SetPadding(6, 6, 6, 6);
                al.Add(fl);
                cbox.PackStart(al, false, false, 0);
            }
            else
            {
                check       = new CheckButton();
                check.Image = fl;
                cbox.PackStart(check, false, false, 0);
                check.ModifyBg(StateType.Prelight, Style.MidColors [(int)StateType.Normal]);
                check.BorderWidth = 3;
            }
            EventBox eb = new EventBox();

            if (!enabledByDefault)
            {
                eb.Realized += delegate {
                    eb.GdkWindow.Cursor = handCursor;
                };
            }
            eb.ModifyBg(StateType.Normal, Style.MidColors[(int)StateType.Normal]);
            eb.Add(cbox);
            eb.ShowAll();
            box.PackStart(eb, false, false, 0);

            HBox fbox = new HBox();

            Gtk.Widget editor = feature.CreateFeatureEditor(parentCombine, entry);
            if (editor != null)
            {
                Label sp = new Label("");
                sp.WidthRequest = 24;
                sp.Show();
                fbox.PackStart(sp, false, false, 0);
                editor.Show();
                fbox.PackStart(editor, false, false, 0);
                box.PackStart(fbox, false, false, 0);
            }

            if (check != null)
            {
                ISolutionItemFeature f = feature;
                check.Toggled += delegate {
                    OnClickFeature(f, check, fbox, editor);
                };
            }
            else
            {
                fbox.Show();
            }
            return(editor);
        }