Back to index

salome-gui  6.5.0
Style_Model.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // File   : Style_Model.cxx
00021 // Author : Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com)
00022 //
00023 #include "Style_Model.h"
00024 #include "Style_Salome.h"
00025 
00026 #include <QtxResourceMgr.h>
00027 
00028 #include <QApplication>
00029 #include <QColor>
00030 #include <QFont>
00031 #include <QPalette>
00032 
00040 static QColor mixColors( const QColor& c1, const QColor& c2 )
00041 {
00042   return QColor( (c1.red()   + c2.red() )   / 2,
00043                  (c1.green() + c2.green() ) / 2,
00044                  (c1.blue()  + c2.blue() )  / 2,
00045                  (c1.alpha() + c2.alpha() ) / 2 );
00046 }
00047 
00067 Style_Model::AppData* Style_Model::myAppData = 0;
00068 
00074 Style_Model::Style_Model()
00075   : myResourceMgr( 0 )
00076 {
00077   initDefaults(); // init from default values
00078 }
00079 
00083 Style_Model::~Style_Model()
00084 {
00085 }
00086 
00101 void Style_Model::fromApplication( bool reset )
00102 {
00103   initDefaults();
00104 
00105   if ( !QApplication::instance() )  // application object is not created yet
00106     return;
00107 
00108   if ( !myAppData ) // if not yes initialized from the application init myAppData
00109     myAppData = new AppData;
00110 
00111   // store original application's style, palette, etc
00112   if ( !Style_Salome::isActive() ) {
00113     myAppData->myStyle   = QApplication::style();
00114     myAppData->myPalette = QApplication::palette();
00115     myAppData->myFont    = QApplication::font();
00116   }
00117 
00118   // initialize style properties from the application
00119 
00120   if ( !reset ) return;
00121 
00122   // font
00123   myFont = myAppData->myFont;
00124   // colors
00125   for ( int i = (int)QPalette::Active; i <= (int)QPalette::Inactive; i++ ) {
00126     for ( int j = (int)Style_Model::WindowText; j < (int)Style_Model::NColorRoles; j++ ) {
00127       myColors[ (QPalette::ColorGroup)i ][ (Style_Model::ColorRole)j ] =
00128         myAppData->myPalette.color( (QPalette::ColorGroup)i, (QPalette::ColorRole)j );
00129     }
00130   }
00131 
00132   QColor dark = myAppData->myPalette.color( QPalette::Dark );
00133   setColor( BorderTop,       dark.lighter() );
00134   setColor( BorderBottom,    dark.darker() );
00135   setColor( TabBorderTop,    dark.lighter().lighter() );
00136   setColor( TabBorderBottom, dark.darker().darker() );
00137   setColor( FieldLight,      myAppData->myPalette.color( QPalette::Light ) );
00138   setColor( FieldDark,       myAppData->myPalette.color( QPalette::Mid ).light( 125 ) );
00139   setColor( ProgressBar,     myAppData->myPalette.color( QPalette::Highlight ) );
00140   setColor( Pointer,         myAppData->myPalette.color( QPalette::WindowText ) );
00141   setColor( Checked,         myAppData->myPalette.color( QPalette::Base ) );
00142   setColor( GridLine,        myAppData->myPalette.color( QPalette::Mid ) );
00143   setColor( Header,          myAppData->myPalette.color( QPalette::Button ) );
00144   setColor( Slider,          myAppData->myPalette.color( QPalette::Button ) );
00145   setColor( HighlightWidget, myAppData->myPalette.color( QPalette::Button ) );
00146   setColor( HighlightBorder, myAppData->myPalette.color( QPalette::Button ) );
00147   setColor( Lines,           myAppData->myPalette.color( QPalette::Mid ) );
00148 }
00149 
00161 void Style_Model::fromResources( QtxResourceMgr* resMgr, const QString& resSection )
00162 {
00163   // init from application
00164   fromApplication( false );
00165 
00166   myResourceMgr     = resMgr;
00167   myResourceSection = resSection;
00168 
00169   // init from resource manager
00170   if ( !resourceMgr() )
00171     return;
00172 
00173   QString section = resourceSection();
00174 
00175   // colors
00176   // Button
00177   readColorValue( Button, "button" );
00178   // Window text
00179   readColorValue( WindowText, "window-text" );
00180   // Light
00181   readColorValue( Light, "light" );
00182   // Dark
00183   readColorValue( Dark, "dark" );
00184   // Mid
00185   readColorValue( Mid, "mid" );
00186   // Text
00187   readColorValue( Text, "text" );
00188   // BrightText
00189   readColorValue( BrightText, "bright-text" );
00190   // ButtonText
00191   readColorValue( ButtonText, "button-text" );
00192   // Base
00193   readColorValue( Base, "base" );
00194   // Window
00195   readColorValue( Window, "window" );
00196   // AlternateBase
00197   readColorValue( AlternateBase, "alternate-base" );
00198   // Midlight
00199   readColorValue( Midlight, "midlight" );
00200   // Shadow
00201   readColorValue( Shadow, "shadow" );
00202   // Highlight
00203   readColorValue( Highlight, "highlight" );
00204   // HighlightedText
00205   readColorValue( HighlightedText, "highlight-text" );
00206   // Link
00207   readColorValue( Link, "link" );
00208   // LinkVisited
00209   readColorValue( LinkVisited, "link-visited" );
00210   // ToolTipBase
00211   readColorValue( ToolTipBase, "tooltip-base" );
00212   // ToolTipText
00213   readColorValue( ToolTipText, "tooltip-text" );
00214   // BorderTop
00215   readColorValue( BorderTop, "border-top" );
00216   // BorderBottom
00217   readColorValue( BorderBottom, "border-bottom" );
00218   // TabBorderTop
00219   readColorValue( TabBorderTop, "tab-border-top" );
00220   // TabBorderBottom
00221   readColorValue( TabBorderBottom, "tab-border-bottom" );
00222   // FieldLight
00223   readColorValue( FieldLight, "field-light" );
00224   // FieldDark
00225   readColorValue( FieldDark, "field-dark" );
00226   // ProgressBar
00227   readColorValue( ProgressBar, "progress-bar" );
00228   // Pointer
00229   readColorValue( Pointer, "pointer" );
00230   // Checked
00231   readColorValue( Checked, "checked" );
00232   // GridLine
00233   readColorValue( GridLine, "grid-line" );
00234   // Header
00235   readColorValue( Header, "header" );
00236   // Slider
00237   readColorValue( Slider, "slider" );
00238   // HighlightWidget
00239   readColorValue( HighlightWidget, "highlight-widget" );
00240   // HighlightBorder
00241   readColorValue( HighlightBorder, "highlight-border" );
00242   // Lines
00243   readColorValue( Lines, "lines" );
00244   // auto-palette flag (internal)
00245   if ( resourceMgr()->hasValue( section, "auto-palette" ) ) {
00246     setAutoPalette( resourceMgr()->booleanValue( section, "auto-palette" ) );
00247   }
00248   // lines type
00249   if ( resourceMgr()->hasValue( section, "lines-type" ) ) {
00250     int ltype = resourceMgr()->integerValue( section, "lines-type" );
00251     if ( ltype >= NoLines && ltype <= Inclined )
00252       setLinesType( (LineType)ltype );
00253   }
00254   // lines transparency
00255   if ( resourceMgr()->hasValue( section, "lines-transparency" ) ) {
00256     int ltransp = resourceMgr()->integerValue( section, "lines-transparency" );
00257     if ( ltransp >= 0 && ltransp <= 100 )
00258       setLinesTransparency( ltransp );
00259   }
00260   // application font
00261   if ( resourceMgr()->hasValue( section, "application-font" ) ) {
00262     setApplicationFont( resourceMgr()->fontValue( section, "application-font" ) );
00263   }
00264   // widgets rounding
00265   if ( resourceMgr()->hasValue( section, "button-rad" ) ) {
00266     setWidgetRounding( ButtonRadius, resourceMgr()->doubleValue( section, "button-rad" ) );
00267   }
00268   if ( resourceMgr()->hasValue( section, "edit-rad" ) ) {
00269     setWidgetRounding( EditRadius, resourceMgr()->doubleValue( section, "edit-rad" ) );
00270   }
00271   if ( resourceMgr()->hasValue( section, "frame-rad" ) ) {
00272     setWidgetRounding( FrameRadius, resourceMgr()->doubleValue( section, "frame-rad" ) );
00273   }
00274   if ( resourceMgr()->hasValue( section, "slider-rad" ) ) {
00275     setWidgetRounding( SliderRadius, resourceMgr()->doubleValue( section, "slider-rad" ) );
00276   }
00277   // widget effect
00278   if ( resourceMgr()->hasValue( section, "widget-effect" ) ) {
00279     int effect = resourceMgr()->integerValue( section, "widget-effect" );
00280     if ( effect >= NoEffect && effect <= AutoRaiseEffect )
00281       setWidgetEffect( (WidgetEffect)effect );
00282   }
00283   else if ( resourceMgr()->hasValue( section, "is-highlight-widget" ) ||
00284             resourceMgr()->hasValue( section, "is-raising-widget" ) ) {
00285     bool highlight = resourceMgr()->booleanValue( section, "is-highlight-widget", false );
00286     bool autoraise = resourceMgr()->booleanValue( section, "is-highlight-widget", false );
00287     if ( highlight )
00288       setWidgetEffect( HighlightEffect );
00289     else if ( autoraise )
00290       setWidgetEffect( AutoRaiseEffect );
00291   }
00292   if ( resourceMgr()->hasValue( section, "all-antialized" ) ) {
00293     setAntialiasing( resourceMgr()->booleanValue( section, "all-antialized" ) );
00294   }
00295   // handles
00296   if ( resourceMgr()->hasValue( section, "hor-hadle-delta" ) ) {
00297     setHandleDelta( Qt::Horizontal, resourceMgr()->integerValue( section, "hor-hadle-delta" ) );
00298   }
00299   if ( resourceMgr()->hasValue( section, "ver-hadle-delta" ) ) {
00300     setHandleDelta( Qt::Vertical, resourceMgr()->integerValue( section, "vsr-hadle-delta" ) );
00301   }
00302   if ( resourceMgr()->hasValue( section, "slider-size" ) ) {
00303     setSliderSize( resourceMgr()->integerValue( section, "slider-size" ) );
00304   }
00305   else if ( resourceMgr()->hasValue( section, "slider-increase" ) ) {
00306     setSliderSize( resourceMgr()->integerValue( section, "slider-increase" ) );
00307   }
00308   if ( resourceMgr()->hasValue( section, "split-handle-len" ) ) {
00309     setSplitHandleLength( resourceMgr()->integerValue( section, "split-handle-len" ) );
00310   }
00311 }
00312 
00323 void Style_Model::save( QtxResourceMgr* resMgr, const QString& resSection )
00324 {
00325   if ( !resMgr )
00326     resMgr = resourceMgr();
00327   if ( !resMgr )
00328     return;
00329 
00330   QString section = resSection.isEmpty() ? resourceSection() : resSection;
00331 
00332   // colors
00333   // Button
00334   writeColorValue( Button, "button", resMgr, section );
00335   // Window text
00336   writeColorValue( WindowText, "window-text", resMgr, section );
00337   // Light
00338   writeColorValue( Light, "light", resMgr, section );
00339   // Dark
00340   writeColorValue( Dark, "dark", resMgr, section );
00341   // Mid
00342   writeColorValue( Mid, "mid", resMgr, section );
00343   // Text
00344   writeColorValue( Text, "text", resMgr, section );
00345   // BrightText
00346   writeColorValue( BrightText, "bright-text", resMgr, section );
00347   // ButtonText
00348   writeColorValue( ButtonText, "button-text", resMgr, section );
00349   // Base
00350   writeColorValue( Base, "base", resMgr, section );
00351   // Window
00352   writeColorValue( Window, "window", resMgr, section );
00353   // AlternateBase
00354   writeColorValue( AlternateBase, "alternate-base", resMgr, section );
00355   // Midlight
00356   writeColorValue( Midlight, "midlight", resMgr, section );
00357   // Shadow
00358   writeColorValue( Shadow, "shadow", resMgr, section );
00359   // Highlight
00360   writeColorValue( Highlight, "highlight", resMgr, section );
00361   // HighlightedText
00362   writeColorValue( HighlightedText, "highlight-text", resMgr, section );
00363   // Link
00364   writeColorValue( Link, "link", resMgr, section );
00365   // LinkVisited
00366   writeColorValue( LinkVisited, "link-visited", resMgr, section );
00367   // ToolTipBase
00368   writeColorValue( ToolTipBase, "tooltip-base", resMgr, section );
00369   // ToolTipText
00370   writeColorValue( ToolTipText, "tooltip-text", resMgr, section );
00371   // BorderTop
00372   writeColorValue( BorderTop, "border-top", resMgr, section );
00373   // BorderBottom
00374   writeColorValue( BorderBottom, "border-bottom", resMgr, section );
00375   // TabBorderTop
00376   writeColorValue( TabBorderTop, "tab-border-top", resMgr, section );
00377   // TabBorderBottom
00378   writeColorValue( TabBorderBottom, "tab-border-bottom", resMgr, section );
00379   // FieldLight
00380   writeColorValue( FieldLight, "field-light", resMgr, section );
00381   // FieldDark
00382   writeColorValue( FieldDark, "field-dark", resMgr, section );
00383   // ProgressBar
00384   writeColorValue( ProgressBar, "progress-bar", resMgr, section );
00385   // Pointer
00386   writeColorValue( Pointer, "pointer", resMgr, section );
00387   // Checked
00388   writeColorValue( Checked, "checked", resMgr, section );
00389   // GridLine
00390   writeColorValue( GridLine, "grid-line", resMgr, section );
00391   // Header
00392   writeColorValue( Header, "header", resMgr, section );
00393   // Slider
00394   writeColorValue( Slider, "slider", resMgr, section );
00395   // HighlightWidget
00396   writeColorValue( HighlightWidget, "highlight-widget", resMgr, section );
00397   // HighlightBorder
00398   writeColorValue( HighlightBorder, "highlight-border", resMgr, section );
00399   // Lines
00400   writeColorValue( Lines, "lines", resMgr, section );
00401   // auto-palette flag (internal)
00402   resMgr->setValue( section, "auto-palette", isAutoPalette() );
00403 
00404   // lines type
00405   resMgr->setValue( section, "lines-type", (int)linesType() );
00406   // lines transparency
00407   resMgr->setValue( section, "lines-transparency", linesTransparency() );
00408   // application font
00409   resMgr->setValue( section, "application-font", applicationFont() );
00410   // widgets rounding
00411   resMgr->setValue( section, "button-rad", widgetRounding( ButtonRadius ) );
00412   resMgr->setValue( section, "edit-rad",   widgetRounding( EditRadius ) );
00413   resMgr->setValue( section, "frame-rad",  widgetRounding( FrameRadius ) );
00414   resMgr->setValue( section, "slider-rad", widgetRounding( SliderRadius ) );
00415   resMgr->setValue( section, "all-antialized", antialiasing() );
00416   // widget effect
00417   resMgr->setValue( section, "widget-effect", (int)widgetEffect() );
00418   // handles
00419   resMgr->setValue( section, "hor-hadle-delta", handleDelta( Qt::Horizontal ) );
00420   resMgr->setValue( section, "vsr-hadle-delta", handleDelta( Qt::Vertical ) );
00421   resMgr->setValue( section, "slider-size", sliderSize() );
00422   resMgr->setValue( section, "split-handle-len", splitHandleLength() );
00423 }
00424 
00429 void Style_Model::update()
00430 {
00431   fromResources( resourceMgr(), resourceSection() );
00432 }
00433 
00444 void Style_Model::restore()
00445 {
00446   if ( !QApplication::instance() ) // application object is not created yet
00447     return;
00448   if ( !myAppData ) // not initialized from the application yet
00449     return;
00450 
00451   QApplication::setStyle( myAppData->myStyle );
00452   QApplication::setPalette( myAppData->myPalette );
00453   QApplication::setFont( myAppData->myFont );
00454 }
00455 
00462 QtxResourceMgr* Style_Model::resourceMgr() const
00463 {
00464   return myResourceMgr;
00465 }
00466 
00475 QString Style_Model::resourceSection() const
00476 {
00477   return !myResourceSection.isEmpty() ? myResourceSection : "Theme";
00478 }
00479 
00487 QColor Style_Model::color( ColorRole role, QPalette::ColorGroup cg ) const
00488 {
00489   QColor c = myColors[ cg ][ role ];
00490   if ( !c.isValid() ) c = myColors[ QPalette::Active ][ role ];
00491   return c;
00492 }
00493 
00506 void Style_Model::setColor( Style_Model::ColorRole role, const QColor& active,
00507                             const QColor& inactive, const QColor& disabled )
00508 {
00509   QColor ac = active, ic = inactive, dc = disabled;
00510 
00511   if ( !ic.isValid() ) {
00512     ic = ac;
00513   }
00514   if ( !dc.isValid() ) {
00515     switch ( role ) {
00516     case WindowText:
00517     case Text:
00518     case ButtonText:
00519       dc = color( Button ).darker();
00520       break;
00521     case Base:
00522       dc = color( Button );
00523       break;
00524     case AlternateBase:
00525       dc = mixColors( color( Base,  QPalette::Inactive ), color( Button, QPalette::Inactive ) );
00526       break;
00527     case Midlight:
00528       dc = mixColors( color( Light, QPalette::Inactive ), color( Button, QPalette::Inactive ) );
00529       break;
00530     default:
00531       dc = ac;
00532       break;
00533     }
00534   }
00535 
00536   setColor( role, QPalette::Active,   ac );
00537   setColor( role, QPalette::Inactive, ic );
00538   setColor( role, QPalette::Disabled, dc );
00539 }
00540 
00552 void Style_Model::setColor( Style_Model::ColorRole role, QPalette::ColorGroup cg, const QColor& c )
00553 {
00554   myColors[ cg ][ role ] = c;
00555 }
00556 
00563 bool Style_Model::isAutoPalette() const
00564 {
00565   return myAutoPalette;
00566 }
00567 
00574 void Style_Model::setAutoPalette( bool on )
00575 {
00576   myAutoPalette = on;
00577 }
00578 
00584 Style_Model::LineType Style_Model::linesType() const
00585 {
00586   return myLinesType;
00587 }
00588 
00594 void Style_Model::setLinesType( LineType lt )
00595 {
00596   myLinesType = lt;
00597 }
00598 
00604 int Style_Model::linesTransparency() const
00605 {
00606   return myLinesTransparency;
00607 }
00608 
00614 void Style_Model::setLinesTransparency( int transparency )
00615 {
00616   myLinesTransparency = transparency;
00617 }
00618 
00624 QFont Style_Model::applicationFont() const
00625 {
00626   return myFont;
00627 }
00628 
00634 void Style_Model::setApplicationFont( const QFont& font )
00635 {
00636   myFont = font;
00637 }
00638 
00645 double Style_Model::widgetRounding( Style_Model::WidgetRounding wr ) const
00646 {
00647   return myWidgetRounding[ wr ];
00648 }
00649 
00656 void Style_Model::setWidgetRounding( WidgetRounding wr, double value )
00657 {
00658   myWidgetRounding[ wr ] = value;
00659 }
00660 
00666 bool Style_Model::antialiasing() const
00667 {
00668   return myAntiAliasing;
00669 }
00670 
00676 void Style_Model::setAntialiasing( bool value )
00677 {
00678   myAntiAliasing = value;
00679 }
00680 
00686 Style_Model::WidgetEffect Style_Model::widgetEffect() const
00687 {
00688   return myWidgetEffect;
00689 }
00690 
00696 void Style_Model::setWidgetEffect( WidgetEffect we )
00697 {
00698   myWidgetEffect = we;
00699 }
00700 
00707 int Style_Model::handleDelta( Qt::Orientation o ) const
00708 {
00709   return myHandleDelta[ o ];
00710 }
00711 
00718 void Style_Model::setHandleDelta( Qt::Orientation o, int value )
00719 {
00720   myHandleDelta[ o ] = value;
00721 }
00722 
00728 int Style_Model::splitHandleLength() const
00729 {
00730   return mySplitHandleLength;
00731 }
00732 
00738 void Style_Model::setSplitHandleLength( int value )
00739 {
00740   mySplitHandleLength = value; 
00741 }
00742 
00748 int Style_Model::sliderSize() const
00749 {
00750   return mySliderSize;
00751 }
00752 
00758 void Style_Model::setSliderSize( int value )
00759 {
00760   mySliderSize = value;
00761 }
00762 
00766 void Style_Model::initDefaults()
00767 {
00768   // default application font
00769   myFont.fromString( "Sans Serif,9,-1,5,50,0,0,0,0,0" );
00770 
00771   // default palette colors
00772   myAutoPalette = false;
00773   QColor btn = QColor( "#e6e7e6" );
00774   QColor fg  = QColor( "#000000" );
00775   QColor bg  = QColor( "#ffffff" );
00776   setColor( Button,          btn );                  // = (230, 231, 230)
00777   setColor( WindowText,      fg );                   // = (  0,   0,   0)
00778   setColor( Light,           bg );                   // = (255, 255, 255)
00779   setColor( Dark,            btn.darker() );         // = (115, 115, 115) // btn.darker( 130 ) = (177, 178, 177)
00780   setColor( Mid,             btn.darker( 150 ) );    // = (153, 154, 153)
00781   setColor( Text,            fg );                   // = (  0,   0,   0)
00782   setColor( BrightText,      bg );                   // = (255, 255, 255) // fg = (  0,  0,  0)
00783   setColor( ButtonText,      fg );                   // = (  0,   0,   0)
00784   setColor( Base,            bg );                   // = (255, 255, 255)
00785   setColor( Window,          btn );                  // = (230, 231, 230)
00786   setColor( AlternateBase,   mixColors( bg, btn ) ); // = (242, 243, 242)
00787   setColor( Midlight,        mixColors( bg, btn ) ); // = (242, 243, 242)
00788   setColor( Shadow,          fg );                   // = (  0,   0,   0)
00789   setColor( Highlight,       "#000080" );            // = (  0,   0, 128) // (  33,  68, 156 )
00790   setColor( HighlightedText, bg );                   // = (255, 255, 255)
00791   setColor( Link,            "#0000ff" );            // = (  0,   0, 255)
00792   setColor( LinkVisited,     "#ff00ff" );            // = (255,   0, 255)
00793   setColor( ToolTipBase,     "#ffffdc" );            // = (255, 255, 220) // ( 230, 231, 230 )
00794   setColor( ToolTipText,     fg );                   // = (  0,   0,   0)
00795   setColor( BorderTop,       "#adadad" );            // = (173, 173, 173) // ( 255, 255, 255 )
00796   setColor( BorderBottom,    "#393939" );            // = ( 57,  57,  57) // (  88,  89,  88 )
00797   setColor( TabBorderTop,    "#ffffff" );            // = (255, 255, 255)
00798   setColor( TabBorderBottom, "#0e0e0e" );            // = ( 14,  14,  14) // (  44,  44,  44 )
00799   setColor( FieldLight,      "#ffffff" );            // = (255, 255, 255)
00800   setColor( FieldDark,       "#c0c1c0" );            // = (192, 193, 192) // ( 240, 241, 240 )
00801   setColor( ProgressBar,     "#000080" );            // = (  0,   0, 128) // (  33,  68, 156 )
00802   setColor( Pointer,         "#000000" );            // = (  0,   0,   0)
00803   setColor( Checked,         "#ffffff" );            // = (255, 255, 255)
00804   setColor( GridLine,        "#999a99" );            // = (153, 154, 153) // ( 192, 192, 192 )
00805   setColor( Header,          "#e6e7e6" );            // = (230, 231, 230)
00806   setColor( Slider,          "#e6e7e6" );            // = (230, 231, 230)
00807   setColor( HighlightWidget, "#e6e7e6" );            // = (230, 231, 230)
00808   setColor( HighlightBorder, "#e6e7e6" );            // = (230, 231, 230)
00809   setColor( Lines,           "#999a99" );            // = (153, 154, 153) // ( 192, 193, 192 )
00810 
00811   // default values
00812   myLinesType          = NoLines;
00813   myWidgetEffect       = NoEffect;
00814   myAntiAliasing       = false;
00815   myLinesTransparency  = 0;
00816   myWidgetRounding[ EditRadius   ] = 0.0;
00817   myWidgetRounding[ ButtonRadius ] = 0.0;
00818   myWidgetRounding[ FrameRadius  ] = 0.0;
00819   myWidgetRounding[ SliderRadius ] = 0.0;
00820   myHandleDelta[ Qt::Horizontal ]  = 3;
00821   myHandleDelta[ Qt::Vertical ]    = 3;
00822   mySplitHandleLength              = 20;
00823   mySliderSize                     = 2;
00824 }
00825 
00832 void Style_Model::readColorValue( ColorRole role, const QString& prefix )
00833 {
00834   if ( !resourceMgr() ) return;
00835 
00836   QString section = resourceSection();
00837   QString active   = QString( "%1-color" ).arg( prefix );
00838   QString inactive = QString( "%1-color-inactive" ).arg( prefix );
00839   QString disabled = QString( "%1-color-disabled" ).arg( prefix );
00840 
00841   if ( resourceMgr()->hasValue( section, active ) )
00842     setColor( role, resourceMgr()->colorValue( section, active ) );
00843   if ( resourceMgr()->hasValue( section, inactive ) )
00844     setColor( role, QPalette::Inactive, resourceMgr()->colorValue( section, inactive ) );
00845   if ( resourceMgr()->hasValue( section, disabled ) )
00846     setColor( role, QPalette::Disabled, resourceMgr()->colorValue( section, disabled ) );
00847 }
00848 
00857 void Style_Model::writeColorValue( ColorRole role, const QString& prefix,
00858                                    QtxResourceMgr* resMgr, const QString& resSection ) const
00859 {
00860   QString active   = QString( "%1-color" ).arg( prefix );
00861   QString inactive = QString( "%1-color-inactive" ).arg( prefix );
00862   QString disabled = QString( "%1-color-disabled" ).arg( prefix );
00863 
00864   resMgr->setValue( resSection, active,   color( role, QPalette::Active ) );
00865   resMgr->setValue( resSection, inactive, color( role, QPalette::Inactive ) );
00866   resMgr->setValue( resSection, disabled, color( role, QPalette::Disabled ) );
00867 }