Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

liquid.cpp

Go to the documentation of this file.
00001 #include "liquid.h"
00002 
00003 #include <qapplication.h>
00004 #include <qdrawutil.h>
00005 
00006 
00007 LiquidDecoInterface::LiquidDecoInterface ( ) 
00008 {
00009 }
00010     
00011 LiquidDecoInterface::~LiquidDecoInterface ( )
00012 {
00013 }
00014 
00015 
00016 
00017 QString LiquidDecoInterface::name ( ) const
00018 {
00019         return qApp-> translate ( "Decoration", "Liquid" );
00020 }
00021 
00022 
00023 QPixmap LiquidDecoInterface::icon ( ) const
00024 {
00025         return QPixmap ( );
00026 }            
00027         
00028 void LiquidDecoInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const
00029 {
00030         QRect r = wd-> rect;
00031         int th = metric ( TitleHeight, wd );
00032 
00033         switch ( a ) {
00034                 case WindowDecorationInterface::Border: {
00035                         const QColorGroup &cg = wd-> palette. active ( );
00036                         qDrawWinPanel ( p, r. x ( ) - metric ( LeftBorder, wd ),
00037                                 r. y ( ) - th - metric ( TopBorder, wd ),
00038                                 r. width ( ) + metric ( LeftBorder, wd ) + metric ( RightBorder, wd ),
00039                                 r. height ( ) + th + metric ( TopBorder,wd) + metric ( BottomBorder, wd ),
00040                                 cg, false, &cg. brush ( QColorGroup::Background ));
00041                         break;
00042                 }
00043                 case WindowDecorationInterface::Title: {
00044                         const QColorGroup &cg = wd-> palette. active ( );
00045                         
00046                         QBrush titleBrush;
00047                         QPen   titleLines1, titleLines2;
00048 
00049                         titleBrush = cg. brush (( wd-> flags & WindowData::Active ) ? QColorGroup::Highlight : QColorGroup::Background );
00050                         titleLines1 = titleBrush. color ( ). dark ( 105 );
00051                         titleLines2 = titleBrush. color ( ). dark ( 103 );
00052                         
00053                         p-> fillRect ( r. x ( ), r. y ( ) - th, r. width ( ), th, titleBrush );
00054                         for ( int i = r.y()-th; i < r.y(); i += 4 ) {
00055                                 p-> setPen ( titleLines1 );
00056                                 p-> drawLine ( r. left ( ), i, r. right ( ), i );
00057                                 p-> setPen ( titleLines2 );
00058                                 p-> drawLine ( r. left ( ), i+1, r. right ( ), i+1 );
00059                         }
00060                         break;
00061                 }
00062                 case WindowDecorationInterface::TitleText: {
00063                         QColor textcol = wd-> palette. active ( ). color (( wd-> flags & WindowData::Active ) ? QColorGroup::HighlightedText : QColorGroup::Text );
00064                         QColor shadecol = ( qGray ( textcol. rgb ( ) ) > 128 ) ? textcol. dark ( 230 ) : textcol.light( 300 );
00065                         if ( textcol == shadecol ) {
00066                                 if ( qGray ( shadecol. rgb ( ) ) < 128 )
00067                                         shadecol = QColor ( 225, 225, 225 );
00068                                 else
00069                                         shadecol = QColor ( 30, 30, 30 );
00070                         }                       
00071                         QColor fillcol = wd-> palette. active ( ). color (( wd-> flags & WindowData::Active ) ? QColorGroup::Highlight : QColorGroup::Background );
00072                         QColor bordercol = fillcol. dark ( 110 );
00073                         fillcol = fillcol. light ( 110 );
00074                         
00075                         QRect tr ( r.x ( ) + 3 + metric ( HelpWidth, wd ), r. top ( ) - th,
00076                                 r. width ( ) - metric ( OKWidth, wd ) - metric ( CloseWidth, wd ), th );
00077 
00078                         QFont f = p-> font ( );
00079                         f. setWeight ( QFont::Bold );
00080                         p-> setFont ( f );                        
00081                                                 
00082                         QRect br = p-> boundingRect ( tr, QPainter::AlignCenter, wd-> caption );
00083                         int trh2 = tr. height ( ) / 2;
00084                         
00085                         int align = QPainter::AlignCenter;
00086 
00087                         if ( br. width ( ) + 2 * trh2 > tr. width ( ) ) {
00088                                 br. setLeft ( tr. left ( ) + trh2 );
00089                                 br. setWidth ( tr. width ( ) - 2 * trh2 );
00090                         
00091                                 align = QPainter::AlignLeft | QPainter::AlignVCenter;
00092                         }
00093                         
00094                         p-> setBrush ( fillcol );
00095                         p-> setPen ( bordercol /*Qt::NoPen*/ );
00096                         p->     drawChord ( br. left ( ) - trh2, tr. top ( ), 2 * trh2, tr. height ( ), 90*16, 180*16 );
00097                         p->     drawChord ( br. right ( ) + 1 - trh2, tr. top ( ), 2 * trh2, tr. height ( ), 90*16, -180*16 );
00098 
00099                         p-> fillRect ( br.left() - 1, tr. top ( ), br. width ( ) + 2, tr. height ( ), fillcol);
00100                                 
00101                         p-> setPen ( shadecol );
00102                         p-> drawText ( br, align, wd-> caption );
00103                         p-> setPen ( textcol );
00104                         br. moveBy ( -1, -1 );
00105                         p-> drawText ( br, align, wd-> caption );
00106                         break;
00107                 }
00108                 default: {
00109                         WindowDecorationInterface::drawArea ( a, p, wd );
00110                         break;
00111                 }
00112         }
00113 }
00114 
00115 QRESULT LiquidDecoInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
00116 {
00117         *iface = 0;
00118         
00119         if ( uuid == IID_QUnknown )
00120                 *iface = this;
00121         else if ( uuid == IID_WindowDecoration )
00122                 *iface = this;
00123         else
00124             return QS_FALSE;
00125         
00126         if ( *iface )
00127                 (*iface)-> addRef ( );
00128                 
00129         return QS_OK;
00130 }
00131 
00132 Q_EXPORT_INTERFACE()
00133 {
00134         Q_CREATE_INSTANCE( LiquidDecoInterface )
00135 }
00136 

Generated on Sat Nov 5 16:17:17 2005 for OPIE by  doxygen 1.4.2