⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qmotifdialog.cpp

📁 Linux下的基于X11的图形开发环境。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** $Id: qt/qmotifdialog.cpp   3.1.1   edited Oct 16 09:19 $**** Implementation of Qt extension classes for Xt/Motif support.**** Copyright (C) 1992-2002 Trolltech AS.  All rights reserved.**** This file is part of the Qt extension for Xt/Motif support.**** Licensees holding valid Qt Enterprise Edition licenses for X11 may use** this file in accordance with the Qt Commercial License Agreement provided** with the Software.**** This file is not available for use under any other license without** express written permission from the copyright holder.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.**** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for**   information about Qt Commercial License Agreements.**** Contact info@trolltech.com if any conditions of this licensing are** not clear to you.************************************************************************/#include "qmotif.h"#include "qmotifdialog.h"#include "qmotifwidget.h"#include <qapplication.h>#include <qobjectlist.h>#include <qwidgetintdict.h>#include <Xm/DialogS.h>#include <Xm/DialogSP.h>#include <Xm/MessageB.h>#include <Xm/SelectioB.h>#include <Xm/FileSB.h>#include <Xm/Command.h>// XmDialogShell subclass to wrap motif dialogs into QDialogstypedef struct {    QMotifDialog *dialog;} QMotifDialogPart;typedef struct _QMotifDialogRec{    // full instance record declaration    CorePart			core;    CompositePart		composite;    ShellPart			shell;    WMShellPart			wmshell;    VendorShellPart		vendorshell;    TransientShellPart		transientshell;    XmDialogShellPart		dialogshell;    QMotifDialogPart		qmotifdialog;} QMotifDialogRec;typedef struct{    // extension record    XtPointer extension;} QMotifDialogClassPart;typedef struct _QMotifDialogClassRec{    CoreClassPart		core_class;    CompositeClassPart		composite_class;    ShellClassPart		shell_class;    WMShellClassPart		wmshell_class;    VendorShellClassPart	vendorshell_class;    TransientShellClassPart	transientshell_class;    XmDialogShellClassPart	dialogshell_class;    QMotifDialogClassPart	qmotifdialog_class;} QMotifDialogClassRec;externalref QMotifDialogClassRec	qmotifDialogShellClassRec;externalref WidgetClass			qmotifDialogWidgetClass;typedef struct _QMotifDialogClassRec   *QMotifDialogWidgetClass;typedef struct _QMotifDialogRec	       *QMotifDialogWidget;externaldef(qmotifdialogclassrec)    QMotifDialogClassRec qmotifDialogClassRec = {	// Core	{	    (WidgetClass) &xmDialogShellClassRec,	/* superclass */	    "QMotifDialog",				/* class_name */	    sizeof(QMotifDialogRec),			/* widget_size */	    NULL,					/* class_initialize proc */	    NULL,					/* class_part_initialize proc */	    FALSE,					/* class_inited flag */	    NULL,					/* instance initialize proc */	    NULL,					/* init_hook proc */	    qmotif_dialog_realize,			/* realize widget proc */	    NULL,					/* action table for class */	    0,						/* num_actions */	    NULL,					/* resource list of class */	    0,						/* num_resources in list */	    NULLQUARK,					/* xrm_class ? */	    FALSE,					/* don't compress_motion */	    XtExposeCompressSeries,		 	/* compressed exposure */	    FALSE,					/* do compress enter-leave */	    FALSE,					/* do have visible_interest */	    NULL,					/* destroy widget proc */	    XtInheritResize,				/* resize widget proc */	    NULL,					/* expose proc */	    NULL,		 			/* set_values proc */	    NULL,					/* set_values_hook proc */	    XtInheritSetValuesAlmost,			/* set_values_almost proc */	    NULL,					/* get_values_hook */	    NULL,					/* accept_focus proc */	    XtVersion,					/* current version */	    NULL,					/* callback offset    */	    XtInheritTranslations,			/* default translation table */	    XtInheritQueryGeometry,			/* query geometry widget proc */	    NULL,					/* display accelerator    */	    NULL,					/* extension record      */	},	// Composite	{	    XtInheritGeometryManager,			/* geometry_manager */	    qmotif_dialog_change_managed,		// change managed	    qmotif_dialog_insert_child,			// insert_child	    qmotif_dialog_delete_child,			// delete_child	    NULL,					// extension record	},	// Shell extension record	{ NULL },	// WMShell extension record	{ NULL },	// VendorShell extension record	{ NULL },	// TransientShell extension record	{ NULL },	// XmDialogShell extension record	{ NULL },	// QMOTIGDIALOG	{ NULL }    };externaldef(qmotifdialogwidgetclass)    WidgetClass qmotifDialogWidgetClass = (WidgetClass)&qmotifDialogClassRec;class QMotifDialogPrivate{public:    QMotifDialogPrivate() : shell( NULL ), dialog( NULL ) { }    Widget shell;    Widget dialog;};/*!    \class QMotifDialog    \brief The QMotifDialog class provides the QDialog API for Motif dialogs.    \extension Motif    When migrating Motif applications to Qt, developers will want to    rewrite their Motif dialogs using Qt, and switch to using Qt's    modality semantics. QMotifDialog ensures that modal Motif dialogs    continue to work properly when used in a Qt application.    For the purpose of the Motif extension, Motif has two types of    dialogs: predefined dialogs and custom dialogs. The predefined    Motif dialogs are:    \list    \i Prompt    \i Selection    \i Command    \i FileSelection    \i Template    \i Error    \i Information    \i Message    \i Question    \i Warning    \i Working    \endlist    QMotifDialog provides a constructor for the predefined Motif    dialog types, which creates a dialog shell and the dialog widget    itself.    Example usage QMotifDialog to create a predefined Motif dialog:    \code    ...    XmString message = XmStringCreateLocalized( "This is a Message dialog.",                                                XmSTRING_DEFAULT_CHARSET );    Arg args[1];    XtSetArg( args[0], XmNmessageString, message );    // parent is an ApplicationShell created earlier in the application    QMotifDialog dailog( QMotifDialog::Message, parent, args, 1,                         "motif message dialog", TRUE );    XtAddCallback( dialog.dialog(), XmNokCallback,                   (XtCallbackProc) QMotifDialog::acceptCallback, &dialog );    XtAddCallback( dialog.dialog(), XmNcancelCallback,                   (XtCallbackProc) QMotifDialog::rejectCallback, &dialog );    dialog.exec();    XmStringFree( message );    ...    \endcode    QMotifDialog also provides a constructor for custom Motif dialogs,    which only creates the dialog shell. The application programmer    can create a custom dialog using the QMotifDialog shell as its    parent.    QMotifDialogs can be used with either an Xt/Motif or a QWidget    parent.*//*!    \enum QMotifDialog::DialogType    This enum lists the predefined Motif dialog types.    \value Prompt    \value Selection    \value Command    \value FileSelection    \value Template    \value Error    \value Information    \value Message    \value Question    \value Warning    \value Working*//*!    Creates a predefined Motif dialog of type \a dtype with a Motif    widget \a parent.    The arguments are passed in \a args, and the number of arguments    in \a argcount. The \a name, \a modal and \a flags arguments are    passed on to the QDialog constructor.    Creates a Shell widget which is a special subclass of    XmDialogShell. This allows applications to use the QDialog API    with existing Motif dialogs. It also means that applications can    properly handle modality with the QMotif extension. You can access    the Shell widget with the shell() member function.    Creates a dialog widget with the Shell widget as it's parent. The    type of the dialog created is specified by the \a dtype    argument. See the \c DialogType enum for a list of available dialog    types. You can access the dialog widget with the dialog() member    function.    \warning When QMotifDialog is destroyed, the Shell widget and the    dialog widget are destroyed. You should not destroy the dialog    widget yourself.*/QMotifDialog::QMotifDialog( DialogType dtype, Widget parent,			    ArgList args, Cardinal argcount,			    const char *name, bool modal, WFlags flags )    : QDialog( 0, name, modal, flags ){    d = new QMotifDialogPrivate;    // tell motif about modality    Arg *realargs = new Arg[ argcount + 2 ];    memcpy( realargs, args, argcount * sizeof(Arg) );    if ( modal ) {	XtSetArg( realargs[argcount], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);	argcount ++;    }    // create the dialog shell    d->shell = XtCreatePopupShell( name, qmotifDialogWidgetClass, parent,				   realargs, argcount );    ( (QMotifDialogWidget) d->shell )->qmotifdialog.dialog = this;    // get the widget class for the dialog type    WidgetClass widgetclass;    int dialogtype;    switch ( dtype ) {    case Prompt:	dialogtype = XmDIALOG_PROMPT;	widgetclass = xmSelectionBoxWidgetClass;	break;    case Selection:	dialogtype = XmDIALOG_SELECTION;	widgetclass = xmSelectionBoxWidgetClass;	break;    case Command:	dialogtype = XmDIALOG_COMMAND;	widgetclass = xmCommandWidgetClass;	break;    case FileSelection:	dialogtype = XmDIALOG_FILE_SELECTION;	widgetclass = xmFileSelectionBoxWidgetClass;	break;    case Template:	dialogtype = XmDIALOG_TEMPLATE;	widgetclass = xmMessageBoxWidgetClass;	break;    case Error:	dialogtype = XmDIALOG_ERROR;	widgetclass = xmMessageBoxWidgetClass;	break;    case Information:	dialogtype = XmDIALOG_INFORMATION;	widgetclass = xmMessageBoxWidgetClass;	break;    case Message:	dialogtype = XmDIALOG_MESSAGE;	widgetclass = xmMessageBoxWidgetClass;	break;    case Question:	dialogtype = XmDIALOG_QUESTION;	widgetclass = xmMessageBoxWidgetClass;	break;    case Warning:	dialogtype = XmDIALOG_WARNING;	widgetclass = xmMessageBoxWidgetClass;	break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -