-Background = vgradient|0:Black|0,1:Gray|0,9:Gray|1:LightGray;
+Background = vgradient|0:Black|0.1:Gray|0.9:Gray|1:LightGray;
Foreground = Gray;
Focusable = true;
Fit = true;
#region keyboard Handling
void Keyboard_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs otk_e)
{
- //if (!CrowInterface.ProcessKeyDown((int)otk_e.Key))
+ if (!CrowInterface.ProcessKeyDown((int)otk_e.Key))
KeyboardKeyDown.Raise (this, otk_e);
}
void Keyboard_KeyUp(object sender, OpenTK.Input.KeyboardKeyEventArgs otk_e)
{
- //if (!CrowInterface.ProcessKeyUp((int)otk_e.Key))
+ if (!CrowInterface.ProcessKeyUp((int)otk_e.Key))
KeyboardKeyUp.Raise (this, otk_e);
}
void OpenTKGameWindow_KeyPress (object sender, OpenTK.KeyPressEventArgs e)
string getDefaultStyleResId (Type t) {
string [] tmp = t.FullName.Split ('.');
string res = tmp [0] + ".Styles";
- for (int i = 1; i < tmp.Length; i++)
+ for (int i = 1; i < tmp.Length; i++)
res += "." + tmp [i];
return res;
}
return;
}
- Dictionary<string, string> styling = null;
+ List<Dictionary<string, string>> styling = new List<Dictionary<string, string>>();
//Search for a style mathing :
//1: Full class name, with full namespace
// those files being placed in a Styles folder
if (Interface.CurrentInterface.Styling.ContainsKey (thisType.FullName))
- styling = Interface.CurrentInterface.Styling [thisType.FullName];
- else if (Interface.CurrentInterface.Styling.ContainsKey (thisType.Name))
- styling = Interface.CurrentInterface.Styling [thisType.Name];
- else {
- string styleFullName = getDefaultStyleResId (thisType);
- if (Interface.CurrentInterface.Styling.ContainsKey (styleFullName))
- styling = Interface.CurrentInterface.Styling [styleFullName];
- }
-
+ styling.Add (Interface.CurrentInterface.Styling [thisType.FullName]);
+ if (Interface.CurrentInterface.Styling.ContainsKey (thisType.Name))
+ styling.Add (Interface.CurrentInterface.Styling [thisType.Name]);
+
+ string styleFullName = getDefaultStyleResId (thisType);
+ if (Interface.CurrentInterface.Styling.ContainsKey (styleFullName))
+ styling.Add (Interface.CurrentInterface.Styling [styleFullName]);
+
//Reflexion being very slow compared to dyn method or delegates,
//I compile the initial values coded in the CustomAttribs of the class,
//all other instance of this type would not longer use reflexion to init properly
name = xaa.AttributeName;
}
- bool memberHasStyle = false;
- if (styling != null){
- if (styling.ContainsKey (name))
- memberHasStyle = true;
- }
- if (memberHasStyle){
- defaultValue = styling [name];
+ int styleIndex = -1;
+ if (styling.Count > 0){
+ for (int i = 0; i < styling.Count; i++) {
+ if (styling[i].ContainsKey (name)){
+ styleIndex = i;
+ break;
+ }
+ }
+ }
+ if (styleIndex >= 0){
+ defaultValue = styling[styleIndex] [name];
}else {
if (name == "Style") {
//retrieve default value from class attribute
if (pi.PropertyType == typeof (string))
il.Emit (OpCodes.Ldstr, Convert.ToString (defaultValue));
else {
- MethodInfo miParse = pi.PropertyType.GetMethod
+ MethodInfo miParse = pi.PropertyType.GetMethod
("Parse", BindingFlags.Static | BindingFlags.Public,
Type.DefaultBinder, new Type [] {typeof (string)},null);
if (miParse == null)
protected Size contentSize;
/// <summary> return size of content + margins </summary>
protected virtual int measureRawSize (LayoutingType lt) {
- return lt == LayoutingType.Width ?
+ return lt == LayoutingType.Width ?
contentSize.Width + 2 * Margin: contentSize.Height + 2 * Margin;
}
/// <summary> By default in groups, LayoutingType.ArrangeChildren is reset </summary>
}
} else
Slot.Y = Top;
-
+
if (LastSlots.Y == Slot.Y)
break;
}
} else
Slot.Height = 0;
-
+
if (LastSlots.Height == Slot.Height)
break;
OnLayoutChanges (layoutType);
- LastSlots.Height = Slot.Height;
+ LastSlots.Height = Slot.Height;
break;
}
/// <summary>
/// The Interface Class is the top container of the application.
/// It provides the Dirty bitmap and zone of the interface to be drawn on screen
- ///
+ ///
/// The Interface contains :
/// - rendering and layouting queues and logic.
/// - helpers to load XML interfaces files
FontRenderingOptions.SubpixelOrder = SubpixelOrder.Rgb;
}
public Interface(){
- LayoutingQueue = new Queue<LayoutingQueueItem>();
Interface.CurrentInterface = this;
LoadStyling ();
}
public static FontOptions FontRenderingOptions;
#endregion
- /// <summary>
- /// The layouting queue contains layouting commands
- /// </summary>
- public Queue<LayoutingQueueItem> LayoutingQueue;
+ public Queue<LayoutingQueueItem> LayoutingQueue = new Queue<LayoutingQueueItem> ();
public Queue<GraphicObject> GraphicUpdateQueue = new Queue<GraphicObject>();
+ public Dictionary<string, Dictionary<string, string>> Styling;
public string Clipboard;
public static void RegisterForGraphicUpdate(GraphicObject g)
{
return tmp;
}
}
- public Dictionary<string, Dictionary<string, string>> Styling;
public void LoadStyling() {
System.Globalization.CultureInfo savedCulture = Thread.CurrentThread.CurrentCulture;
Styling = new Dictionary<string, Dictionary<string, string>> ();
//fetch styling info in this order, if member styling is alreadey referenced in previous
- //assembly, it's ignored
+ //assembly, it's ignored.
loadStylingFromAssembly (Assembly.GetEntryAssembly ());
loadStylingFromAssembly (Assembly.GetExecutingAssembly ());
Thread.CurrentThread.CurrentCulture = savedCulture;
}
- void loadStylingFromAssembly (Assembly assembly) {
+ void loadStylingFromAssembly (Assembly assembly) {
foreach (string s in assembly
.GetManifestResourceNames ()
.Where (r => r.EndsWith (".style", StringComparison.OrdinalIgnoreCase))) {
StyleReader sr = new StyleReader (assembly, s);
-
+ sr.Dispose ();
}
}
-
- //public static bool TryGetStyle (Type crowType, out Stream stream) {
- // string styleId = crowType.Name + ".style";
-
- // if (tryGetStyle (Assembly.GetEntryAssembly (), styleId, out stream))
- // return true;
- // if (tryGetStyle (Assembly.GetExecutingAssembly (), styleId, out stream))
- // return true;
- // return false;
- //}
-
- //static bool tryGetStyle (Assembly assembly, string styleId, out Stream stream) {
- // try {
- // stream = assembly.GetManifestResourceStream (
- // assembly.GetManifestResourceNames ().FirstOrDefault (r => r.EndsWith
- // (styleId, StringComparison.OrdinalIgnoreCase)));
- // } catch {
- // stream = null;
- // return false;
- // }
- // return true;
- //}
#endregion
#if MEASURE_TIME
#endregion
#region Keyboard
- public bool ProcessKeyDown(int Key){
+ public bool ProcessKeyDown(int Key){
if (_focusedWidget == null)
return false;
KeyboardKeyEventArgs e = new KeyboardKeyEventArgs((Crow.Key)Key, false, Keyboard);
List<string> targetsClasses = new List<string> ();
string currentProperty = "";
+ int curlyBracketCount = 0;
+
while (!EndOfStream) {
char c = (Char)Read ();
token += c;
break;
case readerState.expression:
- if (c == ';') {
- if (!string.IsNullOrEmpty (token)) {
- string expression = token.Trim ();
+ if (curlyBracketCount == 0) {
+ if (c == '{'){
+ if (string.IsNullOrEmpty(token))
+ throw new Exception ("Unexpected token '{'");
+ curlyBracketCount++;
+ token = "{";
+ }else if (c == '}')
+ throw new Exception ("Unexpected token '{'");
+ else if (c == ';') {
+ if (!string.IsNullOrEmpty (token)) {
+ string expression = token.Trim ();
- foreach (string tc in targetsClasses) {
- if (!iface.Styling.ContainsKey (tc))
- iface.Styling [tc] = new Dictionary<string, string> ();
- else if (iface.Styling [tc].ContainsKey (currentProperty))
- continue;
- iface.Styling [tc] [currentProperty] = expression;
+ foreach (string tc in targetsClasses) {
+ if (!iface.Styling.ContainsKey (tc))
+ iface.Styling [tc] = new Dictionary<string, string> ();
+ else if (iface.Styling [tc].ContainsKey (currentProperty))
+ continue;
+ iface.Styling [tc] [currentProperty] = expression;
+ }
+ token = "";
}
- token = "";
- }
- state = readerState.propertyName;
- } else
+ state = readerState.propertyName;
+ } else
+ token += c;
+ } else {
+ if (c == '{')
+ curlyBracketCount++;
+ else if (c == '}')
+ curlyBracketCount--;
token += c;
+ }
break;
}
- }
+ }
+
+ if (curlyBracketCount > 0)
+ throw new Exception ("Unexpected end of file");
}
}
}