diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
commit | 8362bf63dea22bbf6736609b0f49c152f975eb63 (patch) | |
tree | 0eea3928e39e50fae91d4e68b21b1e6cbae25604 /lib/kotext/KoBorder.h | |
download | koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip |
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'lib/kotext/KoBorder.h')
-rw-r--r-- | lib/kotext/KoBorder.h | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/lib/kotext/KoBorder.h b/lib/kotext/KoBorder.h new file mode 100644 index 00000000..4e577ac9 --- /dev/null +++ b/lib/kotext/KoBorder.h @@ -0,0 +1,97 @@ +/* This file is part of the KDE project + Copyright (C) 2000, 2001 Thomas Zander <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef KoBorder_h +#define KoBorder_h + +#include <qcolor.h> +#include <qpen.h> +#include <koffice_export.h> +class QDomElement; +class KoZoomHandler; +class QPainter; + +/** + * This class represents a border - for anything, like paragraph, or frame + */ +class KOTEXT_EXPORT KoBorder : public Qt +{ + friend class KoTextCursor; +public: + // Update the DTDs if you add something here! + enum BorderStyle {SOLID = 0, DASH = 1, DOT = 2, DASH_DOT = 3, DASH_DOT_DOT = 4, DOUBLE_LINE = 5}; + enum BorderType { LeftBorder = 0, RightBorder, TopBorder, BottomBorder }; + + KoBorder(); + KoBorder( const QColor & c, BorderStyle s, double width ); + QColor color; + void setPenWidth(double _w); + void setStyle(BorderStyle _style); + // deprecated + BorderStyle getStyle() const {return m_style;} + BorderStyle style() const {return m_style;} + double penWidth() const{ return ptPenWidth;} + double width() const { return ptWidth; } + + bool operator==( const KoBorder _brd ) const; + bool operator!=( const KoBorder _brd ) const; + + // Load from XML + static KoBorder loadBorder( const QDomElement & elem ); + void loadFoBorder( const QString& border ); + // Save to XML + void save( QDomElement & elem ) const; + QString saveFoBorder() const; + + // String to style enum, and vice versa, for UI. + static BorderStyle getStyle( const QString &style ); + static QString getStyle( const BorderStyle &style ); + + // Zoom the border width. If ptWidth is 0, minborder is returned. + static int zoomWidthX( double ptWidth, KoZoomHandler * zoomHandler, int minborder ); // For left/right borders + static int zoomWidthY( double ptWidth, KoZoomHandler * zoomHandler, int minborder ); // For top/bottom borders + + // Get a ready-to-use QPen for this border. + // defaultColor is the color to use for QColor() - either defaultTextColor() or defaultBgColor(). + static QPen borderPen( const KoBorder & brd, int width, QColor defaultColor ); + + // The do-it-all method :) + // Draws in @p painter the 4 borders on the _outside_ of @p rect. + // If a border is of size 0, minborder will be applied (no border if 0, defaultPen otherwise) + static void drawBorders( QPainter& painter, KoZoomHandler * zoomHandler, const QRect& rect, + const KoBorder& left, const KoBorder& right, + const KoBorder& top, const KoBorder& bottom, + int minborder, const QPen& defaultPen, bool drawTopBorder = true , bool drawBottomBorder = true ); +private: + double ptWidth; + double ptPenWidth; + BorderStyle m_style; +}; + +/****************************** + kdDebug support +*******************************/ +#include <kdebug.h> + +inline kdbgstream operator<<( kdbgstream str, const KoBorder & b ) { + str << "[ color:" << b.color << " width:" << b.width() << " penWidth:" << b.penWidth() << " style:" << KoBorder::getStyle( b.getStyle() ) << "]"; return str; +} +inline kndbgstream operator<<( kndbgstream str, const KoBorder & ) { return str; } + +#endif |