Ejemplo n.º 1
0
        /* ~Ihandle()
         * {
         *   Dispose(false);
         * }*/

        public static IntPtr GetCHandle(IupHandle from)
        {
            if (from == null)
            {
                return(IntPtr.Zero);
            }
            return(from.Handle);
        }
Ejemplo n.º 2
0
        public static IupHandle Canvas(string action = null)
        {
            IupHandle res = IupHandle.Create(NativeIUPGL.IupGLCanvas(action));

            if (res == null)
            {
                throw new Exception("Failed to create OpenGL canvas, was IupGL Open():ed correctly?");
            }
            return(res);
        }
Ejemplo n.º 3
0
        public override bool Equals(object obj)
        {
            IupHandle h = obj as IupHandle;

            if (h != null)
            {
                return(Handle.Equals(h.Handle));
            }
            else
            {
                return(base.Equals(obj));
            }
        }
Ejemplo n.º 4
0
        public IntPtr MarshalManagedToNative(object managedObj)
        {
            if (managedObj == null)
            {
                return(IntPtr.Zero);
            }

            IupHandle ih = managedObj as IupHandle;

            if (ih == null)
            {
                throw new ArgumentException("managedObj", "Can only marshal type of Tecgraf.IupHandle");
            }

            return(IupHandle.GetCHandle(ih));
        }
Ejemplo n.º 5
0
        public string[] GetAllAttributes(IupHandle ih)
        {
            IntPtr zero      = IntPtr.Zero;
            int    numattrib = NativeIUP.IupGetAllAttributes(Handle, ref zero, 0);

            IntPtr[] atts = new IntPtr[numattrib];

            if (numattrib == 0)
            {
                return(new string[0]);
            }
            numattrib = NativeIUP.IupGetAllAttributes(Handle, ref atts[0], numattrib);
            string[] res = new string[numattrib];

            for (int l = 0; l < atts.Length; l++)
            {
                res[l] = UTF8ToStr(atts[l]);
            }

            return(res);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Shows a text input dialog to the user. Maximum length of entered text is 10000 characters.
        /// </summary>
        /// <param name="title">Text in the dialogs title bar.</param>
        /// <param name="text">The initial text of dialog. Can be null for empty string.</param>
        /// <returns>True if successful or false on cancel.</returns>
        public static bool GetText(string title, ref string text)
        {
            IntPtr cstring = IntPtr.Zero;

            try
            {
                // According to manual 10240 characters maximum+2 extra for zero term safety etc.
                cstring = Marshal.AllocHGlobal(10242);

                int cnt = 0;
                if (text != null)
                {
                    byte[] utfcode = Encoding.UTF8.GetBytes(text);

                    if (utfcode.Length > 10240)
                    {
                        Array.Resize <byte>(ref utfcode, 10240);
                    }

                    cnt = utfcode.Length;
                    Marshal.Copy(utfcode, 0, cstring, cnt);
                }

                Marshal.WriteByte(cstring, cnt, 0);

                if (NativeIUP.IupGetText(title, cstring) != 0)
                {
                    text = IupHandle.UTF8ToStr(cstring);
                    return(true);
                }

                return(false);
            }
            finally {
                if (cstring != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(cstring);
                }
            }
        }
Ejemplo n.º 7
0
        private void RecursiveUnmapCallbacks(IupHandle Handle)
        {
            if (Handle == null)
            {
                return;
            }
            IupHandle ih = Handle;

            int ch = ih.GetChildCount();

            for (int ci = 0; ci < ch; ci++)
            {
                RecursiveUnmapCallbacks(ih.GetChild(ci));
            }



            if (CallbackMap.ContainsKey(Handle.Handle))
            {
                CallbackMap.Remove(Handle.Handle);
            }
        }
Ejemplo n.º 8
0
        public static IupHandle ImageFromResource(Assembly asm, string resname)
        {
            //try to get resource with the actual name
            Stream stream = asm.GetManifestResourceStream(resname);

            if (stream == null)
            {
                //get resource with some random namspace ending with the given name
                //this is good for Visual Studio express users, where resources are auto prefixed
                string upname = "." + resname.ToUpperInvariant();
                foreach (string s in asm.GetManifestResourceNames())
                {
                    if (s.ToUpper().EndsWith(upname))
                    {
                        stream = asm.GetManifestResourceStream(s);
                    }
                }
            }

            if (stream == null)
            {
                throw new Exception("Resource " + resname + " not found in assembly " + asm.ToString());
            }

            IupHandle res = null;

            try
            {
                res = ImageFromStream(stream);
            }
            finally
            {
                stream.Close();
            }

            return(res);
        }
Ejemplo n.º 9
0
        private static IntPtr[] PtrArrayOf(params IupHandle[] h)
        {
            if (h == null)
            {
                return(null);
            }

            IntPtr[] res = new IntPtr[h.Length + 1];  //one extra element for zero termination
            int      c   = 0;

            foreach (IupHandle ih in h)
            {
                if (ih != null)
                {
                    res[c++] = IupHandle.GetCHandle(ih);
                }
                else
                {
                    res[c++] = IntPtr.Zero;
                }
            }
            res[c] = IntPtr.Zero; //zero terminate array
            return(res);
        }
Ejemplo n.º 10
0
 public static IupHandle LayoutDialog(IupHandle dialog)
 {
     return(IupHandle.Create(NativeIUP.IupLayoutDialog(IupHandle.GetCHandle(dialog))));
 }
Ejemplo n.º 11
0
 public static IupHandle Val(bool horizontal)
 {
     return(IupHandle.Create(NativeIUP.IupVal(horizontal ? "HORIZONTAL" : "VERTICAL")));
 }
Ejemplo n.º 12
0
 public static IupHandle IupProgressDlg()
 {
     return(IupHandle.Create(NativeIUP.IupProgressDlg()));
 }
Ejemplo n.º 13
0
 public static IupHandle FontDlg()
 {
     return(IupHandle.Create(NativeIUP.IupFontDlg()));
 }
Ejemplo n.º 14
0
 public static IupHandle Link(string url, string title)
 {
     return(IupHandle.Create(NativeIUP.IupLink(url, title)));
 }
Ejemplo n.º 15
0
 public static IupHandle Toggle(string title, string action = null)
 {
     return(IupHandle.Create(NativeIUP.IupToggle(title, action)));
 }
Ejemplo n.º 16
0
 internal static string UTF8ToStr(IntPtr ptr)
 {
     //Just a shortcut!
     return(IupHandle.UTF8ToStr(ptr));
 }
Ejemplo n.º 17
0
 public static int TreeGetId(IupHandle ih_tree, IntPtr userid)
 {
     return(NativeIUP.IupTreeGetId(IupHandle.GetCHandle(ih_tree), userid));
 }
Ejemplo n.º 18
0
 public static IupHandle Tabs(params IupHandle[] children)
 {
     return(IupHandle.Create(NativeIUP.IupTabsv(PtrArrayOf(children))));
 }
Ejemplo n.º 19
0
 public static bool TreeSetUserId(IupHandle ih_tree, int id, IntPtr userid)
 {
     return(NativeIUP.IupTreeSetUserId(IupHandle.GetCHandle(ih_tree), id, userid) != 0);
 }
Ejemplo n.º 20
0
 public static int ConvertXYToPos(IupHandle ih, int x, int y)
 {
     return(NativeIUP.IupConvertXYToPos(IupHandle.GetCHandle(ih), x, y));
 }
Ejemplo n.º 21
0
 public static void TextConvertPosToLinCol(IupHandle ih, int pos, out int lin, out int col)
 {
     NativeIUP.IupTextConvertPosToLinCol(IupHandle.GetCHandle(ih), pos, out lin, out col);
 }
Ejemplo n.º 22
0
 public static void TextConvertLinColToPos(IupHandle ih, int lin, int col, out int pos)
 {
     NativeIUP.IupTextConvertLinColToPos(IupHandle.GetCHandle(ih), lin, col, out pos);
 }
Ejemplo n.º 23
0
 public static bool SaveImageAsText(IupHandle ih, string filename, SaveImageFormat format, string name)
 {
     return(NativeIUP.IupSaveImageAsText(IupHandle.GetCHandle(ih), filename, format.ToString().ToUpper(), name) != 0);
 }
Ejemplo n.º 24
0
 public static IupHandle ElementPropertiesDialog(IupHandle element)
 {
     return(IupHandle.Create(NativeIUP.IupElementPropertiesDialog(IupHandle.GetCHandle(element))));
 }
Ejemplo n.º 25
0
 public static void TreeSetAttributeHandle(IupHandle ih, string name, int id, IupHandle ih_named)
 {
     NativeIUP.IupTreeSetAttributeHandle(IupHandle.GetCHandle(ih), name, id, IupHandle.GetCHandle(ih_named));
 }
Ejemplo n.º 26
0
 public static IupHandle MessageDlg()
 {
     return(IupHandle.Create(NativeIUP.IupMessageDlg()));
 }
Ejemplo n.º 27
0
 public static IupHandle Clipboard()
 {
     return(IupHandle.Create(NativeIUP.IupClipboard()));
 }
Ejemplo n.º 28
0
 public static IupHandle ColorDlg()
 {
     return(IupHandle.Create(NativeIUP.IupColorDlg()));
 }
Ejemplo n.º 29
0
 public static IntPtr TreeGetUserId(IupHandle ih_tree, int id)
 {
     return(NativeIUP.IupTreeGetUserId(IupHandle.GetCHandle(ih_tree), id));
 }
Ejemplo n.º 30
0
 public static IupHandle Tree()
 {
     return(IupHandle.Create(NativeIUP.IupTree()));
 }