/// <summary> Dispose by parent. </summary> public override void DisposeByParent() { CallBackMarshaler.Remove(_cancelCommand); CallBackMarshaler.Remove(_okCommand); UnregisterDeleteWindowAction(); base.DisposeByParent(); }
// ############################################################################### // ### A T T R I B U T E S // ############################################################################### #region Attributes #endregion // ############################################################################### // ### C O N S T R U C T I O N A N D I N I T I A L I Z A T I O N // ############################################################################### #region Construction /// <summary> The initializing constructor. </summary> /// <param name="toplevelShell"> The toplevel shell that owns the underlaying transient popup shell of this dialog. <see cref="XtApplicationShell"/> </param> /// <param name="toplevelShell"> The shell caption. <see cref="System.String"/> </param> public XtGrabExclusiveAthenaDialog(XtApplicationShell toplevelShell, string caption) : base(toplevelShell, caption) { if (toplevelShell == null) { throw new ArgumentNullException("toplevelShell"); } // The dialog widget needs the final size of all child widgets during layout calculation to prevent child widget overlapping. Or in other words: // Child widget overlapping will happen, if XtNicon is set after dialog widget's layout calculation, because XtMakeResizeRequest () can't be called. // Currently the dialog widget isn't realized and therefor it hasn't a window. That's why we use the toplevel shell's window instead. IntPtr logo = IntPtr.Zero; if (!(Xtlib.XtIsRealized(toplevelShell.Shell) == (TBoolean)0)) { IntPtr display = Xtlib.XtDisplay(toplevelShell.Shell); IntPtr window = Xtlib.XtWindow(toplevelShell.Shell); logo = X11lib.XCreateBitmapFromData(display, window, XtResources.BIG_EXCLAMATION_ICON_BITS, XtResources.BIG_ICON_WIDTH, XtResources.BIG_ICON_HEIGHT); } Arg[] formArgs = { new Arg(XtNames.XtNlabel, X11.X11Utils.StringToSByteArray("Enter data string:\0")), new Arg(XtNames.XtNvalue, X11.X11Utils.StringToSByteArray("\0")), new Arg(XtNames.XtNicon, (XtArgVal)logo) }; _dialogForm = Xtlib.XtCreateManagedWidget(DIALOG_RESOURCE_NAME, Xtlib.XawDialogWidgetClass(), _shell, formArgs, (XCardinal)3); Arg[] okArgs = { new Arg(XtNames.XtNlabel, X11.X11Utils.StringToSByteArray("OK\0")) }; _okCommand = Xtlib.XtCreateManagedWidget(_okCmdName, Xtlib.XawCommandWidgetClass(), _dialogForm, okArgs, (XCardinal)1); Xtlib.XtAddCallback(_okCommand, XtNames.XtNcallback, CallBackMarshaler.Add(_okCommand, this.DialogOk), IntPtr.Zero); Arg[] cancelArgs = { new Arg(XtNames.XtNlabel, X11.X11Utils.StringToSByteArray("Cancel\0")) }; _cancelCommand = Xtlib.XtCreateManagedWidget(_cancelCmdName, Xtlib.XawCommandWidgetClass(), _dialogForm, cancelArgs, (XCardinal)1); Xtlib.XtAddCallback(_cancelCommand, XtNames.XtNcallback, CallBackMarshaler.Add(_cancelCommand, this.DialogCancel), IntPtr.Zero); }
// ############################################################################### // ### A T T R I B U T E S // ############################################################################### #region Attributes #endregion // ############################################################################### // ### C O N S T R U C T I O N A N D I N I T I A L I Z A T I O N // ############################################################################### #region Construction public XtGrabExclusiveMessageBox(XtApplicationShell toplevelShell, string message, string caption, DialogIcon icontype) : base(toplevelShell, caption) { if (toplevelShell == null) { throw new ArgumentNullException("toplevelShell"); } Arg[] formArgs = { new Arg(XtNames.XtNbackground, (XtArgVal)toplevelShell.AllocColorFromDefaultColormap(X11ColorNames.Gray80).P) }; _dialogForm = Xtlib.XtCreateManagedWidget(DIALOG_RESOURCE_NAME, Xtlib.XawFormWidgetClass(), _shell, formArgs, (XCardinal)1); // The dialog widget needs the final size of all child widgets during layout calculation to prevent child widget overlapping. Or in other words: // Child widget overlapping will happen, if XtNicon is set after dialog widget's layout calculation, because XtMakeResizeRequest () can't be called. // Currently the dialog widget isn't realized and therefor it hasn't a window. That's why we use the toplevel shell's window instead. IntPtr logo = IntPtr.Zero; if (!(Xtlib.XtIsRealized(toplevelShell.Shell) == (TBoolean)0) && icontype != XtDialog.DialogIcon.None) { IntPtr display = Xtlib.XtDisplay(toplevelShell.Shell); IntPtr window = Xtlib.XtWindow(toplevelShell.Shell); if (icontype == DialogIcon.Information) { logo = X11lib.XCreateBitmapFromData(display, window, XtResources.BIG_INFORMATION_ICON_BITS, XtResources.BIG_ICON_WIDTH, XtResources.BIG_ICON_HEIGHT); } else if (icontype == DialogIcon.Question) { logo = X11lib.XCreateBitmapFromData(display, window, XtResources.BIG_QUESTION_ICON_BITS, XtResources.BIG_ICON_WIDTH, XtResources.BIG_ICON_HEIGHT); } else if (icontype == DialogIcon.Exclamation) { logo = X11lib.XCreateBitmapFromData(display, window, XtResources.BIG_EXCLAMATION_ICON_BITS, XtResources.BIG_ICON_WIDTH, XtResources.BIG_ICON_HEIGHT); } else // if (icontype == DialogIcon.Stop) { logo = X11lib.XCreateBitmapFromData(display, window, XtResources.BIG_STOP_ICON_BITS, XtResources.BIG_ICON_WIDTH, XtResources.BIG_ICON_HEIGHT); } } Arg[] msgArgs = { new Arg(XtNames.XtNlabel, X11.X11Utils.StringToSByteArray(message + "\0")), new Arg(XtNames.XtNbackground, (XtArgVal)toplevelShell.AllocColorFromDefaultColormap(X11ColorNames.Gray80).P), new Arg(XtNames.XtNborderWidth, (XtArgVal)0), new Arg(XtNames.XtNleftBitmap, (XtArgVal)logo) }; _messageLabel = Xtlib.XtCreateManagedWidget(_msgLblName, Xtlib.XawLabelWidgetClass(), _dialogForm, msgArgs, (XCardinal)4); Arg[] okArgs = { new Arg(XtNames.XtNlabel, X11.X11Utils.StringToSByteArray("Yes\0")), new Arg(XtNames.XtNfromVert, _messageLabel) }; _okCommand = Xtlib.XtCreateManagedWidget(_okCmdName, Xtlib.XawCommandWidgetClass(), _dialogForm, okArgs, (XCardinal)2); Xtlib.XtAddCallback(_okCommand, XtNames.XtNcallback, CallBackMarshaler.Add(_okCommand, this.DialogOk), IntPtr.Zero); Arg[] cancelArgs = { new Arg(XtNames.XtNlabel, X11.X11Utils.StringToSByteArray("No\0")), new Arg(XtNames.XtNfromVert, _messageLabel), new Arg(XtNames.XtNfromHoriz, _okCommand) }; _cancelCommand = Xtlib.XtCreateManagedWidget(_cancelCmdName, Xtlib.XawCommandWidgetClass(), _dialogForm, cancelArgs, (XCardinal)3); Xtlib.XtAddCallback(_cancelCommand, XtNames.XtNcallback, CallBackMarshaler.Add(_cancelCommand, this.DialogCancel), IntPtr.Zero); }