Version: 9.12.0
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. More...
 
virtual void polish (QApplication *)
 Initialize the appearance of the application. More...
 
virtual void polish (QWidget *)
 Initializes the appearance of the given widget. More...
 
virtual void unpolish (QWidget *)
 Uninitialize the given widget's appearance. More...
 
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. More...
 
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. More...
 
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. More...
 
virtual int pixelMetric (PixelMetric, const QStyleOption *=0, const QWidget *=0) const
 Returns the value of the given pixel metric. More...
 
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. More...
 
virtual QPixmap standardPixmap (StandardPixmap, const QStyleOption *, const QWidget *=0) const
 Returns a pixmap for the given standardPixmap. More...
 
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. More...
 
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. More...
 
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. More...
 

Static Public Member Functions

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

Protected Slots

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

Private Member Functions

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

Static Private Attributes

static Style_ModelmyModel = 0
 

Detailed Description

SALOME style class.

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
static void apply()
Set SALOME style to the application.
Definition: Style_Salome.cxx:244
static void initialize(QtxResourceMgr *=0, const QString &=QString())
Initialize SALOME style.
Definition: Style_Salome.cxx:235

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();
SALOME style prefences dialog box class.
Definition: Style_PrefDlg.h:49

Constructor & Destructor Documentation

◆ Style_Salome()

Style_Salome::Style_Salome ( )
private

Constructor.

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

◆ ~Style_Salome()

Style_Salome::~Style_Salome ( )
virtual

Destructor.

Member Function Documentation

◆ apply()

void Style_Salome::apply ( )
static

Set SALOME style to the application.

See also
initialize(), restore()

References isActive(), model(), Style_Salome(), Style_Model::update(), and update().

◆ drawBackground()

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

Draw background.

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, Style_Model::color(), Style_Model::Horizontal, Style_Model::Inclined, Style_Model::Lines, and model().

◆ drawBorder()

void Style_Salome::drawBorder ( QPainter *  p,
const QRect &  r,
bool  horiz 
) const
private

Draw border.

Parameters
ppainter
rrectangle
horiz'draw horizontal item' flag

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

◆ drawComplexControl()

◆ drawControl()

◆ drawHandle()

void Style_Salome::drawHandle ( QPainter *  p,
const QRect &  r,
bool  horiz,
bool  isRect = true 
) const
private

Draw widget handle.

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.

◆ drawHoverRect()

void Style_Salome::drawHoverRect ( QPainter *  p,
const QRect &  r,
const QColor &  bgCol,
const double  rad,
const int  type,
const bool  border 
) const
private

Draw rectangle for the hovered widget.

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().

◆ drawPrimitive()

◆ hasHover()

bool Style_Salome::hasHover ( ) const
private

Check if any widget effect is currently used.

Returns
true if any widget effect is currently used

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

◆ initialize()

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

Initialize SALOME style.

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().

◆ isActive()

bool Style_Salome::isActive ( )
static

Check if the SALOME style is currently set to application.

Returns
true if SALOME style is set to the applcation or false otherwise

◆ model()

Style_Model * Style_Salome::model ( )
static

Get style model.

Returns
style model

References myModel.

◆ pixelMetric()

int Style_Salome::pixelMetric ( PixelMetric  metric,
const QStyleOption *  opt = 0,
const QWidget w = 0 
) const
virtual

Returns the value of the given pixel metric.

Parameters
metricmetric type
optstyle option
wwidget
Returns
metric value

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

◆ polish() [1/2]

void Style_Salome::polish ( QApplication app)
virtual

Initialize the appearance of the application.

Performs late initialization of the given application object.

Parameters
appapplication object

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

◆ polish() [2/2]

void Style_Salome::polish ( QWidget w)
virtual

Initializes the appearance of the given widget.

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(), and hasHover().

◆ restore()

void Style_Salome::restore ( )
static

Restore original style to the application.

See also
initialize(), apply()

References isActive(), model(), and Style_Model::restore().

◆ sizeFromContents()

QSize Style_Salome::sizeFromContents ( ContentsType  ct,
const QStyleOption *  opt,
const QSize &  contentsSize,
const QWidget w = 0 
) const
virtual

Returns the size of the element described by the specified option opt and type ct, based on the provided contentsSize.

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(), and Style_Model::widgetRounding().

◆ standardIconImplementation

QIcon Style_Salome::standardIconImplementation ( StandardPixmap  standardIcon,
const QStyleOption *  opt = 0,
const QWidget w = 0 
) const
protectedslot

Returns an icon for the given standardIcon.

Parameters
standardIconstandard icon type
optstyle option
wwidget (optional)
Returns
standard icon

References checkDebugLevel().

◆ standardPixmap()

QPixmap Style_Salome::standardPixmap ( StandardPixmap  stPixmap,
const QStyleOption *  opt,
const QWidget w = 0 
) const
virtual

Returns a pixmap for the given standardPixmap.

Parameters
stPixmapstandard pixmap type
optstyle option
wwidget (optional)
Returns
standard pixmap

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

◆ styleHint()

int Style_Salome::styleHint ( StyleHint  hint,
const QStyleOption *  opt = 0,
const QWidget w = 0,
QStyleHintReturn *  returnData = 0 
) const
virtual

Returns an integer representing the specified style hint for the given widget w described by the provided style option opt.

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().

◆ subControlRect()

QRect Style_Salome::subControlRect ( ComplexControl  cc,
const QStyleOptionComplex *  opt,
SubControl  sc,
const QWidget wid = 0 
) const
virtual

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.

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().

◆ subElementRect()

QRect Style_Salome::subElementRect ( SubElement  se,
const QStyleOption *  opt,
const QWidget wid = 0 
) const
virtual

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.

Parameters
sesubelement type
optstyle option
widwidget (optional)
Returns
subelement rectangle

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

◆ titleText()

QString Style_Salome::titleText ( const QString &  txt,
const int  W,
const int  H,
QFont &  f 
) const
private

Get corrected title text.

Parameters
txtoriginal text
Wpossible width
Hpossible height
fused font
Returns
corrected title text

◆ unpolish()

void Style_Salome::unpolish ( QWidget w)
virtual

Uninitialize the given widget's appearance.

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().

◆ update()

void Style_Salome::update ( )
static

Update style from resources.

◆ updateAllWidgets()

void Style_Salome::updateAllWidgets ( QApplication app)
private

Update all widgets with the current style properties.

Parameters
appapplication object

References polish().

◆ updatePaletteColors()

void Style_Salome::updatePaletteColors ( )
private

Update palette colors from style model.

References Style_Model::color(), model(), Style_Model::NColorRoles, and Style_Model::WindowText.

Member Data Documentation

◆ myModel

Style_Model * Style_Salome::myModel = 0
staticprivate

The documentation for this class was generated from the following files: