Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

canvasshapes.cpp

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #include <qgfx_qws.h>
00021 #include "canvasshapes.h"
00022 
00023 
00024 CanvasRoundRect::CanvasRoundRect(int x, int y, QCanvas *canvas) :
00025         QCanvasRectangle( x, y, ( qt_screen->deviceWidth() < 200 ) ? 20 : 23, ( qt_screen->deviceWidth() < 200 ) ? 27 : 36, canvas)
00026 {
00027     setZ(0);
00028     show();
00029 }
00030 
00031 
00032 void CanvasRoundRect::redraw()
00033 {
00034     hide();
00035     show();
00036 }
00037 
00038 
00039 void CanvasRoundRect::drawShape(QPainter &p)
00040 {
00041     if ( qt_screen->deviceWidth() < 200 )
00042         p.drawRoundRect( (int)x() + 1, (int)y() + 1, 18, 25);
00043     else
00044         p.drawRoundRect( (int)x(), (int)y(), 23, 36);
00045 }
00046 
00047 
00048 CanvasCircleOrCross::CanvasCircleOrCross(int x, int y, QCanvas *canvas) :
00049         QCanvasRectangle( x, y, 21, 21, canvas), circleShape(TRUE)
00050 {
00051     show();
00052 }
00053 
00054 
00055 void CanvasCircleOrCross::redraw()
00056 {
00057     hide();
00058     show();
00059 }
00060 
00061 
00062 void CanvasCircleOrCross::setCircle()
00063 {
00064     circleShape = TRUE;
00065     redraw();
00066 }
00067 
00068 
00069 void CanvasCircleOrCross::setCross()
00070 {
00071     circleShape = FALSE;
00072     redraw();
00073 }
00074 
00075 
00076 void CanvasCircleOrCross::drawShape(QPainter &p)
00077 {
00078     if ( qt_screen->deviceWidth() < 200 ) {
00079         int x1 = (int)x(), y1 = (int)y();
00080         // Green circle
00081         if (circleShape == TRUE) {
00082             p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) );
00083             p.drawEllipse( x1 - 1, y1 - 1, 17, 17);
00084             p.drawEllipse( x1 - 1, y1 - 0, 17, 15);
00085             p.drawEllipse( x1 + 0, y1 + 0, 15, 15);
00086             p.drawEllipse( x1 + 1, y1 + 0, 13, 15);
00087             p.drawEllipse( x1 + 1, y1 + 1, 13, 13);
00088         // Red cross
00089         } else {
00090             p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 4 ) );
00091             p.drawLine( x1, y1, x1 + 14, y1 + 14);
00092             p.drawLine( x1 + 14, y1, x1, y1 + 14);
00093         }
00094     } else {
00095         int x1 = (int)x(), y1 = (int)y();
00096         // Green circle
00097         if (circleShape == TRUE) {
00098             p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) );
00099             p.drawEllipse( x1 - 1, y1 - 1, 21, 21);
00100             p.drawEllipse( x1 - 1, y1 - 0, 21, 19);
00101             p.drawEllipse( x1 + 0, y1 + 0, 19, 19);
00102             p.drawEllipse( x1 + 1, y1 + 0, 17, 19);
00103             p.drawEllipse( x1 + 1, y1 + 1, 17, 17);
00104         // Red cross
00105         } else {
00106             p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 5 ) );
00107             p.drawLine( x1, y1, x1 + 20, y1 + 20);
00108             p.drawLine( x1 + 20, y1, x1, y1 + 20);
00109         }
00110     }
00111 }
00112 

Generated on Sat Nov 5 16:17:25 2005 for OPIE by  doxygen 1.4.2