</EmbeddedResource>
<EmbeddedResource Include="ui\DockWindows\winStyleView.crow" />
<EmbeddedResource Include="ui\CategoryExp.template" />
+ <EmbeddedResource Include="ui\DockWindows\winDesign.crow" />
</ItemGroup>
<ItemGroup>
<None Include="ui\test.crow">
CMDUndo, CMDRedo, CMDCut, CMDCopy, CMDPaste, CMDHelp,
CMDAbout, CMDOptions,
CMDViewGTExp, CMDViewProps, CMDViewProj, CMDViewProjProps, CMDViewErrors, CMDViewSolution, CMDViewEditor, CMDViewProperties,
- CMDViewToolbox, CMDViewSchema, CMDViewStyling,
+ CMDViewToolbox, CMDViewSchema, CMDViewStyling,CMDViewDesign,
CMDCompile;
void initCommands () {
{ Caption = "Editor Pane"};
CMDViewProperties = new Command(new Action(() => loadDockWindow ("#Crow.Coding.ui.DockWindows.winProperties.crow")))
{ Caption = "Properties"};
+ CMDViewDesign = new Command(new Action(() => loadDockWindow ("#Crow.Coding.ui.DockWindows.winDesign.crow")))
+ { Caption = "Quick Design", CanExecute = true};
CMDViewToolbox = new Command(new Action(() => loadDockWindow ("#Crow.Coding.ui.DockWindows.winToolbox.crow")))
{ Caption = "Toolbox", CanExecute = false};
CMDViewSchema = new Command(new Action(() => loadDockWindow ("#Crow.Coding.ui.DockWindows.winSchema.crow")))
Measure designWidth, designHeight;
bool updateEnabled;
- SvgPicture icoMove, icoStyle;
+ Picture icoMove, icoStyle;
+ Rectangle rIcons = default(Rectangle);
+ Size iconSize = new Size(10,10);
public List<Crow.Command> Commands;
Crow.Command cmdDelete;
void initIcons () {
icoMove = new SvgPicture ();
icoMove.Load (IFace, "#Crow.Coding.icons.move-arrows.svg");
- icoStyle = new SvgPicture ();
- icoStyle.Load (IFace, "#Crow.Coding.icons.palette.svg");
+// icoStyle = new SvgPicture ();
+// icoStyle.Load (IFace, "#Crow.Coding.icons.palette.svg");
}
[DefaultValue(true)]
}
protected override void updateCheckPostProcess ()
{
+ if (Error != null) {
+ RegisterForRedraw ();
+ return;
+ }
imlVE.Update ();
bool isDirty = false;
}
}
- Rectangle rIcons = default(Rectangle);
- Size iconSize = new Size(10,10);
protected override void onDraw (Cairo.Context gr)
{
Foreground.SetAsSource (gr, cb);
gr.Stroke ();
}
- gr.SetSourceColor (Color.Black);
- gr.Rectangle (cb, 1.0 / z);
- gr.Stroke ();
lock (imlVE.RenderMutex) {
using (Cairo.Surface surf = new Cairo.ImageSurface (imlVE.bmp, Cairo.Format.Argb32,
}
imlVE.IsDirty = false;
}
+ if (Error == null) {
+ gr.SetSourceColor (Color.Black);
+ gr.Rectangle (cb, 1.0 / z);
+ } else {
+ gr.SetSourceColor (Color.LavenderBlush);
+ gr.Rectangle (cb, 2.0 / z);
+ drawCenteredTextLine(gr, cb.Center, Error.InnerException?.Message);
+ }
+ gr.Stroke ();
Rectangle hr;
gr.Restore ();
}
- void drawIcon (Context gr, SvgPicture pic, Rectangle r) {
+ void drawIcon (Context gr, Picture pic, Rectangle r) {
// gr.SetSourceColor (Color.Black);
// CairoHelpers.CairoRectangle (gr, r.Inflated (1), 2, 1.0);
gr.SetSourceColor (Color.White);
gr.Operator = Operator.Over;
}
+ void drawCenteredTextLine (Context gr, Point center, string txt){
+ drawCenteredTextLine (gr, new PointD(center.X,center.Y), txt);
+ }
void drawCenteredTextLine (Context gr, PointD center, string txt){
FontExtents fe = gr.FontExtents;
TextExtents te = gr.TextExtents (txt);
return false;
}
-// public bool ProcessMouseMove(int x, int y)
-// {
-// int deltaX = x - imlVE.Mouse.X;
-// int deltaY = y - imlVE.Mouse.Y;
-// imlVE.Mouse.X = x;
-// imlVE.Mouse.Y = y;
-// MouseMoveEventArgs e = new MouseMoveEventArgs (x, y, deltaX, deltaY);
-// e.Mouse = imlVE.Mouse;
-//
-// if (imlVE.ActiveWidget != null) {
-// //TODO, ensure object is still in the graphic tree
-// //send move evt even if mouse move outside bounds
-// WidgetMouseMove (imlVE.ActiveWidget, e);
-// return true;
-// }
-//
-// if (HoverWidget != null) {
-// //TODO, ensure object is still in the graphic tree
-// //check topmost graphicobject first
-// GraphicObject tmp = HoverWidget;
-// GraphicObject topc = null;
-// while (tmp is GraphicObject) {
-// topc = tmp;
-// tmp = tmp.LogicalParent as GraphicObject;
-// }
-// int idxhw = imlVE.GraphicTree.IndexOf (topc);
-// if (idxhw != 0) {
-// int i = 0;
-// while (i < idxhw) {
-// if (GraphicTree [i].MouseIsIn (e.Position)) {
-// while (HoverWidget != null) {
-// WidgetMouseLeave (imlVE.HoverWidget, e);
-// HoverWidget = HoverWidget.focusParent;
-// }
-//
-// GraphicTree [i].checkHoverWidget (e);
-// WidgetMouseMove (imlVE.HoverWidget, e);
-// return true;
-// }
-// i++;
-// }
-// }
-//
-//
-// if (imlVE.HoverWidget.MouseIsIn (e.Position)) {
-// WidgetCheckOver (imlVE.HoverWidget, (e));
-// WidgetMouseMove (imlVE.HoverWidget, e);
-// return true;
-// } else {
-// WidgetMouseLeave (imlVE.HoverWidget, e);
-// //seek upward from last focused graph obj's
-// while (imlVE.HoverWidget.focusParent != null) {
-// imlVE.HoverWidget = imlVE.HoverWidget.LogicalParent as GraphicObject;
-// if (imlVE.HoverWidget.MouseIsIn (e.Position)) {
-// WidgetCheckOver (imlVE.HoverWidget, e);
-// WidgetMouseMove (imlVE.HoverWidget, e);
-// return true;
-// } else
-// WidgetMouseLeave (imlVE.HoverWidget, e);
-// }
-// }
-// }
-//
-// //top level graphic obj's parsing
-// lock (imlVE.GraphicTree) {
-// for (int i = 0; i < imlVE.GraphicTree.Count; i++) {
-// GraphicObject g = imlVE.GraphicTree [i];
-// if (g.MouseIsIn (e.Position)) {
-// WidgetCheckOver (g, e);
-// WidgetMouseMove (imlVE.HoverWidget, e);
-// return true;
-// }
-// }
-// }
-// imlVE.HoverWidget = null;
-// return false;
-//
-// }
void GTView_SelectedItemChanged (object sender, SelectionChangeEventArgs e)
{
if (hoverLine == value)
return;
hoverLine = value;
- NotifyValueChanged ("HoverLine", hoverLine);
+ NotifyValueChanged ("HoverLine", hoverLine);
+ NotifyValueChanged ("HoverError", buffer [hoverLine].exception);
}
}
void updateHoverLine () {
<MenuItem Command="{CMDViewSolution}"/>
<MenuItem Command="{CMDViewEditor}"/>
<MenuItem Command="{CMDViewProperties}"/>
+ <MenuItem Command="{CMDViewDesign}"/>
<MenuItem Command="{CMDViewStyling}"/>
<MenuItem Command="{CMDViewToolbox}"/>
<MenuItem Command="{CMDViewErrors}"/>
--- /dev/null
+<?xml version="1.0"?>
+<DockWindow DataSource="{CurrentSolution}" Name="winDesign" Caption="Design" Width="200" Height="50%">
+ <VerticalStack DataSource="{SelectedItemElement}">
+ <ColorPicker SelectedColor="{²Background}"/>
+ <Group Fit="true">
+ <Border Foreground="Black" Left="25" Top="12" Width="34" Height="21" Background="{Background}"/>
+ <Border Foreground="Black" Left="1" Top="1" Width="34" Height="21" Background="{Foreground}"/>
+ </Group>
+ </VerticalStack>
+</DockWindow>
</Template>
<Border Background="White" BorderWidth="1" Margin="1" Foreground="Black"
MinimumSize="{../../MinimumPopupSize}" Fit="true">
- <Scroller Name="scroller1" Margin="2" VerticalScrolling="true"
+ <Scroller Name="scroller1" Margin="2"
MaximumSize="0,200"
HorizontalAlignment="Left">
<VerticalStack LayoutChanged="../../../../_list_LayoutChanged"
<Label TextAlignment="Left" Text="{./SelectedItemName}" Width="Stretched"/>
</Border>
<HorizontalStack>
- <Scroller Name="scroller1" Margin="1" VerticalScrolling="true"
+ <Scroller Name="scroller1" Margin="1"
Background="{./Background}"
ScrollY="{../scrollbar1.Value}">
<VerticalStack Spacing="1"
<HorizontalStack Height="Fit" Margin="2" Background="DimGray" Spacing="5">
<HorizontalStack Width="Fit" Spacing="1">
<Label Text="Design Size:"/>
- <TextBox Text="{²../../../editor.DesignWidth}" Width="50" TextAlignment="Right"/>
+ <TextBox Text="{²../../../editor.DesignWidth}" Width="40" TextAlignment="Right"/>
<Label Text="X"/>
- <TextBox Text="{²../../../editor.DesignHeight}" Width="50" TextAlignment="Right"/>
+ <TextBox Text="{²../../../editor.DesignHeight}" Width="40" TextAlignment="Right"/>
</HorizontalStack>
<HorizontalStack Width="Fit" Spacing="1">
<Label Text="Zoom:"/>
- <Slider Value="{²../../../editor.Zoom}" Width="150" Height="10" Minimum="10" Maximum="400" SmallIncrement="5" LargeIncrement="50"/>
+ <Slider Value="{²../../../editor.Zoom}" Width="100" Height="10" Minimum="10" Maximum="200" SmallIncrement="10" LargeIncrement="50"/>
<Label Text="{../../../editor.Zoom}"/>
</HorizontalStack>
- <HorizontalStack Width="Fit" Spacing="1">
- <Label Text="{../../../editor.Width}"/>
- <Label Text="X"/>
- <Label Text="{../../../editor.Height}"/>
- </HorizontalStack>
<HorizontalStack Width="Fit" Spacing="1">
<Label Text="Grid Spacing:"/>
- <Slider Value="{²../../../editor.GridSpacing}" Width="200" Height="10" Minimum="5" Maximum="100" SmallIncrement="5" LargeIncrement="20"/>
+ <Slider Value="{²../../../editor.GridSpacing}" Width="100" Height="10" Minimum="5" Maximum="100" SmallIncrement="5" LargeIncrement="20"/>
<TextBox Text="{../../../editor.GridSpacing}"/>
</HorizontalStack>
</HorizontalStack>
<VerticalStack Height="60%" Width="Stretched" Margin="0" MinimumSize="10,10">
<HorizontalStack>
<Scroller Name="scroller1"
- Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}">
+ Margin="2" ScrollY="{../scrollbar1.Value}">
<ImlVisualEditor Foreground="SkyBlue" Name="editor" Background="Gray"
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10"
Width="512" Height="512" ContextCommands="{/Commands}"
UpdateEnabled="{../../../../../IsSelected}"
ProjectNode="{}" SelectedItem="{²SelectedItem}"/>
</Scroller>
- <ScrollBar Name="scrollbar1" Value="{²../scroller1.ScrollY}"
- LargeIncrement="{../scroller1.PageHeight}" SmallIncrement="30" CursorSize="{../scroller1.ChildHeightRatio}"
- Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
+ <ScrollBar Name="scrollbar1" Orientation="Vertical"
+ Value="{²../scroller1.ScrollY}" Maximum="{../scroller1.MaxScrollY}"
+ CursorSize="{../scroller1.ChildHeightRatio}"
+ LargeIncrement="{../scroller1.PageHeight}" SmallIncrement="30"
Width="14" />
</HorizontalStack>
- <!--<ScrollBar Style="HScrollBar" Name="scrollbarX" Value="{²../scroller1.ScrollX}"
- Maximum="{../scroller1.MaxScrollX}" Orientation="Horizontal"
- LargeIncrement="{../editor.VisibleColumns}"
- CursorSize="{../editor.ChildWidthRatio}"
- Height="14" />-->
+ <ScrollBar Style="HScrollBar" Name="scrollbarX" Orientation="Horizontal"
+ Value="{²../scroller1.ScrollX}" Maximum="{../scroller1.MaxScrollX}"
+ CursorSize="{../scroller1.ChildWidthRatio}"
+ LargeIncrement="{../scroller1.PageWidth}" SmallIncrement="30"
+ Height="14" />
</VerticalStack>
<Splitter/>
<IMLContainer Path="#Crow.Coding.ui.SourceEditor.crow"/>
- <Label DataSource="{../editor.Error}" Text="{}"
+<!-- <Label DataSource="{../editor.Error}" Text="{}"
Visible="{../editor.HasError}"
Height="Fit" Width="Stretched" Background="DarkRed" Foreground="White"
- TextAlignment="TopLeft" Multiline="true"/>
+ TextAlignment="TopLeft" Multiline="true"/>-->
</VerticalStack>
</TabItem>
CursorSize="{../editor.ChildWidthRatio}"
Height="14" />
<HorizontalStack Height="Fit">
- <GraphicObject Height="5" Width="Stretched"/>
+ <Label Text="{../../editor.HoverError}" Width="Stretched"/>
<GraphicObject Background="Red" Width="5" Height="5" Visible="{IsDirty}"/>
+ <Label Text="Hover Line:" Foreground="Gray"/>
+ <Label Text="{../../editor.HoverLine}"/>
+ <GraphicObject Height="5" Width="10"/>
<Label Text="Line:" Foreground="Gray"/>
<Label Text="{CurrentLine}"/>
<GraphicObject Height="5" Width="10"/>
</Template>
<Border Background="DimGray" BorderWidth="1" Margin="1"
MinimumSize="{../../MinimumPopupSize}" Fit="true">
- <Scroller Name="scroller1" Margin="2" VerticalScrolling="true"
+ <Scroller Name="scroller1" Margin="2"
MaximumSize="0,200"
HorizontalAlignment="Left">
<VerticalStack
SelectedItemChanged="./onSelectedItemChanged">
<Template>
<HorizontalStack>
- <Scroller ScrollX="{../scrollbar1.Value}" Name="scroller1"
- VerticalScrolling="true" HorizontalScrolling="false">
+ <Scroller ScrollX="{../scrollbar1.Value}" Name="scroller1">
<VerticalStack Height="Fit" VerticalAlignment="Top"
Name="ItemsContainer" Margin="0" Spacing="1"/>
</Scroller>
<?xml version="1.0"?>
<Border BorderWidth="1" Margin="1" MinimumSize="10,10">
- <Scroller Name="scroller1" Margin="1" VerticalScrolling="true">
+ <Scroller Name="scroller1" Margin="1" >
<VerticalStack
Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
</Scroller>
<Border BorderWidth="1" Background="{./Background}">
<HorizontalStack Margin="1">
<Scroller Name="scroller1"
- Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}">
+ Margin="2" ScrollY="{../scrollbar1.Value}">
<VerticalStack Height="Fit" MinimumSize="10,10"
Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
</Scroller>
<?xml version="1.0"?>
<HorizontalStack>
- <Scroller Name="scroller1" Margin="1" VerticalScrolling="true"
+ <Scroller Name="scroller1" Margin="1"
Background="{./Background}"
ScrollY="{../scrollbar1.Value}">
<VerticalStack
<?xml version="1.0"?>
<Border Fit="true" BorderWidth="2" >
-<Scroller CornerRadius="2" VerticalScrolling="true" Height="200" Width="300" Background="DimGray" Margin="2">
+<Scroller CornerRadius="2" Height="200" Width="300" Background="DimGray" Margin="2">
<VerticalStack Margin="10" VerticalAlignment="Top" Fit="true" Background="vgradient|0:BlueCrayola|1:Black" >
<Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 1"/>
<Label MouseEnter="{Background=Gray}" MouseLeave="{Background=hgradient|0:DarkRed|1:Transparent}" Margin="5" Background="hgradient|0:DarkRed|1:Transparent" Font="droid,20" Text="label 2"/>
<?xml version="1.0"?>
-<Border BorderStyle="Sunken" Fit="true" Background="0.7,0.7,0.7,0.5" CornerRadius="10">
- <VerticalStack Margin="20">
- <Image Path="#Crow.Images.Icons.crow.svg"/>
-<!-- <Label Font="Times bold, 60" Text="C.R.O.W"/>-->
- <HorizontalStack Fit="true" DataSource="{CrowVersion}" Spacing="0">
- <Label Foreground="Black" Font="mono, 12" Text="version: "/>
- <Label Foreground="Black" Font="mono, 12" Text="{Major}"/>
- <Label Foreground="Black" Font="mono, 12" Text="."/>
- <Label Foreground="Black" Font="mono, 12" Text="{Minor}"/>
- <Label Foreground="Black" Font="mono, 12" Text="."/>
- <Label Foreground="DimGray" Font="mono, 12" Text="{Build}"/>
- </HorizontalStack>
- <GraphicObject Height="30"/>
- <Label Font="20" Text="Press <F2> and <F3> to cycle into the examples"/>
- <Label Font="20" Text="Those are basic tests used to validate changes,"/>
- <GraphicObject Height="30"/>
- <Label Foreground="DimGray" Font="20" Text="<F5> => File dialog example"/>
- <Label Foreground="DimGray" Font="20" Text="<F6> => Window example"/>
- </VerticalStack>
-</Border>
\ No newline at end of file
+<GraphicObject Height="30" Width="30" Background="#500000"/>
\ No newline at end of file
<Border BorderWidth="1">
<HorizontalStack Margin="1">
<Scroller Name="scroller1"
- Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}">
+ Margin="2" ScrollY="{../scrollbar1.Value}">
<VerticalStack Height="Fit" MinimumSize="10,10"
Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
</Scroller>
<?xml version="1.0"?>
<Window Caption="Horizontal Wrapper" Width="50%" Height="50%">
<VerticalStack Margin="1">
- <Scroller Name="scroller1" ScrollX="{../scrollbar1.Value}" VerticalScrolling="False" HorizontalScrolling="true" Margin="1" Background="BlueCrayola">
+ <Scroller Name="scroller1" ScrollX="{../scrollbar1.Value}" Margin="1" Background="BlueCrayola">
<Wrapper HorizontalAlignment="Left" Orientation="Horizontal" Height="100%" Width="Fit" Margin="0" Background="MediumSeaGreen" Spacing="1" >
<GraphicObject Width="50" Height="50" Background="SeaGreen"/>
<GraphicObject Width="50" Height="50" Background="SeaGreen"/>
<Splitter/>
<HorizontalStack>
<Scroller Name="scroller1" Background="White"
- Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"
+ Margin="2" ScrollY="{../scrollbar1.Value}"
ValueChanged="./_scroller_ValueChanged">
<TextBox VerticalAlignment="Top" TextChanged="Tb_TextChanged"
Text="{source}" Multiline="true" TextAlignment="TopLeft"
if (!string.IsNullOrEmpty (Style)) {
if (IFace.DefaultValuesLoader.ContainsKey (Style)) {
IFace.DefaultValuesLoader [Style] (this);
+ onInitialized (this, null);
return;
}
} else if (IFace.DefaultValuesLoader.ContainsKey (thisType.FullName)) {
IFace.DefaultValuesLoader [thisType.FullName] (this);
+ onInitialized (this, null);
return;
} else if (IFace.DefaultValuesLoader.ContainsKey (thisType.Name)) {
IFace.DefaultValuesLoader [thisType.Name] (this);
+ onInitialized (this, null);
return;
}
public Scroller (Interface iface) : base(iface){}
#endregion
- bool _verticalScrolling;
- bool _horizontalScrolling;
- bool _scrollbarVisible;
- int _scrollX = 0;
- int _scrollY = 0;
- int scrollSpeed;
-
public event EventHandler<ScrollingEventArgs> Scrolled;
+ int scrollX, scrollY, maxScrollX, maxScrollY, scrollSpeed;
+
+ /// <summary>
+ /// if true, key stroke are handled in derrived class
+ /// </summary>
+ protected bool KeyEventsOverrides = false;
+
#region public properties
- [XmlAttributeAttribute][DefaultValue(true)]
- public bool VerticalScrolling {
- get { return _verticalScrolling; }
- set { _verticalScrolling = value; }
- }
+ /// <summary> Horizontal Scrolling Position </summary>
+ [XmlAttributeAttribute][DefaultValue(0)]
+ public virtual int ScrollX {
+ get { return scrollX; }
+ set {
+ if (scrollX == value)
+ return;
- [XmlAttributeAttribute][DefaultValue(false)]
- public bool HorizontalScrolling {
- get { return _horizontalScrolling; }
- set { _horizontalScrolling = value; }
- }
- [XmlAttributeAttribute][DefaultValue(true)]
- public bool ScrollbarVisible {
- get { return _scrollbarVisible; }
- set { _scrollbarVisible = value; }
+ int newS = value;
+ if (newS < 0)
+ newS = 0;
+ else if (newS > maxScrollX)
+ newS = maxScrollX;
+
+ if (newS == scrollX)
+ return;
+
+ scrollX = value;
+
+ NotifyValueChanged ("ScrollX", scrollX);
+ RegisterForGraphicUpdate ();
+ }
}
+ /// <summary> Vertical Scrolling Position </summary>
[XmlAttributeAttribute][DefaultValue(0)]
- public int ScrollX {
- get {
- return _scrollX;
- }
+ public virtual int ScrollY {
+ get { return scrollY; }
set {
- if (_scrollX == value)
+ if (scrollY == value)
return;
- if (value < 0)
- _scrollX = 0;
- else if (value > Child.Slot.Width - ClientRectangle.Width)
- _scrollX = Math.Max(0, Child.Slot.Width - ClientRectangle.Width);
- else
- _scrollX = value;
- NotifyValueChanged("ScrollX", _scrollX);
- RegisterForRedraw ();
- Scrolled.Raise (this, new ScrollingEventArgs (Orientation.Horizontal));
+
+ int newS = value;
+ if (newS < 0)
+ newS = 0;
+ else if (newS > maxScrollY)
+ newS = maxScrollY;
+
+ if (newS == scrollY)
+ return;
+
+ scrollY = value;
+
+ NotifyValueChanged ("ScrollY", scrollY);
+ RegisterForGraphicUpdate ();
}
}
+ /// <summary> Horizontal Scrolling maximum value </summary>
[XmlAttributeAttribute][DefaultValue(0)]
- public int ScrollY {
- get {
- return _scrollY;
- }
+ public virtual int MaxScrollX {
+ get { return maxScrollX; }
set {
- if (_scrollY == value)
+ if (maxScrollX == value)
return;
- if (value < 0)
- _scrollY = 0;
- else if (value > Child.Slot.Height - ClientRectangle.Height)
- _scrollY = Math.Max(0,Child.Slot.Height - ClientRectangle.Height);
- else
- _scrollY = value;
- NotifyValueChanged("ScrollY", _scrollY);
- RegisterForRedraw ();
- Scrolled.Raise (this, new ScrollingEventArgs (Orientation.Vertical));
+
+ maxScrollX = value;
+
+ if (scrollX > maxScrollX)
+ ScrollX = maxScrollX;
+
+ NotifyValueChanged ("MaxScrollX", maxScrollX);
+ RegisterForGraphicUpdate ();
}
}
+ /// <summary> Vertical Scrolling maximum value </summary>
+ [XmlAttributeAttribute][DefaultValue(0)]
+ public virtual int MaxScrollY {
+ get { return maxScrollY; }
+ set {
+ if (maxScrollY == value)
+ return;
+
+ maxScrollY = value;
+
+ if (scrollY > maxScrollY)
+ ScrollY = maxScrollY;
- [XmlIgnore]
- public int MaximumScroll {
- get {
- try {
- return VerticalScrolling ?
- Math.Max(Child.Slot.Height - ClientRectangle.Height,0) :
- Math.Max(Child.Slot.Width - ClientRectangle.Width,0);
- } catch {
- return 0;
- }
+ NotifyValueChanged ("MaxScrollY", maxScrollY);
+ RegisterForGraphicUpdate ();
}
}
-
- [XmlAttributeAttribute][DefaultValue(30)]
- public int ScrollSpeed {
+ /// <summary> Mouse Wheel Scrolling multiplier </summary>
+ [XmlAttributeAttribute][DefaultValue(50)]
+ public virtual int ScrollSpeed {
get { return scrollSpeed; }
set {
+ if (scrollSpeed == value)
+ return;
+
scrollSpeed = value;
- NotifyValueChanged("ScrollSpeed", scrollSpeed);
+
+ NotifyValueChanged ("ScrollSpeed", scrollSpeed);
}
}
#endregion
- #region GraphicObject Overrides
- public override void OnLayoutChanges (LayoutingType layoutType)
+ public override void SetChild (GraphicObject _child)
{
- base.OnLayoutChanges (layoutType);
+ Group g = child as Group;
+ if (g != null)
+ g.ChildrenCleared -= onChildListCleared;
+
+ base.SetChild (_child);
- NotifyValueChanged("MaximumScroll", MaximumScroll);
- if (layoutType == LayoutingType.Height) {
- NotifyValueChanged ("PageHeight", Slot.Height);
- if (child?.Slot.Height > 0)
- NotifyValueChanged ("ChildHeightRatio", Slot.Height * Slot.Height / child.Slot.Height);
- } else {
- NotifyValueChanged ("PageWidth", Slot.Width);
- if (child?.Slot.Width > 0)
- NotifyValueChanged ("ChildWidthRatio", Slot.Width * Slot.Width / child.Slot.Width);
- }
+ g = _child as Group;
+ if (g != null)
+ g.ChildrenCleared += onChildListCleared;
}
- void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
+ public override void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
{
- //Debug.WriteLine ("scroller childLayoutChanges");
- int maxScroll = MaximumScroll;
- //Debug.WriteLine ("maxscroll={0}", maxScroll);
- if (_verticalScrolling) {
- if (arg.LayoutType == LayoutingType.Height) {
- if (maxScroll < ScrollY) {
- //Debug.WriteLine ("scrolly={0} maxscroll={1}", ScrollY, maxScroll);
- ScrollY = maxScroll;
- }
- NotifyValueChanged("MaximumScroll", maxScroll);
- if (child?.Slot.Height > 0)
- NotifyValueChanged ("ChildHeightRatio", Slot.Height * Slot.Height / child.Slot.Height);
- }
- } else if (arg.LayoutType == LayoutingType.Width) {
- if (maxScroll < ScrollX) {
- //Debug.WriteLine ("scrolly={0} maxscroll={1}", ScrollY, maxScroll);
- ScrollX = maxScroll;
- }
- NotifyValueChanged("MaximumScroll", maxScroll);
- if (child?.Slot.Width > 0)
- NotifyValueChanged ("ChildWidthRatio", Slot.Width * Slot.Width / child.Slot.Width);
- }
+ base.OnChildLayoutChanges (sender, arg);
+ updateMaxScroll (arg.LayoutType);
}
- void onChildListCleared(object sender, EventArgs e){
- ScrollY = 0;
- ScrollX = 0;
+
+
+ #region GraphicObject Overrides
+ public override Rectangle ScreenCoordinates (Rectangle r)
+ {
+ return base.ScreenCoordinates (r) - new Point((int)ScrollX,(int)ScrollY);
}
- public override void SetChild (GraphicObject _child)
+ public override bool PointIsIn (ref Point m)
{
- GraphicObject c = child as GraphicObject;
- Group g = child as Group;
- if (c != null) {
- c.LayoutChanged -= OnChildLayoutChanges;
- if (g != null)
- g.ChildrenCleared -= onChildListCleared;
- }
- c = _child as GraphicObject;
- g = _child as Group;
- if (c != null) {
- c.LayoutChanged += OnChildLayoutChanges;
- if (g != null)
- g.ChildrenCleared += onChildListCleared;
- }
- base.SetChild (_child);
+ if (!base.PointIsIn(ref m))
+ return false;
+ if (!Slot.ContainsOrIsEqual (m) || child==null)
+ return false;
+ m += new Point (ScrollX, ScrollY);
+ return true;
}
- public override Rectangle ScreenCoordinates (Rectangle r)
+ public override void RegisterClip (Rectangle clip)
{
- return base.ScreenCoordinates (r) - new Point((int)ScrollX,(int)ScrollY);
+ base.RegisterClip (clip - new Point(ScrollX,ScrollY));
+ }
+ public override void OnLayoutChanges (LayoutingType layoutType)
+ {
+ base.OnLayoutChanges (layoutType);
+
+ if (layoutType == LayoutingType.Height)
+ NotifyValueChanged ("PageHeight", Slot.Height);
+ else if (layoutType == LayoutingType.Width)
+ NotifyValueChanged ("PageWidth", Slot.Width);
+ else
+ return;
+ updateMaxScroll(layoutType);
}
protected override void onDraw (Context gr)
{
gr.Restore ();
}
- #region Mouse handling
- //internal Point savedMousePos;
-
- public override bool PointIsIn (ref Point m)
- {
- if (!base.PointIsIn(ref m))
- return false;
- if (!Slot.ContainsOrIsEqual (m) || child==null)
- return false;
- m += new Point (ScrollX, ScrollY);
- return true;
- }
-// public override bool MouseIsIn (Point m)
-// {
-// return Visible ? base.ScreenCoordinates(Slot).ContainsOrIsEqual (m) : false;
-// }
-// public override void checkHoverWidget (MouseMoveEventArgs e)
-// {
-// savedMousePos = e.Position;
-// Point m = e.Position - new Point (ScrollX, ScrollY);
-// base.checkHoverWidget (new MouseMoveEventArgs(m.X,m.Y,e.XDelta,e.YDelta));
-// }
+ #region Mouse & Keyboard
+ /// <summary> Process scrolling vertically, or if shift is down, vertically </summary>
public override void onMouseWheel (object sender, MouseWheelEventArgs e)
{
- if (Child == null)
- return;
-
- if (VerticalScrolling )
+ base.onMouseWheel (sender, e);
+ if (IFace.Keyboard.IsKeyDown (Key.ShiftLeft))
+ ScrollX += e.Delta * ScrollSpeed;
+ else
ScrollY -= e.Delta * ScrollSpeed;
- if (HorizontalScrolling )
- ScrollX -= e.Delta * ScrollSpeed;
}
-// public override void onMouseMove (object sender, MouseMoveEventArgs e)
-// {
-// savedMousePos.X += e.XDelta;
-// savedMousePos.Y += e.YDelta;
-// base.onMouseMove (sender, new MouseMoveEventArgs(savedMousePos.X,savedMousePos.Y,e.XDelta,e.YDelta));
-// }
- public override void RegisterClip (Rectangle clip)
+ /// <summary> Process scrolling with arrow keys, home and end keys. </summary>
+ public override void onKeyDown (object sender, KeyboardKeyEventArgs e)
{
- base.RegisterClip (clip - new Point(ScrollX,ScrollY));
+ base.onKeyDown (sender, e);
+
+ if (KeyEventsOverrides)
+ return;
+
+ switch (e.Key) {
+ case Key.Up:
+ ScrollY--;
+ break;
+ case Key.Down:
+ ScrollY++;
+ break;
+ case Key.Left:
+ ScrollX--;
+ break;
+ case Key.Right:
+ ScrollX++;
+ break;
+ case Key.Home:
+ ScrollX = 0;
+ ScrollY = 0;
+ break;
+ case Key.End:
+ ScrollX = MaxScrollX;
+ ScrollY = MaxScrollY;
+ break;
+ }
}
#endregion
#endregion
+
+ void updateMaxScroll (LayoutingType lt){
+ if (Child == null) {
+ MaxScrollX = 0;
+ MaxScrollY = 0;
+ return;
+ }
+
+ Rectangle cb = ClientRectangle;
+
+ if (lt == LayoutingType.Height) {
+ MaxScrollY = child.Slot.Height - cb.Height;
+ if (child.Slot.Height > 0)
+ NotifyValueChanged ("ChildHeightRatio", Slot.Height * Slot.Height / child.Slot.Height);
+ } else if (lt == LayoutingType.Width) {
+ MaxScrollX = child.Slot.Width - cb.Width;
+ if (child.Slot.Width > 0)
+ NotifyValueChanged ("ChildWidthRatio", Slot.Width * Slot.Width / child.Slot.Width);
+ }
+ }
+ void onChildListCleared(object sender, EventArgs e){
+ ScrollY = 0;
+ ScrollX = 0;
+ }
+
+
}
}
}
cursor.Inflate (-1);
}
-
+ Point mouseDownInit;
+ double mouseDownInitValue;
+
#region mouse handling
public override void onMouseDown (object sender, MouseButtonEventArgs e)
{
base.onMouseDown (sender, e);
-
+ mouseDownInit = ScreenPointToLocal (e.Position);
+ mouseDownInitValue = Value;
Rectangle cursInScreenCoord = ScreenCoordinates (cursor + Slot.Position);
- if (cursInScreenCoord.ContainsOrIsEqual (e.Position))
+ if (cursInScreenCoord.ContainsOrIsEqual (e.Position)){
+// Rectangle r = ClientRectangle;
+// if (r.Width - _cursorSize > 0) {
+// double unit = (Maximum - Minimum) / (double)(r.Width - _cursorSize);
+// mouseDownInit += new Point ((int)(Value / unit), (int)(Value / unit));
+// }
holdCursor = true;
- else if (_orientation == Orientation.Horizontal) {
+ }else if (_orientation == Orientation.Horizontal) {
if (e.Position.X < cursInScreenCoord.Left)
Value -= LargeIncrement;
else
public override void onMouseMove (object sender, MouseMoveEventArgs e)
{
if (holdCursor) {
- Point m = ScreenPointToLocal (e.Position);
+ Point m = ScreenPointToLocal (e.Position) - mouseDownInit;
Rectangle r = ClientRectangle;
if (_orientation == Orientation.Horizontal) {
if (r.Width - _cursorSize == 0)
return;
double unit = (Maximum - Minimum) / (double)(r.Width - _cursorSize);
- double tmp = (double)m.X * unit;
+ double tmp = mouseDownInitValue + (double)m.X * unit;
tmp -= tmp % SmallIncrement;
Value = tmp;
} else {
if (r.Height - _cursorSize == 0)
return;
double unit = (Maximum - Minimum) / (double)(r.Height - _cursorSize);
- double tmp = (double)m.Y * unit;
+ double tmp = mouseDownInitValue + (double)m.Y * unit;
tmp -= tmp % SmallIncrement;
Value = tmp;
}
-
-
}
base.onMouseMove (sender, e);