themes-example.html

来自「QT 下载资料仅供参考」· HTML 代码 · 共 1,123 行 · 第 1/5 页

HTML
1,123
字号
}/*!  Reimplementation from QStyle */<a name="x210"></a>void NorwegianWoodStyle::<a href="qstyle.html#polish">polish</a>( <a href="qapplication.html">QApplication</a> *app){<a name="x146"></a>    oldPalette = app-&gt;<a href="qapplication.html#palette">palette</a>();    // we simply create a nice QColorGroup with a couple of fancy wood    // pixmaps here and apply to it all widgets    <a href="qimage.html">QImage</a> img(button_xpm);    <a href="qimage.html">QImage</a> orig = img;<a name="x169"></a>    orig.<a href="qimage.html#detach">detach</a>();    <a href="qpixmap.html">QPixmap</a> button;<a name="x189"></a>    button.<a href="qpixmap.html#convertFromImage">convertFromImage</a>(img);    int i;<a name="x170"></a>    for (i=0; i&lt;img.<a href="qimage.html#numColors">numColors</a>(); i++) {<a name="x168"></a>        QRgb rgb = img.<a href="qimage.html#color">color</a>(i);        <a href="qcolor.html">QColor</a> c(rgb);<a name="x152"></a>        rgb = c.<a href="qcolor.html#dark">dark</a>(120).rgb();<a name="x171"></a>        img.<a href="qimage.html#setColor">setColor</a>(i,rgb);    }    <a href="qpixmap.html">QPixmap</a> mid;    mid.<a href="qpixmap.html#convertFromImage">convertFromImage</a>(img);    img = orig;    img.<a href="qimage.html#detach">detach</a>();    for (i=0; i&lt;img.<a href="qimage.html#numColors">numColors</a>(); i++) {        QRgb rgb = img.<a href="qimage.html#color">color</a>(i);        <a href="qcolor.html">QColor</a> c(rgb);<a name="x153"></a>        rgb = c.<a href="qcolor.html#light">light</a>().rgb();        img.<a href="qimage.html#setColor">setColor</a>(i,rgb);    }    <a href="qpixmap.html">QPixmap</a> light;    light.<a href="qpixmap.html#convertFromImage">convertFromImage</a>(img);    img = orig;    img.<a href="qimage.html#detach">detach</a>();    for (i=0; i&lt;img.<a href="qimage.html#numColors">numColors</a>(); i++) {        QRgb rgb = img.<a href="qimage.html#color">color</a>(i);        <a href="qcolor.html">QColor</a> c(rgb);        rgb = c.<a href="qcolor.html#dark">dark</a>(180).rgb();        img.<a href="qimage.html#setColor">setColor</a>(i,rgb);    }    <a href="qpixmap.html">QPixmap</a> dark;    dark.<a href="qpixmap.html#convertFromImage">convertFromImage</a>(img);    <a href="qimage.html">QImage</a> bgimage(polish_xpm);    <a href="qpixmap.html">QPixmap</a> background;    background.<a href="qpixmap.html#convertFromImage">convertFromImage</a>(bgimage);    img = bgimage;    img.<a href="qimage.html#detach">detach</a>();    for (i=0; i&lt;img.<a href="qimage.html#numColors">numColors</a>(); i++) {        QRgb rgb = img.<a href="qimage.html#color">color</a>(i);        <a href="qcolor.html">QColor</a> c(rgb);        rgb = c.<a href="qcolor.html#dark">dark</a>(180).rgb();        img.<a href="qimage.html#setColor">setColor</a>(i,rgb);    }    sunkenDark = new <a href="qpixmap.html">QPixmap</a>;    sunkenDark-&gt;<a href="qpixmap.html#convertFromImage">convertFromImage</a>(img);    img = bgimage;    img.<a href="qimage.html#detach">detach</a>();    for (i=0; i&lt;img.<a href="qimage.html#numColors">numColors</a>(); i++) {        QRgb rgb = img.<a href="qimage.html#color">color</a>(i);        <a href="qcolor.html">QColor</a> c(rgb);        rgb = c.<a href="qcolor.html#light">light</a>(130).rgb();        img.<a href="qimage.html#setColor">setColor</a>(i,rgb);    }    sunkenLight= new <a href="qpixmap.html">QPixmap</a>;    sunkenLight-&gt;<a href="qpixmap.html#convertFromImage">convertFromImage</a>(img);    <a href="qpalette.html">QPalette</a> op(QColor(212,140,95));    // QPalette op(white);<a name="x185"></a>    <a href="qcolorgroup.html">QColorGroup</a> active (op.<a href="qpalette.html#active">active</a>().foreground(),                     QBrush(op.<a href="qpalette.html#active">active</a>().button(),button),                     QBrush(op.<a href="qpalette.html#active">active</a>().light(), light),                     QBrush(op.<a href="qpalette.html#active">active</a>().dark(), dark),                     QBrush(op.<a href="qpalette.html#active">active</a>().mid(), mid),                     op.<a href="qpalette.html#active">active</a>().text(),                     Qt::white,                     QColor(236,182,120),                     QBrush(op.<a href="qpalette.html#active">active</a>().background(), background)                     );<a name="x186"></a>    <a href="qcolorgroup.html">QColorGroup</a> disabled (op.<a href="qpalette.html#disabled">disabled</a>().foreground(),                     QBrush(op.<a href="qpalette.html#disabled">disabled</a>().button(),button),                     QBrush(op.<a href="qpalette.html#disabled">disabled</a>().light(), light),                     op.<a href="qpalette.html#disabled">disabled</a>().dark(),                     QBrush(op.<a href="qpalette.html#disabled">disabled</a>().mid(), mid),                     op.<a href="qpalette.html#disabled">disabled</a>().text(),                     Qt::white,                     QColor(236,182,120),                     QBrush(op.<a href="qpalette.html#disabled">disabled</a>().background(), background)                     );<a name="x147"></a>   app-&gt;<a href="qapplication.html#setPalette">setPalette</a>(QPalette(active, disabled, active), TRUE );}<a name="x211"></a>void NorwegianWoodStyle::<a href="qstyle.html#unPolish">unPolish</a>( <a href="qapplication.html">QApplication</a> *app){    app-&gt;<a href="qapplication.html#setPalette">setPalette</a>(oldPalette, TRUE);}/*!  Reimplementation from QStyle */void NorwegianWoodStyle::<a href="qstyle.html#polish">polish</a>( <a href="qwidget.html">QWidget</a>* w){    // the polish function sets some widgets to transparent mode and    // some to translate background mode in order to get the full    // benefit from the nice pixmaps in the color group.<a name="x216"></a>    if ( !w-&gt;<a href="qwidget.html#isTopLevel">isTopLevel</a>() ) {<a name="x172"></a>        if ( w-&gt;<a href="qobject.html#inherits">inherits</a>("QPushButton")             || w-&gt;<a href="qobject.html#inherits">inherits</a>("QToolButton")             || w-&gt;<a href="qobject.html#inherits">inherits</a>("QComboBox") ) {<a name="x218"></a>            w-&gt;<a href="qwidget.html#setAutoMask">setAutoMask</a>( TRUE );            return;        }<a name="x213"></a>        if ( w-&gt;<a href="qwidget.html#backgroundPixmap">backgroundPixmap</a>() )<a name="x219"></a>            w-&gt;<a href="qwidget.html#setBackgroundOrigin">setBackgroundOrigin</a>( QWidget::WindowOrigin );    }}void NorwegianWoodStyle::<a href="qstyle.html#unPolish">unPolish</a>( <a href="qwidget.html">QWidget</a>* w){    // the polish function sets some widgets to transparent mode and    // some to translate background mode in order to get the full    // benefit from the nice pixmaps in the color group.    if ( !w-&gt;<a href="qwidget.html#isTopLevel">isTopLevel</a>() ) {        if ( w-&gt;<a href="qobject.html#inherits">inherits</a>("QPushButton")             || w-&gt;<a href="qobject.html#inherits">inherits</a>("QToolButton")             || w-&gt;<a href="qobject.html#inherits">inherits</a>("QComboBox") ) {            w-&gt;<a href="qwidget.html#setAutoMask">setAutoMask</a>( FALSE );            return;        }        if ( w-&gt;<a href="qwidget.html#backgroundPixmap">backgroundPixmap</a>() )            w-&gt;<a href="qwidget.html#setBackgroundOrigin">setBackgroundOrigin</a>( QWidget::WidgetOrigin );    }}<a name="x223"></a>void NorwegianWoodStyle::<a href="qstyle.html#drawPrimitive">drawPrimitive</a>( PrimitiveElement pe,                                        <a href="qpainter.html">QPainter</a> *p,                                        const <a href="qrect.html">QRect</a> &amp;r,                                        const <a href="qcolorgroup.html">QColorGroup</a> &amp;cg,                                        SFlags flags, const <a href="qstyleoption.html">QStyleOption</a>&amp; opt ) const{    int x, y, w, h;<a name="x201"></a>    r.<a href="qrect.html#rect">rect</a>( &amp;x, &amp;y, &amp;w, &amp;h );    switch ( pe ) {    case PE_ButtonCommand:        {            int d = QMIN( w, h ) / 2;            int b = buttonthickness( d );            <a href="qregion.html">QRegion</a> internR = roundRectRegion( QRect(x + b, y + b,                                                       w - 2 * b,                                                       h - 2 * b), d - b );<a name="x179"></a>            <a href="qpen.html">QPen</a> oldPen = p-&gt;<a href="qpainter.html#pen">pen</a>();<a name="x155"></a>            <a href="qbrush.html">QBrush</a> brush( flags &amp; Style_Sunken ? cg.<a href="qcolorgroup.html#brush">brush</a>(QColorGroup::Mid) :                          cg.<a href="qcolorgroup.html#brush">brush</a>(QColorGroup::Button) );<a name="x181"></a>            p-&gt;<a href="qpainter.html#setClipRegion">setClipRegion</a>( internR );<a name="x177"></a>            p-&gt;<a href="qpainter.html#fillRect">fillRect</a>( r, brush );            int e = QMIN( w, h ) / 2;            <a href="qpoint.html">QPoint</a> p2( x + w - 1 - e, y + e );            <a href="qpoint.html">QPoint</a> p3( x + e, y + h - 1 - e );            <a href="qpointarray.html">QPointArray</a> a;<a name="x193"></a><a name="x191"></a><a name="x190"></a>            a.setPoints( 5, x,y, x+w-1, y, p2.<a href="qpoint.html#x">x</a>(), p2.<a href="qpoint.html#y">y</a>(), p3.<a href="qpoint.html#x">x</a>(), p3.<a href="qpoint.html#y">y</a>(),                         x, y + h - 1 );            p-&gt;<a href="qpainter.html#setClipRegion">setClipRegion</a>( QRegion(a) - internR );<a name="x158"></a>            p-&gt;<a href="qpainter.html#fillRect">fillRect</a>( r, (flags &amp; Style_Sunken ? QBrush( cg.<a href="qcolorgroup.html#dark">dark</a>(), *sunkenDark)                                             : cg.<a href="qcolorgroup.html#brush">brush</a>(QColorGroup::Light)) );            // A little inversion is needed the buttons            // ( but not flat)            if ( flags &amp; Style_Raised || flags &amp; Style_Sunken ) {<a name="x192"></a>                a.<a href="qpointarray.html#setPoint">setPoint</a>( 0, x + w - 1, y + w - 1 );                p-&gt;<a href="qpainter.html#setClipRegion">setClipRegion</a>( QRegion( a ) - internR );<a name="x160"></a>                p-&gt;<a href="qpainter.html#fillRect">fillRect</a>( r, (flags &amp; Style_Sunken ? QBrush( cg.<a href="qcolorgroup.html#light">light</a>(), *sunkenLight) : cg.<a href="qcolorgroup.html#brush">brush</a>( QColorGroup::Dark ) ) );            }            p-&gt;<a href="qpainter.html#setClipRegion">setClipRegion</a>( internR );<a name="x182"></a>            p-&gt;<a href="qpainter.html#setClipping">setClipping</a>( FALSE );<a name="x183"></a><a name="x159"></a>            p-&gt;<a href="qpainter.html#setPen">setPen</a>( cg.<a href="qcolorgroup.html#foreground">foreground</a>() );            drawroundrect( p, x, y, w, h, d );            p-&gt;<a href="qpainter.html#setPen">setPen</a>( oldPen );            break;        }    case PE_ScrollBarAddLine:        if ( flags &amp; Style_Horizontal )            drawSemicircleButton( p, r, PointRight, flags &amp; Style_Down, cg );        else            drawSemicircleButton( p, r, PointDown, flags &amp; Style_Down, cg );        break;    case PE_ScrollBarSubLine:        if ( flags &amp; Style_Horizontal )            drawSemicircleButton( p, r, PointLeft, flags &amp; Style_Down, cg );        else            drawSemicircleButton( p, r, PointUp, flags &amp; Style_Down, cg );        break;    default:        <a href="qwindowsstyle.html">QWindowsStyle</a>::<a href="qstyle.html#drawPrimitive">drawPrimitive</a>( pe, p, r, cg, flags, opt );        break;    }}<a name="x222"></a>void NorwegianWoodStyle::<a hre

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?