X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=plugins%2Fdali-swig%2Fmanual%2Fcsharp%2FViewRegistry.cs;h=bd9fecbbae11ce299b12e7b69cd548c52d32cf11;hp=c2be6784e62f2b2344ce8dd7af8074a36aa65149;hb=a65bfc3f5f61060ce3b7e0104d4da5f8f9b9dc87;hpb=bc7cb028cf42ff75d7644c278201883ea3426199 diff --git a/plugins/dali-swig/manual/csharp/ViewRegistry.cs b/plugins/dali-swig/manual/csharp/ViewRegistry.cs index c2be678..bd9fecb 100644 --- a/plugins/dali-swig/manual/csharp/ViewRegistry.cs +++ b/plugins/dali-swig/manual/csharp/ViewRegistry.cs @@ -51,14 +51,14 @@ namespace Dali /// in MyControl.h /// class MyControl : public Control /// { - /// struct Property + /// struct Property + /// { + /// enum /// { - /// enum - /// { - /// HOURS = Control::CONTROL_PROPERTY_END_INDEX + 1 - /// } - /// } - /// + /// HOURS = Control::CONTROL_PROPERTY_END_INDEX + 1 + /// } + /// } + /// } /// /// in MyControl-impl.cpp /// @@ -139,9 +139,9 @@ namespace Dali private PropertyRangeManager _propertyRangeManager; /// - /// Given a C++ custom control the dictionary allows us to find what CustomView it belongs to + /// Given a C++ control the dictionary allows us to find which C# control (View) it belongs to /// - private Dictionary _controlMap; + private Dictionary _controlMap; /// // Maps the name of a custom view to a create instance function @@ -177,7 +177,7 @@ namespace Dali _getPropertyCallback = new GetPropertyDelegate (GetProperty); _setPropertyCallback = new SetPropertyDelegate (SetProperty); - _controlMap = new Dictionary(); + _controlMap = new Dictionary(); _constructorMap = new Dictionary>(); _propertyRangeManager = new PropertyRangeManager(); @@ -199,7 +199,7 @@ namespace Dali } /// - /// Called directly from DALi C++ type registry to create a control (View) uses no marshalling. + /// Called directly from DALi C++ type registry to create a control (View) using no marshalling. /// /// Pointer to the Control (Views) handle /// C pointer to the Control (View) name @@ -215,17 +215,7 @@ namespace Dali { // Create the control CustomView newControl = controlConstructor (); - - // Store the mapping between this instance of the custom control and native part - // We store a pointer to the RefObject for the control - IntPtr cPtr = newControl.GetPtrfromActor(); - RefObject refObj = newControl.GetObjectPtr (); - IntPtr refCptr = (IntPtr) RefObject.getCPtr(refObj); - - //Console.WriteLine ("________Storing ref object cptr in control map Hex: {0:X}", refCptr); - Instance._controlMap.Add (refCptr , newControl ); - - return cPtr; // return pointer to handle + return newControl.GetPtrfromActor(); // return pointer to handle } else { @@ -234,6 +224,25 @@ namespace Dali } } + /// + /// Store the mapping between this instance of control (View) and native part. + /// + /// The instance of control (View) + public static void RegisterView( View view ) + { + // We store a pointer to the RefObject for the control + RefObject refObj = view.GetObjectPtr(); + IntPtr refCptr = (IntPtr) RefObject.getCPtr(refObj); + + //Console.WriteLine ("________Storing ref object cptr in control map Hex: {0:X}", refCptr); + if ( !Instance._controlMap.ContainsKey(refCptr) ) + { + Instance._controlMap.Add(refCptr, view ); + } + + return; + } + private static IntPtr GetProperty( IntPtr controlPtr, IntPtr propertyName ) { string name = System.Runtime.InteropServices.Marshal.PtrToStringAnsi (propertyName); @@ -260,19 +269,16 @@ namespace Dali } } - public static CustomView GetCustomViewFromActor( Actor actor ) + public static View GetViewFromActor( Actor actor ) { // we store a dictionary of ref-obects (C++ land) to custom views (C# land) - Dali.CustomView view; + Dali.View view; RefObject refObj = actor.GetObjectPtr (); IntPtr refObjectPtr = (IntPtr) RefObject.getCPtr(refObj); if ( Instance._controlMap.TryGetValue ( refObjectPtr, out view) ) { - - // call the get property function - return view; } else @@ -346,7 +352,7 @@ namespace Dali private IntPtr GetPropertyValue ( IntPtr controlPtr, string propertyName) { // Get the C# control that maps to the C++ control - Dali.CustomView view; + Dali.View view; BaseHandle baseHandle = new BaseHandle (controlPtr, false); @@ -356,7 +362,6 @@ namespace Dali if ( _controlMap.TryGetValue ( refObjectPtr, out view) ) { - // call the get property function System.Object val = view.GetType ().GetProperty (propertyName).GetAccessors () [0].Invoke (view, null); @@ -377,7 +382,7 @@ namespace Dali private void SetPropertyValue ( IntPtr controlPtr, string propertyName, IntPtr propertyValuePtr) { // Get the C# control that maps to the C++ control - Dali.CustomView view; + Dali.View view; //Console.WriteLine ("SetPropertyValue refObjectPtr = {0:X}", controlPtr);