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

📄 glade2ui.cpp

📁 Linux下的基于X11的图形开发环境。
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    bool layouted = ( numImages > 0 );    if ( layouted ) {	emitOpening( QString("grid") );	if ( !logoImage.isEmpty() )	    emitPixmap( imageName(logoImage), numImages, numImages + 1, 0, 1 );	if ( !watermarkImage.isEmpty() )	    emitPixmap( imageName(watermarkImage), 0, 1, numImages,			numImages + 1 );    } else {	leftAttach = -1;	rightAttach = -1;	topAttach = -1;	bottomAttach = -1;    }    if ( gtkClass.endsWith(QString("Standard")) ) {	emitChildWidgets( childWidgets, layouted, leftAttach, rightAttach,			  topAttach, bottomAttach );    } else if ( !text.isEmpty() ) {	if ( layouted )	    emitOpeningWidget( QString("QLayoutWidget"), leftAttach,			       rightAttach, topAttach, bottomAttach );	emitOpening( QString("hbox") );	emitSpacer( QString("Horizontal") );	emitOpeningWidget( QString("QLabel") );	emitProperty( QString("text"), text );	emitClosing( QString("widget") );	emitSpacer( QString("Horizontal") );	emitClosing( QString("hbox") );	if ( layouted )	    emitClosing( QString("widget") );    }    if ( layouted )	emitClosing( QString("grid") );    emitClosing( QString("widget") );}void Glade2Ui::emitGtkWindowChildWidgets(	const QValueList<QDomElement>& childWidgets, const QString& qtClass ){    if ( childWidgets.count() == 1 && qtClass == QString("QWizard") ) {	emitFontProperty( QString("titleFont"), 18, FALSE );	QDomNode n = childWidgets.first().firstChild();	while ( !n.isNull() ) {	    if ( n.toElement().tagName() == QString("widget") )		emitGnomeDruidPage( n.toElement() );	    n = n.nextSibling();	}    } else {	emitChildWidgets( childWidgets, FALSE );    }}bool Glade2Ui::packEnd( const QDomElement& widget ){    QDomNode n = widget.firstChild();    while ( !n.isNull() ) {	if ( n.toElement().tagName() == QString("child") ) {	    QDomNode child = n.firstChild();	    while ( !child.isNull() ) {		if ( child.toElement().tagName() == QString("pack") ) {		    QString pack = getTextValue( child );		    return pack.endsWith( QString("_END") );		}		child = child.nextSibling();	    }	}	n = n.nextSibling();    }    return FALSE;}void Glade2Ui::emitChildWidgets( const QValueList<QDomElement>& childWidgets,				 bool layouted, int leftAttach, int rightAttach,				 int topAttach, int bottomAttach ){    QValueList<QDomElement> start;    QValueList<QDomElement> end;    QValueList<QDomElement>::ConstIterator e;    if ( layouted ) {	e = childWidgets.begin();	while ( e != childWidgets.end() ) {	    if ( packEnd(*e) )		end.push_front( *e );	    else		start.push_back( *e );	    ++e;	}    } else {	start = childWidgets;    }    e = start.begin();    while ( e != start.end() ) {	emitWidget( *e, layouted, leftAttach, rightAttach, topAttach,		    bottomAttach );	++e;    }    e = end.begin();    while ( e != end.end() ) {	emitWidget( *e, layouted, leftAttach, rightAttach, topAttach,		    bottomAttach );	++e;    }}void Glade2Ui::emitOpeningWidget( const QString& qtClass, int leftAttach,				  int rightAttach, int topAttach,				  int bottomAttach ){    AttributeMap attr = attribute( QString("class"), qtClass );    attach( &attr, leftAttach, rightAttach, topAttach, bottomAttach );    emitOpening( QString("widget"), attr );}/*  Returns TRUE if the vbox containing childWidgets should have a  spacer at the end to prevent it from looking bad, otherwise returns  FALSE.  The algorithm is very experimental.*/bool Glade2Ui::shouldPullup( const QValueList<QDomElement>& childWidgets ){    QRegExp gtkSmallWidget( QString(	    "G.*(?:Button|Combo|Dial|Entry|Label|OptionMenu|Picker|ProgressBar"	    "|Separator|Statusbar|Toolbar|VBox)") );    QValueList<QDomElement>::ConstIterator c = childWidgets.begin();    while ( c != childWidgets.end() ) {	QValueList<QDomElement> grandchildWidgets;	QString gtkClass;	QDomNode n = (*c).firstChild();	while ( !n.isNull() ) {	    QString tagName = n.toElement().tagName();	    if ( tagName == QString("class") ) {		gtkClass = getTextValue( n );	    } else if ( tagName == QString("widget") ) {		grandchildWidgets.push_back( n.toElement() );	    }	    n = n.nextSibling();	}	if ( !gtkSmallWidget.exactMatch(gtkClass) ||	     !shouldPullup(grandchildWidgets) )	    return FALSE;	++c;    }    return TRUE;}QString Glade2Ui::emitWidget( const QDomElement& widget, bool layouted,			      int leftAttach, int rightAttach, int topAttach,			      int bottomAttach ){    QRegExp gtkLayoutWidget( QString(	    "Gtk(?:Packer|Table|Toolbar|[HV](?:(?:Button)?Box))") );    QRegExp gtkOrientedWidget( QString(	    "Gtk([HV])(?:Paned|Scale|Scrollbar|Separator)") );    QValueList<QDomElement> childWidgets;    QString gtkClass;    QString name;    QString title;    int x = 0;    int y = 0;    int width = 0;    int height = 0;    int numRows = 0;    int numColumns = 0;    bool active = FALSE;    QString authors;    QString childName;    QString comments;    QString copyright;    QString creationFunction;    bool editable = TRUE;    QString filename;    QString focusTarget;    QString hscrollbarPolicy;    QString icon;    int initialChoice = 0;    QStringList items;    QString justify;    QString label;    QString logoImage;    int lower = -123456789;    int page = 10;    int pageSize = 10;    QString selectionMode;    QString shadowType( "GTK_SHADOW_NONE" );    bool showText = TRUE;    bool showTitles = TRUE;    int step = 1;    QString tabPos;    QString text;    int textMaxLength = 0;    bool textVisible = TRUE;    QString tooltip;    QString type;    int upper = 123456789;    int value = 123456789;    bool valueInList = TRUE;    QString vscrollbarPolicy;    QString watermarkImage;    bool wrap = FALSE;    bool topLevel = yyFormName.isEmpty();    if ( topLevel )	name = QString( "Form%1" ).arg( uniqueForm++ );    QDomNode n = widget.firstChild();    while ( !n.isNull() ) {	QString tagName = n.toElement().tagName();	if ( !tagName.isEmpty() ) {	    /*	      Recognize the properties and stores them in variables.	      This step is a bit silly, and if this function were to	      be rewritten, almost everything would just be stored, as	      strings, in a giant map, and looked up for when emitting	      the properties.	    */	    switch ( (uchar) tagName[0].cell() ) {	    case 'a':		if ( tagName == QString("active") ) {		    active = isTrue( getTextValue(n) );		} else if ( tagName == QString("authors") ) {		    authors = getTextValue( n );		}		break;	    case 'c':		if ( tagName == QString("child") ) {		    QDomNode child = n.firstChild();		    while ( !child.isNull() ) {			QString childTagName = child.toElement().tagName();			if ( childTagName == QString("left_attach") ) {			    leftAttach = getTextValue( child ).toInt();			} else if ( childTagName == QString("right_attach") ) {			    rightAttach = getTextValue( child ).toInt();			} else if ( childTagName == QString("top_attach") ) {			    topAttach = getTextValue( child ).toInt();			} else if ( childTagName == QString("bottom_attach") ) {			    bottomAttach = getTextValue( child ).toInt();			}			child = child.nextSibling();		    }		} else if ( tagName == QString("child_name") ) {		    childName = getTextValue( n );		} else if ( tagName == QString("class") ) {		    gtkClass = getTextValue( n );		} else if ( tagName == QString("climb_rate") ) {		    step = getTextValue( n ).toInt();		} else if ( tagName == QString("columns") ) {		    numColumns = getTextValue( n ).toInt();		} else if ( tagName == QString("comments") ) {		    comments = getTextValue( n );		} else if ( tagName == QString("copyright") ) {		    copyright = getTextValue( n );		} else if ( tagName == QString("creation_function") ) {		    creationFunction = getTextValue( n );		}		break;	    case 'd':		if ( tagName == QString("default_focus_target") ) {		    if ( focusTarget.isEmpty() )			focusTarget = getTextValue( n );		}		break;	    case 'e':		if ( tagName == QString("editable") )		    editable = isTrue( getTextValue(n) );		break;	    case 'f':		if ( tagName == QString("filename") ) {		    filename = getTextValue( n );		} else if ( tagName == QString("focus_target") ) {		    focusTarget = getTextValue( n );		}		break;	    case 'h':		if ( tagName == QString("height") ) {		    height = getTextValue( n ).toInt();		} else if ( tagName == QString("hscrollbar_policy") ) {		    hscrollbarPolicy = getTextValue( n );		}		break;	    case 'i':		if ( tagName == QString("icon") ) {		    icon = getTextValue( n );		} else if ( tagName == QString("initial_choice") ) {		    initialChoice = getTextValue( n ).toInt();		} else if ( tagName == QString("items") ) {		    items = QStringList::split( QChar('\n'), getTextValue(n) );		}		break;	    case 'j':		if ( tagName == QString("justify") )		    justify = getTextValue( n );		break;	    case 'l':		if ( tagName == QString("label") ) {		    label = getTextValue( n );		} else if ( tagName == QString("logo_image") ) {		    logoImage = getTextValue( n );		} else if ( tagName == QString("lower") ) {		    lower = getTextValue( n ).toInt();		}		break;	    case 'n':		if ( tagName == QString("name") )		    name = getTextValue( n );		break;	    case 'p':		if ( tagName == QString("page") ) {		    page = getTextValue( n ).toInt();		} else if ( tagName == QString("page_size") ) {		    pageSize = getTextValue( n ).toInt();		}		break;	    case 'r':		if ( tagName == QString("rows") )		    numRows = getTextValue( n ).toInt();		break;	    case 's':		if ( tagName == QString("selection_mode") ) {		    selectionMode = getTextValue( n );		} else if ( tagName == QString("shadow_type") ) {		    shadowType = getTextValue( n );		} else if ( tagName == QString("show_text") ) {		    showText = isTrue( getTextValue(n) );		} else if ( tagName == QString(QString("show_titles")) ) {		    showTitles = isTrue( getTextValue(n) );		} else if ( tagName == QString("step") ) {		    step = getTextValue( n ).toInt();		} else if ( tagName == QString("stock_button") ) {		    /*		      Let's cheat: We convert the symbolic name into a		      button label.		    */		    label = getTextValue( n );		    int k = label.findRev( QChar('_') );		    if ( k != -1 )			label = label.mid( k + 1 );		    if ( !label.isEmpty() && label != QString("OK") )			label = label.left( 1 ) + label.mid( 1 ).lower();		}		break;	    case 't':		if ( tagName == QString("tab_pos") ) {		    tabPos = getTextValue( n );		} else if ( tagName == QString("text") ) {		    text = getTextValue( n );		} else if ( tagName == QString("textMaxLength") ) {		    textMaxLength = getTextValue( n ).toInt();		} else if ( tagName == QString("textVisible") ) {		    textVisible = isTrue( getTextValue(n) );		} else if ( tagName == QString("title") ) {		    title = getTextValue( n );		} else if ( tagName == QString("tooltip") ) {		    tooltip = getTextValue( n );		} else if ( tagName == QString("type") ) {		    type = getTextValue( n );		}		break;	    case 'u':		if ( tagName == QString("upper") )		    upper = getTextValue( n ).toInt();		break;	    case 'v':		if ( tagName == QString("value") ) {		    value = getTextValue( n ).toInt();		} else if ( tagName == QString("value_in_list") ) {		    valueInList = isTrue( getTextValue(n) );		} else if ( tagName == QString("vscrollbar_policy") ) {		    vscrollbarPolicy = getTextValue( n );		}		break;	    case 'w':		if ( tagName == QString("watermark_image") ) {		    watermarkImage = getTextValue( n );		} else if ( tagName == QString("widget") )		    childWidgets.push_back( n.toElement() );		else if ( tagName == QString("width") )		    width = getTextValue( n ).toInt();		else if ( tagName == QString("wrap") )		    wrap = isTrue( getTextValue(n) );		break;	    case 'x':		if ( tagName == QString("x") )		    x = getTextValue( n ).toInt();		break;	    case 'y':		if ( tagName == QString("y") )		    y = getTextValue( n ).toInt();	    }	}	n = n.nextSibling();    }    if ( topLevel ) {	yyFormName = name;	emitSimpleValue( QString("class"), yyFormName );    }    if ( gtkLayoutWidget.exactMatch(gtkClass) ) {	QString boxKind;	QString orientation;	if ( gtkClass.startsWith(QString("GtkH")) ||	     gtkClass == QString(QString("GtkToolbar")) ) {	    /*	      GtkToolbar, right. Toolbars may appear anywhere in a	      widget, but then they really are just a row of buttons.	    */	    boxKind = QString( "hbox" );	    orientation = QString( "Horizontal" );	} else if ( gtkClass.startsWith(QString("GtkV")) ||		    gtkClass == QString("GtkPacker") ) {	    /*	      We don't support the GtkPacker, whose trails lead to	      destruction.	    */	    boxKind = QString( "vbox" );	    orientation = QString( "Vertical" );	} else {	    boxKind = QString( "grid" );	}	if ( layouted )

⌨️ 快捷键说明

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