AllowDrag = "true";
}
MessageBox {
- Background = "0.3,0.3,0.3,0.3";
+ Background = "0.1,0.1,0.2,0.7";
Width = "Fit";
Caption="MessageBox";
Font = "serif, 12";
<GraphicObject Width="5" Height="5"/>
</HorizontalStack>
</Border>
- <HorizontalStack Margin="5">
+ <HorizontalStack Margin="5" >
<Image Name="Image" Width="50" Height="30" Path="{./MsgIcon}" />
- <Label Margin="5" Font="{./Font}" Width="Fit" Text="{./Message}"
- TextAlignment="Left"
+ <Label Margin="5" Font="{./Font}" Width="Fit" Text="{./Message}"
+ TextAlignment="Center"
Multiline="true" />
</HorizontalStack>
- <HorizontalStack Margin="1" Spacing="0" Width="Fit" Height="Fit" HorizontalAlignment="Right">
+ <HorizontalStack Margin="4" Spacing="0" Width="Fit" Height="Fit" HorizontalAlignment="Right">
<Button Width="Fit" Caption="{./OkMessage}" MouseClick="./onOkButtonClick" />
- <Button Width="Fit" Caption="{./CancelMessage}" MouseClick="./onCancelButtonClick" />
+ <Button Width="Fit" Visible="{./NoButIsVisible}"
+ Caption="{./NoMessage}" MouseClick="./onNoButtonClick" />
+ <Button Width="Fit" Visible="{./CancelButIsVisible}"
+ Caption="{./CancelMessage}" MouseClick="./onCancelButtonClick" />
</HorizontalStack>
</VerticalStack>
</Border>
FpsLabel {
- Width = 50%;
- Font = droid, 10;
- Margin = 0;
- TextAlignment = Center;
- Background = Onyx;
+ Width = "50%";
+ Font = "droid, 10";
+ Margin = "0";
+ TextAlignment = "Center";
+ Background = "Onyx";
}
FpsDisp {
- Font = droid bold, 10;
- Width = 50%;
- Margin = 0;
- TextAlignment = Center;
- Background = Teal;
+ Font = "droid bold, 10";
+ Width = "50%";
+ Margin = "0";
+ TextAlignment = "Center";
+ Background = "Teal";
}
CheckBox2 {
- Template= #Tests.Interfaces.CheckBox2.imlt;
- Background = Onyx;
- Checked={Background=Mantis;Font=droid bold, 10};
- Unchecked = {Background=Onyx;Font=droid,10};
+ Template= "#Tests.Interfaces.CheckBox2.imlt";
+ Background = "Onyx";
+ Checked="{Background=Mantis;Font=droid bold, 10}";
+ Unchecked = "{Background=Onyx;Font=droid,10}";
}
RadioButton2 {
- Template=#Tests.Interfaces.CheckBox2.imlt;
- Background = Onyx;
- Checked = {Background=Mantis;Font=droid bold, 10};
- Unchecked = {Background=Onyx;Font=droid,10};
+ Template="#Tests.Interfaces.CheckBox2.imlt";
+ Background = "Onyx";
+ Checked = "{Background=Mantis;Font=droid bold, 10}";
+ Unchecked = "{Background=Onyx;Font=droid,10}";
}
labPerf {
- Font = droid, 8;
- Width = 50%;
+ Font = "droid, 8";
+ Width = "50%";
}
labPerfVal{
- Font = droid, 8;
- Width = 50%;
+ Font = "droid, 8";
+ Width = "50%";
}
-MouseEnter = {Background = Gray;Foreground = White;}
-Fit = true;
-MouseLeave = {Background=Transparent;Foreground=Gray;}
-MouseDown = {Background=Red;Foreground=White;}
-MouseUp = {Background=Gray;Foreground=White;}
-Foreground=Gray;
-Margin=5;
-CornerRadius=5;
+MouseEnter = "{Background = Gray;Foreground = White;}";
+Fit = "true";
+MouseLeave = "{Background=Transparent;Foreground=Gray;}";
+MouseDown = "{Background=Red;Foreground=White;}";
+MouseUp = "{Background=Gray;Foreground=White;}";
+Foreground="Gray";
+Margin="5";
+CornerRadius="5";
-Height = Fit;
-Width = Stretched;
-MinimumSize=60;10;
-Margin=2;
-CornerRadius=0;
-TextAlignment=Left;
-Foreground=Gray;
-MouseEnter = {Background=SeaGreen;Foreground=White;}
-MouseLeave = {Background=Transparent;Foreground=Gray;}
-MouseDown = {Background=White;Foreground=DimGray;}
-MouseUp = {Background=SeaGreen;Foreground=White;}
+Height = "Fit";
+Width = "Stretched";
+MinimumSize="60;10";
+Margin="2";
+CornerRadius="0";
+TextAlignment="Left";
+Foreground="Gray";
+MouseEnter = "{Background=SeaGreen;Foreground=White;}";
+MouseLeave = "{Background=Transparent;Foreground=Gray;}";
+MouseDown = "{Background=White;Foreground=DimGray;}";
+MouseUp = "{Background=SeaGreen;Foreground=White;}";
public virtual void OnTextChanged(Object sender, TextChangeEventArgs e)
{
+ textMeasureIsUpToDate = false;
NotifyValueChanged ("Text", Text);
TextChanged.Raise (this, e);
}
CurrentColumn = 0;
OnTextChanged (this, new TextChangeEventArgs (Text));
}
+ bool textMeasureIsUpToDate = false;
+ Size cachedTextSize = default(Size);
#region GraphicObject overrides
protected override int measureRawSize(LayoutingType lt)
- {
+ {
if (lines == null)
lines = getLines;
-
- using (ImageSurface img = new ImageSurface (Format.Argb32, 10, 10)) {
- using (Context gr = new Context (img)) {
- //Cairo.FontFace cf = gr.GetContextFontFace ();
-
- gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
- gr.SetFontSize (Font.Size);
-
-
- fe = gr.FontExtents;
- te = new TextExtents();
-
- if (lt == LayoutingType.Height){
- int lc = lines.Count;
- //ensure minimal height = text line height
- if (lc == 0)
- lc = 1;
-
- return (int)Math.Ceiling(fe.Height * lc) + Margin * 2;
+ if (!textMeasureIsUpToDate) {
+ using (ImageSurface img = new ImageSurface (Format.Argb32, 10, 10)) {
+ using (Context gr = new Context (img)) {
+ //Cairo.FontFace cf = gr.GetContextFontFace ();
+
+ gr.SelectFontFace (Font.Name, Font.Slant, Font.Wheight);
+ gr.SetFontSize (Font.Size);
+ gr.FontOptions = Interface.FontRenderingOptions;
+ gr.Antialias = Interface.Antialias;
+
+ fe = gr.FontExtents;
+ te = new TextExtents ();
+
+ cachedTextSize.Height = (int)Math.Ceiling ((fe.Ascent+fe.Descent) * Math.Max (1, lines.Count)) + Margin * 2;
+
+ try {
+ foreach (string s in lines) {
+ string l = s.Replace ("\t", new String (' ', Interface.TabSize));
+
+ TextExtents tmp = gr.TextExtents (l);
+
+ if (tmp.XAdvance > te.XAdvance)
+ te = tmp;
+ }
+ cachedTextSize.Width = (int)Math.Ceiling (te.XAdvance) + Margin * 2;
+ textMeasureIsUpToDate = true;
+ } catch {
+ return -1;
+ }
}
- try {
- foreach (string s in lines) {
- string l = s.Replace("\t", new String (' ', Interface.TabSize));
-
- TextExtents tmp = gr.TextExtents (l);
-
- if (tmp.XAdvance > te.XAdvance)
- te = tmp;
- }
- } catch (Exception ex) {
- return -1;
- }
- return (int)Math.Ceiling (te.XAdvance) + Margin * 2;
}
+
}
- }
+ return lt == LayoutingType.Height ? cachedTextSize.Height : cachedTextSize.Width;
+ }
protected override void onDraw (Context gr)
{
base.onDraw (gr);
break;
case Alignment.Center://ok
rText.X = cb.X + cb.Width / 2 - rText.Width / 2;
- rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
+ //rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
+ rText.Y = cb.Y + (int)Math.Floor((double)cb.Height / 2.0 - (double)rText.Height / 2.0);
break;
}
- gr.FontMatrix = new Matrix(widthRatio * (float)Font.Size, 0, 0, heightRatio * (float)Font.Size, 0, 0);
+ //gr.FontMatrix = new Matrix(widthRatio * (float)Font.Size, 0, 0, heightRatio * (float)Font.Size, 0, 0);
fe = gr.FontExtents;
#region draw text cursor
Foreground.SetAsSource (gr);
gr.LineWidth = 1.0;
- gr.MoveTo (0.5 + textCursorPos + rText.X, rText.Y + CurrentLine * fe.Height);
- gr.LineTo (0.5 + textCursorPos + rText.X, rText.Y + (CurrentLine + 1) * fe.Height);
+ gr.MoveTo (0.5 + textCursorPos + rText.X, rText.Y + CurrentLine * (fe.Ascent+fe.Descent));
+ gr.LineTo (0.5 + textCursorPos + rText.X, rText.Y + (CurrentLine + 1) * (fe.Ascent+fe.Descent));
gr.Stroke();
}
#endregion
// new SolidColor(Color.DarkGreen).SetAsSource(gr);
// Rectangle R = new Rectangle (
// rText.X + (int)SelEndCursorPos - 3,
-// rText.Y + (int)(SelRelease.Y * fe.Height),
+// rText.Y + (int)(SelRelease.Y * (fe.Ascent+fe.Descent)),
// 6,
-// (int)fe.Height);
+// (int)(fe.Ascent+fe.Descent));
// gr.Rectangle (R);
// gr.Fill ();
// }
// new SolidColor(Color.DarkRed).SetAsSource(gr);
// Rectangle R = new Rectangle (
// rText.X + (int)SelStartCursorPos - 3,
-// rText.Y + (int)(SelBegin.Y * fe.Height),
+// rText.Y + (int)(SelBegin.Y * (fe.Ascent+fe.Descent)),
// 6,
-// (int)fe.Height);
+// (int)(fe.Ascent+fe.Descent));
// gr.Rectangle (R);
// gr.Fill ();
// }
int lineLength = (int)gr.TextExtents (l).XAdvance;
Rectangle lineRect = new Rectangle (
rText.X,
- rText.Y + (int)Math.Ceiling(i * fe.Height),
+ rText.Y + (int)Math.Floor((double)i * (fe.Ascent+fe.Descent)),
lineLength,
- (int)Math.Ceiling(fe.Height));
+ (int)Math.Ceiling((fe.Ascent+fe.Descent)));
// if (TextAlignment == Alignment.Center ||
// TextAlignment == Alignment.Top ||
continue;
Foreground.SetAsSource (gr);
- gr.MoveTo (lineRect.X, rText.Y + fe.Ascent + fe.Height * i);
+ gr.MoveTo (lineRect.X,(double)rText.Y + fe.Ascent + (fe.Ascent+fe.Descent) * i) ;
gr.ShowText (l);
gr.Fill ();
gr.Save ();
gr.Clip ();
gr.SetSourceColor (SelectionForeground);
- gr.MoveTo (lineRect.X, rText.Y + fe.Ascent + fe.Height * i);
+ gr.MoveTo (lineRect.X, (double)rText.Y + fe.Ascent + (fe.Ascent+fe.Descent) * i);
gr.ShowText (l);
gr.Fill ();
gr.Restore ();
double cPos = 0f;
- CurrentLine = (int)(mouseLocalPos.Y / fe.Height);
+ CurrentLine = (int)(mouseLocalPos.Y / (fe.Ascent+fe.Descent));
//fix cu
if (CurrentLine >= lines.Count)
#endregion
public enum Type {
+ None,
Information,
- YesNo,
Alert,
- Error
+ Error,
+ YesNo,
+ YesNoCancel,
+
}
protected override void loadTemplate (GraphicObject template)
base.loadTemplate (template);
NotifyValueChanged ("MsgIcon", "#Crow.Images.Icons.Informations.svg");
}
- string message, okMessage, cancelMessage;
- Type msgType = Type.Information;
+ string message, okMessage, cancelMessage, noMessage;
+ Type msgType = Type.None;
- public event EventHandler Ok;
+ public event EventHandler Yes;
+ public event EventHandler No;
public event EventHandler Cancel;
- [XmlAttributeAttribute][DefaultValue("Informations")]
+ [DefaultValue("Informations")]
public virtual string Message
{
get { return message; }
NotifyValueChanged ("Message", message);
}
}
- [XmlAttributeAttribute][DefaultValue("Ok")]
+ [DefaultValue("Ok")]
public virtual string OkMessage
{
get { return okMessage; }
NotifyValueChanged ("OkMessage", okMessage);
}
}
- [XmlAttributeAttribute][DefaultValue("Cancel")]
+ [DefaultValue("Cancel")]
public virtual string CancelMessage
{
get { return cancelMessage; }
NotifyValueChanged ("CancelMessage", cancelMessage);
}
}
- [XmlAttributeAttribute][DefaultValue("Information")]
+ [DefaultValue("No")]
+ public virtual string NoMessage
+ {
+ get { return cancelMessage; }
+ set {
+ if (cancelMessage == value)
+ return;
+ cancelMessage = value;
+ NotifyValueChanged ("NoMessage", cancelMessage);
+ }
+ }
+ [DefaultValue("Information")]
public virtual Type MsgType
{
get { return msgType; }
NotifyValueChanged ("MsgType", msgType);
switch (msgType) {
case Type.Information:
- NotifyValueChanged ("MsgIcon", "#Crow.Images.Icons.Informations.svg");
+ MsgIcon = "#Crow.Images.Icons.Informations.svg";
Caption = "Informations";
OkMessage = "Ok";
- CancelMessage = "Cancel";
+ NotifyValueChanged ("CancelButIsVisible", false);
+ NotifyValueChanged ("NoButIsVisible", false);
break;
case Type.YesNo:
- NotifyValueChanged ("MsgIcon", "#Crow.Icons.question.svg");
+ case Type.YesNoCancel:
+ MsgIcon = "#Crow.Icons.question.svg";
Caption = "Choice";
OkMessage = "Yes";
- CancelMessage = "No";
+ NoMessage = "No";
+ NotifyValueChanged ("CancelButIsVisible", msgType == Type.YesNoCancel);
+ NotifyValueChanged ("NoButIsVisible", true);
break;
case Type.Alert:
- NotifyValueChanged ("MsgIcon", "#Crow.Images.Icons.IconAlerte.svg");
+ MsgIcon = "#Crow.Images.Icons.IconAlerte.svg";
Caption = "Alert";
OkMessage = "Ok";
CancelMessage = "Cancel";
+ NotifyValueChanged ("CancelButIsVisible", true);
+ NotifyValueChanged ("NoButIsVisible", false);
break;
case Type.Error:
- NotifyValueChanged ("MsgIcon", "#Crow.Images.Icons.exit.svg");
+ MsgIcon = "#Crow.Images.Icons.exit.svg";
Caption = "Error";
OkMessage = "Ok";
+ NotifyValueChanged ("CancelButIsVisible", false);
+ NotifyValueChanged ("NoButIsVisible", false);
break;
}
}
}
+
+ string msgIcon = null;
+ public string MsgIcon {
+ get { return msgIcon; }
+ set {
+ if (value == MsgIcon)
+ return;
+ msgIcon = value;
+ NotifyValueChanged ("MsgIcon", MsgIcon);
+ }
+ }
void onOkButtonClick (object sender, EventArgs e)
{
- Ok.Raise (this, null);
+ Yes.Raise (this, null);
+ close ();
+ }
+ void onNoButtonClick (object sender, EventArgs e)
+ {
+ No.Raise (this, null);
close ();
}
void onCancelButtonClick (object sender, EventArgs e)
return mb;
}
}
+ public static MessageBox ShowModal (Interface iface, Type msgBoxType, string message){
+ lock (iface.UpdateMutex) {
+ MessageBox mb = new MessageBox (iface) {
+ Modal = true,
+ MsgType = msgBoxType,
+ Message = message
+ };
+
+ iface.AddWidget (mb);
+ return mb;
+ }
+ }
}
}
}
string _icon;
- bool _resizable;
- bool _movable;
+ bool resizable;
+ bool movable;
+ bool modal;
protected bool hoverBorder = false;
bool alwaysOnTop = false;
Fill titleBarBackground = Color.UnitedNationsBlue;
[XmlAttributeAttribute][DefaultValue(true)]
public bool Resizable {
get {
- return _resizable;
+ return resizable;
}
set {
- if (_resizable == value)
+ if (resizable == value)
return;
- _resizable = value;
- NotifyValueChanged ("Resizable", _resizable);
+ resizable = value;
+ NotifyValueChanged ("Resizable", resizable);
}
}
[XmlAttributeAttribute][DefaultValue(true)]
public bool Movable {
get {
- return _movable;
+ return movable;
}
set {
- if (_movable == value)
+ if (movable == value)
return;
- _movable = value;
- NotifyValueChanged ("Movable", _movable);
+ movable = value;
+ NotifyValueChanged ("Movable", movable);
+ }
+ }
+ [XmlAttributeAttribute][DefaultValue(false)]
+ public bool Modal {
+ get {
+ return modal;
+ }
+ set {
+ if (modal == value)
+ return;
+ modal = value;
+ NotifyValueChanged ("Modal", modal);
}
}
[XmlAttributeAttribute][DefaultValue(false)]
[XmlAttributeAttribute][DefaultValue(false)]
public bool AlwaysOnTop {
get {
- return alwaysOnTop;
+ return modal ? true : alwaysOnTop;
}
set {
if (alwaysOnTop == value)
return;
+
alwaysOnTop = value;
- if (alwaysOnTop && Parent != null)
+ if (AlwaysOnTop && Parent != null)
IFace.PutOnTop (this);
- NotifyValueChanged ("AlwaysOnTop", alwaysOnTop);
+ NotifyValueChanged ("AlwaysOnTop", AlwaysOnTop);
}
}
// [XmlAttributeAttribute()][DefaultValue(WindowState.Normal)]
return;
}
- if (this.HasFocus && _movable) {
+ if (this.HasFocus && movable) {
if (e.Mouse.IsButtonDown (MouseButton.Left)) {
MoveAndResize (e.XDelta, e.YDelta, currentDirection);
return;
{
base.onMouseDown (sender, e);
}
+ public override bool MouseIsIn (Point m)
+ {
+ return modal ? true : base.MouseIsIn (m);
+ }
#endregion
protected void onMaximized (object sender, EventArgs e){