34#include <KDFrameProfileSection.h>
35#include <KDXMLTools.h>
37#if defined( SUN7 ) || defined( _SGIAPI )
43#define M_PI 3.14159265358979323846
49 _profileSections.clear();
64 if( TQt::NoBrush != _background.style() ) {
65 TQPen oldPen( painter.pen() );
66 TQPoint oldOrig( painter.brushOrigin() );
67 TQBrush oldBrush( painter.brush() );
68 painter.setPen( TQt::NoPen );
69 const TQPoint newTopLeft( painter.xForm( innerRect.topLeft() ) );
70 painter.setBrushOrigin( newTopLeft.x(), newTopLeft.y() );
71 painter.setBrush( _background );
74 painter.setPen( oldPen );
75 painter.setBrushOrigin( oldOrig );
76 painter.setBrush( oldBrush );
79 if( ! _backPixmap.isNull() ) {
81 if( PixCentered == _backPixmapMode )
83 ol.setX( innerRect.center().x() - _backPixmap.width() / 2 );
84 ol.setY( innerRect.center().y() - _backPixmap.height()/ 2 );
85 bitBlt( painter.device(), ol, &_backPixmap );
88 double zW = (double) innerRect.width() / (double)_backPixmap.width();
89 double zH = (double) innerRect.height() / (double)_backPixmap.height();
90 switch ( _backPixmapMode ) {
103 TQPixmap pm = _backPixmap.xForm( m );
104 ol.setX( innerRect.center().x() - pm.width() / 2 );
105 ol.setY( innerRect.center().y() - pm.height()/ 2 );
106 bitBlt( painter.device(), ol, &pm );
121 if( !_topProfile.isEmpty() ){
124 for ( section = ((KDFrameProfile)_topProfile).last(); section; section = ((KDFrameProfile)_topProfile).prev() ){
125 const TQPen oldPen = painter.pen();
126 const TQBrush oldBrush = painter.brush();
128 thePen = section->pen();
129 int penWidth = TQMAX(thePen.width(), 1) * TQMAX(section->width(), 1);
133 thePen.setWidth( penWidth );
134 painter.setPen( thePen );
135 painter.setBrush( TQt::NoBrush );
136 painter.drawRect( innerRect.x()-penWidth,
140 painter.setBrush( oldBrush );
141 painter.setPen( oldPen );
163 case PaintBackground:
189 case ProfileTop: _topProfile.clear();
191 case ProfileRight: _rightProfile.clear();
193 case ProfileBottom:_bottomProfile.clear();
195 case ProfileLeft: _leftProfile.clear();
221 case ProfileTop: _topProfile = profile;
223 case ProfileRight: _rightProfile = profile;
225 case ProfileBottom:_bottomProfile = profile;
227 case ProfileLeft: _leftProfile = profile;
235 case ProfileTop: return _topProfile;
237 case ProfileRight: return _rightProfile;
239 case ProfileBottom: return _bottomProfile;
241 default: return _leftProfile;
253 const TQPixmap* backPixmap,
256 _profileSections.clear();
258 _rightProfile.clear();
259 _bottomProfile.clear();
260 _leftProfile.clear();
262 _backPixmap = backPixmap ? *backPixmap : TQPixmap();
263 _backPixmapMode = backPixmapMode;
264 if( FrameFlat == frame ) {
268 KDFrameProfileSection::CvtPlain,
270 _profileSections.append( newsection );
274 _topProfile.append( newsection );
275 _rightProfile = _topProfile;
276 _bottomProfile = _topProfile;
277 _leftProfile = _topProfile;
281 case FrameElegance: {
282 int line1 = lineWidth / 8;
283 int line2 = lineWidth / 16;
285 int gap2 = line2 * 4;
286 int gap1 = lineWidth - line1 - line2 - line3 - gap2;
287 TQPen noP( TQt::NoPen );
290 KDFrameProfileSection::CvtPlain,
292 _profileSections.append( newsection );
293 _topProfile.append( newsection );
295 KDFrameProfileSection::CvtPlain,
297 _profileSections.append( newsection );
298 _topProfile.append( newsection );
300 KDFrameProfileSection::CvtPlain,
302 _profileSections.append( newsection );
303 _topProfile.append( newsection );
305 KDFrameProfileSection::CvtPlain,
307 _profileSections.append( newsection );
308 _topProfile.append( newsection );
310 KDFrameProfileSection::CvtPlain,
312 _profileSections.append( newsection );
313 _topProfile.append( newsection );
320 KDFrameProfileSection::CvtPlain,
322 _profileSections.append( newsection );
323 _topProfile.append( newsection );
325 KDFrameProfileSection::CvtPlain,
327 _profileSections.append( newsection );
328 _topProfile.append( newsection );
330 KDFrameProfileSection::CvtPlain,
332 _profileSections.append( newsection );
333 _topProfile.append( newsection );
340 KDFrameProfileSection::CvtPlain,
342 _profileSections.append( newsection );
343 _topProfile.append( newsection );
345 KDFrameProfileSection::CvtPlain,
347 _profileSections.append( newsection );
348 _topProfile.append( newsection );
350 KDFrameProfileSection::CvtPlain,
352 _profileSections.append( newsection );
353 _topProfile.append( newsection );
356 case FramePanelRaized:
360 KDFrameProfileSection::CvtPlain,
362 _profileSections.append( newsection );
363 _topProfile.append( newsection );
366 case FramePanelSunken:
370 KDFrameProfileSection::CvtPlain,
372 _profileSections.append( newsection );
373 _topProfile.append( newsection );
376 case FrameSemicircular:
380 KDFrameProfileSection::CvtConvex,
382 _profileSections.append( newsection );
383 _topProfile.append( newsection );
385 KDFrameProfileSection::CvtPlain,
387 _profileSections.append( newsection );
388 _topProfile.append( newsection );
390 KDFrameProfileSection::CvtConcave,
392 _profileSections.append( newsection );
393 _topProfile.append( newsection );
400 _rightProfile = _topProfile;
401 _bottomProfile = _topProfile;
402 _leftProfile = _topProfile;
408 const TQString& elementName,
411 TQDomElement frameElement = document.createElement( elementName );
412 parent.appendChild( frameElement );
413 KDXML::createIntNode( document, frameElement, "ShadowWidth",
414 frame._shadowWidth );
415 KDXML::createStringNode( document, frameElement, "CornerName",
418 KDXML::createBrushNode( document, frameElement, "Background",
420 KDXML::createPixmapNode( document, frameElement, "BackPixmap",
422 KDXML::createStringNode( document, frameElement, "BackPixmapMode",
425 KDXML::createRectNode( document, frameElement, "InnerRect",
430 frame._rightProfile );
432 frame._bottomProfile );
434 frame._leftProfile );
446 const TQString& elementName,
449 TQDomElement profileElement = document.createElement( elementName );
450 parent.appendChild( profileElement );
462 const TQString& elementName,
465 TQDomElement cornerElement = document.createElement( elementName );
466 parent.appendChild( cornerElement );
467 KDXML::createStringNode( document, cornerElement, "Style",
469 KDXML::createIntNode( document, cornerElement, "Width",
480 TQBrush tempBackground;
481 TQPixmap tempBackPixmap;
483 TQRect tempInnerRect;
484 KDFrameProfile tempTopProfile, tempRightProfile,
485 tempBottomProfile, tempLeftProfile;
486 KDFrameCorner tempCornerTL, tempCornerTR, tempCornerBL, tempCornerBR;
487 TQDomNode node = element.firstChild();
488 while( !node.isNull() ) {
489 TQDomElement element = node.toElement();
490 if( !element.isNull() ) {
491 TQString tagName = element.tagName();
492 if( tagName == "ShadowWidth" ) {
493 ok = ok & KDXML::readIntNode( element, tempShadowWidth );
494 } else if( tagName == "CornerName" ) {
496 ok = ok & KDXML::readStringNode( element, value );
498 } else if( tagName == "Background" ) {
499 ok = ok & KDXML::readBrushNode( element, tempBackground );
500 } else if( tagName == "BackPixmap" ) {
501 ok = ok & KDXML::readPixmapNode( element, tempBackPixmap );
502 } else if( tagName == "BackPixmapMode" ) {
504 ok = ok & KDXML::readStringNode( element, value );
506 } else if( tagName == "InnerRect" ) {
507 ok = ok & KDXML::readRectNode( element, tempInnerRect );
508 } else if( tagName == "TopProfile" ) {
510 } else if( tagName == "RightProfile" ) {
512 } else if( tagName == "BottomProfile" ) {
514 } else if( tagName == "LeftProfile" ) {
516 } else if( tagName == "CornerTL" ) {
519 } else if( tagName == "CornerTR" ) {
522 } else if( tagName == "CornerBL" ) {
525 } else if( tagName == "CornerBR" ) {
529 tqDebug( "Unknown tag in frame" );
532 node = node.nextSibling();
536 frame._shadowWidth = tempShadowWidth;
537 frame._sunPos = tempCornerName;
538 frame._background = tempBackground;
539 frame._backPixmap = tempBackPixmap;
540 frame._backPixmapMode = tempBackPixmapMode;
541 frame._innerRect = tempInnerRect;
542 frame._topProfile = tempTopProfile;
543 frame._rightProfile = tempRightProfile;
544 frame._bottomProfile = tempBottomProfile;
545 frame._leftProfile = tempLeftProfile;
546 frame._cornerTL = tempCornerTL;
547 frame._cornerTR = tempCornerTR;
548 frame._cornerBL = tempCornerBL;
549 frame._cornerBR = tempCornerBR;
559 TQDomNode node = element.firstChild();
560 while( !node.isNull() ) {
561 TQDomElement element = node.toElement();
562 if( !element.isNull() ) {
563 TQString tagName = element.tagName();
564 if( tagName == "ProfileSection" ) {
570 tqDebug( "Unknown tag in double map" );
574 node = node.nextSibling();
587 KDFrameProfile tempProfile;
588 TQDomNode node = element.firstChild();
589 while( !node.isNull() ) {
590 TQDomElement element = node.toElement();
591 if( !element.isNull() ) {
592 TQString tagName = element.tagName();
593 if( tagName == "Style" ) {
595 ok = ok & KDXML::readStringNode( element, value );
597 } else if( tagName == "Width" ) {
598 ok = ok & KDXML::readIntNode( element, tempWidth );
599 } else if( tagName == "Profile" ) {
603 tqDebug( "Unknown tag in frame" );
606 node = node.nextSibling();
610 corner._style = tempStyle;
611 corner._width = tempWidth;
612 corner._profile = tempProfile;
618#include "KDFrame.moc"
Header of the KDFrame class providing highly configurable rectangular frame drawing.
Settings for one profile section of one side of the frame.
static void createFrameProfileSectionNode(TQDomDocument &document, TQDomNode &parent, const TQString &elementName, const KDFrameProfileSection *section) Creates a DOM element node that represents a frame profile section for use in a DOM document.
Curvature Profile Curvature Mode: specifying the shape of a frame profile section.
Direction Profile Direction Mode: specifying whether a part of a profile looks embossed or engraved in comparis...
static bool readFrameProfileSectionNode(const TQDomElement &element, KDFrameProfileSection *section) Reads data from a DOM element node that represents a frame profile section and fills a KDFrameProfile...
virtual ~KDFrameCorner() Destructor.
static void createFrameCornerNode(TQDomDocument &document, TQDomNode &parent, const TQString &elementName, const KDFrameCorner &corner)
static bool readFrameCornerNode(const TQDomElement &element, KDFrameCorner &corner)
The main class of KDFrame.
const KDFrameProfile & profile(ProfileName name) const
static BackPixmapMode stringToBackPixmapMode(const TQString &string) Converts the specified string to a background pixmap mode enum value.
BackPixmapMode These are ways how to display a pixmap that might be painted into the inner area.
void addProfileSection(ProfileName name, int wid, TQPen pen, KDFrameProfileSection::Direction dir=KDFrameProfileSection::DirPlain, KDFrameProfileSection::Curvature curv=KDFrameProfileSection::CvtPlain)
KDFramePaintSteps The different steps taken to paint the frame: first paint the background then the edges then the corn...
TQRect innerRect() const Returns the position and the size of the frame.
SimpleFrame These simple frames are pre-defined for your convenience.
virtual void paint(TQPainter *painter, KDFramePaintSteps steps=PaintAll, TQRect innerRect=TQRect(0, 0, 0, 0)) const Paint methode actually drawing the frame.
static void createFrameNode(TQDomDocument &document, TQDomNode &parent, const TQString &elementName, const KDFrame &frame) Creates a DOM element node that represents a frame for use in a DOM document.
void clearProfile(ProfileName name)
static CornerName stringToCornerName(const TQString &string)
static TQString cornerStyleToString(CornerStyle type)
virtual void paintCorners(TQPainter &painter, const TQRect &innerRect) const Paint methode drawing the corners (if any) of the frame.
void setProfile(ProfileName name, const KDFrameProfile &profile)
virtual ~KDFrame() Destructor.
static void createFrameProfileNode(TQDomDocument &document, TQDomNode &parent, const TQString &elementName, KDFrameProfile profile) Creates a DOM element node that represents a frame profile for use in a DOM document.
virtual void paintEdges(TQPainter &painter, const TQRect &innerRect) const Paint methode drawing the edges (if any) of the frame.
static bool readFrameNode(const TQDomElement &element, KDFrame &frame) Reads data from a DOM element node that represents a frame object and fills a KDFrame object with the...
static TQString cornerNameToString(CornerName type)
void setSimpleFrame(SimpleFrame frame, int lineWidth, int midLineWidth, TQPen pen, TQBrush background=TQBrush(), const TQPixmap *backPixmap=0, BackPixmapMode backPixmapMode=PixStretched)
static TQString backPixmapModeToString(BackPixmapMode type) Converts the specified background pixmap mode enum to a string representation.
static bool readFrameProfileNode(const TQDomElement &element, KDFrameProfile &profile) Reads data from a DOM element node that represents a frame profile and fills a KDFrameProfile object ...
void setCorners(CornerStyle style, int width, KDFrameProfile *const profile=0)
static CornerStyle stringToCornerStyle(const TQString &string)
virtual void paintBackground(TQPainter &painter, const TQRect &innerRect) const Paint methode drawing the background (if any) of the frame.
const TQBrush & background(const TQPixmap *&backPixmap, BackPixmapMode &backPixmapMode) const Returns the brush that is used to fill the inner area of this frame, or a TQBrush( \cNoBrush ) if no ...
|