summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/fifteen/fifteen.cpp83
-rw-r--r--noncore/games/fifteen/fifteen.h12
-rw-r--r--noncore/games/fifteen/fifteen.pro4
-rw-r--r--noncore/games/fifteen/main.cpp20
4 files changed, 70 insertions, 49 deletions
diff --git a/noncore/games/fifteen/fifteen.cpp b/noncore/games/fifteen/fifteen.cpp
index 2e4ed94..b4e0308 100644
--- a/noncore/games/fifteen/fifteen.cpp
+++ b/noncore/games/fifteen/fifteen.cpp
@@ -1,5 +1,5 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** This file is part of the Qtopia Environment.
**
@@ -22,4 +22,4 @@
-#include <qpe/resource.h>
-#include <qpe/config.h>
+#include <qtopia/resource.h>
+#include <qtopia/config.h>
@@ -31,3 +31,3 @@
#include <qmessagebox.h>
-#include <qpe/qpetoolbar.h>
+#include <qtoolbar.h>
#include <qmenubar.h>
@@ -35,2 +35,3 @@
#include <qapplication.h>
+#include <qtoolbutton.h>
@@ -39,4 +40,4 @@
-FifteenMainWindow::FifteenMainWindow(QWidget *parent, const char* name)
- : QMainWindow( parent, name )
+FifteenMainWindow::FifteenMainWindow(QWidget *parent, const char* name, WFlags fl)
+ : QMainWindow( parent, name, fl )
{
@@ -44,15 +45,8 @@ FifteenMainWindow::FifteenMainWindow(QWidget *parent, const char* name)
srand(time(0));
-
- setToolBarsMovable( FALSE );
- QVBox *vbox = new QVBox( this );
- PiecesTable *table = new PiecesTable( vbox );
- setCentralWidget(vbox);
+ setCaption( tr("Fifteen Pieces") );
QToolBar *toolbar = new QToolBar(this);
- toolbar->setHorizontalStretchable( TRUE );
- addToolBar(toolbar);
-
+ toolbar->setHorizontalStretchable( FALSE );
QMenuBar *menubar = new QMenuBar( toolbar );
menubar->setMargin(0);
-
QPopupMenu *game = new QPopupMenu( this );
@@ -63,2 +57,10 @@ FifteenMainWindow::FifteenMainWindow(QWidget *parent, const char* name)
+
+ setToolBarsMovable( FALSE );
+ QVBox *vbox = new QVBox( this );
+ PiecesTable *table = new PiecesTable( vbox );
+ setCentralWidget(vbox);
+
+
+
QAction *a = new QAction( tr( "Randomize" ), Resource::loadPixmap( "new" ),
@@ -69,3 +71,4 @@ FifteenMainWindow::FifteenMainWindow(QWidget *parent, const char* name)
- a = new QAction( tr( "Solve" ), Resource::loadPixmap( "repeat" ),
+ /* This is pointless and confusing.
+ a = new QAction( tr( "Solve" ), Resource::loadIconSet( "repeat" ),
QString::null, 0, this, 0 );
@@ -74,3 +77,3 @@ FifteenMainWindow::FifteenMainWindow(QWidget *parent, const char* name)
a->addTo( toolbar );
-
+ */
menubar->insertItem( tr( "Game" ), game );
@@ -111,3 +114,3 @@ void PiecesTable::writeConfig()
QStringList map;
- for (unsigned int i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++)
map.append( QString::number( _map[i] ) );
@@ -123,3 +126,3 @@ void PiecesTable::readConfig()
_randomized = cfg.readBoolEntry( "Randomized", FALSE );
- unsigned int i = 0;
+ int i = 0;
for ( QStringList::Iterator it = map.begin(); it != map.end(); ++it ) {
@@ -148,10 +151,11 @@ void PiecesTable::paintCell(QPainter *p, int row, int col)
+ if (number == 16) return;
+
// draw borders
if (height() > 40) {
- p->setPen(colorGroup().text());
- if(col < numCols()-1)
- p->drawLine(x2, 0, x2, y2); // right border line
+ p->setBrush(_colors[number-1].light(130));
+ p->drawPolygon(light_border);
- if(row < numRows()-1)
- p->drawLine(0, y2, x2, y2); // bottom boder line
+ p->setBrush(_colors[number-1].dark(130));
+ p->drawPolygon(dark_border);
}
@@ -159,3 +163,2 @@ void PiecesTable::paintCell(QPainter *p, int row, int col)
// draw number
- if (number == 16) return;
p->setPen(black);
@@ -170,2 +173,26 @@ void PiecesTable::resizeEvent(QResizeEvent *e)
setCellHeight(contentsRect().height() / numCols());
+
+ //
+ // Calculate 3d-effect borders
+ //
+ int cell_w = cellWidth();
+ int cell_h = cellHeight();
+ int x_offset = cell_w - int(cell_w * 0.9); // 10% should be enough
+ int y_offset = cell_h - int(cell_h * 0.9);
+
+ light_border.setPoints(6,
+ 0, 0,
+ cell_w, 0,
+ cell_w - x_offset, y_offset,
+ x_offset, y_offset,
+ x_offset, cell_h - y_offset,
+ 0, cell_h);
+
+ dark_border.setPoints(6,
+ cell_w, 0,
+ cell_w, cell_h,
+ 0, cell_h,
+ x_offset, cell_h - y_offset,
+ cell_w - x_offset, cell_h - y_offset,
+ cell_w - x_offset, y_offset);
}
@@ -183,3 +210,3 @@ void PiecesTable::initMap()
_map.resize(16);
- for (unsigned int i = 0; i < 16; i++)
+ for ( int i = 0; i < 16; i++)
_map[i] = i;
@@ -243,4 +270,4 @@ void PiecesTable::randomizeMap()
_map[pos=(col + row * numCols())] = 15;
- repaint();
}
+ repaint();
}
diff --git a/noncore/games/fifteen/fifteen.h b/noncore/games/fifteen/fifteen.h
index 703a8a7..58eb756 100644
--- a/noncore/games/fifteen/fifteen.h
+++ b/noncore/games/fifteen/fifteen.h
@@ -1,5 +1,5 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** This file is part of the Qtopia Environment.
**
@@ -26,2 +26,3 @@
#include <qarray.h>
+#include <qpointarray.h>
@@ -59,2 +60,4 @@ class PiecesTable : public QTableView
bool _randomized;
+ QPointArray light_border;
+ QPointArray dark_border;
@@ -79,3 +82,6 @@ class FifteenMainWindow : public QMainWindow
public:
- FifteenMainWindow(QWidget *parent=0, const char* name=0);
+ static QString appName() {
+ return QString::fromLatin1("fifteen");
+ }
+ FifteenMainWindow(QWidget *parent=0, const char* name=0, WFlags fl=0);
};
diff --git a/noncore/games/fifteen/fifteen.pro b/noncore/games/fifteen/fifteen.pro
index 43d336d..14ea3c9 100644
--- a/noncore/games/fifteen/fifteen.pro
+++ b/noncore/games/fifteen/fifteen.pro
@@ -1,4 +1,2 @@
-DESTDIR = $(OPIEDIR)/bin
-TEMPLATE = app
-CONFIG = qt warn_on release
+CONFIG = qt warn_on release quick-app
HEADERS = fifteen.h
diff --git a/noncore/games/fifteen/main.cpp b/noncore/games/fifteen/main.cpp
index 4838a36..74a7368 100644
--- a/noncore/games/fifteen/main.cpp
+++ b/noncore/games/fifteen/main.cpp
@@ -1,5 +1,5 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
+** Copyright (C) 2004 Holger Freyther. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** This file is part of Opie Environment.
**
@@ -15,5 +15,2 @@
**
-** Contact info@trolltech.com if any conditions of this licensing are
-** not clear to you.
-**
**********************************************************************/
@@ -22,12 +19,5 @@
-#include <qpe/qpeapplication.h>
+#include <opie/oapplicationfactory.h>
+
+OPIE_EXPORT_APP( OApplicationFactory<FifteenMainWindow> )
-int main( int argc, char ** argv)
-{
- QPEApplication app( argc, argv );
-
- FifteenMainWindow mw;
- mw.setCaption( FifteenMainWindow::tr("Fifteen Pieces") );
- app.showMainWidget( &mw );
- return app.exec();
-}