This commit is contained in:
jb
2009-03-21 11:25:52 +00:00
parent 2e68340b3a
commit bc7c8fad43
4 changed files with 146 additions and 6 deletions

View File

@@ -14,11 +14,17 @@
BoardArea::BoardArea (QWidget *parent) : QWidget(parent)
{
setBackgroundRole(QPalette::Base);
penBorder.setColor (QColor (95,13,15));
penBorder.setWidth (4);
penLine.setColor (QColor (95,13,15));
penLine.setWidth (1);
}
QSize BoardArea::minimumSizeHint() const
{
return QSize(270, 270);
return QSize(270, 300);
}
QSize BoardArea::sizeHint() const
@@ -28,10 +34,31 @@ QSize BoardArea::sizeHint() const
void BoardArea::paintEvent(QPaintEvent *)
{
QRect rect(10, 20, 80, 60);
int i;
QPoint start (10,10);
QPainter painter(this);
painter.drawLine(QPoint (10,10), QPoint (200, 200));
painter.restore();
painter.setFont (QFont ("Courier", 14));
/* Draw the border of the of areas.*/
painter.setPen (penBorder);
for (i = 4; i < 360; i+= 90) {
/* Verticales*/
painter.drawLine(start+QPoint (i,4), start+QPoint (i, 274));
/* Horiz. */
painter.drawLine(start + QPoint (4,i), start + QPoint (274, i));
}
/* Draw the interior lines. */
painter.setPen (penLine);
for (i = 34; i < 360; i+= 30) {
/* Verticales*/
painter.drawLine(start+QPoint (i,4), start+QPoint (i, 274));
/* Horiz. */
painter.drawLine(start+QPoint (4, i), start+QPoint (274, i));
}
for (i = 24; i < 270; i+= 30) {
painter.drawText (i, 35, "6");
}
}
/* This function draw the complet board. */

View File

@@ -6,7 +6,10 @@
#ifndef BOARDAREA_H
#define BOARDAREA_H
#include <QWidget>
#include <QPen>
#include <QWidget>
class BoardArea : public QWidget
{
@@ -22,6 +25,10 @@ protected:
private:
void drawBoard ();
private:
QPen penBorder;
QPen penLine;
};

View File

@@ -14,7 +14,7 @@ int main (int argc, char **argv)
QApplication a (argc, argv);
/* Create a new Sudoku object. */
Sudoku * mw = new Sudoku ();
mw->resize (300,300);
mw->resize (300,340);
mw->show();
return a.exec();
}