Exemple #1
0
        // ###############################################################################
        // ### 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 XtDialog(XtApplicationShell toplevelShell, string caption)
        {
            if (toplevelShell == null)
            {
                throw new ArgumentNullException("toplevelShell");
            }

            _toplevelShell = toplevelShell;

            if (!string.IsNullOrEmpty(caption))
            {
                Arg[] shellArgs = { new Arg(XtNames.XtNtitle, X11.X11Utils.StringToSByteArray(caption + "\0")) };
                _shell = Xtlib.XtCreatePopupShell(SHELL_RESOURCE_NAME,
                                                  Xtlib.XawTransientShellWidgetClass(), toplevelShell.Shell,
                                                  shellArgs, (XCardinal)1);
            }
            else
            {
                _shell = Xtlib.XtCreatePopupShell(SHELL_RESOURCE_NAME,
                                                  Xtlib.XawTransientShellWidgetClass(), toplevelShell.Shell,
                                                  Arg.Zero, 0);
            }

            _toplevelShell.AssociatedShells.Add(this);
        }
        /// <summary> Initializing constructor. </summary>
        /// <param name="appResourceName"> The ressource name of the application. <see cref="System.String"/> </param>
        /// <param name="shellResourceName"> The ressource name of the root shell. <see cref="System.String"/> </param>
        /// <param name="fallbackResources"> The fallback ressources to apply. <see cref="Xt.XtFallbackRessources"/> </param>
        public XtApplicationShell(string appResourceName, string shellResourceName, Xt.XtFallbackRessources fallbackResources)
        {
            if (_instance != null)
            {
                Console.WriteLine(CLASS_NAME + "::ctr () ERROR: Already an instance created.");
            }

            _appResourceName = appResourceName;

            IntPtr argv = (string.IsNullOrEmpty(shellResourceName) ? IntPtr.Zero : (new XtStringArray(shellResourceName, '|')).Data);
            TInt   argc = (TInt)(argv != IntPtr.Zero ? 1 : 0);

            _shell = Xtlib.XtAppInitialize(ref _appContext, _appResourceName, IntPtr.Zero, 0, ref argc,
                                           argv, fallbackResources.Marshal(), IntPtr.Zero, 0);
            _instance = this;
        }
Exemple #3
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);
        }
        // ###############################################################################
        // ### 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);
        }