📄 qmotifdialog.cpp
字号:
case Working: dialogtype = XmDIALOG_WORKING; widgetclass = xmMessageBoxWidgetClass; break; } // set the dialog type XtSetArg( realargs[ argcount ], XmNdialogType, dialogtype ); argcount++; d->dialog = XtCreateWidget( name, widgetclass, d->shell, realargs, argcount ); delete [] realargs;}/*! Creates a QMotifDialog for use in a custom Motif dialog. The dialog's parent is \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. A dialog widget is not created by this constructor. Instead, you should create the dialog widget as a child of this dialog. Once you do this, QMotifDialog will take ownership of your custom dialog, and you can access it 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( 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 + 1 ]; 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; delete [] realargs;}/*! Destroys the QDialog, dialog widget and shell widget.*/QMotifDialog::~QMotifDialog(){ QMotif::unregisterWidget( this ); ( (QMotifDialogWidget) d->shell )->qmotifdialog.dialog = 0; XtDestroyWidget( d->shell ); delete d; destroy( FALSE );}/*! Returns the Shell widget embedded in this dialog.*/Widget QMotifDialog::shell() const{ return d->shell;}/*! Returns the Motif widget embedded in this dialog.*/Widget QMotifDialog::dialog() const{ return d->dialog;}/*! \reimp*/void QMotifDialog::accept(){ QDialog::accept();}/*! \reimp*/void QMotifDialog::reject(){ QDialog::reject();}/*! \reimp Manages the dialog widget and shows the dialog.*/void QMotifDialog::show(){ QMotifDialogWidget motifdialog = (QMotifDialogWidget) d->shell; XtManageChildren( motifdialog->composite.children, motifdialog->composite.num_children ); QDialog::show();}/*! \reimp Unmanages the dialog and hides the dialog.*/void QMotifDialog::hide(){ QMotifDialogWidget motifdialog = (QMotifDialogWidget) d->shell; XtUnmanageChildren( motifdialog->composite.children, motifdialog->composite.num_children ); QDialog::hide();}/*! Convenient Xt/Motif callback to accept the QMotifDialog. The data is passed in \a client_data.*/void QMotifDialog::acceptCallback( Widget, XtPointer client_data, XtPointer ){ QMotifDialog *dialog = (QMotifDialog *) client_data; dialog->accept();}/*! Convenient Xt/Motif callback to reject the QMotifDialog. The data is passed in \a client_data.*/void QMotifDialog::rejectCallback( Widget, XtPointer client_data, XtPointer ){ QMotifDialog *dialog = (QMotifDialog *) client_data; dialog->reject();}/*! \internal Wraps the Motif dialog by setting the X window for the QMotifDialog to the X window id of the dialog shell.*/void QMotifDialog::realize( Widget w ){ // use the winid of the dialog shell, reparent any children we have if ( XtWindow( w ) != winId() ) { Window newid = XtWindow( w ); if ( children() ) { QObjectListIt it( *children() ); for ( ; it.current(); ++it ) { if ( it.current()->isWidgetType() ) { QWidget *widget = (QWidget *) it.current(); XReparentWindow( QPaintDevice::x11AppDisplay(), widget->winId(), newid, widget->x(), widget->y() ); if ( !widget->isHidden() ) XMapWindow( QPaintDevice::x11AppDisplay(), widget->winId() ); } } } QApplication::syncX(); create( newid, TRUE, TRUE ); QString cap; if ( ! caption().isNull() ) { cap = caption(); setCaption( QString::null ); } else { setCaption( QString::null ); XTextProperty text_prop; if (XGetWMName( QPaintDevice::x11AppDisplay(), winId(), &text_prop)) { if (text_prop.value && text_prop.nitems > 0) { if (text_prop.encoding == XA_STRING) { cap = QString::fromLocal8Bit( (char *) text_prop.value ); } else { text_prop.nitems = strlen((char *) text_prop.value); char **list; int num; if (XmbTextPropertyToTextList(QPaintDevice::x11AppDisplay(), &text_prop, &list, &num) == Success && num > 0 && *list) { cap = QString::fromLocal8Bit( *list ); XFreeStringList(list); } } } } } // if this dialog was created without a QWidget parent, then the transient // for will be set to the root window, which is not acceptable. // instead, set it to the window id of the shell's parent if ( ! parent() && XtParent( d->shell ) ) XSetTransientForHint( QPaintDevice::x11AppDisplay(), newid, XtWindow( XtParent( d->shell ) ) ); } QMotif::registerWidget( this );}/*! \internal Sets the dialog widget for the QMotifDialog to \w.*/void QMotifDialog::insertChild( Widget w ){#if defined(QT_CHECK_STATE) if ( d->dialog != NULL && d->dialog != w ) { qWarning( "QMotifDialog::insertChild: cannot insert widget since one child\n" " has been inserted already." ); return; }#endif d->dialog = w;}/*! \internal Resets the dialog widget for the QMotifDialog if the current dialog widget matches \w.*/void QMotifDialog::deleteChild( Widget w ){#if defined(QT_CHECK_STATE) if ( ! d->dialog ) { qWarning( "QMotifDialog::deleteChild: cannot delete widget since no child\n" " was inserted." ); return; } if ( d->dialog != w ) { qWarning( "QMotifDialog::deleteChild: cannot delete widget different from\n" " inserted child" ); return; }#endif d->dialog = NULL;}/*! \internal Motif callback to resolve a QMotifDialog and call QMotifDialog::realize().*/void qmotif_dialog_realize( Widget w, XtValueMask *mask, XSetWindowAttributes *attr ){ XtRealizeProc realize = xmDialogShellClassRec.core_class.realize; (*realize)( w, mask, attr ); QMotifDialog *dialog = ( (QMotifDialogWidget) w )->qmotifdialog.dialog; if ( ! dialog ) return; dialog->realize( w );}/*! \internal Motif callback to forward a QMotifDialog and call QMotifDialog::insertChild().*/void qmotif_dialog_insert_child( Widget w ){ XtWidgetProc insert_child = xmDialogShellClassRec.composite_class.insert_child; (*insert_child)( w ); QMotifDialog *dialog = ( (QMotifDialogWidget) w->core.parent )->qmotifdialog.dialog; if ( ! dialog ) return; dialog->insertChild( w );}/*! \internal Motif callback to resolve a QMotifDialog and call QMotifDialog::deleteChild().*/void qmotif_dialog_delete_child( Widget w ){ XtWidgetProc delete_child = xmDialogShellClassRec.composite_class.delete_child; (*delete_child)( w ); QMotifDialog *dialog = ( (QMotifDialogWidget) w->core.parent )->qmotifdialog.dialog; if ( ! dialog ) return; dialog->deleteChild( w );}/*! \internal Motif callback to resolve a QMotifDialog and set the initial geometry of the dialog.*/void qmotif_dialog_change_managed( Widget w ){ XtWidgetProc change_managed = xmDialogShellClassRec.composite_class.change_managed; (*change_managed)( w ); QMotifDialog *dialog = ( (QMotifDialogWidget) w )->qmotifdialog.dialog; if ( ! dialog ) return; QRect r( dialog->d->shell->core.x, dialog->d->shell->core.y, dialog->d->shell->core.width, dialog->d->shell->core.height ), d = dialog->geometry(); if ( d != r ) { dialog->setGeometry( r ); }}/*!\reimp */bool QMotifDialog::event( QEvent* e ){ if ( QMotifWidget::dispatchQEvent( e, this ) ) return TRUE; return QWidget::event( e );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -