/// <summary>Inserts a button at the specified location.</summary> /// <param name="Widget">The button to add.</param> /// <param name="ButtonIndex">The index (starting at 0) at which the button must be inserted, or -1 to insert the button after all existing buttons.</param> public void InsertButton (BaseButton Widget, int ButtonIndex) { Widget.Parent = this; Widget.Visible = true; Widget.DrawBackground = true; if(ButtonIndex == -1 || ButtonIndex == buttons.Count) { if(buttons.Count == 0) { Widget.GroupStyle = GroupStyle.Alone; } else { Widget.GroupStyle = GroupStyle.Right; if(buttons.Count == 1) { buttons[buttons.Count - 1].GroupStyle = GroupStyle.Left; } else if(buttons.Count > 1) { buttons[buttons.Count - 1].GroupStyle = GroupStyle.Center; } } buttons.Add (Widget); } else { if(ButtonIndex == 0) { buttons[buttons.Count - 1].GroupStyle = GroupStyle.Left; if(buttons.Count == 1) { buttons[0].GroupStyle = GroupStyle.Right; } else { buttons[0].GroupStyle = GroupStyle.Center; } } buttons.Insert (ButtonIndex, Widget); } ShowAll (); }
/// <summary>Adds a button before all existing buttons.</summary> /// <param name="Widget">The button to add.</param> public void PrependButton (BaseButton Widget) { InsertButton (Widget, 0); }
/// <summary>Adds a button after all existing buttons.</summary> /// <param name="Widget">The button to add.</param> public void AppendButton (BaseButton Widget) { InsertButton (Widget, -1); }
/// <summary>Draws a button.</summary> public void DrawButton (Context cr, Rectangle bodyAllocation, ButtonState state, double roundSize, double lineWidth, double arrowSize, double arrowPadding, bool drawSeparator, BaseButton widget) { double lineWidth05 = lineWidth / 2; double lineWidth15 = lineWidth05 * 3; bool upLeft = true, upRight = true, downRight = true, downLeft = true; switch(widget.GroupStyle) { case GroupStyle.Left: upRight = downRight = false; break; case GroupStyle.Center: upLeft = downLeft = upRight = downRight = false; break; case GroupStyle.Right: upLeft = downLeft = false; break; } cr.LineWidth = lineWidth; if(state == ButtonState.Pressed || state == ButtonState.Hover) { LinearGradient bodyPattern, innerBorderPattern; Color borderColor; if(state == ButtonState.Pressed) { bodyPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height); bodyPattern.AddColorStopRgb (0.0, new Color (0.996, 0.847, 0.667)); bodyPattern.AddColorStopRgb (0.37, new Color (0.984, 0.710, 0.396)); bodyPattern.AddColorStopRgb (0.43, new Color (0.980, 0.616, 0.204)); bodyPattern.AddColorStopRgb (1.0, new Color (0.992, 0.933, 0.667)); innerBorderPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X + bodyAllocation.Width, bodyAllocation.Y + bodyAllocation.Height); innerBorderPattern.AddColorStop (0.0, new Color (0.876, 0.718, 0.533, 1)); innerBorderPattern.AddColorStop (1.0, new Color (0.876, 0.718, 0.533, 0)); borderColor = new Color (0.671, 0.631, 0.549); } else { bodyPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height); bodyPattern.AddColorStopRgb (0.0, new Color (1, 0.996, 0.890)); bodyPattern.AddColorStopRgb (0.37, new Color (1, 0.906, 0.592)); bodyPattern.AddColorStopRgb (0.43, new Color (1, 0.843, 0.314)); bodyPattern.AddColorStopRgb (1.0, new Color (1, 0.906, 0.588)); innerBorderPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X + bodyAllocation.Width, bodyAllocation.Y + bodyAllocation.Height); innerBorderPattern.AddColorStop (0.0, new Color (1, 1, 0.969, 1)); innerBorderPattern.AddColorStop (1.0, new Color (1, 1, 0.969, 0)); borderColor = new Color (0.824, 0.753, 0.553); } double x0 = bodyAllocation.X + lineWidth05, y0 = bodyAllocation.Y + lineWidth05; double x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth05, y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth05; if(upLeft) cr.MoveTo (x0 + roundSize, y0); else cr.MoveTo (x0, y0); if(upRight) cr.Arc (x1 - roundSize, y0 + roundSize, roundSize, 1.5*Math.PI, 0); else cr.LineTo (x1, y0); if(downRight) cr.Arc (x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5*Math.PI); else cr.LineTo (x1, y1); if(downLeft) cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI); else cr.LineTo (x0, y1); if(upLeft) cr.Arc (x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5*Math.PI); else cr.LineTo (x0, y0); cr.Pattern = bodyPattern; cr.Fill (); x0 = bodyAllocation.X + lineWidth15; y0 = bodyAllocation.Y + lineWidth15; x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth15; y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth15; double roundSizeMinusLineWidth = roundSize - lineWidth; if(widget.GroupStyle != GroupStyle.Left) x0 -= lineWidth; if(upLeft) cr.MoveTo (x0 + roundSizeMinusLineWidth, y0); else cr.MoveTo (x0, y0); if(upRight) cr.Arc (x1 - roundSizeMinusLineWidth, y0 + roundSizeMinusLineWidth, roundSizeMinusLineWidth, 1.5*Math.PI, 0); else cr.LineTo (x1, y0); if(downRight) cr.Arc (x1 - roundSizeMinusLineWidth, y1 - roundSizeMinusLineWidth, roundSizeMinusLineWidth, 0, 0.5*Math.PI); else cr.LineTo (x1, y1); if(downLeft) cr.Arc (x0 + roundSizeMinusLineWidth, y1 - roundSizeMinusLineWidth, roundSizeMinusLineWidth, 0.5*Math.PI, Math.PI); else cr.LineTo (x0, y1); if(upLeft) cr.Arc (x0 + roundSizeMinusLineWidth, y0 + roundSizeMinusLineWidth, roundSizeMinusLineWidth, Math.PI, 1.5*Math.PI); else cr.LineTo (x0, y0); if(widget.GroupStyle != GroupStyle.Left) x0 += lineWidth; cr.Pattern = innerBorderPattern; cr.Stroke (); x0 = bodyAllocation.X + lineWidth05; y0 = bodyAllocation.Y + lineWidth05; x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth05; y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth05; if(upLeft) cr.MoveTo (x0 + roundSize, y0); else cr.MoveTo (x0, y0); if(upRight) cr.Arc (x1 - roundSize, y0 + roundSize, roundSize, 1.5*Math.PI, 0); else cr.LineTo (x1, y0); if(downRight) cr.Arc (x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5*Math.PI); else cr.LineTo (x1, y1); if(downLeft) cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI); else cr.LineTo (x0, y1); if(widget.GroupStyle == GroupStyle.Left) { if(upLeft) cr.Arc (x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5*Math.PI); else cr.LineTo (x0, y0); } cr.Color = borderColor; cr.Stroke (); } else if(widget.DrawBackground) { LinearGradient bodyPattern = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height); bodyPattern.AddColorStop (0.0, new Color (1, 1, 1, 0.7)); bodyPattern.AddColorStop (0.37, new Color (1, 1, 1, 0.2)); bodyPattern.AddColorStop (0.43, new Color (1, 1, 1, 0.2)); bodyPattern.AddColorStop (1.0, new Color (1, 1, 1, 0.7)); double x0 = bodyAllocation.X + lineWidth05, y0 = bodyAllocation.Y + lineWidth05; double x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth05, y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth05; if(upLeft) cr.MoveTo (x0 + roundSize, y0); else cr.MoveTo (x0, y0); if(upRight) cr.Arc (x1 - roundSize, y0 + roundSize, roundSize, 1.5*Math.PI, 0); else cr.LineTo (x1, y0); if(downRight) cr.Arc (x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5*Math.PI); else cr.LineTo (x1, y1); if(downLeft) cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI); else cr.LineTo (x0, y1); if(upLeft) cr.Arc (x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5*Math.PI); else cr.LineTo (x0, y0); cr.Pattern = bodyPattern; cr.Fill (); if(widget.GroupStyle != GroupStyle.Left) { if(downLeft) cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI); else cr.MoveTo (x0, y1); if(upLeft) cr.Arc (x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5*Math.PI); else cr.LineTo (x0, y0); cr.Color = new Color (1, 1, 1, 0.8); cr.Stroke (); } if(upLeft) cr.Arc (x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5*Math.PI); else cr.MoveTo (x0, y0); if(upRight) cr.Arc (x1 - roundSize, y0 + roundSize, roundSize, 1.5*Math.PI, 0); else cr.LineTo (x1, y0); if(downRight) cr.Arc (x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5*Math.PI); else cr.LineTo (x1, y1); if(downLeft) cr.Arc (x0 + roundSize, y1 - roundSize, roundSize, 0.5*Math.PI, Math.PI); else cr.LineTo (x0, y1); if(widget.GroupStyle == GroupStyle.Left) { if(upLeft) cr.LineTo (x0, y0 + roundSize); else cr.LineTo (x0, y0); } cr.Color = new Color (0, 0, 0, 0.2); cr.Stroke (); } if(arrowSize > 0) { double x, y; switch(widget.ImagePosition) { case Gtk.PositionType.Bottom: case Gtk.PositionType.Top: x = bodyAllocation.X + (bodyAllocation.Width - arrowSize) / 2.0; y = bodyAllocation.Y + bodyAllocation.Height - 2 * lineWidth - arrowSize - 2 * arrowPadding; if(drawSeparator) { double left = bodyAllocation.X + 2 * lineWidth, right = bodyAllocation.X + bodyAllocation.Width - 2 * lineWidth; cr.MoveTo (left, y - lineWidth / 2); cr.LineTo (right, y - lineWidth / 2); cr.Color = new Color (0, 0, 0, 0.1); cr.Stroke (); cr.MoveTo (left, y + lineWidth / 2); cr.LineTo (right, y + lineWidth / 2); cr.Color = new Color (1, 1, 1, 0.6); cr.Stroke (); } y += arrowPadding; break; default: x = bodyAllocation.X + bodyAllocation.Width - 2 * lineWidth - arrowSize - 2 * arrowPadding; y = bodyAllocation.Y + (bodyAllocation.Height - arrowSize) / 2.0; if(drawSeparator) { double top = bodyAllocation.Y + 2 * lineWidth, bottom = bodyAllocation.Y + bodyAllocation.Height - 2 * lineWidth; cr.MoveTo (x - lineWidth / 2, top); cr.LineTo (x - lineWidth / 2, bottom); cr.Color = new Color (0, 0, 0, 0.1); cr.Stroke (); cr.MoveTo (x + lineWidth / 2, top); cr.LineTo (x + lineWidth / 2, bottom); cr.Color = new Color (1, 1, 1, 0.6); cr.Stroke (); } x += arrowPadding; break; } y += arrowSize / 4.0 + lineWidth / 2.0; cr.MoveTo (x, y); cr.LineTo (x + arrowSize, y); cr.LineTo (x + arrowSize / 2.0, y + arrowSize / 2.0); cr.LineTo (x, y); cr.Color = new Color (0, 0, 0); cr.Fill (); } }
/// <summary>Adds a button after all existing buttons.</summary> /// <param name="Widget">The button to add.</param> public void AppendButton(BaseButton Widget) { InsertButton(Widget, -1); }
/// <summary>Adds a button before all existing buttons.</summary> /// <param name="Widget">The button to add.</param> public void PrependButton(BaseButton Widget) { InsertButton(Widget, 0); }
/// <summary>Draws an application button.</summary> public void DrawApplicationButton(Context cr, Gdk.Rectangle bodyAllocation, ButtonState state, double lineWidth, BaseButton widget) { const double dropShadowOffset = 1; double radius = (bodyAllocation.Height - dropShadowOffset) / 2; double x = bodyAllocation.X + radius + dropShadowOffset; double y = bodyAllocation.Y + radius + dropShadowOffset; cr.Arc (x, y, radius, 0, 2 * Math.PI); cr.Color = new Color (0, 0, 0, 0.5); cr.Fill (); cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, 0, 2 * Math.PI); switch(state) { case ButtonState.Hover: cr.Color = new Color (0.9, 0.815, 0.533); break; case ButtonState.Pressed: cr.Color = new Color (0.886, 0.639, 0.356); break; default: cr.Color = new Color (0.8, 0.8, 0.8); break; } cr.Fill (); cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, 0, 2 * Math.PI); LinearGradient linGrad = new LinearGradient (0, bodyAllocation.Y, 0, bodyAllocation.Y + bodyAllocation.Height); linGrad.AddColorStop (0.0, new Color (1, 1, 1, 0.9)); linGrad.AddColorStop (0.5, new Color (1, 1, 1, 0.0)); linGrad.AddColorStop (1.0, new Color (1, 1, 1, 1.0)); cr.Pattern = linGrad; cr.Fill (); linGrad.Destroy (); cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, 0, 2 * Math.PI); linGrad = new LinearGradient (0, bodyAllocation.Y, 0, bodyAllocation.Y + bodyAllocation.Height); linGrad.AddColorStop (0.0, new Color (0, 0, 0, 0.0)); linGrad.AddColorStop (0.4, new Color (0, 0, 0, 0.0)); linGrad.AddColorStop (0.5, new Color (0, 0, 0, 0.1)); linGrad.AddColorStop (0.75, new Color (0, 0, 0, 0.0)); linGrad.AddColorStop (1.0, new Color (0, 0, 0, 0.0)); cr.Pattern = linGrad; cr.Fill (); linGrad.Destroy (); cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, 0, Math.PI); linGrad = new LinearGradient (0, bodyAllocation.Y + radius, 0, bodyAllocation.Y + bodyAllocation.Height); linGrad.AddColorStop (0.0, new Color (0, 0, 0, 0.0)); linGrad.AddColorStop (1.0, new Color (0, 0, 0, 0.5)); cr.Pattern = linGrad; cr.LineWidth = 1.0; cr.Stroke (); linGrad.Destroy (); cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, Math.PI, 0); linGrad = new LinearGradient (0, bodyAllocation.Y, 0, bodyAllocation.Y + radius); linGrad.AddColorStop (0.0, new Color (1, 1, 1, 0.5)); linGrad.AddColorStop (1.0, new Color (1, 1, 1, 0.0)); cr.LineWidth = 1.0; cr.Stroke (); linGrad.Destroy (); cr.Arc (bodyAllocation.X + radius, bodyAllocation.Y + radius, radius, 0, 2 * Math.PI); RadialGradient radGrad = new RadialGradient (bodyAllocation.X + radius, bodyAllocation.Y + 1.5 * radius, 0, bodyAllocation.X + radius, bodyAllocation.Y + 1.5 * radius, 0.5 * radius); radGrad.AddColorStop (0, new Color (1, 1, 1, 0.4)); radGrad.AddColorStop (1, new Color (1, 1, 1, 0.0)); cr.Pattern = radGrad; cr.Fill (); radGrad.Destroy (); }
/// <summary>Draws a button.</summary> public void DrawButton(Context cr, Rectangle bodyAllocation, ButtonState state, double roundSize, double lineWidth, double arrowSize, double arrowPadding, bool drawSeparator, BaseButton widget) { double lineWidth05 = lineWidth / 2; double lineWidth15 = lineWidth05 * 3; bool upLeft = true, upRight = true, downRight = true, downLeft = true; switch (widget.GroupStyle) { case GroupStyle.Left: upRight = downRight = false; break; case GroupStyle.Center: upLeft = downLeft = upRight = downRight = false; break; case GroupStyle.Right: upLeft = downLeft = false; break; } cr.LineWidth = lineWidth; if (state == ButtonState.Pressed || state == ButtonState.Hover) { LinearGradient bodyPattern, innerBorderPattern; Color borderColor; if (state == ButtonState.Pressed) { bodyPattern = new LinearGradient(bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height); bodyPattern.AddColorStopRgb(0.0, new Color(0.996, 0.847, 0.667)); bodyPattern.AddColorStopRgb(0.37, new Color(0.984, 0.710, 0.396)); bodyPattern.AddColorStopRgb(0.43, new Color(0.980, 0.616, 0.204)); bodyPattern.AddColorStopRgb(1.0, new Color(0.992, 0.933, 0.667)); innerBorderPattern = new LinearGradient(bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X + bodyAllocation.Width, bodyAllocation.Y + bodyAllocation.Height); innerBorderPattern.AddColorStop(0.0, new Color(0.876, 0.718, 0.533, 1)); innerBorderPattern.AddColorStop(1.0, new Color(0.876, 0.718, 0.533, 0)); borderColor = new Color(0.671, 0.631, 0.549); } else { bodyPattern = new LinearGradient(bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height); bodyPattern.AddColorStopRgb(0.0, new Color(1, 0.996, 0.890)); bodyPattern.AddColorStopRgb(0.37, new Color(1, 0.906, 0.592)); bodyPattern.AddColorStopRgb(0.43, new Color(1, 0.843, 0.314)); bodyPattern.AddColorStopRgb(1.0, new Color(1, 0.906, 0.588)); innerBorderPattern = new LinearGradient(bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X + bodyAllocation.Width, bodyAllocation.Y + bodyAllocation.Height); innerBorderPattern.AddColorStop(0.0, new Color(1, 1, 0.969, 1)); innerBorderPattern.AddColorStop(1.0, new Color(1, 1, 0.969, 0)); borderColor = new Color(0.824, 0.753, 0.553); } double x0 = bodyAllocation.X + lineWidth05, y0 = bodyAllocation.Y + lineWidth05; double x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth05, y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth05; if (upLeft) { cr.MoveTo(x0 + roundSize, y0); } else { cr.MoveTo(x0, y0); } if (upRight) { cr.Arc(x1 - roundSize, y0 + roundSize, roundSize, 1.5 * Math.PI, 0); } else { cr.LineTo(x1, y0); } if (downRight) { cr.Arc(x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5 * Math.PI); } else { cr.LineTo(x1, y1); } if (downLeft) { cr.Arc(x0 + roundSize, y1 - roundSize, roundSize, 0.5 * Math.PI, Math.PI); } else { cr.LineTo(x0, y1); } if (upLeft) { cr.Arc(x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5 * Math.PI); } else { cr.LineTo(x0, y0); } cr.Pattern = bodyPattern; cr.Fill(); x0 = bodyAllocation.X + lineWidth15; y0 = bodyAllocation.Y + lineWidth15; x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth15; y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth15; double roundSizeMinusLineWidth = roundSize - lineWidth; if (widget.GroupStyle != GroupStyle.Left) { x0 -= lineWidth; } if (upLeft) { cr.MoveTo(x0 + roundSizeMinusLineWidth, y0); } else { cr.MoveTo(x0, y0); } if (upRight) { cr.Arc(x1 - roundSizeMinusLineWidth, y0 + roundSizeMinusLineWidth, roundSizeMinusLineWidth, 1.5 * Math.PI, 0); } else { cr.LineTo(x1, y0); } if (downRight) { cr.Arc(x1 - roundSizeMinusLineWidth, y1 - roundSizeMinusLineWidth, roundSizeMinusLineWidth, 0, 0.5 * Math.PI); } else { cr.LineTo(x1, y1); } if (downLeft) { cr.Arc(x0 + roundSizeMinusLineWidth, y1 - roundSizeMinusLineWidth, roundSizeMinusLineWidth, 0.5 * Math.PI, Math.PI); } else { cr.LineTo(x0, y1); } if (upLeft) { cr.Arc(x0 + roundSizeMinusLineWidth, y0 + roundSizeMinusLineWidth, roundSizeMinusLineWidth, Math.PI, 1.5 * Math.PI); } else { cr.LineTo(x0, y0); } if (widget.GroupStyle != GroupStyle.Left) { x0 += lineWidth; } cr.Pattern = innerBorderPattern; cr.Stroke(); x0 = bodyAllocation.X + lineWidth05; y0 = bodyAllocation.Y + lineWidth05; x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth05; y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth05; if (upLeft) { cr.MoveTo(x0 + roundSize, y0); } else { cr.MoveTo(x0, y0); } if (upRight) { cr.Arc(x1 - roundSize, y0 + roundSize, roundSize, 1.5 * Math.PI, 0); } else { cr.LineTo(x1, y0); } if (downRight) { cr.Arc(x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5 * Math.PI); } else { cr.LineTo(x1, y1); } if (downLeft) { cr.Arc(x0 + roundSize, y1 - roundSize, roundSize, 0.5 * Math.PI, Math.PI); } else { cr.LineTo(x0, y1); } if (widget.GroupStyle == GroupStyle.Left) { if (upLeft) { cr.Arc(x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5 * Math.PI); } else { cr.LineTo(x0, y0); } } cr.Color = borderColor; cr.Stroke(); } else if (widget.DrawBackground) { LinearGradient bodyPattern = new LinearGradient(bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height); bodyPattern.AddColorStop(0.0, new Color(1, 1, 1, 0.7)); bodyPattern.AddColorStop(0.37, new Color(1, 1, 1, 0.2)); bodyPattern.AddColorStop(0.43, new Color(1, 1, 1, 0.2)); bodyPattern.AddColorStop(1.0, new Color(1, 1, 1, 0.7)); double x0 = bodyAllocation.X + lineWidth05, y0 = bodyAllocation.Y + lineWidth05; double x1 = bodyAllocation.X + bodyAllocation.Width - lineWidth05, y1 = bodyAllocation.Y + bodyAllocation.Height - lineWidth05; if (upLeft) { cr.MoveTo(x0 + roundSize, y0); } else { cr.MoveTo(x0, y0); } if (upRight) { cr.Arc(x1 - roundSize, y0 + roundSize, roundSize, 1.5 * Math.PI, 0); } else { cr.LineTo(x1, y0); } if (downRight) { cr.Arc(x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5 * Math.PI); } else { cr.LineTo(x1, y1); } if (downLeft) { cr.Arc(x0 + roundSize, y1 - roundSize, roundSize, 0.5 * Math.PI, Math.PI); } else { cr.LineTo(x0, y1); } if (upLeft) { cr.Arc(x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5 * Math.PI); } else { cr.LineTo(x0, y0); } cr.Pattern = bodyPattern; cr.Fill(); if (widget.GroupStyle != GroupStyle.Left) { if (downLeft) { cr.Arc(x0 + roundSize, y1 - roundSize, roundSize, 0.5 * Math.PI, Math.PI); } else { cr.MoveTo(x0, y1); } if (upLeft) { cr.Arc(x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5 * Math.PI); } else { cr.LineTo(x0, y0); } cr.Color = new Color(1, 1, 1, 0.8); cr.Stroke(); } if (upLeft) { cr.Arc(x0 + roundSize, y0 + roundSize, roundSize, Math.PI, 1.5 * Math.PI); } else { cr.MoveTo(x0, y0); } if (upRight) { cr.Arc(x1 - roundSize, y0 + roundSize, roundSize, 1.5 * Math.PI, 0); } else { cr.LineTo(x1, y0); } if (downRight) { cr.Arc(x1 - roundSize, y1 - roundSize, roundSize, 0, 0.5 * Math.PI); } else { cr.LineTo(x1, y1); } if (downLeft) { cr.Arc(x0 + roundSize, y1 - roundSize, roundSize, 0.5 * Math.PI, Math.PI); } else { cr.LineTo(x0, y1); } if (widget.GroupStyle == GroupStyle.Left) { if (upLeft) { cr.LineTo(x0, y0 + roundSize); } else { cr.LineTo(x0, y0); } } cr.Color = new Color(0, 0, 0, 0.2); cr.Stroke(); } if (arrowSize > 0) { double x, y; switch (widget.ImagePosition) { case Gtk.PositionType.Bottom: case Gtk.PositionType.Top: x = bodyAllocation.X + (bodyAllocation.Width - arrowSize) / 2.0; y = bodyAllocation.Y + bodyAllocation.Height - 2 * lineWidth - arrowSize - 2 * arrowPadding; if (drawSeparator) { double left = bodyAllocation.X + 2 * lineWidth, right = bodyAllocation.X + bodyAllocation.Width - 2 * lineWidth; cr.MoveTo(left, y - lineWidth / 2); cr.LineTo(right, y - lineWidth / 2); cr.Color = new Color(0, 0, 0, 0.1); cr.Stroke(); cr.MoveTo(left, y + lineWidth / 2); cr.LineTo(right, y + lineWidth / 2); cr.Color = new Color(1, 1, 1, 0.6); cr.Stroke(); } y += arrowPadding; break; default: x = bodyAllocation.X + bodyAllocation.Width - 2 * lineWidth - arrowSize - 2 * arrowPadding; y = bodyAllocation.Y + (bodyAllocation.Height - arrowSize) / 2.0; if (drawSeparator) { double top = bodyAllocation.Y + 2 * lineWidth, bottom = bodyAllocation.Y + bodyAllocation.Height - 2 * lineWidth; cr.MoveTo(x - lineWidth / 2, top); cr.LineTo(x - lineWidth / 2, bottom); cr.Color = new Color(0, 0, 0, 0.1); cr.Stroke(); cr.MoveTo(x + lineWidth / 2, top); cr.LineTo(x + lineWidth / 2, bottom); cr.Color = new Color(1, 1, 1, 0.6); cr.Stroke(); } x += arrowPadding; break; } y += arrowSize / 4.0 + lineWidth / 2.0; cr.MoveTo(x, y); cr.LineTo(x + arrowSize, y); cr.LineTo(x + arrowSize / 2.0, y + arrowSize / 2.0); cr.LineTo(x, y); cr.Color = new Color(0, 0, 0); cr.Fill(); } }