Version: 6.3.1
Data Structures | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes

Style_Model Class Reference

SALOME style model. More...

#include <Style_Model.h>

Data Structures

struct  AppData

Public Types

enum  ColorRole {
  WindowText = QPalette::WindowText, Button = QPalette::Button, Light = QPalette::Light, Midlight = QPalette::Midlight,
  Dark = QPalette::Dark, Mid = QPalette::Mid, Text = QPalette::Text, BrightText = QPalette::BrightText,
  ButtonText = QPalette::ButtonText, Base = QPalette::Base, Window = QPalette::Window, Shadow = QPalette::Shadow,
  Highlight = QPalette::Highlight, HighlightedText = QPalette::HighlightedText, Link = QPalette::Link, LinkVisited = QPalette::LinkVisited,
  AlternateBase = QPalette::AlternateBase, NoRole = QPalette::NoRole, ToolTipBase = QPalette::ToolTipBase, ToolTipText = QPalette::ToolTipText,
  NColorRoles = QPalette::NColorRoles, BorderTop = NColorRoles, BorderBottom, TabBorderTop,
  TabBorderBottom, FieldLight, FieldDark, Slider,
  Lines, HighlightWidget, HighlightBorder, Header,
  ProgressBar, Pointer, Checked, GridLine,
  LastColor
}
 

Color palette instance enumeration.

More...
enum  LineType { NoLines, Horizontal, Inclined }
 

Lines type.

More...
enum  WidgetRounding { ButtonRadius, EditRadius, FrameRadius, SliderRadius }
enum  WidgetEffect { NoEffect, HighlightEffect, AutoRaiseEffect }
 

Widget effect.

More...

Public Member Functions

 Style_Model ()
 Constructor.
virtual ~Style_Model ()
 Destructor.
void fromApplication (bool=false)
 Initialize model from the current application style.
void fromResources (QtxResourceMgr *, const QString &=QString())
 Initialize model from the resources.
void save (QtxResourceMgr *=0, const QString &=QString())
 Save SALOME stype properties to the resource file.
void update ()
 Reload SALOME style properties from the resources file(s).
void restore ()
 Restore original style, palette and font to the application.
QtxResourceMgrresourceMgr () const
 Get resource manager used by this SALOME style model.
QString resourceSection () const
 Get resources section name.
QColor color (ColorRole, QPalette::ColorGroup=QPalette::Active) const
 Get palette color value.
void setColor (ColorRole, const QColor &, const QColor &=QColor(), const QColor &=QColor())
 Set palette color value.
void setColor (ColorRole, QPalette::ColorGroup, const QColor &)
 Set palette color value.
bool isAutoPalette () const
 Returns 'auto-calculating color values' flag.
void setAutoPalette (bool)
 Set/clear 'auto-calculating color values' flag.
LineType linesType () const
 Get lines type.
void setLinesType (LineType)
 Set lines type.
int linesTransparency () const
 Get lines transparency value.
void setLinesTransparency (int)
 Set lines transparency value.
QFont applicationFont () const
 Get application font.
void setApplicationFont (const QFont &)
 Set application font.
double widgetRounding (WidgetRounding) const
 Get widget corners rounding radius value.
void setWidgetRounding (WidgetRounding, double)
 Set widget corners rounding radius value.
bool antialiasing () const
 Get anti-aliasing flag value.
void setAntialiasing (bool)
 Set anti-aliasing flag value.
WidgetEffect widgetEffect () const
 Get widget effect.
void setWidgetEffect (WidgetEffect)
 Set widget effect.
int handleDelta (Qt::Orientation) const
 Get handle spacing value.
void setHandleDelta (Qt::Orientation, int)
 Set handle spacing value.
int splitHandleLength () const
 Get splitter handle length.
void setSplitHandleLength (int)
 Set splitted handle length.
int sliderSize () const
 Get slider handle extra size.
void setSliderSize (int)
 Set slider handle extra size.

Private Types

typedef QMap< ColorRole, QColor > ColorMap
typedef QMap
< QPalette::ColorGroup,
ColorMap
ColorGroupMap
typedef QMap< WidgetRounding,
double > 
RoundMap
typedef QMap< Qt::Orientation,
int > 
DeltaMap

Private Member Functions

void initDefaults ()
 Initialize model with the default values.
void readColorValue (ColorRole, const QString &)
 Read palette color values from resources manager.
void writeColorValue (ColorRole, const QString &, QtxResourceMgr *, const QString &) const
 Write palette color values to resources manager.

Private Attributes

QtxResourceMgrmyResourceMgr
QString myResourceSection
ColorGroupMap myColors
bool myAutoPalette
RoundMap myWidgetRounding
DeltaMap myHandleDelta
QFont myFont
LineType myLinesType
WidgetEffect myWidgetEffect
bool myAntiAliasing
int myLinesTransparency
int mySplitHandleLength
int mySliderSize

Static Private Attributes

static AppDatamyAppData = 0
 Application style data.

Detailed Description

Style model class stores properties of the SALOME style, like palette colors, widget roundings etc. It allows reading these properties from the resource file and write them back to resource file.

SALOME_Style class provides an access to the global style model (which is applied to the application). To get access to the global SALOME style model, use static Style_Model.model() function.

See also:
Style_Salome class

Member Typedef Documentation

typedef QMap<ColorRole, QColor> Style_Model.ColorMap [private]
typedef QMap<QPalette::ColorGroup, ColorMap> Style_Model.ColorGroupMap [private]
typedef QMap<WidgetRounding, double> Style_Model.RoundMap [private]
typedef QMap<Qt::Orientation, int> Style_Model.DeltaMap [private]

Member Enumeration Documentation

Enumerator:
WindowText 

A general foreground color.

Button 

The general button background color.

Light 

Usually lighter than Button color.

Midlight 

Usually between Button and Light.

Dark 

Usually darker than Button.

Mid 

Usualliy between Button and Dark.

Text 

The foreground color used with Base.

BrightText 

A text color that is very different from WindowText, and contrasts well with e.g. Dark.

ButtonText 

A foreground color used with the Button color.

Base 

Used mostly as the background color for text entry widgets.

Window 

A general background color.

Shadow 

Usually a very dark palette color.

Highlight 

A color to indicate a selected item or the current item.

HighlightedText 

A text color that contrasts with Highlight.

Link 

A text color used for unvisited hyperlinks.

LinkVisited 

A text color used for already visited hyperlinks.

AlternateBase 

Used as the alternate background color in views with alternating row colors.

NoRole 

No role; this special role is often used to indicate that a role has not been assigned.

ToolTipBase 

Used as the background color for QToolTip and QWhatsThis.

ToolTipText 

Used as the foreground color for QToolTip and QWhatsThis.

NColorRoles 

Used to indicate last standard palette color.

BorderTop 

Used to draw top-left borders of the widgets.

BorderBottom 

Used to draw bottom-right borders of the widgets.

TabBorderTop 

Used to draw top-left borders of the tab panels.

TabBorderBottom 

Used to draw bottom-right borders of the tab panels.

FieldLight 

Light component of the text entry widgets.

FieldDark 

Dark component of the text entry widgets.

Slider 

Used to draw sliders.

Lines 

Used to draw lines throughout all the widgets.

HighlightWidget 

Used to draw widget background when widget is hovered.

HighlightBorder 

Used to draw widget borders when widget is hovered.

Header 

Used to draw header of tab panels.

ProgressBar 

Main progress bar color.

Pointer 

Used to draw different widgets indicators like spin box arrows etc.

Checked 

Check box indicator color.

GridLine 

Used to draw table widgets grid.

LastColor 

Points to the last color; no specific meaning.

Enumerator:
NoLines 

Do not draw lines.

Horizontal 

Draw horozontal lines.

Inclined 

Draw inclined lines.

Enumerator:
ButtonRadius 

Buttons rounding.

EditRadius 

Text entry widgets rounding.

FrameRadius 

Frames rounding.

SliderRadius 

Sliders rounding.

Enumerator:
NoEffect 

Do not use widget effects.

HighlightEffect 

Highlight widget when it is hovered.

AutoRaiseEffect 

Raise widget when it is hovered.


Constructor & Destructor Documentation

Style_Model::Style_Model ( )

Create new SALOME style model with default properties.

References initDefaults().

Style_Model::~Style_Model ( ) [virtual]

Member Function Documentation

void Style_Model::fromApplication ( bool  reset = false)

This function is useful when it is necessary to set/remove SALOME style dynamically. Function fromApplication() saves current application properties (style, palette, font) which can be later restored with the restore() function.

The simplest way it can be done is using static functions of Style_Salome class: Style_Salome.apply(), Style_Salome.restore()

Parameters:
resetif true model is also initializes preoperties from the application
See also:
restore(), fromResources()
Style_Salome class

References BorderBottom, BorderTop, Checked, FieldDark, FieldLight, GridLine, Header, HighlightBorder, HighlightWidget, initDefaults(), Style_Salome.isActive(), Lines, myAppData, myColors, myFont, Style_Model.AppData.myFont, Style_Model.AppData.myPalette, Style_Model.AppData.myStyle, NColorRoles, Pointer, ProgressBar, setColor(), Slider, TabBorderBottom, TabBorderTop, and WindowText.

void Style_Model::fromResources ( QtxResourceMgr resMgr,
const QString &  resSection = QString() 
)
void Style_Model::save ( QtxResourceMgr resMgr = 0,
const QString &  resSection = QString() 
)
void Style_Model::update ( )
void Style_Model::restore ( )

This function should be used in conjunction with fromApplication() method. Sets initial style, color palette and font to the application. If SALOME style model has not been initialized from the application, this function does nothing.

See also:
fromApplication()

References myAppData, Style_Model.AppData.myFont, Style_Model.AppData.myPalette, and Style_Model.AppData.myStyle.

QtxResourceMgr * Style_Model::resourceMgr ( ) const
Returns:
pointer to the resource manager passed previously to the fromResources() method
See also:
initFromResources(), resourceSection()

References myResourceMgr.

QString Style_Model::resourceSection ( ) const

If section name is empty, default "Theme" is returned

Returns:
resource section name passed previously to the fromResources() method
See also:
initFromResources(), resourceMgr()

References myResourceSection.

QColor Style_Model::color ( ColorRole  role,
QPalette::ColorGroup  cg = QPalette::Active 
) const
Parameters:
rolecolor role
cgcolor group
Returns:
a color which should be used to draw the corresponding part of the application
See also:
setColor()

References test_table.c, and myColors.

void Style_Model::setColor ( Style_Model::ColorRole  role,
const QColor &  active,
const QColor &  inactive = QColor(),
const QColor &  disabled = QColor() 
)

If inactive and/or disabled colors are not specified, they are automatically calculated from active color.

Parameters:
rolecolor role
activea color to be used with active color group (QPalette.Active)
inactivea color to be used with inactive color group (QPalette.Inactive)
disableda color to be used with disabled color group (QPalette.Disabled)
See also:
color()

References AlternateBase, Base, Button, color(), Light, Midlight, mixColors(), Text, and WindowText.

void Style_Model::setColor ( Style_Model::ColorRole  role,
QPalette::ColorGroup  cg,
const QColor &  c 
)

If inactive and/or disabled colors are not specified, they are automatically calculated from active color.

Parameters:
rolecolor role
cgcolor group
ccolor which should be used to draw the corresponding part of the application
See also:
color()

References test_table.c, and myColors.

bool Style_Model::isAutoPalette ( ) const
Returns:
'auto-calculating color values' flag
See also:
setAutoPalette()

References myAutoPalette.

void Style_Model::setAutoPalette ( bool  on)
Parameters:
onnew value of 'auto-calculating color values' flag
See also:
isAutoPalette()

References myAutoPalette.

Style_Model::LineType Style_Model::linesType ( ) const
Returns:
current lines type
See also:
setLinesType(), linesTransparency()

References myLinesType.

void Style_Model::setLinesType ( LineType  lt)
Parameters:
ltnew lines type
See also:
linesType(), linesTransparency()

References myLinesType.

int Style_Model::linesTransparency ( ) const
Returns:
current lines transparency
See also:
setLinesTransparency(), linesType()

References myLinesTransparency.

void Style_Model::setLinesTransparency ( int  transparency)
Parameters:
transparencynew lines transparency
See also:
linesTransparency(), linesType()

References myLinesTransparency.

QFont Style_Model::applicationFont ( ) const
Returns:
current application font
See also:
setApplicationFont()

References myFont.

void Style_Model::setApplicationFont ( const QFont &  font)
Parameters:
fontnew application font
See also:
applicationFont()

References myFont.

double Style_Model::widgetRounding ( Style_Model::WidgetRounding  wr) const
Parameters:
wrwidget type
Returns:
current widget corners rounding
See also:
setWidgetRounding(), antialiasing()

References myWidgetRounding.

void Style_Model::setWidgetRounding ( WidgetRounding  wr,
double  value 
)
Parameters:
wrwidget type
valuenew widget corners rounding
See also:
widgetRounding(), antialiasing()

References myWidgetRounding.

bool Style_Model::antialiasing ( ) const
Returns:
true if widgets borders should be antialiased
See also:
setAntialiasing(), widgetRounding()

References myAntiAliasing.

void Style_Model::setAntialiasing ( bool  value)
Parameters:
valueif true, widgets borders should be antialiased
See also:
antialiasing(), widgetRounding()

References myAntiAliasing.

Style_Model::WidgetEffect Style_Model::widgetEffect ( ) const
Returns:
current widget effect
See also:
setWidgetEffect()

References myWidgetEffect.

void Style_Model::setWidgetEffect ( WidgetEffect  we)
Parameters:
wenew widget effect
See also:
widgetEffect()

References myWidgetEffect.

int Style_Model::handleDelta ( Qt::Orientation  o) const
Parameters:
ohandle spacing direction
Returns:
current handle spacing value
See also:
setHandleDelta()

References myHandleDelta.

void Style_Model::setHandleDelta ( Qt::Orientation  o,
int  value 
)
Parameters:
ohandle spacing direction
valuenew handle spacing value
See also:
handleDelta()

References myHandleDelta.

int Style_Model::splitHandleLength ( ) const
Returns:
current splitter handle length
See also:
setSplitHandleLength()

References mySplitHandleLength.

void Style_Model::setSplitHandleLength ( int  value)
Parameters:
valuenew splitter handle length
See also:
splitHandleLength()

References mySplitHandleLength.

int Style_Model::sliderSize ( ) const
Returns:
current slider handle extra size
See also:
setSliderSize()

References mySliderSize.

void Style_Model::setSliderSize ( int  value)
Parameters:
valuenew slider handle extra size
See also:
sliderSize()

References mySliderSize.

void Style_Model::initDefaults ( ) [private]
void Style_Model::readColorValue ( ColorRole  role,
const QString &  prefix 
) [private]
Parameters:
rolecolor role
prefixpalette color value resource name prefix
See also:
writeColorValue()

References resourceMgr(), resourceSection(), and setColor().

void Style_Model::writeColorValue ( ColorRole  role,
const QString &  prefix,
QtxResourceMgr resMgr,
const QString &  resSection 
) const [private]
Parameters:
rolecolor role
prefixpalette color value resource name prefix
resMgrresource manager
resSectionresource section name
See also:
readColorValue()

References color(), and QtxResourceMgr.setValue().


Field Documentation

QString Style_Model.myResourceSection [private]
bool Style_Model.myAutoPalette [private]
QFont Style_Model.myFont [private]
int Style_Model.mySliderSize [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