/* ~Ihandle() * { * Dispose(false); * }*/ public static IntPtr GetCHandle(IupHandle from) { if (from == null) { return(IntPtr.Zero); } return(from.Handle); }
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); }
public override bool Equals(object obj) { IupHandle h = obj as IupHandle; if (h != null) { return(Handle.Equals(h.Handle)); } else { return(base.Equals(obj)); } }
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)); }
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); }
/// <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); } } }
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); } }
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); }
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); }
public static IupHandle LayoutDialog(IupHandle dialog) { return(IupHandle.Create(NativeIUP.IupLayoutDialog(IupHandle.GetCHandle(dialog)))); }
public static IupHandle Val(bool horizontal) { return(IupHandle.Create(NativeIUP.IupVal(horizontal ? "HORIZONTAL" : "VERTICAL"))); }
public static IupHandle IupProgressDlg() { return(IupHandle.Create(NativeIUP.IupProgressDlg())); }
public static IupHandle FontDlg() { return(IupHandle.Create(NativeIUP.IupFontDlg())); }
public static IupHandle Link(string url, string title) { return(IupHandle.Create(NativeIUP.IupLink(url, title))); }
public static IupHandle Toggle(string title, string action = null) { return(IupHandle.Create(NativeIUP.IupToggle(title, action))); }
internal static string UTF8ToStr(IntPtr ptr) { //Just a shortcut! return(IupHandle.UTF8ToStr(ptr)); }
public static int TreeGetId(IupHandle ih_tree, IntPtr userid) { return(NativeIUP.IupTreeGetId(IupHandle.GetCHandle(ih_tree), userid)); }
public static IupHandle Tabs(params IupHandle[] children) { return(IupHandle.Create(NativeIUP.IupTabsv(PtrArrayOf(children)))); }
public static bool TreeSetUserId(IupHandle ih_tree, int id, IntPtr userid) { return(NativeIUP.IupTreeSetUserId(IupHandle.GetCHandle(ih_tree), id, userid) != 0); }
public static int ConvertXYToPos(IupHandle ih, int x, int y) { return(NativeIUP.IupConvertXYToPos(IupHandle.GetCHandle(ih), x, y)); }
public static void TextConvertPosToLinCol(IupHandle ih, int pos, out int lin, out int col) { NativeIUP.IupTextConvertPosToLinCol(IupHandle.GetCHandle(ih), pos, out lin, out col); }
public static void TextConvertLinColToPos(IupHandle ih, int lin, int col, out int pos) { NativeIUP.IupTextConvertLinColToPos(IupHandle.GetCHandle(ih), lin, col, out pos); }
public static bool SaveImageAsText(IupHandle ih, string filename, SaveImageFormat format, string name) { return(NativeIUP.IupSaveImageAsText(IupHandle.GetCHandle(ih), filename, format.ToString().ToUpper(), name) != 0); }
public static IupHandle ElementPropertiesDialog(IupHandle element) { return(IupHandle.Create(NativeIUP.IupElementPropertiesDialog(IupHandle.GetCHandle(element)))); }
public static void TreeSetAttributeHandle(IupHandle ih, string name, int id, IupHandle ih_named) { NativeIUP.IupTreeSetAttributeHandle(IupHandle.GetCHandle(ih), name, id, IupHandle.GetCHandle(ih_named)); }
public static IupHandle MessageDlg() { return(IupHandle.Create(NativeIUP.IupMessageDlg())); }
public static IupHandle Clipboard() { return(IupHandle.Create(NativeIUP.IupClipboard())); }
public static IupHandle ColorDlg() { return(IupHandle.Create(NativeIUP.IupColorDlg())); }
public static IntPtr TreeGetUserId(IupHandle ih_tree, int id) { return(NativeIUP.IupTreeGetUserId(IupHandle.GetCHandle(ih_tree), id)); }
public static IupHandle Tree() { return(IupHandle.Create(NativeIUP.IupTree())); }