F:/KPlato/koffice/libs/kofficeui/Kolinestyleaction.cpp

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Peter Simonsson <psn@linux.se>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "Kolinestyleaction.h"
00021 
00022 #include <QPainter>
00023 #include <QPixmap>
00024 #include <QBitmap>
00025 
00026 #include <kmenu.h>
00027 #include <kdebug.h>
00028 #include <klocale.h>
00029 
00030 class KoLineStyleAction::KoLineStyleActionPrivate
00031 {
00032   public:
00033     KoLineStyleActionPrivate()
00034     {
00035       m_currentStyle = Qt::SolidLine;
00036     }
00037     
00038     ~KoLineStyleActionPrivate()
00039     {
00040     }
00041     
00042     int m_currentStyle;
00043 };
00044 
00045 KoLineStyleAction::KoLineStyleAction(const QString &text, const QString& icon,
00046   QObject* parent, const char* name) : KoSelectAction(text, icon, parent, name)
00047 {
00048   d = new KoLineStyleActionPrivate;
00049    
00050   createMenu();
00051 }
00052 
00053 KoLineStyleAction::KoLineStyleAction(const QString &text, const QString& icon, const QObject* receiver,
00054   const char* slot, QObject* parent, const char* name) : KoSelectAction(text, icon, receiver, slot, parent, name)
00055 {
00056   d = new KoLineStyleActionPrivate;
00057   
00058   createMenu();
00059 }
00060 
00061 KoLineStyleAction::~KoLineStyleAction()
00062 {
00063   delete d;
00064 }
00065 
00066 void KoLineStyleAction::createMenu()
00067 {
00068   KMenu* popup = popupMenu();
00069   QBitmap mask;
00070   QPixmap pix(70, 21);
00071   QPainter p(&pix, popup);
00072   int cindex = 0;
00073   QPen pen;
00074   pen.setWidth(2);
00075   popup->insertItem(i18n("None"),cindex++);
00076 
00077   for(int i = 1; i < 6; i++) {
00078     pix.fill(Qt::white);
00079     pen.setStyle(static_cast<Qt::PenStyle>(i));
00080     p.setPen(pen);
00081     p.drawLine(0, 10, pix.width(), 10);
00082     mask = pix;
00083     pix.setMask(mask);
00084     popup->insertItem(pix,cindex++);
00085   }
00086 }
00087 
00088 #include "Kolinestyleaction.moc"

Généré le Wed Nov 22 23:41:05 2006 pour KPlato par  doxygen 1.5.1-p1