// Load and save font descriptions
bool wxWindowSettings::LoadFont(wxConfigBase& config, const wxString& windowName, wxFont& font)
{
    wxString pathBase(wxT("/Fonts/"));
    pathBase += windowName;
    pathBase += wxT("/");

    int pointSize, family, style, weight;
    bool underlined = FALSE;
    wxString faceName;

    if (!config.Read(pathBase + wxT("PointSize"), & pointSize))
        return FALSE;

    if (!config.Read(pathBase + wxT("Family"), & family))
        return FALSE;

    if (!config.Read(pathBase + wxT("Style"), & style))
        return FALSE;

    if (!config.Read(pathBase + wxT("Weight"), & weight))
        return FALSE;

    config.Read(pathBase + wxT("Underlined"), (bool*) & underlined);
    config.Read(pathBase + wxT("FaceName"), & faceName);

    wxFont font1(pointSize, family, style, weight, underlined, faceName);
    font = font1;

    return TRUE;    
}
Exemple #2
0
void ShowWidget::DisplayAnswer()
{
    Table t = this->table;

    QLayoutItem *child;
    while((child = gridlayout->takeAt(0)) != 0)
    {
        delete child->widget();
        delete child;
    }

    for(int i=0;i<t.n;i++)
        for(int j=0;j<t.n;j++)
        {
            QLabel *label = new QLabel();
            QPixmap pmap(":/new/prefix1/Back");
            QPainter painter1;
            QFont font1("Arial",13,QFont::Bold,false);
            QFont font2("Arial",9,QFont::Bold,false);
            painter1.begin(&pmap);
            if(t.n<10) painter1.setFont(font1);
            else painter1.setFont(font2);
            painter1.setPen(Qt::blue);
            painter1.drawText(3,3,20,20,Qt::AlignCenter,QString::number(t.data[i][j],10));//将数字转化成输出
            painter1.end();
            label->setPixmap(pmap);
            gridlayout->addWidget(label,i,j);
        }

    this->setWindowTitle(QString::number(t.n,10) + tr("阶魔方阵"));
    this->show();
}
Exemple #3
0
menu_pause::menu_pause(QWidget *parent,QMainWindow* fenetre):
    parent(parent),mainWindow(fenetre)
{
    QFont font("Bradley Hand ITC",16,75,false);
    font.setBold(true);

    QFont font1("Bradley Hand ITC",14,75,false);
    font1.setBold(true);

    btn_Reprendre = new QPushButton;
    btn_Reprendre->setMinimumSize(QSize(250, 55));
    btn_Reprendre->setMaximumSize(QSize(250, 55));
    btn_Reprendre->setFont(font);
    btn_Reprendre->setCursor(QCursor(Qt::PointingHandCursor));
    btn_Reprendre->setLayoutDirection(Qt::LeftToRight);
    btn_Reprendre->setStyleSheet("color: rgb(138, 0, 0);\n"
"border-color: rgb(138, 138,138);\n"
"background-color: rgb(241, 241, 241);");

    btn_nouvelle = new QPushButton;
    btn_nouvelle->setMinimumSize(QSize(190, 55));
    btn_nouvelle->setMaximumSize(QSize(190, 55));
    btn_nouvelle->setFont(font);
    btn_nouvelle->setCursor(QCursor(Qt::PointingHandCursor));
    btn_nouvelle->setFocusPolicy(Qt::StrongFocus);
    btn_Reprendre->setLayoutDirection(Qt::LeftToRight);
    btn_nouvelle->setStyleSheet(QString::fromUtf8("color: rgb(138, 0, 0);\n"
"border-color: rgb(138, 138,138);\n"
"background-color: rgb(241, 241, 241);"));

    btn_Accueil = new QPushButton;
    btn_Accueil->setMinimumSize(QSize(230, 55));
    btn_Accueil->setMaximumSize(QSize(230, 55));
    btn_Accueil->setFont(font1);
    btn_Accueil->setCursor(QCursor(Qt::PointingHandCursor));
    btn_Accueil->setFocusPolicy(Qt::StrongFocus);
    btn_Reprendre->setLayoutDirection(Qt::LeftToRight);
    btn_Accueil->setStyleSheet(QString::fromUtf8("color: rgb(138, 0, 0);\n"
"border-color: rgb(138, 138,138);\n"
"background-color: rgb(241, 241, 241);"));

    btn_Exit = new QPushButton;
    btn_Exit->setMinimumSize(QSize(150, 40));
    btn_Exit->setMaximumSize(QSize(150, 40));
    btn_Exit->setFont(font);
    btn_Exit->setCursor(QCursor(Qt::PointingHandCursor));
    btn_Exit->setFocusPolicy(Qt::StrongFocus);
    btn_Reprendre->setLayoutDirection(Qt::LeftToRight);
    btn_Exit->setStyleSheet(QString::fromUtf8("color: rgb(138, 0, 0);\n"
"border-color: rgb(138, 138,138);\n"
"background-color: rgb(241, 241, 241);"));


    btn_Reprendre->setText("&Reprendre la \nPartie");
    btn_nouvelle->setText("Nouvelle Partie");
    btn_Accueil->setText("Vers le menu\nd'accueil");
    btn_Exit->setText("&Quitter");

}
Exemple #4
0
SNIFFER::SNIFFER()
{
    QFont font("Courier", 8, QFont::Normal);
    QFont font1("Courier",8,QFont::Bold);
    setWindowTitle(tr("Sniffer"));
    //resize(500, 400);
    interface=false;

    status=new QTextEdit();
    status->setWordWrapMode(QTextOption::NoWrap);
    status->setFont(font);
    status->setFixedSize(700,200);
    status->setReadOnly(true);
    setCentralWidget(status);
    pcnt=0;
    error=false;
    // open();
    //emit(onLoad());

}
void ListViewSingleButtonDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
     //
    // This method paints a new row into the listview
    //

    painter->save();

    // Set normal background color
    painter->setBrush((QColor("#ffffff")));

    // Alternating rows
    if (index.row() % 2) {
        // Set brush to aliceblue
        painter->setBrush((QColor("#f5f5f5")));
    }

    if(index.model()->data(index, Qt::UserRole + 4).toInt() == ConnectionState::Error)
    {
        painter->setBrush(QColor("#FFCCCC"));
    }

    QString textBottom (index.model()->data(index, Qt::UserRole + 101).toString());
    QString textName (index.data(Qt::DisplayRole).toString());

    // Hindergrund zeichnen
    painter->setPen(Qt::NoPen);

    if (textBottom == "__divider__") {
        painter->setBrush(QBrush(QColor("#f2f2f2"))); //0053a1
        painter->drawRect(option.rect);
        painter->setPen(Qt::lightGray);
        painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
        if (index.row() == 0) {
            painter->drawLine(option.rect.topLeft(), option.rect.topRight());
        }

        painter->setPen(Qt::black);
        QStyleOptionViewItem nOptionD (option);
        QFont sdasda("Verdana", 10, QFont::Normal);
        //sdasda.setPixelSize(11);
        painter->setFont(sdasda);
        nOptionD.rect.adjust(3, 0, 0, 0);
        painter->drawText(nOptionD.rect, textName);
        rectForRow.insert(index.row(), QRect());
        rectForRow[index.row()] = option.rect;
         painter->restore();
        return;
    }

    painter->drawRect(option.rect);

    // Get text

    QString ip (index.data(Qt::UserRole + 1).toString());
    quint32 lastUsed(index.data(Qt::UserRole + 2).toUInt());
    quint32 lastConnected(index.data(Qt::UserRole + 3).toUInt());
    // Set and calc items width
    int buttonWidth (36* windowsDpiScale());
    int buttonHeight (36* windowsDpiScale());
    int marginRight (10* windowsDpiScale());
    int marginTop (5* windowsDpiScale());

    // Draw delete button
    QStyleOptionViewItem buttonOption (option);
    // -10 is the right margin, the margin is necessary to reset the state when mouse is leaving to the right side
    buttonOption.rect.setRight(buttonWidth + 2 * marginRight);
    buttonOption.rect.setHeight(buttonHeight);
    buttonOption.rect.adjust(10* windowsDpiScale(), option.rect.height() / 2 - buttonHeight / 2, -(marginRight), marginTop + 1);
    buttonOption.rect.setHeight(buttonHeight);
    // Draw delete button and return limits
    // This is to figure out which button is under the mouse position
    rectForRow.insert(index.row(), QRect());
    rectForRow[index.row()] = buttonOption.rect;

    auto drawButton = [](const QModelIndex &index, QPainter *painter, const QRect &rect, int role, ConnectionState conState)
    {
        // Draw delete button
        QStyleOptionButton buttonStyle;

        //
        // Set the button state to enabled
        buttonStyle.state |= QStyle::State_Enabled;
        // Set postion and size to the item
        buttonStyle.rect = rect;
        // Button is a flat button
        buttonStyle.features = QStyleOptionButton::Flat;
        // No text, only an icon
        // Icon default is 16x16
        buttonStyle.iconSize = QSize(16* windowsDpiScale(), 16* windowsDpiScale());
        //

        // Set the button states
        ButtonState state = (ButtonState) index.data(role).toInt();
        QPen pen;
        pen.setWidth(1);

        switch(conState)
        {
        case ConnectionState::Disconnected:
            {
                if(state == Hover) {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#F0D151"));
                } else if(state == Pressed) {

                } else {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#EEEEEC"));
                }
            }
            break;
        case ConnectionState::Connecting:
            {
                if(state == Hover) {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#EEEEEC"));
                } else if(state == Pressed) {
                } else {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#F1C40F"));
                }

            }
            break;
        case ConnectionState::Connected:
            {
                if(state == Hover) {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#EEEEEC"));
                } else if(state == Pressed) {
                } else {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#72C02C"));
                }
            }
            break;
        case ConnectionState::Error:
            {
                if(state == Hover) {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#F0D151"));
                } else if(state == Pressed) {
                } else {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#FF0000"));
                }
            }
            break;
        default:
            {
                pen.setColor("#808080");
                painter->setBrush(QBrush("#EEEEEC"));
            }
        }

    // Set the pen and draw the border of the button
    painter->setPen(pen);
    painter->drawRect(buttonStyle.rect);
    painter->setBrush(Qt::NoBrush);

    QRect buttonOption(rect);



    // Draw button
    QApplication::style()->drawControl(QStyle::CE_PushButton, &buttonStyle, painter);
    };

    ConnectionState conState = (ConnectionState)index.data(Qt::UserRole + 4).toInt();

    drawButton(index, painter, buttonOption.rect, Qt::UserRole + 100, conState);

   // this->buttonLimits = this->drawButton(index, painter, buttonOption.rect, this->iconForType(this->buttonIconType, option), Qt::UserRole + 100);


    // Draw text
    QStyleOptionViewItem textOption (option);
    textOption.rect.adjust(buttonWidth + marginRight + 10 + 4, 4, buttonWidth + 2 * marginRight, 0);
    QPen pen;
    pen.setColor(QColor("#2c2c2c"));
    painter->setPen(pen);

    QFont font1("Verdana", 9, QFont::Normal);
    //font1.setPixelSize(11);
    
    QFont font2("Verdana", 7, QFont::Normal);
    //font2.setPixelSize(9);

    painter->setFont(font1);
    painter->drawText(textOption.rect, textName);
    textOption.rect.adjust(0, 13* windowsDpiScale(), 0, 0);
    painter->setFont(font2);
    //painter->drawText(textOption.rect, "Connected: ");
    //textOption.rect.adjust(0, 9, 0, 0);
    //painter->drawText(textOption.rect, "Last used: ");
    //textOption.rect.adjust(0, 9, 0, 0);

    typedef std::chrono::duration<int, std::ratio_multiply<std::chrono::hours::period, std::ratio<24>>::type> days;
    std::chrono::seconds sec((QDateTime::currentDateTime().toTime_t() - lastConnected));

    auto d = std::chrono::duration_cast<days>(sec);
    auto h = std::chrono::duration_cast<std::chrono::hours>(sec - d);
    auto m = std::chrono::duration_cast<std::chrono::minutes>((sec - d - h));
    auto s = std::chrono::duration_cast<std::chrono::seconds>((sec - d - h - m));


    QString day("%1%2 D ");
    day = day.arg(d.count() < 10 ? "0" : "")
        .arg(d.count());

    QString hour("%1%2 H ");
    hour = hour.arg(h.count() < 10 ? "0" : "")
        .arg(h.count());

    QString minute("%1%2 M ");
    minute = minute.arg(m.count() < 10 ? "0" : "")
        .arg(m.count());

    switch(conState)
    {
    case ConnectionState::Connected:
        painter->drawText(textOption.rect, QObject::tr("Connected: ") + (day) + (hour) + (d.count() > 0 ? "" : minute));
        break;
    case ConnectionState::Disconnected:
        painter->drawText(textOption.rect, QObject::tr("Last used: ") + (lastUsed == 0 ? QObject::tr("Never") : QDateTime::fromTime_t(lastUsed).toString("dd.MM.yy hh:mm")));
        break;
    default:
        painter->drawText(textOption.rect, QObject::tr("Last used: ") + (lastUsed == 0 ? QObject::tr("Never") : QDateTime::fromTime_t(lastUsed).toString("dd.MM.yy hh:mm")));
        break;
    };

    if(buttonOption.rect.size() != _lastImgSize)
    {     
        imgStart = imgStart_.scaled(buttonOption.rect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
        imgOffline = imgOffline_.scaled(buttonOption.rect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
        imgError = imgError_.scaled(buttonOption.rect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
        imgOnline = imgOnline_.scaled(buttonOption.rect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
        imgStop = imgStop_.scaled(buttonOption.rect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
        imgConnecting = imgConnecting_.scaled(buttonOption.rect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
        auto s = buttonOption.rect.size();

        // I dont know why this thing has to be adjusted, but well, it works.
        s.setWidth(s.width() - 1);
        s.setHeight(s.height() - 1);
        movieKeks->setScaledSize(s);

        QSize size(16, 16);

        

        imgIconUsers = imgIconUsers_.scaled(size * windowsDpiScale(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
        imgIconAutostart = imgIconAutostart_.scaled(size * windowsDpiScale(), Qt::KeepAspectRatio, Qt::SmoothTransformation);

        _lastImgSize = buttonOption.rect.size();
    }   
    buttonOption.rect.adjust(((buttonWidth) - imgStart.width()) / 2 +1, ((buttonWidth) - imgStart.height()) / 2 + 1, 0, 0);

    ButtonState state = (ButtonState) index.data(Qt::UserRole + 100).toInt();

    switch(conState)
    {
    case ConnectionState::Disconnected:
        {
            if(state == Hover)
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgStart);
            else
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgOffline);
        }
        break;
    case ConnectionState::Connecting:
        {
            if(state == Hover)
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgStop);
            else
            {
                auto pixx = movieKeks->currentPixmap();
                //auto size = imgStart.size();
                ////size.setHeight(size.height() -10);
                //pixx = pixx.scaled(imgStart.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), pixx.toImage());
            }
        }
        break;
    case ConnectionState::Connected:
        {
            if(state == Hover)
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgStop);
            else
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgOnline);
        }
        break;
    case ConnectionState::Error:
        {
            if(state == Hover)
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgStart);
            else
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgError);
        }
        break;
    default:
        {
            if(state == Hover)
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgStart);
            else
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgOffline);
        }
    }


    static const int iconPadding = 5;

    textOption.rect.setTop(buttonOption.rect.bottom());
    textOption.rect.adjust(0, -imgIconAutostart.height()+2, 0, 0);
    textOption.rect.setWidth(imgIconAutostart.width());

    if(index.data(Qt::UserRole + 5).toBool())
    {
        painter->drawImage(textOption.rect.left(),  textOption.rect.top(), imgIconAutostart);
        textOption.rect.adjust(imgIconAutostart.width() + iconPadding, 0, 0, 0);
    }

    if(index.data(Qt::UserRole + 6).toBool())
    {
        painter->drawImage(textOption.rect.left(),  textOption.rect.top(), imgIconUsers);
        textOption.rect.adjust(imgIconAutostart.width() + iconPadding, 0, 0, 0);
    }
    painter->setPen(Qt::lightGray);
    painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());

    // Restore saved painter
    painter->restore();
}
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    /* Erstellung des Fensterlayouts*/
    this->setCentralWidget(fenster);;
    fenster->setWindowTitle("Project VON");

    /*----- Westpart wird designed -----*/

    /*Label Optionen mit einer bestimmten Form*/
    QFont font1( "Calibri", 20, QFont::Bold);
    option->setFont(font1);
    option->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
    option->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);


    /*Hintergrundfarben mit ihrem Label Hintergrund */
    QFont font2( "Calibri", 10, QFont::Bold);
    hintergrund->setFont(font2);


    QPushButton *schwarz = new QPushButton();
    schwarz->setStyleSheet("background-color: black");
    QObject::connect(schwarz, &QPushButton::clicked,this, &MainWindow::schwarz);
    QPushButton *weiss = new QPushButton();
    weiss->setStyleSheet("background-color: white");
    QObject::connect(weiss, &QPushButton::clicked,this, &MainWindow::weiss);
    QPushButton *beige = new QPushButton();
    beige->setStyleSheet("background-color: beige");
    QObject::connect(beige, &QPushButton::clicked,this, &MainWindow::beige);
    QPushButton *rose = new QPushButton();
    rose->setStyleSheet("background-color: pink");
    QObject::connect(rose, &QPushButton::clicked,this, &MainWindow::pink);
    QGridLayout *farben = new QGridLayout();
    QGridLayout *farb = new QGridLayout();
    QWidget *farbenWidget = new QWidget();
    farb->addWidget(schwarz,0,0);
    farb->addWidget(weiss,0,1);
    farb->addWidget(beige,0,2);
    farb->addWidget(rose,0,3);
    farben->addWidget(hintergrund,0,0);
    farben->addLayout(farb,1,0);
    farbenWidget->setLayout(farben);

    /*Bilderanzahl als Buttons mit dem Label "Anzahl Bilder"*/
    QFont font3( "Calibri", 10, QFont::Bold);
    anzahlBilder->setFont(font3);

    QGridLayout *bilder = new QGridLayout();
    QGridLayout *bild = new QGridLayout();
    bild->addWidget(zwanzig,1,0);
    bild->addWidget(vierzig,1,1);
    bild->addWidget(sechsig,1,2);
    bilder->addWidget(anzahlBilder,0,0);
    bilder->addLayout(bild,1,0);
    QWidget *bilderWidget = new QWidget();
    bilderWidget->setLayout(bilder);


    /*Einstellung des Vollbildmoduses mit dem Label*/
    QFont font4( "Calibri", 10, QFont::Bold);
    vollbild->setFont(font4);
    QVBoxLayout *voll = new QVBoxLayout();
    voll->addWidget(vollbild);
    voll->addWidget(vollbildmodus);
    QWidget *vollWidget = new QWidget();
    vollWidget->setLayout(voll);

    /*Filter zur Behandlung ihrer Bildermenge + Label Filter*/
    QFont font5( "Calibri", 10, QFont::Bold);
    filter->setFont(font5);
    QLineEdit *filtern = new QLineEdit();
    QGridLayout *filt = new QGridLayout();
    filt->addWidget(filter,0,1);
    filt->addWidget(filtern,2,1);
    QWidget *filterWidget = new QWidget();
    filterWidget->setLayout(filt);


    menu->addWidget(option);
    menu->addWidget(farbenWidget, 0, Qt::AlignLeft | Qt::AlignTop);
    menu->addWidget(bilderWidget, 0, Qt::AlignLeft | Qt::AlignTop);
    menu->addWidget(vollWidget, 0, Qt::AlignLeft | Qt::AlignTop);
    menu->addWidget(filterWidget, 0, Qt::AlignLeft | Qt::AlignTop);


    QVBoxLayout *menu2 = new QVBoxLayout();
    menu->insertStretch(300,30);
    menu->addLayout(menu);

    fenster->setStyleSheet("background-color:white;");
    westpart->setStyleSheet("background-color:rgb(245,245,245);");
    westpart->setLayout(menu);
    west->addWidget(westpart);
    window->addWidget(westpart);


    /*Center muss hier programmiert werden*/

//    centerpart->setStyleSheet("background-color:black;");
    center->addWidget(centerpart);


    /*Layouts dem Widget hinzufügen*/

    window->addLayout(west,0,0,0,1);
    window->addLayout(center,0,1,1,4);

    fenster->setLayout(window);
}
Dialog::Dialog(QWidget *parent)
    : QDialog(parent), ui(new Ui::Dialog)
{
    ui->setupUi(this);

    QFont font1("Times", 12, QFont::Normal);
    QFont font("Times", 10, QFont::Normal);

    lm=new QLabel("<u>Matrix:</u>");
    m1=new QLineEdit("1");
    m2=new QLineEdit("0");
    m3=new QLineEdit("0");
    m4=new QLineEdit("1");
    M=new QLineEdit("5");
    R=new QLineEdit("0.25");
    mm=new QLabel("m = ");
    rr=new QLabel("R = ");
    speed=new QLabel("Speed:");
    voptions=new QLabel("<u>Picture options:</u>");
    viewoptions=new QLabel("<u>View options:</u>");
    zoomlabel=new QLabel("<u>Scaling:</u>");
    zoomlabel->setFont(font1);
    lm->setFont(font1);
    mm->setFont(font1);
    rr->setFont(font1);
    speed->setFont(font1);
    voptions->setFont(font1);
    viewoptions->setFont(font1);
    //QDoubleValidator *b=new QDoubleValidator(0,9999,begin);
    //QIntValidator *e=new QIntValidator(1,10000,end);

    //begin->setValidator(b);
    //end->setValidator(e);

    QLabel *space=new QLabel(" ");

    //mm1=new QLabel("mm");
    //mm2=new QLabel("mm");
    //mm1->setFont(font1);
    //mm2->setFont(font1);

   // lbegin=new QLabel("From:");
   // lend=new QLabel("To:");

    //lbegin->setFont(font);
    //lend->setFont(font);


    backDef=new QPushButton("Default view");
    pmdstop=new QPushButton("Stop");
    goButton=new QPushButton("Go!");
    delaxis=new QPushButton("Delete axis");
    delmcircle=new QPushButton("Delete moving circle");
    delscircle=new QPushButton("Delete static circle");
    aboutbutton=new QPushButton("About");
    zoombutton=new QPushButton("Fit to screen");
    zoombutton->setFont(font1);
    aboutbutton->setFont(font1);
    backDef->setFont(font1);
    pmdstop->setFont(font1);
    goButton->setFont(font1);
    delaxis->setFont(font1);
    delmcircle->setFont(font1);
    delscircle->setFont(font1);
    delaxis->setFont(font);
    delmcircle->setFont(font);
    delscircle->setFont(font);
    zoombutton->setFixedHeight(25);
    zoombutton->setFixedWidth(120);
    delmcircle->setFixedWidth(120);
    backDef->setFixedWidth(120);
    pmdstop->setFixedWidth(120);
    goButton->setFixedWidth(120);
    delscircle->setFixedWidth(120);
    delaxis->setFixedWidth(120);
    delmcircle->setFixedHeight(25);
    backDef->setFixedHeight(25);
    pmdstop->setFixedHeight(25);
    goButton->setFixedHeight(25);
    delscircle->setFixedHeight(25);
    delaxis->setFixedHeight(25);
    delmcircle->setFixedHeight(25);
    aboutbutton->setFixedWidth(120);
    aboutbutton->setFixedHeight(20);
    aboutbutton->setFont(font);
    fast=new QPushButton(">");
    fast->setFont(font1);
    fast->setFixedWidth(20);
    slow=new QPushButton("<");
    slow->setFont(font1);
    slow->setFixedWidth(20);
    //pmdstop->setDisabled(true);
    //backDef->setDisabled(true);

    QHBoxLayout *main=new QHBoxLayout;
    QGridLayout *gl=new QGridLayout;

    int size=250;
    p1=new PMD1;
    p1->setFixedSize(size,size);
    p2=new PMD2;
    p2->setFixedSize(size,size);
    p3=new PMD3;
    p3->setFixedSize(size,size);
    p4=new PMD4;
    p4->setFixedSize(size,size);

    gl->addWidget(p1,0,0,1,1,Qt::AlignCenter);
    gl->addWidget(p2,0,1,1,1,Qt::AlignCenter);
    gl->addWidget(p3,1,0,1,1,Qt::AlignCenter);
    gl->addWidget(p4,1,1,1,1,Qt::AlignCenter);
    main->addLayout(gl);

    QVBoxLayout *left=new QVBoxLayout;
    QGridLayout *panel=new QGridLayout;

    panel->addWidget(lm,0,0,1,4,Qt::AlignCenter);
    panel->addWidget(m1,1,0,1,2,Qt::AlignCenter);
    panel->addWidget(m2,1,2,1,2,Qt::AlignCenter);
    panel->addWidget(m3,2,0,1,2,Qt::AlignCenter);
    panel->addWidget(m4,2,2,1,2,Qt::AlignCenter);
    panel->addWidget(rr,3,0,1,2,Qt::AlignRight);
    panel->addWidget(R,3,2,1,2,Qt::AlignCenter);
    panel->addWidget(mm,4,0,1,2,Qt::AlignRight);
    panel->addWidget(M,4,2,1,2,Qt::AlignCenter);
    panel->addWidget(speed,5,0,1,2,Qt::AlignCenter);
    panel->addWidget(slow,5,2,1,1,Qt::AlignCenter);
    panel->addWidget(fast,5,3,1,1,Qt::AlignCenter);
    panel->addWidget(goButton,6,0,1,4,Qt::AlignCenter);
    panel->addWidget(voptions,7,0,1,4,Qt::AlignCenter);
    panel->addWidget(delaxis,8,0,1,4,Qt::AlignCenter);
    panel->addWidget(delmcircle,9,0,1,4,Qt::AlignCenter);
    panel->addWidget(delscircle,10,0,1,4,Qt::AlignCenter);
    panel->addWidget(zoomlabel,11,0,1,4,Qt::AlignCenter);
    panel->addWidget(zoombutton,12,0,1,4,Qt::AlignCenter);
    panel->addWidget(viewoptions,13,0,1,4,Qt::AlignCenter);
    panel->addWidget(backDef,14,0,1,4,Qt::AlignCenter);
    panel->addWidget(pmdstop,15,0,1,4,Qt::AlignCenter);
    //panel->addWidget(space,16,0,1,4,Qt::AlignCenter);
    panel->addWidget(aboutbutton,17,0,1,4,Qt::AlignCenter);
    left->addLayout(panel);
    left->addStretch();
    main->addLayout(left);

    QObject::connect(backDef,SIGNAL(clicked()),this,
                     SLOT(backDefault()));
    QObject::connect(pmdstop,SIGNAL(clicked()),this,
                     SLOT(pmdStop()));
    QObject::connect(goButton,SIGNAL(clicked()),this,
                     SLOT(pmdGo()));
    QObject::connect(fast,SIGNAL(clicked()),this,
                     SLOT(makefast()));
    QObject::connect(slow,SIGNAL(clicked()),this,
                     SLOT(makeslow()));
    QObject::connect(delaxis,SIGNAL(clicked()),this,
                     SLOT(deleteaxis()));
    QObject::connect(delmcircle,SIGNAL(clicked()),this,
                     SLOT(deletemcircle()));
    QObject::connect(delscircle,SIGNAL(clicked()),this,
                     SLOT(deletescircle()));
    QObject::connect(aboutbutton,SIGNAL(clicked()),this,
                     SLOT(about()));
    QObject::connect(zoombutton,SIGNAL(clicked()),this,
                     SLOT(zoom()));
    Dialog::setLayout(main);

    timer = new QTimer(this);

    //connect(timer, SIGNAL(timeout()), p1, SLOT(update()));
    //connect(timer, SIGNAL(timeout()), p2, SLOT(update()));
    //connect(timer, SIGNAL(timeout()), p3, SLOT(update()));
    connect(timer, SIGNAL(timeout()), p4, SLOT(update()));
    timer->start(50);
}
Exemple #8
0
// The start of the Application
int App::start(const std::vector<CL_String> &args)
{
	quit = false;

	// Create a console window for text-output if not available
	CL_ConsoleWindow console("Console");

	try
	{
		CL_DisplayWindow window("ClanLib Font Sprite Test", 1024, 480);

		// Connect the Window close event
		CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close);

		// Connect a keyboard handler to on_key_up()
		CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up);

		// Get the graphic context
		CL_GraphicContext gc = window.get_gc();

		// Load some fonts from the resource file
		CL_ResourceManager resources("font.xml");
		CL_Font_Sprite font1(gc, "Font1", &resources);
		CL_Font_Sprite font2(gc, "Font2", &resources);

		// Run until someone presses escape
		while (!quit)
		{
			gc.set_map_mode(CL_MapMode(cl_map_2d_upper_left));
			gc.clear(CL_Colorf::red);

			font1.draw_text(gc, 25, 25, "ClanLib: Phear the Power!");
			
			font2.draw_text(gc, 3, 155, "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzÆæØøÅå0123456789[]()!#$&%/\\=-+~'`\".,:;*?");

			font2.draw_text(gc, 10.0f, 200.0f, 2.0f, 2.0f, "Hello World\nMy Message");

			// Flip the display, showing on the screen what we have drawed
			// since last call to flip()
			window.flip(1);

			// This call processes user input and other events
			CL_KeepAlive::process();
		}
	}
	catch(CL_Exception& exception)
	{
		CL_Console::write_line("Exception caught:");
		CL_Console::write_line(exception.message);

		// Display the stack trace (if available)
		std::vector<CL_String> stacktrace = exception.get_stack_trace();
		int size = stacktrace.size();
		if (size > 0)
		{
			CL_Console::write_line("Stack Trace:");
			for (int cnt=0; cnt < size; cnt++)
			{
				CL_Console::write_line(stacktrace[cnt]);
			}
		}

		console.display_close_message();

		return -1;
	}
	return 0;
}
void GameWidget::paintEvent(QPaintEvent *e)
{
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing, true);

    painter.setPen(QPen(Qt::black, 1.0));
    int half = cellSize() / 2;
    for (int x = 0; x < board.size(); x++)
        painter.drawLine(cellLeft(x) + half, fromTop() + half, cellLeft(x) + half, cellTop(board.size()) - half);
    for (int y = 0; y < board.size(); y++)
        painter.drawLine(fromLeft() + half, cellTop(y) + half, cellLeft(board.size()) - half, cellTop(y) + half);

    {
        QFont fontBit(fontName, 40, QFont::Normal);
        painter.setFont(fontBit);
        painter.setPen(QPen(Qt::black, 1.0));
        painter.drawText(QRect(15, 0, (width() < height() ? width() : fromLeft()) - 20, 60),
                width() < height() ? Qt::AlignHCenter : Qt::AlignLeft, tr("Game"));

        QFont font(fontName, 24, QFont::Normal);
        painter.setFont(font);
        QString your_point = tr("Your points: ");
        QString boox_point = tr("Boox's points: ");
        if(width() < height())
        {
            QString s= your_point + QString::number(board.getPoints(1))+"        "+
                       boox_point + QString::number(board.getPoints(2));
            painter.drawText(QRect(0, 60, width(), 30), Qt::AlignHCenter, s);
        }
        else
        {
            painter.drawText(QRect(15, 65, fromLeft() - cellSize()/2, 30),
                    Qt::AlignLeft, your_point + QString::number(board.getPoints(1)));
            painter.drawText(QRect(15, 100, fromLeft() - cellSize()/2, 30),
                    Qt::AlignLeft, boox_point + QString::number(board.getPoints(2)));
        }

        painter.setOpacity(1);
        QFont font1(fontName, 40, QFont::Normal);
        painter.setFont(font1);
        painter.setPen(QPen(Qt::black, 1.0));
        if(width() < height())
        {
            if (wygral < 1)
                painter.drawText(0, 90, width(), 50, Qt::AlignHCenter, "...");
            else if (wygral == 1)
                painter.drawText(0, 90, width(), 50, Qt::AlignHCenter, tr("You won!"));
            else if (wygral == 2)
                painter.drawText(0, 90, width(), 50, Qt::AlignHCenter, tr("Boox won!"));
            else
                painter.drawText(0, 90, width(), 50, Qt::AlignHCenter, tr("Draw."));
        }
        else
        {
            if (wygral < 1)
                painter.drawText(15, 160, fromLeft() - cellSize()/2, 60,
                        Qt::AlignLeft, "...");
            else if (wygral == 1)
                painter.drawText(15, 160, fromLeft() - cellSize()/2, 60,
                        Qt::AlignLeft, tr("You won!"));
            else if (wygral == 2)
                painter.drawText(15, 160, fromLeft() - cellSize()/2, 60,
                        Qt::AlignLeft, tr("Boox won!"));
            else
                painter.drawText(15, 160, fromLeft() - cellSize()/2, 60,
                        Qt::AlignLeft, tr("Draw."));
        }
    }

    {
        int x1 = cellLeft(currentX) + 1;
        int y1 = cellTop(currentY) + 1;
        int x2 = cellLeft(currentX) + cellSize() - 1;
        int y2 = y1;
        int x3 = x1;
        int y3 = cellTop(currentY) + cellSize() - 1;
        int x4 = x2;
        int y4 = y3;
        int gap = cellSize() / 3;

        painter.setPen(QPen(Qt::black, 2));
        painter.drawLine(x1, y1, x1+gap, y1);
        painter.drawLine(x1, y1, x1, y1+gap);
        painter.drawLine(x2, y2, x2-gap, y2);
        painter.drawLine(x2, y2, x2, y2+gap);
        painter.drawLine(x3, y3, x3+gap, y3);
        painter.drawLine(x3, y3, x3, y3-gap);
        painter.drawLine(x4, y4, x4-gap, y4);
        painter.drawLine(x4, y4, x4, y4-gap);
    }

    for (int x = 0; x < board.size(); x++)
    for (int y = 0; y < board.size(); y++)
        if (board.is(1, x, y))
        {
            painter.setPen(QPen(Qt::black, 3));
            painter.setBrush(Qt::black);
            painter.drawEllipse(cellLeft(x) + 4, cellTop(y) + 4, cellSize() - 8, cellSize() - 8);
        }
        else if (board.is(2, x, y))
        {
            painter.setPen(QPen(Qt::black, 3));
            painter.setBrush(Qt::white);
            painter.drawEllipse(cellLeft(x) + 4, cellTop(y) + 4, cellSize() - 8, cellSize() - 8);
        }
}
Exemple #10
0
/************
 *
 *功能:绘制背景
 *
 *
 *
 **/
void    mainview::paintEvent(QPaintEvent *)
{

    switch(ui->widgetstack->currentIndex())
    {
        case    0:
        case    2:
        logo_y = this->height()/2 - 200;
        logo_x = this->width()/2 - 100;
        break;
        default:
        logo_y = 50;
        logo_x=this->width()/2-100;
        break;
    }
    switch(ui->widgetstack->currentIndex())
    {
        case  0:
        ui->widgetstack->move(logo_x-80,logo_y+50);
        break;
        case  1://networkconfig
        {
        ui->widgetstack->move(logo_x-150,height()/2-325);
        if(height()/2 > 325)
        ui->widgetstack->resize(461,650);
        break;}
        case  3://wifi
        ui->widgetstack->move(logo_x-50,height()/2-283);
        break;
        case  4://vmlist
        {
                if(this->hostlist->nums_vm <= 12)
                    //vmlist display  order  in  the  windows
                {
                    ui->widgetstack->move(width()/20,this->height()/2-100);
                }
                else if(this->hostlist->nums_vm > 12 && this->hostlist->nums_vm <= 18 )
                {
                    ui->widgetstack->move(width()/20,this->height()/2-200);
                }
                else
                {
                    ui->widgetstack->move(width()/20,this->height()/2-300);
                }
        break;
        }
        default:
        ui->widgetstack->move(logo_x-100,height()/2-80);
        break;

    }
    
    
    
    
    QFont font("Arial",10);
    QPainter painter(this);

    painter.drawPixmap(rect(),QPixmap("./images/terminal-bg.png"));
    painter.drawPixmap(QPoint(logo_x,logo_y),QPixmap("./images/terminal-logo.png"));

    QPixmap  *map = new  QPixmap("./images/information.png");
    painter.drawPixmap(QPoint(this->width()-200,this->height()-50),map->copy(0,map->height()/2,map->width(),
                map->height()/14));//down
    painter.drawPixmap(QPoint(this->width()-100,this->height()-50),map->copy(0,map->height()/2+map->height()/7,//reset
                map->width(),map->height()/14));

    painter.drawPixmap(QPoint(this->width()-70,10),map->copy(0,map->height()/14,map->width(),map->height()/14));//?help
    painter.drawPixmap(QPoint(this->width()-230,10),map->copy(0,map->height()/7+map->height()/14,//reflush
                map->width(),map->height()/14));
    painter.drawPixmap(QPoint(this->width()-270,10),map->copy(0,2*(map->height()/7)+map->height()/14,map->width(),
                                                                  map->height()/14));//more operator
    delete map;

    if(wifi->connectedname.length()<=0)
    {
    map = new  QPixmap("./images/wifi.png");
    painter.drawPixmap(QPoint(this->width()-120,5),map->copy(0,map->height()/2,map->width(),map->height()/2));
    }
    else
    {
    map = new  QPixmap("./images/wifi_img.png"/*wifi->CheckSignals(wifi->choice_signal)*/);
    painter.drawPixmap(QPoint(this->width()-120,5),map->copy(0,10*map->height()/14,map->width(),map->height()/14));
    }

    delete map;

    QFont font1("Arial",10,QFont::Normal,true);
    painter.setFont(font1);//????
    painter.setPen(QColor(Qt::white));
    painter.drawText(155+logo_x,15+logo_y,version);
    painter.setFont(font);//????
    painter.drawText(20,this->height()-30,"Copyright (C)2001-2015 Yovole Corporation, All Rights Reserved");

    font.setPixelSize(13);
    painter.setFont(font);//????
    painter.drawText(this->width()-175,this->height()-30,"关机");
    painter.drawText(this->width()-75,this->height()-30,"重启");
    if(http->login_state == true)
    {
        /*************the  username length is not equal to the drawtext length,there have question.*******/
        //if(hostlist->nums_vm > 0)
        painter.drawText(this->width()-350-(login->GetUserName().length()),30,login->GetUserName());
        //else
        //painter.drawText(this->width()-350,30,"更多操作");
        if(open) 
            emit  loadoperator(1);
    }
    else
    {
        if(open) 
            emit  loadoperator(0);
        painter.drawText(this->width()-350,30,"更多操作");
    }
   
    
    painter.drawText(this->width()-200,30,"刷新列表");
    painter.drawText(this->width()-40,30,"帮助");
    font.setPixelSize(8);
    font.setBold(true);
    painter.setFont(font);
    painter.drawText(this->width()-120,35,wifi->connectedname);

    ui->widgetlist->move(this->width()-350,40);
    
    ui->pushButton->move(this->width()-240,10);
    ui->pushButton_1->move(this->width()-350,10);
    ui->pushButton_2->move(this->width()-120,10);
    ui->pushButton_3->move(this->width()-70,10);
    ui->pushButton_4->move(this->width()-200,this->height()-50);
    ui->pushButton_5->move(this->width()-100,this->height()-50);


}