コード例 #1
0
ファイル: MainWindow.cpp プロジェクト: Sangil-Lee/RefCode
void
MainWindow::makeUI()
{
    setObjectName(QString::fromUtf8("MainWindow"));
#if 1
    action_Exit = new QAction(this);
    action_Exit->setObjectName(QString::fromUtf8("action_Exit"));
	//connect(action_Exit, SIGNAL(triggered()), qApp, SLOT(quit()));
	connect(action_Exit, SIGNAL(triggered()), this, SLOT(close()));
#endif

    centralwidget = new QWidget(this);
    centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
	
    widget = new QWidget(centralwidget);
    widget->setObjectName(QString::fromUtf8("widget"));
    widget->setGeometry(QRect(190, 0, 1080, 821));
    widget->setMinimumSize(QSize(400, 0));
    vboxLayout = new QVBoxLayout(widget);
    vboxLayout->setSpacing(0);
    vboxLayout->setMargin(0);
    vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
    dockWidget = new QDockWidget(widget);
    dockWidget->setObjectName(QString::fromUtf8("dockWidget"));
    QSizePolicy sizePolicy(static_cast<QSizePolicy::Policy>(7), static_cast<QSizePolicy::Policy>(7));
    sizePolicy.setHorizontalStretch(0);
    sizePolicy.setVerticalStretch(0);
    sizePolicy.setHeightForWidth(dockWidget->sizePolicy().hasHeightForWidth());
    dockWidget->setSizePolicy(sizePolicy);
    dockWidgetContents = new QWidget(dockWidget);
    dockWidgetContents->setObjectName(QString::fromUtf8("dockWidgetContents"));

    vdockLayout = new QVBoxLayout(widget);
    vdockLayout->setSpacing(0);
    vdockLayout->setMargin(0);
    vdockLayout->setObjectName(QString::fromUtf8("vdockLayout"));

    stackedWidget = new QStackedWidget(dockWidgetContents);
    stackedWidget->setObjectName(QString::fromUtf8("stackedWidget"));
    stackedWidget->setGeometry(QRect(0, 0, 1080, 821));
    dockWidget->setWidget(dockWidgetContents);

    vboxLayout->addWidget(dockWidget);

	dockWidgetContents->setLayout(vdockLayout);
	vdockLayout->addWidget(stackedWidget);

    tabWidget = new QTabWidget(centralwidget);
    tabWidget->setObjectName(QString::fromUtf8("tabWidget"));
    tabWidget->setGeometry(QRect(0, 0, 190, 821));
    QSizePolicy sizePolicy1(static_cast<QSizePolicy::Policy>(5), static_cast<QSizePolicy::Policy>(5));
    sizePolicy1.setHorizontalStretch(0);
    sizePolicy1.setVerticalStretch(0);
    sizePolicy1.setHeightForWidth(tabWidget->sizePolicy().hasHeightForWidth());

    tabWidget->setSizePolicy(sizePolicy1);
    tabWidget->setMaximumSize(QSize(16777215, 16777215));
    tabWidget->setTabPosition(QTabWidget::West);
    tabWidget->setTabShape(QTabWidget::Triangular);
    tabWidget->setElideMode(Qt::ElideNone);

    tab_0 = new QWidget();
    tab_0->setObjectName(QString::fromUtf8("tab_0"));
    QFont font;
    font.setPointSize(14);
    vboxLayout0 = new QVBoxLayout(tab_0);
    vboxLayout0->setSpacing(6);
    vboxLayout0->setMargin(9);
    vboxLayout0->setAlignment(Qt::AlignTop);
    vboxLayout0->setObjectName(QString::fromUtf8("vboxLayout0"));

    pushButton[0] = new QPushButton(tab_0);
    pushButton[0]->setObjectName(QString::fromUtf8("pushButton_0"));
    pushButton[0]->setFont(font);
    pushButton[0]->setText(QApplication::translate("MainWindow", "PMS In Board", 0, QApplication::UnicodeUTF8));
    vboxLayout0->addWidget(pushButton[0]);

    pushButton[1] = new QPushButton(tab_0);
    pushButton[1]->setObjectName(QString::fromUtf8("pushButton_1"));
    pushButton[1]->setFont(font);
    pushButton[1]->setText(QApplication::translate("MainWindow", "PMS Out Board", 0, QApplication::UnicodeUTF8));
    vboxLayout0->addWidget(pushButton[1]);

    QSpacerItem *spacerItem;
    //spacerItem = new QSpacerItem(31, 61, QSizePolicy::Minimum, QSizePolicy::Expanding);
    spacerItem = new QSpacerItem(31, 61, QSizePolicy::Minimum, QSizePolicy::Fixed);
    vboxLayout0->addItem(spacerItem);

	//Add Code.
    archiveList = new QComboBox(tab_0);
    archiveList->setObjectName(QString::fromUtf8("archiveList"));
    vboxLayout0->addWidget(archiveList);

    Start_dateTime = new QDateTimeEdit(tab_0);
    Start_dateTime->setObjectName(QString::fromUtf8("Start_dateTime"));
    Start_dateTime->setDisplayFormat("yyyy/MM/dd hh:mm:ss");
    Start_dateTime->setDateTime(QDateTime(QDate(2012,5,29), QTime(12,0,0)));
    vboxLayout0->addWidget(Start_dateTime);

    End_dateTime = new QDateTimeEdit(tab_0);
    End_dateTime->setObjectName(QString::fromUtf8("End_dateTime"));
    End_dateTime->setDisplayFormat("yyyy/MM/dd hh:mm:ss");
    End_dateTime->setDateTime(QDateTime(QDate(2012,5,29), QTime(13,0,0)));
    vboxLayout0->addWidget(End_dateTime);

    RButton = new QPushButton(tab_0);
    RButton->setObjectName(QString::fromUtf8("RButton"));
    RButton->setText("OK");
	if(RButton!=0) connect(RButton, SIGNAL(clicked()), this, SLOT(getChannelValues()));
    //RButton->setGeometry(QRect(980, 20, 80, 27));
    vboxLayout0->addWidget(RButton);


    currentTimeLabel = new QLabel(tab_0);
    currentTimeLabel->setObjectName(QString::fromUtf8("currentTimeLabel"));
    currentTimeLabel->setText("Current Index Time");
    //currentTimeLabel->setGeometry(QRect(760, 7, 161, 21));
    vboxLayout0->addWidget(currentTimeLabel);

    timeSlider = new QSlider(tab_0);
    timeSlider->setObjectName(QString::fromUtf8("timeSlider"));
    //timeSlider->setGeometry(QRect(760, 24, 201, 16));
    timeSlider->setValue(-1);
    timeSlider->setOrientation(Qt::Horizontal);
	connect(timeSlider, SIGNAL(valueChanged(int)), this, SLOT(readValue(int)));
    vboxLayout0->addWidget(timeSlider);

	//--> Splitter
    splitter = new QSplitter(tab_0);
    splitter->setObjectName(QString::fromUtf8("splitter"));
    splitter->setOrientation(Qt::Horizontal);

    incButtonDouble = new QPushButton(splitter);
    incButtonDouble->setObjectName(QString::fromUtf8("incButtonDouble"));
    QSizePolicy sizePol(QSizePolicy::Fixed, QSizePolicy::Fixed);
    sizePol.setHeightForWidth(incButtonDouble->sizePolicy().hasHeightForWidth());
    incButtonDouble->setSizePolicy(sizePol);
    incButtonDouble->setText("<<");
	connect(incButtonDouble,SIGNAL(clicked()), this, SLOT(decDouble()));
    splitter->addWidget(incButtonDouble);

    incButton = new QPushButton(splitter);
    incButton->setObjectName(QString::fromUtf8("incButton"));
    sizePol.setHeightForWidth(incButton->sizePolicy().hasHeightForWidth());
    incButton->setSizePolicy(sizePol);
    incButton->setText("<");
	connect(incButton,SIGNAL(clicked()), this, SLOT(decrease()));
    splitter->addWidget(incButton);

    decButton = new QPushButton(splitter);
    decButton->setObjectName(QString::fromUtf8("decButton"));
    sizePol.setHeightForWidth(decButton->sizePolicy().hasHeightForWidth());
    decButton->setSizePolicy(sizePol);
    decButton->setText(">");
	connect(decButton,SIGNAL(clicked()), this, SLOT(increase()));
    splitter->addWidget(decButton);

    decButtonDouble = new QPushButton(splitter);
    decButtonDouble->setObjectName(QString::fromUtf8("decButtonDouble"));
    sizePol.setHeightForWidth(decButtonDouble->sizePolicy().hasHeightForWidth());
    decButtonDouble->setSizePolicy(sizePol);
    decButtonDouble->setText(">>");
	connect(decButtonDouble,SIGNAL(clicked()), this, SLOT(incDouble()));
    splitter->addWidget(decButtonDouble);

    vboxLayout0->addWidget(splitter);
	//<-- Splitter

    splitter2 = new QSplitter(tab_0);
    splitter2->setObjectName(QString::fromUtf8("splitter2"));
    splitter2->setOrientation(Qt::Horizontal);

    stopButton = new QPushButton(splitter2);
    stopButton->setObjectName(QString::fromUtf8("stopButton"));
    sizePol.setHeightForWidth(stopButton->sizePolicy().hasHeightForWidth());
    stopButton->setSizePolicy(sizePol);
    stopButton->setText("Stop");
	connect(stopButton,SIGNAL(clicked()), this, SLOT(timerStop()));
    splitter2->addWidget(stopButton);

    startButton = new QPushButton(splitter2);
    startButton->setObjectName(QString::fromUtf8("startButton"));
    sizePol.setHeightForWidth(startButton->sizePolicy().hasHeightForWidth());
    startButton->setSizePolicy(sizePol);
    startButton->setText("Run");
	connect(startButton,SIGNAL(clicked()), this, SLOT(timerRun()));
    splitter2->addWidget(startButton);

    vboxLayout0->addWidget(splitter2);

    tabWidget->addTab(tab_0, QApplication::translate("MainWindow", "PMS Panel", 0, QApplication::UnicodeUTF8));

    menubar = new QMenuBar(this);
    menubar->setObjectName(QString::fromUtf8("menubar"));
    menubar->setGeometry(QRect(0, 0, 1280, 30));
    menu_File = new QMenu(menubar);
    menu_File->setObjectName(QString::fromUtf8("menu_File"));
    menu_Util = new QMenu(menubar);
    menu_Util->setObjectName(QString::fromUtf8("menu_Util"));

	menu_Help = new QMenu(menubar);
	menu_Help->setObjectName(QString::fromUtf8("menu_Help"));
    setMenuBar(menubar);

    QLabel *slabel1 = new QLabel("Set your mouse on the dynamic value to read PVNAME.");
    slabel1->setAlignment(Qt::AlignHCenter);
    slabel1->setMinimumSize(slabel1->sizeHint());
    slabel1->setFrameStyle(QFrame::Panel | QFrame::Plain);

    QFrame *sframe = new QFrame();
    QVBoxLayout *svlayout = new QVBoxLayout(sframe);
    svlayout->setSpacing(1);
    svlayout->setMargin(2);

    statusBar()->addWidget(sframe,1);
    
    toolBar = new QToolBar(this);
    toolBar->setObjectName(QString::fromUtf8("toolBar"));
    QPalette palette;
    QBrush brush(QColor(108, 147, 255, 100));
    brush.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::Active, QPalette::Base, brush);
    palette.setBrush(QPalette::Active, QPalette::AlternateBase, brush);
    QBrush brush1(QColor(44, 51, 91, 100));
    brush1.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::Active, QPalette::Window, brush1);
    QBrush brush2(QColor(108, 147, 255, 100));
    brush2.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::Inactive, QPalette::Base, brush2);
    QBrush brush3(QColor(44, 51, 91, 100));
    brush3.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::Inactive, QPalette::Window, brush3);
    QBrush brush4(QColor(44, 51, 91, 100));
    brush4.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::Disabled, QPalette::Base, brush4);
    QBrush brush5(QColor(44, 51, 91, 100));
    brush5.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::Disabled, QPalette::Window, brush5);
    toolBar->setPalette(palette);
    toolBar->setOrientation(Qt::Horizontal);
    addToolBar(static_cast<Qt::ToolBarArea>(4), toolBar);

    menubar->addAction(menu_File->menuAction());
    menubar->addAction(menu_Util->menuAction());
	menubar->addSeparator();
    menubar->addAction(menu_Help->menuAction());


    menu_File->addAction(action_Exit);

    QSize size(1280, 1024);
    size = size.expandedTo(minimumSizeHint());
    resize(size);
    tabWidget->setCurrentIndex(0);
    QMetaObject::connectSlotsByName(this);

    msgframe = new QFrame(centralwidget);
    msgframe->setObjectName(QString::fromUtf8("msgframe"));
    QSizePolicy sizePolicy4(static_cast<QSizePolicy::Policy>(5), static_cast<QSizePolicy::Policy>(5));
    sizePolicy4.setHorizontalStretch(0);
    sizePolicy4.setVerticalStretch(0);
    msgframe->setGeometry(QRect(19, 820, 1255, 90));
    //msgframe->setSizePolicy(sizePolicy4);
    //msgframe->setGeometry(QRect(18, 880, 1254, 70));
    //msgframe->setMinimumSize(QSize(1164, 90));
    //msgframe->setFrameShape(QFrame::StyledPanel);
    //msgframe->setFrameShadow(QFrame::Raised);

	setCentralWidget(centralwidget);

	QObject::connect(tabWidget, SIGNAL(currentChanged(int)), SLOT(setDefaultIndex(int))); 

	// Set Object Text.
	setWindowTitle(QApplication::translate("MainWindow", "PMS (Plant Monitoring System)", 0, QApplication::UnicodeUTF8));
    action_Exit->setText(QApplication::translate("MainWindow", "e&Xit", 0, QApplication::UnicodeUTF8));
    tabWidget->setTabText(tabWidget->indexOf(tab_0), QApplication::translate("MainWindow", "PMS Data Retrieval", 0, QApplication::UnicodeUTF8));
    menu_File->setTitle(QApplication::translate("MainWindow", "&File", 0, QApplication::UnicodeUTF8));
    menu_Util->setTitle(QApplication::translate("MainWindow", "&Util", 0, QApplication::UnicodeUTF8));
    menu_Help->setTitle(QApplication::translate("MainWindow", "&Help", 0, QApplication::UnicodeUTF8));

} // makeUI
コード例 #2
0
ファイル: loremipsum.cpp プロジェクト: moceap/scribus
LoremManager::LoremManager(ScribusDoc* doc, QWidget* parent) : QDialog( parent )
{
	m_Doc=doc;
	setModal(true);
	setWindowTitle( tr( "Lorem Ipsum" ) );
	setWindowIcon(QIcon(loadIcon ( "AppIcon.png" )));
	LoremManagerLayout = new QGridLayout(this) ;
	LoremManagerLayout->setMargin(10);
	LoremManagerLayout->setSpacing(5);

	layout3 = new QVBoxLayout;
	layout3->setMargin(0);
	layout3->setSpacing(5);

	loremList = new QTreeWidget( this );
	loremList->setRootIsDecorated(true);
	loremList->setColumnCount(1);
	loremList->setHeaderLabel( tr("Select Lorem Ipsum"));
	loremList->header()->setClickable( false );
	loremList->header()->setResizeMode( QHeaderView::ResizeToContents );
	loremList->setSelectionMode(QAbstractItemView::SingleSelection);
	layout3->addWidget( loremList );

	layout2 = new QHBoxLayout;
	layout2->setMargin(0);
	layout2->setSpacing(5);

	paraLabel = new QLabel( this );
	layout2->addWidget( paraLabel );

	paraBox = new QSpinBox( this );
	paraBox->setMinimum( 1 );
	paraBox->setValue(PrefsManager::instance()->appPrefs.miscPrefs.paragraphsLI);
	layout2->addWidget( paraBox );
	randomCheckBox = new QCheckBox(this);
	randomCheckBox->setChecked(true);
	layout2->addWidget( randomCheckBox );
	paraSpacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum );
	layout2->addItem( paraSpacer );
	layout3->addLayout( layout2 );

	layout1 = new QHBoxLayout;
	layout1->setMargin(0);
	layout1->setSpacing(5);
	buttonSpacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum );
	layout1->addItem( buttonSpacer );

	okButton = new QPushButton( this );
	layout1->addWidget( okButton );

	cancelButton = new QPushButton( this );
	layout1->addWidget( cancelButton );
	layout3->addLayout( layout1 );

	LoremManagerLayout->addLayout( layout3, 0, 0 );
	languageChange();

	// reading lorems
	QDir d(getLoremLocation(QString::null), "*.xml");

	QFileInfoList list = d.entryInfoList();
	QListIterator<QFileInfo> it(list);
	QFileInfo fi;
	LanguageManager * langmgr( LanguageManager::instance() );
// 	langmgr->init(false);

	while (it.hasNext())
	{
		fi = it.next();
		if (langmgr->getLangFromAbbrev(fi.baseName(), false).isEmpty())
			continue;
		LoremParser *parser = new LoremParser(fi.fileName());
		if (!parser->correct)
		{
			delete parser;
			continue;
		}
		availableLorems[parser->name] = fi.fileName();
		QTreeWidgetItem *item = new QTreeWidgetItem(loremList);
		if (parser->name=="la")
			item->setText(0, standardloremtext);
		else
			item->setText(0, langmgr->getLangFromAbbrev(parser->name, true));
		QTreeWidgetItem *subItem;
		subItem = new QTreeWidgetItem(item);
		subItem->setText(0, tr("Author:") + " " + parser->author);
		subItem = new QTreeWidgetItem(item);
		subItem->setText(0, tr("Get More:") + " " + parser->url);
		subItem = new QTreeWidgetItem(item);
		subItem->setText(0, tr("XML File:") + " " + fi.fileName());
		delete parser;
	}
	loremList->sortItems(0, Qt::AscendingOrder);
	loremList->setSortingEnabled(false);
	resize( QSize(320, 340).expandedTo(minimumSizeHint()) );
	QList<QTreeWidgetItem *> defItem;
	defItem.clear();
	defItem = loremList->findItems(langmgr->getTransLangFromLang(m_Doc->Language), Qt::MatchExactly);
	if (defItem.count() == 0)
		defItem = loremList->findItems(standardloremtext, Qt::MatchExactly);
	if (defItem.count() != 0)
	{
		loremList->setCurrentItem(defItem[0]);
		defItem[0]->setSelected(true);
	}
	// signals and slots connections
	connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
	connect( cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
	connect( loremList, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(accept()));
	
}
コード例 #3
0
ファイル: MainDialog.cpp プロジェクト: limingzhou/sshproxy
MainDialog::MainDialog(QWidget *parent)
    : QDialog(parent)
    , mHostEdit(new QLineEdit)
    , mPortEdit(new QLineEdit)
    , mUserEdit(new QLineEdit)
    , mPswdEdit(new QLineEdit)
    , mLAddrEdit(new QLineEdit)
    , mLPortEdit(new QLineEdit)
    , mWaitEdit(new QLineEdit)
    , mCtrlBtn(new QPushButton(tr("Start")))
    , mQuitBtn(new QPushButton(tr("Quit")))
    , mLogList(new QListWidget)
    , mInfoIcon(QPixmap(":/icon-info.png"))
    , mWarnIcon(QPixmap(":/icon-warn.png"))
    , mErrorIcon(QPixmap(":/icon-error.png"))
    , mStoppedIcon(QPixmap(":/icon-stopped.png"))
    , mConnectingIcon(QPixmap(":/icon-connecting.png"))
    , mConnectedIcon(QPixmap(":/icon-connected.png"))
    , mSleepingIcon(QPixmap(":/icon-sleeping.png"))
    , mSettings(new QSettings(QSettings::IniFormat, QSettings::UserScope,
                              "glacjay", "sshproxy", this))
    , mIsKeepRunning(false)
    , mProcess(new QProcess(this))
    , mRestartTimer(new QTimer(this))
{
    setWindowTitle(tr("SSH Proxy"));
    setWindowIcon(mConnectedIcon);

    mHostEdit->setText(mSettings->value("ssh/host").toString());
    mPortEdit->setText(mSettings->value("ssh/port", "22").toString());
    mUserEdit->setText(mSettings->value("ssh/user").toString());
    mLAddrEdit->setText(mSettings->value("ssh/laddr", "127.0.0.1").toString());
    mLPortEdit->setText(mSettings->value("ssh/lport", "1077").toString());
    mWaitEdit->setText(mSettings->value("ssh/wait", "10").toString());

    mPortEdit->setValidator(new QIntValidator(1, 65535));
    mPswdEdit->setEchoMode(QLineEdit::Password);
    mLPortEdit->setValidator(new QIntValidator(1, 65535));
    mWaitEdit->setValidator(new QIntValidator);
    mLogList->setWordWrap(true);

    mProcess->setProcessChannelMode(QProcess::MergedChannels);

    QLabel *hostLabel = new QLabel(tr("SSH Host:"));
    hostLabel->setBuddy(mHostEdit);
    QLabel *portLabel = new QLabel(tr("SSH Port:"));
    portLabel->setBuddy(mPortEdit);
    QLabel *userLabel = new QLabel(tr("Username:"******"Password:"******"Listen Addr:"));
    lAddrLabel->setBuddy(mLAddrEdit);
    QLabel *lPortLabel = new QLabel(tr("Listen Port:"));
    lPortLabel->setBuddy(mLPortEdit);
    QLabel *waitLabel = new QLabel(tr("Seconds wait to reconnect:"));
    waitLabel->setBuddy(mWaitEdit);

    QVBoxLayout *inputLayout = new QVBoxLayout;
    inputLayout->addWidget(hostLabel);
    inputLayout->addWidget(mHostEdit);
    inputLayout->addWidget(portLabel);
    inputLayout->addWidget(mPortEdit);
    inputLayout->addWidget(userLabel);
    inputLayout->addWidget(mUserEdit);
    inputLayout->addWidget(pswdLabel);
    inputLayout->addWidget(mPswdEdit);
    inputLayout->addWidget(lAddrLabel);
    inputLayout->addWidget(mLAddrEdit);
    inputLayout->addWidget(lPortLabel);
    inputLayout->addWidget(mLPortEdit);
    inputLayout->addWidget(waitLabel);
    inputLayout->addWidget(mWaitEdit);
    inputLayout->insertStretch(-1);
    inputLayout->addWidget(mCtrlBtn);
    inputLayout->addWidget(mQuitBtn);

    QGroupBox *inputGroup = new QGroupBox(tr("Settings"));
    inputGroup->setLayout(inputLayout);

    QVBoxLayout *logLayout = new QVBoxLayout;
    logLayout->addWidget(mLogList);

    QGroupBox *logGroup = new QGroupBox(tr("Log"));
    logGroup->setLayout(logLayout);

    QSplitter *splitter = new QSplitter(Qt::Horizontal);
    splitter->addWidget(inputGroup);
    splitter->addWidget(logGroup);
    splitter->setStretchFactor(1, 5);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(splitter);

    setLayout(mainLayout);
    resize(1000, 600);

    connect(mCtrlBtn, SIGNAL(clicked(void)), this, SLOT(on_mCtrlBtn_clicked(void)));
    connect(mQuitBtn, SIGNAL(clicked(void)), this, SLOT(onQuit(void)));

    mTray = new QSystemTrayIcon(mStoppedIcon);
    mTray->show();

    setSshStatus(StatStopped);

    connect(mTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            this, SLOT(on_mTray_activated(QSystemTrayIcon::ActivationReason)));

    QAction *toggleAction = new QAction(tr("Toggle Main Dialog"), this);
    connect(toggleAction, SIGNAL(triggered(void)),
            this, SLOT(on_toggleAction_triggered(void)));

    QAction *quitAction = new QAction(tr("Quit"), this);
    connect(quitAction, SIGNAL(triggered(void)),
            this, SLOT(onQuit(void)));

    QMenu *trayMenu = new QMenu;
    trayMenu->addAction(toggleAction);
    trayMenu->addSeparator();
    trayMenu->addAction(quitAction);

    mTray->setContextMenu(trayMenu);

    connect(qApp, SIGNAL(aboutToQuit(void)), this, SLOT(onQuit(void)));

    connect(mProcess, SIGNAL(started(void)), this, SLOT(on_mProcess_started(void)));
    connect(mProcess, SIGNAL(finished(int, QProcess::ExitStatus)),
            this, SLOT(on_mProcess_finished(int, QProcess::ExitStatus)));
    connect(mProcess, SIGNAL(error(QProcess::ProcessError)),
            this, SLOT(on_mProcess_error(QProcess::ProcessError)));
    connect(mProcess, SIGNAL(readyReadStandardOutput(void)),
            this, SLOT(on_mProcess_readyReadStandardOutput(void)));

    connect(mRestartTimer, SIGNAL(timeout(void)), this, SLOT(startRunning(void)));

    if (mHostEdit->text().isEmpty())
        mHostEdit->setFocus();
    else if (mPortEdit->text().isEmpty())
        mPortEdit->setFocus();
    else if (mUserEdit->text().isEmpty())
        mUserEdit->setFocus();
    else if (mPswdEdit->text().isEmpty())
        mPswdEdit->setFocus();
    else if (mLAddrEdit->text().isEmpty())
        mLAddrEdit->setFocus();
    else if (mLPortEdit->text().isEmpty())
        mLPortEdit->setFocus();
    else if (mWaitEdit->text().isEmpty())
        mWaitEdit->setFocus();
}
コード例 #4
0
ファイル: showwidget.cpp プロジェクト: youngjeff/qt
ShowWidget::ShowWidget(QWidget *parent)
    :QWidget(parent)
{
    resize(600,500);
    this->setWindowTitle("Database");
    this->setStyleSheet("background-color: rgb(0, 205, 255)");
    view = new QTableView(this);
    view->setGeometry(0,0,500,500);
    view->setStyleSheet("background-color: white;color:black");
    QVBoxLayout *vbox = new QVBoxLayout;
    QHBoxLayout *hbox = new QHBoxLayout;

    addButton = new QPushButton(this);
    addButton->setText("添加");
    addButton->setStyleSheet("background-color: rgb(15, 125, 254);");
    removeButton = new QPushButton(this);
    removeButton->setText("删除");
    removeButton->setStyleSheet("background-color: rgb(15, 125, 254);");
    changeButton = new QPushButton(this);
    changeButton->setText("修改");
    changeButton->setStyleSheet("background-color: rgb(15, 125, 254);");
    findButton = new QPushButton(this);
    findButton->setText("查找");
    findButton->setStyleSheet("background-color: rgb(15, 125, 254);");
    flushButton = new QPushButton(this);
    flushButton->setText("刷新");
    flushButton->setStyleSheet("background-color: rgb(15, 125, 254);");
    vbox->addWidget(addButton);
    vbox->addWidget(changeButton);
    vbox->addWidget(removeButton);
    vbox->addWidget(findButton);
    vbox->addWidget(flushButton);
    hbox->addWidget(view);
    hbox->addLayout(vbox);
    this->setLayout(hbox);

        model = new QSqlRelationalTableModel;
        model->setTable("student");
        model->setSort(0,Qt::AscendingOrder);
        model->setRelation(4,QSqlRelation("city","id","name"));
        model->setHeaderData(0,Qt::Horizontal,"ID号");
        model->setHeaderData(1, Qt::Horizontal, "姓名");
        model->setHeaderData(2, Qt::Horizontal, "年龄");
        model->setHeaderData(3, Qt::Horizontal, "专业");
        model->setHeaderData(4, Qt::Horizontal, "城市");


        model->select();
//        model->removeColumn(0);
        view->setModel(model);
//        view->setSelectionMode(QAbstractItemView::NoEditTriggers);
        view->setSelectionBehavior(QAbstractItemView::SelectRows);
        QSqlQuery query;
       /*  query.exec("select name from student");
        int num = 0;

       while(query.next())
        {
            num++;
        }
        for(int i =0;i<=3;i++)
        {
            view->setColumnWidth(i,110);
        }
        for(int j = 0;j<num;j++)
        {
            view->setRowHeight(j,60);
        }*/

//        view->setItemDelegate(new QSqlRelationalDelegate(view));
    connect(addButton,&QPushButton::clicked,this,&ShowWidget::addEvent);
    connect(removeButton,&QPushButton::clicked,this,&ShowWidget::removeEvent);
    connect(findButton,&QPushButton::clicked,this,&ShowWidget::findEvent);
    connect(changeButton,&QPushButton::clicked,this,&ShowWidget::changeEvent);
    connect(flushButton,&QPushButton::clicked,this,&ShowWidget::flushEvent);
}
コード例 #5
0
SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) :
    QWidget(0, f), curAlignment(0)
{
    // set reference point, paddings
    int paddingLeft             = 14;
    int paddingTop              = 470;
    int titleVersionVSpace      = 17;
    int titleCopyrightVSpace    = 32;

    float fontFactor            = 1.0;

    // define text to place
    QString titleText       = tr("Owncoin Core");
    QString versionText     = QString(tr("Version %1")).arg(QString::fromStdString(FormatFullVersion()));
    QString copyrightTextBtc   = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers"));
    QString copyrightTextOwncoin   = QChar(0xA9)+QString(" 2014-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Owncoin Core developers"));
    QString titleAddText    = networkStyle->getTitleAddText();

    QString font            = QApplication::font().toString();

    // load the bitmap for writing some text over it
    pixmap     = networkStyle->getSplashImage();

    QPainter pixPaint(&pixmap);
    pixPaint.setPen(QColor(100,100,100));

    // check font size and drawing with
    pixPaint.setFont(QFont(font, 28*fontFactor));
    QFontMetrics fm = pixPaint.fontMetrics();
    int titleTextWidth  = fm.width(titleText);
    if(titleTextWidth > 160) {
        // strange font rendering, Arial probably not found
        fontFactor = 0.75;
    }

    pixPaint.setFont(QFont(font, 28*fontFactor));
    fm = pixPaint.fontMetrics();
    titleTextWidth  = fm.width(titleText);
    pixPaint.drawText(paddingLeft,paddingTop,titleText);

    pixPaint.setFont(QFont(font, 15*fontFactor));
    pixPaint.drawText(paddingLeft,paddingTop+titleVersionVSpace,versionText);

    // draw copyright stuff
    pixPaint.setFont(QFont(font, 10*fontFactor));
    pixPaint.drawText(paddingLeft,paddingTop+titleCopyrightVSpace,copyrightTextBtc);
    pixPaint.drawText(paddingLeft,paddingTop+titleCopyrightVSpace+12,copyrightTextOwncoin);

    // draw additional text if special network
    if(!titleAddText.isEmpty()) {
        QFont boldFont = QFont(font, 10*fontFactor);
        boldFont.setWeight(QFont::Bold);
        pixPaint.setFont(boldFont);
        fm = pixPaint.fontMetrics();
        int titleAddTextWidth  = fm.width(titleAddText);
        pixPaint.drawText(pixmap.width()-titleAddTextWidth-10,pixmap.height()-25,titleAddText);
    }

    pixPaint.end();

    // Set window title
    setWindowTitle(titleText + " " + titleAddText);

    // Resize window and move to center of desktop, disallow resizing
    QRect r(QPoint(), pixmap.size());
    resize(r.size());
    setFixedSize(r.size());
    move(QApplication::desktop()->screenGeometry().center() - r.center());

    subscribeToCoreSignals();
}
コード例 #6
0
 ArbitraryInteger ArbitraryInteger::operator -=(long v){
     cout << "-= long value " << toLong() << " same as ";
     resize(sizeof(long));
     cout << toLong() << endl;
 }
コード例 #7
0
ファイル: NumVec.cpp プロジェクト: IEDB/smmpmbec
void CNumVec::clear()
{
	resize(0);
}
コード例 #8
0
ExtImageProps::ExtImageProps( QWidget* parent, ImageInfoRecord *info, PageItem *item, ScribusView *view )
	: QDialog( parent )
{
	setModal(true);
	setWindowTitle( tr( "Extended Image Properties" ) );
	setWindowIcon(IconManager::instance()->loadIcon("AppIcon.png"));
	ExtImagePropsLayout = new QVBoxLayout( this );
	ExtImagePropsLayout->setMargin(6);
	ExtImagePropsLayout->setSpacing(6);
	m_view  = view;
	m_timer = 0;
	if (info->layerInfo.count() != 0)
	{
		m_timer = new QTimer(this);
		m_timer->setSingleShot(true);
		m_timer->setInterval(350);
	}
	m_item = item;
	currentLayer = 0;
	originalInfo = *info;
	originalImageClip = item->imageClip.copy();
	blendModes.clear();
	blendModes.insert("norm", tr("Normal"));
	blendModes.insert("dark", tr("Darken"));
	blendModes.insert("lite", tr("Lighten"));
	blendModes.insert("hue ", tr("Hue"));
	blendModes.insert("sat ", tr("Saturation"));
	blendModes.insert("colr", tr("Color"));
	blendModes.insert("lum ", tr("Luminosity"));
	blendModes.insert("mul ", tr("Multiply"));
	blendModes.insert("scrn", tr("Screen"));
	blendModes.insert("diss", tr("Dissolve"));
	blendModes.insert("over", tr("Overlay"));
	blendModes.insert("hLit", tr("Hard Light"));
	blendModes.insert("sLit", tr("Soft Light"));
	blendModes.insert("diff", tr("Difference"));
	blendModes.insert("smud", tr("Exclusion"));
	blendModes.insert("div ", tr("Color Dodge"));
	blendModes.insert("idiv", tr("Color Burn"));
	blendModes.insert("plus", tr("Plus"));
	blendModes.insert("dsti", tr("Destination In"));
	blendModes.insert("dsto", tr("Destination Out"));
	blendModesRev.clear();
	blendModesRev.insert( tr("Normal"), "norm");
	blendModesRev.insert( tr("Darken"), "dark");
	blendModesRev.insert( tr("Lighten"), "lite");
	blendModesRev.insert( tr("Hue"), "hue ");
	blendModesRev.insert( tr("Saturation"), "sat ");
	blendModesRev.insert( tr("Color"), "colr");
	blendModesRev.insert( tr("Luminosity"), "lum ");
	blendModesRev.insert( tr("Multiply"), "mul ");
	blendModesRev.insert( tr("Screen"), "scrn");
	blendModesRev.insert( tr("Dissolve"), "diss");
	blendModesRev.insert( tr("Overlay"), "over");
	blendModesRev.insert( tr("Hard Light"), "hLit");
	blendModesRev.insert( tr("Soft Light"), "sLit");
	blendModesRev.insert( tr("Difference"), "diff");
	blendModesRev.insert( tr("Exclusion"), "smud");
	blendModesRev.insert( tr("Color Dodge"), "div ");
	blendModesRev.insert( tr("Color Burn"), "idiv");
	blendModesRev.insert( tr("Plus"), "plus");
	blendModesRev.insert( tr("Destination In"), "dsti");
	blendModesRev.insert( tr("Destination Out"), "dsto");
	propsTab = new QTabWidget( this );
	QPalette palette;
	palette.setColor(backgroundRole(), Qt::white);
	if (info->layerInfo.count() != 0)
	{
		tab = new QWidget( propsTab );
		tabLayout = new QVBoxLayout( tab );
		tabLayout->setMargin(6);
		tabLayout->setSpacing(6);
		layout1 = new QHBoxLayout;
		layout1->setMargin(0);
		layout1->setSpacing(6);
		textLabel1 = new QLabel( tab );
		textLabel1->setText( tr( "Blend Mode:" ) );
		layout1->addWidget( textLabel1 );
		blendMode = new ScComboBox( tab );
		blendMode->clear();
		blendMode->addItem( tr("Normal"));
		blendMode->addItem( tr("Darken"));
		blendMode->addItem( tr("Lighten"));
		blendMode->addItem( tr("Hue"));
		blendMode->addItem( tr("Saturation"));
		blendMode->addItem( tr("Color"));
		blendMode->addItem( tr("Luminosity"));
		blendMode->addItem( tr("Multiply"));
		blendMode->addItem( tr("Screen"));
		blendMode->addItem( tr("Dissolve"));
		blendMode->addItem( tr("Overlay"));
		blendMode->addItem( tr("Hard Light"));
		blendMode->addItem( tr("Soft Light"));
		blendMode->addItem( tr("Difference"));
		blendMode->addItem( tr("Exclusion"));
		blendMode->addItem( tr("Color Dodge"));
		blendMode->addItem( tr("Color Burn"));
		blendMode->addItem( tr("Plus"));
		blendMode->addItem( tr("Destination In"));
		blendMode->addItem( tr("Destination Out"));
		layout1->addWidget( blendMode );
		textLabel2 = new QLabel( tab );
		textLabel2->setText( tr( "Opacity:" ) );
		layout1->addWidget( textLabel2 );
		opacitySpinBox = new ScrSpinBox( tab );
		opacitySpinBox->setMinimum(0);
		opacitySpinBox->setDecimals(0);
		opacitySpinBox->setMaximum(100);
		opacitySpinBox->setSingleStep(10);
		opacitySpinBox->setSuffix( tr(" %"));
		layout1->addWidget( opacitySpinBox );
		tabLayout->addLayout( layout1 );
		layerTable = new QTableWidget(info->layerInfo.count(), 3, tab );
		layerTable->setHorizontalHeaderItem(0, new QTableWidgetItem(IconManager::instance()->loadIcon("16/show-object.png"), ""));
		layerTable->setHorizontalHeaderItem(1, new QTableWidgetItem(""));
		layerTable->setHorizontalHeaderItem(2, new QTableWidgetItem( tr("Name")));
		QHeaderView* headerH = layerTable->horizontalHeader();
		headerH->setStretchLastSection(true);
		headerH->setSectionsClickable(false );
		headerH->setSectionsMovable( false );
		if (info->layerInfo.count() == 1)
		{
			layerTable->setColumnWidth(1, 40);
			layerTable->setColumnWidth(0, 24);
		}
		layerTable->setSortingEnabled(false);
		layerTable->setSelectionBehavior(QTableWidget::SelectRows);
		QHeaderView *Header = layerTable->verticalHeader();
		Header->setSectionsMovable( false );
		Header->setSectionResizeMode(QHeaderView::Fixed);
		Header->hide();
		FlagsSicht.clear();
		int col2Width = 0;
		int col1Width = 0;
		if ((info->isRequest) && (info->RequestProps.contains(0)))
		{
			opacitySpinBox->setValue(qRound(info->RequestProps[0].opacity / 255.0 * 100));
			setCurrentComboItem(blendMode, blendModes[info->RequestProps[0].blend]);
		}
		else
		{
			opacitySpinBox->setValue(qRound(info->layerInfo[0].opacity / 255.0 * 100));
			setCurrentComboItem(blendMode, blendModes[info->layerInfo[0].blend]);
		}
		opacitySpinBox->setEnabled(true);
		blendMode->setEnabled(true);
		QString tmp;
		QList<PSDLayer>::iterator it2;
		uint counter = 0;
		for (it2 = info->layerInfo.begin(); it2 != info->layerInfo.end(); ++it2)
		{
			QCheckBox *cp = new QCheckBox(it2->layerName, this);
			cp->setPalette(palette);
			QPixmap pm;
			pm=QPixmap::fromImage(it2->thumb);
			col1Width = qMax(col1Width, pm.width());
			cp->setIcon(pm);
			FlagsSicht.append(cp);
			connect(cp, SIGNAL(clicked()), this, SLOT(changedLayer()));
			layerTable->setCellWidget(info->layerInfo.count()-counter-1, 0, cp);
			if ((info->isRequest) && (info->RequestProps.contains(counter)))
				cp->setChecked(info->RequestProps[counter].visible);
			else
				cp->setChecked(!(it2->flags & 2));
			if (!it2->thumb_mask.isNull())
			{
				QCheckBox *cp2 = new QCheckBox(it2->layerName, this);
				cp2->setPalette(palette);
				QPixmap pm2;
				pm2=QPixmap::fromImage(it2->thumb_mask);
				col2Width = qMax(col2Width, pm2.width());
				cp2->setIcon(pm2);
				connect(cp2, SIGNAL(clicked()), this, SLOT(changedLayer()));
				layerTable->setCellWidget(info->layerInfo.count()-counter-1, 1, cp2);
				if ((info->isRequest) && (info->RequestProps.contains(counter)))
					cp2->setChecked(info->RequestProps[counter].useMask);
				else
					cp2->setChecked(true);
				FlagsMask.append(cp2);
			}
			else
				FlagsMask.append(0);
			QTableWidgetItem *tW = new QTableWidgetItem(it2->layerName);
			tW->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
			layerTable->setItem(info->layerInfo.count()-counter-1, 2, tW);
			layerTable->setRowHeight(info->layerInfo.count()-counter-1, 40);
			counter++;
		}
		tabLayout->addWidget( layerTable );
		layerTable->setColumnWidth(1, 24 + col2Width);
		layerTable->setColumnWidth(0, 24 + col1Width);
		blendMode->setCurrentIndex(0);
// 		headerH->setResizeMode(QHeaderView::Fixed);
		propsTab->addTab( tab,  tr( "Layers" ) );
	}
	tab_2 = new QWidget( propsTab );
	tabLayout_2 = new QVBoxLayout( tab_2 );
	tabLayout_2->setMargin(6);
	tabLayout_2->setSpacing(6);
	pathList = new QListWidget( tab_2 );
	pathList->clear();
	pathList->setIconSize(QSize(40, 40));
	QMap<QString, FPointArray>::Iterator it;
	if (info->PDSpathData.count() != 0)
	{
		for (it = info->PDSpathData.begin(); it != info->PDSpathData.end(); ++it)
		{
			QImage pixm(40, 40, QImage::Format_ARGB32_Premultiplied);
			ScPainter *p = new ScPainter(&pixm, 40, 40);
			p->clear();
			p->translate(3.0, 3.0);
			if (it.key() == info->clipPath)
			{
				pixm.fill(Qt::green);
				p->clear(Qt::green);
			}
			else
				pixm.fill(Qt::white);
			FPointArray Path;
			Path.resize(0);
			Path = info->PDSpathData[it.key()].copy();
			FPoint min = getMinClipF(&Path);
			Path.translate(-min.x(), -min.y());
			FPoint max = Path.WidthHeight();
			QTransform mm;
			mm.scale(34.0 / qMax(max.x(), max.y()), 34.0 / qMax(max.x(), max.y()));
			Path.map(mm);
			p->setupPolygon(&Path);
			p->setPen(Qt::black, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
			p->setBrush(Qt::white);
			p->setFillMode(ScPainter::None);
			p->setStrokeMode(ScPainter::Solid);
			p->strokePath();
			p->end();
			delete p;
			QPixmap pm;
			pm=QPixmap::fromImage(pixm);
			new QListWidgetItem(QIcon(pm), it.key(), pathList);
			if (it.key() == info->usedPath)
			{
				pathList->setCurrentRow(pathList->count()-1);
				pathList->currentItem()->setSelected(true);
			}
		}
	}
	tabLayout_2->addWidget( pathList );
	resetPath = new QPushButton( tr("Don't use any Path"), tab_2);
	tabLayout_2->addWidget( resetPath );
	propsTab->addTab( tab_2, tr( "Paths" ) );
	ExtImagePropsLayout->addWidget( propsTab );

	layoutBottom = new QHBoxLayout;
	layoutBottom->setMargin(0);
	layoutBottom->setSpacing(6);
	livePreview = new QCheckBox( this );
	livePreview->setText( tr( "Live Preview" ) );
	livePreview->setChecked(true);
	doPreview = true;
	layoutBottom->addWidget( livePreview );
	QSpacerItem* spacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum );
	layoutBottom->addItem( spacer );
	okButton = new QPushButton( CommonStrings::tr_OK, this );
	layoutBottom->addWidget( okButton );
	cancelButton = new QPushButton( CommonStrings::tr_Cancel, this );
	cancelButton->setDefault( true );
	layoutBottom->addWidget( cancelButton );
	ExtImagePropsLayout->addLayout( layoutBottom );
	resize(330, 320);

	connect(pathList, SIGNAL( itemClicked(QListWidgetItem*) ), this, SLOT( selPath(QListWidgetItem*) ) );
	connect(resetPath, SIGNAL(clicked()), this, SLOT(noPath()));
	connect(livePreview, SIGNAL(clicked()), this, SLOT(changePreview()));
	connect(okButton, SIGNAL(clicked()), this, SLOT(leaveOK()));
	connect(cancelButton, SIGNAL(clicked()), this, SLOT(leaveCancel()));
	if (info->layerInfo.count() != 0)
	{
		layerTable->selectionModel()->clearSelection();
		opacitySpinBox->setEnabled(false);
		blendMode->setEnabled(false);
		connect(m_timer, SIGNAL(timeout()), this,  SLOT(changedLayer()));
		connect(layerTable, SIGNAL(itemSelectionChanged()), this, SLOT(selLayer()));
		connect(opacitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(delayedLayerChange()));
		connect(blendMode, SIGNAL(activated(int)), this, SLOT(changedLayer()));
	}
コード例 #9
0
ファイル: gpuPictoString.cpp プロジェクト: hiroMTB/picto
void gpuPictoString::setup(){
    particleSize = 30.0f;
    timeStep = 0.0167f;
    numParticles = 512*512;
    
    offset.set(0.5, 0.5);
    offsetVel.set(0, 0);
    
    updatePos.load("", "shaders/posUpdate.frag");
    updateVel.load("", "shaders/velUpdate.frag");
    
    updateRender.setGeometryInputType(GL_POINTS);
    updateRender.setGeometryOutputType(GL_TRIANGLE_STRIP);
    updateRender.setGeometryOutputCount(6);
    updateRender.load("shaders/render.vert", "shaders/render.frag", "shaders/render.geom");
    
    textureRes = (int)sqrt((float)numParticles);
    numParticles = textureRes*textureRes;
    printf("Particle Num Limited under %i\n", numParticles);
    
    
    
    finalTargetTex.allocate(textureRes, textureRes, GL_RGB32F);
    iconPrmTex.allocate(textureRes, textureRes, GL_RGBA32F);
    springPrmTex.allocate(textureRes, textureRes, GL_RGBA32F);
    randomTex.allocate(textureRes, textureRes, GL_RGB32F);
    
    
    // target
    finalTargetPosData = new float[numParticles*3];
    
    // random
    randomData = new float[numParticles*3];
    for (int x = 0; x < textureRes; x++){
        for (int y = 0; y < textureRes; y++){
            int i = textureRes * y + x;
            
            randomData[i*3 + 0] = ofRandom(1.0);
            randomData[i*3 + 1] = ofRandom(1.0);
            randomData[i*3 + 2] = ofRandom(1.0);
//            randomData[i*4 + 3] = ofRandom(1.0);
        }
    }
    randomTex.setTextureMinMagFilter(GL_NEAREST, GL_NEAREST);
    randomTex.loadData(randomData, textureRes, textureRes, GL_RGB);
    
    
    
    // icon
    iconPrmData = new float[numParticles*4];
    for (int x = 0; x < textureRes; x++){
        for (int y = 0; y < textureRes; y++){
            int i = textureRes * y + x;
            
            iconPrmData[i*4 + 0] = -0.5;  // colorType
            iconPrmData[i*4 + 1] = -0.5;  // iconType
            iconPrmData[i*4 + 2] = 0.0;
            iconPrmData[i*4 + 3] = 0.0;
        }
    }
    iconPrmTex.setTextureMinMagFilter(GL_NEAREST, GL_NEAREST);
    iconPrmTex.loadData(iconPrmData, textureRes, textureRes, GL_RGBA);

    
    
    //spring
    springPrmData = new float[numParticles*4];
    for (int x = 0; x < textureRes; x++){
        for (int y = 0; y < textureRes; y++){
            int i = textureRes * y + x;
            
            springPrmData[i*4 + 0] = ofRandom(0.06, 0.12); // K
            springPrmData[i*4 + 1] = ofRandom(0.2, 0.35); // topSpeed
            springPrmData[i*4 + 2] = ofRandom(0.001, 0.03); // minSpeed;
            springPrmData[i*4 + 3] = 1.0;           // attractOn
            
            if(ofRandom(0, 100)>99){
                springPrmData[i*4 + 2] = ofRandom(0.15, 0.2);
            }
        }
    }
    springPrmTex.setTextureMinMagFilter(GL_NEAREST, GL_NEAREST);
    springPrmTex.loadData(springPrmData, textureRes, textureRes, GL_RGBA);

    
    
    // pos
    posData = new float[numParticles*3];
    for (int x = 0; x < textureRes; x++){
        for (int y = 0; y < textureRes; y++){
            int i = textureRes * y + x;
            
            posData[i*3 + 0] = 0.0; //x;
            posData[i*3 + 1] = 0.0; //y;
            posData[i*3 + 2] = 0.0;
        }
    }
    
    
    posPingPong.allocate(textureRes, textureRes, GL_RGB32F);
    posPingPong.src->getTextureReference().loadData(posData, textureRes, textureRes, GL_RGB);
    posPingPong.dst->getTextureReference().loadData(posData, textureRes, textureRes, GL_RGB);
    
    
    // vel
    velData = new float[numParticles*4];
    for (int i = 0; i < numParticles; i++){
        velData[i*4 + 0] = 0;
        velData[i*4 + 1] = 0;
        velData[i*4 + 2] = 0; //a
        velData[i*4 + 3] = 0; //a
        
    }
    velPingPong.allocate(textureRes, textureRes,GL_RGBA32F);
    velPingPong.src->getTextureReference().loadData(velData, textureRes, textureRes, GL_RGBA);
    velPingPong.dst->getTextureReference().loadData(velData, textureRes, textureRes, GL_RGBA);
    
    
    int w = ofGetWindowWidth();
    int h = ofGetWindowHeight();
    renderFBO.allocate(w, h, GL_RGB32F);
    renderFBO.getTextureReference().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST);
    // renderFBO.getTextureReference().setTextureMinMagFilter(GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_NEAREST);

    renderFBO.begin();
    ofClear(0,0,0,0);
    renderFBO.end();
    

    //img128.getTextureReference().setTextureMinMagFilter(GL_LINEAR, GL_LINEAR);                                // flickering
    //img128.getTextureReference().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST);                              // sliced
    //img128.getTextureReference().setTextureMinMagFilter(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR);    // not so good
    //img128.getTextureReference().setTextureMinMagFilter(GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST);
    //img128.getTextureReference().setTextureMinMagFilter(GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_NEAREST);
    //img128.getTextureReference().setTextureMinMagFilter(GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR);
    
    
//    img1.getTextureReference().setTextureMinMagFilter(GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR);
//    img2.getTextureReference().setTextureMinMagFilter(GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR);
//    img4.getTextureReference().setTextureMinMagFilter(GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR);
//    img8.getTextureReference().setTextureMinMagFilter(GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR);
//    img16.getTextureReference().setTextureMinMagFilter(GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR);
//    img32.getTextureReference().setTextureMinMagFilter(GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR);
//    img64.getTextureReference().setTextureMinMagFilter(GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR);
//    img128.getTextureReference().setTextureMinMagFilter(GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST_MIPMAP_LINEAR);
    
//    texadv.allocate(testApp::getW(), testApp::getH(), GL_RGB);
    //texId = renderFBO.getTextureReference().getTextureData().textureID;
    resize(testApp::getW(), testApp::getH());
}
コード例 #10
0
 Foo() : QDialog(0, "foo", true) { resize(200,200); new QLabel("Hello World", this); show(); }
コード例 #11
0
AddJobDialog::AddJobDialog(QWidget *parent, OptionsModel *const options, RecentlyUsed *const recentlyUsed, const SysinfoModel *const sysinfo, const PreferencesModel *const preferences)
:
	QDialog(parent),
	m_options(options),
	m_recentlyUsed(recentlyUsed),
	m_sysinfo(sysinfo),
	m_preferences(preferences),
	m_defaults(new OptionsModel(sysinfo)),
	ui(new Ui::AddJobDialog()),
	m_monitorConfigChanges(true)
{
	//Init the dialog, from the .ui file
	ui->setupUi(this);
	setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));

	//Fix dialog size
	ui->buttonSaveTemplate->setMaximumHeight(20);
	ui->buttonDeleteTemplate->setMaximumHeight(20);
	resize(width(), minimumHeight());
	setMinimumSize(size());
	setMaximumHeight(height());

	//Init combobox items
	ui->cbxTuning ->addItem(QString::fromLatin1(OptionsModel::TUNING_UNSPECIFIED));
	ui->cbxProfile->addItem(QString::fromLatin1(OptionsModel::PROFILE_UNRESTRICTED));

	//Hide optional controls
	ui->checkBoxApplyToAll->setVisible(false);

	//Monitor combobox changes
	connect(ui->cbxEncoderType,     SIGNAL(currentIndexChanged(int)), this, SLOT(encoderIndexChanged(int)));
	connect(ui->cbxEncoderVariant,  SIGNAL(currentIndexChanged(int)), this, SLOT(variantIndexChanged(int)));
	connect(ui->cbxRateControlMode, SIGNAL(currentIndexChanged(int)), this, SLOT(modeIndexChanged(int)));

	//Activate buttons
	connect(ui->buttonBrowseSource,   SIGNAL(clicked()), this, SLOT(browseButtonClicked()));
	connect(ui->buttonBrowseOutput,   SIGNAL(clicked()), this, SLOT(browseButtonClicked()));
	connect(ui->buttonSaveTemplate,   SIGNAL(clicked()), this, SLOT(saveTemplateButtonClicked()));
	connect(ui->buttonDeleteTemplate, SIGNAL(clicked()), this, SLOT(deleteTemplateButtonClicked()));

	//Setup validator
	ui->editCustomX264Params->installEventFilter(this);
	ui->editCustomX264Params->setValidator(new StringValidatorX264(ui->labelNotificationX264, ui->iconNotificationX264));
	ui->editCustomX264Params->clear();
	ui->editCustomAvs2YUVParams->installEventFilter(this);
	ui->editCustomAvs2YUVParams->setValidator(new StringValidatorAvs2YUV(ui->labelNotificationAvs2YUV, ui->iconNotificationAvs2YUV));
	ui->editCustomAvs2YUVParams->clear();

	//Install event filter
	ui->labelHelpScreenX264->installEventFilter(this);
	ui->labelHelpScreenAvs2YUV->installEventFilter(this);

	//Monitor for options changes
	connect(ui->cbxEncoderType, SIGNAL(currentIndexChanged(int)), this, SLOT(configurationChanged()));
	connect(ui->cbxEncoderArch, SIGNAL(currentIndexChanged(int)), this, SLOT(configurationChanged()));
	connect(ui->cbxEncoderVariant, SIGNAL(currentIndexChanged(int)), this, SLOT(configurationChanged()));
	connect(ui->cbxRateControlMode, SIGNAL(currentIndexChanged(int)), this, SLOT(configurationChanged()));
	connect(ui->spinQuantizer, SIGNAL(valueChanged(double)), this, SLOT(configurationChanged()));
	connect(ui->spinBitrate, SIGNAL(valueChanged(int)), this, SLOT(configurationChanged()));
	connect(ui->cbxPreset, SIGNAL(currentIndexChanged(int)), this, SLOT(configurationChanged()));
	connect(ui->cbxTuning, SIGNAL(currentIndexChanged(int)), this, SLOT(configurationChanged()));
	connect(ui->cbxProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(configurationChanged()));
	connect(ui->editCustomX264Params, SIGNAL(textChanged(QString)), this, SLOT(configurationChanged()));
	connect(ui->editCustomAvs2YUVParams, SIGNAL(textChanged(QString)), this, SLOT(configurationChanged()));

	//Create context menus
	ADD_CONTEXTMENU_ACTION(ui->editCustomX264Params, QIcon(":/buttons/page_edit.png"), tr("Open the Text-Editor"), editorActionTriggered);
	ADD_CONTEXTMENU_ACTION(ui->editCustomAvs2YUVParams, QIcon(":/buttons/page_edit.png"), tr("Open the Text-Editor"), editorActionTriggered);
	ADD_CONTEXTMENU_SEPARATOR(ui->editCustomX264Params);
	ADD_CONTEXTMENU_SEPARATOR(ui->editCustomAvs2YUVParams);
	ADD_CONTEXTMENU_ACTION(ui->editCustomX264Params, QIcon(":/buttons/page_copy.png"), tr("Copy to Clipboard"), copyActionTriggered);
	ADD_CONTEXTMENU_ACTION(ui->editCustomAvs2YUVParams, QIcon(":/buttons/page_copy.png"), tr("Copy to Clipboard"), copyActionTriggered);
	ADD_CONTEXTMENU_ACTION(ui->editCustomX264Params, QIcon(":/buttons/page_paste.png"), tr("Paste from Clipboard"), pasteActionTriggered);
	ADD_CONTEXTMENU_ACTION(ui->editCustomAvs2YUVParams, QIcon(":/buttons/page_paste.png"), tr("Paste from Clipboard"), pasteActionTriggered);

	//Setup template selector
	loadTemplateList();
	connect(ui->cbxTemplate, SIGNAL(currentIndexChanged(int)), this, SLOT(templateSelected()));
}
コード例 #12
0
ファイル: widget.cpp プロジェクト: ReDetection/qTox
void Widget::resizeWindow(QMouseEvent *e)
{
    if (!Settings::getInstance().getUseNativeDecoration())
    {
        if (allowToResize)
        {
            int xMouse = e->pos().x();
            int yMouse = e->pos().y();
            int wWidth = geometry().width();
            int wHeight = geometry().height();

            if (cursor().shape() == Qt::SizeVerCursor)
            {
                if (resizeVerSup)
                {
                    int newY = geometry().y() + yMouse;
                    int newHeight = wHeight - yMouse;

                    if (newHeight > minimumSizeHint().height())
                    {
                        resize(wWidth, newHeight);
                        move(geometry().x(), newY);
                    }
                }
                else
                    resize(wWidth, yMouse+1);
            }
            else if (cursor().shape() == Qt::SizeHorCursor)
            {
                if (resizeHorEsq)
                {
                    int newX = geometry().x() + xMouse;
                    int newWidth = wWidth - xMouse;

                    if (newWidth > minimumSizeHint().width())
                    {
                        resize(newWidth, wHeight);
                        move(newX, geometry().y());
                    }
                }
                else
                    resize(xMouse, wHeight);
            }
            else if (cursor().shape() == Qt::SizeBDiagCursor)
            {
                int newX = 0;
                int newWidth = 0;
                int newY = 0;
                int newHeight = 0;

                if (resizeDiagSupDer)
                {
                    newX = geometry().x();
                    newWidth = xMouse;
                    newY = geometry().y() + yMouse;
                    newHeight = wHeight - yMouse;
                }
                else
                {
                    newX = geometry().x() + xMouse;
                    newWidth = wWidth - xMouse;
                    newY = geometry().y();
                    newHeight = yMouse;
                }

                if (newWidth >= minimumSizeHint().width() and newHeight >= minimumSizeHint().height())
                {
                    resize(newWidth, newHeight);
                    move(newX, newY);
                }
                else if (newWidth >= minimumSizeHint().width())
                {
                    resize(newWidth, wHeight);
                    move(newX, geometry().y());
                }
                else if (newHeight >= minimumSizeHint().height())
                {
                    resize(wWidth, newHeight);
                    move(geometry().x(), newY);
                }
            }
            else if (cursor().shape() == Qt::SizeFDiagCursor)
            {
                if (resizeDiagSupEsq)
                {
                    int newX = geometry().x() + xMouse;
                    int newWidth = wWidth - xMouse;
                    int newY = geometry().y() + yMouse;
                    int newHeight = wHeight - yMouse;

                    if (newWidth >= minimumSizeHint().width() and newHeight >= minimumSizeHint().height())
                    {
                        resize(newWidth, newHeight);
                        move(newX, newY);
                    }
                    else if (newWidth >= minimumSizeHint().width())
                    {
                        resize(newWidth, wHeight);
                        move(newX, geometry().y());
                    }
                    else if (newHeight >= minimumSizeHint().height())
                    {
                        resize(wWidth, newHeight);
                        move(geometry().x(), newY);
                    }
                }
                else
                    resize(xMouse+1, yMouse+1);
            }

            e->accept();
        }
    }
}
コード例 #13
0
GraphicsInterface::DataBufferObject DataBufferManager::getAllocationBufferObject(AllocationObject allocationObject,
                                                                                 uintptr_t& offset)
{
    if (!allocationObject)
        return nullptr;

    auto allocation = reinterpret_cast<const Allocation*>(allocationObject);

    if (allocation->isDynamic)
    {
        // For dynamic allocations simply return its data buffer with no offset
        offset = 0;
        return allocation->buffer;
    }

    auto group = allocation->group;

    // Return the offset to this allocation from the start of the data buffer
    offset = allocation->allocation->firstBlock * group->blockSize;

    // Dirty static data groups need to be reuploaded to the graphics interface
    if (group->isDirty)
    {
        // No longer dirty
        group->isDirty = false;

        // Create data buffer if needed
        if (!group->buffer)
        {
            group->buffer = graphics().createDataBuffer();
            if (!group->buffer)
            {
                LOG_ERROR << "Failed creating static data buffer";
                return nullptr;
            }
        }

        // Allocate a buffer to ready to receive the contents of this static data group
        auto uploadBuffer = Vector<byte_t>();
        try
        {
            uploadBuffer.resize(group->getActiveBlockCount() * group->blockSize);
        }
        catch (const std::bad_alloc&)
        {
            LOG_ERROR << "Failed allocating memory for the upload buffer";
            return nullptr;
        }

        // Fill the upload buffer
        for (auto i = 0U; i < group->allocations.size(); i++)
        {
            auto a = group->allocations[i];
            memcpy(&uploadBuffer[a->firstBlock * group->blockSize], a->data, a->dataSize);
        }

        // Upload to the graphics interface
        auto timer = SimpleTimer();
        graphics().uploadStaticDataBuffer(group->buffer, allocation->type, uploadBuffer.size(), uploadBuffer.getData());

        LOG_INFO << "Updated static " << (allocation->type == GraphicsInterface::VertexDataBuffer ? "vertex" : "index")
                 << " data group " << group << ", size: " << FileSystem::formatByteSize(uploadBuffer.size())
                 << ", time: " << timer;
    }

    return group->buffer;
}
コード例 #14
0
ファイル: htmleditor.cpp プロジェクト: GDXN/shotcut
void HtmlEditor::resizeWebView(int w, int h)
{
    int widthDelta = width() - ui->webView->width();
    int heightDelta = height() - ui->webView->height();
    resize(w + widthDelta, h + heightDelta);
}
コード例 #15
0
ファイル: glearray.cpp プロジェクト: pnkfelix/glx-gle
void GLEBoolArray::setBoolAt(bool v, int i) {
	resize(i);
	m_Elems[i] = v;
}
コード例 #16
0
ファイル: wrapper.hpp プロジェクト: gnaghi/bass
string& string::strip() {
  nall::strip(data());
  resize(length());
  return *this;
}
コード例 #17
0
void MainDialog::updateSize()
{
	resize( sizeHint() );
}
コード例 #18
0
ファイル: wrapper.hpp プロジェクト: gnaghi/bass
string& string::removespace() {
  nall::removespace(data());
  resize(length());
  return *this;
}
コード例 #19
0
void QBlittablePlatformPixmap::setBlittable(QBlittable *blittable)
{
    resize(blittable->size().width(),blittable->size().height());
    m_blittable.reset(blittable);
}
コード例 #20
0
ファイル: newgroupbox.cpp プロジェクト: 2k13yr/tdesktop
void NewGroupInner::updateFilter(QString filter) {
	QStringList f;
	if (!filter.isEmpty()) {
		QStringList filterList = filter.split(cWordSplit(), QString::SkipEmptyParts);
		int l = filterList.size();

		f.reserve(l);
		for (int i = 0; i < l; ++i) {
			QString filterName = filterList[i].trimmed();
			if (filterName.isEmpty()) continue;
			f.push_back(filterName);
		}
		filter = f.join(' ');
	}
	if (_filter != filter) {
		int32 rh = (st::profileListPhotoSize + st::profileListPadding.height() * 2);
		_filter = filter;
		if (_filter.isEmpty()) {
			resize(width(), _contacts->list.count * rh);
			if (_contacts->list.count) {
				_sel = _contacts->list.begin;
			}
		} else {
			QStringList::const_iterator fb = f.cbegin(), fe = f.cend(), fi;

			_filtered.clear();
			if (!f.isEmpty()) {
				DialogsList *dialogsToFilter = 0;
				if (_contacts->list.count) {
					for (fi = fb; fi != fe; ++fi) {
						DialogsIndexed::DialogsIndex::iterator i = _contacts->index.find(fi->at(0));
						if (i == _contacts->index.cend()) {
							dialogsToFilter = 0;
							break;
						}
						if (!dialogsToFilter || dialogsToFilter->count > i.value()->count) {
							dialogsToFilter = i.value();
						}
					}
				}
				if (dialogsToFilter && dialogsToFilter->count) {
					_filtered.reserve(dialogsToFilter->count);
					for (DialogRow *i = dialogsToFilter->begin, *e = dialogsToFilter->end; i != e; i = i->next) {
						const PeerData::Names &names(i->history->peer->names);
						PeerData::Names::const_iterator nb = names.cbegin(), ne = names.cend(), ni;
						for (fi = fb; fi != fe; ++fi) {
							QString filterName(*fi);
							for (ni = nb; ni != ne; ++ni) {
								if (ni->startsWith(*fi)) {
									break;
								}
							}
							if (ni == ne) {
								break;
							}
						}
						if (fi == fe) {
							i->attached = 0;
							_filtered.push_back(i);
						}
					}
				}
			}
			_filteredSel = _filtered.isEmpty() ? -1 : 0;

			resize(width(), _filtered.size() * rh);
		}
		if (parentWidget()) parentWidget()->update();
		loadProfilePhotos(0);
	}
}
コード例 #21
0
ファイル: NumVec.cpp プロジェクト: IEDB/smmpmbec
void CNumVec::SetTo(const DoubleVec &v)
{
	resize(v.size());
	for(unsigned i=0; i<v.size(); i++)
		gsl_vector_set(m_vec,i,v[i]);
}
コード例 #22
0
ファイル: spicedialog.cpp プロジェクト: ClemensFMN/qucs
SpiceDialog::SpiceDialog(SpiceFile *c, Schematic *d)
			: QDialog(d, 0, TRUE, Qt::WDestructiveClose)
{
  resize(400, 250);
  setCaption(tr("Edit SPICE Component Properties"));
  Comp = c;
  Doc  = d;

  all = new Q3VBoxLayout(this); // to provide neccessary size
  QWidget *myParent = this;

  Expr.setPattern("[^\"=]+");  // valid expression for property 'edit' etc
  Validator = new QRegExpValidator(Expr, this);
  Expr.setPattern("[\\w_]+");  // valid expression for property 'NameEdit' etc
  ValRestrict = new QRegExpValidator(Expr, this);


  // ...........................................................
  Q3GridLayout *topGrid = new Q3GridLayout(0, 4,3,3,3);
  all->addLayout(topGrid);

  topGrid->addWidget(new QLabel(tr("Name:"), myParent), 0,0);
  CompNameEdit = new QLineEdit(myParent);
  CompNameEdit->setValidator(ValRestrict);
  topGrid->addWidget(CompNameEdit, 0,1);
  connect(CompNameEdit, SIGNAL(returnPressed()), SLOT(slotButtOK()));

  topGrid->addWidget(new QLabel(tr("File:"), myParent), 1,0);
  FileEdit = new QLineEdit(myParent);
  FileEdit->setValidator(ValRestrict);
  topGrid->addWidget(FileEdit, 1,1);
  connect(FileEdit, SIGNAL(returnPressed()), SLOT(slotButtOK()));

  ButtBrowse = new QPushButton(tr("Browse"), myParent);
  topGrid->addWidget(ButtBrowse, 1,2);
  connect(ButtBrowse, SIGNAL(clicked()), SLOT(slotButtBrowse()));

  ButtEdit = new QPushButton(tr("Edit"), myParent);
  topGrid->addWidget(ButtEdit, 2,2);
  connect(ButtEdit, SIGNAL(clicked()), SLOT(slotButtEdit()));

  FileCheck = new QCheckBox(tr("show file name in schematic"), myParent);
  topGrid->addWidget(FileCheck, 2,1);

  SimCheck = new QCheckBox(tr("include SPICE simulations"), myParent);
  topGrid->addWidget(SimCheck, 3,1);

  Q3HBox *h1 = new Q3HBox(myParent);
  h1->setSpacing(5);
  PrepCombo = new QComboBox(h1);
  PrepCombo->insertItem("none");
  PrepCombo->insertItem("ps2sp");
  PrepCombo->insertItem("spicepp");
  PrepCombo->insertItem("spiceprm");
  QLabel * PrepLabel = new QLabel(tr("preprocessor"), h1);
  PrepLabel->setMargin(5);
  topGrid->addWidget(h1, 4,1);
  connect(PrepCombo, SIGNAL(activated(int)), SLOT(slotPrepChanged(int)));

  // ...........................................................
  Q3GridLayout *midGrid = new Q3GridLayout(0, 2,3,5,5);
  all->addLayout(midGrid);

  midGrid->addWidget(new QLabel(tr("SPICE net nodes:"), myParent), 0,0);
  NodesList = new Q3ListBox(myParent);
  midGrid->addWidget(NodesList, 1,0);
  connect(NodesList, SIGNAL(doubleClicked(Q3ListBoxItem*)),
	SLOT(slotAddPort(Q3ListBoxItem*)));
  
  Q3VBox *v0 = new Q3VBox(myParent);
  v0->setSpacing(5);
  midGrid->addWidget(v0, 1,1);
  ButtAdd = new QPushButton(tr("Add >>"), v0);
  connect(ButtAdd, SIGNAL(clicked()), SLOT(slotButtAdd()));
  ButtRemove = new QPushButton(tr("<< Remove"), v0);
  connect(ButtRemove, SIGNAL(clicked()), SLOT(slotButtRemove()));
  v0->setStretchFactor(new QWidget(v0), 5); // stretchable placeholder

  midGrid->addWidget(new QLabel(tr("Component ports:"), myParent), 0,2);
  PortsList = new Q3ListBox(myParent);
  midGrid->addWidget(PortsList, 1,2);
  connect(PortsList, SIGNAL(doubleClicked(Q3ListBoxItem*)),
	SLOT(slotRemovePort(Q3ListBoxItem*)));
  

  // ...........................................................
  Q3HBox *h0 = new Q3HBox(this);
  h0->setSpacing(5);
  all->addWidget(h0);
  connect(new QPushButton(tr("OK"),h0), SIGNAL(clicked()),
	  SLOT(slotButtOK()));
  connect(new QPushButton(tr("Apply"),h0), SIGNAL(clicked()),
	  SLOT(slotButtApply()));
  connect(new QPushButton(tr("Cancel"),h0), SIGNAL(clicked()),
	  SLOT(slotButtCancel()));

  // ------------------------------------------------------------
  CompNameEdit->setText(Comp->Name);
  changed = false;

  // insert all properties into the ListBox
  Property *pp = Comp->Props.first();
  FileEdit->setText(pp->Value);
  FileCheck->setChecked(pp->display);
  SimCheck->setChecked(Comp->Props.at(2)->Value == "yes");
  for(int i=0; i<PrepCombo->count(); i++) {
    if(PrepCombo->text(i) == Comp->Props.at(3)->Value) {
      PrepCombo->setCurrentItem(i);
      currentPrep = i;
      break;
    }
  }

  loadSpiceNetList(pp->Value);  // load netlist nodes
}
コード例 #23
0
ファイル: GLDriver_GLX.cpp プロジェクト: martydill/Fizz3D
// Initialize our rendering device
int GLDriver::initialize(IWindow* pWindow)
{
    Assert(pWindow != NULL);
    Trace("Initializing OpenGL");

    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
    glClearDepth(1.0f);
    glEnable(GL_DEPTH_TEST);
    glClearColor(0.0,0.0,0.0,0.0);
    glDepthFunc(GL_LEQUAL);
    glEnable(GL_TEXTURE_2D);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnableClientState(GL_VERTEX_ARRAY);
    resize(pWindow->getWidth(), pWindow->getHeight());
    //resize
    /*HWND hwnd;

    Trace("Initializing OpenGL graphics driver");

    hwnd = static_cast< HWND > (pWindow->getWindowHandle());

    // Create an OpenGL pixel format descriptor
    PIXELFORMATDESCRIPTOR pfd =
    {
    	sizeof(PIXELFORMATDESCRIPTOR),				// Size Of This Pixel Format Descriptor
    	1,											// Version Number
    	PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,	// Format Must Support OpenGL and double buffering
    	PFD_TYPE_RGBA,								// Request An RGBA Format
    	pWindow->getBpp(),							// Select Our Color Depth
    	0, 0, 0, 0, 0, 0,							// Color Bits Ignored
    	0,											// No Alpha Buffer
    	0,											// Shift Bit Ignored
    	0,											// No Accumulation Buffer
    	0, 0, 0, 0,									// Accumulation Bits Ignored
    	16,											// 16Bit Z-Buffer (Depth Buffer)
    	0,											// No Stencil Buffer
    	0,											// No Auxiliary Buffer
    	PFD_MAIN_PLANE,								// Main Drawing Layer
    	0,											// Reserved
    	0, 0, 0										// Layer Masks Ignored
    };


    // Initialise stuff, and check for errors

    Trace("Acquiring device context");
    if (!(hdc = GetDC(hwnd)))
    	CEngine::CriticalError("Unable to create GL device context!");

    Trace("Finding pixel format");
    if (!(pixelFormat = ChoosePixelFormat(hdc, &pfd)))
    	CEngine::CriticalError("Unable to find a pixel format!");

    Trace("Setting pixel format");
    if(!SetPixelFormat(hdc, pixelFormat, &pfd))
    	CEngine::CriticalError("Unable to set the pixel format!");

    Trace("Acquiring rendering context");
    if(!(hrc = wglCreateContext(hdc)))
    	CEngine::CriticalError("Unable to create GL rendering context!");

    Trace("Setting current GL window");
    if(!wglMakeCurrent(hdc, hrc))
    	CEngine::CriticalError("Unable to activate GL rendering context!");

    resize(pWindow->getWidth(), pWindow->getHeight());

    // Set up initial gl parameters
    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
    glClearDepth(1.0f);
    glEnable(GL_DEPTH_TEST);
    glClearColor(0.0,0.0,0.0,0.0);
    glDepthFunc(GL_LEQUAL);
    glEnable(GL_TEXTURE_2D);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnableClientState(GL_VERTEX_ARRAY);

    // Grab GL vendor information
    Trace("Getting OpenGL driver info ...");
    char* str;

    str = (char*)glGetString(GL_VENDOR);
    vendor.assign(str);
    Trace("OpenGL Vendor: %s", vendor.c_str());

    str = (char*)glGetString(GL_RENDERER);
    renderer.assign(str);
    Trace("OpenGL Renderer: %s", renderer.c_str());

    str = (char*)glGetString(GL_VERSION);
    version.assign(str);
    Trace("OpenGL Version: %s", version.c_str());

    str = (char*)glGetString(GL_EXTENSIONS);
    extensions.assign(str);

    // Replace all spaces with newlines
    for(int i = 0; i < extensions.length(); ++i)
    {
    	if(extensions[i] == ' ')
    		extensions[i] = '\n';
    }


    // Acquire pointer to extension functions

    // Multitexturing
    glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress("glActiveTextureARB");
    glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)wglGetProcAddress("glClientActiveTextureARB");
    glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)wglGetProcAddress("glMultiTexCoord2fARB");


    // Set up hardware gamma, if we are using it
    if(Config::getIntValue("UseHardwareGamma") == 1)
    {

    	GetDeviceGammaRamp(hdc, &oldGamma);
    	float gamma = 2.0f;

    	for(int i = 0; i < 3; i++)
    	{
    		for(int j = 0;j < 256; j++)
    		{
    			DWORD d = oldGamma[j][i] * gamma;
    			if(d > 65535)
    				d = 65535;
    			newGamma[j][i] = d;
    		}
    	}

    	SetDeviceGammaRamp(hdc, &newGamma);
    }


    // Set up the font
    HFONT	oldfont;

    fontDispListBase = glGenLists(96);

    font = CreateFont(-17, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS,
    					CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH, "Arial");

    oldfont = (HFONT)SelectObject(hdc, font);
    wglUseFontBitmaps(hdc, 32, 96, fontDispListBase);
    SelectObject(hdc, oldfont);
    DeleteObject(font);
    */
    return 0;
}
コード例 #24
0
ファイル: main.c プロジェクト: AVataRR626/NDK-Samples
int initialize() {
    EGLint surface_width, surface_height;

    //Load background and button textures
    float tex_x = 1.0f, tex_y = 1.0f;

    //Load textures for radio buttons
    int size_x = 64, size_y = 64;

    if (EXIT_SUCCESS
            != bbutil_load_texture("app/native/radio_btn_unselected.png",
                    NULL, NULL, &tex_x, &tex_y, &radio_btn_unselected)) {
        fprintf(stderr, "Unable to load non-selected radio button texture\n");
    }

    radio_btn_unselected_vertices[0] = 0.0f;
    radio_btn_unselected_vertices[1] = 0.0f;
    radio_btn_unselected_vertices[2] = size_x;
    radio_btn_unselected_vertices[3] = 0.0f;
    radio_btn_unselected_vertices[4] = 0.0f;
    radio_btn_unselected_vertices[5] = size_y;
    radio_btn_unselected_vertices[6] = size_x;
    radio_btn_unselected_vertices[7] = size_y;

    radio_btn_unselected_tex_coord[0] = 0.0f;
    radio_btn_unselected_tex_coord[1] = 0.0f;
    radio_btn_unselected_tex_coord[2] = tex_x;
    radio_btn_unselected_tex_coord[3] = 0.0f;
    radio_btn_unselected_tex_coord[4] = 0.0f;
    radio_btn_unselected_tex_coord[5] = tex_y;
    radio_btn_unselected_tex_coord[6] = tex_x;
    radio_btn_unselected_tex_coord[7] = tex_y;

    if (EXIT_SUCCESS
            != bbutil_load_texture("app/native/radio_btn_selected.png", NULL,
                    NULL, &tex_x, &tex_y, &radio_btn_selected)) {
        fprintf(stderr, "Unable to load selected radio button texture\n");
    }

    radio_btn_selected_vertices[0] = 0.0f;
    radio_btn_selected_vertices[1] = 0.0f;
    radio_btn_selected_vertices[2] = size_x;
    radio_btn_selected_vertices[3] = 0.0f;
    radio_btn_selected_vertices[4] = 0.0f;
    radio_btn_selected_vertices[5] = size_y;
    radio_btn_selected_vertices[6] = size_x;
    radio_btn_selected_vertices[7] = size_y;

    radio_btn_selected_tex_coord[0] = 0.0f;
    radio_btn_selected_tex_coord[1] = 0.0f;
    radio_btn_selected_tex_coord[2] = tex_x;
    radio_btn_selected_tex_coord[3] = 0.0f;
    radio_btn_selected_tex_coord[4] = 0.0f;
    radio_btn_selected_tex_coord[5] = tex_y;
    radio_btn_selected_tex_coord[6] = tex_x;
    radio_btn_selected_tex_coord[7] = tex_y;

    button_size_x = (float) size_x;
    button_size_y = (float) size_y;

    eglQuerySurface(egl_disp, egl_surf, EGL_WIDTH, &surface_width);
    eglQuerySurface(egl_disp, egl_surf, EGL_HEIGHT, &surface_height);

    EGLint err = eglGetError();
    if (err != 0x3000) {
        fprintf(stderr, "Unable to query EGL surface dimensions\n");
        return EXIT_FAILURE;
    }

    width = (float) surface_width;
    height = (float) surface_height;

    if (EXIT_SUCCESS
            != bbutil_load_texture("app/native/background-landscape.png", NULL, NULL,
                    &tex_x, &tex_y, &background_landscape)) {
        fprintf(stderr, "Unable to load landscape background texture\n");
    }

    size_x = (width > height) ? width : height;
    size_y = (width > height) ? height : width;

    background_landscape_vertices[0] = 0.0f;
    background_landscape_vertices[1] = 0.0f;
    background_landscape_vertices[2] = size_x;
    background_landscape_vertices[3] = 0.0f;
    background_landscape_vertices[4] = 0.0f;
    background_landscape_vertices[5] = size_y;
    background_landscape_vertices[6] = size_x;
    background_landscape_vertices[7] = size_y;

    background_landscape_tex_coord[0] = 0.0f;
    background_landscape_tex_coord[1] = 0.0f;
    background_landscape_tex_coord[2] = tex_x;
    background_landscape_tex_coord[3] = 0.0f;
    background_landscape_tex_coord[4] = 0.0f;
    background_landscape_tex_coord[5] = tex_y;
    background_landscape_tex_coord[6] = tex_x;
    background_landscape_tex_coord[7] = tex_y;

    if (EXIT_SUCCESS
            != bbutil_load_texture("app/native/background-portrait.png", NULL, NULL,
                    &tex_x, &tex_y, &background_portrait)) {
        fprintf(stderr, "Unable to load portrait background texture\n");
    }

    size_x = (height > width) ? width : height;
    size_y = (height > width) ? height : width;

    background_portrait_vertices[0] = 0.0f;
    background_portrait_vertices[1] = 0.0f;
    background_portrait_vertices[2] = size_x;
    background_portrait_vertices[3] = 0.0f;
    background_portrait_vertices[4] = 0.0f;
    background_portrait_vertices[5] = size_y;
    background_portrait_vertices[6] = size_x;
    background_portrait_vertices[7] = size_y;

    background_portrait_tex_coord[0] = 0.0f;
    background_portrait_tex_coord[1] = 0.0f;
    background_portrait_tex_coord[2] = tex_x;
    background_portrait_tex_coord[3] = 0.0f;
    background_portrait_tex_coord[4] = 0.0f;
    background_portrait_tex_coord[5] = tex_y;
    background_portrait_tex_coord[6] = tex_x;
    background_portrait_tex_coord[7] = tex_y;

    angle = 0.0f;
    pos_x = 0.0f;
    pos_y = 0.0f;

    //Load a typical arial font to use for our color menu
    int dpi = bbutil_calculate_dpi(screen_cxt);

    if (dpi == EXIT_FAILURE) {
        fprintf(stderr, "Unable to calculate dpi\n");
        return EXIT_FAILURE;
    }

    //As bbutil renders text using device-specifc dpi, we need to compute a point size
    //for the font, so that the text string fits into the bubble. Note that Playbook is used
    //as a reference point in this equation as we know that at dpi of 170, font with point size of
    //15 fits into the bubble texture.

    int point_size = (int)(15.0f / ((float)dpi / 170.0f ));

    font = bbutil_load_font("/usr/fonts/font_repository/monotype/arial.ttf", point_size, dpi);

    if (!font) {
       return EXIT_FAILURE;
    }

    float text_width, text_height;
    bbutil_measure_text(font, "Color Menu", &text_width, &text_height);
    menu_height = text_height + 10.0f + button_size_y * 4;

    //See if a savefile exists. If not, initialize to a hidden menu and a red cube.
    if (!read_from_file()) {
        selected = 3;
        cube_color[0] = 1.0f;
        cube_color[1] = 0.0f;
        cube_color[2] = 0.0f;
        cube_color[3] = 1.0f;

        menu_animation = 0.0f;
        menu_active = false;
        menu_show_animation = false;
        menu_hide_animation = false;
    }

    //Initialize positions of graphics assets on the screen, but don't resize the surface
    if (EXIT_FAILURE == resize(NULL)) {
        fprintf(stderr, "Initialize surface\n");
        return EXIT_FAILURE;
    }

    //Common gl setup
    glShadeModel(GL_SMOOTH);
    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

    glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
    glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
    glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, light_direction);

    glEnable(GL_CULL_FACE);

    menu_show_animation = true;

    return EXIT_SUCCESS;
}
コード例 #25
0
ファイル: splashscreen.cpp プロジェクト: bitcoin8m/B8M
SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) :
    QWidget(0, f), curAlignment(0)
{
    // set reference point, paddings
    int paddingRight            = 50;
    int paddingTop              = 50;
    int titleVersionVSpace      = 17;
    int titleCopyrightVSpace    = 40;

    float fontFactor            = 1.0;
    float devicePixelRatio      = 1.0;
#if QT_VERSION > 0x050100
    devicePixelRatio = ((QGuiApplication*)QCoreApplication::instance())->devicePixelRatio();
#endif

    // define text to place
    QString titleText       = tr("Bitcoin8m Core");
    QString versionText     = QString("Version %1").arg(QString::fromStdString(FormatFullVersion()));
    QString copyrightText   = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin8m Core developers"));
    QString titleAddText    = networkStyle->getTitleAddText();

    QString font            = QApplication::font().toString();

    // create a bitmap according to device pixelratio
    QSize splashSize(480*devicePixelRatio,320*devicePixelRatio);
    pixmap = QPixmap(splashSize);

#if QT_VERSION > 0x050100
    // change to HiDPI if it makes sense
    pixmap.setDevicePixelRatio(devicePixelRatio);
#endif

    QPainter pixPaint(&pixmap);
    pixPaint.setPen(QColor(100,100,100));

    // draw a slightly radial gradient
    QRadialGradient gradient(QPoint(0,0), splashSize.width()/devicePixelRatio);
    gradient.setColorAt(0, Qt::white);
    gradient.setColorAt(1, QColor(247,247,247));
    QRect rGradient(QPoint(0,0), splashSize);
    pixPaint.fillRect(rGradient, gradient);

    // draw the bitcoin8m icon, expected size of PNG: 1024x1024
    QRect rectIcon(QPoint(-150,-122), QSize(430,430));

    const QSize requiredSize(1024,1024);
    QPixmap icon(networkStyle->getAppIcon().pixmap(requiredSize));

    pixPaint.drawPixmap(rectIcon, icon);

    // check font size and drawing with
    pixPaint.setFont(QFont(font, 33*fontFactor));
    QFontMetrics fm = pixPaint.fontMetrics();
    int titleTextWidth  = fm.width(titleText);
    if(titleTextWidth > 160) {
        // strange font rendering, Arial probably not found
        fontFactor = 0.75;
    }

    pixPaint.setFont(QFont(font, 33*fontFactor));
    fm = pixPaint.fontMetrics();
    titleTextWidth  = fm.width(titleText);
    pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop,titleText);

    pixPaint.setFont(QFont(font, 15*fontFactor));

    // if the version string is to long, reduce size
    fm = pixPaint.fontMetrics();
    int versionTextWidth  = fm.width(versionText);
    if(versionTextWidth > titleTextWidth+paddingRight-10) {
        pixPaint.setFont(QFont(font, 10*fontFactor));
        titleVersionVSpace -= 5;
    }
    pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);

    // draw copyright stuff
    pixPaint.setFont(QFont(font, 10*fontFactor));
    pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText);

    // draw additional text if special network
    if(!titleAddText.isEmpty()) {
        QFont boldFont = QFont(font, 10*fontFactor);
        boldFont.setWeight(QFont::Bold);
        pixPaint.setFont(boldFont);
        fm = pixPaint.fontMetrics();
        int titleAddTextWidth  = fm.width(titleAddText);
        pixPaint.drawText(pixmap.width()/devicePixelRatio-titleAddTextWidth-10,15,titleAddText);
    }

    pixPaint.end();

    // Set window title
    setWindowTitle(titleText + " " + titleAddText);

    // Resize window and move to center of desktop, disallow resizing
    QRect r(QPoint(), QSize(pixmap.size().width()/devicePixelRatio,pixmap.size().height()/devicePixelRatio));
    resize(r.size());
    setFixedSize(r.size());
    move(QApplication::desktop()->screenGeometry().center() - r.center());

    subscribeToCoreSignals();
}
コード例 #26
0
ファイル: glearray.cpp プロジェクト: pnkfelix/glx-gle
void GLEObjectArray::setObjectAt(GLEObject* v, int i) {
	resize(i);
	m_Elems[i] = v;
}
コード例 #27
0
ファイル: widget.cpp プロジェクト: YeClimEric/Qt
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget),
    m_pData(new Widget::Private())
{
    ui->setupUi(this);
    QComboBox *cityList = new QComboBox(this);
    cityList->addItem(tr("Beijing"), QLatin1String("Beijing, cn"));
    cityList->addItem(tr("Shanghai"), QLatin1String("Shanghai, cn"));
    cityList->addItem(tr("Nanjing"), QLatin1String("Nanjing, cn"));

    QLabel* cityLabel = new QLabel(tr("City:"), this);
    QPushButton *refreshButton = new QPushButton(tr("Refresh"), this);
    QHBoxLayout *cityListLayout = new QHBoxLayout;
    cityListLayout->setDirection(QBoxLayout::LeftToRight);
    cityListLayout->addWidget(cityLabel);
    cityListLayout->addWidget(cityList);
    cityListLayout->addWidget(refreshButton);

    QVBoxLayout *weatherLayout = new QVBoxLayout;
    weatherLayout->setDirection(QBoxLayout::TopToBottom);
    QLabel* cityNameLabel = new QLabel(this);
    weatherLayout->addWidget(cityNameLabel);
    QLabel *dateTimeLabel = new QLabel(this);
    weatherLayout->addWidget(dateTimeLabel);

    m_pData->descLabel = new QLabel(this);
    weatherLayout->addWidget(m_pData->descLabel);
    m_pData->iconLabel = new QLabel(this);
    weatherLayout->addWidget(m_pData->iconLabel);

    QVBoxLayout* mainLayout = new QVBoxLayout(this);
    mainLayout->addLayout(cityListLayout);
    mainLayout->addLayout(weatherLayout);
    resize(320, 120);
    setWindowTitle("Weather");

    connect(m_pData->network, &NetWorker::finished, [=](QNetworkReply* reply){
        switch(m_pData->replyMap.value(reply))
        {
        case FetchWeatherInfo:
            {
                QJsonParseError error;
                QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);

                if(error.error == QJsonParseError::NoError){
                    if(!(jsonDoc.isNull() || jsonDoc.isEmpty()) && (jsonDoc.isObject())){
                        QVariantMap data = jsonDoc.toVariant().toMap();
                        WeatherInfo weather;
                        weather.setCityName(data[QLatin1String("name")].toString());
                        QDateTime dateTime;
                        dateTime.setTime_t(data[QLatin1String("dt")].toLongLong());
                        weather.setDateTime(dateTime);
                        QVariantMap main = data[QLatin1String("main")].toMap();
                        weather.setTempertuare(main[QLatin1String("temp")].toFloat());
                        weather.setPressure(main[QLatin1String("pressure")].toFloat());
                        weather.setHumidity(main[QLatin1String("humidity")].toFloat());
                        QVariantList detaiList = data[QLatin1String("weather")].toList();
                        WeatherDetailList details;
                        foreach (QVariant w, detaiList) {
                            QVariantMap wm = w.toMap();
                            WeatherDetail *detail = new WeatherDetail;
                            detail->setDesc(wm[QLatin1String("description")].toString());
                            detail->setIcon(wm[QLatin1Literal("icon")].toString());
                            details.append(detail);
                        }
                        weather.setDetails(details);
                        cityNameLabel->setText(weather.cityName());
                        dateTimeLabel->setText(weather.dateTime().toString(Qt::DefaultLocaleLongDate));
                        m_pData->descLabel->setText(weather.details().at(0)->desc());
                        qDebug()<<weather;
                    }
                    else{
                        QMessageBox::critical(this, "Error","Parse Reply Error!");
                    }
                }
            }
コード例 #28
0
ファイル: glearray.cpp プロジェクト: pnkfelix/glx-gle
void GLEDoubleArray::setDoubleAt(double v, int i) {
	resize(i);
	m_Elems[i] = v;
}
コード例 #29
0
void OSDWidget::showOSD(const QString &str, OSDUserData *data)
{
    if (isScreenSaverActive()){
        hide();
        return;
    }
    setFont(FontEdit::str2font(data->Font.ptr, baseFont));
    QPainter p(this);
    p.setFont(font());
    unsigned nScreen = data->Screen.value;
    unsigned nScreens = screens();
    if (nScreen >= nScreens)
        nScreen = 0;
    int SHADOW_OFFS = SHADOW_DEF;
    QRect rcScreen = screenGeometry(nScreen);
    rcScreen = QRect(0, 0,
                     rcScreen.width()  - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.value,
                     rcScreen.height() - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.value);
    QRect rc = p.boundingRect(rcScreen, AlignLeft | AlignTop | WordBreak, str);
    if (rc.height() >= rcScreen.height() / 2){
        rcScreen = QRect(0, 0,
                         rcScreen.width() - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.value,
                         rcScreen.height() - SHADOW_OFFS - XOSD_MARGIN * 2 - data->Offset.value);
        rc = p.boundingRect(rcScreen, AlignLeft | AlignTop | WordBreak, str);
    }
    p.end();
    if (data->EnableMessageShowContent.bValue && data->ContentLines.value){
        QFontMetrics fm(font());
        int maxHeight = fm.height() * (data->ContentLines.value + 1);
        if (rc.height() > maxHeight)
            rc.setHeight(maxHeight);
    }
    int x = rcScreen.left();
    int y = rcScreen.top();
    int w = rc.width() + 1;
    int h = rc.height() + 1;
    int text_y = 0;
    if (data->Background.bValue){
        w += XOSD_MARGIN * 2;
        h += XOSD_MARGIN * 2;
        if (m_button == NULL){
            m_button = new QPushButton("", this);
            m_button->setPixmap(QPixmap((const char **)close_h_xpm));
            connect(m_button, SIGNAL(clicked()), this, SLOT(slotCloseClick()));
        }
        QSize s = m_button->sizeHint();
        m_button->resize(s.height() - 4, s.height() - 4);
        m_button->move(w - m_button->width() - 3, 2);
        text_y = m_button->height() + 4;
        h += text_y;
        m_button->show();
    }else{
        if (m_button){
            delete m_button;
            m_button = NULL;
        }
    }
    if (data->Shadow.bValue){
        w += SHADOW_OFFS;
        h += SHADOW_OFFS;
    }
    resize(QSize(w, h));
    switch (data->Position.value){
    case 1:
        move(x + data->Offset.value, y + data->Offset.value);
        break;
    case 2:
        move(x + rcScreen.width() - data->Offset.value - w, y + rcScreen.height() - data->Offset.value - h);
        break;
    case 3:
        move(x + rcScreen.width() - data->Offset.value - w, y + data->Offset.value);
        break;
    case 4:
        move(x + (rcScreen.width() - w) / 2, y + rcScreen.height() - data->Offset.value - h);
        break;
    case 5:
        move(x + (rcScreen.width() - w) / 2, y + data->Offset.value);
        break;
    case 6:
        move(x + (rcScreen.width() - w) / 2, y + (rcScreen.height() - h) /2);
        break;
    default:
        move(x + data->Offset.value, y + rcScreen.height() - data->Offset.value - h);
    }
    if (!data->Background.bValue || data->Shadow.bValue){
        QBitmap mask(w, h);
        p.begin(&mask);
#ifdef WIN32
        QColor bg(255, 255, 255);
        QColor fg(0, 0, 0);
#else
        QColor bg(0, 0, 0);
        QColor fg(255, 255, 255);
#endif
        p.fillRect(0, 0, w, h, bg);
        if (data->Background.bValue){
            p.fillRect(0, 0, w - SHADOW_OFFS, h - SHADOW_OFFS, fg);
            p.fillRect(SHADOW_OFFS, SHADOW_OFFS, w - SHADOW_OFFS, h - SHADOW_OFFS, fg);
        }else{
            p.setPen(fg);
            p.setFont(font());
            if (data->Shadow.bValue){
                rc = QRect(SHADOW_OFFS, SHADOW_OFFS, w - SHADOW_OFFS, h - SHADOW_OFFS);
                p.drawText(rc, AlignLeft | AlignTop | WordBreak, str);
                rc = QRect(0, 0, w - SHADOW_OFFS, h - SHADOW_OFFS);
                p.drawText(rc, AlignLeft | AlignTop | WordBreak, str);
            }else{
                rc = QRect(0, 0, w, h);
                p.drawText(rc, AlignLeft | AlignTop | WordBreak, str);
            }
        }
        p.end();
        setMask(mask);
    }
    qApp->syncX();
    QPixmap pict = QPixmap::grabWindow(QApplication::desktop()->winId(), this->x(), this->y(), width(), height());
    intensity(pict, -0.50f);
    p.begin(&pict);
    rc = QRect(0, 0, w, h);
    if (data->Background.bValue){
        if (data->Shadow.bValue){
            w -= SHADOW_OFFS;
            h -= SHADOW_OFFS;
            rc = QRect(0, 0, w, h);
        }
        QBrush bg(data->BgColor.value);
        p.fillRect(rc, bg);
#if COMPAT_QT_VERSION < 0x030000
        style().drawPopupPanel(&p, 0, 0, w, h, colorGroup(), 2, &bg);
#else
        style().drawPrimitive(QStyle::PE_PanelPopup, &p, rc, colorGroup());
#endif
        rc = QRect(XOSD_MARGIN, XOSD_MARGIN, w - XOSD_MARGIN * 2, h - XOSD_MARGIN * 2);
    }
    p.setFont(font());
    p.setPen(QColor(data->Color.value));
    rc.setTop(text_y);
    p.drawText(rc, AlignLeft | AlignTop | WordBreak, str);
    p.end();
    bgPict = pict;
    QWidget::show();
    raise();
}
コード例 #30
0
ファイル: eval.c プロジェクト: ChunHungLiu/uemacs
/*
 * Set a variable.
 *
 * @var: variable to set.
 * @value: value to set to.
 */
int svar(struct variable_description *var, char *value)
{
	int vnum;	/* ordinal number of var refrenced */
	int vtype;	/* type of variable to set */
	int status;	/* status return */
	int c;		/* translated character */
	char *sp;	/* scratch string pointer */

	/* simplify the vd structure (we are gonna look at it a lot) */
	vnum = var->v_num;
	vtype = var->v_type;

	/* and set the appropriate value */
	status = TRUE;
	switch (vtype) {
	case TKVAR:		/* set a user variable */
		if (uv[vnum].u_value != NULL)
			free(uv[vnum].u_value);
		sp = malloc(strlen(value) + 1);
		if (sp == NULL)
			return FALSE;
		strcpy(sp, value);
		uv[vnum].u_value = sp;
		break;

	case TKENV:		/* set an environment variable */
		status = TRUE;	/* by default */
		switch (vnum) {
		case EVFILLCOL:
			fillcol = atoi(value);
			break;
		case EVPAGELEN:
			status = newsize(TRUE, atoi(value));
			break;
		case EVCURCOL:
			status = setccol(atoi(value));
			break;
		case EVCURLINE:
			status = gotoline(TRUE, atoi(value));
			break;
		case EVRAM:
			break;
		case EVFLICKER:
			flickcode = stol(value);
			break;
		case EVCURWIDTH:
			status = newwidth(TRUE, atoi(value));
			break;
		case EVCBUFNAME:
			strcpy(curbp->b_bname, value);
			curwp->w_flag |= WFMODE;
			break;
		case EVCFNAME:
			strcpy(curbp->b_fname, value);
			curwp->w_flag |= WFMODE;
			break;
		case EVSRES:
			status = TTrez(value);
			break;
		case EVDEBUG:
			macbug = stol(value);
			break;
		case EVSTATUS:
			cmdstatus = stol(value);
			break;
		case EVASAVE:
			gasave = atoi(value);
			break;
		case EVACOUNT:
			gacount = atoi(value);
			break;
		case EVLASTKEY:
			lastkey = atoi(value);
			break;
		case EVCURCHAR:
			ldelchar(1, FALSE);	/* delete 1 char */
			c = atoi(value);
			if (c == '\n')
				lnewline();
			else
				linsert(1, c);
			backchar(FALSE, 1);
			break;
		case EVDISCMD:
			discmd = stol(value);
			break;
		case EVVERSION:
			break;
		case EVPROGNAME:
			break;
		case EVSEED:
			seed = atoi(value);
			break;
		case EVDISINP:
			disinp = stol(value);
			break;
		case EVWLINE:
			status = resize(TRUE, atoi(value));
			break;
		case EVCWLINE:
			status = forwline(TRUE, atoi(value) - getwpos());
			break;
		case EVTARGET:
			curgoal = atoi(value);
			thisflag = saveflag;
			break;
		case EVSEARCH:
			strcpy(pat, value);
			rvstrcpy(tap, pat);
#if	MAGIC
			mcclear();
#endif
			break;
		case EVREPLACE:
			strcpy(rpat, value);
			break;
		case EVMATCH:
			break;
		case EVKILL:
			break;
		case EVCMODE:
			curbp->b_mode = atoi(value);
			curwp->w_flag |= WFMODE;
			break;
		case EVGMODE:
			gmode = atoi(value);
			break;
		case EVTPAUSE:
			term.t_pause = atoi(value);
			break;
		case EVPENDING:
			break;
		case EVLWIDTH:
			break;
		case EVLINE:
			putctext(value);
		case EVGFLAGS:
			gflags = atoi(value);
			break;
		case EVRVAL:
			break;
		case EVTAB:
			tabmask = atoi(value) - 1;
			if (tabmask != 0x07 && tabmask != 0x03)
				tabmask = 0x07;
			curwp->w_flag |= WFHARD;
			break;
		case EVOVERLAP:
			overlap = atoi(value);
			break;
		case EVSCROLLCOUNT:
			scrollcount = atoi(value);
			break;
		case EVSCROLL:
#if SCROLLCODE
			if (!stol(value))
				term.t_scroll = NULL;
#endif
			break;
		}
		break;
	}
	return status;
}