<?xml version="1.0" encoding="UTF-8" ?>
-<GenericStack Margin="2" Background="DarkRed" Orientation="Vertical"
- Width="{../../TemplatedWidth}" Height="{../../TemplatedHeight}">
- <Label Name="TabTitle" Width="-1" Background="BlueCrayola"
+<GenericStack Orientation="Vertical" Spacing="0"
+ Width="{../../WidthPolicy}" Height="{../../HeightPolicy}">
+ <Label Margin="5" Name="TabTitle" Width="-1"
+ HorizontalAlignment="Left"
Text="{../../Caption}"
Height="{../../../TabThickness}"
Left="{../../TabOffset}"
LayoutChanged="../../../TabTitleLayoutChanged"/>
- <Container Background="White" Margin="2"
- Name="Content" Width="{../../../TemplatedWidth}" Height="{../../../TemplatedHeight}"/>
+ <Container
+ Name="Content" Width="{../../../WidthPolicy}" Height="{../../../HeightPolicy}"/>
</GenericStack>
set {
if (tabOffset == value)
return;
- tabOffset = value;
+ tabOffset = value;
NotifyValueChanged ("TabOffset", tabOffset);
}
- }
+ }
[XmlAttributeAttribute()][DefaultValue("TabItem")]
public string Caption {
- get { return caption; }
+ get { return caption; }
set {
if (caption == value)
return;
- caption = value;
+ caption = value;
NotifyValueChanged ("Caption", caption);
}
- }
+ }
+ protected override void onDraw (Cairo.Context gr)
+ {
+ int spacing = (Parent as TabView).Spacing;
+ gr.MoveTo (0, TabTitle.Slot.Bottom);
+ gr.LineTo (TabTitle.Slot.Left - spacing, TabTitle.Slot.Bottom);
+ gr.CurveTo (
+ TabTitle.Slot.Left - spacing / 2, TabTitle.Slot.Bottom,
+ TabTitle.Slot.Left - spacing / 2, 0,
+ TabTitle.Slot.Left, 0);
+ gr.LineTo (TabTitle.Slot.Right, 0);
+ gr.CurveTo (
+ TabTitle.Slot.Right + spacing / 2, 0,
+ TabTitle.Slot.Right + spacing / 2, TabTitle.Slot.Bottom,
+ TabTitle.Slot.Right + spacing, TabTitle.Slot.Bottom);
+ gr.LineTo (Slot.Width, TabTitle.Slot.Bottom);
+ gr.LineWidth = 1;
+ Foreground.SetAsSource (gr);
+ gr.StrokePreserve ();
+ gr.LineTo (Slot.Width, Slot.Height);
+ gr.LineTo (0, Slot.Height);
+ gr.ClosePath ();
+ gr.Save ();
+ gr.Clip ();
+ base.onDraw (gr);
+ gr.Restore ();
+ }
}
}
using System;
using System.Xml.Serialization;
using System.ComponentModel;
+using Cairo;
+using System.Diagnostics;
namespace Crow
{
public class TabView : Group
{
+ #region Private fields
+ int _spacing;
Orientation _orientation;
int selectedTab = 0;
+ #endregion
public TabView () : base()
{
public virtual Orientation Orientation
{
get { return _orientation; }
- set {
+ set {
if (_orientation == value)
return;
- _orientation = value;
+ _orientation = value;
NotifyValueChanged ("Orientation", _orientation);
if (_orientation == Orientation.Horizontal)
NotifyValueChanged ("TabOrientation", Orientation.Vertical);
NotifyValueChanged ("TabOrientation", Orientation.Horizontal);
}
}
+ [XmlAttributeAttribute()][DefaultValue(2)]
+ public int Spacing
+ {
+ get { return _spacing; }
+ set {
+ if (_spacing == value)
+ return;
+ _spacing = value;
+ NotifyValueChanged ("Spacing", Spacing);
+ }
+ }
[XmlAttributeAttribute()][DefaultValue(0)]
public virtual int SelectedTab {
get { return selectedTab; }
set {
if (selectedTab == value)
return;
- selectedTab = value;
+ selectedTab = value;
NotifyValueChanged ("SelectedTab", selectedTab);
+ registerForGraphicUpdate ();
}
}
int tabThickness;
set {
if (tabThickness == value)
return;
- tabThickness = value;
+ tabThickness = value;
NotifyValueChanged ("TabThickness", tabThickness);
}
}
TabItem ti = child as TabItem;
if (ti == null)
throw new Exception ("TabView control accept only TabItem as child.");
-
+
ti.MouseDown += Ti_MouseDown;
return base.AddChild (child);
}
public override bool ArrangeChildren { get { return true; } }
- public override void ChildrenLayoutingConstraints (ref LayoutingType layoutType)
- {
-// //Prevent child repositionning in the direction of
-// if (Orientation == Orientation.Horizontal)
-// layoutType &= (~LayoutingType.X);
-// else
-// layoutType &= (~LayoutingType.Y);
- }
public override bool UpdateLayout (LayoutingType layoutType)
{
RegisteredLayoutings &= (~layoutType);
- if (layoutType == LayoutingType.ArrangeChildren) {
- int curOffset = 0;
+ if (layoutType == LayoutingType.ArrangeChildren) {
+ int curOffset = Spacing;
for (int i = 0; i < Children.Count; i++) {
if (!Children [i].Visible)
continue;
if (Orientation == Orientation.Horizontal) {
if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Width))
return false;
- curOffset += ti.TabTitle.Slot.Width;
+ curOffset += ti.TabTitle.Slot.Width + Spacing;
} else {
if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Height))
return false;
- curOffset += ti.TabTitle.Slot.Height;
+ curOffset += ti.TabTitle.Slot.Height + Spacing;
}
}
void TabTitleLayoutChanged (object sender, LayoutingEventArgs e)
{
-
+
}
void Ti_MouseDown (object sender, OpenTK.Input.MouseButtonEventArgs e)
{
SelectedTab = Children.IndexOf (sender as GraphicObject);
}
- protected override void onDraw (Cairo.Context gr)
- {
- base.onDraw (gr);
-
-
- }
}
}