public static Gdk.Pixbuf GetAsPixbuf(this IDrawingCell aCell, bool aFramed) { int fw = (aFramed == true) ? 1 : 0; Cairo.ImageSurface surface = new Cairo.ImageSurface(Cairo.Format.RGB24, System.Convert.ToInt32(aCell.Area.Width + 2), System.Convert.ToInt32(aCell.Area.Height + 2)); Cairo.Context context = new Cairo.Context(surface); CellRectangle rect = new CellRectangle(0, 0, aCell.Area.Width + (fw * 2), aCell.Area.Height + (fw * 2)); context.Color = new Cairo.Color(1, 1, 1); rect.DrawPath(context); // context.Rectangle (rect); context.FillPreserve(); context.Color = new Cairo.Color(0, 0, 0); if (aFramed == true) { context.Stroke(); rect = new CellRectangle(1, 1, aCell.Area.Width + 1, aCell.Area.Height + 1); } CellRectangle fake = new CellRectangle(0, 0, 9999999, 9999999); CellExposeEventArgs args = new CellExposeEventArgs(null, context, null, fake, rect); args.NeedsRecalculation = true; aCell.Paint(args); Gdk.Pixbuf px = surface.GetAsPixbuf(); ((IDisposable)context.Target).Dispose(); ((IDisposable)context).Dispose(); ((IDisposable)surface).Dispose(); return(px); }
/// <summary> /// Handles ButtonPress event /// </summary> /// <param name="evnt"> /// Arguments <see cref="Gdk.EventButton"/> /// </param> /// <returns> /// true if handled, false if not <see cref="System.Boolean"/> /// </returns> protected override bool OnButtonPressEvent(Gdk.EventButton evnt) { if (CanFocus == true) { if (HasFocus == false) { GrabFocus(); return(true); } } if (Editable == false) { return(base.OnButtonPressEvent(evnt)); } IDrawingCell cell = mainbox.CellAtCoordinates(System.Convert.ToInt32(evnt.X), System.Convert.ToInt32(evnt.Y)); if (cell == null) { return(base.OnButtonPressEvent(evnt)); } if (TypeValidator.IsCompatible(cell.GetType(), typeof(TimeText)) == true) { if ((int)(cell as TimeText).Part < 4) { Selected = (cell as TimeText).Part; return(true); } } return(base.OnButtonPressEvent(evnt)); }
/// <summary> /// Packs cell as last /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> /// <param name="aExpanded"> /// Cell is expanded if true, only one expanded cell is supported <see cref="System.Boolean"/> /// </param> public override void PackEnd(IDrawingCell aCell, bool aExpanded) { if (Count > 0) { throw new NotSupportedException("DrawingCellBin only supports one cell"); } base.PackEnd(aCell, aExpanded); }
/// <summary> /// Packs new cell at end of the list /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> public void PackEnd(IDrawingCell aCell) { if ((aCell == null) || (cells.IndexOf(aCell) > -1)) { return; } cells.Add(aCell); }
/// <summary> /// Removes cell from collection /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> public void Remove(IDrawingCell aCell) { if (cells.IndexOf(aCell) < 0) { return; } cells.Remove(aCell); }
/// <summary> /// Packs cell as last /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> /// <param name="aExpanded"> /// Cell is expanded if true, only one expanded cell is supported <see cref="System.Boolean"/> /// </param> public void PackEnd(IDrawingCell aCell, bool aExpanded) { if (aCell == null) { return; } box.PackEnd(aCell, aExpanded); }
public static bool MasterIsSensitive(this IDrawingCell aCell) { if (aCell.MasterIsGtkWidget() == true) { return((aCell.Master as Gtk.Widget).IsSensitive()); } return(true); }
/// <summary> /// Packs new cell at start of the list /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> public void PackStart (IDrawingCell aCell) { if (Count == 0) { PackEnd (aCell); return; } if ((aCell == null) || (cells.IndexOf(aCell) > -1)) return; cells.Insert (0, aCell); }
/// <summary> /// Loads pixbuf resource from store, if specified pixbuf is not already loaded in /// store, then this methods loads it from list of resources and registers it /// </summary> /// <param name="aWidget"> /// Extension method per drawing cell <see cref="Gtk.Widget"/> /// </param> /// <param name="aName"> /// Resource name <see cref="System.String"/> /// </param> /// <returns> /// Result pixbuf <see cref="Gdk.Pixbuf"/> /// </returns> public static Gdk.Pixbuf LoadPixbufFromResourceStore(this IDrawingCell aCell, string aName) { if (PictureResourceStore.Get(aName) != null) { return((Gdk.Pixbuf)PictureResourceStore.Get(aName)); } Gdk.Pixbuf pix = new Gdk.Pixbuf(AssemblyEngine.EntryAssembly.LoadBinaryResource(aName)); if (pix != null) { PictureResourceStore.Add(aName, pix); } return(pix); }
/// <summary> /// Packs new cell at start of the list /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> public void PackStart(IDrawingCell aCell) { if (Count == 0) { PackEnd(aCell); return; } if ((aCell == null) || (cells.IndexOf(aCell) > -1)) { return; } cells.Insert(0, aCell); }
public static bool Activate(this IDrawingCell aCell) { if (aCell == null) { return(false); } IActivatable act = aCell.GetActivatableCell(); if (act != null) { act.Activate(); return(true); } return(false); }
public static IActivatable GetActivatableCell(this IDrawingCell aCell) { if (TypeValidator.IsCompatible(aCell.GetType(), typeof(IActivatable)) == true) { return(aCell as IActivatable); } if (aCell.Owner == null) { return(null); } if (TypeValidator.IsCompatible(aCell.Owner.GetType(), typeof(IDrawingCell)) == true) { return((aCell.Owner as IDrawingCell).GetActivatableCell()); } return(null); }
/// <summary> /// Packs cell into container /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> /// <remarks> /// if cell already exists, exception is thrown /// </remarks> public virtual void Pack(IDrawingCell aCell) { if (aCell == null) { return; } if (Count > 0) { throw new NotSupportedException("Pack method only supports one cell"); } PackStart(aCell, true); if (TypeValidator.IsCompatible(aCell.GetType(), typeof(DrawingCellContent)) == true) { (aCell as DrawingCellContent).XPos = 0.5; (aCell as DrawingCellContent).YPos = 0.5; } }
protected override bool OnButtonPressEvent(Gdk.EventButton evnt) { if (TypeValidator.IsCompatible(this.GetType(), typeof(IEditable)) == true) { if ((this as IEditable).Editable == false) { return(base.OnButtonPressEvent(evnt)); } } if (CanFocus == false) { return(base.OnButtonPressEvent(evnt)); } if (HasFocus == false) { GrabFocus(); if (box != null) { IDrawingCell icell = box.CellAtCoordinates(System.Convert.ToInt32(evnt.X), System.Convert.ToInt32(evnt.Y)); if (icell != null) { icell.Activate(); } } return(true); } if (box == null) { return(base.OnButtonPressEvent(evnt)); } IDrawingCell cell = box.CellAtCoordinates(System.Convert.ToInt32(evnt.X), System.Convert.ToInt32(evnt.Y)); if (cell == null) { return(base.OnButtonPressEvent(evnt)); } if (cell.Activate() == true) { return(true); } return(base.OnButtonPressEvent(evnt)); }
/// <summary> /// Packs cell as last /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> /// <param name="aExpanded"> /// Cell is expanded if true, only one expanded cell is supported <see cref="System.Boolean"/> /// </param> public virtual void PackEnd(IDrawingCell aCell, bool aExpanded) { if (aCell == null) { return; } if (aExpanded == true) { foreach (IDrawingCell dc in cells) { if (dc.Expanded == true) { throw new NotSupportedException("Two expanded cells are not supported"); } } } cells.PackEnd(aCell); aCell.Expanded = aExpanded; aCell.Owner = this; }
/// <summary> /// Checks if cell area is inside of clipping area /// </summary> /// <param name="aCell"> /// A <see cref="IDrawingCell"/> /// </param> /// <param name="aClippingArea"> /// Cllipping rectangle <see cref="Cairo.Rectangle"/> /// </param> /// <returns> /// true if area intersects with clipping area, false if not <see cref="System.Boolean"/> /// </returns> public static bool IsInsideArea(this IDrawingCell aCell, Cairo.Rectangle aClippingArea) { if (aCell.Area.X > (aClippingArea.X + aClippingArea.Width)) { return(false); } if ((aCell.Area.X + aCell.Area.Width) < aClippingArea.X) { return(false); } if (aCell.Area.Y > (aClippingArea.Y + aClippingArea.Height)) { return(false); } if ((aCell.Area.Y + aCell.Area.Height) < aClippingArea.Y) { return(false); } return(true); }
public static StateType ResolveState(this IDrawingCell aCell) { if (aCell.MasterIsSensitive() == false) { return(StateType.Insensitive); } if (TypeValidator.IsCompatible(aCell.GetType(), typeof(IGtkState)) == true) { return((aCell as IGtkState).State); } if (TypeValidator.IsCompatible(aCell.Owner.GetType(), typeof(IDrawingCell)) == true) { return((aCell.Owner as IDrawingCell).ResolveState()); } if (TypeValidator.IsCompatible(aCell.Owner.GetType(), typeof(Gtk.Widget)) == true) { return((aCell.Owner as Gtk.Widget).State); } return(StateType.Normal); }
public static void SetGtkState(this IDrawingCell aCell, StateType aState) { if (TypeValidator.IsCompatible(aCell.GetType(), typeof(ICustomGtkState)) == true) { if ((aCell as ICustomGtkState).StateResolving == ValueResolveMethod.Manual) { (aCell as ICustomGtkState).CustomState = aState; } else { return; } return; } if (aCell.Owner != null) { if (TypeValidator.IsCompatible(aCell.Owner.GetType(), typeof(IDrawingCell)) == true) { (aCell.Owner as IDrawingCell).SetGtkState(aState); } } }
/// <summary> /// Returns cell which takes place on specified coordinates /// </summary> /// <param name="aX"> /// X <see cref="System.Double"/> /// </param> /// <param name="aY"> /// Y <see cref="System.Double"/> /// </param> /// <returns> /// Cell at specified coordinates <see cref="IDrawingCell"/> /// </returns> public override IDrawingCell CellAtCoordinates(double aX, double aY) { IDrawingCell c = base.CellAtCoordinates(aX, aY); if (c == null) { return(null); } foreach (IDrawingCell cell in Cells) { if (cell.IsVisible == false) { continue; } c = cell.CellAtCoordinates(aX, aY); if (c != null) { return(c); } } return(null); }
public DrawingCellThemedBin (IDrawingCell aCell) : base (aCell) { }
/// <summary> /// Removes cell from collection /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> public virtual void Remove(IDrawingCell aCell) { cells.Remove(aCell); }
public static bool MasterIsGtkWidget(this IDrawingCell aCell) { return(TypeValidator.IsCompatible(aCell.Master.GetType(), typeof(Gtk.Widget)) == true); }
public DrawingCellBin(IDrawingCell aCell) : base() { Pack(aCell); }
public static Gdk.Pixbuf GetAsPixbuf(this IDrawingCell aCell) { return(aCell.GetAsPixbuf(true)); }
/// <summary> /// Packs cell as last /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> /// <param name="aExpanded"> /// Cell is expanded if true, only one expanded cell is supported <see cref="System.Boolean"/> /// </param> public void PackEnd (IDrawingCell aCell, bool aExpanded) { if (aCell == null) return; box.PackEnd (aCell, aExpanded); }
/// <summary> /// Packs cell into container /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> /// <remarks> /// if cell already exists, exception is thrown /// </remarks> public virtual void Pack (IDrawingCell aCell) { if (aCell == null) return; if (Count > 0) throw new NotSupportedException ("Pack method only supports one cell"); PackStart (aCell, true); if (TypeValidator.IsCompatible(aCell.GetType(), typeof(DrawingCellContent)) == true) { (aCell as DrawingCellContent).XPos = 0.5; (aCell as DrawingCellContent).YPos = 0.5; } }
/// <summary> /// Packs new cell at end of the list /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> public void PackEnd (IDrawingCell aCell) { if ((aCell == null) || (cells.IndexOf(aCell) > -1)) return; cells.Add (aCell); }
/// <summary> /// Removes cell from collection /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> public void Remove (IDrawingCell aCell) { if (cells.IndexOf(aCell) < 0) return; cells.Remove (aCell); }
public DrawingCellEntry(IDrawingCell aCell) : base(aCell) { }
/// <summary> /// Packs cell as last /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> /// <param name="aExpanded"> /// Cell is expanded if true, only one expanded cell is supported <see cref="System.Boolean"/> /// </param> public virtual void PackEnd (IDrawingCell aCell, bool aExpanded) { if (aCell == null) return; if (aExpanded == true) foreach (IDrawingCell dc in cells) if (dc.Expanded == true) throw new NotSupportedException ("Two expanded cells are not supported"); cells.PackEnd (aCell); aCell.Expanded = aExpanded; aCell.Owner = this; }
public DrawingCellButton(IDrawingCell aCell) : base(aCell) { StateResolving = ValueResolveMethod.Manual; }
public DrawingCellThemedBin(IDrawingCell aCell) : base(aCell) { }
/// <summary> /// Removes cell from collection /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> public virtual void Remove (IDrawingCell aCell) { cells.Remove (aCell); }
/// <summary> /// Packs cell as last /// </summary> /// <param name="aCell"> /// Cell <see cref="IDrawingCell"/> /// </param> /// <param name="aExpanded"> /// Cell is expanded if true, only one expanded cell is supported <see cref="System.Boolean"/> /// </param> public override void PackEnd (IDrawingCell aCell, bool aExpanded) { if (Count > 0) throw new NotSupportedException ("DrawingCellBin only supports one cell"); base.PackEnd (aCell, aExpanded); }
public DrawingCellBin (IDrawingCell aCell) : base() { Pack (aCell); }
/// <summary> /// Calculates cell areas /// </summary> /// <param name="aRect"> /// Bounding rectangle <see cref="Cairo.Rectangle"/> /// </param> public static void HBoxCalculateCellAreas(DrawingCellBox aBox, CellRectangle aRect) { CellRectangle rect = aRect.Copy(); rect.Shrink(aBox.Padding); double start = rect.X; double end = System.Convert.ToInt32(rect.Width + rect.X); double w, h = 0; double cellTop = rect.Y; double cellHeight = System.Convert.ToInt32(rect.Height); if (aBox.Homogeneous == true) { double cw, ch = cw = 0; for (int i = 0; i < aBox.Count; i++) { if (aBox.Cells[i].IsVisible == false) { aBox.Cells[i].Area.Set(0, 0, 0, 0); continue; } aBox.Cells[i].GetCellSize(out w, out h); if (w > cw) { cw = w; } if (h > ch) { ch = h; } } int j = 0; for (int i = 0; i < aBox.Count; i++) { if (aBox.Cells[i].IsVisible == true) { aBox.Cells[i].Area.Set(j * cw, cellTop, cw, cellHeight); j++; } } return; } IDrawingCell expandedCell = null; for (int i = 0; i < aBox.Count; i++) { if (aBox.Cells[i].IsVisible == false) { aBox.Cells[i].Area.Set(0, 0, 0, 0); continue; } if (aBox.Cells[i].Expanded == true) { expandedCell = aBox.Cells[i]; break; } aBox.Cells[i].GetCellSize(out w, out h); aBox.Cells[i].Area.Set(start, cellTop, w, cellHeight); start += w + aBox.Spacing; } if (expandedCell != null) { for (int i = aBox.Count - 1; i > -1; i--) { if (aBox.Cells[i].IsVisible == false) { aBox.Cells[i].Area.Set(0, 0, 0, 0); continue; } if (aBox.Cells[i].Expanded == true) { break; } aBox.Cells[i].GetCellSize(out w, out h); aBox.Cells[i].Area.Set(end - w, cellTop, w, cellHeight); end -= w + aBox.Spacing; } if (expandedCell.IsVisible == true) { expandedCell.Area.Set(start, cellTop, end - start, cellHeight); } else { expandedCell.Area.Set(0, 0, 0, 0); } } aBox.RecalcChildren(); }
public DrawingCellEntry (IDrawingCell aCell) : base (aCell) { }