KDFrame Class Reference

The main class of KDFrame. More...

#include <KDFrame.h>

Inheritance diagram for KDFrame:

QObject
Collaboration diagram for KDFrame:

Collaboration graph
[legend]

List of all members.

Public Types

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 KDFrameProfileprofile (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 KDFrameProfilecornerProfile (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)

Private Member Functions

 KDFrame (const KDFrame &)
KDFrameoperator= (const KDFrame &)
void setProfileSectionsAutoDelete (bool on) const

Private Attributes

int _shadowWidth
CornerName _sunPos
QBrush _background
QPixmap _backPixmap
BackPixmapMode _backPixmapMode
QRect _innerRect
KDFrameProfile _profileSections
KDFrameProfile _topProfile
KDFrameProfile _rightProfile
KDFrameProfile _bottomProfile
KDFrameProfile _leftProfile
KDFrameCorner _cornerTL
KDFrameCorner _cornerTR
KDFrameCorner _cornerBL
KDFrameCorner _cornerBR

Friends

QTextStream & operator<< (QTextStream &s, const KDFrame &p)
QTextStream & operator>> (QTextStream &s, KDFrame &p)

Classes

class  KDFrameCorner


Detailed Description

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.
The frame corners ( see types defined in CornerStyle ) are set up via setCorner()

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()


Member Enumeration Documentation

These are ways how to display a pixmap that might be painted into the inner area.

To have a 'tiled' background image do not use a background pixmap but use a background brush holding this pixmap.

Enumerator:
PixCentered 
PixScaled 
PixStretched 

These simple frames are pre-defined for your convenience

  • FrameFlat a flat rectangular frame
  • FrameElegance a flat frame consisting of three lines
  • FrameBoxRaized a raised box
  • FrameBoxSunken a sunken box
  • FramePanelRaized a raised panel
  • FramePanelSunken a sunken panel
  • FrameSemicircular a raised box with round edges
All pre-defined frames have normal corners.
Enumerator:
FrameFlat 
FrameElegance 
FrameBoxRaized 
FrameBoxSunken 
FramePanelRaized 
FramePanelSunken 
FrameSemicircular 

Deprecated:
Feature scheduled for future release, at present not implemented.
Enumerator:
ProfileTop 
ProfileRight 
ProfileBottom 
ProfileLeft 

Deprecated:
Feature scheduled for future release, at present not implemented.
Enumerator:
CornerTopLeft 
CornerTopRight 
CornerBottomLeft 
CornerBottomRight 
CornerUNKNOWN 

Deprecated:
Feature scheduled for future release, at present not implemented.
Enumerator:
CornerNormal 
CornerRound 
CornerOblique 

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 any
  • PaintEdges
  • PaintCorners
  • PaintBorder -- paint the edges and the corners but not the background
  • PaintAll
See also:
paint
Enumerator:
PaintBackground 
PaintEdges 
PaintCorners 
PaintBorder 
PaintAll 


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 ( const KDFrame  )  [inline, private]

virtual KDFrame::~KDFrame (  )  [virtual]

Destructor. Only defined to have it virtual.


Member Function Documentation

static QString KDFrame::backPixmapModeToString ( BackPixmapMode  type  )  [inline, static, slot]

Converts the specified background pixmap mode enum to a string representation.

Parameters:
type the background pixmap mode to convert
Returns:
the string representation of the background pixmap mode enum

static BackPixmapMode KDFrame::stringToBackPixmapMode ( const QString &  string  )  [inline, static, slot]

Converts the specified string to a background pixmap mode enum value.

Parameters:
string the string to convert
Returns:
the background pixmap mode enum value

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.

void KDFrame::clearProfile ( ProfileName  name  )  [slot]

Deprecated:
Feature scheduled for future release, at present not implemented.

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.

void KDFrame::setProfile ( ProfileName  name,
const KDFrameProfile profile 
) [slot]

Deprecated:
Feature scheduled for future release, at present not implemented.

const KDFrameProfile& KDFrame::profile ( ProfileName  name  )  const [slot]

Deprecated:
Feature scheduled for future release, at present not implemented.

static QString KDFrame::cornerNameToString ( CornerName  type  )  [inline, static, slot]

Deprecated:
Feature scheduled for future release, at present not implemented.

static CornerName KDFrame::stringToCornerName ( const QString &  string  )  [inline, static, 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.

static CornerStyle KDFrame::stringToCornerStyle ( const QString &  string  )  [inline, static, slot]

Deprecated:
Feature scheduled for future release, at present not implemented.

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.

CornerStyle KDFrame::cornerStyle ( CornerName  name  )  const [inline, 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.

const KDFrameProfile& KDFrame::cornerProfile ( CornerName  name  )  const [inline, slot]

Deprecated:
Feature scheduled for future release, at present not implemented.

void KDFrame::setSunPos ( CornerName  sunPos  )  [inline, 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.

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 ).

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.

To have a 'tiled' background image do not use setBackPixmap but use setBackground specifying a brush holding the pixmap.

See also:
setBackground, background

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()
If a 'tiled' background image is shown the respective pixmap may be found by calling the brush's pixmap() function.

See also:
setBackground, setBackPixmap

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

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

virtual 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 with PaintAll, resp.) for the steps parameter.

virtual 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 with PaintAll, PaintBorder, resp.) for the steps parameter.

virtual 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 with PaintAll, PaintBorder, resp.) for the steps parameter.

virtual 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.

void KDFrame::clearAll (  )  [inline, slot]

Remove all settings and specify no border, no edges, no background.

KDFrame& KDFrame::operator= ( const KDFrame  )  [inline, private]

static void KDFrame::deepCopy ( KDFrame D,
const KDFrame R 
) [inline, static]

static 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

static 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

static 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

static 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

void KDFrame::changed (  )  [signal]

This signal is emitted when any of the frame parameters has changed.

void KDFrame::setProfileSectionsAutoDelete ( bool  on  )  const [inline, private]


Friends And Related Function Documentation

QTextStream& operator<< ( QTextStream &  s,
const KDFrame p 
) [friend]

Writes the KDFrame object p as an XML document to the text stream s.

Parameters:
s the text stream to write to
p the KDFrame object to write
Returns:
the text stream after the write operation

QTextStream& operator>> ( QTextStream &  s,
KDFrame p 
) [friend]

Reads the an XML document from the text stream s into the KDFrame object p

Parameters:
s the text stream to read from
p the KDFrame object to read into
Returns:
the text stream after the read operation


Member Data Documentation

int KDFrame::_shadowWidth [private]

Stores the width of the shadow.

Stores the position of the sun.

QBrush KDFrame::_background [private]

Stores the brush to be used to fill the inner area.

QPixmap KDFrame::_backPixmap [private]

Stores the pixmap to be painted into the inner area.

Stores the way how to display the pixmap that is to be painted into the inner area.

QRect KDFrame::_innerRect [private]

Stores the position and size of the frame.

Stores all currently used profile settings for a controlled deletion.

Note:
The other pointer lists (like _topProfile or _rightProfile) do NOT delete the objects that belong to their pointers, but all sections will be deleted via this extra _profileSections list: this allows for using the same KDFrameProfileSection* to be used by several lists - typically done for simple frames where all 4 sides are composed the same way.

Stores the profile settings for the top side of the frame.

Stores the profile settings for the right side of the frame.

Stores the profile settings for the bottom side of the frame.

Stores the profile settings for the left side of the frame.

Stores the settings for the top left corner of the frame.

Stores the settings for the top right corner of the frame.

Stores the settings for the bottom left corner of the frame.

Stores the settings for the bottom right corner of the frame.


The documentation for this class was generated from the following file:

Generated on Wed Jan 26 13:06:56 2011 for KMyMoney by  doxygen 1.5.6