lib Library API Documentation

koborder.h

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., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
00018 */
00019 
00020 #ifndef KoBorder_h
00021 #define KoBorder_h
00022 
00023 #include <qcolor.h>
00024 #include <qpen.h>
00025 #include <koffice_export.h>
00026 class QDomElement;
00027 class KoZoomHandler;
00028 class QPainter;
00029 
00033 class KOTEXT_EXPORT KoBorder : public Qt
00034 {
00035 public:
00036     // Update the DTDs if you add something here!
00037     enum BorderStyle {SOLID = 0, DASH = 1, DOT = 2, DASH_DOT = 3, DASH_DOT_DOT = 4, DOUBLE_LINE = 5};
00038 
00039     KoBorder();
00040     KoBorder( const QColor & c, BorderStyle s, double width );
00041     QColor color;
00042     void setPenWidth(double _w);
00043     void setStyle(BorderStyle _style);
00044     // deprecated
00045     BorderStyle getStyle() const {return m_style;}
00046     BorderStyle style() const {return m_style;}
00047     double penWidth() const{ return ptPenWidth;}
00048     double width() const { return ptWidth; }
00049 
00050     bool operator==( const KoBorder _brd ) const;
00051     bool operator!=( const KoBorder _brd ) const;
00052 
00053     // Load from XML
00054     static KoBorder loadBorder( const QDomElement & elem );
00055     void loadFoBorder( const QString& border );
00056     // Save to XML
00057     void save( QDomElement & elem ) const;
00058     QString saveFoBorder() const;
00059 
00060     // String to style enum, and vice versa, for UI.
00061     static BorderStyle getStyle( const QString &style );
00062     static QString getStyle( const BorderStyle &style );
00063 
00064     // Zoom the border width. If ptWidth is 0, minborder is returned.
00065     static int zoomWidthX( double ptWidth, KoZoomHandler * zoomHandler, int minborder ); // For left/right borders
00066     static int zoomWidthY( double ptWidth, KoZoomHandler * zoomHandler, int minborder ); // For top/bottom borders
00067 
00068     // Get a ready-to-use QPen for this border.
00069     // defaultColor is the color to use for QColor() - either defaultTextColor() or defaultBgColor().
00070     static QPen borderPen( const KoBorder & brd, int width, QColor defaultColor );
00071 
00072     // The do-it-all method :)
00073     // Draws in @p painter the 4 borders on the _outside_ of @p rect.
00074     // If a border is of size 0, minborder will be applied (no border if 0, defaultPen otherwise)
00075     static void drawBorders( QPainter& painter, KoZoomHandler * zoomHandler, const QRect& rect,
00076                              const KoBorder& left, const KoBorder& right,
00077                              const KoBorder& top, const KoBorder& bottom,
00078                              int minborder, const QPen& defaultPen );
00079 private:
00080     double ptWidth;
00081     double ptPenWidth;
00082     BorderStyle m_style;
00083 };
00084 
00085 /******************************
00086   kdDebug support
00087 *******************************/
00088 #include <kdebug.h>
00089 
00090 inline kdbgstream operator<<( kdbgstream str, const KoBorder & b )  {
00091     str << "[ color:" << b.color << " width:" << b.width() << " penWidth:" << b.penWidth() << " style:" << KoBorder::getStyle( b.getStyle() ) << "]"; return str;
00092 }
00093 inline kndbgstream operator<<( kndbgstream str, const KoBorder & )  { return str; }
00094 
00095 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:39:59 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003