lib

KoBorder.h
1/* This file is part of the KDE project
2 Copyright (C) 2000, 2001 Thomas Zander <zander@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KoBorder_h
21#define KoBorder_h
22
23#include <tqcolor.h>
24#include <tqpen.h>
25#include <koffice_export.h>
26class TQDomElement;
27class KoZoomHandler;
28class TQPainter;
29
33class KOTEXT_EXPORT KoBorder : public TQt
34{
35 friend class KoTextCursor;
36public:
37 // Update the DTDs if you add something here!
38 enum BorderStyle {SOLID = 0, DASH = 1, DOT = 2, DASH_DOT = 3, DASH_DOT_DOT = 4, DOUBLE_LINE = 5};
39 enum BorderType { LeftBorder = 0, RightBorder, TopBorder, BottomBorder };
40
41 KoBorder();
42 KoBorder( const TQColor & c, BorderStyle s, double width );
43 TQColor color;
44 void setPenWidth(double _w);
45 void setStyle(BorderStyle _style);
46 // deprecated
47 BorderStyle getStyle() const {return m_style;}
48 BorderStyle style() const {return m_style;}
49 double penWidth() const{ return ptPenWidth;}
50 double width() const { return ptWidth; }
51
52 bool operator==( const KoBorder _brd ) const;
53 bool operator!=( const KoBorder _brd ) const;
54
55 // Load from XML
56 static KoBorder loadBorder( const TQDomElement & elem );
57 void loadFoBorder( const TQString& border );
58 // Save to XML
59 void save( TQDomElement & elem ) const;
60 TQString saveFoBorder() const;
61
62 // String to style enum, and vice versa, for UI.
63 static BorderStyle getStyle( const TQString &style );
64 static TQString getStyle( const BorderStyle &style );
65
66 // Zoom the border width. If ptWidth is 0, minborder is returned.
67 static int zoomWidthX( double ptWidth, KoZoomHandler * zoomHandler, int minborder ); // For left/right borders
68 static int zoomWidthY( double ptWidth, KoZoomHandler * zoomHandler, int minborder ); // For top/bottom borders
69
70 // Get a ready-to-use TQPen for this border.
71 // defaultColor is the color to use for TQColor() - either defaultTextColor() or defaultBgColor().
72 static TQPen borderPen( const KoBorder & brd, int width, TQColor defaultColor );
73
74 // The do-it-all method :)
75 // Draws in @p painter the 4 borders on the _outside_ of @p rect.
76 // If a border is of size 0, minborder will be applied (no border if 0, defaultPen otherwise)
77 static void drawBorders( TQPainter& painter, KoZoomHandler * zoomHandler, const TQRect& rect,
78 const KoBorder& left, const KoBorder& right,
79 const KoBorder& top, const KoBorder& bottom,
80 int minborder, const TQPen& defaultPen, bool drawTopBorder = true , bool drawBottomBorder = true );
81private:
82 double ptWidth;
83 double ptPenWidth;
84 BorderStyle m_style;
85};
86
87/******************************
88 kdDebug support
89*******************************/
90#include <kdebug.h>
91
92inline kdbgstream operator<<( kdbgstream str, const KoBorder & b ) {
93 str << "[ color:" << b.color << " width:" << b.width() << " penWidth:" << b.penWidth() << " style:" << KoBorder::getStyle( b.getStyle() ) << "]"; return str;
94}
95inline kndbgstream operator<<( kndbgstream str, const KoBorder & ) { return str; }
96
97#endif
This class represents a border - for anything, like paragraph, or frame.
Definition KoBorder.h:34
This class handles the zooming and DPI stuff (conversions between pt values and pixels).