aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/Button.cs15
-rw-r--r--src/GraphicObjects/Container.cs4
-rw-r--r--src/GraphicObjects/GenericStack.cs1
-rw-r--r--src/GraphicObjects/GraphicObject.cs16
-rw-r--r--src/GraphicObjects/Group.cs4
-rw-r--r--src/GraphicObjects/Image.cs79
-rw-r--r--src/GraphicObjects/Menu.cs6
-rw-r--r--src/GraphicObjects/MenuItem.cs67
-rw-r--r--src/GraphicObjects/Popper.cs40
-rw-r--r--src/GraphicObjects/TemplatedContainer.cs4
-rw-r--r--src/GraphicObjects/TemplatedControl.cs4
-rw-r--r--src/GraphicObjects/TemplatedGroup.cs58
-rw-r--r--src/GraphicObjects/TreeView.cs27
-rw-r--r--src/GraphicObjects/Window.cs149
14 files changed, 338 insertions, 136 deletions
diff --git a/src/GraphicObjects/Button.cs b/src/GraphicObjects/Button.cs
index 1cfbe85c..c73062f0 100644
--- a/src/GraphicObjects/Button.cs
+++ b/src/GraphicObjects/Button.cs
@@ -26,7 +26,6 @@ namespace Crow
public event EventHandler Pressed;
public event EventHandler Released;
- public event EventHandler Clicked;
#region TemplatedContainer overrides
public override GraphicObject Content {
@@ -34,7 +33,7 @@ namespace Crow
return _contentContainer == null ? null : _contentContainer.Child;
}
set {
- if (_contentContainer != null)
+ if (_contentContainer != null)
_contentContainer.SetChild(value);
}
}
@@ -69,24 +68,24 @@ namespace Crow
[XmlAttributeAttribute][DefaultValue("Button")]
public string Caption {
- get { return caption; }
+ get { return caption; }
set {
if (caption == value)
return;
- caption = value;
+ caption = value;
NotifyValueChanged ("Caption", caption);
}
- }
+ }
[XmlAttributeAttribute][DefaultValue("#Crow.Images.button.svg")]
public string Image {
- get { return image; }
+ get { return image; }
set {
if (image == value)
return;
- image = value;
+ image = value;
NotifyValueChanged ("Image", image);
}
- }
+ }
[XmlAttributeAttribute][DefaultValue(false)]
public bool IsPressed
{
diff --git a/src/GraphicObjects/Container.cs b/src/GraphicObjects/Container.cs
index 0b6045bb..be6774b5 100644
--- a/src/GraphicObjects/Container.cs
+++ b/src/GraphicObjects/Container.cs
@@ -50,8 +50,10 @@ namespace Crow
if (t == null) {
Assembly a = Assembly.GetEntryAssembly ();
foreach (Type expT in a.GetExportedTypes ()) {
- if (expT.Name == subTree.Name)
+ if (expT.Name == subTree.Name) {
t = expT;
+ break;
+ }
}
}
GraphicObject go = (GraphicObject)Activator.CreateInstance(t);
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs
index a2d78d88..0636c14e 100644
--- a/src/GraphicObjects/GenericStack.cs
+++ b/src/GraphicObjects/GenericStack.cs
@@ -29,6 +29,7 @@ namespace Crow
return;
_spacing = value;
NotifyValueChanged ("Spacing", Spacing);
+ RegisterForLayouting (LayoutingType.Sizing|LayoutingType.ArrangeChildren);
}
}
[XmlAttributeAttribute()][DefaultValue(Orientation.Horizontal)]
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index e0e6affc..574870f8 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -270,7 +270,6 @@ namespace Crow
set {
if (horizontalAlignment == value)
return;
-
horizontalAlignment = value;
NotifyValueChanged("HorizontalAlignment", horizontalAlignment);
RegisterForLayouting (LayoutingType.X);
@@ -282,7 +281,6 @@ namespace Crow
set {
if (left == value)
return;
-
left = value;
NotifyValueChanged ("Left", left);
this.RegisterForLayouting (LayoutingType.X);
@@ -294,7 +292,6 @@ namespace Crow
set {
if (top == value)
return;
-
top = value;
NotifyValueChanged ("Top", top);
this.RegisterForLayouting (LayoutingType.Y);
@@ -509,10 +506,6 @@ namespace Crow
isVisible = value;
- //ensure main win doesn't keep hidden childrens ref
- if (!isVisible && this.Contains (CurrentInterface.HoverWidget))
- CurrentInterface.HoverWidget = null;
-
if (isVisible)
RegisterForLayouting (LayoutingType.Sizing);
else {
@@ -524,6 +517,8 @@ namespace Crow
LastSlots.Width = LastSlots.Height = 0;
}
+ //trigger a mouse to handle possible hover changes
+ CurrentInterface.ProcessMouseMove (CurrentInterface.Mouse.X, CurrentInterface.Mouse.Y);
NotifyValueChanged ("Visible", isVisible);
}
@@ -893,6 +888,7 @@ namespace Crow
#if DEBUG_LAYOUTING
CurrentInterface.currentLQI.Slot = LastSlots;
CurrentInterface.currentLQI.NewSlot = Slot;
+ Debug.WriteLine ("\t\t{0} => {1}",LastSlots,Slot);
#endif
switch (layoutType) {
@@ -1193,7 +1189,7 @@ namespace Crow
if (p != null)
p.onMouseMove(sender,e);
- MouseMove.Raise (sender, e);
+ MouseMove.Raise (this, e);
}
public virtual void onMouseDown(object sender, MouseButtonEventArgs e){
if (CurrentInterface.eligibleForDoubleClick == this && CurrentInterface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick)
@@ -1202,8 +1198,8 @@ namespace Crow
currentInterface.clickTimer.Restart();
CurrentInterface.eligibleForDoubleClick = null;
- if (CurrentInterface.activeWidget == null)
- CurrentInterface.activeWidget = this;
+ if (CurrentInterface.ActiveWidget == null)
+ CurrentInterface.ActiveWidget = this;
if (this.Focusable && !Interface.FocusOnHover) {
BubblingMouseButtonEventArg be = e as BubblingMouseButtonEventArg;
if (be.Focused == null) {
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs
index a285e282..3c509185 100644
--- a/src/GraphicObjects/Group.cs
+++ b/src/GraphicObjects/Group.cs
@@ -337,8 +337,10 @@ namespace Crow
if (t == null) {
Assembly a = Assembly.GetEntryAssembly ();
foreach (Type expT in a.GetExportedTypes ()) {
- if (expT.Name == subTree.Name)
+ if (expT.Name == subTree.Name) {
t = expT;
+ break;
+ }
}
}
if (t == null)
diff --git a/src/GraphicObjects/Image.cs b/src/GraphicObjects/Image.cs
index fa036b97..281011ad 100644
--- a/src/GraphicObjects/Image.cs
+++ b/src/GraphicObjects/Image.cs
@@ -11,66 +11,81 @@ namespace Crow
{
Picture _pic;
string _svgSub;
- bool scaled;
- [XmlAttributeAttribute()][DefaultValue(true)]
+ bool scaled, keepProps;
+
+ #region Public properties
+ [XmlAttributeAttribute][DefaultValue(true)]
public virtual bool Scaled {
get { return scaled; }
set {
if (scaled == value)
return;
- scaled = value;
+ scaled = value;
NotifyValueChanged ("Scaled", scaled);
if (_pic == null)
return;
_pic.Scaled = scaled;
RegisterForGraphicUpdate ();
}
- }
- bool keepProps;
- [XmlAttributeAttribute()][DefaultValue(true)]
+ }
+ [XmlAttributeAttribute][DefaultValue(true)]
public virtual bool KeepProportions {
get { return keepProps; }
set {
if (keepProps == value)
return;
- keepProps = value;
+ keepProps = value;
NotifyValueChanged ("KeepProportions", keepProps);
if (_pic == null)
return;
_pic.KeepProportions = keepProps;
RegisterForGraphicUpdate ();
}
- }
- [XmlAttributeAttribute("Path")]
+ }
+ [XmlAttributeAttribute]
public string Path {
- get { return _pic == null ? null : _pic.Path; }
- set {
+ get { return _pic == null ? "" : _pic.Path; }
+ set {
+ if (value == Path)
+ return;
try {
- if (string.IsNullOrEmpty(value)){
- _pic = null;
- return;
- }
- lock(CurrentInterface.LayoutMutex){
- LoadImage (value);
- _pic.Scaled = scaled;
- _pic.KeepProportions = keepProps;
+ if (string.IsNullOrEmpty(value))
+ Picture = null;
+ else {
+ lock(CurrentInterface.LayoutMutex){
+ LoadImage (value);
+ }
}
} catch (Exception ex) {
Debug.WriteLine (ex.Message);
_pic = null;
}
+ NotifyValueChanged ("Path", Path);
}
}
-
- [XmlAttributeAttribute()][DefaultValue(null)]
+ [XmlAttributeAttribute]
public string SvgSub {
get { return _svgSub; }
set {
+ if (_svgSub == value)
+ return;
_svgSub = value;
RegisterForGraphicUpdate ();
}
}
-
+ [XmlAttributeAttribute]
+ public Picture Picture {
+ get { return _pic; }
+ set {
+ if (_pic == value)
+ return;
+ _pic = value;
+ NotifyValueChanged ("Picture", _pic);
+ RegisterForGraphicUpdate ();
+ }
+ }
+ #endregion
+
#region CTOR
public Image () : base()
{
@@ -80,14 +95,17 @@ namespace Crow
#region Image Loading
public void LoadImage (string path)
{
+ Picture pic;
+ if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture))
+ pic = new SvgPicture ();
+ else
+ pic = new BmpPicture ();
- if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture))
- _pic = new SvgPicture ();
- else
- _pic = new BmpPicture ();
+ pic.LoadImage (path);
+ pic.Scaled = scaled;
+ pic.KeepProportions = keepProps;
- _pic.LoadImage (path);
- RegisterForGraphicUpdate ();
+ Picture = pic;
}
#endregion
@@ -95,12 +113,13 @@ namespace Crow
protected override int measureRawSize (LayoutingType lt)
{
if (_pic == null)
- _pic = "#Crow.Images.Icons.IconAlerte.svg";
+ return 2 * Margin;
+ //_pic = "#Crow.Images.Icons.IconAlerte.svg";
//TODO:take scalling in account
if (lt == LayoutingType.Width)
return _pic.Dimensions.Width + 2 * Margin;
else
- return _pic.Dimensions.Height + 2 * Margin;
+ return _pic.Dimensions.Height + 2 * Margin;
}
protected override void onDraw (Context gr)
{
diff --git a/src/GraphicObjects/Menu.cs b/src/GraphicObjects/Menu.cs
index 1a7a3f95..66d23194 100644
--- a/src/GraphicObjects/Menu.cs
+++ b/src/GraphicObjects/Menu.cs
@@ -31,8 +31,10 @@ namespace Crow
#endregion
Orientation orientation;
+ bool autoOpen = false;
- [XmlAttributeAttribute()][DefaultValue(Orientation.Horizontal)]
+ #region Public properties
+ [XmlAttributeAttribute][DefaultValue(Orientation.Horizontal)]
public Orientation Orientation {
get { return orientation; }
set {
@@ -42,12 +44,12 @@ namespace Crow
NotifyValueChanged ("Orientation", orientation);
}
}
- bool autoOpen = false;
[XmlIgnore]public bool AutomaticOpenning
{
get { return autoOpen; }
set { autoOpen = value; }
}
+ #endregion
public override void AddItem (GraphicObject g)
{
diff --git a/src/GraphicObjects/MenuItem.cs b/src/GraphicObjects/MenuItem.cs
index 80b5759d..adec326f 100644
--- a/src/GraphicObjects/MenuItem.cs
+++ b/src/GraphicObjects/MenuItem.cs
@@ -32,12 +32,14 @@ namespace Crow
public event EventHandler Open;
public event EventHandler Close;
- public event EventHandler Execute;
string caption;
- Command command;//TODO
+ Command command;
+ Picture icon;
bool isOpened;
+ Measure popWidth, popHeight;
+ #region Public properties
[XmlAttributeAttribute][DefaultValue(false)]
public bool IsOpened {
get { return isOpened; }
@@ -54,38 +56,87 @@ namespace Crow
onClose (this, null);
}
}
-
[XmlAttributeAttribute][DefaultValue(null)]
public virtual Command Command {
get { return command; }
set {
if (command == value)
return;
+
+ if (command != null) {
+ command.raiseAllValuesChanged ();
+ command.ValueChanged -= Command_ValueChanged;
+ }
+
command = value;
+
+ if (command != null) {
+ command.ValueChanged += Command_ValueChanged;
+ command.raiseAllValuesChanged ();
+ }
+
NotifyValueChanged ("Command", command);
}
}
-
[XmlAttributeAttribute][DefaultValue("MenuItem")]
public string Caption {
- get { return caption; }
+ get { return Command == null ? caption : Command.Caption; }
set {
if (caption == value)
return;
caption = value;
- NotifyValueChanged ("Caption", caption);
+
+ if (command == null)//raise value changed only if not bound to a command
+ NotifyValueChanged ("Caption", caption);
+ }
+ }
+ [XmlAttributeAttribute]
+ public Picture Icon {
+ get { return Command == null ? icon : Command.Icon;; }
+ set {
+ if (icon == value)
+ return;
+ icon = value;
+ if (command == null)
+ NotifyValueChanged ("Icon", icon);
}
}
-
+ [XmlAttributeAttribute()][DefaultValue("Fit")]
+ public virtual Measure PopWidth {
+ get { return popWidth; }
+ set {
+ if (popWidth == value)
+ return;
+ popWidth = value;
+ NotifyValueChanged ("PopWidth", popWidth);
+ }
+ }
+ [XmlAttributeAttribute()][DefaultValue("Fit")]
+ public virtual Measure PopHeight {
+ get { return popHeight; }
+ set {
+ if (popHeight == value)
+ return;
+ popHeight = value;
+ NotifyValueChanged ("PopHeight", popHeight);
+ }
+ }
+ #endregion
+
public override void AddItem (GraphicObject g)
{
base.AddItem (g);
g.NotifyValueChanged ("PopDirection", Alignment.Right);
}
+ void Command_ValueChanged (object sender, ValueChangeEventArgs e)
+ {
+ NotifyValueChanged (e.MemberName, e.NewValue);
+ }
void onMI_Click (object sender, MouseButtonEventArgs e)
{
- Execute.Raise (this, null);
+ if (command != null)
+ command.Execute ();
if(!IsOpened)
(LogicalParent as Menu).AutomaticOpenning = false;
}
diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs
index 38621337..8c79ce24 100644
--- a/src/GraphicObjects/Popper.cs
+++ b/src/GraphicObjects/Popper.cs
@@ -38,6 +38,7 @@ namespace Crow
string caption;
Alignment popDirection;
GraphicObject _content;
+ Measure popWidth, popHeight;
public event EventHandler Pop;
public event EventHandler Unpop;
@@ -53,6 +54,26 @@ namespace Crow
NotifyValueChanged ("Caption", caption);
}
}
+ [XmlAttributeAttribute()][DefaultValue("Fit")]
+ public virtual Measure PopWidth {
+ get { return popWidth; }
+ set {
+ if (popWidth == value)
+ return;
+ popWidth = value;
+ NotifyValueChanged ("PopWidth", popWidth);
+ }
+ }
+ [XmlAttributeAttribute()][DefaultValue("Fit")]
+ public virtual Measure PopHeight {
+ get { return popHeight; }
+ set {
+ if (popHeight == value)
+ return;
+ popHeight = value;
+ NotifyValueChanged ("PopHeight", popHeight);
+ }
+ }
[XmlAttributeAttribute()][DefaultValue(false)]
public bool IsPopped
{
@@ -164,18 +185,6 @@ namespace Crow
}
#region GraphicObject overrides
- public override void OnLayoutChanges (LayoutingType layoutType)
- {
- base.OnLayoutChanges (layoutType);
-
- if (_content == null)
- return;
-
- if (layoutType == LayoutingType.Width)
- _content.MinimumSize = new Size (this.Slot.Width, _content.MinimumSize.Height);
- }
-
-
public override void onMouseClick (object sender, MouseButtonEventArgs e)
{
if (_canPop)
@@ -219,16 +228,17 @@ namespace Crow
if (Content != null) {
Content.Visible = true;
if (Content.Parent == null)
- CurrentInterface.AddWidget (Content);
- CurrentInterface.PutOnTop (Content);
+ CurrentInterface.AddWidget (Content, true);
+ CurrentInterface.PutOnTop (Content, true);
_content_LayoutChanged (this, new LayoutingEventArgs (LayoutingType.Sizing));
}
Pop.Raise (this, e);
}
public virtual void onUnpop(object sender, EventArgs e)
{
- if (Content != null)
+ if (Content != null) {
Content.Visible = false;
+ }
Unpop.Raise (this, e);
}
}
diff --git a/src/GraphicObjects/TemplatedContainer.cs b/src/GraphicObjects/TemplatedContainer.cs
index 44c2ad08..f4243588 100644
--- a/src/GraphicObjects/TemplatedContainer.cs
+++ b/src/GraphicObjects/TemplatedContainer.cs
@@ -84,8 +84,10 @@ namespace Crow
if (t == null) {
Assembly a = Assembly.GetEntryAssembly ();
foreach (Type expT in a.GetExportedTypes ()) {
- if (expT.Name == xr.Name)
+ if (expT.Name == xr.Name) {
t = expT;
+ break;
+ }
}
}
if (t == null)
diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs
index ba49f44f..4a3a2507 100644
--- a/src/GraphicObjects/TemplatedControl.cs
+++ b/src/GraphicObjects/TemplatedControl.cs
@@ -154,8 +154,10 @@ namespace Crow
if (t == null) {
Assembly a = Assembly.GetEntryAssembly ();
foreach (Type expT in a.GetExportedTypes ()) {
- if (expT.Name == xr.Name)
+ if (expT.Name == xr.Name) {
t = expT;
+ break;
+ }
}
}
GraphicObject go = (GraphicObject)Activator.CreateInstance (t);
diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs
index 772b89cf..4c35197f 100644
--- a/src/GraphicObjects/TemplatedGroup.cs
+++ b/src/GraphicObjects/TemplatedGroup.cs
@@ -40,6 +40,7 @@ namespace Crow
#region events
public event EventHandler<SelectionChangeEventArgs> SelectedItemChanged;
+ public event EventHandler Loaded;
#endregion
IList data;
@@ -47,7 +48,7 @@ namespace Crow
Color selBackground, selForeground;
int itemPerPage = 50;
- Thread loadingThread = null;
+ CrowThread loadingThread = null;
volatile bool cancelLoading = false;
#region Templating
@@ -106,11 +107,11 @@ namespace Crow
public virtual List<GraphicObject> Items{ get { return items.Children; }}
[XmlAttributeAttribute][DefaultValue(-1)]public int SelectedIndex{
get { return _selectedIndex; }
- set {
+ set {
if (value == _selectedIndex)
return;
- _selectedIndex = value;
+ _selectedIndex = value;
NotifyValueChanged ("SelectedIndex", _selectedIndex);
NotifyValueChanged ("SelectedItem", SelectedItem);
@@ -135,14 +136,14 @@ namespace Crow
NotifyValueChanged ("Data", data);
- lock (CurrentInterface.UpdateMutex)
+ //lock (CurrentInterface.UpdateMutex)
ClearItems ();
if (data == null)
return;
- loadingThread = new Thread (loading);
- loadingThread.IsBackground = true;
+ loadingThread = new CrowThread (this, loading);
+ loadingThread.Finished += (object sender, EventArgs e) => (sender as TemplatedGroup).Loaded.Raise (sender, e);
loadingThread.Start ();
//loadPage(1);
@@ -179,7 +180,7 @@ namespace Crow
protected void raiseSelectedItemChanged(){
SelectedItemChanged.Raise (this, new SelectionChangeEventArgs (SelectedItem));
}
-
+
public virtual void AddItem(GraphicObject g){
items.AddChild (g);
@@ -271,8 +272,10 @@ namespace Crow
if (t == null) {
Assembly a = Assembly.GetEntryAssembly ();
foreach (Type expT in a.GetExportedTypes ()) {
- if (expT.Name == xr.Name)
+ if (expT.Name == xr.Name) {
t = expT;
+ break;
+ }
}
}
if (t == null)
@@ -310,13 +313,8 @@ namespace Crow
}
}
void cancelLoadingThread(){
- if (loadingThread == null)
- return;
- if (!loadingThread.IsAlive)
- return;
- cancelLoading = true;
- loadingThread.Join ();
- cancelLoading = false;
+ if (loadingThread != null)
+ loadingThread.Cancel ();
}
void loadPage(int pageNum)
{
@@ -341,7 +339,7 @@ namespace Crow
page = gs;
}else
- page = Activator.CreateInstance (items.GetType ()) as Group;
+ page = Activator.CreateInstance (items.GetType ()) as Group;
page.Name = "page" + pageNum;
@@ -374,6 +372,8 @@ namespace Crow
}
}
protected void loadItem(int i, Group page){
+ if (data [i] == null)//TODO:surely a threading sync problem
+ return;
GraphicObject g = null;
ItemTemplate iTemp = null;
Type dataType = data [i].GetType ();
@@ -383,9 +383,29 @@ namespace Crow
itempKey = getItempKey (dataType, data [i]);
if (ItemTemplates.ContainsKey (itempKey))
- iTemp = ItemTemplates [itempKey];
- else
- iTemp = ItemTemplates ["default"];
+ iTemp = ItemTemplates [itempKey];
+ else {
+ foreach (string it in ItemTemplates.Keys) {
+ Type t = Type.GetType (it);
+ if (t == null) {
+ Assembly a = Assembly.GetEntryAssembly ();
+ foreach (Type expT in a.GetExportedTypes ()) {
+ if (expT.Name == it) {
+ t = expT;
+ break;
+ }
+ }
+ }
+ if (t == null)
+ continue;
+ if (t.IsAssignableFrom (dataType)) {//TODO:types could be cached
+ iTemp = ItemTemplates [it];
+ break;
+ }
+ }
+ if (iTemp == null)
+ iTemp = ItemTemplates ["default"];
+ }
lock (CurrentInterface.LayoutMutex) {
g = iTemp.CreateInstance(CurrentInterface);
diff --git a/src/GraphicObjects/TreeView.cs b/src/GraphicObjects/TreeView.cs
index 4fa881b4..d4354b65 100644
--- a/src/GraphicObjects/TreeView.cs
+++ b/src/GraphicObjects/TreeView.cs
@@ -48,7 +48,6 @@ namespace Crow
NotifyValueChanged ("IsRoot", isRoot);
}
}
-
[XmlIgnore]public override object SelectedItem {
get {
return selectedItemContainer == null ?
@@ -84,6 +83,32 @@ namespace Crow
NotifyValueChanged ("SelectedItem", SelectedItem);
raiseSelectedItemChanged ();
}
+
+ void onExpandAll_MouseClick (object sender, MouseButtonEventArgs e)
+ {
+ ExpandAll ();
+ }
+
+ public void ExpandAll(){
+ foreach (Group grp in items.Children) {
+ foreach (GraphicObject go in grp.Children) {
+ Expandable exp = go as Expandable;
+ if (exp == null)
+ continue;
+ TreeView subTV = exp.FindByName ("List") as TreeView;
+ if (subTV == null)
+ continue;
+ EventHandler handler = null;
+ handler = delegate(object sender, EventArgs e) {
+ TreeView tv = sender as TreeView;
+ tv.Loaded -= handler;
+ tv.ExpandAll ();
+ };
+ subTV.Loaded += handler;
+ exp.IsExpanded = true;
+ }
+ }
+ }
}
}
diff --git a/src/GraphicObjects/Window.cs b/src/GraphicObjects/Window.cs
index 86f05d86..9c1a0124 100644
--- a/src/GraphicObjects/Window.cs
+++ b/src/GraphicObjects/Window.cs
@@ -46,15 +46,20 @@ namespace Crow
bool _resizable;
bool _movable;
bool hoverBorder = false;
- bool isMaximized = false;
- Measure savedH, savedW;
+ bool alwaysOnTop = false;
+
+ Rectangle savedBounds;
+ bool _minimized = false;
Container _contentContainer;
Direction currentDirection = Direction.None;
+ #region Events
public event EventHandler Closing;
public event EventHandler Maximized;
public event EventHandler Unmaximized;
+ public event EventHandler Minimize;
+ #endregion
#region CTOR
public Window () : base() {
@@ -64,73 +69,115 @@ namespace Crow
#region TemplatedContainer overrides
public override GraphicObject Content {
- get {
- return _contentContainer == null ? null : _contentContainer.Child;
- }
- set {
- _contentContainer.SetChild(value);
- }
+ get { return _contentContainer == null ? null : _contentContainer.Child; }
+ set { _contentContainer.SetChild(value); }
}
protected override void loadTemplate(GraphicObject template = null)
{
base.loadTemplate (template);
_contentContainer = this.child.FindByName ("Content") as Container;
+
+ NotifyValueChanged ("ShowNormal", false);
+ NotifyValueChanged ("ShowMinimize", true);
+ NotifyValueChanged ("ShowMaximize", true);
}
#endregion
#region public properties
- [XmlAttributeAttribute()][DefaultValue("Window")]
+ [XmlAttributeAttribute][DefaultValue("Window")]
public string Title {
get { return _title; }
set {
+ if (_title == value)
+ return;
_title = value;
NotifyValueChanged ("Title", _title);
}
}
- [XmlAttributeAttribute()][DefaultValue("#Crow.Images.Icons.crow.png")]
+ [XmlAttributeAttribute][DefaultValue("#Crow.Images.Icons.crow.png")]
public string Icon {
get { return _icon; }
set {
+ if (_icon == value)
+ return;
_icon = value;
NotifyValueChanged ("Icon", _icon);
}
}
- [XmlAttributeAttribute()][DefaultValue(true)]
+ [XmlAttributeAttribute][DefaultValue(true)]
public bool Resizable {
get {
return _resizable;
}
set {
+ if (_resizable == value)
+ return;
_resizable = value;
NotifyValueChanged ("Resizable", _resizable);
}
}
- [XmlAttributeAttribute()][DefaultValue(true)]
+ [XmlAttributeAttribute][DefaultValue(true)]
public bool Movable {
get {
return _movable;
}
set {
+ if (_movable == value)
+ return;
_movable = value;
NotifyValueChanged ("Movable", _movable);
}
}
- [XmlAttributeAttribute()][DefaultValue(false)]
- public bool IsMaximized {
- get { return isMaximized; }
+ [XmlAttributeAttribute][DefaultValue(false)]
+ public bool IsMinimized {
+ get { return _minimized; }
set{
- if (value == isMaximized)
+ if (value == IsMinimized)
return;
- isMaximized = value;
- if (isMaximized)
- onMaximized (this, null);
- else
- onUnmaximized (this, null);
+ _minimized = value;
+ _contentContainer.Visible = !_minimized;
- NotifyValueChanged ("IsMaximized", isMaximized);
+ NotifyValueChanged ("IsMinimized", _minimized);
+ }
+ }
+ [XmlIgnore]public bool IsMaximized {
+ get { return Width == Measure.Stretched & Height == Measure.Stretched & !_minimized; }
+ }
+ [XmlIgnore]public bool IsNormal {
+ get { return !(IsMaximized|_minimized); }
+ }
+ [XmlAttributeAttribute][DefaultValue(false)]
+ public bool AlwaysOnTop {
+ get {
+ return alwaysOnTop;
+ }
+ set {
+ if (alwaysOnTop == value)
+ return;
+ alwaysOnTop = value;
+ if (alwaysOnTop) {
+ CurrentInterface.PutOnTop (this);
+ CurrentInterface.TopWindows++;
+ }else
+ CurrentInterface.TopWindows--;
+ NotifyValueChanged ("AlwaysOnTop", alwaysOnTop);
}
}
+// [XmlAttributeAttribute()][DefaultValue(WindowState.Normal)]
+// public virtual WindowState State {
+// get { return _state; }
+// set {
+// if (_state == value)
+// return;
+// _state = value;
+// NotifyValueChanged ("State", _state);
+// NotifyValueChanged ("IsNormal", IsNormal);
+// NotifyValueChanged ("IsMaximized", IsMaximized);
+// NotifyValueChanged ("IsMinimized", IsMinimized);
+// NotifyValueChanged ("IsNotMinimized", IsNotMinimized);
+// }
+// }
#endregion
#region GraphicObject Overrides
@@ -219,14 +266,6 @@ namespace Crow
return;
}
}
-// GraphicObject firstFocusableAncestor = otkgw.hoverWidget;
-// while (firstFocusableAncestor != this) {
-// if (firstFocusableAncestor == null)
-// return;
-// if (firstFocusableAncestor.Focusable)
-// return;
-// firstFocusableAncestor = firstFocusableAncestor.Parent as GraphicObject;
-// }
if (Resizable) {
Direction lastDir = currentDirection;
@@ -289,21 +328,56 @@ namespace Crow
base.onMouseDown (sender, e);
}
#endregion
+
protected void onMaximized (object sender, EventArgs e){
- savedW = this.Width;
- savedH = this.Height;
- this.Width = Measure.Stretched;
- this.Height = Measure.Stretched;
+ lock (CurrentInterface.LayoutMutex) {
+ if (!IsMinimized)
+ savedBounds = this.LastPaintedSlot;
+ this.Left = this.Top = 0;
+ this.RegisterForLayouting (LayoutingType.Positioning);
+ this.Width = this.Height = Measure.Stretched;
+ IsMinimized = false;
+ Resizable = false;
+ NotifyValueChanged ("ShowNormal", true);
+ NotifyValueChanged ("ShowMinimize", true);
+ NotifyValueChanged ("ShowMaximize", false);
+ }
Maximized.Raise (sender, e);
+
+
+
}
protected void onUnmaximized (object sender, EventArgs e){
- this.Width = savedW;
- this.Height = savedH;
+ lock (CurrentInterface.LayoutMutex) {
+ this.Left = savedBounds.Left;
+ this.Top = savedBounds.Top;
+ this.Width = savedBounds.Width;
+ this.Height = savedBounds.Height;
+ IsMinimized = false;
+ Resizable = true;
+ NotifyValueChanged ("ShowNormal", false);
+ NotifyValueChanged ("ShowMinimize", true);
+ NotifyValueChanged ("ShowMaximize", true);
+ }
Unmaximized.Raise (sender, e);
}
+ protected void onMinimized (object sender, EventArgs e){
+ lock (CurrentInterface.LayoutMutex) {
+ if (IsNormal)
+ savedBounds = this.LastPaintedSlot;
+ Width = 200;
+ Height = 20;
+ Resizable = false;
+ IsMinimized = true;
+ NotifyValueChanged ("ShowNormal", true);
+ NotifyValueChanged ("ShowMinimize", false);
+ NotifyValueChanged ("ShowMaximize", true);
+ }
+ Minimize.Raise (sender, e);
+ }
protected void onBorderMouseLeave (object sender, MouseMoveEventArgs e)
{
hoverBorder = false;
@@ -316,9 +390,6 @@ namespace Crow
}
- protected void butMaximizePress (object sender, MouseButtonEventArgs e){
- IsMaximized = !IsMaximized;
- }
protected void butQuitPress (object sender, MouseButtonEventArgs e)
{
CurrentInterface.MouseCursor = XCursor.Default;