<?xml version="1.0"?>
-<Window Width="50%" Height="50%">
- <Wrapper Orientation="Horizontal" Height="Fit" Width="Fit" Margin="5" Background="Teal" Spacing="1" >
- <GraphicObject Width="50" Height="50" Background="Mantis"/>
- <GraphicObject Width="50" Height="50" Background="Mantis"/>
- <GraphicObject Width="50" Height="50" Background="Mantis"/>
- <GraphicObject Width="50" Height="50" Background="Mantis"/>
- <GraphicObject Width="50%" Height="50" Background="Mantis"/>
- <GraphicObject Width="50" Height="50" Background="Mantis"/>
- <GraphicObject Width="50" Height="50" Background="Mantis"/>
- <GraphicObject Width="50" Height="50%" Background="Mantis"/>
- <GraphicObject Width="50" Height="50" Background="Mantis"/>
- </Wrapper>
-</Window>
\ No newline at end of file
+<TextBox Multiline="true" Text="this is a test of double click\n and here a second line of text\n and again a third one"/>
<?xml version="1.0"?>
-<Window Title="Showcase" Height="90%" Width="90%">
- <HorizontalStack >
- <VerticalStack Width="33%" Margin="5">
- <GroupBox Caption="Performance" Height="Fit">
- <VerticalStack Width="90%" Height="Fit" Spacing="2" >
- <HorizontalStack Height="Fit">
- <Label Text="Fps:" Style="FpsLabel"/>
- <Label Text="{fps}" Style="FpsDisp"/>
- </HorizontalStack>
- <HorizontalStack Height="Fit">
- <Label Text="Min:" Style="FpsLabel"/>
- <Label Text="{fpsMin}" Style="FpsDisp"/>
- </HorizontalStack>
- <HorizontalStack Height="Fit">
- <Label Text="Max:" Style="FpsLabel"/>
- <Label Text="{fpsMax}" Style="FpsDisp"/>
- </HorizontalStack>
- <HorizontalStack Height="Fit">
- <Label Text="Update:" Style="FpsLabel"/>
- <Label Text="{update}" Style="FpsDisp"/>
- </HorizontalStack>
- <HorizontalStack Height="Fit">
- <Label Text="Layouting:" Style="FpsLabel"/>
- <Label Text="{layouting}" Style="FpsDisp"/>
- </HorizontalStack>
- <HorizontalStack Height="Fit">
- <Label Text="Clipping:" Style="FpsLabel"/>
- <Label Text="{clipping}" Style="FpsDisp"/>
- </HorizontalStack>
- <HorizontalStack Height="Fit">
- <Label Text="Drawing:" Style="FpsLabel"/>
- <Label Text="{drawing}" Style="FpsDisp"/>
- </HorizontalStack>
- </VerticalStack>
- </GroupBox>
- <Label Width="Stretched" Margin="3" Background="Onyx"/>
- <TextBox Text="TextBox" Multiline="true" Margin="3"/>
- <HorizontalStack Height="Fit" Margin="5" Background="Onyx" CornerRadius="10">
- <VerticalStack Spacing="5" Width="50%">
- <CheckBox Fit="true"/>
- <CheckBox Fit="true"/>
- <CheckBox Fit="true"/>
- <CheckBox Fit="true"/>
- </VerticalStack>
- <VerticalStack Spacing="5" Width="50%">
- <RadioButton Fit="true"/>
- <RadioButton Fit="true"/>
- <RadioButton Fit="true"/>
- <RadioButton Fit="true"/>
- </VerticalStack>
- </HorizontalStack>
- <HorizontalStack Height="Fit" Margin="5">
- <Label Text="MouseEvents" Width="50%" Margin="3"
- Background="Onyx"
- Foreground="DimGray"
- TextAlignment="Center"
- MouseEnter="{Foreground=White}"
- MouseLeave="{Foreground=DimGray}"
- MouseDown="{Background=DarkRed}"
- MouseUp="{Background=Onyx}"/>
- <Label Text="MouseEvents" Width="50%" Margin="3"
- Background="Onyx"
- Foreground="DimGray"
- TextAlignment="Center"
- MouseEnter="{Foreground=White}"
- MouseLeave="{Foreground=DimGray}"
- MouseDown="{Background=Mantis}"
- MouseUp="{Background=Onyx}"/>
- </HorizontalStack>
- <GroupBox Caption="Templated controls" Height="Fit" Margin="5">
- <HorizontalStack Height="Fit">
- <VerticalStack Width="50%">
- <CheckBox Template="#Tests.Interfaces.CheckBox2.imlt" Style="CheckBox2"/>
- <CheckBox Template="#Tests.Interfaces.CheckBox2.imlt" Style="CheckBox2"/>
- <CheckBox Template="#Tests.Interfaces.CheckBox2.imlt" Style="CheckBox2"/>
- <CheckBox Template="#Tests.Interfaces.CheckBox2.imlt" Style="CheckBox2"/>
- </VerticalStack>
- <Splitter/>
- <VerticalStack Width="50%">
- <RadioButton Template="#Tests.Interfaces.CheckBox2.imlt" Style="RadioButton2"/>
- <RadioButton Template="#Tests.Interfaces.CheckBox2.imlt" Style="RadioButton2"/>
- <RadioButton Template="#Tests.Interfaces.CheckBox2.imlt" Style="RadioButton2"/>
- <RadioButton Template="#Tests.Interfaces.CheckBox2.imlt" Style="RadioButton2"/>
- </VerticalStack>
- </HorizontalStack>
- </GroupBox>
- <Spinner Fit="true"/>
- </VerticalStack>
- <VerticalStack Width="33%" Margin="5" Spacing="5">
- <Expandable Background="DimGray">
- <Image Path="#Crow.Images.Icons.crow.svg"/>
- </Expandable>
- <Popper Background="DimGray" PopDirection="Bottom">
- <Border Fit="True" Background="DimGray" CornerRadius="0" BorderWidth="1">
- <Image Path="#Crow.Images.Icons.crow.svg" Width="100" Height="100" Margin="10"
- MouseEnter="{Background=LightGray}"
- MouseLeave="{Background=Transparent}"/>
- </Border>
- </Popper>
- <Slider Height="10" Width="90%"/>
- <Container Height="Fit" Background="Onyx" Margin="2" CornerRadius="5">
- <ProgressBar Background="DimGray" Height="10" Value="50"/>
- </Container>
- <Image Path="#Crow.Images.Icons.crow.svg" Width="60" Height="60" Background="LightGray" />
- <TabView Name="tabview1"
- Height="120" Orientation="Horizontal" Spacing="15">
- <TabItem Name="TabItem1" Caption="Tab 1" Margin="0">
- <VerticalStack Fit="true">
- <CheckBox/>
- <CheckBox/>
- <CheckBox/>
- <CheckBox/>
- </VerticalStack>
- </TabItem>
- <TabItem Name="TabItem2" Caption="Tab 2" Background="Gray">
- <VerticalStack Fit="true">
- <RadioButton/>
- <RadioButton/>
- <RadioButton/>
- <RadioButton/>
- </VerticalStack>
- </TabItem>
- <TabItem Name="TabItem2" Caption="Tab 3" Background="Gray">
- <Container Margin="5" CornerRadius="2">
- <TextBox Height="Stretched" Margin="5" Multiline="true" TextAlignment="TopLeft"/>
- </Container>
- </TabItem>
- </TabView>
- <MessageBox Movable="false"/>
- </VerticalStack>
- <VerticalStack Width="33%" Margin="5">
- <Border Margin="5" Background="Onyx" Height="Fit">
- <Label Width="Stretched" Margin="1" Text="{../../dv.SelectedItem}"/>
- </Border>
- <Border Margin="5" Background="Onyx" Height="50%">
- <DirectoryView Name="dv" Root="./" Margin="1"/>
- </Border>
- <ListBox Data="{TestList}" Background="Onyx" Margin="5"
- ItemTemplate="#Tests.Interfaces.colorItem.crow"
- Template="#Crow.Templates.ScrollingListBox.goml"/>
- </VerticalStack>
- </HorizontalStack>
-</Window>
\ No newline at end of file
+<ListBox Data="{TestList}">
+ <Template>
+ <Scroller Name="scroller1" Height="{./HeightPolicy}" Width="{./WidthPolicy}"
+ Margin="2" VerticalScrolling="true"
+ ValueChanged="../../../_scroller_ValueChanged">
+ <Wrapper Width="{./WidthPolicy}" Height="Fit" MinimumSize="10,10"
+ Name="List" Margin="0"
+ VerticalAlignment="Top"
+ HorizontalAlignment="Left"
+ LayoutChanged="./_list_LayoutChanged"/>
+ </Scroller>
+ </Template>
+ <ItemTemplate>
+ <GraphicObject Height="4" Width="4" Background="{}" Margin="0" CornerRadius="1"/>
+ </ItemTemplate>
+</ListBox>
\ No newline at end of file
<?xml version="1.0"?>
-<Container Background="Green" Margin="0">
- <GraphicObject Margin="0" Width="90" Height="90%" Background="Red"/>
-</Container>
\ No newline at end of file
+<Window Width="50%" Height="50%">
+ <Wrapper Orientation="Horizontal" Height="Fit" Width="Fit" Margin="5" Background="Teal" Spacing="1" >
+ <GraphicObject Width="50" Height="50" Background="Mantis"/>
+ <GraphicObject Width="50" Height="50" Background="Mantis"/>
+ <GraphicObject Width="50" Height="50" Background="Mantis"/>
+ <GraphicObject Width="50" Height="50" Background="Mantis"/>
+ <GraphicObject Width="50%" Height="50" Background="Mantis"/>
+ <GraphicObject Width="50" Height="50" Background="Mantis"/>
+ <GraphicObject Width="50" Height="50" Background="Mantis"/>
+ <GraphicObject Width="50" Height="50%" Background="Mantis"/>
+ <GraphicObject Width="50" Height="50" Background="Mantis"/>
+ </Wrapper>
+</Window>
\ No newline at end of file
<?xml version="1.0"?>
-<HorizontalStack Width="Stretched" Height="Fit" Margin="5" Background="Mantis">
- <GraphicObject Background="Carmine" Width="10%" Height="20"/>
- <GraphicObject Background="Carmine" Width="Stretched" Height="20"/>
- <GraphicObject Background="Carmine" Width="10%" Height="20"/>
- <GraphicObject Background="Carmine" Width="10%" Height="20"/>
- <GraphicObject Background="Carmine" Width="10%" Height="20"/>
- <GraphicObject Background="Carmine" Width="10%" Height="20"/>
- <GraphicObject Background="Carmine" Width="10%" Height="20"/>
-</HorizontalStack>
+<Window Width="50%" Height="50%">
+ <VerticalStack>
+ <ListBox Data="{TestList}">
+ <Template>
+ <Border BorderWidth="1" Height="{./HeightPolicy}" Width="{./WidthPolicy}">
+ <HorizontalStack Margin="1" Height="{./HeightPolicy}" Width="{./WidthPolicy}" >
+ <Scroller Name="scroller1" Height="{./HeightPolicy}" Width="{./WidthPolicy}"
+ Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"
+ ValueChanged="../../../_scroller_ValueChanged">
+ <Wrapper Width="{./WidthPolicy}" Height="Fit" MinimumSize="10,10"
+ Name="List" Margin="0"
+ VerticalAlignment="Top"
+ HorizontalAlignment="Left"
+ LayoutChanged="./_list_LayoutChanged"/>
+ </Scroller>
+ <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}"
+ Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
+ Width="14" Height="{./HeightPolicy}" />
+ </HorizontalStack>
+ </Border>
+ </Template>
+ <ItemTemplate>
+ <GraphicObject Height="4" Width="4" Background="{}" Margin="0" CornerRadius="1"/>
+ </ItemTemplate>
+ </ListBox>
+ <HorizontalStack Fit="true" HorizontalAlignment="Right">
+ <Button Caption="Load" MouseClick="OnLoadList"/>
+ <Button Caption="Clear" MouseClick="OnClear"/>
+ </HorizontalStack>
+ </VerticalStack>
+</Window>
\ No newline at end of file
<?xml version="1.0"?>
-<VerticalStack Height="Fit" Width="Fit">
- <Label Width="Stretched"/>
- <Expandable Width="Fit" Background="Gray">
- <Expandable Background="LightBlue">
- <Expandable Background="Green">
- <Expandable Background="LimeGreen">
- <Expandable Background="DimGray">
- <Expandable Width="Stretched" Background="Yellow">
- <Expandable Background="NavyBlue">
- <Expandable Width="Stretched" Background="Blue">
- <Expandable Width="Stretched" Background="BlueCrayola">
- <Expandable Width="Stretched" Background="Green">
- <Label Background="Red"/>
- </Expandable>
- </Expandable>
- </Expandable>
- </Expandable>
- </Expandable>
- </Expandable>
- </Expandable>
+<Window Title="Showcase" Height="90%" Width="90%">
+ <HorizontalStack >
+ <VerticalStack Width="33%" Margin="5">
+ <GroupBox Caption="Performance" Height="Fit">
+ <VerticalStack Width="90%" Height="Fit" Spacing="2" >
+ <HorizontalStack Height="Fit">
+ <Label Text="Fps:" Style="FpsLabel"/>
+ <Label Text="{fps}" Style="FpsDisp"/>
+ </HorizontalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Min:" Style="FpsLabel"/>
+ <Label Text="{fpsMin}" Style="FpsDisp"/>
+ </HorizontalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Max:" Style="FpsLabel"/>
+ <Label Text="{fpsMax}" Style="FpsDisp"/>
+ </HorizontalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Update:" Style="FpsLabel"/>
+ <Label Text="{update}" Style="FpsDisp"/>
+ </HorizontalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Layouting:" Style="FpsLabel"/>
+ <Label Text="{layouting}" Style="FpsDisp"/>
+ </HorizontalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Clipping:" Style="FpsLabel"/>
+ <Label Text="{clipping}" Style="FpsDisp"/>
+ </HorizontalStack>
+ <HorizontalStack Height="Fit">
+ <Label Text="Drawing:" Style="FpsLabel"/>
+ <Label Text="{drawing}" Style="FpsDisp"/>
+ </HorizontalStack>
+ </VerticalStack>
+ </GroupBox>
+ <Label Width="Stretched" Margin="3" Background="Onyx"/>
+ <TextBox Text="TextBox" Multiline="true" Margin="3"/>
+ <HorizontalStack Height="Fit" Margin="5" Background="Onyx" CornerRadius="10">
+ <VerticalStack Spacing="5" Width="50%">
+ <CheckBox Fit="true"/>
+ <CheckBox Fit="true"/>
+ <CheckBox Fit="true"/>
+ <CheckBox Fit="true"/>
+ </VerticalStack>
+ <VerticalStack Spacing="5" Width="50%">
+ <RadioButton Fit="true"/>
+ <RadioButton Fit="true"/>
+ <RadioButton Fit="true"/>
+ <RadioButton Fit="true"/>
+ </VerticalStack>
+ </HorizontalStack>
+ <HorizontalStack Height="Fit" Margin="5">
+ <Label Text="MouseEvents" Width="50%" Margin="3"
+ Background="Onyx"
+ Foreground="DimGray"
+ TextAlignment="Center"
+ MouseEnter="{Foreground=White}"
+ MouseLeave="{Foreground=DimGray}"
+ MouseDown="{Background=DarkRed}"
+ MouseUp="{Background=Onyx}"/>
+ <Label Text="MouseEvents" Width="50%" Margin="3"
+ Background="Onyx"
+ Foreground="DimGray"
+ TextAlignment="Center"
+ MouseEnter="{Foreground=White}"
+ MouseLeave="{Foreground=DimGray}"
+ MouseDown="{Background=Mantis}"
+ MouseUp="{Background=Onyx}"/>
+ </HorizontalStack>
+ <GroupBox Caption="Templated controls" Height="Fit" Margin="5">
+ <HorizontalStack Height="Fit">
+ <VerticalStack Width="50%">
+ <CheckBox Template="#Tests.Interfaces.CheckBox2.imlt" Style="CheckBox2"/>
+ <CheckBox Template="#Tests.Interfaces.CheckBox2.imlt" Style="CheckBox2"/>
+ <CheckBox Template="#Tests.Interfaces.CheckBox2.imlt" Style="CheckBox2"/>
+ <CheckBox Template="#Tests.Interfaces.CheckBox2.imlt" Style="CheckBox2"/>
+ </VerticalStack>
+ <Splitter/>
+ <VerticalStack Width="50%">
+ <RadioButton Template="#Tests.Interfaces.CheckBox2.imlt" Style="RadioButton2"/>
+ <RadioButton Template="#Tests.Interfaces.CheckBox2.imlt" Style="RadioButton2"/>
+ <RadioButton Template="#Tests.Interfaces.CheckBox2.imlt" Style="RadioButton2"/>
+ <RadioButton Template="#Tests.Interfaces.CheckBox2.imlt" Style="RadioButton2"/>
+ </VerticalStack>
+ </HorizontalStack>
+ </GroupBox>
+ <Spinner Fit="true"/>
+ </VerticalStack>
+ <VerticalStack Width="33%" Margin="5" Spacing="5">
+ <Expandable Background="DimGray">
+ <Image Path="#Crow.Images.Icons.crow.svg"/>
</Expandable>
- </Expandable>
- </Expandable>
- <Expandable Width="Stretched" Background="Gray">
- <Expandable Width="Stretched" Background="LightBlue">
- <Expandable Width="Stretched" Background="Green">
- <Expandable Width="Stretched" Background="LimeGreen">
- <Expandable Width="Stretched" Background="DimGray">
- <Expandable Width="Stretched" Background="Yellow">
- <Expandable Width="Stretched" Background="NavyBlue">
- <Expandable Width="Stretched" Background="Blue">
- <Expandable Width="Stretched" Background="BlueCrayola">
- <Expandable Width="Stretched" Background="Green">
- <Label Background="Red"/>
- </Expandable>
- </Expandable>
- </Expandable>
- </Expandable>
- </Expandable>
- </Expandable>
- </Expandable>
- </Expandable>
- </Expandable>
- </Expandable>
-</VerticalStack>
+ <Popper Background="DimGray" PopDirection="Bottom">
+ <Border Fit="True" Background="DimGray" CornerRadius="0" BorderWidth="1">
+ <Image Path="#Crow.Images.Icons.crow.svg" Width="100" Height="100" Margin="10"
+ MouseEnter="{Background=LightGray}"
+ MouseLeave="{Background=Transparent}"/>
+ </Border>
+ </Popper>
+ <Slider Height="10" Width="90%"/>
+ <Container Height="Fit" Background="Onyx" Margin="2" CornerRadius="5">
+ <ProgressBar Background="DimGray" Height="10" Value="50"/>
+ </Container>
+ <Image Path="#Crow.Images.Icons.crow.svg" Width="60" Height="60" Background="LightGray" />
+ <TabView Name="tabview1"
+ Height="120" Orientation="Horizontal" Spacing="15">
+ <TabItem Name="TabItem1" Caption="Tab 1" Margin="0">
+ <VerticalStack Fit="true">
+ <CheckBox/>
+ <CheckBox/>
+ <CheckBox/>
+ <CheckBox/>
+ </VerticalStack>
+ </TabItem>
+ <TabItem Name="TabItem2" Caption="Tab 2" Background="Gray">
+ <VerticalStack Fit="true">
+ <RadioButton/>
+ <RadioButton/>
+ <RadioButton/>
+ <RadioButton/>
+ </VerticalStack>
+ </TabItem>
+ <TabItem Name="TabItem2" Caption="Tab 3" Background="Gray">
+ <Container Margin="5" CornerRadius="2">
+ <TextBox Height="Stretched" Margin="5" Multiline="true" TextAlignment="TopLeft"/>
+ </Container>
+ </TabItem>
+ </TabView>
+ <MessageBox Movable="false"/>
+ </VerticalStack>
+ <VerticalStack Width="33%" Margin="5">
+ <Border Margin="5" Background="Onyx" Height="Fit">
+ <Label Width="Stretched" Margin="1" Text="{../../dv.SelectedItem}"/>
+ </Border>
+ <Border Margin="5" Background="Onyx" Height="50%">
+ <DirectoryView Name="dv" Root="./" Margin="1"/>
+ </Border>
+ <ListBox Data="{TestList}" Background="Onyx" Margin="5"
+ ItemTemplate="#Tests.Interfaces.colorItem.crow"
+ Template="#Crow.Templates.ScrollingListBox.goml"/>
+ </VerticalStack>
+ </HorizontalStack>
+</Window>
\ No newline at end of file
#region private fields
LayoutingType registeredLayoutings = LayoutingType.All;
ILayoutable logicalParent;
- ILayoutable _parent;
- string _name = "unamed";
- Fill _background = Color.Transparent;
- Fill _foreground = Color.White;
- Font _font = "droid, 10";
- Measure _width, _height;
- int _left, _top;
- double _cornerRadius = 0;
- int _margin = 0;
- bool _focusable = false;
- bool _hasFocus = false;
- bool _isActive = false;
- bool _mouseRepeat;
- protected bool _isVisible = true;
- VerticalAlignment _verticalAlignment = VerticalAlignment.Center;
- HorizontalAlignment _horizontalAlignment = HorizontalAlignment.Center;
- Size _maximumSize = "0,0";
- Size _minimumSize = "0,0";
+ ILayoutable parent;
+ string name = "unamed";
+ Fill background = Color.Transparent;
+ Fill foreground = Color.White;
+ Font font = "droid, 10";
+ Measure width, height;
+ int left, top;
+ double cornerRadius = 0;
+ int margin = 0;
+ bool focusable = false;
+ bool hasFocus = false;
+ bool isActive = false;
+ bool mouseRepeat;
+ protected bool isVisible = true;
+ bool isEnabled = true;
+ VerticalAlignment verticalAlignment = VerticalAlignment.Center;
+ HorizontalAlignment horizontalAlignment = HorizontalAlignment.Center;
+ Size maximumSize = "0,0";
+ Size minimumSize = "0,0";
bool cacheEnabled = false;
object dataSource;
string style;
/// Parent in the graphic tree, used for rendering and layouting
/// </summary>
[XmlIgnore]public virtual ILayoutable Parent {
- get { return _parent; }
- set { _parent = value; }
+ get { return parent; }
+ set { parent = value; }
}
[XmlIgnore]public ILayoutable LogicalParent {
get { return logicalParent == null ? Parent : logicalParent; }
public event EventHandler<KeyPressEventArgs> KeyPress;
public event EventHandler Focused;
public event EventHandler Unfocused;
+ public event EventHandler Enabled;
+ public event EventHandler Disabled;
public event EventHandler<LayoutingEventArgs> LayoutChanged;
#endregion
}
[XmlAttributeAttribute()][DefaultValue("unamed")]
public virtual string Name {
- get { return _name; }
+ get { return name; }
set {
- if (_name == value)
+ if (name == value)
return;
- _name = value;
- NotifyValueChanged("Name", _verticalAlignment);
+ name = value;
+ NotifyValueChanged("Name", verticalAlignment);
}
}
[XmlAttributeAttribute ()][DefaultValue(VerticalAlignment.Center)]
public virtual VerticalAlignment VerticalAlignment {
- get { return _verticalAlignment; }
+ get { return verticalAlignment; }
set {
- if (_verticalAlignment == value)
+ if (verticalAlignment == value)
return;
- _verticalAlignment = value;
- NotifyValueChanged("VerticalAlignment", _verticalAlignment);
+ verticalAlignment = value;
+ NotifyValueChanged("VerticalAlignment", verticalAlignment);
}
}
[XmlAttributeAttribute()][DefaultValue(HorizontalAlignment.Center)]
public virtual HorizontalAlignment HorizontalAlignment {
- get { return _horizontalAlignment; }
+ get { return horizontalAlignment; }
set {
- if (_horizontalAlignment == value)
+ if (horizontalAlignment == value)
return;
- _horizontalAlignment = value;
- NotifyValueChanged("HorizontalAlignment", _horizontalAlignment);
+ horizontalAlignment = value;
+ NotifyValueChanged("HorizontalAlignment", horizontalAlignment);
}
}
[XmlAttributeAttribute()][DefaultValue(0)]
public virtual int Left {
- get { return _left; }
+ get { return left; }
set {
- if (_left == value)
+ if (left == value)
return;
- _left = value;
- NotifyValueChanged ("Left", _left);
+ left = value;
+ NotifyValueChanged ("Left", left);
this.RegisterForLayouting (LayoutingType.X);
}
}
[XmlAttributeAttribute()][DefaultValue(0)]
public virtual int Top {
- get { return _top; }
+ get { return top; }
set {
- if (_top == value)
+ if (top == value)
return;
- _top = value;
- NotifyValueChanged ("Top", _top);
+ top = value;
+ NotifyValueChanged ("Top", top);
this.RegisterForLayouting (LayoutingType.Y);
}
}
[XmlAttributeAttribute()][DefaultValue("Stretched")]
public virtual Measure Width {
- get { return _width; }
+ get { return width; }
set {
- if (_width == value)
+ if (width == value)
return;
if (value.IsFixed) {
if (value < MinimumSize.Width || (value > MaximumSize.Width && MaximumSize.Width > 0))
return;
}
Measure lastWP = WidthPolicy;
- _width = value;
- NotifyValueChanged ("Width", _width);
+ width = value;
+ NotifyValueChanged ("Width", width);
if (WidthPolicy != lastWP) {
NotifyValueChanged ("WidthPolicy", WidthPolicy);
//contentSize in Stacks are only update on childLayoutChange, and the single stretched
//child of the stack is not counted in contentSize, so when changing size policy of a child
//we should adapt contentSize
//TODO:check case when child become stretched, and another stretched item already exists.
- if (_parent is GenericStack) {//TODO:check if I should test Group instead
- if ((_parent as GenericStack).Orientation == Orientation.Horizontal) {
+ if (parent is GenericStack) {//TODO:check if I should test Group instead
+ if ((parent as GenericStack).Orientation == Orientation.Horizontal) {
if (lastWP == Measure.Fit)
- (_parent as GenericStack).contentSize.Width -= this.LastSlots.Width;
+ (parent as GenericStack).contentSize.Width -= this.LastSlots.Width;
else
- (_parent as GenericStack).contentSize.Width += this.LastSlots.Width;
+ (parent as GenericStack).contentSize.Width += this.LastSlots.Width;
}
}
}
}
[XmlAttributeAttribute()][DefaultValue("Stretched")]
public virtual Measure Height {
- get { return _height; }
+ get { return height; }
set {
- if (_height == value)
+ if (height == value)
return;
if (value.IsFixed) {
if (value < MinimumSize.Height || (value > MaximumSize.Height && MaximumSize.Height > 0))
return;
}
Measure lastHP = HeightPolicy;
- _height = value;
- NotifyValueChanged ("Height", _height);
+ height = value;
+ NotifyValueChanged ("Height", height);
if (HeightPolicy != lastHP) {
NotifyValueChanged ("HeightPolicy", HeightPolicy);
- if (_parent is GenericStack) {
- if ((_parent as GenericStack).Orientation == Orientation.Vertical) {
+ if (parent is GenericStack) {
+ if ((parent as GenericStack).Orientation == Orientation.Vertical) {
if (lastHP == Measure.Fit)
- (_parent as GenericStack).contentSize.Height -= this.LastSlots.Height;
+ (parent as GenericStack).contentSize.Height -= this.LastSlots.Height;
else
- (_parent as GenericStack).contentSize.Height += this.LastSlots.Height;
+ (parent as GenericStack).contentSize.Height += this.LastSlots.Height;
}
}
}
}
[XmlAttributeAttribute()][DefaultValue(false)]
public virtual bool Focusable {
- get { return _focusable; }
+ get { return focusable; }
set {
- if (_focusable == value)
+ if (focusable == value)
return;
- _focusable = value;
- NotifyValueChanged ("Focusable", _focusable);
+ focusable = value;
+ NotifyValueChanged ("Focusable", focusable);
}
}
[XmlIgnore]public virtual bool HasFocus {
- get { return _hasFocus; }
+ get { return hasFocus; }
set {
- if (value == _hasFocus)
+ if (value == hasFocus)
return;
- _hasFocus = value;
- NotifyValueChanged ("HasFocus", _hasFocus);
+ hasFocus = value;
+ NotifyValueChanged ("HasFocus", hasFocus);
}
}
[XmlIgnore]public virtual bool IsActive {
- get { return _isActive; }
+ get { return isActive; }
set {
- if (value == _isActive)
+ if (value == isActive)
return;
- _isActive = value;
- NotifyValueChanged ("IsActive", _isActive);
+ isActive = value;
+ NotifyValueChanged ("IsActive", isActive);
}
}
[XmlAttributeAttribute()][DefaultValue(false)]
public virtual bool MouseRepeat {
- get { return _mouseRepeat; }
+ get { return mouseRepeat; }
set {
- if (_mouseRepeat == value)
+ if (mouseRepeat == value)
return;
- _mouseRepeat = value;
- NotifyValueChanged ("MouseRepeat", _mouseRepeat);
+ mouseRepeat = value;
+ NotifyValueChanged ("MouseRepeat", mouseRepeat);
}
}
[XmlAttributeAttribute()][DefaultValue("Transparent")]
public virtual Fill Background {
- get { return _background; }
+ get { return background; }
set {
- if (_background == value)
+ if (background == value)
return;
- _background = value;
- NotifyValueChanged ("Background", _background);
+ background = value;
+ NotifyValueChanged ("Background", background);
RegisterForRedraw ();
}
}
[XmlAttributeAttribute()][DefaultValue("White")]
public virtual Fill Foreground {
- get { return _foreground; }
+ get { return foreground; }
set {
- if (_foreground == value)
+ if (foreground == value)
return;
- _foreground = value;
- NotifyValueChanged ("Foreground", _foreground);
+ foreground = value;
+ NotifyValueChanged ("Foreground", foreground);
RegisterForRedraw ();
}
}
[XmlAttributeAttribute()][DefaultValue("sans,10")]
public virtual Font Font {
- get { return _font; }
+ get { return font; }
set {
- if (value == _font)
+ if (value == font)
return;
- _font = value;
- NotifyValueChanged ("Font", _font);
+ font = value;
+ NotifyValueChanged ("Font", font);
RegisterForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(0.0)]
public virtual double CornerRadius {
- get { return _cornerRadius; }
+ get { return cornerRadius; }
set {
- if (value == _cornerRadius)
+ if (value == cornerRadius)
return;
- _cornerRadius = value;
- NotifyValueChanged ("CornerRadius", _cornerRadius);
+ cornerRadius = value;
+ NotifyValueChanged ("CornerRadius", cornerRadius);
RegisterForRedraw ();
}
}
[XmlAttributeAttribute()][DefaultValue(0)]
public virtual int Margin {
- get { return _margin; }
+ get { return margin; }
set {
- if (value == _margin)
+ if (value == margin)
return;
- _margin = value;
- NotifyValueChanged ("Margin", _margin);
+ margin = value;
+ NotifyValueChanged ("Margin", margin);
RegisterForGraphicUpdate ();
}
}
- [XmlAttributeAttribute()][DefaultValue(true)]
+ [XmlAttributeAttribute][DefaultValue(true)]
public virtual bool Visible {
- get { return _isVisible; }
+ get { return isVisible; }
set {
- if (value == _isVisible)
+ if (value == isVisible)
return;
- _isVisible = value;
+ isVisible = value;
if (Interface.CurrentInterface == null)
return;
//ensure main win doesn't keep hidden childrens ref
- if (!_isVisible && this.Contains (Interface.CurrentInterface.HoverWidget))
+ if (!isVisible && this.Contains (Interface.CurrentInterface.HoverWidget))
Interface.CurrentInterface.HoverWidget = null;
if (Parent is GraphicObject)
if (Parent is GenericStack)
(Parent as GraphicObject).RegisterForLayouting (LayoutingType.ArrangeChildren);
- if (_isVisible)
+ if (isVisible)
RegisterForLayouting (LayoutingType.Sizing);
Interface.CurrentInterface.EnqueueForRepaint (this);
- NotifyValueChanged ("Visible", _isVisible);
+ NotifyValueChanged ("Visible", isVisible);
+ }
+ }
+ [XmlAttributeAttribute][DefaultValue(true)]
+ public virtual bool IsEnabled {
+ get { return isEnabled; }
+ set {
+ if (value == isEnabled)
+ return;
+
+ isEnabled = value;
+
+ if (isEnabled)
+ onEnable (this, null);
+ else
+ onDisable (this, null);
+
+ NotifyValueChanged ("IsEnabled", isEnabled);
}
}
[XmlAttributeAttribute()][DefaultValue("1,1")]
public virtual Size MinimumSize {
- get { return _minimumSize; }
+ get { return minimumSize; }
set {
- if (value == _minimumSize)
+ if (value == minimumSize)
return;
- _minimumSize = value;
+ minimumSize = value;
- NotifyValueChanged ("MinimumSize", _minimumSize);
+ NotifyValueChanged ("MinimumSize", minimumSize);
RegisterForLayouting (LayoutingType.Sizing);
}
}
[XmlAttributeAttribute()][DefaultValue("0,0")]
public virtual Size MaximumSize {
- get { return _maximumSize; }
+ get { return maximumSize; }
set {
- if (value == _maximumSize)
+ if (value == maximumSize)
return;
- _maximumSize = value;
+ maximumSize = value;
- NotifyValueChanged ("MaximumSize", _maximumSize);
+ NotifyValueChanged ("MaximumSize", maximumSize);
RegisterForLayouting (LayoutingType.Sizing);
}
}
#endregion
public virtual GraphicObject FindByName(string nameToFind){
- return string.Equals(nameToFind, _name, StringComparison.Ordinal) ? this : null;
+ return string.Equals(nameToFind, name, StringComparison.Ordinal) ? this : null;
}
public virtual bool Contains(GraphicObject goToFind){
return false;
}
+
+ #region Queuing
public virtual void RegisterClip(Rectangle clip){
if (CacheEnabled && bmp != null)
Clipping.AddRectangle (clip + ClientRectangle.Position);
if (RegisteredLayoutings == LayoutingType.None)
Interface.CurrentInterface.EnqueueForRepaint (this);
}
-// public Interface CurrentInterface {
-// get {
-// ILayoutable tmp = this.Parent;
-// while (tmp != null) {
-// if (tmp is Interface)
-// return tmp as Interface;
-// tmp = tmp.Parent;
-// }
-// return null;
-// }
-// }
+ // public Interface CurrentInterface {
+ // get {
+ // ILayoutable tmp = this.Parent;
+ // while (tmp != null) {
+ // if (tmp is Interface)
+ // return tmp as Interface;
+ // tmp = tmp.Parent;
+ // }
+ // return null;
+ // }
+ // }
+ #endregion
#region Layouting
Rectangle rBack = new Rectangle (Slot.Size);
Background.SetAsSource (gr, rBack);
- CairoHelpers.CairoRectangle(gr,rBack,_cornerRadius);
+ CairoHelpers.CairoRectangle(gr,rBack,cornerRadius);
gr.Fill ();
}
MouseWheelChanged.Raise (this, e);
}
+ public virtual void onMouseEnter(object sender, MouseMoveEventArgs e)
+ {
+ #if DEBUG_FOCUS
+ Debug.WriteLine("MouseEnter => " + this.ToString());
+ #endif
+ MouseEnter.Raise (this, e);
+ }
+ public virtual void onMouseLeave(object sender, MouseMoveEventArgs e)
+ {
+ #if DEBUG_FOCUS
+ Debug.WriteLine("MouseLeave => " + this.ToString());
+ #endif
+ MouseLeave.Raise (this, e);
+ }
+ #endregion
+
public virtual void onFocused(object sender, EventArgs e){
#if DEBUG_FOCUS
Debug.WriteLine("Focused => " + this.ToString());
Unfocused.Raise (this, e);
this.HasFocus = false;
}
- public virtual void onMouseEnter(object sender, MouseMoveEventArgs e)
- {
- #if DEBUG_FOCUS
- Debug.WriteLine("MouseEnter => " + this.ToString());
- #endif
- MouseEnter.Raise (this, e);
+ public virtual void onEnable(object sender, EventArgs e){
+ Enabled.Raise (this, e);
}
- public virtual void onMouseLeave(object sender, MouseMoveEventArgs e)
- {
- #if DEBUG_FOCUS
- Debug.WriteLine("MouseLeave => " + this.ToString());
- #endif
- MouseLeave.Raise (this, e);
+ public virtual void onDisable(object sender, EventArgs e){
+ Disabled.Raise (this, e);
}
- #endregion
-
public override string ToString ()
{
string tmp ="";
List<string> getLines {
get {
return _multiline ?
- Regex.Split (_text, "\r\n|\r|\n|" + @"\\n").ToList() :
+ Regex.Split (_text, "\r\n|\r|\n|\\\\n").ToList() :
new List<string>(new string[] { _text });
}
}
-
+ /// <summary>
+ /// Moves cursor one char to the left.
+ /// </summary>
+ /// <returns><c>true</c> if move succeed</returns>
+ public bool MoveLeft(){
+ int tmp = _currentCol - 1;
+ if (tmp < 0) {
+ if (_currentLine == 0)
+ return false;
+ CurrentLine--;
+ CurrentColumn = int.MaxValue;
+ } else
+ CurrentColumn = tmp;
+ return true;
+ }
+ /// <summary>
+ /// Moves cursor one char to the right.
+ /// </summary>
+ /// <returns><c>true</c> if move succeed</returns>
+ public bool MoveRight(){
+ int tmp = _currentCol + 1;
+ if (tmp > lines [_currentLine].Length){
+ if (CurrentLine == lines.Count - 1)
+ return false;
+ CurrentLine++;
+ CurrentColumn = 0;
+ } else
+ CurrentColumn = tmp;
+ return true;
+ }
public void GotoWordStart(){
CurrentColumn--;
//skip white spaces
}
public void GotoWordEnd(){
//skip white spaces
+ if (CurrentColumn >= lines [CurrentLine].Length - 1)
+ return;
while (char.IsWhiteSpace (this.CurrentChar) && CurrentColumn < lines [CurrentLine].Length-1)
CurrentColumn++;
while (!char.IsWhiteSpace (this.CurrentChar) && CurrentColumn < lines [CurrentLine].Length-1)
if (CurrentColumn == 0) {
if (CurrentLine == 0 && lines.Count == 1)
return;
- //CurrentLine--;
- CurrentColumn = 0;//lines [CurrentLine].Length;
+ CurrentLine--;
+ CurrentColumn = lines [CurrentLine].Length;
lines [CurrentLine] += lines [CurrentLine + 1];
lines.RemoveAt (CurrentLine + 1);
NotifyValueChanged ("Text", Text);
CurrentColumn--;
lines [CurrentLine] = lines [CurrentLine].Remove (CurrentColumn, 1);
} else {
- int linesToRemove = selectionEnd.Y - selectionStart.Y;
+ int linesToRemove = selectionEnd.Y - selectionStart.Y + 1;
int l = selectionStart.Y;
if (linesToRemove > 0) {
l++;
for (int c = 0; c < linesToRemove-1; c++)
lines.RemoveAt (l);
- CurrentColumn = selectionStart.X;
CurrentLine = selectionStart.Y;
+ CurrentColumn = selectionStart.X;
} else
lines [l] = lines [l].Remove (selectionStart.X, selectionEnd.X - selectionStart.X);
CurrentColumn = selectionStart.X;
/// <param name="str">String.</param>
protected void Insert(string str)
{
- lines [CurrentLine] = lines [CurrentLine].Insert (CurrentColumn, str);
- CurrentColumn += str.Length;
+ if (!selectionIsEmpty)
+ this.DeleteChar ();
+ if (_multiline) {
+ string[] strLines = Regex.Split (str, "\r\n|\r|\n|" + @"\\n").ToArray();
+ lines [CurrentLine] = lines [CurrentLine].Insert (CurrentColumn, strLines[0]);
+ CurrentColumn += strLines[0].Length;
+ for (int i = 1; i < strLines.Length; i++) {
+ InsertLineBreak ();
+ lines [CurrentLine] = lines [CurrentLine].Insert (CurrentColumn, strLines[i]);
+ CurrentColumn += strLines[i].Length;
+ }
+ } else {
+ lines [CurrentLine] = lines [CurrentLine].Insert (CurrentColumn, str);
+ CurrentColumn += str.Length;
+ }
NotifyValueChanged ("Text", Text);
}
/// <summary>
switch (key)
{
case Key.Back:
+ if (CurrentPosition == 0)
+ return;
this.DeleteChar();
break;
case Key.Clear:
break;
case Key.Delete:
- if (selectionIsEmpty)
- CurrentColumn++;
- else if (e.Shift)
+ if (selectionIsEmpty) {
+ if (!MoveRight ())
+ return;
+ }else if (e.Shift)
Interface.CurrentInterface.Clipboard = this.SelectedText;
this.DeleteChar ();
break;
case Key.End:
if (e.Shift) {
if (selectionIsEmpty)
- SelBegin = new Point (CurrentColumn, CurrentLine);
+ SelBegin = CurrentPosition;
if (e.Control)
CurrentLine = int.MaxValue;
CurrentColumn = int.MaxValue;
- SelRelease = new Point (CurrentColumn, CurrentLine);
+ SelRelease = CurrentPosition;
break;
}
SelRelease = -1;
case Key.Insert:
if (e.Shift)
this.Insert (Interface.CurrentInterface.Clipboard);
- else if (e.Control)
+ else if (e.Control && !selectionIsEmpty)
Interface.CurrentInterface.Clipboard = this.SelectedText;
break;
case Key.Left:
SelBegin = new Point(CurrentColumn, CurrentLine);
if (e.Control)
GotoWordStart ();
- else
- CurrentColumn--;
- SelRelease = new Point(CurrentColumn, CurrentLine);
+ else if (!MoveLeft ())
+ return;
+ SelRelease = CurrentPosition;
break;
}
SelRelease = -1;
if (e.Control)
GotoWordStart ();
else
- CurrentColumn--;
+ MoveLeft();
break;
case Key.Right:
if (e.Shift) {
if (selectionIsEmpty)
- SelBegin = new Point(CurrentColumn, CurrentLine);
+ SelBegin = CurrentPosition;
if (e.Control)
GotoWordEnd ();
- else
- CurrentColumn++;
- SelRelease = new Point(CurrentColumn, CurrentLine);
+ else if (!MoveRight ())
+ return;
+ SelRelease = CurrentPosition;
break;
}
SelRelease = -1;
if (e.Control)
GotoWordEnd ();
else
- CurrentColumn++;
+ MoveRight ();
break;
case Key.Up:
if (e.Shift) {
if (selectionIsEmpty)
- SelBegin = new Point(CurrentColumn, CurrentLine);
+ SelBegin = CurrentPosition;
CurrentLine--;
- SelRelease = new Point(CurrentColumn, CurrentLine);
+ SelRelease = CurrentPosition;
break;
}
SelRelease = -1;
case Key.Down:
if (e.Shift) {
if (selectionIsEmpty)
- SelBegin = new Point(CurrentColumn, CurrentLine);
+ SelBegin = CurrentPosition;
CurrentLine++;
- SelRelease = new Point(CurrentColumn, CurrentLine);
+ SelRelease = CurrentPosition;
break;
}
SelRelease = -1;
//TODO: shold be declared in graphicObject
public static bool FocusOnHover = false;
/// <summary> Time to wait in millisecond before starting repeat loop</summary>
- public static int DeviceRepeatDelay = 600;
+ public static int DeviceRepeatDelay = 700;
/// <summary> Time interval in millisecond between device event repeat</summary>
- public static int DeviceRepeatInterval = 100;
+ public static int DeviceRepeatInterval = 40;
public static bool ReplaceTabsWithSpace = false;
/// <summary> Allow rendering of interface in development environment </summary>
public static bool DesignerMode = false;
FocusedWidget.onMouseClick (this, new MouseButtonEventArgs (Mouse.X, Mouse.Y, MouseButton.Left, true));
}
}
+ if (keyboardRepeatCount > 0) {
+ int mc = keyboardRepeatCount;
+ keyboardRepeatCount -= mc;
+ for (int i = 0; i < mc; i++) {
+ _focusedWidget.onKeyDown (this, lastKeyDownEvt);
+ }
+ }
+
if (!Monitor.TryEnter (UpdateMutex))
return;
HoverWidget.onMouseWheel (this, e);
return true;
}
-
- volatile bool mouseRepeatOn;
- volatile int mouseRepeatCount;
- Thread mouseRepeatThread;
- void mouseRepeatThreadFunc()
- {
- mouseRepeatOn = true;
- Thread.Sleep (Interface.DeviceRepeatDelay);
- while (mouseRepeatOn) {
- mouseRepeatCount++;
- Thread.Sleep (Interface.DeviceRepeatInterval);
- }
- mouseRepeatCount = 0;
- }
#endregion
#region Keyboard
Keyboard.SetKeyState((Crow.Key)Key,true);
if (_focusedWidget == null)
return false;
- KeyboardKeyEventArgs e = new KeyboardKeyEventArgs((Crow.Key)Key, false, Keyboard);
+ KeyboardKeyEventArgs e = lastKeyDownEvt = new KeyboardKeyEventArgs((Crow.Key)Key, false, Keyboard);
+ lastKeyDownEvt.IsRepeat = true;
_focusedWidget.onKeyDown (this, e);
+
+ keyboardRepeatThread = new Thread (keyboardRepeatThreadFunc);
+ keyboardRepeatThread.IsBackground = true;
+ keyboardRepeatThread.Start ();
+
return true;
}
public bool ProcessKeyUp(int Key){
if (_focusedWidget == null)
return false;
KeyboardKeyEventArgs e = new KeyboardKeyEventArgs((Crow.Key)Key, false, Keyboard);
+
_focusedWidget.onKeyUp (this, e);
+
+ if (keyboardRepeatThread != null) {
+ keyboardRepeatOn = false;
+ keyboardRepeatThread.Abort();
+ keyboardRepeatThread.Join ();
+ }
return true;
}
public bool ProcessKeyPress(char Key){
}
#endregion
+ #region Device Repeat Events
+ volatile bool mouseRepeatOn, keyboardRepeatOn;
+ volatile int mouseRepeatCount, keyboardRepeatCount;
+ Thread mouseRepeatThread, keyboardRepeatThread;
+ KeyboardKeyEventArgs lastKeyDownEvt;
+ void mouseRepeatThreadFunc()
+ {
+ mouseRepeatOn = true;
+ Thread.Sleep (Interface.DeviceRepeatDelay);
+ while (mouseRepeatOn) {
+ mouseRepeatCount++;
+ Thread.Sleep (Interface.DeviceRepeatInterval);
+ }
+ mouseRepeatCount = 0;
+ }
+ void keyboardRepeatThreadFunc()
+ {
+ keyboardRepeatOn = true;
+ Thread.Sleep (Interface.DeviceRepeatDelay);
+ while (keyboardRepeatOn) {
+ keyboardRepeatCount++;
+ Thread.Sleep (Interface.DeviceRepeatInterval);
+ }
+ keyboardRepeatCount = 0;
+ }
+ #endregion
+
#region ILayoutable implementation
public void RegisterClip(Rectangle r){
clipping.AddRectangle (r);