Version: 6.3.1
Public Member Functions | Static Public Member Functions | Protected Slots | Private Member Functions | Static Private Attributes

Style_Salome Class Reference

SALOME style class. More...

#include <Style_Salome.h>

Inheritance diagram for Style_Salome:
Inheritance graph

Public Member Functions

virtual ~Style_Salome ()
 Destructor.
virtual void polish (QApplication *)
 Initialize the appearance of the application.
virtual void polish (QWidget *)
 Initializes the appearance of the given widget.
virtual void unpolish (QWidget *)
 Uninitialize the given widget's appearance.
virtual void drawComplexControl (ComplexControl, const QStyleOptionComplex *, QPainter *, const QWidget *=0) const
 Draws the given control using the provided painter with the style options specified by opt.
virtual void drawControl (ControlElement, const QStyleOption *, QPainter *, const QWidget *) const
 Draws the given element with the provided painter with the style options specified by opt.
virtual void drawPrimitive (PrimitiveElement, const QStyleOption *, QPainter *, const QWidget *=0) const
 Draws the given primitive element with the provided painter using the style options specified by opt.
virtual int pixelMetric (PixelMetric, const QStyleOption *=0, const QWidget *=0) const
 Returns the value of the given pixel metric.
virtual QSize sizeFromContents (ContentsType, const QStyleOption *, const QSize &, const QWidget *=0) const
 Returns the size of the element described by the specified option opt and type ct, based on the provided contentsSize.
virtual QPixmap standardPixmap (StandardPixmap, const QStyleOption *, const QWidget *=0) const
 Returns a pixmap for the given standardPixmap.
virtual int styleHint (StyleHint, const QStyleOption *=0, const QWidget *=0, QStyleHintReturn *=0) const
 Returns an integer representing the specified style hint for the given widget w described by the provided style option opt.
virtual QRect subControlRect (ComplexControl, const QStyleOptionComplex *, SubControl, const QWidget *=0) const
 Get the rectangle containing the specified subcontrol sc of the given complex control cc (with the style specified by option opt). The rectangle is defined in screen coordinates.
virtual QRect subElementRect (SubElement, const QStyleOption *, const QWidget *=0) const
 Returns the sub-area for the given element se as described in the provided style option opt. The returned rectangle is defined in screen coordinates.

Static Public Member Functions

static void initialize (QtxResourceMgr *=0, const QString &=QString())
 Initialize SALOME style.
static void apply ()
 Set SALOME style to the application.
static void restore ()
 Restore original style to the application.
static bool isActive ()
 Check if the SALOME style is currently set to application.
static Style_Modelmodel ()
 Get style model.
static void update ()
 Update style from resources.

Protected Slots

QIcon standardIconImplementation (StandardPixmap, const QStyleOption *=0, const QWidget *=0) const
 Returns an icon for the given standardIcon.

Private Member Functions

 Style_Salome ()
 Constructor.
void updatePaletteColors ()
 Update palette colors from style model.
void updateAllWidgets (QApplication *)
 Update all widgets with the current style properties.
bool hasHover () const
 Check if any widget effect is currently used.
void drawHoverRect (QPainter *, const QRect &, const QColor &, const double, const int, const bool) const
 Draw rectangle for the hovered widget.
void drawHandle (QPainter *, const QRect &, bool, bool=true) const
 Draw widget handle.
void drawBackground (QPainter *, const QRect &, const QColor &, const bool, const bool=false, const bool=true) const
 Draw background.
void drawBorder (QPainter *, const QRect &, bool) const
 Draw border.
QString titleText (const QString &, const int, const int, QFont &) const
 Get corrected title text.

Static Private Attributes

static Style_ModelmyModel = 0

Detailed Description

To set SALOME style to the application, use static function Style_Salome.apply(). Static function restore() can be used then to restore initial application style.

The usual way to use SALOME style is as following:

  Style_Salome::initialize( resourceMgr() );     // initialize SALOME style from resources
  if ( needSalomeStyle ) Style_Salome::apply();  // set SALOME style to the application

Style_PrefDlg class can be then used to change style properties, select one of the predefined style themes or even create user themes:

  Style_PrefDlg dlg( desktop() );
  dlg.exec();

Constructor & Destructor Documentation

Style_Salome::Style_Salome ( ) [private]

Use Style_Salome.apply() static function to set SALOME style to the application.

Style_Salome::~Style_Salome ( ) [virtual]

Member Function Documentation

void Style_Salome::initialize ( QtxResourceMgr resMgr = 0,
const QString &  section = QString() 
) [static]

This method should be called at the very beginning of the application which uses SALOME style. The method initializes style properties from the current settings.

If the parameter resMgr is not 0, the style is initialized from the resources manager.

The parameter section allows customizing of the resources file section used to store style's properties. By default "Theme" section name is used.

Parameters:
resMgrresources manager
sectionresources file section name
See also:
apply(), restore()

References Style_Model.fromResources(), and model().

void Style_Salome::apply ( ) [static]
void Style_Salome::restore ( ) [static]
bool Style_Salome::isActive ( ) [static]
Returns:
true if SALOME style is set to the applcation or false otherwise
Style_Model * Style_Salome::model ( ) [static]
Returns:
style model

References myModel.

void Style_Salome::update ( ) [static]
void Style_Salome::polish ( QApplication app) [virtual]

Performs late initialization of the given application object.

Parameters:
appapplication object

References checkDebugLevel(), model(), updateAllWidgets(), and updatePaletteColors().

void Style_Salome::polish ( QWidget w) [virtual]

This function is called for every widget at some point after it has been fully created but just before it is shown for the very first time.

Parameters:
wwidget object

References checkDebugLevel(), hasHover(), and polish().

void Style_Salome::unpolish ( QWidget w) [virtual]

This function is the counterpart to polish(). It is called for every polished widget whenever the style is dynamically changed; the former style has to unpolish its settings before the new style can polish them again.

Parameters:
wwidget object

References checkDebugLevel(), and hasHover().

void Style_Salome::drawComplexControl ( ComplexControl  cc,
const QStyleOptionComplex *  opt,
QPainter *  p,
const QWidget w = 0 
) const [virtual]
void Style_Salome::drawControl ( ControlElement  ce,
const QStyleOption *  opt,
QPainter *  p,
const QWidget w 
) const [virtual]
void Style_Salome::drawPrimitive ( PrimitiveElement  pe,
const QStyleOption *  opt,
QPainter *  p,
const QWidget w = 0 
) const [virtual]
int Style_Salome::pixelMetric ( PixelMetric  metric,
const QStyleOption *  opt = 0,
const QWidget w = 0 
) const [virtual]
Parameters:
metricmetric type
optstyle option
wwidget
Returns:
metric value

References checkDebugLevel(), model(), and Style_Model.sliderSize().

QSize Style_Salome::sizeFromContents ( ContentsType  ct,
const QStyleOption *  opt,
const QSize &  contentsSize,
const QWidget w = 0 
) const [virtual]
Parameters:
ctcontents type
optstyle option
contentsSizecontents size
wwidget (optional)
Returns:
size of the element

References checkDebugLevel(), DELTA_H_TAB, Style_Model.EditRadius, Style_Tools.getMaxRect(), model(), Style_Model.sliderSize(), subControlRect(), and Style_Model.widgetRounding().

QPixmap Style_Salome::standardPixmap ( StandardPixmap  stPixmap,
const QStyleOption *  opt,
const QWidget w = 0 
) const [virtual]
Parameters:
stPixmapstandard pixmap type
optstyle option
wwidget (optional)
Returns:
standard pixmap

References checkDebugLevel(), cross_xpm, maximize_xpm, minimize_xpm, and normal_xpm.

int Style_Salome::styleHint ( StyleHint  hint,
const QStyleOption *  opt = 0,
const QWidget w = 0,
QStyleHintReturn *  returnData = 0 
) const [virtual]
Parameters:
hinthint type
optstyle option
wwidget (optional)
returnData(currently not used)
Returns:
style hint value

References checkDebugLevel(), Style_Model.color(), Style_Model.GridLine, and model().

QRect Style_Salome::subControlRect ( ComplexControl  cc,
const QStyleOptionComplex *  opt,
SubControl  sc,
const QWidget wid = 0 
) const [virtual]
Parameters:
cccomplex control type
optstyle option
scsubcontrol type
widwidget (optional)
Returns:
subcontrol rectangle

References Style_Model.ButtonRadius, checkDebugLevel(), DELTA_SLIDER, Style_Model.EditRadius, Style_Tools.getMaxRect(), Horizontal, model(), SHADOW, and Style_Model.widgetRounding().

QRect Style_Salome::subElementRect ( SubElement  se,
const QStyleOption *  opt,
const QWidget wid = 0 
) const [virtual]
Parameters:
sesubelement type
optstyle option
widwidget (optional)
Returns:
subelement rectangle

References checkDebugLevel(), Style_Model.EditRadius, Style_Tools.getMaxRect(), hasHover(), model(), SHADOW, subControlRect(), and Style_Model.widgetRounding().

QIcon Style_Salome::standardIconImplementation ( StandardPixmap  standardIcon,
const QStyleOption *  opt = 0,
const QWidget w = 0 
) const [protected, slot]
Parameters:
standardIconstandard icon type
optstyle option
wwidget (optional)
Returns:
standard icon

References checkDebugLevel().

void Style_Salome::updatePaletteColors ( ) [private]
void Style_Salome::updateAllWidgets ( QApplication app) [private]
Parameters:
appapplication object

References polish().

bool Style_Salome::hasHover ( ) const [private]
Returns:
true if any widget effect is currently used

References model(), Style_Model.NoEffect, and Style_Model.widgetEffect().

void Style_Salome::drawHoverRect ( QPainter *  p,
const QRect &  r,
const QColor &  bgCol,
const double  rad,
const int  type,
const bool  border 
) const [private]
Parameters:
ppainter
rrectangle
bgColbackground color
radcorners rounding radius
typeshadow type
borderif true border is colored with specific color

References Style_Model.AutoRaiseEffect, Style_Model.BorderTop, BUT_PERCENT_ON, Style_Model.color(), hasHover(), HIGH_WDG_MARGIN, Style_Model.HighlightBorder, Style_Model.HighlightEffect, Style_Tools.highlightRect(), Style_Model.HighlightWidget, model(), and Style_Model.widgetEffect().

void Style_Salome::drawHandle ( QPainter *  p,
const QRect &  r,
bool  horiz,
bool  isRect = true 
) const [private]
Parameters:
ppainter
rrectangle
horizif true draw horizontal handle, otherwise draw vertical handle
isRectif true surrounding rectangle is also drawn

References Style_Model.handleDelta(), hole_xpm, Horizontal, model(), and Vertical.

void Style_Salome::drawBackground ( QPainter *  p,
const QRect &  r,
const QColor &  bgCol,
const bool  fill,
const bool  grad = false,
const bool  horiz = true 
) const [private]
Parameters:
ppainter
rrectangle
bgColbackground color
fill'fill rectangle' flag
grad'draw gradient' flag
horix'draw horizontal item' flag (usefull for gradient background)

References BUT_PERCENT_ON, test_table.c, Style_Model.color(), Style_Model.Horizontal, Style_Model.Inclined, Style_Model.Lines, and model().

void Style_Salome::drawBorder ( QPainter *  p,
const QRect &  r,
bool  horiz 
) const [private]
Parameters:
ppainter
rrectangle
horiz'draw horizontal item' flag

References Style_Model.color(), model(), Style_Model.TabBorderBottom, and Style_Model.TabBorderTop.

QString Style_Salome::titleText ( const QString &  txt,
const int  W,
const int  H,
QFont &  f 
) const [private]
Parameters:
txtoriginal text
Wpossible width
Hpossible height
fused font
Returns:
corrected title text

Field Documentation

Style_Model * Style_Salome::myModel = 0 [static, private]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS