F:/KPlato/koffice/libs/kotext/KoBorder.h

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2000, 2001 Thomas Zander <zander@kde.org>
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 #ifndef KoBorder_h
00021 #define KoBorder_h
00022 
00023 #include <QColor>
00024 #include <QPen>
00025 #include <koffice_export.h>
00026 class QDomElement;
00027 class KoZoomHandler;
00028 class QPainter;
00029 class QRect;
00030 
00034 class KOTEXT_EXPORT KoBorder
00035 {
00036     friend class KoTextCursor;
00037 public:
00038     // Update the DTDs if you add something here!
00039     enum BorderStyle {SOLID = 0, DASH = 1, DOT = 2, DASH_DOT = 3, DASH_DOT_DOT = 4, DOUBLE_LINE = 5};
00040     enum BorderType { LeftBorder = 0, RightBorder, TopBorder, BottomBorder };
00041 
00042     KoBorder();
00043     KoBorder( const QColor & c, BorderStyle s, double width );
00044     QColor color;
00045     void setPenWidth(double _w);
00046     void setStyle(BorderStyle _style);
00047     // deprecated
00048     BorderStyle getStyle() const {return m_style;}
00049     BorderStyle style() const {return m_style;}
00050     double penWidth() const{ return ptPenWidth;}
00051     double width() const { return ptWidth; }
00052 
00053     bool operator==( const KoBorder _brd ) const;
00054     bool operator!=( const KoBorder _brd ) const;
00055 
00056     // Load from XML
00057     static KoBorder loadBorder( const QDomElement & elem );
00058     void loadFoBorder( const QString& border );
00059     // Save to XML
00060     void save( QDomElement & elem ) const;
00061     QString saveFoBorder() const;
00062 
00063     // String to style enum, and vice versa, for UI.
00064     static BorderStyle getStyle( const QString &style );
00065     static QString getStyle( const BorderStyle &style );
00066 
00067     // Zoom the border width. If ptWidth is 0, minborder is returned.
00068     static int zoomWidthX( double ptWidth, KoZoomHandler * zoomHandler, int minborder ); // For left/right borders
00069     static int zoomWidthY( double ptWidth, KoZoomHandler * zoomHandler, int minborder ); // For top/bottom borders
00070 
00071     // Get a ready-to-use QPen for this border.
00072     // defaultColor is the color to use for QColor() - either defaultTextColor() or defaultBgColor().
00073     static QPen borderPen( const KoBorder & brd, int width, QColor defaultColor );
00074 
00075     // The do-it-all method :)
00076     // Draws in @p painter the 4 borders on the _outside_ of @p rect.
00077     // If a border is of size 0, minborder will be applied (no border if 0, defaultPen otherwise)
00078     static void drawBorders( QPainter& painter, KoZoomHandler * zoomHandler, const QRect& rect,
00079                              const KoBorder& left, const KoBorder& right,
00080                              const KoBorder& top, const KoBorder& bottom,
00081                              int minborder, const QPen& defaultPen, bool drawTopBorder = true , bool drawBottomBorder = true );
00082 private:
00083     double ptWidth;
00084     double ptPenWidth;
00085     BorderStyle m_style;
00086 };
00087 
00088 /******************************
00089   kDebug support
00090 *******************************/
00091 #include <kdebug.h>
00092 
00093 inline kdbgstream operator<<( kdbgstream str, const KoBorder & b )  {
00094     str << "[ color:" << b.color << " width:" << b.width() << " penWidth:" << b.penWidth() << " style:" << KoBorder::getStyle( b.getStyle() ) << "]"; return str;
00095 }
00096 inline kndbgstream operator<<( kndbgstream str, const KoBorder & )  { return str; }
00097 
00098 #endif

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