Пример #1
0
void CStartMenuView::OnDraw(CDC* dc)
{
	// TODO: Fügen Sie hier Ihren spezialisierten Code ein, und/oder rufen Sie die Basisklasse auf.
	AssertBotE((CBotEDoc*)GetDocument());

	CMyMemDC pDC(dc);
	CRect client;
	GetClientRect(&client);

	// Graphicsobjekt, in welches gezeichnet wird anlegen
	Graphics g(pDC->GetSafeHdc());

	g.Clear(static_cast<Gdiplus::ARGB>(Color::Black));
	g.SetSmoothingMode(SmoothingModeHighSpeed);
	g.SetInterpolationMode(InterpolationModeLowQuality);
	g.SetPixelOffsetMode(PixelOffsetModeHighSpeed);
	g.SetCompositingQuality(CompositingQualityHighSpeed);
	g.ScaleTransform((REAL)client.Width() / (REAL)m_TotalSize.cx, (REAL)client.Height() / (REAL)m_TotalSize.cy);

	// zum Start nur einen schwarzen Hintergrund mit Welcome Nachricht anzeigen
	if (m_nLogoTimer < 2)
	{
		Gdiplus::Font font(L"Calibri", 25, FontStyleBold);
		StringFormat format;
		format.SetAlignment(StringAlignmentCenter);
		format.SetLineAlignment(StringAlignmentCenter);

		CString s= CLoc::GetString("PRESENTEDBY")+"\n\n"+CLoc::GetString("PRESENTED");
		g.DrawString(CComBSTR(s), -1, &font, RectF(0, 0, m_TotalSize.cx, m_TotalSize.cy), &format, &SolidBrush(static_cast<Gdiplus::ARGB>(Color::WhiteSmoke)));

		g.ReleaseHDC(pDC->GetSafeHdc());
		// nichts weiter Zeichnen
		return;
	}

	// Hintergrundbild anzeigen
	g.DrawImage(m_pBkgndImg, 0, 0, m_TotalSize.cx, m_TotalSize.cy);

	Gdiplus::Font font(L"Calibri", 10, FontStyleBold);
	StringFormat format;
	format.SetAlignment(StringAlignmentFar);
	format.SetLineAlignment(StringAlignmentFar);

	CString sVersion = "Birth of the Empires Alpha7 V";
	sVersion += CString(VERSION_INFORMATION.c_str());
	sVersion += "\n© by Sir Pustekuchen 2014";
	g.DrawString(CComBSTR(sVersion), -1, &font, RectF(0, 0, m_TotalSize.cx, m_TotalSize.cy), &format, &SolidBrush(static_cast<Gdiplus::ARGB>(Color::WhiteSmoke)));

	// Hintergrundbild langsam einblenden
	if (m_nTimeCounter < 255)
	{
		Color clr(255 - m_nTimeCounter, 0, 0, 0);
		g.FillRectangle(&Gdiplus::SolidBrush(clr), RectF(0, 0, m_TotalSize.cx, m_TotalSize.cy));

		Gdiplus::Font font(L"Calibri", 25, FontStyleBold);
		StringFormat format;
		format.SetAlignment(StringAlignmentCenter);
		format.SetLineAlignment(StringAlignmentCenter);

		Color clr2(max(0, 255 - m_nTimeCounter * 1.2), 245,245,245);
		CString s= CLoc::GetString("PRESENTEDBY")+"\n\n"+CLoc::GetString("PRESENTED");
		g.DrawString(CComBSTR(s), -1, &font, RectF(0, 0, m_TotalSize.cx, m_TotalSize.cy), &format, &SolidBrush(clr2));
	}

	g.ReleaseHDC(pDC->GetSafeHdc());
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{


    //ui->setupUi(this);
    QGridLayout* gamefield = new QGridLayout();
    config *current=new config();

    QColor clr(255,255,255);
    QPalette qw(clr);
    QColor clr2(9,227,89);
    QPalette qw2(clr2);

    for(int i=0;i<25;i++)
    {
        for(int j=0;j<25;j++)
        {

            my_cell *mWidget= new my_cell(this);
            current->array[i][j]=mWidget;

            mWidget->setAutoFillBackground(1);
            if(i==0 || i==24 || j==24 || j==0)
            {
                mWidget->setVisible(false);

            gamefield->addWidget(mWidget,i,j);
            }
            else
            {

            mWidget->setPalette(qw);
            gamefield->addWidget(mWidget,i,j);

            }
        }
    }

    this->setWindowTitle("Life");

    QWidget* w = new QWidget(this);

    QPushButton *btn1=new QPushButton("GO");
    QPushButton *stahp=new QPushButton("STOP");
     QPushButton *clearz=new QPushButton("CLEAR");
    gamefield->addWidget(btn1,1,26);
   gamefield->addWidget(stahp,2,26);
   gamefield->addWidget(clearz,3,26);

    connect(btn1,SIGNAL(clicked()),current,SLOT(woohoo()));
    connect(stahp,SIGNAL(clicked()),current,SLOT(stop()));
      connect(clearz,SIGNAL(clicked()),current,SLOT(clear()));




    gamefield->setHorizontalSpacing(1);
     gamefield->setVerticalSpacing(1);
    w->setLayout(gamefield);
    this->setCentralWidget(w);
    w->setFixedHeight(600);
    w->setFixedWidth(600);
    w->setMaximumHeight(601);
     w->setMaximumWidth(601);
     this->setMaximumHeight(600);
     this->setMaximumHeight(600);







}