Ejemplo n.º 1
0
        // ###############################################################################
        // ### 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);
        }