00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023 void ClassName::drawFrame( QPainter *p )
00024 {
00025 if (frameShape() == QFrame::Box) {
00026 if ( frameShadow() == Plain )
00027 qDrawPlainRect( p, frameRect(), d->frameColor, lineWidth() );
00028 else
00029 qDrawShadeRect( p, frameRect(), colorGroup(), frameShadow() == QFrame::Sunken,
00030 lineWidth(), midLineWidth() );
00031 }
00032 else {
00033 SuperClassName::drawFrame(p);
00034 }
00035 }
00036
00037 void ClassName::setPalette( const QPalette &pal )
00038 {
00039 QPalette pal2(pal);
00040 QColorGroup cg( pal2.active() );
00041 cg.setColor(QColorGroup::Light, KexiUtils::bleachedColor( d->frameColor, 150 ));
00042 cg.setColor(QColorGroup::Mid, d->frameColor);
00043 cg.setColor(QColorGroup::Dark, d->frameColor.dark(150));
00044 pal2.setActive(cg);
00045 QColorGroup cg2( pal2.inactive() );
00046 cg2.setColor(QColorGroup::Light, cg.light() );
00047 cg2.setColor(QColorGroup::Mid, cg.mid());
00048 cg2.setColor(QColorGroup::Dark, cg.dark());
00049 pal2.setInactive(cg2);
00050 SuperClassName::setPalette(pal2);
00051 }
00052
00053 const QColor& ClassName::frameColor() const
00054 {
00055 return d->frameColor;
00056 }
00057
00058 void ClassName::setFrameColor(const QColor& color)
00059 {
00060 d->frameColor = color;
00061
00062 setPalette( palette() );
00063 }
00064
00065 #if 0
00066
00067 ClassName::Shape ClassName::frameShape() const
00068 {
00069 return d->frameShape;
00070 }
00071
00072 void ClassName::setFrameShape( ClassName::Shape shape )
00073 {
00074 d->frameShape = shape;
00075 update();
00076 }
00077
00078 ClassName::Shadow ClassName::frameShadow() const
00079 {
00080 return d->frameShadow;
00081 }
00082
00083 void ClassName::setFrameShadow( ClassName::Shadow shadow )
00084 {
00085 d->frameShadow = shadow;
00086 update();
00087 }
00088 #endif
00089
00090 #if 0
00091 void QFrame::drawFrame( QPainter *p )
00092 {
00093 QPoint p1, p2;
00094 QRect r = frameRect();
00095 int type = fstyle & MShape;
00096 int cstyle = fstyle & MShadow;
00097 #ifdef QT_NO_DRAWUTIL
00098 p->setPen( black );
00099 p->drawRect( r );
00100 #else
00101 const QColorGroup & g = colorGroup();
00102
00103 #ifndef QT_NO_STYLE
00104 QStyleOption opt(lineWidth(),midLineWidth());
00105
00106 QStyle::SFlags flags = QStyle::Style_Default;
00107 if (isEnabled())
00108 flags |= QStyle::Style_Enabled;
00109 if (cstyle == Sunken)
00110 flags |= QStyle::Style_Sunken;
00111 else if (cstyle == Raised)
00112 flags |= QStyle::Style_Raised;
00113 if (hasFocus())
00114 flags |= QStyle::Style_HasFocus;
00115 if (hasMouse())
00116 flags |= QStyle::Style_MouseOver;
00117 #endif // QT_NO_STYLE
00118
00119 switch ( type ) {
00120
00121 case Box:
00122 if ( cstyle == Plain )
00123 qDrawPlainRect( p, r, g.foreground(), lwidth );
00124 else
00125 qDrawShadeRect( p, r, g, cstyle == Sunken, lwidth,
00126 midLineWidth() );
00127 break;
00128
00129 case LineEditPanel:
00130 style().drawPrimitive( QStyle::PE_PanelLineEdit, p, r, g, flags, opt );
00131 break;
00132
00133 case GroupBoxPanel:
00134 style().drawPrimitive( QStyle::PE_PanelGroupBox, p, r, g, flags, opt );
00135 break;
00136
00137 case TabWidgetPanel:
00138 style().drawPrimitive( QStyle::PE_PanelTabWidget, p, r, g, flags, opt );
00139 break;
00140
00141 case MenuBarPanel:
00142 #ifndef QT_NO_STYLE
00143 style().drawPrimitive(QStyle::PE_PanelMenuBar, p, r, g, flags, opt);
00144 break;
00145 #endif // fall through to Panel if QT_NO_STYLE
00146
00147 case ToolBarPanel:
00148 #ifndef QT_NO_STYLE
00149 style().drawPrimitive( QStyle::PE_PanelDockWindow, p, rect(), g, flags, opt);
00150 break;
00151 #endif // fall through to Panel if QT_NO_STYLE
00152
00153 case StyledPanel:
00154 #ifndef QT_NO_STYLE
00155 if ( cstyle == Plain )
00156 qDrawPlainRect( p, r, g.foreground(), lwidth );
00157 else
00158 style().drawPrimitive(QStyle::PE_Panel, p, r, g, flags, opt);
00159 break;
00160 #endif // fall through to Panel if QT_NO_STYLE
00161
00162 case PopupPanel:
00163 #ifndef QT_NO_STYLE
00164 {
00165 int vextra = style().pixelMetric(QStyle::PM_PopupMenuFrameVerticalExtra, this),
00166 hextra = style().pixelMetric(QStyle::PM_PopupMenuFrameHorizontalExtra, this);
00167 if(vextra > 0 || hextra > 0) {
00168 QRect fr = frameRect();
00169 int fw = frameWidth();
00170 if(vextra > 0) {
00171 style().drawControl(QStyle::CE_PopupMenuVerticalExtra, p, this,
00172 QRect(fr.x() + fw, fr.y() + fw, fr.width() - (fw*2), vextra),
00173 g, flags, opt);
00174 style().drawControl(QStyle::CE_PopupMenuVerticalExtra, p, this,
00175 QRect(fr.x() + fw, fr.bottom() - fw - vextra, fr.width() - (fw*2), vextra),
00176 g, flags, opt);
00177 }
00178 if(hextra > 0) {
00179 style().drawControl(QStyle::CE_PopupMenuHorizontalExtra, p, this,
00180 QRect(fr.x() + fw, fr.y() + fw + vextra, hextra, fr.height() - (fw*2) - vextra),
00181 g, flags, opt);
00182 style().drawControl(QStyle::CE_PopupMenuHorizontalExtra, p, this,
00183 QRect(fr.right() - fw - hextra, fr.y() + fw + vextra, hextra, fr.height() - (fw*2) - vextra),
00184 g, flags, opt);
00185 }
00186 }
00187
00188 if ( cstyle == Plain )
00189 qDrawPlainRect( p, r, g.foreground(), lwidth );
00190 else
00191 style().drawPrimitive(QStyle::PE_PanelPopup, p, r, g, flags, opt);
00192 break;
00193 }
00194 #endif // fall through to Panel if QT_NO_STYLE
00195
00196 case Panel:
00197 if ( cstyle == Plain )
00198 qDrawPlainRect( p, r, g.foreground(), lwidth );
00199 else
00200 qDrawShadePanel( p, r, g, cstyle == Sunken, lwidth );
00201 break;
00202
00203 case WinPanel:
00204 if ( cstyle == Plain )
00205 qDrawPlainRect( p, r, g.foreground(), wpwidth );
00206 else
00207 qDrawWinPanel( p, r, g, cstyle == Sunken );
00208 break;
00209 case HLine:
00210 case VLine:
00211 if ( type == HLine ) {
00212 p1 = QPoint( r.x(), r.height()/2 );
00213 p2 = QPoint( r.x()+r.width(), p1.y() );
00214 }
00215 else {
00216 p1 = QPoint( r.x()+r.width()/2, 0 );
00217 p2 = QPoint( p1.x(), r.height() );
00218 }
00219 if ( cstyle == Plain ) {
00220 QPen oldPen = p->pen();
00221 p->setPen( QPen(g.foreground(),lwidth) );
00222 p->drawLine( p1, p2 );
00223 p->setPen( oldPen );
00224 }
00225 else
00226 qDrawShadeLine( p, p1, p2, g, cstyle == Sunken,
00227 lwidth, midLineWidth() );
00228 break;
00229 }
00230 #endif // QT_NO_DRAWUTIL
00231
00232 #endif