Beispiel #1
0
		// we can't override Initialize () or use the default constructor for this,
		// because a valid Gdk.Window is required for full Gtk.Style initialization
		static void InitializeStyle (Gtk.Widget container)
		{
			if (style == null && container.GdkWindow != null) {
				Gtk.CheckButton cb = new BooleanEditor (); // use the BooleanEditor style for the checks
				cb.GdkWindow = container.GdkWindow;
				cb.Parent = container;
				cb.Realize ();
				style = cb.Style;
				style.Attach (container.GdkWindow);
				indicatorSize = (int)cb.StyleGetProperty ("indicator-size");
				indicatorSpacing = (int)cb.StyleGetProperty ("indicator-spacing");
				style.Detach ();
				cb.Dispose ();
			}
		}
 // we can't override Initialize () or use the default constructor for this,
 // because a valid Gdk.Window is required for full Gtk.Style initialization
 static void InitializeStyle(Gtk.Widget container)
 {
     if (style == null && container.GdkWindow != null)
     {
         Gtk.CheckButton cb = new BooleanEditor();
         cb.GdkWindow = container.GdkWindow;
         cb.Parent    = container;
         cb.Realize();
         style = cb.Style;
         style.Attach(container.GdkWindow);
         indicatorSize    = (int)cb.StyleGetProperty("indicator-size");
         indicatorSpacing = (int)cb.StyleGetProperty("indicator-spacing");
         style.Detach();
         cb.Dispose();
     }
 }
Beispiel #3
0
		public void Initialize (EditSession session)
		{
			PropertyDescriptor prop = session.Property;
			
			if (!prop.PropertyType.IsEnum)
				throw new ApplicationException ("Flags editor does not support editing values of type " + prop.PropertyType);
			
			Spacing = FlagsEditorCell.CheckSpacing;
			propType = prop.PropertyType;
			
			property = prop.Description;
			if (property == null || property.Length == 0)
				property = prop.Name;

			// For small enums, the editor is a list of checkboxes inside a frame
			// For large enums (>5), use a selector dialog.

			values = System.Enum.GetValues (prop.PropertyType);
			
			if (values.Length < FlagsEditorCell.MaxCheckCount) 
			{
				Gtk.VBox vbox = new Gtk.VBox (true, FlagsEditorCell.CheckSpacing);

				flags = new Hashtable ();

				foreach (object value in values) {
					ulong uintVal = Convert.ToUInt64 (value);
					Gtk.CheckButton check = new BooleanEditor ();
					if (uintVal == 0)
						check.Active = true; // default for None is always enabled
					check.Label = value.ToString ();
					check.TooltipText = value.ToString ();
					flags[check] = uintVal;
					flags[uintVal] = check;
					
					check.Toggled += FlagToggled;
					vbox.PackStart (check, false, false, 3);
				}

				Gtk.Frame frame = new Gtk.Frame ();
				frame.Add (vbox);
				frame.ShowAll ();
				PackStart (frame, true, true, 0);
			} 
			else 
			{
				flagsLabel = new Gtk.Entry ();
				flagsLabel.IsEditable = false;
				flagsLabel.HasFrame = false;
				flagsLabel.ShowAll ();
				PackStart (flagsLabel, true, true, 0);
				
				Gtk.Button but = new Gtk.Button ("...");
				but.Clicked += OnSelectFlags;
				but.ShowAll ();
				PackStart (but, false, false, 0);
			}
		}
Beispiel #4
0
        public void Initialize(EditSession session)
        {
            PropertyDescriptor prop = session.Property;

            if (!prop.PropertyType.IsEnum)
            {
                throw new ApplicationException("Flags editor does not support editing values of type " + prop.PropertyType);
            }

            Spacing  = FlagsEditorCell.CheckSpacing;
            propType = prop.PropertyType;

            property = prop.Description;
            if (property == null || property.Length == 0)
            {
                property = prop.Name;
            }

            // For small enums, the editor is a list of checkboxes inside a frame
            // For large enums (>5), use a selector dialog.

            values = System.Enum.GetValues(prop.PropertyType);

            if (values.Length < FlagsEditorCell.MaxCheckCount)
            {
                Gtk.VBox vbox = new Gtk.VBox(true, FlagsEditorCell.CheckSpacing);

                flags = new Hashtable();

                foreach (object value in values)
                {
                    ulong           uintVal = Convert.ToUInt64(value);
                    Gtk.CheckButton check   = new BooleanEditor();
                    if (uintVal == 0)
                    {
                        check.Active = true;                         // default for None is always enabled
                    }
                    check.Label       = value.ToString();
                    check.TooltipText = value.ToString();
                    flags[check]      = uintVal;
                    flags[uintVal]    = check;

                    check.Toggled += FlagToggled;
                    vbox.PackStart(check, false, false, 3);
                }

                Gtk.Frame frame = new Gtk.Frame();
                frame.Add(vbox);
                frame.ShowAll();
                PackStart(frame, true, true, 0);
            }
            else
            {
                flagsLabel            = new Gtk.Entry();
                flagsLabel.IsEditable = false;
                flagsLabel.HasFrame   = false;
                flagsLabel.ShowAll();
                PackStart(flagsLabel, true, true, 0);

                Gtk.Button but = new Gtk.Button("...");
                but.Clicked += OnSelectFlags;
                but.ShowAll();
                PackStart(but, false, false, 0);
            }
        }