From e6541b353e7a0ecfd2e514e5c9c6f6c9c1ba96b1 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bruyère Date: Tue, 13 Nov 2018 14:48:41 +0100 Subject: first try with xlib --- src/Interface.cs | 318 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 231 insertions(+), 87 deletions(-) (limited to 'src/Interface.cs') diff --git a/src/Interface.cs b/src/Interface.cs index cc62a1aa..69fa36f8 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -36,6 +36,9 @@ using System.Xml.Serialization; using Cairo; using System.Globalization; using Crow.IML; +using System.Runtime.InteropServices; + + namespace Crow { @@ -63,8 +66,22 @@ namespace Crow /// The resulting surface (a byte array in the OpenTK renderer) is made available and protected with the /// RenderMutex of the interface. /// - public class Interface : ILayoutable + public class Interface : ILayoutable, IDisposable ,IValueChange { + #region IValueChange implementation + public event EventHandler ValueChanged; + public virtual void NotifyValueChanged(string MemberName, object _value) + { + //Debug.WriteLine ("Value changed: {0}->{1} = {2}", this, MemberName, _value); + ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value)); + } + #endregion + + internal IntPtr xHandle, xwinHnd, xDefaultRootWin, xDefaultVisual; + internal UInt32 xDefaultDepth; + internal Int32 xScreen; + XLib.XErrorHandler errorHnd; + #region CTOR static Interface(){ if (Type.GetType ("Mono.Runtime") == null) { @@ -94,18 +111,159 @@ namespace Crow FontRenderingOptions.HintStyle = HintStyle.Full; FontRenderingOptions.SubpixelOrder = SubpixelOrder.Rgb; } - public Interface(){ - CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; + + public Interface(int width=800, int height=600){ + + clientRectangle = new Rectangle (0, 0, width, height); + + Init (); + + initX (); + } + private int HandleError (IntPtr display, ref XLib.XErrorEvent error_event) + { + /*if (ErrorExceptions) + throw new X11Exception (error_event.display, error_event.resourceid, + error_event.serial, error_event.error_code, + error_event.request_code, error_event.minor_code); + else + Console.WriteLine ("X11 Error encountered: {0}{1}\n", + X11Exception.GetMessage(error_event.display, error_event.resourceid, + error_event.serial, error_event.error_code, + error_event.request_code, error_event.minor_code), + WhereString());*/ + Debug.WriteLine ("XERROR {0}", error_event.error_code); + return 0; + } + #endregion + + void interfaceThread() + { + while (true) { + Update (); + + if (XLib.NativeMethods.XPending (xHandle) > 0) { + XLib.XEvent xevent = new XLib.XEvent (); + XLib.NativeMethods.XNextEvent (xHandle, ref xevent); + + switch (xevent.type) { + case XLib.XEventName.Expose: + ProcessResize (new Rectangle (0, 0, xevent.ExposeEvent.width, xevent.ExposeEvent.height)); + break; + case XLib.XEventName.KeyPress: + ProcessKeyDown (xevent.KeyEvent.keycode); + //Debug.WriteLine ("keypress: {0}", xevent.KeyEvent.keycode); + break; + case XLib.XEventName.KeyRelease: + ProcessKeyUp (xevent.KeyEvent.keycode); + //Debug.WriteLine ("keypress: {0}", xevent.KeyEvent.keycode); + break; + case XLib.XEventName.MotionNotify: + //Debug.WriteLine ("motion: ({0},{1})", xevent.MotionEvent.x, xevent.MotionEvent.y); + ProcessMouseMove (xevent.MotionEvent.x, xevent.MotionEvent.y); + break; + case XLib.XEventName.ButtonPress: + //Debug.WriteLine ("button press: {0}", xevent.ButtonEvent.button); + if (xevent.ButtonEvent.button == 4) + ProcessMouseWheelChanged (WheelIncrement); + else if(xevent.ButtonEvent.button == 5) + ProcessMouseWheelChanged (-WheelIncrement); + else + ProcessMouseButtonDown (xevent.ButtonEvent.button - 1); + break; + case XLib.XEventName.ButtonRelease: + //Debug.WriteLine ("button release: {0}", xevent.ButtonEvent.button); + ProcessMouseButtonUp (xevent.ButtonEvent.button - 1); + break; + + } + } + } + } + + #region IDisposable Support + private bool disposedValue = false; // To detect redundant calls + + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + // TODO: dispose managed state (managed objects). + } + + //Marshal.FreeHGlobal (lastEvent); + XLib.NativeMethods.XCloseDisplay (xHandle); + + disposedValue = true; + } + } + + // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources. + ~Interface() { + // Do not change this code. Put cleanup code in Dispose(bool disposing) above. + Dispose(false); + } + + // This code added to correctly implement the disposable pattern. + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); } #endregion public void Init () { + CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; + CurrentInterface = this; - loadCursors (); + //loadCursors (); loadStyling (); findAvailableTemplates (); - initTooltip (); - initContextMenus (); + //initTooltip (); + //initContextMenus (); + + #if MEASURE_TIME + PerfMeasures.Add (updateMeasure); + PerfMeasures.Add (drawingMeasure); + PerfMeasures.Add (layoutingMeasure); + PerfMeasures.Add (clippingMeasure); + #endif + } + + protected virtual void initX() { + XLib.NativeMethods.XInitThreads (); + xHandle = XLib.NativeMethods.XOpenDisplay(IntPtr.Zero); + if (xHandle == IntPtr.Zero) + throw new NotSupportedException("[XLib] Failed to open display."); + + xScreen = XLib.NativeMethods.XDefaultScreen(xHandle); + + xDefaultRootWin = XLib.NativeMethods.XDefaultRootWindow (xHandle); + xDefaultVisual = XLib.NativeMethods.XDefaultVisual (xHandle, xScreen); + xDefaultDepth = XLib.NativeMethods.XDefaultDepth (xHandle, xScreen); + + xwinHnd = XLib.NativeMethods.XCreateSimpleWindow (xHandle, xDefaultRootWin, + 0, 0, (uint)clientRectangle.Width, (uint)clientRectangle.Height, 0, IntPtr.Zero, IntPtr.Zero); + if (xwinHnd == IntPtr.Zero) + throw new NotSupportedException("[XLib] Failed to create window."); + + XLib.NativeMethods.XSelectInput (xHandle, xwinHnd, XLib.EventMask.ExposureMask | + XLib.EventMask.KeyPressMask | XLib.EventMask.KeyReleaseMask | + XLib.EventMask.PointerMotionMask | XLib.EventMask.ButtonPressMask | XLib.EventMask.ButtonReleaseMask); + + XLib.NativeMethods.XMapWindow (xHandle, xwinHnd); + + surf = new Cairo.XlibSurface (xHandle, xwinHnd, xDefaultVisual, clientRectangle.Width, clientRectangle.Height); + + errorHnd = new XLib.XErrorHandler (HandleError); + XLib.NativeMethods.XSetErrorHandler (errorHnd); + + Thread t = new Thread (interfaceThread); + t.IsBackground = true; + t.Start (); + } #region Static and constants @@ -125,6 +283,7 @@ namespace Crow public static int DeviceRepeatDelay = 700; /// Time interval in millisecond between device event repeat public static int DeviceRepeatInterval = 40; + public static float WheelIncrement = 1; /// Tabulation size in Text controls public static int TabSize = 4; public static string LineBreak = "\n"; @@ -178,6 +337,9 @@ namespace Crow public event EventHandler KeyboardKeyUp; #endregion + /// Main Cairo surface + public Surface surf; + #region Public Fields /// Graphic Tree of this interface public List GraphicTree = new List(); @@ -229,13 +391,11 @@ namespace Crow #region Private Fields /// Client rectangle in the host context - Rectangle clientRectangle; + protected Rectangle clientRectangle; /// Clipping rectangles on the root context Region clipping = new Region(); /// Main Cairo context Context ctx; - /// Main Cairo surface - Surface surf; #endregion #region Default values and Style loading @@ -335,7 +495,7 @@ namespace Crow if (path.StartsWith ("#")) { string resId = path.Substring (1); //try/catch added to prevent nunit error - try { + try { stream = System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceStream (resId); } catch{} if (stream == null)//try to find ressource in Crow assembly @@ -644,80 +804,57 @@ namespace Crow #endif if (DragImage != null) clipping.UnionRectangle(new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight)); - using (surf = new ImageSurface (bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height, ClientRectangle.Width * 4)) { - using (ctx = new Context (surf)){ - if (!clipping.IsEmpty) { - - for (int i = 0; i < clipping.NumRectangles; i++) - ctx.Rectangle(clipping.GetRectangle(i)); - - ctx.ClipPreserve(); - ctx.Operator = Operator.Clear; - ctx.Fill(); - ctx.Operator = Operator.Over; - - for (int i = GraphicTree.Count -1; i >= 0 ; i--){ - GraphicObject p = GraphicTree[i]; - if (!p.Visible) - continue; - if (clipping.Contains (p.Slot) == RegionOverlap.Out) - continue; + //using (surf = new ImageSurface (bmp, Format.Argb32, ClientRectangle.Width, ClientRectangle.Height, ClientRectangle.Width * 4)) { + using (ctx = new Context (surf)){ + if (!clipping.IsEmpty) { + IsDirty = true; + for (int i = 0; i < clipping.NumRectangles; i++) + ctx.Rectangle(clipping.GetRectangle(i)); + + ctx.ClipPreserve(); + ctx.Operator = Operator.Clear; + ctx.Fill(); + ctx.Operator = Operator.Over; + + for (int i = GraphicTree.Count -1; i >= 0 ; i--){ + GraphicObject p = GraphicTree[i]; + if (!p.Visible) + continue; + if (clipping.Contains (p.Slot) == RegionOverlap.Out) + continue; + + ctx.Save (); + p.Paint (ref ctx); + ctx.Restore (); + } + + if (DragAndDropOperation != null) { + if (DragImage != null) { + DirtyRect += new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight); + DragImageX = Mouse.X - DragImageWidth / 2; + DragImageY = Mouse.Y - DragImageHeight / 2; ctx.Save (); - p.Paint (ref ctx); + ctx.ResetClip (); + ctx.SetSourceSurface (DragImage, DragImageX, DragImageY); + ctx.PaintWithAlpha (0.8); ctx.Restore (); - } - - if (DragAndDropOperation != null) { - if (DragImage != null) { - DirtyRect += new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight); - DragImageX = Mouse.X - DragImageWidth / 2; - DragImageY = Mouse.Y - DragImageHeight / 2; - ctx.Save (); - ctx.ResetClip (); - ctx.SetSourceSurface (DragImage, DragImageX, DragImageY); - ctx.PaintWithAlpha (0.8); - ctx.Restore (); - DirtyRect += new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight); - IsDirty = true; - //Console.WriteLine ("dragimage drawn: {0},{1}", DragImageX, DragImageY); - } - } - - #if DEBUG_CLIP_RECTANGLE - clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5)); - #endif - lock (RenderMutex) { -// Array.Copy (bmp, dirtyBmp, bmp.Length); - - if (IsDirty) - DirtyRect += clipping.Extents; - else - DirtyRect = clipping.Extents; + DirtyRect += new Rectangle (DragImageX, DragImageY, DragImageWidth, DragImageHeight); IsDirty = true; - - DirtyRect.Left = Math.Max (0, DirtyRect.Left); - DirtyRect.Top = Math.Max (0, DirtyRect.Top); - DirtyRect.Width = Math.Min (ClientRectangle.Width - DirtyRect.Left, DirtyRect.Width); - DirtyRect.Height = Math.Min (ClientRectangle.Height - DirtyRect.Top, DirtyRect.Height); - DirtyRect.Width = Math.Max (0, DirtyRect.Width); - DirtyRect.Height = Math.Max (0, DirtyRect.Height); - - if (DirtyRect.Width > 0 && DirtyRect.Height >0) { - dirtyBmp = new byte[4 * DirtyRect.Width * DirtyRect.Height]; - for (int y = 0; y < DirtyRect.Height; y++) { - Array.Copy (bmp, - ((DirtyRect.Top + y) * ClientRectangle.Width * 4) + DirtyRect.Left * 4, - dirtyBmp, y * DirtyRect.Width * 4, DirtyRect.Width * 4); - } - - } else - IsDirty = false; + //Console.WriteLine ("dragimage drawn: {0},{1}", DragImageX, DragImageY); } - clipping.Dispose (); - clipping = new Region (); } + + #if DEBUG_CLIP_RECTANGLE + clipping.stroke (ctx, Color.Red.AdjustAlpha(0.5)); + #endif + + clipping.Dispose (); + clipping = new Region (); + //} //surf.WriteToPng (@"/mnt/data/test.png"); + + //XLib.NativeMethods.XSync (xHandle, 0); } } #if MEASURE_TIME @@ -728,7 +865,7 @@ namespace Crow #region GraphicTree handling /// Add widget to the Graphic tree of this interface and register it for layouting - public void AddWidget(GraphicObject g) + public GraphicObject AddWidget(GraphicObject g) { g.Parent = this; int ptr = 0; @@ -749,6 +886,8 @@ namespace Crow g.RegisteredLayoutings = LayoutingType.None; g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren); + + return g; } /// Set visible state of widget to false and delete if from the graphic tree public void DeleteWidget(GraphicObject g) @@ -837,13 +976,14 @@ namespace Crow /// when window resize event occurs. /// /// bounding box of the interface - public void ProcessResize(Rectangle bounds){ + public virtual void ProcessResize(Rectangle bounds){ lock (UpdateMutex) { clientRectangle = bounds; - int stride = 4 * ClientRectangle.Width; - int bmpSize = Math.Abs (stride) * ClientRectangle.Height; - bmp = new byte[bmpSize]; - dirtyBmp = new byte[bmpSize]; + + /*surf.Dispose (); + surf = new Cairo.XlibSurface (xHandle, xwinHnd, xDefaultVisual, clientRectangle.Width, clientRectangle.Height);*/ + (surf as XlibSurface).SetSize (clientRectangle.Width, clientRectangle.Height); + foreach (GraphicObject g in GraphicTree) g.RegisterForLayouting (LayoutingType.All); @@ -1051,6 +1191,7 @@ namespace Crow lastKeyDownEvt.IsRepeat = true; _focusedWidget.onKeyDown (this, e); + KeyboardKeyDown.Raise (this, e); // keyboardRepeatThread = new Thread (keyboardRepeatThreadFunc); // keyboardRepeatThread.IsBackground = true; // keyboardRepeatThread.Start (); @@ -1070,6 +1211,8 @@ namespace Crow _focusedWidget.onKeyUp (this, e); + KeyboardKeyUp.Raise (this, e); + // if (keyboardRepeatThread != null) { // keyboardRepeatOn = false; // keyboardRepeatThread.Abort(); @@ -1246,10 +1389,11 @@ namespace Crow #endregion #if MEASURE_TIME - public PerformanceMeasure clippingMeasure = new PerformanceMeasure("Clipping", 100); - public PerformanceMeasure layoutingMeasure = new PerformanceMeasure("Layouting", 100); - public PerformanceMeasure updateMeasure = new PerformanceMeasure("Update", 100); - public PerformanceMeasure drawingMeasure = new PerformanceMeasure("Drawing", 100); + public PerformanceMeasure clippingMeasure = new PerformanceMeasure("Clipping", 1); + public PerformanceMeasure layoutingMeasure = new PerformanceMeasure("Layouting", 1); + public PerformanceMeasure updateMeasure = new PerformanceMeasure("Update", 1); + public PerformanceMeasure drawingMeasure = new PerformanceMeasure("Drawing", 1); + public List PerfMeasures = new List(); #endif #if DEBUG_LAYOUTING public List LQIsTries = new List(); -- cgit v1.3.1-4-g156e From a1dca1431f685020df843162b805edee11e1929c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bruyère Date: Tue, 20 Nov 2018 17:22:12 +0100 Subject: DebugLog --- Crow.csproj | 5 +- Tests/BasicTests.cs | 14 +- Tests/CrowDebugger.cs | 37 - Tests/Showcase.cs | 6 +- Tests/Tests.csproj | 4 +- Tests/keysyms.cs | 79 ++ src/GraphicObjects/GraphicObject.cs | 67 +- src/GraphicObjects/PrivateContainer.cs | 5 + src/Interface.cs | 78 +- src/LayoutingQueueItem.cs | 56 +- src/XLib/NativeMethods.cs | 12 + src/XLib/XKeySym.cs | 2109 ++++++++++++++++++++++++++++++++ src/debug/DebugLogger.cs | 241 ++++ 13 files changed, 2587 insertions(+), 126 deletions(-) delete mode 100644 Tests/CrowDebugger.cs create mode 100644 Tests/keysyms.cs create mode 100644 src/XLib/XKeySym.cs create mode 100644 src/debug/DebugLogger.cs (limited to 'src/Interface.cs') diff --git a/Crow.csproj b/Crow.csproj index 558511b3..76650bd1 100644 --- a/Crow.csproj +++ b/Crow.csproj @@ -32,7 +32,7 @@ true false $(SolutionDir)build\Debug - XLIB_BACKEND0;DESIGN_MODE;DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_DISPOSE0;DEBUG_LAYOUTING0;TRACE0;DEBUG;MEASURE_TIME;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0 + DEBUG_LOG;XLIB_BACKEND0;DESIGN_MODE;DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_DISPOSE0;TRACE0;DEBUG;MEASURE_TIME;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0 @@ -231,6 +231,8 @@ + + @@ -261,6 +263,7 @@ + diff --git a/Tests/BasicTests.cs b/Tests/BasicTests.cs index be2b1636..c13dd53d 100644 --- a/Tests/BasicTests.cs +++ b/Tests/BasicTests.cs @@ -23,11 +23,11 @@ namespace tests //app.AddWidget ("Interfaces/Divers/perfMeasures.crow").DataSource = app; while (true) { - #if MEASURE_TIME + /*#if MEASURE_TIME foreach (PerformanceMeasure m in app.PerfMeasures) m.NotifyChanges (); - #endif - Thread.Sleep(10); + #endif*/ + //Thread.Sleep(10); } } /*using (Display disp = new Display()) @@ -50,8 +50,12 @@ namespace tests static void App_KeyboardKeyDown (object sender, KeyboardKeyEventArgs e) { - GraphicObject obj = sender as GraphicObject; - obj.IFace.AddWidget(@"Interfaces/Divers/0.crow"); + Console.WriteLine((byte)e.Key); + switch (e.Key) { + case Key.Keypad1: + DebugLog.save (sender as Interface); + break; + } } } } diff --git a/Tests/CrowDebugger.cs b/Tests/CrowDebugger.cs deleted file mode 100644 index 7d85ff50..00000000 --- a/Tests/CrowDebugger.cs +++ /dev/null @@ -1,37 +0,0 @@ -// -// CrowDebugger.cs -// -// Author: -// Jean-Philippe Bruyère -// -// Copyright (c) 2013-2017 Jean-Philippe Bruyère -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -using System; - -namespace Tests -{ - public class CrowDebugger - { - public CrowDebugger () - { - } - } -} - diff --git a/Tests/Showcase.cs b/Tests/Showcase.cs index e5a9316e..38bc175c 100644 --- a/Tests/Showcase.cs +++ b/Tests/Showcase.cs @@ -61,7 +61,11 @@ namespace Tests static void App_KeyboardKeyDown (object sender, KeyboardKeyEventArgs e) { - + switch (e.Key) { + case Key.Keypad1: + DebugLog.save (sender as Interface); + break; + } } public Showcase () diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 7bae42b0..7366607f 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -8,7 +8,7 @@ Exe Tests Tests - Tests.Showcase + tests.MainClass v4.5 AnyCPU 0.5 @@ -102,7 +102,7 @@ - + diff --git a/Tests/keysyms.cs b/Tests/keysyms.cs new file mode 100644 index 00000000..430954fe --- /dev/null +++ b/Tests/keysyms.cs @@ -0,0 +1,79 @@ +// +// keysyms.cs +// +// Author: +// Jean-Philippe Bruyère +// +// Copyright (c) 2013-2017 Jean-Philippe Bruyère +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.IO; + +namespace Tests +{ + static class keysyms + { + public static void Main(string[] args) + { + using (StreamWriter sw = new StreamWriter ("test.cs")) { + using (StreamReader r = new StreamReader ("/usr/include/X11/keysymdef.h")) { + bool skip = false; + int maxChar = 0; + sw.WriteLine ("/* autogenerated */"); + sw.WriteLine ("using System;\n"); + sw.WriteLine ("namespace XLib"); + sw.WriteLine ("{"); + sw.WriteLine ("\t[Flags]"); + sw.WriteLine ("\tpublic enum KeySym"); + sw.WriteLine ("\t{"); + while (!r.EndOfStream) { + string s = r.ReadLine ().Trim(); + if (skip) { + if (s.EndsWith ("*/")) + skip = false; + continue; + } + if (s.StartsWith ("/*")) { + if (!s.EndsWith ("*/")) + skip = true; + continue; + } + if (!s.StartsWith ("#define")) + continue; + string[] tmp = s.Split (new char[] {' ', '\t'}, StringSplitOptions.RemoveEmptyEntries); + + if (tmp [1].Length > maxChar) + maxChar = tmp [1].Length; + + int nbTab = tmp [1].Length / 4; + nbTab = 8 - nbTab; + + sw.WriteLine ("\t\t{0}{1}= {2},", tmp[1],new String('\t',nbTab), tmp[2]); + } + sw.WriteLine ("\t}"); + sw.WriteLine ("}"); + Console.WriteLine ("max char: " + maxChar.ToString ()); + } + + } + } + } +} + diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 49decd8d..c7fbcb18 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -50,7 +50,10 @@ namespace Crow public class GraphicObject : ILayoutable, IValueChange, IDisposable { internal ReaderWriterLockSlim parentRWLock = new ReaderWriterLockSlim(); - + #if DEBUG_LOG + public int yIndex;//absolute index in the graphic tree for debug draw + public int xLevel;//x increment for debug draw + #endif #if DESIGN_MODE static MethodInfo miDesignAddDefLoc = typeof(GraphicObject).GetMethod("design_add_style_location", BindingFlags.Instance | BindingFlags.NonPublic); @@ -188,8 +191,9 @@ namespace Crow } #endregion - internal static ulong currentUid = 0; - internal ulong uid = 0; + #if DEBUG_LOG + internal static List GraphicObjects = new List(); + #endif internal bool isPopup = false; public GraphicObject focusParent { @@ -234,9 +238,9 @@ namespace Crow /// protected GraphicObject () { Clipping = new Region (); - #if DEBUG - uid = currentUid; - currentUid++; + #if DEBUG_LOG + GraphicObjects.Add (this); + DebugLog.AddEvent(DbgEvtType.GOClassCreation, this); #endif } /// @@ -261,7 +265,6 @@ namespace Crow /// public virtual void Initialize(){ loadDefaultValues (); - //initialized = true; } #region private fields LayoutingType registeredLayoutings = LayoutingType.All; @@ -504,7 +507,7 @@ namespace Crow } #if DEBUG [XmlIgnore]public string TreePath { - get { return this.GetType().Name + uid.ToString (); } + get { return this.GetType().Name + GraphicObjects.IndexOf(this).ToString (); } } #endif /// @@ -516,7 +519,7 @@ namespace Crow public virtual string Name { get { #if DEBUG - return string.IsNullOrEmpty(name) ? this.GetType().Name + uid.ToString () : name; + return string.IsNullOrEmpty(name) ? this.GetType().Name + GraphicObjects.IndexOf(this).ToString () : name; #else return name; #endif @@ -975,6 +978,10 @@ namespace Crow public virtual void OnDataSourceChanged(object sender, DataSourceChangeEventArgs e){ DataSourceChanged.Raise (this, e); + #if DEBUG_LOG + DebugLog.AddEvent(DbgEvtType.GONewDataSource, this); + #endif + #if DEBUG_BINDING Debug.WriteLine("New DataSource for => {0} \n\t{1}=>{2}", this.ToString(),e.OldDataSource,e.NewDataSource); #endif @@ -1189,6 +1196,9 @@ namespace Crow onInitialized (this, null); } protected virtual void onInitialized (object sender, EventArgs e){ + #if DEBUG_LOG + DebugLog.AddEvent(DbgEvtType.GOInitialized, this); + #endif Initialized.Raise(sender, e); } bool getDefaultEvent(EventInfo ei, List