kchart
KDFrame Class Reference
#include <KDFrame.h>
Detailed Description
The main class of KDFrame.KDFrame is made for highly configurable rectangular frame drawing.
A frame may consist of an (optional) border and/or an (optional) background. v200 This class is work in progress, at present only single line frame borders and (scaled/streched) background pictures are available. See KDChartParams::setSimpleFrame() to learn how to use them.
The border may consist of up to four edges and/or up to four border corners.
- Note:
- Each of the edges and each of the corners may use their own user-definable profile.
Some commonly used frame profiles (e.g. raised box, sunken panel) are predefined in SimpleFrame, see setSimpleFrame(). To learn how to specify your frame profiles have a look at example code given with setProfile()
Definition at line 87 of file KDFrame.h.
Public Types | |
PixCentered | |
PixScaled | |
PixStretched | |
FrameFlat | |
FrameElegance | |
FrameBoxRaized | |
FrameBoxSunken | |
FramePanelRaized | |
FramePanelSunken | |
FrameSemicircular | |
ProfileTop | |
ProfileRight | |
ProfileBottom | |
ProfileLeft | |
CornerTopLeft | |
CornerTopRight | |
CornerBottomLeft | |
CornerBottomRight | |
CornerUNKNOWN | |
CornerNormal | |
CornerRound | |
CornerOblique | |
PaintBackground | |
PaintEdges | |
PaintCorners | |
PaintBorder | |
PaintAll | |
enum | BackPixmapMode { PixCentered, PixScaled, PixStretched } |
enum | SimpleFrame { FrameFlat, FrameElegance, FrameBoxRaized, FrameBoxSunken, FramePanelRaized, FramePanelSunken, FrameSemicircular } |
enum | ProfileName { ProfileTop, ProfileRight, ProfileBottom, ProfileLeft } |
enum | CornerName { CornerTopLeft, CornerTopRight, CornerBottomLeft, CornerBottomRight, CornerUNKNOWN } |
enum | CornerStyle { CornerNormal, CornerRound, CornerOblique } |
enum | KDFramePaintSteps { PaintBackground, PaintEdges, PaintCorners, PaintBorder, PaintAll } |
Public Slots | |
static QString | backPixmapModeToString (BackPixmapMode type) |
static BackPixmapMode | stringToBackPixmapMode (const QString &string) |
void | setSimpleFrame (SimpleFrame frame, int lineWidth, int midLineWidth, QPen pen, QBrush background=QBrush(), const QPixmap *backPixmap=0, BackPixmapMode backPixmapMode=PixStretched) |
void | clearProfile (ProfileName name) |
void | addProfileSection (ProfileName name, int wid, QPen pen, KDFrameProfileSection::Direction dir=KDFrameProfileSection::DirPlain, KDFrameProfileSection::Curvature curv=KDFrameProfileSection::CvtPlain) |
void | setProfile (ProfileName name, const KDFrameProfile &profile) |
const KDFrameProfile & | profile (ProfileName name) const |
static QString | cornerNameToString (CornerName type) |
static CornerName | stringToCornerName (const QString &string) |
static QString | cornerStyleToString (CornerStyle type) |
static CornerStyle | stringToCornerStyle (const QString &string) |
void | setCorner (CornerName name, CornerStyle style, int width, KDFrameProfile *const profile=0) |
void | setCorners (CornerStyle style, int width, KDFrameProfile *const profile=0) |
CornerStyle | cornerStyle (CornerName name) const |
int | cornerWidth (CornerName name) const |
const KDFrameProfile & | cornerProfile (CornerName name) const |
void | setSunPos (CornerName sunPos) |
CornerName | sunPos () const |
void | setBackground (QBrush background=QBrush(Qt::NoBrush)) |
void | setBackPixmap (const QPixmap *backPixmap=0, BackPixmapMode backPixmapMode=PixStretched) |
const QBrush & | background (const QPixmap *&backPixmap, BackPixmapMode &backPixmapMode) const |
void | setInnerRect (QRect innerRect) |
QRect | innerRect () const |
virtual void | paintBackground (QPainter &painter, const QRect &innerRect) const |
virtual void | paintEdges (QPainter &painter, const QRect &innerRect) const |
virtual void | paintCorners (QPainter &painter, const QRect &innerRect) const |
virtual void | paint (QPainter *painter, KDFramePaintSteps steps=PaintAll, QRect innerRect=QRect(0, 0, 0, 0)) const |
void | clearAll () |
Signals | |
void | changed () |
Public Member Functions | |
KDFrame (QRect innerRect=QRect(0, 0, 0, 0), SimpleFrame frame=FrameFlat, int lineWidth=1, int midLineWidth=0, QPen pen=QPen(), QBrush background=QBrush(), const QPixmap *backPixmap=0, BackPixmapMode backPixmapMode=PixStretched, int shadowWidth=0, CornerName sunPos=CornerTopLeft) | |
virtual | ~KDFrame () |
Static Public Member Functions | |
static void | deepCopy (KDFrame &D, const KDFrame &R) |
static void | createFrameNode (QDomDocument &document, QDomNode &parent, const QString &elementName, const KDFrame &frame) |
static void | createFrameProfileNode (QDomDocument &document, QDomNode &parent, const QString &elementName, KDFrameProfile profile) |
static bool | readFrameNode (const QDomElement &element, KDFrame &frame) |
static bool | readFrameProfileNode (const QDomElement &element, KDFrameProfile &profile) |
Friends | |
QTextStream & | operator<< (QTextStream &s, const KDFrame &p) |
QTextStream & | operator>> (QTextStream &s, KDFrame &p) |
Classes | |
class | KDFrameCorner |
Member Enumeration Documentation
enum KDFrame::CornerName |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
enum KDFrame::CornerStyle |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
The different steps taken to paint the frame: first paint the background then the edges then the corners.
By choosing PaintAll
all the parts of the frame will be drawn.
PaintBackground
-- first paints the brush, then paints the pixmap if anyPaintEdges
PaintCorners
PaintBorder
-- paint the edges and the corners but not the backgroundPaintAll
- See also:
- paint
enum KDFrame::ProfileName |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
enum KDFrame::SimpleFrame |
These simple frames are pre-defined for your convenience.
FrameFlat
a flat rectangular frameFrameElegance
a flat frame consisting of three linesFrameBoxRaized
a raised boxFrameBoxSunken
a sunken boxFramePanelRaized
a raised panelFramePanelSunken
a sunken panelFrameSemicircular
a raised box with round edges
Constructor & Destructor Documentation
KDFrame::KDFrame | ( | QRect | innerRect = QRect(0,0,0,0) , |
|
SimpleFrame | frame = FrameFlat , |
|||
int | lineWidth = 1 , |
|||
int | midLineWidth = 0 , |
|||
QPen | pen = QPen() , |
|||
QBrush | background = QBrush() , |
|||
const QPixmap * | backPixmap = 0 , |
|||
BackPixmapMode | backPixmapMode = PixStretched , |
|||
int | shadowWidth = 0 , |
|||
CornerName | sunPos = CornerTopLeft | |||
) | [inline] |
Default Constructor.
Defines default values.
The constructor does *not* have a parent
parameter since drawing of the frame is not done transparently but by (one or more) explicit calls of the frames paint() methode. See explanation given there to learn about the why and how of this...
- Note:
- The rectangle applies to the inner area of the frame. The Frame is drawn around this area: touching it but not covering it. The outer size of the frame and the position of its outer left corner depends from the frame profile width.
To have a 'tiled' background image do not specify a backPixmap but use a background brush holding this pixmap.
- See also:
- rect, setInnerRect, setProfile
KDFrame::~KDFrame | ( | ) | [virtual] |
Member Function Documentation
void KDFrame::addProfileSection | ( | ProfileName | name, | |
int | wid, | |||
QPen | pen, | |||
KDFrameProfileSection::Direction | dir = KDFrameProfileSection::DirPlain , |
|||
KDFrameProfileSection::Curvature | curv = KDFrameProfileSection::CvtPlain | |||
) | [slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
Definition at line 200 of file KDFrame.cpp.
const QBrush& KDFrame::background | ( | const QPixmap *& | backPixmap, | |
BackPixmapMode & | backPixmapMode | |||
) | const [inline, slot] |
Returns the brush that is used to fill the inner area of this frame, or a QBrush( ) if no background is to be drawn.
- Parameters:
-
backPixmap receives the pixmap used for drawing the background or a null pixmap, test this by calling backPixmap.isNull()
- Note:
- If a 'tiled' background image is shown the respective pixmap may be found by calling the brush's pixmap() function.
- See also:
- setBackground, setBackPixmap
static QString KDFrame::backPixmapModeToString | ( | BackPixmapMode | type | ) | [inline, static, slot] |
void KDFrame::changed | ( | ) | [signal] |
This signal is emitted when any of the frame parameters has changed.
void KDFrame::clearAll | ( | ) | [inline, slot] |
void KDFrame::clearProfile | ( | ProfileName | name | ) | [slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
Definition at line 186 of file KDFrame.cpp.
static QString KDFrame::cornerNameToString | ( | CornerName | type | ) | [inline, static, slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
const KDFrameProfile& KDFrame::cornerProfile | ( | CornerName | name | ) | const [inline, slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
CornerStyle KDFrame::cornerStyle | ( | CornerName | name | ) | const [inline, slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
static QString KDFrame::cornerStyleToString | ( | CornerStyle | type | ) | [inline, static, slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
int KDFrame::cornerWidth | ( | CornerName | name | ) | const [inline, slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
void KDFrame::createFrameNode | ( | QDomDocument & | document, | |
QDomNode & | parent, | |||
const QString & | elementName, | |||
const KDFrame & | frame | |||
) | [static] |
Creates a DOM element node that represents a frame for use in a DOM document.
- Parameters:
-
document the DOM document to which the node will belong parent the parent node to which the new node will be appended elementName the name of the new node frame the frame to be represented
Definition at line 407 of file KDFrame.cpp.
void KDFrame::createFrameProfileNode | ( | QDomDocument & | document, | |
QDomNode & | parent, | |||
const QString & | elementName, | |||
KDFrameProfile | profile | |||
) | [static] |
Creates a DOM element node that represents a frame profile for use in a DOM document.
- Parameters:
-
document the DOM document to which the node will belong parent the parent node to which the new node will be appended elementName the name of the new node profile the profile to be represented
Definition at line 445 of file KDFrame.cpp.
QRect KDFrame::innerRect | ( | ) | const [inline, slot] |
Returns the position and the size of the frame.
- Note:
- The rectangle returns to the inner area of the frame. The Frame is drawn around this area: touching it but not covering it. The outer size of the frame and the position of its outer left corner depends from the frame profile width.
- See also:
- setInnerRect, setProfile
void KDFrame::paint | ( | QPainter * | painter, | |
KDFramePaintSteps | steps = PaintAll , |
|||
QRect | innerRect = QRect(0, 0, 0, 0) | |||
) | const [virtual, slot] |
Paint methode actually drawing the frame.
This method must be called from inside the paint()
methode of your widget.
In order not to override the inner contents of the frame you normally would first call paint( painter, PaintBackground ); then do all the inside drawing and finally call paint( painter, PaintBorder );. In case the inner contents are allowed to (partially) override the frame border you could do the following: First call paint( painter, PaintBackground ); immediately followed by paint( painter, PaintEdges ); then do all your inside work and finally draw paint( painter, PaintCorners );.
- Parameters:
-
painter The QPainter to be used for drawing. steps The part of the frame to be drawn, use KDFrame::PaintAll to draw the entire frame and the background, use KDFrame::PaintBackground to draw only the background, use KDFrame::PaintEdges to draw just the edges, use KDFrame::PaintCorners to draw only the corners. innerRect The area inside the frame. Use this parameter to temporarily override the innerRect
set by the constructor of KDFrame or by setInnerRect(). This approach can be usefull if you want to draw several frames that differ only regarding to their position and size but share the same edges/corners/background settings. In this case you could decide to instantiate only one KDFrame set up the desired settings and just call its paint() methode several time - giving it the appropriate innerRect for each frame. This would result in less memory usage since you could use that single KDFrame object as kind of a shared ressource.
Definition at line 156 of file KDFrame.cpp.
void KDFrame::paintBackground | ( | QPainter & | painter, | |
const QRect & | innerRect | |||
) | const [virtual, slot] |
Paint methode drawing the background (if any) of the frame.
- Note:
- Under normal circumstances you will never have to call this methode since it is called internally by paint() if you start it with
PaintBackground
(or withPaintAll
, resp.) for thesteps
parameter.
Definition at line 61 of file KDFrame.cpp.
void KDFrame::paintCorners | ( | QPainter & | painter, | |
const QRect & | innerRect | |||
) | const [virtual, slot] |
Paint methode drawing the corners (if any) of the frame.
- Note:
- Under normal circumstances you will never have to call this methode since it is called internally by paint() if you start it with
PaintCorners
(or withPaintAll
,PaintBorder
, resp.) for thesteps
parameter.
Definition at line 147 of file KDFrame.cpp.
void KDFrame::paintEdges | ( | QPainter & | painter, | |
const QRect & | innerRect | |||
) | const [virtual, slot] |
Paint methode drawing the edges (if any) of the frame.
- Note:
- Under normal circumstances you will never have to call this methode since it is called internally by paint() if you start it with
PaintEdges
(or withPaintAll
,PaintBorder
, resp.) for thesteps
parameter.
Definition at line 112 of file KDFrame.cpp.
const KDFrameProfile & KDFrame::profile | ( | ProfileName | name | ) | const [slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
Definition at line 232 of file KDFrame.cpp.
bool KDFrame::readFrameNode | ( | const QDomElement & | element, | |
KDFrame & | frame | |||
) | [static] |
Reads data from a DOM element node that represents a frame object and fills a KDFrame object with the data.
- Parameters:
-
element the DOM element to read from frame the frame object to read the data into
Definition at line 475 of file KDFrame.cpp.
bool KDFrame::readFrameProfileNode | ( | const QDomElement & | element, | |
KDFrameProfile & | profile | |||
) | [static] |
Reads data from a DOM element node that represents a frame profile and fills a KDFrameProfile object with the data.
- Parameters:
-
element the DOM element to read from profile the frame profile object to read the data into
Definition at line 556 of file KDFrame.cpp.
void KDFrame::setBackground | ( | QBrush | background = QBrush( Qt::NoBrush ) |
) | [inline, slot] |
Specifies the brush to be used to fill the inner area of this frame, calling this methode without passing in a parameter re-sets the background brush to QBrush
( NoBrush ).
- Note:
- To have a 'tiled' background image just use a brush holding this pixmap - for other ways to show background images please use setBackPixmap.
- See also:
- setBackPixmap, background
void KDFrame::setBackPixmap | ( | const QPixmap * | backPixmap = 0 , |
|
BackPixmapMode | backPixmapMode = PixStretched | |||
) | [inline, slot] |
Specifies a pixmap to be used to fill the inner area of this frame, calling this methode without passing in a parameter removes the background pixmap.
- Note:
- To have a 'tiled' background image do not use setBackPixmap but use setBackground specifying a brush holding the pixmap.
- See also:
- setBackground, background
void KDFrame::setCorner | ( | CornerName | name, | |
CornerStyle | style, | |||
int | width, | |||
KDFrameProfile *const | profile = 0 | |||
) | [inline, slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
void KDFrame::setCorners | ( | CornerStyle | style, | |
int | width, | |||
KDFrameProfile *const | profile = 0 | |||
) | [inline, slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
void KDFrame::setInnerRect | ( | QRect | innerRect | ) | [inline, slot] |
Specifies the position and the size of area that is surrounded by the frame.
- Note:
- The rectangle applies to the inner area of the frame. The Frame is drawn around this area: touching it but not covering it. The outer size of the frame and the position of its outer left corner depends from the frame profile width(s).
- See also:
- innerRect, setCorners, setSimpleFrame, setProfile
void KDFrame::setProfile | ( | ProfileName | name, | |
const KDFrameProfile & | profile | |||
) | [slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
Definition at line 218 of file KDFrame.cpp.
void KDFrame::setSimpleFrame | ( | SimpleFrame | frame, | |
int | lineWidth, | |||
int | midLineWidth, | |||
QPen | pen, | |||
QBrush | background = QBrush() , |
|||
const QPixmap * | backPixmap = 0 , |
|||
BackPixmapMode | backPixmapMode = PixStretched | |||
) | [slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
Definition at line 248 of file KDFrame.cpp.
void KDFrame::setSunPos | ( | CornerName | sunPos | ) | [inline, slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
static BackPixmapMode KDFrame::stringToBackPixmapMode | ( | const QString & | string | ) | [inline, static, slot] |
static CornerName KDFrame::stringToCornerName | ( | const QString & | string | ) | [inline, static, slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
static CornerStyle KDFrame::stringToCornerStyle | ( | const QString & | string | ) | [inline, static, slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
CornerName KDFrame::sunPos | ( | ) | const [inline, slot] |
- Deprecated:
- Feature scheduled for future release, at present not implemented.
Friends And Related Function Documentation
QTextStream& operator<< | ( | QTextStream & | s, | |
const KDFrame & | p | |||
) | [friend] |
QTextStream& operator>> | ( | QTextStream & | s, | |
KDFrame & | p | |||
) | [friend] |
The documentation for this class was generated from the following files: