#
# Check existence of Test recorder sources and libraries.
-# Set DISABLE_TESTRECORDER to yes|no
+# Set ENABLE_TESTRECORDER to yes|no
#
# Author : Margarita KARPUNINA (OCN, 2008)
#
TESTRECORDER_INCLUDES=""
TESTRECORDER_LIBS=""
- DISABLE_TESTRECORDER="yes"
+ ENABLE_TESTRECORDER="no"
TestRecorder_ok=no
AC_MSG_WARN(TestRecorder is not found or not properly installed)
else
AC_MSG_RESULT(for TestRecorder: yes)
- DISABLE_TESTRECORDER="no"
+ ENABLE_TESTRECORDER="yes"
fi
AC_SUBST(TESTRECORDER_INCLUDES)
TEST_LIB_DIRS="${TEST_LIB_DIRS} /usr/lib${LIB_LOCATION_SUFFIX} /usr/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages"
TEST_LIB_DIRS="${TEST_LIB_DIRS} /usr/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/site-packages/PyQt4"
TEST_SIPS_DIRS="${TEST_SIPS_DIRS} /usr/share/sip"
+ TEST_SIPS_DIRS="${TEST_SIPS_DIRS} /usr/share/sip/PyQt4"
dnl check PyQt libs
pyqt_ok=no
# is necessary for loading of .ini or .xml resources file
###
-if ( ! $?LightAppConfig ) setenv LightAppConfig ${GUI_ROOT_DIR}/share/salome/resources/gui
-if ( ! $?LightAppResources ) setenv LightAppResources ${GUI_ROOT_DIR}/share/salome/resources/gui
+if ( ! ($?LightAppConfig) ) then
+ setenv LightAppConfig ${GUI_ROOT_DIR}/share/salome/resources/gui
+else
+ setenv LightAppConfig ${LightAppConfig}:${GUI_ROOT_DIR}/share/salome/resources/gui
+endif
+if ( ! ($?LightAppResources) ) then
+ setenv LightAppResources ${GUI_ROOT_DIR}/share/salome/resources/gui
+else
+ setenv LightAppResources ${LightAppResources}:${GUI_ROOT_DIR}/share/salome/resources/gui
+endif
###
# default settings
# start application
###
-SUITApp LightApp -style salome $* &
+SUITApp LightApp $* &
if [ -z "$LightAppConfig" ] ; then
export LightAppConfig=${GUI_ROOT_DIR}/share/salome/resources/gui
+else
+ export LightAppConfig=${LightAppConfig}:${GUI_ROOT_DIR}/share/salome/resources/gui
fi
if [ -z "$LightAppResources" ] ; then
export LightAppResources=${GUI_ROOT_DIR}/share/salome/resources/gui
+else
+ export LightAppResources=${LightAppResources}:${GUI_ROOT_DIR}/share/salome/resources/gui
fi
###
# start application
###
-SUITApp LightApp -style salome $* &
+SUITApp LightApp $* &
# Modified by : Mikhail PONIKAROV (OCN) - autotools usage
#
-AC_INIT([Salome2 Project GUI module], [5.0.0], [webmaster.salome@opencascade.com], [SalomeGUI])
+AC_INIT([Salome2 Project GUI module], [5.1.0], [webmaster.salome@opencascade.com], [SalomeGUI])
AC_CONFIG_AUX_DIR(salome_adm/unix/config_files)
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AM_CONDITIONAL(ENABLE_VTKVIEWER, [test "$DISABLE_VTKVIEWER" = no])
AM_CONDITIONAL(ENABLE_SALOMEOBJECT, [test "$DISABLE_SALOMEOBJECT" = no])
AM_CONDITIONAL(ENABLE_QXGRAPHVIEWER, [test "$DISABLE_QXGRAPHVIEWER" = no])
-AM_CONDITIONAL(ENABLE_TESTRECORDER, [test "$DISABLE_TESTRECORDER" = no])
+AM_CONDITIONAL(ENABLE_TESTRECORDER, [test "$ENABLE_TESTRECORDER" = yes])
echo
echo ---------------------------------------------
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
BRIEF_MEMBER_DESC = YES
-REPEAT_BRIEF = NO
+REPEAT_BRIEF = YES
ABBREVIATE_BRIEF =
ALWAYS_DETAILED_SEC = YES
INLINE_INHERITED_MEMB = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
-HIDE_UNDOC_MEMBERS = YES
-HIDE_UNDOC_CLASSES = YES
+HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
-SORT_MEMBER_DOCS = NO
+SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
-WARN_LOGFILE =
+WARN_LOGFILE = log.txt
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
-SOURCE_BROWSER = NO
-INLINE_SOURCES = NO
+SOURCE_BROWSER = YES
+INLINE_SOURCES = YES
STRIP_CODE_COMMENTS = YES
-REFERENCED_BY_RELATION = NO
+REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
-USE_HTAGS = NO
+#USE_HTAGS = NO
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
-COLS_IN_ALPHA_INDEX = 3
+COLS_IN_ALPHA_INDEX = 2
IGNORE_PREFIX =
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = .
HTML_FILE_EXTENSION = .html
-HTML_HEADER = @srcdir@/static/myheader.html
-HTML_FOOTER = @srcdir@/static/footer.html
-HTML_STYLESHEET = @srcdir@/static/doxygen.css
+#HTML_HEADER = @srcdir@/static/myheader.html
+#HTML_FOOTER = @srcdir@/static/footer.html
+#HTML_STYLESHEET = @srcdir@/static/doxygen.css
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
-BINARY_TOC = YES
-TOC_EXPAND = YES
+BINARY_TOC = NO
+TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
-GENERATE_TREEVIEW = NO
+GENERATE_TREEVIEW = YES
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
-MACRO_EXPANSION = YES
+MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
-SKIP_FUNCTION_MACROS = NO
+SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
HIDE_UNDOC_RELATIONS = NO
HAVE_DOT = YES
CLASS_GRAPH = YES
-COLLABORATION_GRAPH = NO
-GROUP_GRAPHS = NO
+COLLABORATION_GRAPH = YES
+GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = YES
INCLUDE_GRAPH = YES
-INCLUDED_BY_GRAPH = NO
+INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
-DOT_IMAGE_FORMAT = jpg
+DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
-MAX_DOT_GRAPH_HEIGHT = 1200
-MAX_DOT_GRAPH_DEPTH = 0
+MAX_DOT_GRAPH_HEIGHT = 1024
+MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
-GENERATE_LEGEND = NO
+GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
editUndo->setComment( tr( "INF_APP_UNDOACTIONS" ) );
editRedo->setComment( tr( "INF_APP_REDOACTIONS" ) );
- connect( editUndo, SIGNAL( activated( int ) ), this, SLOT( onUndo( int ) ) );
- connect( editRedo, SIGNAL( activated( int ) ), this, SLOT( onRedo( int ) ) );
+ connect( editUndo, SIGNAL( triggered( int ) ), this, SLOT( onUndo( int ) ) );
+ connect( editRedo, SIGNAL( triggered( int ) ), this, SLOT( onRedo( int ) ) );
int editMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1, 10 );
#ifndef CAF_TOOLS_H
#define CAF_TOOLS_H
-#include <CAF.h>
+#include "CAF.h"
#include <SUIT_Tools.h>
/*!
\brief Get data object icon for the specified column.
- The parameter \a index specifies the column number
- (to display, for example, in the tree view widget).
+ The parameter \a id specifies the column identificator
- \param index column index
+ \param id column id
\return object icon for the specified column
*/
-QPixmap CAM_ModuleObject::icon( const int index ) const
+QPixmap CAM_ModuleObject::icon( const int id ) const
{
QPixmap p;
// show icon only for the "Name" column
- if ( index == NameIdx && dataModel() && dataModel()->module() )
+ if ( id == NameId && dataModel() && dataModel()->module() )
p = dataModel()->module()->moduleIcon();
if ( !p.isNull() )
p = Qtx::scaleIcon( p, 16 );
/*!
\brief Get data object tooltip for the specified column.
- The parameter \a index specifies the column number
- (to display, for example, in the tree view widget).
+ The parameter \a id specifies the column identificator
- \param index column index
+ \param id column id
\return object tooltip for the specified column
*/
-QString CAM_ModuleObject::toolTip( const int /*index*/ ) const
+QString CAM_ModuleObject::toolTip( const int /*id*/ ) const
{
// show the same tooltip for all columns
QString tip;
virtual ~CAM_ModuleObject();
virtual QString name() const;
- QPixmap icon( const int = NameIdx ) const;
- QString toolTip( const int = NameIdx ) const;
+ QPixmap icon( const int = NameId ) const;
+ QString toolTip( const int = NameId ) const;
virtual CAM_DataModel* dataModel() const;
virtual void setDataModel( CAM_DataModel* );
#include <UnitsAPI.hxx>
-#include <TColStd_SequenceOfAsciiString.hxx>
-
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>
if ( !myUnitSystem.IsBound( aName ) )
myUnitSystem.Bind( aName, aLabel );
+
+
}
}
aDicItem->myComponent = this;
aDicItem->FillDataMap( anID, aQuantity, theComponentData, theDocElement, unitSystems );
myDataMap.Add( anID, aDicItem );
+
+ bool exist = false;
+ for( int i=1, n=myKeys.Length(); i<=n && !exist; i++ )
+ if( myKeys.Value( i )==anID )
+ {
+ cout << "Doubled key:" << anID << endl;
+ exist = true;
+ }
+ if( !exist )
+ myKeys.Append( anID );
}
}
return aDicItem;
}
+
+/*!
+ \brief Return all keys of the group
+ \param seq - string container to be filled with keys
+*/
+void DDS_DicGroup::GetKeys( TColStd_SequenceOfAsciiString& seq ) const
+{
+ seq = myKeys;
+}
#include "DDS_DicItem.h"
#include <MMgt_TShared.hxx>
-
-#include <TCollection_AsciiString.hxx>
-
+#include <TColStd_SequenceOfAsciiString.hxx>
#include <NCollection_List.hxx>
class LDOM_Element;
-class TColStd_SequenceOfAsciiString;
DEFINE_STANDARD_HANDLE(DDS_DicGroup, MMgt_TShared)
DDS_DicGroup( const TCollection_AsciiString& );
TCollection_AsciiString GetName() const;
+ Standard_EXPORT void GetKeys( TColStd_SequenceOfAsciiString& ) const;
Standard_EXPORT Handle(DDS_DicItem) GetDicItem( const TCollection_AsciiString& ) const;
DDS_IndexedDataMapOfDicItems myDataMap;
UnitSystemMap myUnitSystem;
TCollection_AsciiString myActiveSystem;
+ TColStd_SequenceOfAsciiString myKeys;
friend class DDS_Dictionary;
LDOM_Element anOpt = theDatum.GetChildByTagName( DDS_Dictionary::KeyWord( "OPTIONS" ) );
if ( !anOpt.isNull() )
{
- LDOM_NodeList anOptions = anOpt.getElementsByTagName( DDS_Dictionary::KeyWord( "OPTION" ) );
+ LDOM_NodeList anOptions = anOpt.GetAttributesList();//anOpt.getElementsByTagName( DDS_Dictionary::KeyWord( "OPTION" ) );
for ( Standard_Integer oi = 0; oi < anOptions.getLength(); oi++ )
{
LDOM_Node node = anOptions.item( oi );
- if ( node.getNodeType() != LDOM_Node::ELEMENT_NODE )
- continue;
-
- LDOM_Element& elem = (LDOM_Element&)node;
- TCollection_AsciiString name = elem.getAttribute( DDS_Dictionary::KeyWord( "OPTION_NAME" ) );
+ LDOM_Node::NodeType t = node.getNodeType();
+ TCollection_AsciiString name;
TCollection_ExtendedString value;
- const LDOM_Node aNode = elem.getFirstChild();
- LDOM_Text anOptTxt( (const LDOM_Text&)(aNode) );
- if ( !anOptTxt.isNull() )
- value = anOptTxt.getData();
+
+ if( t==LDOM_Node::ELEMENT_NODE )
+ {
+ const LDOM_Element& elem = ( const LDOM_Element& )node;
+ name = elem.getAttribute( DDS_Dictionary::KeyWord( "OPTION_NAME" ) );
+
+ const LDOM_Node aNode = elem.getFirstChild();
+ LDOM_Text anOptTxt( (const LDOM_Text&)(aNode) );
+ if ( !anOptTxt.isNull() )
+ value = anOptTxt.getData();
+ }
+ else if( t==LDOM_Node::ATTRIBUTE_NODE )
+ {
+ const LDOM_Attr& attr = ( const LDOM_Attr& )node;
+ name = ( Standard_CString )attr.getName().GetString();
+ LDOMString v = attr.getValue();
+ if( v.Type()==LDOMBasicString::LDOM_Integer )
+ {
+ Standard_Integer ival;
+ v.GetInteger( ival );
+ value = TCollection_ExtendedString( ival );
+ }
+ else
+ value = ( Standard_CString )v.GetString();
+ }
+ else
+ continue;
if ( !name.IsEmpty() && value.Length() && !myOptions.IsBound( name ) )
myOptions.Bind( name, value );
return aRetValue;
}
+
+/*!
+ \brief Fill given string container \a seq with keys belonging to group with name \a theComponent
+ \param theComponent name of group whose keys should be stored in the container
+ \param seq returned string container with keys belonging to group; it is not cleared before filling
+*/
+void DDS_Dictionary::GetKeys( const TCollection_AsciiString& theComponent, TColStd_SequenceOfAsciiString& seq ) const
+{
+ Handle( DDS_DicGroup ) aDicGroup;
+ if( myGroupMap.Contains( theComponent ) )
+ aDicGroup = myGroupMap.FindFromKey( theComponent );
+
+ if( !aDicGroup.IsNull() )
+ aDicGroup->GetKeys( seq );
+}
// Return instance of data dictionary. Create instance if it is NULL.
+ Standard_EXPORT void GetKeys( const TCollection_AsciiString&, TColStd_SequenceOfAsciiString& ) const;
+
Standard_EXPORT Handle(DDS_DicItem) GetDicItem( const TCollection_AsciiString& ) const;
Standard_EXPORT Handle(DDS_DicItem) GetDicItem( const TCollection_AsciiString&,
const TCollection_AsciiString& ) const;
#ifndef SALOME_EVENT_H
#define SALOME_EVENT_H
-#include <Event.h>
+#include "Event.h"
#include <QEvent>
//
//#include <GLViewerAfx.h>
-#include <GLViewer_Geom.h>
+#include "GLViewer_Geom.h"
#define FAR_POINT 1e10 // Value used as a "very distant" co-ordinate
#define TOLERANCE 1e-3
#include <GL/gl.h>
#include <iostream>
+#include <string.h>
/*!
Constructor
#include <SALOME_Event.h>
-#include <Style_Model.h>
#include <Style_Salome.h>
+#include <Style_PrefDlg.h>
#include <CAM_Module.h>
#include <CAM_DataModel.h>
#ifndef DISABLE_PLOT2DVIEWER
#include <Plot2d_ViewManager.h>
#include <Plot2d_ViewModel.h>
+ #include "LightApp_Plot2dSelector.h"
#ifndef DISABLE_SALOMEOBJECT
#include <SPlot2d_ViewModel.h>
#else
createMenu( MRUId, fileMenu, 100, -1 );
createMenu( separator(), fileMenu, -1, 100, -1 );
+ createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
+ 0, desk, false, this, SLOT( onStylePreferences() ) );
+
+ int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
+ createMenu( separator(), viewMenu, -1, 20, -1 );
+ createMenu( StyleId, viewMenu, 20, -1 );
+
int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ) );
createTool( ModulesListId, modTBar );
}
viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
Plot2d_Viewer* vm;
#ifndef DISABLE_SALOMEOBJECT
- vm = new SPlot2d_Viewer();
+ SPlot2d_Viewer* v = new SPlot2d_Viewer();
+ vm = v;
+ new LightApp_Plot2dSelector( v, mySelMgr );
#else
vm = new Plot2d_Viewer();
#endif
{
viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
OCCViewer_Viewer* vm;
+ bool staticTrihedron = resMgr->booleanValue( "OCCViewer", "static_trihedron", true );
#ifndef DISABLE_SALOMEOBJECT
vm = new SOCC_Viewer();
#else
- vm = new OCCViewer_Viewer();
+ vm = new OCCViewer_Viewer( true, staticTrihedron );
#endif
vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
vm->setTrihedronSize( resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
- int SalomeStyleGroup = pref->addPreference( tr( "PREF_GROUP_STYLE" ), genTab );
- pref->addPreference( tr( "PREF_USE_SALOME_STYLE" ), SalomeStyleGroup, LightApp_Preferences::Bool, "Style", "use_salome_style" );
- if ( resourceMgr() )
- resourceMgr()->booleanValue( "Style", "use_salome_style", true );
-
int viewTab = pref->addPreference( tr( "PREF_TAB_VIEWERS" ), salomeCat );
int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), viewTab );
pref->setItemProperty( "strings", aValuesList, mruLinkType );
pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
- // theme values
- Style_Model* aSModel = 0;
- QStyle* style = qApp->style();
- if ( style ) {
- Style_Salome* aSStyle = qobject_cast<Style_Salome*>( style );
- if ( aSStyle )
- aSModel = aSStyle->getModel();
- }
- if ( !aSModel )
- return;
-
- QString aSection = aSModel->sectionName();
- int themaTab = pref->addPreference( aSection, salomeCat );
- QtxResourceMgr* aResMgr = pref->resourceMgr();
- aSModel->initFromResource( aResMgr );
-
- QList<int> aTabLst = aSModel->getTabs();
- QList<int>::iterator aTabIt = aTabLst.begin(), aTabEnd = aTabLst.end();
- QList<int> aGrpLst, aPropLst;
- QList<int>::iterator anIt, anEnd, aPropIt, aPropEnd;
- int aGrpId, aPropId, aPrefId;
- int themaSubTab = pref->addPreference( "ThemeTabs", themaTab,
- SUIT_PreferenceMgr::Tab );
- for ( ; aTabIt != aTabEnd; ++aTabIt ) {
- QList<int> aGrpLst = aSModel->getGroups( *aTabIt );
- int themaSubSubTab = pref->addPreference( aSModel->getTabTitle( *aTabIt ), themaSubTab,
- SUIT_PreferenceMgr::Frame );
- for( anIt = aGrpLst.begin(), anEnd = aGrpLst.end(); anIt != anEnd; ++anIt ) {
- aGrpId = *anIt;
- int themaGroup = pref->addPreference( aSModel->getGroupTitle( aGrpId ), themaSubSubTab, SUIT_PreferenceMgr::GroupBox );
- pref->setItemProperty( "columns", aSModel->getGroupNbColumns( aGrpId ), themaGroup );
- aPropLst = aSModel->getGroupProps( aGrpId );
- for( aPropIt = aPropLst.begin(), aPropEnd = aPropLst.end(); aPropIt != aPropEnd; ++aPropIt ) {
- aPropId = *aPropIt;
- Style_Model::PropType aType = aSModel->getPropType( aPropId );
- LightApp_Preferences::PrefItemType aPType = LightApp_Preferences::Auto;
- switch( aType ) {
- case Style_Model::Bool: aPType = LightApp_Preferences::Bool; break;
- case Style_Model::Color: aPType = LightApp_Preferences::Color; break;
- case Style_Model::String: aPType = LightApp_Preferences::String; break;
- case Style_Model::IntSpin: aPType = LightApp_Preferences::IntSpin; break;
- case Style_Model::DblSpin: aPType = LightApp_Preferences::DblSpin; break;
- case Style_Model::Selector: aPType = LightApp_Preferences::Selector; break;
- case Style_Model::Font: aPType = LightApp_Preferences::Font; break;
- default: break;
- }
- aPrefId = pref->addPreference( aSModel->getPropTitle( aPropId ), themaGroup,
- aPType, aSection, aSModel->getPropName( aPropId ) );
- aSModel->getValueTo( aResMgr, aPropId, true );//set default values into resource
- if ( aPType == LightApp_Preferences::Selector )
- {
- aValuesList.clear();
- anIndicesList.clear();
- aSModel->getSelector( aPropId, aValuesList, anIndicesList );
- pref->setItemProperty( "strings", aValuesList, aPrefId );
- pref->setItemProperty( "indexes", anIndicesList, aPrefId );
- }
- }
- }
- }
pref->retrieve();
}
}
#endif
- Style_Salome* aSStyle = 0;
- if ( QStyle* style = qApp->style() ) aSStyle = qobject_cast<Style_Salome*>( style );
-
- if( sec=="Style" )
- {
- if( param=="use_salome_style" )
- {
- if ( resMgr->booleanValue( "Style", "use_salome_style", true ) )
- {
- if ( !aSStyle )
- {
- aSStyle = new Style_Salome();
- aSStyle->getModel()->initFromResource( resMgr );
- qApp->setStyle( aSStyle );
- }
- }
- else if ( aSStyle )
- {
- qApp->setStyle( new QWindowsStyle );
- }
- }
- }
-
if( sec=="MRU" )
{
QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
}
}
-
- if ( aSStyle ) {
- Style_Model* aSModel = aSStyle->getModel();
- if ( sec==aSModel->sectionName() ) {
- bool retrieve = aSModel->updateFromResource( resMgr, param );
- if ( retrieve && _prefs_ )
- _prefs_->retrieve();
- aSStyle->polish(qApp);
- }
- }
}
/*!
onOpenDoc( name );
}
+void LightApp_Application::onStylePreferences()
+{
+ Style_PrefDlg dlg( desktop() );
+ dlg.exec();
+
+ resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
+}
+
/*!
Connects just added view manager
*/
enum { RenameId = CAM_Application::UserID,
CloseId, CloseAllId, GroupAllId,
PreferencesId, MRUId, ModulesListId,
- NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId, NewQxGraphViewId, NewQxSceneViewId, UserID };
+ NewGLViewId, NewPlot2dId, NewOCCViewId, NewVTKViewId, NewQxGraphViewId,
+ NewQxSceneViewId, StyleId,
+ UserID };
protected:
enum { NewStudyId = 1, OpenStudyId };
virtual bool checkDataObject( LightApp_DataObject* theObj );
+ virtual void updateDesktopTitle();
+
signals:
void studyOpened();
void studySaved();
virtual void loadPreferences();
virtual void savePreferences();
- virtual void updateDesktopTitle();
-
virtual QMap<int, QString> activateModuleActions() const;
virtual void moduleActionSelected( const int );
void onMRUActivated( const QString& );
+ void onStylePreferences();
+
private slots:
void onSelection();
void onRefresh();
#include "LightApp_Module.h"
#include "LightApp_Application.h"
+#include <SUIT_TreeModel.h>
#include <SUIT_DataBrowser.h>
#include <SUIT_DataObject.h>
LightApp_DataModel::LightApp_DataModel( CAM_Module* theModule )
: CAM_DataModel( theModule )
{
+ myGroupId = 0;
+ if( module() )
+ myGroupId = qHash( module()->name() );
}
/*!
{
return true;
}
+
+/*!
+ \return data model group id used for custom columns creation
+*/
+int LightApp_DataModel::groupId() const
+{
+ return myGroupId;
+}
+
+/*!
+ Register custom column in the object browser
+ \param browser - object browser where new column should be created
+ \param name - translated column name
+ \param custom_id - custom column identificator passed into data object's methods text(), icon() etc
+*/
+void LightApp_DataModel::registerColumn( SUIT_DataBrowser* browser, const QString& name, const int custom_id )
+{
+ SUIT_AbstractModel* m = dynamic_cast<SUIT_AbstractModel*>( browser ? browser->model() : 0 );
+ if( m )
+ m->registerColumn( groupId(), name, custom_id );
+}
+
+/*!
+ Remove registered custom column from the object browser
+ \param browser - object browser where new column should be created
+ \param name - translated column name
+*/
+void LightApp_DataModel::unregisterColumn( SUIT_DataBrowser* browser, const QString& name )
+{
+ SUIT_AbstractModel* m = dynamic_cast<SUIT_AbstractModel*>( browser ? browser->model() : 0 );
+ if( m )
+ m->unregisterColumn( groupId(), name );
+}
class LightApp_Module;
class LightApp_Study;
class LightApp_DataObject;
+class SUIT_DataBrowser;
/*!
Description : Base class of data model
LightApp_Module* getModule() const;
+ int groupId() const;
+ void registerColumn( SUIT_DataBrowser*, const QString&, const int );
+ void unregisterColumn( SUIT_DataBrowser*, const QString& );
+
signals:
void opened();
void saved();
LightApp_Study* getStudy() const;
virtual void build();
virtual void updateWidgets();
+
+private:
+ int myGroupId;
};
#endif
#include "LightApp_DataObject.h"
#include "LightApp_Study.h"
+#include "LightApp_DataModel.h"
-#include <CAM_DataModel.h>
#include <CAM_Module.h>
#include <SUIT_DataObjectKey.h>
{
}
-/*!
- \brief Get the number of the columns provided by the data tree.
- \return number of the columns
-*/
-int LightApp_DataObject::columnCount() const
-{
- // add "Entry" column
- return CAM_DataObject::columnCount() + 1;
-}
-
-/*!
- \brief Get column title.
- \param index column index
- \return title of the specified column
-*/
-QString LightApp_DataObject::columnTitle( const int index ) const
-{
- // add "Entry" column
- return index == EntryIdx ? QObject::tr( "ENTRY_COLUMN" )
- : CAM_DataObject::columnTitle( index );
-}
-
-/*!
- \brief Check if the column should appear in the tree view header popup menu
- (to show/hide the column).
- \param index column index
- \return \c true if the column can be shown/hidden
-*/
-bool LightApp_DataObject::appropriate( const int index ) const
+int LightApp_DataObject::groupId() const
{
- // add "Entry" column
- return index == EntryIdx ? true : CAM_DataObject::appropriate( index );
+ LightApp_DataModel* m = dynamic_cast<LightApp_DataModel*>( dataModel() );
+ return m ? m->groupId() : CAM_DataObject::groupId();
}
/*!
/*!
\brief Get object text data for the specified column.
- Column with \a index = 0 (NameIdx) is supposed to be used
+ Column with \a id = 0 (NameId) is supposed to be used
to get the object name.
- Column with \a index = 1 (EntryIdx) is supposed to be used
+ Column with \a id = 1 (EntryId) is supposed to be used
to get the object entry.
- \param index column index
+ \param id column id
\return object text data
*/
-QString LightApp_DataObject::text( const int index ) const
+QString LightApp_DataObject::text( const int id ) const
{
- // add "Entry" column
- return index == EntryIdx ? entry() : CAM_DataObject::text( index );
+ return id == EntryId ? entry() : CAM_DataObject::text( id );
}
/*!
/*!
\brief Check if the specified column supports custom sorting.
- \param index column index
+ \param id column id
\return \c true if column sorting should be customized
\sa compare()
*/
-bool LightApp_DataObject::customSorting( const int index ) const
+bool LightApp_DataObject::customSorting( const int id ) const
{
// perform custom sorting for the "Entry" column
- return index == EntryIdx ? true
- : CAM_DataObject::customSorting( index );
+ return id == EntryId ? true : CAM_DataObject::customSorting( id );
}
/*!
\param left first data to compare
\param right second data to compare
- \param index column index
+ \param id column id
\return result of the comparison
\sa customSorting()
*/
-bool LightApp_DataObject::compare( const QVariant& left, const QVariant& right,
- const int index ) const
+bool LightApp_DataObject::compare( const QVariant& left, const QVariant& right, const int id ) const
{
- if ( index == EntryIdx ) {
+ if ( id == EntryId )
+ {
// perform custom sorting for the "Entry" column
QString leftStr = left.toString();
QString rightStr = right.toString();
}
return QString::localeAwareCompare( leftStr, rightStr ) < 0;
}
- return CAM_DataObject::compare( left, right, index );
+ return CAM_DataObject::compare( left, right, id );
}
/*!
/*!
\brief Get data object icon for the specified column.
- \param index column index
+ \param id column id
\return object icon for the specified column
*/
-QPixmap LightApp_ModuleObject::icon( const int index ) const
+QPixmap LightApp_ModuleObject::icon( const int id ) const
{
- return CAM_ModuleObject::icon( index );
+ return CAM_ModuleObject::icon( id );
}
/*!
\brief Get data object tooltip for the specified column.
- \param index column index
+ \param id column id
\return object tooltip for the specified column
*/
-QString LightApp_ModuleObject::toolTip( const int index ) const
+QString LightApp_ModuleObject::toolTip( const int id ) const
{
- return CAM_ModuleObject::toolTip( index );
+ return CAM_ModuleObject::toolTip( id );
}
/*!
class Key;
public:
- //! Column index
+ //! Column id
enum {
- EntryIdx = NameIdx + 1 //!< entry column
+ EntryId = NameId + 1 //!< entry column
};
public:
LightApp_DataObject( SUIT_DataObject* = 0 );
virtual ~LightApp_DataObject();
- virtual int columnCount() const;
- virtual QString columnTitle( const int = NameIdx ) const;
- virtual bool appropriate( const int = NameIdx ) const;
-
virtual SUIT_DataObjectKey* key() const;
virtual QString entry() const;
- virtual QString text( const int = NameIdx ) const;
+ virtual QString text( const int = NameId ) const;
virtual SUIT_DataObject* componentObject() const;
virtual QString componentDataType() const;
- virtual bool customSorting( const int = NameIdx ) const;
- virtual bool compare( const QVariant&, const QVariant&,
- const int = NameIdx ) const;
+ virtual bool customSorting( const int = NameId ) const;
+ virtual bool compare( const QVariant&, const QVariant&, const int = NameId ) const;
+ virtual int groupId() const;
protected:
QString myCompDataType;
virtual ~LightApp_ModuleObject();
virtual QString name() const;
- QPixmap icon( const int = NameIdx ) const;
- QString toolTip( const int = NameIdx ) const;
+ QPixmap icon( const int = NameId ) const;
+ QString toolTip( const int = NameId ) const;
virtual void insertChild( SUIT_DataObject*, int );
};
#ifndef LIGHTAPP_DATASUBOWNER_H
#define LIGHTAPP_DATASUBOWNER_H
-#include <LightApp.h>
-#include <LightApp_DataOwner.h>
+#include "LightApp.h"
+#include "LightApp_DataOwner.h"
/*!
Class provide sub owner.
// File: LightApp_Dialog.cxx
// Author: Alexander SOLOVYOV
-#include <LightApp_Dialog.h>
+#include "LightApp_Dialog.h"
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#ifndef LIGHTAPP_DRIVER_H
#define LIGHTAPP_DRIVER_H
-#include <LightApp.h>
+#include "LightApp.h"
#include "string"
#include "vector"
#ifndef LIGHTAPP_HDFDRIVER_H
#define LIGHTAPP_HDFDRIVER_H
-#include <LightApp.h>
-#include <LightApp_Driver.h>
+#include "LightApp.h"
+#include "LightApp_Driver.h"
#ifdef WIN32
#pragma warning( disable:4251 )
#include "LightApp_ShowHideOp.h"
#include "LightApp_SelectionMgr.h"
-#include <SUIT_DataBrowser.h>
#include <SUIT_Study.h>
#include <SUIT_DataObject.h>
+#include <SUIT_DataBrowser.h>
#include <SUIT_Operation.h>
#include <SUIT_ViewManager.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Desktop.h>
+#include <SUIT_TreeModel.h>
+#ifndef DISABLE_SALOMEOBJECT
#include <SALOME_ListIO.hxx>
#include <SALOME_ListIteratorOfListIO.hxx>
+#endif
#ifndef DISABLE_VTKVIEWER
#ifndef DISABLE_SALOMEOBJECT
#include <QString>
#include <QStringList>
+
/*!Constructor.*/
LightApp_Module::LightApp_Module( const QString& name )
: CAM_Module( name ),
{
// return true if selected objects belong to this module
bool isCompatible = true;
+#ifndef DISABLE_SALOMEOBJECT
SALOME_ListIO selected;
if ( LightApp_SelectionMgr *Sel = getApp()->selectionMgr() )
Sel->selectedObjects( selected );
isCompatible = ( aStudy->componentDataType( io->getEntry() ) == moduleDataType );
}
}
+#endif
return isCompatible;
}
if ( mySwitchOp == 0 )
mySwitchOp = new LightApp_SwitchOp( this );
+ QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
+ LightApp_DataModel* m = dynamic_cast<LightApp_DataModel*>( dataModel() );
+ if( m )
+ {
+ SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
+ m->registerColumn( getApp()->objectBrowser(), EntryCol, LightApp_DataObject::EntryId );
+ treeModel->setAppropriate( EntryCol, Qtx::Toggled );
+ }
return res;
}
anIt.value()->abort();
}
- return CAM_Module::activateModule( study );
+ QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
+ LightApp_DataModel* m = dynamic_cast<LightApp_DataModel*>( dataModel() );
+ if( m )
+ {
+ SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
+
+ treeModel->setAppropriate( EntryCol, Qtx::Shown );
+ m->unregisterColumn( getApp()->objectBrowser(), EntryCol );
+ }
+ return CAM_Module::deactivateModule( study );
}
/*!NOT IMPLEMENTED*/
/*!Create new instance of data model and return it.*/
CAM_DataModel* LightApp_Module::createDataModel()
{
- return new LightApp_DataModel(this);
+ return new LightApp_DataModel( this );
}
/*!Create and return instance of LightApp_Selection.*/
void LightApp_Module::onViewManagerRemoved( SUIT_ViewManager* )
{
}
+
+/*!
+ \brief Returns instance of operation by its id; if there is no operation
+ corresponding to this id, null pointer is returned
+ \param id - operation id
+ \return operation instance
+*/
+LightApp_Operation* LightApp_Module::operation( const int id ) const
+{
+ return myOperations.contains( id ) ? myOperations[id] : 0;
+}
virtual bool isSelectionCompatible();
+ LightApp_Operation* operation( const int ) const;
+
private:
typedef QMap<int,LightApp_Operation*> MapOfOperation;
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
//
-#include <LightApp_ModuleDlg.h>
+#include "LightApp_ModuleDlg.h"
#include <QLabel>
#include <QPushButton>
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
//
-#include <LightApp_NameDlg.h>
+#include "LightApp_NameDlg.h"
#include <SUIT_Tools.h>
#include <QGroupBox>
// Author : Sergey LITONIN
// Module : LightApp
-#include <LightApp_Operation.h>
-#include <LightApp_Module.h>
-#include <LightApp_Application.h>
-#include <LightApp_SelectionMgr.h>
-#include <LightApp_Dialog.h>
+#include "LightApp_Operation.h"
+#include "LightApp_Module.h"
+#include "LightApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+#include "LightApp_Dialog.h"
#include <SUIT_Desktop.h>
#include <SUIT_Study.h>
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "LightApp_Plot2dSelector.h"
+
+#include "LightApp_DataOwner.h"
+#include "LightApp_DataObject.h"
+#include "LightApp_Application.h"
+
+/*!
+ Constructor
+*/
+LightApp_Plot2dSelector::LightApp_Plot2dSelector( SPlot2d_Viewer* v, SUIT_SelectionMgr* mgr )
+: SUIT_Selector( mgr, v )
+{
+ if ( v )
+ connect( v, SIGNAL( legendSelected( const QString& ) ), this, SLOT( onSelectionChanged( const QString& ) ) );
+}
+
+/*!
+ Destructor
+*/
+LightApp_Plot2dSelector::~LightApp_Plot2dSelector()
+{
+}
+
+/*!
+ Gets selection.
+*/
+void LightApp_Plot2dSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const
+{
+ if( !myCurEntry.isNull() )
+ theList.append( new LightApp_DataOwner( myCurEntry ) );
+}
+
+/*!Sets selection.*/
+void LightApp_Plot2dSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
+{
+ /* if( theList.count()>0 )
+ myCurEntry = theList.first()->getEntry();
+ else
+ myCurEntry = QString::null;*/
+}
+
+/*!On selection changed.*/
+void LightApp_Plot2dSelector::onSelectionChanged( const QString& entry )
+{
+ myCurEntry = entry;
+ selectionChanged();
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef LIGHTAPP_PLOT2DSELECTOR_H
+#define LIGHTAPP_PLOT2DSELECTOR_H
+
+#include "LightApp.h"
+
+#include <SUIT_Selector.h>
+#include <SUIT_DataOwner.h>
+#include <SPlot2d_ViewModel.h>
+
+class LightApp_DataObject;
+
+/*!
+ \class LightApp_Plot2dSelector
+ Custom selector to get/set selection from object browser
+*/
+class LIGHTAPP_EXPORT LightApp_Plot2dSelector : public QObject, public SUIT_Selector
+{
+ Q_OBJECT
+
+public:
+ LightApp_Plot2dSelector( SPlot2d_Viewer*, SUIT_SelectionMgr* );
+ virtual ~LightApp_Plot2dSelector();
+
+ /*!Return "ObjectBrowser"*/
+ virtual QString type() const { return "PLot2dViewer"; }
+
+private slots:
+ void onSelectionChanged( const QString& );
+
+protected:
+ virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
+ virtual void setSelection( const SUIT_DataOwnerPtrList& );
+
+private:
+ QString myCurEntry;
+};
+
+#endif
#ifndef LIGHTAPP_PREFERENCES_H
#define LIGHTAPP_PREFERENCES_H
-#include <LightApp.h>
+#include "LightApp.h"
#include <SUIT_PreferenceMgr.h>
#include <QMap>
{
if ( myPrefs && myPrefs->resourceMgr() )
{
- bool prev = myPrefs->resourceMgr()->ignoreUserValues();
- myPrefs->resourceMgr()->setIgnoreUserValues( true );
+ QtxResourceMgr::WorkingMode prev = myPrefs->resourceMgr()->workingMode();
+ myPrefs->resourceMgr()->setWorkingMode( QtxResourceMgr::IgnoreUserValues );
myPrefs->retrieve();
- myPrefs->resourceMgr()->setIgnoreUserValues( prev );
+ myPrefs->resourceMgr()->setWorkingMode( prev );
}
}
}
#ifndef LIGHTAPP_PREFERENCESDLG_H
#define LIGHTAPP_PREFERENCESDLG_H
-#include <LightApp.h>
+#include "LightApp.h"
#include <QtxDialog.h>
#ifndef LIGHTAPP_STUDY_H
#define LIGHTAPP_STUDY_H
-#include <LightApp.h>
-#include <LightApp_Driver.h>
+#include "LightApp.h"
+#include "LightApp_Driver.h"
#include <CAM_Study.h>
if ENABLE_GLVIEWER
salomeinclude_HEADERS += LightApp_GLSelector.h
endif
+if ENABLE_PLOT2DVIEWER
+ salomeinclude_HEADERS += LightApp_Plot2dSelector.h
+endif
dist_libLightApp_la_SOURCES = \
LightApp_AboutDlg.cxx \
if ENABLE_GLVIEWER
dist_libLightApp_la_SOURCES += LightApp_GLSelector.cxx
endif
+if ENABLE_PLOT2DVIEWER
+ dist_libLightApp_la_SOURCES += LightApp_Plot2dSelector.cxx
+endif
MOC_FILES = \
LightApp_AboutDlg_moc.cxx \
if ENABLE_GLVIEWER
MOC_FILES += LightApp_GLSelector_moc.cxx
endif
+if ENABLE_PLOT2DVIEWER
+ MOC_FILES += LightApp_Plot2dSelector_moc.cxx
+endif
nodist_libLightApp_la_SOURCES = $(MOC_FILES)
dist_salomeres_DATA = \
<parameter name="relative_size" value="true" />
<parameter name="use_advanced_selection_algorithm" value="true" />
<parameter name="navigation_mode" value="0" />
- <parameter name="speed_value" val ue="10" />
+ <parameter name="speed_value" value="10" />
<parameter name="speed_mode" value="0" />
<parameter name="spacemouse_func1_btn" value="1" />
<parameter name="spacemouse_func2_btn" value="2" />
</context>
<context>
<name>LightApp_Application</name>
+ <message>
+ <source>MEN_DESK_THEME</source>
+ <translation>Theme</translation>
+ </message>
+ <message>
+ <source>TOT_THEME</source>
+ <translation>Theme</translation>
+ </message>
+ <message>
+ <source>PRP_THEME</source>
+ <translation>Change style properties</translation>
+ </message>
<message>
<source>INF_TOOLBAR_MODULES</source>
<translation>Modules</translation>
#endif
#ifndef _Handle_SALOME_Filter_HeaderFile
-#include <Handle_SALOME_Filter.hxx>
+#include "Handle_SALOME_Filter.hxx"
#endif
class Standard_Transient;
#include <Standard.hxx>
#endif
#ifndef _Handle_SALOME_AISObject_HeaderFile
-#include <Handle_SALOME_AISObject.hxx>
+#include "Handle_SALOME_AISObject.hxx"
#endif
#ifndef _AIS_InteractiveObject_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Handle_SALOME_AISShape_HeaderFile
-#include <Handle_SALOME_AISShape.hxx>
+#include "Handle_SALOME_AISShape.hxx"
#endif
#ifndef _Standard_CString_HeaderFile
#include <TCollection_BasicMapIterator.hxx>
#endif
#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
-#include <Handle_SALOME_InteractiveObject.hxx>
+#include "Handle_SALOME_InteractiveObject.hxx"
#endif
#ifndef _Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_HeaderFile
-#include <Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx>
+#include "Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx"
#endif
class Standard_NoSuchObject;
class SALOME_InteractiveObject;
#include <Standard.hxx>
#endif
#ifndef _Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_HeaderFile
-#include <Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx>
+#include "Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx"
#endif
#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
-#include <Handle_SALOME_InteractiveObject.hxx>
+#include "Handle_SALOME_InteractiveObject.hxx"
#endif
#ifndef _TColStd_IndexedMapOfInteger_HeaderFile
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TCollection_BasicMap.hxx>
#endif
#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
-#include <Handle_SALOME_InteractiveObject.hxx>
+#include "Handle_SALOME_InteractiveObject.hxx"
#endif
#ifndef _Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_HeaderFile
-#include <Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx>
+#include "Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx"
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#include <Standard.hxx>
#endif
#ifndef _Handle_SALOME_Filter_HeaderFile
-#include <Handle_SALOME_Filter.hxx>
+#include "Handle_SALOME_Filter.hxx"
#endif
#ifndef _MMgt_TShared_HeaderFile
#include <Standard_Boolean.hxx>
#endif
#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
-#include <Handle_SALOME_InteractiveObject.hxx>
+#include "Handle_SALOME_InteractiveObject.hxx"
#endif
class SALOME_Filter : public MMgt_TShared {
#include <Standard.hxx>
#endif
#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
-#include <Handle_SALOME_InteractiveObject.hxx>
+#include "Handle_SALOME_InteractiveObject.hxx"
#endif
#ifndef _Standard_CString_HeaderFile
#include <Standard_Address.hxx>
#endif
#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
-#include <Handle_SALOME_InteractiveObject.hxx>
+#include "Handle_SALOME_InteractiveObject.hxx"
#endif
#ifndef _Handle_SALOME_ListNodeOfListIO_HeaderFile
-#include <Handle_SALOME_ListNodeOfListIO.hxx>
+#include "Handle_SALOME_ListNodeOfListIO.hxx"
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#include <Standard_Address.hxx>
#endif
#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
-#include <Handle_SALOME_InteractiveObject.hxx>
+#include "Handle_SALOME_InteractiveObject.hxx"
#endif
#ifndef _Handle_SALOME_ListNodeOfListIO_HeaderFile
-#include <Handle_SALOME_ListNodeOfListIO.hxx>
+#include "Handle_SALOME_ListNodeOfListIO.hxx"
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#include <Standard.hxx>
#endif
#ifndef _Handle_SALOME_ListNodeOfListIO_HeaderFile
-#include <Handle_SALOME_ListNodeOfListIO.hxx>
+#include "Handle_SALOME_ListNodeOfListIO.hxx"
#endif
#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
-#include <Handle_SALOME_InteractiveObject.hxx>
+#include "Handle_SALOME_InteractiveObject.hxx"
#endif
#ifndef _TCollection_MapNode_HeaderFile
#include <TCollection_MapNode.hxx>
#include <Standard.hxx>
#endif
#ifndef _Handle_SALOME_TypeFilter_HeaderFile
-#include <Handle_SALOME_TypeFilter.hxx>
+#include "Handle_SALOME_TypeFilter.hxx"
#endif
#ifndef _Standard_CString_HeaderFile
OCCViewer_SetRotationPointDlg.cxx \
OCCViewer_ClippingDlg.cxx \
OCCViewer_AxialScaleDlg.cxx \
- OCCViewer_Trihedron.cxx
+ OCCViewer_Trihedron.cxx \
+ OCCViewer_ToolTip.cxx
MOC_FILES = \
OCCViewer_AISSelector_moc.cxx \
OCCViewer_CreateRestoreViewDlg_moc.cxx \
OCCViewer_SetRotationPointDlg_moc.cxx \
OCCViewer_ClippingDlg_moc.cxx \
- OCCViewer_AxialScaleDlg_moc.cxx
+ OCCViewer_AxialScaleDlg_moc.cxx \
+ OCCViewer_ToolTip_moc.cxx
+
nodist_libOCCViewer_la_SOURCES = $(MOC_FILES)
dist_salomeres_DATA = \
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include <OCCViewer_Trihedron.h>
+#include "OCCViewer_Trihedron.h"
#include <Graphic3d_CBounds.hxx>
#include <OpenGl_GraphicDriver.hxx>
myListBox->insertItem( 0, "No Items" );
}
- connect( myListBox, SIGNAL( itemClicked( QListBoxItem* ) ), this, SLOT( changeImage( QListBoxItem* ) ) );
- connect( myListBox, SIGNAL( itemChanged( QListBoxItem* ) ), this, SLOT( editItemText( QListBoxItem* ) ) );
+ connect( myListBox, SIGNAL( itemClicked( QListWidgetItem* ) ), this, SLOT( changeImage( QListWidgetItem* ) ) );
+ connect( myListBox, SIGNAL( itemChanged( QListWidgetItem* ) ), this, SLOT( editItemText( QListWidgetItem* ) ) );
aLayout->addWidget( myListBox );
aLayout->addWidget( myCurViewPort, 30 );
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: OCCViewer_ToolTip.cxx
+// Author: Alexandre SOLOVYOV
+
+#include <OCCViewer_ToolTip.h>
+#include <OCCViewer_ViewWindow.h>
+#include <OCCViewer_ViewPort3d.h>
+#include <OCCViewer_ViewModel.h>
+
+#include <SUIT_ViewManager.h>
+
+#include <SelectMgr_EntityOwner.hxx>
+
+/*!
+ Constructor
+
+ \param wnd - window where the tooltip should be assigned
+*/
+OCCViewer_ToolTip::OCCViewer_ToolTip( OCCViewer_ViewWindow* wnd )
+: QtxToolTip( wnd->getViewPort() ),
+ myWnd( wnd )
+{
+ connect( this, SIGNAL( maybeTip( QPoint, QString&, QFont&, QRect&, QRect& ) ),
+ this, SLOT( onToolTip( QPoint, QString&, QFont&, QRect&, QRect& ) ) );
+}
+
+/*!
+ Destructor
+ */
+OCCViewer_ToolTip::~OCCViewer_ToolTip()
+{
+}
+
+/*!
+ \return font of the tooltip
+ */
+QFont OCCViewer_ToolTip::font() const
+{
+ return myFont;
+}
+
+/*!
+ Change font of the tooltip
+
+ \param f - new font
+ */
+void OCCViewer_ToolTip::setFont( const QFont& f )
+{
+ myFont = f;
+}
+
+/*!
+ Tooltip handler
+
+ \param p - current point
+ \param str - returned tooltip text
+ \param f - returned tooltip font
+ \param txtRect - returned tooltip text rectangle
+ \param rect - returned tooltip rectangle
+ */
+void OCCViewer_ToolTip::onToolTip( QPoint p, QString& str, QFont& f, QRect& txtRect, QRect& rect )
+{
+ OCCViewer_Viewer* v = dynamic_cast<OCCViewer_Viewer*>( myWnd->getViewManager()->getViewModel() );
+ Handle( AIS_InteractiveContext ) aCont = v->getAISContext();
+ if( aCont.IsNull() )
+ return;
+
+ QString txt;
+ Handle( SelectMgr_EntityOwner ) owner = aCont->DetectedOwner();
+ if( !owner.IsNull() )
+ emit toolTipFor( owner, txt );
+
+ Handle_AIS_InteractiveObject obj = aCont->DetectedInteractive();
+ if( txt.isEmpty() && !obj.IsNull() )
+ emit toolTipFor( obj, txt );
+
+ if( txt.isEmpty() )
+ return;
+
+ str = txt;
+ QFontMetrics m( myFont );
+ int w = m.width( str ), h = m.height();
+
+ txtRect = QRect( p.x()+4, p.y()-h, w, h );
+ rect = txtRect;
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef OCCVIEWER_TOOLTIP_H
+#define OCCVIEWER_TOOLTIP_H
+
+#include <OCCViewer.h>
+#include <QtxToolTip.h>
+#include <QFont>
+
+class OCCViewer_ViewWindow;
+class Handle_SelectMgr_EntityOwner;
+class Handle_AIS_InteractiveObject;
+
+/*!
+ \class OCCViewer_ToolTip
+ \brief Custom tooltip for AIS_InteractiveObjects and SelectMgr_EntityOwners in the OCC Viewer
+*/
+class OCCVIEWER_EXPORT OCCViewer_ToolTip : public QtxToolTip
+{
+ Q_OBJECT
+
+public:
+ OCCViewer_ToolTip( OCCViewer_ViewWindow* );
+ virtual ~OCCViewer_ToolTip();
+
+ QFont font() const;
+ void setFont( const QFont& );
+
+signals:
+ /*!
+ Called when owner is detected; allows to redefine tooltip text for owner
+ */
+ void toolTipFor( const Handle_SelectMgr_EntityOwner&, QString& );
+ /*!
+ Called when object is detected; allows to redefine tooltip text for object
+ */
+ void toolTipFor( const Handle_AIS_InteractiveObject&, QString& );
+
+public slots:
+ void onToolTip( QPoint, QString&, QFont&, QRect&, QRect& );
+
+private:
+ OCCViewer_ViewWindow* myWnd;
+ QFont myFont;
+};
+
+#endif
#ifndef OCCVIEWER_TRIHEDRON_H
#define OCCVIEWER_TRIHEDRON_H
-#include <OCCViewer.h>
+#include "OCCViewer.h"
#include <AIS_InteractiveObject.hxx>
#include <Graphic3d_CBounds.hxx>
#include <WNT_GraphicDevice.hxx>
#include <WNT_GraphicDevice.hxx>
#include <WNT_WDriver.hxx>
+#include <InterfaceGraphic_WNT.hxx>
#else
#include <Xw_Window.hxx>
#include <Graphic3d_GraphicDevice.hxx>
#ifdef WNT
Handle(WNT_Window) w =
new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin );
+ // Prevent flicker
+ w->SetFlags( WDF_NOERASEBKGRND );
#else
Handle(Xw_Window) w =
new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, quality );
Constructor
*/
OCCViewer_ViewManager::OCCViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop, bool DisplayTrihedron )
-: SUIT_ViewManager( study, theDesktop, new OCCViewer_Viewer( DisplayTrihedron ) )
+: SUIT_ViewManager( study, theDesktop, new OCCViewer_Viewer( DisplayTrihedron, false ) )
{
setTitle( tr( "OCC_VIEW_TITLE" ) );
}
aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_DUMP" ) ),
tr( "MNU_DUMP_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onDumpView()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onDumpView()));
toolMgr()->registerAction( aAction, DumpId );
// FitAll
aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITALL" ) ),
tr( "MNU_FITALL" ), 0, this);
aAction->setStatusTip(tr("DSC_FITALL"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onFitAll()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onFitAll()));
toolMgr()->registerAction( aAction, FitAllId );
// FitRect
aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FITAREA" ) ),
tr( "MNU_FITRECT" ), 0, this);
aAction->setStatusTip(tr("DSC_FITRECT"));
- connect(aAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(activateWindowFit()));
toolMgr()->registerAction( aAction, FitRectId );
// Zoom
aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ZOOM" ) ),
tr( "MNU_ZOOM_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(activateZoom()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(activateZoom()));
toolMgr()->registerAction( aAction, ZoomId );
// Panning
aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_PAN" ) ),
tr( "MNU_PAN_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_PAN_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(activatePanning()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(activatePanning()));
toolMgr()->registerAction( aAction, PanId );
// Global Panning
aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_GLOBALPAN" ) ),
tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(activateGlobalPanning()));
toolMgr()->registerAction( aAction, GlobalPanId );
// Rotation Point
aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATE" ) ),
tr( "MNU_ROTATE_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(activateRotation()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(activateRotation()));
toolMgr()->registerAction( aAction, RotationId );
// Projections
aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_FRONT" ) ),
tr( "MNU_FRONT_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_FRONT_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onFrontView()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onFrontView()));
toolMgr()->registerAction( aAction, FrontId );
aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BACK" ) ),
tr( "MNU_BACK_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_BACK_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onBackView()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onBackView()));
toolMgr()->registerAction( aAction, BackId );
aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TOP" ) ),
tr( "MNU_TOP_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_TOP_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onTopView()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onTopView()));
toolMgr()->registerAction( aAction, TopId );
aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_BOTTOM" ) ),
tr( "MNU_BOTTOM_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onBottomView()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onBottomView()));
toolMgr()->registerAction( aAction, BottomId );
aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_LEFT" ) ),
tr( "MNU_LEFT_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_LEFT_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onLeftView()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onLeftView()));
toolMgr()->registerAction( aAction, LeftId );
aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RIGHT" ) ),
tr( "MNU_RIGHT_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onRightView()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onRightView()));
toolMgr()->registerAction( aAction, RightId );
// Reset
aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_RESET" ) ),
tr( "MNU_RESET_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_RESET_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onResetView()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onResetView()));
toolMgr()->registerAction( aAction, ResetId );
// Reset
aAction = new QtxAction(tr("MNU_CLONE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLONE_VIEW" ) ),
tr( "MNU_CLONE_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_CLONE_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onCloneView()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onCloneView()));
toolMgr()->registerAction( aAction, CloneId );
myClippingAction = new QtxAction(tr("MNU_CLIPPING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING" ) ),
aAction = new QtxAction(tr("MNU_SHOOT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SHOOT_VIEW" ) ),
tr( "MNU_SHOOT_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_SHOOT_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onMemorizeView()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onMemorizeView()));
toolMgr()->registerAction( aAction, MemId );
aAction = new QtxAction(tr("MNU_PRESETS_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESETS_VIEW" ) ),
tr( "MNU_PRESETS_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_PRESETS_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onRestoreView()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onRestoreView()));
toolMgr()->registerAction( aAction, RestoreId );
if (myModel->trihedronActivated()) {
aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_TRIHEDRON" ) ),
tr( "MNU_SHOW_TRIHEDRE" ), 0, this);
aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRE"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onTrihedronShow()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onTrihedronShow()));
toolMgr()->registerAction( aAction, TrihedronShowId );
}
aAction = new QtxAction(tr("MNU_SCALING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SCALING" ) ),
tr( "MNU_SCALING" ), 0, this);
aAction->setStatusTip(tr("DSC_SCALING"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onAxialScale()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onAxialScale()));
toolMgr()->registerAction( aAction, AxialScaleId );
}
connect( myView, SIGNAL( selectionChanged() ),
this, SIGNAL( selectionChanged() ) );
- connect( myView, SIGNAL( doubleClicked( QListViewItem* ) ),
- this, SLOT( onDoubleClicked( QListViewItem* ) ) );
}
// File: Plot2d_ToolTip.cxx
// Author: Alexandre SOLOVYOV
-#include <Plot2d_ToolTip.h>
-#include <Plot2d_ViewFrame.h>
-#include <Plot2d_Curve.h>
+#include "Plot2d_ToolTip.h"
+#include "Plot2d_ViewFrame.h"
+#include "Plot2d_Curve.h"
#include <QFontMetrics>
#include <QEvent>
#ifndef PLOT2D_TOOLTIP_H
#define PLOT2D_TOOLTIP_H
-#include <Plot2d.h>
+#include "Plot2d.h"
#include <QtxToolTip.h>
class Plot2d_ViewFrame;
aLayout->addWidget( myPlot );
-// createActions();
- //connect( myPlot, SIGNAL( legendClicked( long ) ),
- // this, SLOT( onLegendClicked( long ) ) );
+ // createActions();
+ connect( myPlot, SIGNAL( legendClicked( QwtPlotItem* ) ),
+ this, SIGNAL( legendClicked( QwtPlotItem* ) ) );
/* Initial Setup - get from the preferences */
readPreferences();
legend = new QwtLegend( myPlot );
legend->setFrameStyle( QFrame::Box | QFrame::Sunken );
}
+ legend->setItemMode( QwtLegend::ClickableItem );
myPlot->insertLegend( legend );
setLegendPos( myLegendPos );
}
void onSettings();
void onFitData();
void onChangeBackground();
-
void onPanLeft();
void onPanRight();
void onPanUp();
void vpModeVerChanged();
void vpCurveChanged();
void contextMenuRequested( QContextMenuEvent *e );
+ void legendClicked( QwtPlotItem* );
protected:
Plot2d_Plot2d* myPlot;
#include "Plot2d_ViewManager.h"
#include "Plot2d_ViewModel.h"
#include "Plot2d_ViewWindow.h"
+#include "Plot2d_ViewFrame.h"
/*!
Constructor
{
Plot2d_ViewWindow* view = (Plot2d_ViewWindow*)theView;
connect( view, SIGNAL( cloneView() ), this, SLOT( onCloneView() ) );
+
+ Plot2d_ViewFrame* aViewFrame = view->getViewFrame();
+ Plot2d_Viewer* aViewer = getPlot2dModel();
+ connect( aViewFrame, SIGNAL( legendClicked( QwtPlotItem* ) ),
+ aViewer, SLOT( onLegendClicked( QwtPlotItem* ) ) );
}
return res;
}
}
}
+/*
+ SLOT: called when clicked item in the legend from Plot2d_ViewManager
+ */
+void Plot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem )
+{
+}
+
/*!
Sets view manager
\param mgr - new view manager
#include "Plot2d.h"
#include "SUIT_ViewModel.h"
+#include "qwt_plot.h"
class SUIT_ViewWindow;
class SUIT_Desktop;
void onDumpView();
void onShowToolbar();
virtual void onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* );
+ virtual void onLegendClicked( QwtPlotItem* );
private:
Plot2d_Prs* myPrs;
int id = -1;
QString aDefValue = defaultValue();
if ( !aDefValue.isEmpty() )
- id = aDefValue.toInt();
-
- if ( id == -1 )
- id = getId( 0 );
-
- setIntegerValue( id );
+ setString( aDefValue );
+ else
+ setIntegerValue( getId( 0 ) );
}
/*!
if ( cb )
{
if ( myIcons.contains( id ) )
- cb->insertItem( -1, QIcon(myIcons[id]), myValue[id] );
+ cb->addItem( QIcon(myIcons[id]), myValue[id] );
else
- cb->insertItem( -1, myValue[id] );
+ cb->addItem( myValue[id] );
}
}
//
#include "QDS_Datum.h"
-#include "QDS_Validator.h"
-
-#include <DDS_Dictionary.h>
-
+#include <QLayout>
+#include <QVariant>
#include <QTimer>
-#include <QLabel>
-#include <QWidget>
-#include <QHBoxLayout>
-#include <QVBoxLayout>
-#include <QGridLayout>
-#include <QMessageBox>
#include <QEvent>
+#include <QMessageBox>
+#include <QApplication>
-#include <TColStd_SequenceOfAsciiString.hxx>
+#include <QDS_Validator.h>
+#include <DDS_Dictionary.h>
/*!
\class QDS_Datum::Wrapper
Wrapper( QWidget* = 0 );
virtual ~Wrapper();
- QWidget* widget() const;
- void setWidget( QWidget* );
+ QWidget* widget() const;
+ void setWidget( QWidget* );
virtual void setGeometry( int x, int y, int w, int h );
virtual void setSizePolicy( QSizePolicy );
private:
- QWidget* myWid;
- QHBoxLayout* myBase;
+ QWidget* myWid;
};
/*!
: QWidget( parent ),
myWid( 0 )
{
- //QHBoxLayout* base = new QHBoxLayout( this );
- //base->setAutoAdd( true );
- myBase = new QHBoxLayout( this );
+ setLayout( new QHBoxLayout() );
+ layout()->setSpacing( 0 );
+ layout()->setMargin( 0 );
setFocusPolicy( Qt::StrongFocus );
}
*/
void QDS_Datum::Wrapper::setWidget( QWidget* wid )
{
- if ( myWid == wid )
+ if ( myWid == wid || !wid )
return;
+ wid->setParent( this );
+ QHBoxLayout* hl = qobject_cast<QHBoxLayout*>( layout() );
+ if( myWid )
+ hl->removeWidget( myWid );
+ hl->addWidget( wid );
myWid = wid;
- if ( !myWid )
- return;
-
- if ( myWid->parent() != this ) {
- myWid->setParent( this );
- myWid->move( QPoint( 0, 0 ) );
- myWid->hide();
- myBase->addWidget( myWid );
- }
-
setTabOrder( this, myWid );
setFocusProxy( myWid );
myUnits( 0 ),
myControl( 0 ),
myFlags( flags ),
- myInitialised( false )
+ myInitialised( false ),
+ myTr( false )
{
if ( myFlags & Label )
myWrapper.insert( Label, new Wrapper( parent ) );
return res;
}
+/*!
+ \brief Return state of custom translation.
+ \return true if custom translation is enabled
+*/
+bool QDS_Datum::isCustomTr() const
+{
+ return myTr;
+}
+
+/*!
+ \brief Change state of custom translation.
+
+ Custom translation means that text labels of datums are translated
+ with help of standard Qt mechanism of internationalization. In this
+ case special records should be placed into *.ts files under context "QDS".
+ For example, if label has name "myLabel", the corresponding translation
+ should be written:
+ <context>
+ <name>QDS</name>
+ <message>
+ <source>myLabel</source>
+ <translation>myLabel translation</translation>
+ </message>
+ ...
+
+ If custom translation mechanism is deactivated, then labels will be shown
+ with text got from xml data dictionary file
+
+ By default, the custom translation is deactivated
+
+ \param on - if it is true, custom translation is activated, otherwise, deactivated
+*/
+void QDS_Datum::enableCustomTr( const bool on )
+{
+ myTr = on;
+ labelWidget()->setText( label() );
+}
+
/*!
\brief Get the datum label text.
\return label text
QString labStr;
if ( !myDicItem.IsNull() )
+ {
labStr = toQString( myDicItem->GetLabel() );
-
+ if( labStr.isNull() )
+ labStr = toQString( myDicItem->GetId() );
+ }
+ if( myTr )
+ {
+ QString dest = QApplication::translate( "QDS", labStr.toLatin1().constData() );
+ if( labStr != dest )
+ labStr = dest;
+ }
if ( flags() & NotAccel )
labStr = removeAccel( labStr );
-
return labStr;
}
info += QString( "\n" ) + extMsg;
QString msg;
- for ( uint i = 0; i < info.length(); i++ )
+ for ( int i = 0; i < info.length(); i++ )
if ( info.at( i ) == '\n' )
msg += QString( "<br>" );
else
#define QDS_DATUM_H
#include "QDS.h"
-
-#include <QString>
-#include <QVariant>
#include <QPointer>
+#include <QMap>
+#include <QLabel>
+
+class QHBoxLayout;
+class QVBoxLayout;
+class QGridLayout;
+class QValidator;
#include <DDS_DicItem.h>
-class QLabel;
class QWidget;
-class QValidator;
-class QVBoxLayout;
-class QHBoxLayout;
-class QGridLayout;
class QDS_EXPORT QDS_Datum : public QObject, public QDS
{
operator QWidget*() const;
+ bool isCustomTr() const;
+ void enableCustomTr( const bool );
+
signals:
void paramChanged();
void paramChanged( QString& );
QString mySourceValue;
QString myTargetValue;
- bool myInitialised;
+ bool myInitialised, myTr;
friend class QDS;
};
sb->setSuffix( suffix() );
sb->setPrefix( prefix() );
- sb->setMinimum( minValue().toInt() );
- sb->setMaximum( maxValue().toInt() );
+ sb->setMinimum( minValue().isEmpty() ? -INT_MAX : minValue().toInt() );
+ sb->setMaximum( maxValue().isEmpty() ? INT_MAX : maxValue().toInt() );
+
}
}
QtxPathEdit_moc.cxx \
QtxPathListEdit_moc.cxx \
QtxPopupMgr_moc.cxx \
+ QtxRubberBand_moc.cxx \
QtxSearchTool_moc.cxx \
QtxSplash_moc.cxx \
QtxToolBar_moc.cxx \
AppropriateRole = Qt::UserRole + 100 //!< can be used to return \c true if data is appropriate
};
+ typedef enum {
+ Shown, //!< column should be always visible
+ Hidden, //!< column should be always hidden
+ Toggled //!< it should be possible to show/hide the column with help of popup menu
+ } Appropriate; //!< appropriate status
+
static QString toQString( const char*, const int = -1 );
static QString toQString( const short*, const int = -1 );
static QString toQString( const unsigned char*, const int = -1 );
*/
void QtxFontEdit::setCurrentFont( const QFont& fnt )
{
+ myFamily->blockSignals( true );
+ mySize->blockSignals( true );
+ myB->blockSignals( true );
+ myI->blockSignals( true );
+ myU->blockSignals( true );
+
setFontFamily( fnt.family() );
setFontSize( fnt.pointSize() );
setFontScripting( ( fnt.bold() ? Bold : 0 ) |
( fnt.italic() ? Italic : 0 ) |
( fnt.underline() ? Underline : 0 ) );
+
+ myFamily->blockSignals( false );
+ mySize->blockSignals( false );
+ myB->blockSignals( false );
+ myI->blockSignals( false );
+ myU->blockSignals( false );
+
+ emit( changed( currentFont() ) );
}
/*!
*/
void QtxFontEdit::onFontChanged( const QFont& /*f*/ )
{
+ bool blocked = mySize->signalsBlocked();
+ mySize->blockSignals( true );
+
int s = fontSize();
mySize->clear();
mySize->addItems( sizes );
setFontSize( s );
+
+ mySize->blockSignals( blocked );
+
+ if ( !myFamily->signalsBlocked() )
+ emit( changed( currentFont() ) );
+}
+
+void QtxFontEdit::onPropertyChanged()
+{
+ emit( changed( currentFont() ) );
}
/*!
myFamily->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
- connect( myPreview, SIGNAL( clicked( bool ) ), this, SLOT( onPreview( bool ) ) );
- connect( myFamily, SIGNAL( currentFontChanged( const QFont& ) ), this, SLOT( onFontChanged( const QFont& ) ) );
+ connect( myPreview, SIGNAL( clicked( bool ) ), this, SLOT( onPreview( bool ) ) );
+ connect( myFamily, SIGNAL( currentFontChanged( const QFont& ) ), this, SLOT( onFontChanged( const QFont& ) ) );
+ connect( mySize, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onPropertyChanged() ) );
+ connect( mySize, SIGNAL( editTextChanged( QString ) ), this, SLOT( onPropertyChanged() ) );
+ connect( myB, SIGNAL( toggled( bool ) ), this, SLOT( onPropertyChanged() ) );
+ connect( myI, SIGNAL( toggled( bool ) ), this, SLOT( onPropertyChanged() ) );
+ connect( myU, SIGNAL( toggled( bool ) ), this, SLOT( onPropertyChanged() ) );
updateState();
onFontChanged( currentFont() );
int features() const;
void setFeatures( const int );
+signals:
+ void changed( const QFont& );
+
private slots:
void onPreview( bool );
void onFontChanged( const QFont& );
+ void onPropertyChanged();
private:
void initialize();
myFrame->hide();
if ( numActions > 0 )
- emit activated( numActions );
+ emit triggered( numActions );
}
/*!
if ( idx < 0 )
return;
- emit activated( idx + 1 );
+ emit triggered( idx + 1 );
}
/*!
void setCharsNumber( const int );
signals:
- void activated( int );
+ void triggered( int );
private slots:
void onChanged();
resources environment variable has higher priority. Priority has the meaning when
searching requested resources (application preference, pixmap file name, translation
file, etc).
- Loading of the user configuration file can be omitted by calling setIgnoreUserValues()
- with \c true parameter.
+
+ When retrieving preferences, it is sometimes helpful to ignore values coming from the
+ user preference file and take into account only global preferences.
+ To do this, use setWorkingMode() method passing QtxResourceMgr::IgnoreUserValues enumerator
+ as parameter.
Resources manager operates with such terms like options, sections and parameters.
Parametets are named application resources, for example, application preferences like
myCheckExist( true ),
myDefaultPix( 0 ),
myIsPixmapCached( true ),
- myIsIgnoreUserValues( false )
+ myHasUserValues( true ),
+ myWorkingMode( AllowUserValues )
{
QString envVar = !resVarTemplate.isEmpty() ? resVarTemplate : QString( "%1Resources" );
if ( envVar.contains( "%1" ) )
Prepare the resources containers and load resources (if \a autoLoad is \c true).
\param autoLoad if \c true (default) then all resources are loaded
- \param loadUser if \c true (default) then user settings are also loaded
*/
-void QtxResourceMgr::initialize( const bool autoLoad, const bool loadUser ) const
+void QtxResourceMgr::initialize( const bool autoLoad ) const
{
if ( !myResources.isEmpty() )
return;
QtxResourceMgr* that = (QtxResourceMgr*)this;
- if ( loadUser && !userFileName( appName() ).isEmpty() )
+ if ( !userFileName( appName() ).isEmpty() )
that->myResources.append( new Resources( that, userFileName( appName() ) ) );
+ that->myHasUserValues = myResources.count() > 0;
+
for ( QStringList::ConstIterator it = myDirList.begin(); it != myDirList.end(); ++it )
{
QString path = Qtx::addSlash( *it ) + globalFileName( appName() );
}
/*!
- \brief Set "ignore user values" option value.
-
- If this option is \c true, then all resources loaded from user home directory are ignored.
+ \brief Get current working mode.
- \param val new option value
- \sa ignoreUserValues()
+ \return current working mode
+ \sa setWorkingMode(), value(), hasValue(), hasSection(), setValue()
*/
-void QtxResourceMgr::setIgnoreUserValues( const bool val )
+QtxResourceMgr::WorkingMode QtxResourceMgr::workingMode() const
{
- myIsIgnoreUserValues = val;
+ return myWorkingMode;
}
/*!
- \brief Get "ignore user values" option value.
+ \brief Set resource manager's working mode.
+
+ The resource manager can operate in the following working modes:
+ * AllowUserValues : methods values(), hasValue(), hasSection() take into account user values (default)
+ * IgnoreUserValues : methods values(), hasValue(), hasSection() do not take into account user values
+
+ Note, that setValue() method always put the value to the user settings file.
- \return "ignore user values" option value
- \sa setIgnoreUserValues()
+ \param mode new working mode
+ \sa workingMode(), value(), hasValue(), hasSection(), setValue()
*/
-bool QtxResourceMgr::ignoreUserValues() const
+void QtxResourceMgr::setWorkingMode( WorkingMode mode )
{
- return myIsIgnoreUserValues;
+ myWorkingMode = mode;
}
/*!
bool ok = false;
ResList::ConstIterator it = myResources.begin();
- if ( ignoreUserValues() )
+ if ( myHasUserValues && workingMode() == IgnoreUserValues )
++it;
for ( ; it != myResources.end() && !ok; ++it )
initialize();
bool ok = false;
- for ( ResList::ConstIterator it = myResources.begin(); it != myResources.end() && !ok; ++it )
+
+ ResList::ConstIterator it = myResources.begin();
+ if ( myHasUserValues && workingMode() == IgnoreUserValues )
+ ++it;
+
+ for ( ; it != myResources.end() && !ok; ++it )
ok = (*it)->hasValue( sect, name );
return ok;
initialize();
bool ok = false;
- for ( ResList::ConstIterator it = myResources.begin(); it != myResources.end() && !ok; ++it )
+
+ ResList::ConstIterator it = myResources.begin();
+ if ( myHasUserValues && workingMode() == IgnoreUserValues )
+ ++it;
+
+ for ( ; it != myResources.end() && !ok; ++it )
ok = (*it)->hasSection( sect );
return ok;
if ( !fmt )
return false;
+ if ( myResources.isEmpty() || !myHasUserValues )
+ return false;
+
Resources* r = myResources[0];
if ( !r )
return false;
if ( !fmt )
return false;
- if ( myResources.isEmpty() )
+ if ( myResources.isEmpty() || !myHasUserValues )
return true;
return fmt->save( myResources[0] );
initialize();
QMap<QString, int> map;
- for ( ResList::ConstIterator it = myResources.begin(); it != myResources.end(); ++it )
+
+ ResList::ConstIterator it = myResources.begin();
+ if ( myHasUserValues && workingMode() == IgnoreUserValues )
+ ++it;
+
+ for ( ; it != myResources.end(); ++it )
{
QStringList lst = (*it)->sections();
for ( QStringList::ConstIterator itr = lst.begin(); itr != lst.end(); ++itr )
map.insert( *itr, 0 );
}
- QStringList res;
- for ( QMap<QString, int>::ConstIterator iter = map.begin(); iter != map.end(); ++iter )
- res.append( iter.key() );
-
- return res;
+ return map.keys();
}
/*!
#endif
PMap pmap;
- ResList::ConstIterator it = myResources.end();
- while ( it != myResources.begin() )
+ Resources* ur = !myResources.isEmpty() && workingMode() == IgnoreUserValues ? myResources[0] : 0;
+
+ QListIterator<Resources*> it( myResources );
+ it.toBack();
+ while ( it.hasPrevious() )
{
- --it;
- QStringList lst = (*it)->parameters( sec );
+ Resources* r = it.previous();
+ if ( r == ur ) break;
+ QStringList lst = r->parameters( sec );
for ( QStringList::ConstIterator itr = lst.begin(); itr != lst.end(); ++itr )
+#if defined(QTX_NO_INDEXED_MAP)
+ if ( !pmap.contains( *itr ) ) pmap.insert( *itr, 0 );
+#else
pmap.insert( *itr, 0, false );
+#endif
}
- QStringList res;
- for ( PMap::ConstIterator iter = pmap.begin(); iter != pmap.end(); ++iter )
- res.append( iter.key() );
-
- return res;
+ return pmap.keys();
}
/*!
QString QtxResourceMgr::path( const QString& sect, const QString& prefix, const QString& name ) const
{
QString res;
- for ( ResList::ConstIterator it = myResources.begin(); it != myResources.end() && res.isEmpty(); ++it )
+
+ ResList::ConstIterator it = myResources.begin();
+ if ( myHasUserValues && workingMode() == IgnoreUserValues )
+ ++it;
+
+ for ( ; it != myResources.end() && res.isEmpty(); ++it )
res = (*it)->path( sect, prefix, name );
return res;
}
initialize();
QPixmap pix;
- for ( ResList::ConstIterator it = myResources.begin(); it != myResources.end() && pix.isNull(); ++it )
+
+ ResList::ConstIterator it = myResources.begin();
+ if ( myHasUserValues && workingMode() == IgnoreUserValues )
+ ++it;
+
+ for ( ; it != myResources.end() && pix.isNull(); ++it )
pix = (*it)->loadPixmap( resSection(), prefix, name );
if ( pix.isNull() )
pix = defPix;
return pix;
}
-/*!
- \brief Load translation files according to the specified language.
-
- Names of the translation files are calculated according to the pattern specified
- by the "translators" option (this option is read from the section "language" of resources files).
- By default, "%P_msg_%L.qm" pattern is used.
- Keywords \%A, \%P, \%L in the pattern are substituted by the application name, prefix and language name
- correspondingly.
- For example, for prefix "SUIT" an language "en", all translation files "SUIT_msg_en.qm" are searched and
- loaded.
-
- If prefix is empty or null string, all translation files specified in the "resources" section of resources
- files are loaded (actually, the section is retrieved from resSection() method).
- If language is not specified, it is retrieved from the langSection() method, and if the latest is also empty,
- by default "en" (English) language is used.
-
- \param pref parameter which defines translation context (for example, package name)
- \param l language name
-
- \sa resSection(), langSection(), loadTranslators()
-*/
-void QtxResourceMgr::loadLanguage( const QString& pref, const QString& l )
-{
- loadLanguage( true, pref, l );
-}
-
/*!
\brief Load translation files according to the specified language.
By default, settings from the user preferences file are also loaded (if user resource file is valid,
see userFileName()). To avoid loading user settings, pass \c false as first parameter.
- \param loadUser if \c true then user settings are also loaded
\param pref parameter which defines translation context (for example, package name)
\param l language name
\sa resSection(), langSection(), loadTranslators()
*/
-void QtxResourceMgr::loadLanguage( const bool loadUser, const QString& pref, const QString& l )
+void QtxResourceMgr::loadLanguage( const QString& pref, const QString& l )
{
- initialize( true, loadUser );
+ initialize( true );
QMap<QChar, QString> substMap;
substMap.insert( 'A', appName() );
initialize();
ResList lst;
- for ( ResList::Iterator iter = myResources.begin(); iter != myResources.end(); ++iter )
+
+ ResList::ConstIterator iter = myResources.begin();
+ if ( myHasUserValues && workingMode() == IgnoreUserValues )
+ ++iter;
+
+ for ( ; iter != myResources.end(); ++iter )
lst.prepend( *iter );
QTranslator* trans = 0;
QTranslator* trans = 0;
- ResList::ConstIterator it = myResources.end();
- while ( it != myResources.begin() )
+ Resources* ur = !myResources.isEmpty() && workingMode() == IgnoreUserValues ? myResources[0] : 0;
+
+ QListIterator<Resources*> it( myResources );
+ it.toBack();
+ while ( it.hasPrevious() )
{
- --it;
- trans = (*it)->loadTranslator( resSection(), prefix, name );
+ Resources* r = it.previous();
+ if ( r == ur ) break;
+
+ trans = r->loadTranslator( resSection(), prefix, name );
if ( trans )
{
if ( !myTranslator[prefix].contains( trans ) )
{
initialize();
- if ( !myResources.isEmpty() )
+ if ( !myResources.isEmpty() && myHasUserValues )
myResources.first()->setValue( sect, name, val );
}
typedef IMap<QString, QString> Section; //!< resource section
#endif
+ //! Working mode; defines a way how resource manager handles user preferences
+ typedef enum {
+ AllowUserValues, //!< User values are processed by the resource manager
+ IgnoreUserValues //!< User values are ignored by the resource manager
+ } WorkingMode;
+
public:
QtxResourceMgr( const QString&, const QString& = QString() );
virtual ~QtxResourceMgr();
void clear();
- void setIgnoreUserValues( const bool = true );
- bool ignoreUserValues() const;
+ WorkingMode workingMode() const;
+ void setWorkingMode( WorkingMode );
bool value( const QString&, const QString&, int& ) const;
bool value( const QString&, const QString&, double& ) const;
QPixmap loadPixmap( const QString&, const QString&, const bool ) const;
QPixmap loadPixmap( const QString&, const QString&, const QPixmap& ) const;
void loadLanguage( const QString& = QString(), const QString& = QString() );
- void loadLanguage( const bool, const QString& = QString(), const QString& = QString() );
void raiseTranslators( const QString& );
void removeTranslators( const QString& );
virtual QString globalFileName( const QString& ) const;
private:
- void initialize( const bool = true, const bool = true ) const;
+ void initialize( const bool = true ) const;
QString substMacro( const QString&, const QMap<QChar, QString>& ) const;
private:
QPixmap* myDefaultPix; //!< default icon
bool myIsPixmapCached; //!< "cached pixmaps" flag
- bool myIsIgnoreUserValues; //!< "ignore user values" flag
+ bool myHasUserValues; //!< \c true if user preferences has been read
+ WorkingMode myWorkingMode; //!< working mode
friend class QtxResourceMgr::Format;
};
#include <QWidget>
-class QTX_EXPORT QtxAbstractRubberBand: public QWidget
+class QTX_EXPORT QtxAbstractRubberBand : public QWidget
{
+ Q_OBJECT
+
protected:
QtxAbstractRubberBand( QWidget* );
class QTX_EXPORT QtxRectRubberBand: public QtxAbstractRubberBand
{
-public:
+ Q_OBJECT
+public:
QtxRectRubberBand( QWidget* );
virtual ~QtxRectRubberBand();
class QTX_EXPORT QtxPolyRubberBand: public QtxAbstractRubberBand
{
-public:
+ Q_OBJECT
+public:
QtxPolyRubberBand( QWidget* );
virtual ~QtxPolyRubberBand();
else if ( qVariantCanConvert<QPixmap>( iconData ) )
icon = qVariantValue<QPixmap>( iconData );
}
- if ( ( !lab.isEmpty() || !icon.isNull() ) &&
- appropriate.isValid() ? appropriate.toBool() : true ) {
+ if( ( !lab.isEmpty() || !icon.isNull() ) &&
+ appropriate.isValid() ? appropriate.toInt()==Qtx::Toggled : true )
+ {
QAction* a = menu.addAction( icon, lab );
a->setCheckable( true );
a->setChecked( !isSectionHidden( i ) );
e->accept();
}
+
/*!
\class QtxTreeView
\brief Tree view class with possibility to display columns popup menu.
{
emit( sortingEnabled( enabled ) );
}
+
+void QtxTreeView::setModel( QAbstractItemModel* m )
+{
+ if( model() )
+ disconnect( model(), SIGNAL( headerDataChanged( Qt::Orientation, int, int ) ),
+ this, SLOT( onAppropriate( Qt::Orientation, int, int ) ) );
+ QTreeView::setModel( m );
+ if ( model() )
+ connect( model(), SIGNAL( headerDataChanged( Qt::Orientation, int, int ) ),
+ this, SLOT( onAppropriate( Qt::Orientation, int, int ) ) );
+}
+
+void QtxTreeView::onAppropriate( Qt::Orientation orient, int first, int last )
+{
+ if( orient==Qt::Horizontal )
+ for( int i=first; i<=last; i++ )
+ {
+ int appr = model()->headerData( i, orient, Qtx::AppropriateRole ).toInt();
+ header()->setSectionHidden( i, appr==Qtx::Hidden );
+ }
+}
void resizeColumnToEncloseContents( int );
+ virtual void setModel( QAbstractItemModel* );
+
protected slots:
void onHeaderClicked( int );
void rowsAboutToBeRemoved( const QModelIndex&, int, int );
void selectionChanged( const QItemSelection&, const QItemSelection& );
+ void onAppropriate( Qt::Orientation, int, int );
protected:
void setOpened( const QModelIndex&, const int, bool );
QResizeEvent re( myBar->size(), myBar->size() );
QApplication::sendEvent( myBar, &re );
+ myBar->updateGeometry();
+
if ( isEmpty() )
{
hide();
#ifndef QXGRAPH_PRS_H
#define QXGRAPH_PRS_H
-#include <QxGraph.h>
+#include "QxGraph.h"
#include <qcanvas.h>
#include <map>
libSalomePyQtGUI_la_CPPFLAGS = $(QT_INCLUDES) $(SIP_INCLUDES) $(PYTHON_INCLUDES) \
$(CAS_CPPFLAGS) $(VTK_INCLUDES) $(OGL_INCLUDES) $(BOOST_CPPFLAGS) \
-DHAVE_CONFIG_H @KERNEL_CXXFLAGS@ -DCALL_OLD_METHODS \
- -I$(srcdir)/../../PyInterp -I$(srcdir)/../../SalomeApp \
+ -I@builddir@ -I$(srcdir)/../../PyInterp -I$(srcdir)/../../SalomeApp \
-I$(srcdir)/../../SUIT -I$(srcdir)/../../Qtx -I$(srcdir)/../../LightApp \
-I$(srcdir)/../../Plot2d -I$(srcdir)/../../OCCViewer \
-I$(srcdir)/../../SalomeApp -I$(srcdir)/../../CAM -I$(srcdir)/../../STD \
*/
QAction* SALOME_PYQT_Module::action( const int id ) const
{
- return SalomeApp_Module::action( id );
+ QAction* a = SalomeApp_Module::action( id );
+ if ( !a ) {
+ // try menu
+ QMenu* m = menuMgr()->findMenu( id );
+ if ( m ) a = m->menuAction();
+ }
+ return a;
}
/*!
COMMON_CPP_FLAGS = $(QT_INCLUDES) $(QWT_INCLUDES) $(SIP_INCLUDES) $(PYTHON_INCLUDES) \
$(CAS_CPPFLAGS) $(VTK_INCLUDES) $(OGL_INCLUDES) $(BOOST_CPPFLAGS) \
-DHAVE_CONFIG_H @KERNEL_CXXFLAGS@ -I$(top_builddir)/salomeadn/unix \
- -I$(top_builddir)/idl \
+ -I$(srcdir) -I$(top_builddir)/idl \
-I$(srcdir)/../../SUIT -I$(srcdir)/../../CAM -I$(srcdir)/../../STD \
-I$(srcdir)/../../Qtx -I$(srcdir)/../../SalomeApp -I$(srcdir)/../../Event \
-I$(srcdir)/../../SalomeSession -I$(srcdir)/../../LogWindow \
_libSALOME_Swig_la_CPPFLAGS = \
$(QT_INCLUDES) $(QWT_INCLUDES) $(PYTHON_INCLUDES) $(CAS_CPPFLAGS) $(VTK_INCLUDES) \
$(OGL_INCLUDES) $(BOOST_CPPFLAGS) -DHAVE_CONFIG_H @KERNEL_CXXFLAGS@ \
- -I$(top_builddir)/salome_adm/unix -I$(top_builddir)/idl \
+ -I$(top_builddir)/salome_adm/unix -I$(top_builddir)/idl -I$(srcdir) \
-I$(srcdir)/../SalomeApp -I$(srcdir)/../Qtx -I$(srcdir)/../SUIT \
-I$(srcdir)/../ObjBrowser -I$(srcdir)/../LightApp -I$(srcdir)/../SOCC \
-I$(srcdir)/../SVTK -I$(srcdir)/../Event -I$(srcdir)/../OBJECT \
#include "SUIT_Application.h"
#include "SUIT_ViewManager.h"
-//#include "utilities.h"
+#include "SALOME_ListIO.hxx"
+
#include <QApplication>
#include <QToolBar>
#include <QToolButton>
aPlot2dView->getViewFrame()->Display(getPrs());
return aPlot2dView;
}
+
+/*!
+ SLOT: called when action "Legend Clicked" is activated.
+ override "onLegendClicked" method from Plot2d_ViewModel.
+*/
+void SPlot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem )
+{
+ Plot2d_ViewFrame* aViewFrame = getActiveViewFrame();
+ if(aViewFrame == NULL) return;
+
+ CurveDict aCurves = aViewFrame->getCurves();
+ SPlot2d_Curve* aSCurve;
+ CurveDict::Iterator it = aCurves.begin();
+ for( ; it != aCurves.end(); ++it )
+ {
+ if ( it.key() == plotItem ) {
+ aSCurve = dynamic_cast<SPlot2d_Curve*>( it.value() );
+ break;
+ }
+ }
+ // Highlight curve in Object Browser
+ if(aSCurve && aSCurve->hasIO()) {
+ QString anEntry = aSCurve->getIO()->getEntry();
+ emit legendSelected( anEntry );
+ }
+}
SPlot2d_Curve* getCurveByIO( const Handle(SALOME_InteractiveObject)&, Plot2d_ViewFrame* = 0 );
Plot2d_ViewFrame* getActiveViewFrame();
Handle(SALOME_InteractiveObject) FindIObject( const char* Entry );
+
+protected slots:
+ virtual void onLegendClicked( QwtPlotItem* plotItem );
+
+signals:
+ void legendSelected( const QString& );
};
studyCreated( activeStudy() );
else
{
- delete activeStudy();
+ SUIT_Study* st = activeStudy();
setActiveStudy( 0 );
+ delete st;
}
}
else
Q_OBJECT
public:
- enum { FileNewId, FileOpenId, FileCloseId, FileSaveId, FileSaveAsId, FileExitId,
- ViewWindowsId, ViewToolBarsId, ViewStatusBarId, NewWindowId,
- EditCutId, EditCopyId, EditPasteId, HelpAboutId, UserID };
+ enum { MenuFileId, FileNewId, FileOpenId, FileCloseId, FileSaveId, FileSaveAsId, FileExitId,
+ MenuViewId, ViewWindowsId, ViewToolBarsId, ViewStatusBarId, NewWindowId,
+ MenuEditId, EditCutId, EditCopyId, EditPasteId,
+ MenuHelpId, HelpAboutId,
+ UserID
+ };
public:
STD_Application();
bool exitConfirmation() const;
void setExitConfirmation( const bool );
+ virtual void updateDesktopTitle();
+
signals:
/*!emit that view manager added*/
void viewManagerAdded( SUIT_ViewManager* );
virtual void onViewManagerActivated( SUIT_ViewManager* );
protected:
- enum { MenuFileId = 1,
- MenuViewId = 2,
- MenuEditId = 3,
- MenuHelpId = 7
- };
-
enum { OpenCancel, OpenNew, OpenExist };
enum { CloseCancel, CloseSave, CloseDiscard };
protected:
virtual void createActions();
- virtual void updateDesktopTitle();
virtual void updateCommandsStatus();
virtual void setDesktop( SUIT_Desktop* );
libsuit_la_CPPFLAGS = $(QT_INCLUDES) -I$(srcdir)/../Qtx -I$(srcdir)/../ObjBrowser
if ENABLE_TESTRECORDER
- libsuit_la_CPPFLAGS+= $(TESTRECORDER_INCLUDES)
-else !ENABLE_TESTRECORDER
- libsuit_la_CPPFLAGS+= -DDISABLE_TESTRECORDER
+ libsuit_la_CPPFLAGS+= -DENABLE_TESTRECORDER $(TESTRECORDER_INCLUDES)
endif
libsuit_la_LDFLAGS = $(QT_MT_LIBS)
myAction = a;
myAction->setEnabled( application()->activeStudy() );
- connect( myAction, SIGNAL( activated() ), SLOT( start() ) );
+ connect( myAction, SIGNAL( triggered() ), SLOT( start() ) );
}
/*! Add action to widget \a wid.
//
#include "SUIT_DataBrowser.h"
-#include <SUIT_TreeModel.h>
+#include "SUIT_TreeModel.h"
#include <QtxTreeView.h>
#include <QShortcut>
setItemDelegate( qobject_cast<SUIT_ProxyModel*>( model() )->delegate() );
connect( treeView(), SIGNAL( sortingEnabled( bool ) ),
model(), SLOT( setSortingEnabled( bool ) ) );
+ connect( treeView(), SIGNAL( clicked( const QModelIndex& ) ),
+ this, SLOT( onClicked( const QModelIndex& ) ) );
connect( treeView(), SIGNAL( doubleClicked( const QModelIndex& ) ),
this, SLOT( onDblClicked( const QModelIndex& ) ) );
connect( treeView(), SIGNAL( expanded( const QModelIndex& ) ),
\sa updateKey(), setUpdateKey()
*/
+/*!
+ \fn void SUIT_DataBrowser::clicked( SUIT_DataObject* o );
+ \brief This signal is emitted when a mouse button is clicked.
+
+ The data object the mouse was clicked on is specified by \a o.
+ The signal is only emitted when the object is valid.
+
+ \param o data object which is clicked
+*/
+
/*!
\fn void SUIT_DataBrowser::doubleClicked( SUIT_DataObject* o );
\brief This signal is emitted when a mouse button is double-clicked.
setModified();
}
+/*!
+ \brief Called when item is clicked in the tree view
+ \internal
+
+ Emits signal clicked( SUIT_DataObject* );
+*/
+void SUIT_DataBrowser::onClicked( const QModelIndex& index )
+{
+ SUIT_ProxyModel* m = qobject_cast<SUIT_ProxyModel*>( model() );
+
+ if ( m ) {
+ SUIT_DataObject* obj = m->object( index );
+ if ( obj ) emit( clicked( obj ) );
+ }
+}
+
/*!
\brief Called when item is double-clicked in the tree view
\internal
signals:
void requestUpdate();
+ void clicked( SUIT_DataObject* );
void doubleClicked( SUIT_DataObject* );
private slots:
void onModelUpdated();
+ void onClicked( const QModelIndex& );
void onDblClicked( const QModelIndex& );
void onExpanded( const QModelIndex& );
return child;
}
-/*!
- \brief Get the number of the columns provided by the data tree.
-
- This method can be re-implemented in the subclasses.
- Default implementation returns 1 ("Name" column) only.
-
- \return number of the columns
-*/
-int SUIT_DataObject::columnCount() const
-{
- return 1; // one column ("Name") is provided by default
-}
-
-/*!
- \brief Get column title.
-
- This method can be re-implemented in the subclasses.
- Default implementation returns the title for the first column ("Name") only.
-
- \param index column index
- \return title of the specified column
-*/
-QString SUIT_DataObject::columnTitle( const int index ) const
-{
- if ( index == NameIdx )
- return QObject::tr( "NAME_COLUMN" ); // one column ("Name") is provided by default
- return QString();
-}
-
-/*!
- \brief Get column icon.
-
- This method can be re-implemented in the subclasses.
- Default implementation returns null pixmap.
-
- \param index column index
- \return icon of the specified column
-*/
-QPixmap SUIT_DataObject::columnIcon( const int /*index*/ ) const
-{
- return QPixmap();
-}
-
-/*!
- \brief Check if the column should appear in the tree view header popup menu
- (to show/hide the column).
-
- Default implementation returns \c false because 'Name' column should be
- always visible.
-
- \param index column index
- \return \c true if the column can be shown/hidden
-*/
-bool SUIT_DataObject::appropriate( const int /*index*/ ) const
-{
- return false;
-}
-
/*!
\brief Get the number of the child objects.
\return number of the children
This method can be re-implemented in the subclasses.
Default implementation returns null string.
- Column with \a index = 0 (NameIdx) is supposed to be used
+ Column with \a id = 0 (NameId) is supposed to be used
to get the object name (as it does the default implementation).
- \param index column index
+ \param id column id
\return object text data
*/
-QString SUIT_DataObject::text( const int index ) const
+QString SUIT_DataObject::text( const int id ) const
{
- return index == NameIdx ? name() : QString();
+ return id == NameId ? name() : QString();
}
/*!
This method can be re-implemented in the subclasses.
Default implementation returns null pixmap.
- The parameter \a index specifies the column number
- (to display, for example, in the tree view widget).
+ The parameter \a id specifies the column identificator
- \param index column index
+ \param id column id
\return object icon for the specified column
*/
-QPixmap SUIT_DataObject::icon( const int /*index*/ ) const
+QPixmap SUIT_DataObject::icon( const int /*id*/ ) const
{
return QPixmap();
}
This method can be re-implemented in the subclasses.
Default implementation returns null color.
- The parameter \a index specifies the column number
- (to display, for example, in the tree view widget).
+ The parameter \a id specifies the column identificator
\param role color role
- \param index column index
+ \param id column id
\return object color for the specified column
*/
-QColor SUIT_DataObject::color( const ColorRole /*role*/, const int /*index*/ ) const
+QColor SUIT_DataObject::color( const ColorRole /*role*/, const int /*id*/ ) const
{
return QColor();
}
This method can be re-implemented in the subclasses.
Default implementation returns null string.
- The parameter \a index specifies the column number
+ The parameter \a id specifies the column identificator
(to display, for example, in the tree view widget).
- \param index column index
+ \param id column id
\return object tooltip for the specified column
*/
-QString SUIT_DataObject::toolTip( const int /*index*/ ) const
+QString SUIT_DataObject::toolTip( const int /*id*/ ) const
{
return QString();
}
This method can be re-implemented in the subclasses.
Default implementation returns null string.
- The parameter \a index specifies the column number
- (to display, for example, in the tree view widget).
+ The parameter \a id specifies the column identificator
- \param index column index
+ \param id column id
\return object status tip for the specified column
*/
-QString SUIT_DataObject::statusTip( const int /*index*/ ) const
+QString SUIT_DataObject::statusTip( const int /*id*/ ) const
{
return QString();
}
This method can be re-implemented in the subclasses.
Default implementation returns null string.
- The parameter \a index specifies the column number
- (to display, for example, in the tree view widget).
+ The parameter \a id specifies the column identificator
- \param index column index
+ \param id column id
\return object "what's this" information for the specified column
*/
-QString SUIT_DataObject::whatsThis( const int /*index*/ ) const
+QString SUIT_DataObject::whatsThis( const int /*id*/ ) const
{
return QString();
}
This method can be re-implemented in the subclasses.
Default implementation returns application default font.
- The parameter \a index specifies the column number
- (to display, for example, in the tree view widget).
+ The parameter \a id specifies the column identificator
- \param index column index
+ \param id column id
\return object font for the specified column
*/
-QFont SUIT_DataObject::font( const int /*index*/ ) const
+QFont SUIT_DataObject::font( const int /*id*/ ) const
{
return QFont();
}
Default implementation returns default alignment which
is Qt:AlignLeft.
- The parameter \a index specifies the column number
+ The parameter \a id specifies the column identificator
(to display, for example, in the tree view widget).
- \param index column index
+ \param id column id
\return object text alignment flags for the specified column
*/
-int SUIT_DataObject::alignment( const int /*index*/ ) const
+int SUIT_DataObject::alignment( const int /*id*/ ) const
{
return Qt::AlignLeft;
}
This method can be re-implemented in the subclasses.
Default implementation returns \c false (all objects are not checkable).
- \param index column index
+ \param id column id
\return \c true if the item can be checked or unchecked by the user
\sa isOn(), setOn()
*/
-bool SUIT_DataObject::isCheckable( const int /*index*/ ) const
+bool SUIT_DataObject::isCheckable( const int /*id*/ ) const
{
return false;
}
Default implementation supports the checked state for the first
("Name") column only.
- \param index column index
+ \param id column id
\return checked state of the object for the specified column
\sa setOn(), isCheckable()
*/
-bool SUIT_DataObject::isOn( const int index ) const
+bool SUIT_DataObject::isOn( const int id ) const
{
- return index == NameIdx && myCheck;
+ return id == NameId && myCheck;
}
/*!
("Name") column only.
\param on new checked state of the object for the specified column
- \param index column index
+ \param id column id
\sa isOn(), isCheckable()
*/
-void SUIT_DataObject::setOn( const bool on, const int index )
+void SUIT_DataObject::setOn( const bool on, const int id )
{
- if ( index == NameIdx )
+ if( id == NameId )
myCheck = on;
}
Default implementation returns false ("Name" column does not require
custom sorting).
- \param index column index
+ \param id column id
\return \c true if column sorting should be customized
\sa compare()
*/
-bool SUIT_DataObject::customSorting( const int /*index*/ ) const
+bool SUIT_DataObject::customSorting( const int /*id*/ ) const
{
return false;
}
\param left first data to compare
\param right second data to compare
- \param index column index
+ \param id column id
\return result of the comparison
\sa customSorting()
*/
bool SUIT_DataObject::compare( const QVariant& /*left*/, const QVariant& /*right*/,
- const int /*index*/ ) const
+ const int /*id*/ ) const
{
return false;
}
{
}
+/*!
+ \brief return unique group identificator
+
+ Groups of data objects are used for column information search.
+ Each column of data model has one or several registered group id
+ If object has the same group id as one of registered, the information
+ will be shown; the custom id of column will be passed into data() method
+ in order to identify column from point of view of data object
+
+ */
+int SUIT_DataObject::groupId() const
+{
+ return 0;
+}
+
/*!
\fn void SUIT_DataObject::Signal::created( SUIT_DataObject* object );
\brief Emitted when data object is created.
HighlightedText //!< highlighted foreground (text) color
} ColorRole;
- //! Column index
- enum {
- NameIdx //!< name column
+ //! Column id
+ enum
+ {
+ NameId //!< name column
};
SUIT_DataObject( SUIT_DataObject* = 0 );
SUIT_DataObject* lastChild() const;
SUIT_DataObject* firstChild() const;
- virtual int columnCount() const;
- virtual QString columnTitle( const int = NameIdx ) const;
- virtual QPixmap columnIcon( const int = NameIdx ) const;
- virtual bool appropriate( const int = NameIdx ) const;
-
int childCount() const;
int childPos( const SUIT_DataObject* ) const;
SUIT_DataObject* childObject( const int ) const;
virtual void setParent( SUIT_DataObject* );
virtual QString name() const;
- virtual QString text( const int = NameIdx ) const;
- virtual QPixmap icon( const int = NameIdx ) const;
- virtual QColor color( const ColorRole, const int = NameIdx ) const;
- virtual QString toolTip( const int = NameIdx ) const;
- virtual QString statusTip( const int = NameIdx ) const;
- virtual QString whatsThis( const int = NameIdx ) const;
- virtual QFont font( const int = NameIdx ) const;
- virtual int alignment( const int = NameIdx ) const;
+ virtual QString text( const int = NameId ) const;
+ virtual QPixmap icon( const int = NameId ) const;
+ virtual QColor color( const ColorRole, const int = NameId ) const;
+ virtual QString toolTip( const int = NameId ) const;
+ virtual QString statusTip( const int = NameId ) const;
+ virtual QString whatsThis( const int = NameId ) const;
+ virtual QFont font( const int = NameId ) const;
+ virtual int alignment( const int = NameId ) const;
virtual bool isDragable() const;
virtual bool isDropAccepted( SUIT_DataObject* obj );
virtual bool isEnabled() const;
virtual bool isSelectable() const;
- virtual bool isCheckable( const int = NameIdx ) const;
+ virtual bool isCheckable( const int = NameId ) const;
- virtual bool isOn( const int = NameIdx ) const;
- virtual void setOn( const bool, const int = NameIdx );
+ virtual bool isOn( const int = NameId ) const;
+ virtual void setOn( const bool, const int = NameId );
virtual bool isOpen() const;
virtual void setOpen( const bool );
virtual void update();
- virtual bool customSorting( const int = NameIdx ) const;
- virtual bool compare( const QVariant&, const QVariant&,
- const int = NameIdx ) const;
+ virtual bool customSorting( const int = NameId ) const;
+ virtual bool compare( const QVariant&, const QVariant&, const int = NameId ) const;
virtual SUIT_DataObjectKey* key() const;
+ virtual int groupId() const;
static Signal* signal();
static bool connect( const char*, QObject*, const char* );
#include "SUIT_MessageBox.h"
-#ifndef DISABLE_TESTRECORDER
+#ifdef ENABLE_TESTRECORDER
#include <TestApplication.h>
#endif
*/
bool SUIT_ExceptionHandler::internalHandle( QObject* o, QEvent* e )
{
-#ifndef DISABLE_TESTRECORDER
+#ifdef ENABLE_TESTRECORDER
TestApplication* aTApp = qobject_cast<TestApplication*>(qApp);
return aTApp ? aTApp->TestApplication::notify( o, e ) : false;
#else
QFont aFooterFont = aBodyFont;
// calculate margin
- QPaintDevice* aMetrics(aPainter.device());
+ QPaintDevice* aMetrics = aPainter.device();
int aDpiY = aMetrics->logicalDpiY();
int aMargin = (int) ( (2/2.54)*aDpiY ); // 2 cm margins
#define SUIT_SESSION_H
#include "SUIT.h"
-
-#include <SUIT_Application.h>
+#include "SUIT_Application.h"
#include <QList>
#include <QObject>
// get last operation which can be resumed
SUIT_Operation* aResultOp = 0;
- for ( Operations::iterator it = myOperations.end(); it != myOperations.begin(); --it )
+
+ QListIterator<SUIT_Operation*> it (myOperations);
+ it.toBack();
+ while( it.hasPrevious() )
{
- SUIT_Operation* anOp = *it;
+ SUIT_Operation* anOp = it.previous();
if ( anOp && anOp != theOp && blockingOperation( anOp ) == 0 )
{
aResultOp = anOp;
#include <QList>
#include <QObject>
+#include <QListIterator>
class SUIT_DataObject;
class SUIT_Application;
#include "SUIT_DataObject.h"
#include <QApplication>
+#include <QHash>
+
+SUIT_AbstractModel::SUIT_AbstractModel()
+{
+}
+
+SUIT_AbstractModel::operator const QAbstractItemModel*() const
+{
+ return dynamic_cast<const QAbstractItemModel*>( this );
+}
+
+SUIT_AbstractModel::operator QAbstractItemModel*()
+{
+ return dynamic_cast<QAbstractItemModel*>( this );
+}
+
+SUIT_AbstractModel::operator const QObject*() const
+{
+ return dynamic_cast<const QObject*>( this );
+}
+
+
+
+
+
/*!
\class SUIT_TreeModel::TreeItem
delete myRootItem;
}
+/*!
+ \brief Register new column in the model
+ \param group_id - unique data object group identificator
+ \param name - translated column name
+ \param custom_id - custom column id that should be passed into method SUIT_DataObject::data()
+ */
+void SUIT_TreeModel::registerColumn( const int group_id, const QString& name, const int custom_id )
+{
+ bool found = false;
+ for( int i=0, n=myColumns.size(); i<n && !found; i++ )
+ if( name==myColumns[i].myName )
+ {
+ myColumns[i].myIds.insert( group_id, custom_id );
+ found = true;
+ }
+ if( !found )
+ {
+ ColumnInfo inf;
+ inf.myName = name;
+ inf.myIds.insert( group_id, custom_id );
+ inf.myAppropriate = Qtx::Shown;
+ int n = myColumns.size();
+ myColumns.resize( n+1 );
+ myColumns[n] = inf;
+ reset();
+ }
+}
+
+/*!
+ \brief Remove column from the model
+
+ Please take into account that column is removed only for given group_id, it means
+ that information of data objects with such group_id won't be shown.
+ If there is not any registered group_id for this column after removing, the column will be hidden
+ otherwise it continue to be shown
+
+ \param group_id - unique data object identificator allowing the classification of objects
+ \param name - translated column name
+ */
+void SUIT_TreeModel::unregisterColumn( const int group_id, const QString& name )
+{
+ for( int i=0, n=myColumns.size(); i<n; i++ )
+ if( myColumns[i].myName==name )
+ {
+ myColumns[i].myIds.remove( group_id );
+ if( myColumns[i].myIds.isEmpty() )
+ {
+ myColumns.remove( i );
+ reset();
+ }
+ break;
+ }
+}
+
+/*!
+ \brief Change column icon.
+
+ \param name - column name
+ \param icon - new icon of the specified column
+*/
+void SUIT_TreeModel::setColumnIcon( const QString& name, const QPixmap& icon )
+{
+ for( int i=0, n=myColumns.size(); i<n; i++ )
+ if( myColumns[i].myName==name )
+ {
+ myColumns[i].myIcon = icon;
+ break;
+ }
+}
+
+/*!
+ \brief Get column icon.
+
+ \param name - column name
+ \return icon of the specified column
+*/
+QPixmap SUIT_TreeModel::columnIcon( const QString& name ) const
+{
+ QPixmap res;
+ for( int i=0, n=myColumns.size(); i<n; i++ )
+ if( myColumns[i].myName==name )
+ {
+ res = myColumns[i].myIcon;
+ break;
+ }
+ return res;
+}
+
+/*!
+ \brief Change appropriate status
+
+ Appropriate status determines if the column should appear in the tree view header popup menu
+ (to show/hide the column).
+
+ If appropriate status is not specified yet, the \c Shown value is taken,
+ it means that column should be always visible.
+
+ \param name - column name
+ \param appr - new appropriate status
+*/
+void SUIT_TreeModel::setAppropriate( const QString& name, const Qtx::Appropriate appr )
+{
+ for( int i=0, n=myColumns.size(); i<n; i++ )
+ if( myColumns[i].myName==name )
+ {
+ myColumns[i].myAppropriate = appr;
+ emit headerDataChanged( Qt::Horizontal, i, i );
+ break;
+ }
+}
+
+/*!
+ \brief Check if the column should appear in the tree view header popup menu
+ (to show/hide the column).
+
+ Default implementation (if appropriate status is not specified yet)
+ returns \c Shown, it means that column should be always visible.
+
+ \param name - column name
+ \return appropriate status
+*/
+Qtx::Appropriate SUIT_TreeModel::appropriate( const QString& name ) const
+{
+ Qtx::Appropriate appr = Qtx::Shown;
+ for( int i=0, n=myColumns.size(); i<n; i++ )
+ if( myColumns[i].myName==name )
+ {
+ appr = myColumns[i].myAppropriate;
+ break;
+ }
+ return appr;
+}
+
+
/*!
\brief Get data tree root object.
\return data tree root
QColor c;
QVariant val;
- if ( obj ) {
- switch ( role ) {
+ int obj_group_id = obj->groupId();
+ const ColumnInfo& inf = myColumns[index.column()];
+
+ int id = -1;
+ if( inf.myIds.contains( 0 ) )
+ id = inf.myIds[0];
+ if( inf.myIds.contains( obj_group_id ) )
+ id = inf.myIds[obj_group_id];
+
+ if( id<0 )
+ return QVariant();
+
+ if ( obj )
+ {
+ switch ( role )
+ {
case DisplayRole:
// data object text for the specified column
- val = obj->text( index.column() );
+ val = obj->text( id );
break;
case DecorationRole:
// data object icon for the specified column
- val = obj->icon( index.column() );
+ val = obj->icon( id );
break;
case ToolTipRole:
// data object tooltip for the specified column
- val = obj->toolTip( index.column() );
+ val = obj->toolTip( id );
break;
case StatusTipRole:
// data object status tip for the specified column
- val = obj->statusTip( index.column() );
+ val = obj->statusTip( id );
break;
case WhatsThisRole:
// data object what's this info for the specified column
- val = obj->whatsThis( index.column() );
+ val = obj->whatsThis( id );
break;
case FontRole:
// data object font for the specified column
- val = obj->font( index.column() );
+ val = obj->font( id );
break;
case TextAlignmentRole:
// data object text alignment for the specified column
- val = obj->alignment( index.column() );
+ val = obj->alignment( id );
break;
case BackgroundRole:
// data background color for the specified column
- c = obj->color( SUIT_DataObject::Background, index.column() );
- if ( !c.isValid() ) // default value
- c = QApplication::palette().color( QPalette::Base );
+ c = obj->color( SUIT_DataObject::Background, id );
+ if( !c.isValid() ) // default value
+ c = QApplication::palette().color( QPalette::Base );
c.setAlpha( 0 );
val = c;
break;
case ForegroundRole:
// data foreground (text) color for the specified column
- c = obj->color( SUIT_DataObject::Foreground, index.column() );
- if ( !c.isValid() ) // default value
- c = QApplication::palette().color( QPalette::Foreground );
+ c = obj->color( SUIT_DataObject::Foreground, id );
+ if( !c.isValid() ) // default value
+ c = QApplication::palette().color( QPalette::Foreground );
val = c;
break;
case BaseColorRole:
// editor background color for the specified column
- c = obj->color( SUIT_DataObject::Base, index.column() );
- if ( !c.isValid() ) // default value
- c = QApplication::palette().color( QPalette::Base );
+ c = obj->color( SUIT_DataObject::Base, id );
+ if( !c.isValid() ) // default value
+ c = QApplication::palette().color( QPalette::Base );
val = c;
break;
case TextColorRole:
// editor foreground (text) color for the specified column
- c = obj->color( SUIT_DataObject::Text, index.column() );
- if ( !c.isValid() ) // default value
- c = QApplication::palette().color( QPalette::Text );
+ c = obj->color( SUIT_DataObject::Text, id );
+ if( !c.isValid() ) // default value
+ c = QApplication::palette().color( QPalette::Text );
val = c;
break;
case HighlightRole:
// adta object highlighted background color for the specified column
- c = obj->color( SUIT_DataObject::Highlight, index.column() );
- if ( !c.isValid() ) // default value
- c = QApplication::palette().color( QPalette::Highlight );
+ c = obj->color( SUIT_DataObject::Highlight, id );
+ if( !c.isValid() ) // default value
+ c = QApplication::palette().color( QPalette::Highlight );
val = c;
break;
case HighlightedTextRole:
// data object highlighted foreground (text) color for the specified column
- c = obj->color( SUIT_DataObject::HighlightedText, index.column() );
- if ( !c.isValid() ) // default value
- c = QApplication::palette().color( QPalette::HighlightedText );
+ c = obj->color( SUIT_DataObject::HighlightedText, id );
+ if( !c.isValid() ) // default value
+ c = QApplication::palette().color( QPalette::HighlightedText );
val = c;
break;
case CheckStateRole:
// data object checked state for the specified column
// NOTE! three-state check is not supported currently
- if ( obj->isCheckable( index.column() ) )
- val = obj->isOn( index.column() ) ? Qt::Checked : Qt::Unchecked;
+ if( obj->isCheckable( id ) )
+ val = obj->isOn( id ) ? Qt::Checked : Qt::Unchecked;
break;
case SizeHintRole:
// data size hint
\param role data role
\return header data
*/
-QVariant SUIT_TreeModel::headerData( int column, Qt::Orientation orientation,
- int role ) const
+QVariant SUIT_TreeModel::headerData( int column, Qt::Orientation orientation, int role ) const
{
QVariant d;
// NOTE! only horizontal header is supported
- if ( root() && orientation == Qt::Horizontal ) {
- switch ( role ) {
+ if ( root() && orientation == Qt::Horizontal )
+ {
+ switch ( role )
+ {
case DisplayRole:
// column title
- d = root()->columnTitle( column );
+ d = myColumns[column].myName;
break;
case DecorationRole:
// column icon
- d = root()->columnIcon( column );
+ d = myColumns[column].myIcon;
break;
case AppropriateRole:
// appropriate flag (can column be hidden via context popup menu)
- d = root()->appropriate( column );
+ d = myColumns[column].myAppropriate;
break;
default:
break;
QModelIndex SUIT_TreeModel::index( int row, int column,
const QModelIndex& parent ) const
{
- if ( hasIndex( row, column, parent ) ) {
+ if( hasIndex( row, column, parent ) )
+ {
TreeItem* parentItem = treeItem( parent );
- if ( parentItem ) {
+ QString pname;
+ if( parentItem && parentItem->dataObject() )
+ pname = parentItem->dataObject()->name();
+ if( parentItem )
+ {
TreeItem* childItem = parentItem->child( row );
- if ( childItem )
+ if( childItem )
return createIndex( row, column, childItem );
}
}
*/
int SUIT_TreeModel::columnCount( const QModelIndex& /*parent*/ ) const
{
- return root() ? root()->columnCount() : 0;
+ return myColumns.size();
}
/*!
if ( !myRootItem )
myRootItem = new TreeItem( 0 );
+ registerColumn( 0, QObject::tr( "NAME_COLUMN" ), SUIT_DataObject::NameId );
updateTree();
}
// update all columns corresponding to the given data object
QModelIndex firstIdx = index( obj, 0 );
- QModelIndex lastIdx = index( obj, obj->columnCount() - 1 );
+ QModelIndex lastIdx = index( obj, columnCount() - 1 );
emit dataChanged( firstIdx, lastIdx );
}
\param model tree model
\param parent parent object
*/
-SUIT_ProxyModel::SUIT_ProxyModel( SUIT_TreeModel* model, QObject* parent )
+SUIT_ProxyModel::SUIT_ProxyModel( SUIT_AbstractModel* model, QObject* parent )
: QSortFilterProxyModel( parent ),
mySortingEnabled( true )
{
- connect( model, SIGNAL( modelUpdated() ), this, SIGNAL( modelUpdated() ) );
- setSourceModel( model );
+ connect( *model, SIGNAL( modelUpdated() ), this, SIGNAL( modelUpdated() ) );
+ setSourceModel( *model );
}
/*!
return QSortFilterProxyModel::lessThan( left, right );
}
+/*!
+ \brief Check if the specified column supports custom sorting.
+ \param column column index on which data is being sorted
+ \return \c true if column requires custom sorting
+ \sa lessThan()
+*/
+bool SUIT_ProxyModel::customSorting( const int column ) const
+{
+ return treeModel() ? treeModel()->customSorting( column ) : false;
+}
+
/*!
\brief Enable/disable sorting.
\param enabled new flag state
\brief Get tree model.
\return tree model
*/
-SUIT_TreeModel* SUIT_ProxyModel::treeModel() const
+SUIT_AbstractModel* SUIT_ProxyModel::treeModel() const
+{
+ return dynamic_cast<SUIT_AbstractModel*>( sourceModel() );
+}
+
+/*!
+ \brief Register new column in the model
+ \param group_id - unique data object identificator allowing the classification of objects
+ \param name - translated column name
+ \param custom_id - custom column id that should be passed into method SUIT_DataObject::data()
+ */
+void SUIT_ProxyModel::registerColumn( const int group_id, const QString& name, const int custom_id )
{
- return dynamic_cast<SUIT_TreeModel*>( sourceModel() );
+ if( treeModel() )
+ treeModel()->registerColumn( group_id, name, custom_id );
}
+/*!
+ \brief Remove column from the model
+
+ Please take into account that column is removed only for given group_id, it means
+ that information of data objects with such group_id won't be shown.
+ If there is not any registered group_id for this column after removing, the column will be hidden
+ otherwise it continue to be shown
+
+ \param group_id - unique data object identificator allowing the classification of objects
+ \param name - translated column name
+ */
+void SUIT_ProxyModel::unregisterColumn( const int group_id, const QString& name )
+{
+ if( treeModel() )
+ treeModel()->unregisterColumn( group_id, name );
+}
+
+/*!
+ \brief Change column icon.
+
+ \param name - column name
+ \param icon - new icon of the specified column
+*/
+void SUIT_ProxyModel::setColumnIcon( const QString& name, const QPixmap& icon )
+{
+ if( treeModel() )
+ treeModel()->setColumnIcon( name, icon );
+}
+
+/*!
+ \brief Get column icon.
+
+ \param name - column name
+ \return icon of the specified column
+*/
+QPixmap SUIT_ProxyModel::columnIcon( const QString& name ) const
+{
+ return treeModel() ? treeModel()->columnIcon( name ) : QPixmap();
+}
+
+/*!
+ \brief Change appropriate status
+
+ Appropriate status determines if the column should appear in the tree view header popup menu
+ (to show/hide the column).
+
+ If appropriate status is not specified yet, the \c Shown value is taken,
+ it means that column should be always visible.
+
+ \param name - column name
+ \param appr - new appropriate status
+*/
+void SUIT_ProxyModel::setAppropriate( const QString& name, const Qtx::Appropriate appr )
+{
+ if( treeModel() )
+ treeModel()->setAppropriate( name, appr );
+}
+
+/*!
+ \brief Check if the column should appear in the tree view header popup menu
+ (to show/hide the column).
+
+ Default implementation (if appropriate status is not specified yet)
+ returns \c Shown, it means that column should be always visible.
+
+ \param name - column name
+ \return appropriate status
+*/
+Qtx::Appropriate SUIT_ProxyModel::appropriate( const QString& name ) const
+{
+ return treeModel() ? treeModel()->appropriate( name ) : Qtx::Shown;
+}
+
+
+
+
+
+
/*!
\class SUIT_ItemDelegate
\brief An SUIT_DataObject-based item delegate class.
class SUIT_DataObject;
class SUIT_TreeModel;
-class SUIT_EXPORT SUIT_TreeModel : public QAbstractItemModel
+class SUIT_EXPORT SUIT_AbstractModel
+{
+public:
+ SUIT_AbstractModel();
+
+ operator const QAbstractItemModel*() const;
+ operator QAbstractItemModel*();
+ operator const QObject*() const;
+
+ virtual SUIT_DataObject* root() const = 0;
+ virtual void setRoot( SUIT_DataObject* ) = 0;
+ virtual SUIT_DataObject* object( const QModelIndex& = QModelIndex() ) const = 0;
+ virtual QModelIndex index( const SUIT_DataObject*, int = 0 ) const = 0;
+ virtual bool autoDeleteTree() const = 0;
+ virtual void setAutoDeleteTree( const bool ) = 0;
+ virtual bool autoUpdate() const = 0;
+ virtual void setAutoUpdate( const bool ) = 0;
+ virtual QAbstractItemDelegate* delegate() const = 0;
+ virtual bool customSorting( const int ) const = 0;
+ virtual bool lessThan( const QModelIndex& left, const QModelIndex& right ) const = 0;
+
+ virtual void updateTree( const QModelIndex& ) = 0;
+ virtual void updateTree( SUIT_DataObject* = 0 ) = 0;
+
+ virtual void registerColumn( const int group_id, const QString& name, const int custom_id ) = 0;
+ virtual void unregisterColumn( const int group_id, const QString& name ) = 0;
+ virtual void setColumnIcon( const QString& name, const QPixmap& icon ) = 0;
+ virtual QPixmap columnIcon( const QString& name ) const = 0;
+ virtual void setAppropriate( const QString& name, const Qtx::Appropriate appr ) = 0;
+ virtual Qtx::Appropriate appropriate( const QString& name ) const = 0;
+};
+
+
+class SUIT_EXPORT SUIT_TreeModel : public QAbstractItemModel, public SUIT_AbstractModel
{
Q_OBJECT
virtual QModelIndex index( int, int, const QModelIndex& = QModelIndex() ) const;
virtual QModelIndex parent( const QModelIndex& ) const;
- virtual int columnCount( const QModelIndex& = QModelIndex() ) const;
- virtual int rowCount( const QModelIndex& = QModelIndex() ) const;
+ virtual int columnCount( const QModelIndex& = QModelIndex() ) const;
+ virtual int rowCount( const QModelIndex& = QModelIndex() ) const;
+ virtual void registerColumn( const int group_id, const QString& name, const int custom_id );
+ virtual void unregisterColumn( const int group_id, const QString& name );
+ virtual void setColumnIcon( const QString& name, const QPixmap& icon );
+ virtual QPixmap columnIcon( const QString& name ) const;
+ virtual void setAppropriate( const QString& name, const Qtx::Appropriate appr );
+ virtual Qtx::Appropriate appropriate( const QString& name ) const;
SUIT_DataObject* object( const QModelIndex& = QModelIndex() ) const;
QModelIndex index( const SUIT_DataObject*, int = 0 ) const;
TreeItem* treeItem( const SUIT_DataObject* ) const;
SUIT_DataObject* object( const TreeItem* ) const;
- TreeItem* createItem( SUIT_DataObject*,
- TreeItem* = 0,
- TreeItem* = 0 );
+ TreeItem* createItem( SUIT_DataObject*, TreeItem* = 0, TreeItem* = 0 );
void updateItem( TreeItem* );
void removeItem( TreeItem* );
private:
typedef QMap<SUIT_DataObject*, TreeItem*> ItemMap;
+ typedef struct
+ {
+ QString myName;
+ QMap<int,int> myIds;
+ QPixmap myIcon;
+ Qtx::Appropriate myAppropriate;
+
+ } ColumnInfo;
- SUIT_DataObject* myRoot;
- TreeItem* myRootItem;
- ItemMap myItems;
- bool myAutoDeleteTree;
- bool myAutoUpdate;
+ SUIT_DataObject* myRoot;
+ TreeItem* myRootItem;
+ ItemMap myItems;
+ bool myAutoDeleteTree;
+ bool myAutoUpdate;
+ QVector<ColumnInfo> myColumns;
friend class SUIT_TreeModel::TreeSync;
};
-class SUIT_EXPORT SUIT_ProxyModel : public QSortFilterProxyModel
+class SUIT_EXPORT SUIT_ProxyModel : public QSortFilterProxyModel, public SUIT_AbstractModel
{
Q_OBJECT
public:
SUIT_ProxyModel( QObject* = 0 );
SUIT_ProxyModel( SUIT_DataObject*, QObject* = 0 );
- SUIT_ProxyModel( SUIT_TreeModel*, QObject* = 0 );
+ SUIT_ProxyModel( SUIT_AbstractModel*, QObject* = 0 );
~SUIT_ProxyModel();
SUIT_DataObject* root() const;
void setAutoUpdate( const bool );
bool isSortingEnabled() const;
+ bool customSorting( const int ) const;
+
+ virtual bool lessThan( const QModelIndex&, const QModelIndex& ) const;
+ virtual void registerColumn( const int group_id, const QString& name, const int custom_id );
+ virtual void unregisterColumn( const int group_id, const QString& name );
+ virtual void setColumnIcon( const QString& name, const QPixmap& icon );
+ virtual QPixmap columnIcon( const QString& name ) const;
+ virtual void setAppropriate( const QString& name, const Qtx::Appropriate appr );
+ virtual Qtx::Appropriate appropriate( const QString& name ) const;
QAbstractItemDelegate* delegate() const;
void modelUpdated();
protected:
- virtual bool lessThan( const QModelIndex&, const QModelIndex& ) const;
-
-private:
- SUIT_TreeModel* treeModel() const;
+ SUIT_AbstractModel* treeModel() const;
private:
bool mySortingEnabled;
#include "SUIT_Desktop.h"
#include "SUIT_ViewModel.h"
-#include <SUIT_ViewWindow.h>
+#include "SUIT_ViewWindow.h"
#include "SUIT_Study.h"
#include <QMap>
//
#include "SUIT_ViewModel.h"
-
-#include <SUIT_ViewWindow.h>
+#include "SUIT_ViewWindow.h"
SUIT_ViewModel::StatesMap SUIT_ViewModel::myStateMap;
SUIT_ViewModel::ButtonsMap SUIT_ViewModel::myButtonMap;
+++ /dev/null
-// SALOME Utils : general SALOME's definitions and tools
-//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-//
-//
-// File : utilities.h
-// Author : Antoine YESSAYAN, Paul RASCLE, EDF
-// Module : SALOME
-// $Header$
-
-/*! --- Definition macros file to print informations if _DEBUG_ is defined --- */
-
-#ifndef UTILITIES_H
-#define UTILITIES_H
-
-#include <iostream>
-#include <sstream>
-#include <cstdlib>
-
-
-#include "LocalTraceBufferPool.hxx"
-
-/*! \file utilities.h
- * For each message to put in the trace, a specific ostingstream object is \n
- * created and destroyed automatically at the end of the message macro. \n
- * The insert function of LocalTraceBufferPool class gets a buffer in a \n
- * buffer pool (unique with the help of mutexes and semaphores) and copy the \n
- * message in the buffer.\n
- * This buffer is read later by a specific thread in charge of trace print.\n
- * Order of trace entries is globally respected. Nevertheless, if there are \n
- * several threads waiting for a free buffer to trace, the order of \n
- * thread waken up is not garanteed (no fifo or priority rules in Linux Kernel)
- */
-
-#define MESS_INIT(deb) std::ostringstream os; os<<deb
-#define MESS_BEGIN(deb) MESS_INIT(deb)<<__FILE__ <<" ["<<__LINE__<<"] : "
-#define MESS_END std::endl; LocalTraceBufferPool::instance()->insert(NORMAL_MESS, os.str().c_str());
-#define MESS_ABORT std::endl; LocalTraceBufferPool::instance()->insert(ABORT_MESS, os.str().c_str());
-
-// --- Some macros are always defined (without _DEBUG_): for use with release version
-
-#define INFOS(msg) {MESS_BEGIN("- Trace ") << msg << MESS_END}
-#define PYSCRIPT(msg) {MESS_INIT("---PYSCRIPT--- ") << msg << MESS_END}
-#define INTERRUPTION(msg) {MESS_BEGIN("- INTERRUPTION: ")<< msg << MESS_ABORT}
-#define IMMEDIATE_ABORT(code) {std::cout <<std::flush; \
- std::cerr << "- ABORT " << __FILE__ << " [" <<__LINE__<< "] : " << flush; \
- std::cerr << "ABORT return code= "<< code << std::endl; \
- std::exit(code);}
-
-/*! --- To print date and time of compilation of current source --- */
-
-#if defined ( __GNUC__ )
-#define COMPILER "g++"
-#elif defined ( __sun )
-#define COMPILER "CC"
-#elif defined ( __KCC )
-#define COMPILER "KCC"
-#elif defined ( __PGI )
-#define COMPILER "pgCC"
-#elif defined ( __alpha )
-#define COMPILER "cxx"
-#else
-#define COMPILER "undefined"
-#endif
-
-#ifdef INFOS_COMPILATION
-#error INFOS_COMPILATION already defined
-#endif
-
-#define INFOS_COMPILATION { MESS_BEGIN("COMPILED with ") << COMPILER \
- << ", " << __DATE__ \
- << " at " << __TIME__ << MESS_END }
-#ifdef _DEBUG_
-
-/*! @name the following MACROS are useful at debug time*/
-//@{
-#define MESSAGE(msg) {MESS_BEGIN("- Trace ") << msg << MESS_END}
-#define SCRUTE(var) {MESS_BEGIN("- Trace ") << #var << "=" << var <<MESS_END}
-
-#define REPERE ("------- ")
-#define BEGIN_OF(msg) {MESS_BEGIN(REPERE) << "Begin of: " << msg << MESS_END}
-#define END_OF(msg) {MESS_BEGIN(REPERE) << "Normal end of: " << msg << MESS_END}
-
-#ifndef ASSERT
-#define ASSERT(condition) \
- if (!(condition)){INTERRUPTION("CONDITION "<<#condition<<" NOT VERIFIED")}
-#endif /* ASSERT */
-//@}
-
-#else /* ifdef _DEBUG_*/
-
-#define MESSAGE(msg) {}
-#define SCRUTE(var) {}
-#define REPERE
-#define BEGIN_OF(msg) {}
-#define END_OF(msg) {}
-
-#ifndef ASSERT
-#define ASSERT(condition) {}
-#endif /* ASSERT */
-
-#endif /* ifdef _DEBUG_*/
-
-#endif /* ifndef UTILITIES_H */
-I$(srcdir)/../SUIT -I$(srcdir)/../Qtx -I$(srcdir)/../Style
if ENABLE_TESTRECORDER
- libSUITApp_la_CPPFLAGS+= $(TESTRECORDER_INCLUDES)
-else !ENABLE_TESTRECORDER
- libSUITApp_la_CPPFLAGS+= -DDISABLE_TESTRECORDER
- MOC_FLAGS = -DDISABLE_TESTRECORDER
+ libSUITApp_la_CPPFLAGS+= -DENABLE_TESTRECORDER $(TESTRECORDER_INCLUDES)
+ MOC_FLAGS = -DENABLE_TESTRECORDER
endif
libSUITApp_la_LDFLAGS = $(QT_MT_LIBS)
-I$(srcdir)/../SUIT -I$(srcdir)/../Qtx -I$(srcdir)/../Style
if ENABLE_TESTRECORDER
- SUITApp_CPPFLAGS+= $(TESTRECORDER_INCLUDES)
-else !ENABLE_TESTRECORDER
- SUITApp_CPPFLAGS+= -DDISABLE_TESTRECORDER
+ SUITApp_CPPFLAGS+= -DENABLE_TESTRECORDER $(TESTRECORDER_INCLUDES)
endif
SUITApp_LDADD = libSUITApp.la ../Qtx/libqtx.la ../SUIT/libsuit.la ../Style/libSalomeStyle.la
#include <SUIT_Desktop.h>
#include <SUIT_ResourceMgr.h>
#include <Style_Salome.h>
-#include <Style_Model.h>
#include <QtxSplash.h>
#include <SUIT_LicenseDlg.h>
SUIT_Application* theApp = aSession->startApplication( argList.first() );
if ( theApp )
{
- if ( resMgr && resMgr->booleanValue( "Style", "use_salome_style", true ) )
- {
- Style_Salome* aStyle = new Style_Salome();
- aStyle->getModel()->initFromResource( theApp->resourceMgr() );
- app.setStyle( aStyle );
- }
-
+ Style_Salome::initialize( theApp->resourceMgr() );
+ if ( theApp->resourceMgr()->booleanValue( "Style", "use_salome_style", true ) )
+ Style_Salome::apply();
+
if ( !noExceptHandling )
app.setHandler( aSession->handler() );
splash->finish( theApp->desktop() );
result = app.exec();
- delete splash;
}
delete aSession;
}
Constructor
*/
SUITApp_Application::SUITApp_Application( int& argc, char** argv, SUIT_ExceptionHandler* hand )
-#ifndef DISABLE_TESTRECORDER
+#ifdef ENABLE_TESTRECORDER
: TestApplication( argc, argv ),
#else
: QApplication( argc, argv ),
Constructor
*/
SUITApp_Application::SUITApp_Application( int& argc, char** argv, Type type, SUIT_ExceptionHandler* hand )
-#ifndef DISABLE_TESTRECORDER
+#ifdef ENABLE_TESTRECORDER
: TestApplication( argc, argv ),
#else
: QApplication( argc, argv, type ),
bool SUITApp_Application::notify( QObject* receiver, QEvent* e )
{
return myExceptHandler ? myExceptHandler->handle( receiver, e ) :
-#ifndef DISABLE_TESTRECORDER
+#ifdef ENABLE_TESTRECORDER
TestApplication::notify( receiver, e );
#else
QApplication::notify( receiver, e );
#ifndef SUITAPP_APPLICATION_H
#define SUITAPP_APPLICATION_H
-#ifndef DISABLE_TESTRECORDER
+#ifdef ENABLE_TESTRECORDER
#include <TestApplication.h>
#else
#include <QApplication>
class SUIT_ExceptionHandler;
-#ifndef DISABLE_TESTRECORDER
+#ifdef ENABLE_TESTRECORDER
class SUITApp_Application : public TestApplication
#else
class SUITApp_Application : public QApplication
Functions of loading OpenGL extensions.
*/
-#include <SVTK.h>
+#include "SVTK.h"
namespace SVTK
{
#ifndef SVTK_Prs_H
#define SVTK_Prs_H
-#include <SVTK.h>
+#include "SVTK.h"
#include "SALOME_Prs.h"
class vtkActorCollection;
{
myTransform->SetMatrixScale( theScale[0], theScale[1], theScale[2] );
AdjustActors();
+
+ vtkActorCollection* anActors = GetDevice()->GetActors();
+ anActors->InitTraversal();
+ while(vtkActor* anAct = anActors->GetNextActor())
+ if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(anAct))
+ if(anActor->isHighlighted() && !anActor->IsInfinitive())
+ anActor->highlight(true);
}
/*!
#include "SUIT_ViewModel.h"
#include "SUIT_ViewManager.h"
-#include <SALOME_Actor.h>
+#include "SALOME_Actor.h"
#include <QtxActionToolMgr.h>
connect( ob, SIGNAL( doubleClicked( SUIT_DataObject* ) ), this, SLOT( onDblClick( SUIT_DataObject* ) ) );
+ QString
+ ValueCol = QObject::tr( "VALUE_COLUMN" ),
+ IORCol = QObject::tr( "IOR_COLUMN" ),
+ RefCol = QObject::tr( "REFENTRY_COLUMN" ),
+ EntryCol = QObject::tr( "ENTRY_COLUMN" );
+
+ SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
+ treeModel->registerColumn( 0, EntryCol, SalomeApp_DataObject::EntryId );
+ treeModel->registerColumn( 0, ValueCol, SalomeApp_DataObject::ValueId );
+ treeModel->registerColumn( 0, IORCol, SalomeApp_DataObject::IORId );
+ treeModel->registerColumn( 0, RefCol, SalomeApp_DataObject::RefEntryId );
+ treeModel->setAppropriate( EntryCol, Qtx::Toggled );
+ treeModel->setAppropriate( ValueCol, Qtx::Toggled );
+ treeModel->setAppropriate( IORCol, Qtx::Toggled );
+ treeModel->setAppropriate( RefCol, Qtx::Toggled );
+
bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", true );
int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
int defCols = pref->addPreference( tr( "PREF_GROUP_DEF_COLUMNS" ), obTab );
- for ( int i = SalomeApp_DataObject::EntryIdx; i <= SalomeApp_DataObject::RefEntryIdx; i++ )
+ for ( int i = SalomeApp_DataObject::EntryId; i <= SalomeApp_DataObject::RefEntryId; i++ )
{
pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i-1 ).toLatin1() ), defCols,
- LightApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i-1 ) );
+ LightApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_id_%d", i ) );
}
pref->setItemProperty( "orientation", Qt::Vertical, defCols );
void SalomeApp_Application::objectBrowserColumnsVisibility()
{
if ( objectBrowser() )
- for ( int i = SalomeApp_DataObject::EntryIdx; i <= SalomeApp_DataObject::RefEntryIdx; i++ )
- objectBrowser()->treeView()->setColumnHidden( i,
- !(resourceMgr()->booleanValue( "ObjectBrowser",
- QString().sprintf( "visibility_column_%d", i-1 ),
- true )) );
+ for ( int i = SalomeApp_DataObject::EntryId; i <= SalomeApp_DataObject::RefEntryId; i++ )
+ {
+ bool shown = resourceMgr()->booleanValue( "ObjectBrowser", QString( "visibility_column_id_%1" ).arg( i ), true );
+ objectBrowser()->treeView()->setColumnHidden( i, !shown );
+ }
}
virtual bool isPossibleToClose( bool& );
virtual bool useStudy( const QString& );
+ virtual void updateDesktopTitle();
public slots:
virtual void onLoadDoc();
virtual void onSelectionChanged();
virtual void createPreferences( LightApp_Preferences* );
- virtual void updateDesktopTitle();
virtual bool closeAction( const int, bool& );
virtual int closeChoice( const QString& );
#ifndef SALOMEAPP_CHECKFILEDIALOG_H
#define SALOMEAPP_CHECKFILEDIALOG_H
-#include <SalomeApp.h>
+#include "SalomeApp.h"
#include <SUIT_FileDlg.h>
{
}
-/*!
- \brief Get the number of the columns provided by the data tree.
- \return number of the columns
-*/
-int SalomeApp_DataObject::columnCount() const
-{
- // add "Value", "IOR", and "Reference Entry" columns
- return LightApp_DataObject::columnCount() + 3;
-}
-
-/*!
- \brief Get column title.
- \param index column index
- \return title of the specified column
-*/
-QString SalomeApp_DataObject::columnTitle( const int index ) const
-{
- // add "Value", "IOR", and "Reference Entry" columns
- switch ( index ) {
- case ValueIdx:
- return QObject::tr( "VALUE_COLUMN" ) ;
- case IORIdx:
- return QObject::tr( "IOR_COLUMN" ) ;
- case RefEntryIdx:
- return QObject::tr( "REFENTRY_COLUMN" ) ;
- default:
- break;
- }
- return LightApp_DataObject::columnTitle( index );
-}
-
-/*!
- \brief Check if the column should appear in the tree view header popup menu
- (to show/hide the column).
- \param index column index
- \return \c true if the column can be shown/hidden
-*/
-bool SalomeApp_DataObject::appropriate( const int index ) const
-{
- // add "Value", "IOR", and "Reference Entry" columns
- return index > EntryIdx && index <= RefEntryIdx ? true :
- LightApp_DataObject::appropriate( index );
-}
-
/*!
\brief Get data object name.
\return object name
/*!
\brief Get object text data for the specified column.
- This method returns the data according to the specufied column \a index:
- - NameIdx : object name (by calling name() method)
- - EntryIdx : object entry (by calling entry() method)
- - ValueIdx : object value
- - IORIdx : object IOR
- - RefEntryIdx : object reference entry
+ This method returns the data according to the specufied column \a id:
+ - NameId : object name (by calling name() method)
+ - EntryId : object entry (by calling entry() method)
+ - ValueId : object value
+ - IORId : object IOR
+ - RefEntryId : object reference entry
- \param index column index
+ \param id column id
\return object text data
*/
-QString SalomeApp_DataObject::text( const int index ) const
+QString SalomeApp_DataObject::text( const int id ) const
{
QString txt;
// add "Value", "IOR", and "Reference Entry" columns
- switch ( index )
+ switch ( id )
{
- case ValueIdx:
+ case ValueId:
#ifndef WIN32
if ( componentObject() != this )
#else
if ( txt.isEmpty() )
txt = value( referencedObject() );
break;
- case IORIdx:
+ case IORId:
txt = ior( referencedObject() );
break;
- case RefEntryIdx:
+ case RefEntryId :
if ( isReference() )
txt = entry( referencedObject() );
break;
default:
- txt = LightApp_DataObject::text( index );
+ txt = LightApp_DataObject::text( id );
break;
}
return txt;
/*!
\brief Get data object icon for the specified column.
- \param index column index
+ \param id column id
\return object icon for the specified column
*/
-QPixmap SalomeApp_DataObject::icon( const int index ) const
+QPixmap SalomeApp_DataObject::icon( const int id ) const
{
- // we display icon only for the first (NameIdx) column
- if ( index == NameIdx ) {
+ // we display icon only for the first (NameId ) column
+ if ( id == NameId ) {
_PTR(GenericAttribute) anAttr;
if ( myObject && myObject->FindAttribute( anAttr, "AttributePixMap" ) ){
_PTR(AttributePixMap) aPixAttr ( anAttr );
}
}
}
- return LightApp_DataObject::icon( index );
+ return LightApp_DataObject::icon( id );
}
/*!
\brief Get data object color for the specified column.
\param role color role
- \param index column index (not used)
+ \param id column id (not used)
\return object color for the specified column
*/
-QColor SalomeApp_DataObject::color( const ColorRole role, const int index ) const
+QColor SalomeApp_DataObject::color( const ColorRole role, const int id ) const
{
- // we ignore parameter <index> in order to use the same colors for
+ // we ignore parameter <id> in order to use the same colors for
// all columns
QColor c;
switch ( role )
break;
}
if ( !c.isValid() )
- c = LightApp_DataObject::color( role, index );
+ c = LightApp_DataObject::color( role, id );
return c;
}
/*!
\brief Get data object tooltip for the specified column.
- \param index column index (not used)
+ \param id column id (not used)
\return object tooltip for the specified column
*/
-QString SalomeApp_DataObject::toolTip( const int /*index*/ ) const
+QString SalomeApp_DataObject::toolTip( const int /*id*/ ) const
{
- // we ignore parameter <index> in order to use the same tooltip for
+ // we ignore parameter <id> in order to use the same tooltip for
// all columns
return QString( "Object \'%1\', module \'%2\', ID=%3" ).arg( name() ).arg( componentDataType() ).arg( entry() );
}
/*!
\brief Check if the specified column supports custom sorting.
- \param index column index
+ \param id column id
\return \c true if column sorting should be customized
\sa compare()
*/
-bool SalomeApp_DataObject::customSorting( const int index ) const
+bool SalomeApp_DataObject::customSorting( const int id ) const
{
// perform custom sorting for the "Entry" and "Reference Entry" columns
- return index == EntryIdx || index == RefEntryIdx ? true
- : LightApp_DataObject::customSorting( index );
+ return id == EntryId || id == RefEntryId ? true
+ : LightApp_DataObject::customSorting( id );
}
/*!
\param left first data to compare
\param right second data to compare
- \param index column index
+ \param id column id
\return result of the comparison
\sa customSorting()
*/
-bool SalomeApp_DataObject::compare( const QVariant& left, const QVariant& right,
- const int index ) const
+bool SalomeApp_DataObject::compare( const QVariant& left, const QVariant& right, const int id ) const
{
// use the same custom sorting for the "Reference Entry" column as for the
// "Entry" column (call base implementation)
- return LightApp_DataObject::compare( left, right, index == RefEntryIdx ? EntryIdx : index );
+ return LightApp_DataObject::compare( left, right, id == RefEntryId ? EntryId : id );
}
/*!
/*!
\brief Get data object icon for the specified column.
- \param index column index
+ \param id column id
\return object icon for the specified column
*/
-QPixmap SalomeApp_ModuleObject::icon( const int index ) const
+QPixmap SalomeApp_ModuleObject::icon( const int id ) const
{
- return SalomeApp_DataObject::icon( index );
+ return SalomeApp_DataObject::icon( id );
}
/*!
\brief Get data object tooltip for the specified column.
- \param index column index
+ \param id column id
\return object tooltip for the specified column
*/
-QString SalomeApp_ModuleObject::toolTip( const int index ) const
+QString SalomeApp_ModuleObject::toolTip( const int id ) const
{
- return SalomeApp_DataObject::toolTip( index );
+ return SalomeApp_DataObject::toolTip( id );
}
/*!
/*!
\brief Get object text data for the specified column.
- \param index column index
+ \param id column id
\return object text data
*/
-QString SalomeApp_RootObject::text( const int index ) const
+QString SalomeApp_RootObject::text( const int id ) const
{
- return LightApp_RootObject::text( index );
+ return LightApp_RootObject::text( id );
}
/*!
\brief Get data object icon for the specified column.
- \param index column index
+ \param id column id
\return object icon for the specified column
*/
-QPixmap SalomeApp_RootObject::icon( const int index ) const
+QPixmap SalomeApp_RootObject::icon( const int id ) const
{
- return LightApp_RootObject::icon( index );
+ return LightApp_RootObject::icon( id );
}
/*!
\brief Get data object color for the specified column.
\param role color role
- \param index column index (not used)
+ \param id column id (not used)
\return object color for the specified column
*/
-QColor SalomeApp_RootObject::color( const ColorRole role, const int index ) const
+QColor SalomeApp_RootObject::color( const ColorRole role, const int id ) const
{
- return LightApp_RootObject::color( role, index );
+ return LightApp_RootObject::color( role, id );
}
/*!
\brief Get data object tooltip for the specified column.
- \param index column index (not used)
+ \param id column id (not used)
\return object tooltip for the specified column
*/
-QString SalomeApp_RootObject::toolTip( const int index ) const
+QString SalomeApp_RootObject::toolTip( const int id ) const
{
- return LightApp_RootObject::toolTip( index );
+ return LightApp_RootObject::toolTip( id );
}
/*!
/*!
\brief Get data object icon for the specified column.
- \param index column index
+ \param id column id
\return object icon for the specified column
*/
-QPixmap SalomeApp_SavePointObject::icon( const int /*index*/ ) const
+QPixmap SalomeApp_SavePointObject::icon( const int /*id*/ ) const
{
return QPixmap();
}
/*!
\brief Get data object tooltip for the specified column.
- \param index column index (not used)
+ \param id column id (not used)
\return object tooltip for the specified column
*/
-QString SalomeApp_SavePointObject::toolTip( const int /*index*/ ) const
+QString SalomeApp_SavePointObject::toolTip( const int /*id*/ ) const
{
return QObject::tr( "SAVE_POINT_OBJECT_TOOLTIP" ).arg( name() );
}
/*!
\brief Get data object tooltip for the specified column.
- \param index column index (not used)
+ \param id column id (not used)
\return object tooltip for the specified column
*/
-QString SalomeApp_SavePointRootObject::toolTip( const int /*index*/ ) const
+QString SalomeApp_SavePointRootObject::toolTip( const int /*id*/ ) const
{
return QObject::tr( "SAVE_POINT_ROOT_TOOLTIP" );
}
{
public:
- //! Column index
+ //! Column id
enum {
- ValueIdx = EntryIdx + 1, //!< value column
- IORIdx, //!< IOR column
- RefEntryIdx //!< reference entry column
+ ValueId = EntryId + 1, //!< value column
+ IORId, //!< IOR column
+ RefEntryId //!< reference entry column
};
public:
SalomeApp_DataObject( const _PTR(SObject)&, SUIT_DataObject* = 0 );
virtual ~SalomeApp_DataObject();
- virtual int columnCount() const;
- virtual QString columnTitle( const int = NameIdx ) const;
- virtual bool appropriate( const int = NameIdx ) const;
-
virtual QString name() const;
virtual QString entry() const;
- virtual QString text( const int = NameIdx ) const;
- virtual QPixmap icon( const int = NameIdx ) const;
- virtual QColor color( const ColorRole, const int = NameIdx ) const;
- virtual QString toolTip( const int = NameIdx ) const;
+ virtual QString text( const int = NameId ) const;
+ virtual QPixmap icon( const int = NameId ) const;
+ virtual QColor color( const ColorRole, const int = NameId ) const;
+ virtual QString toolTip( const int = NameId ) const;
virtual _PTR(SObject) object() const;
virtual QString componentDataType() const;
- virtual bool customSorting( const int = NameIdx ) const;
- virtual bool compare( const QVariant&, const QVariant&,
- const int = NameIdx ) const;
+ virtual bool customSorting( const int = NameId ) const;
+ virtual bool compare( const QVariant&, const QVariant&, const int = NameId ) const;
+
private:
QString ior( const _PTR(SObject)& ) const;
QString entry( const _PTR(SObject)& ) const;
virtual ~SalomeApp_ModuleObject();
virtual QString name() const;
- QPixmap icon( const int = NameIdx ) const;
- QString toolTip( const int = NameIdx ) const;
+ QPixmap icon( const int = NameId ) const;
+ QString toolTip( const int = NameId ) const;
};
class SALOMEAPP_EXPORT SalomeApp_RootObject : public SalomeApp_DataObject,
QString name() const;
QString entry() const;
- QString text( const int = NameIdx ) const;
- QPixmap icon( const int = NameIdx ) const;
- QColor color( const ColorRole, const int = NameIdx ) const;
- QString toolTip( const int = NameIdx ) const;
+ QString text( const int = NameId ) const;
+ QPixmap icon( const int = NameId ) const;
+ QColor color( const ColorRole, const int = NameId ) const;
+ QString toolTip( const int = NameId ) const;
};
class SALOMEAPP_EXPORT SalomeApp_SavePointObject : public virtual LightApp_DataObject
virtual QString name() const;
virtual QString entry() const;
- virtual QPixmap icon( const int = NameIdx ) const;
- virtual QString toolTip( const int = NameIdx ) const;
+ virtual QPixmap icon( const int = NameId ) const;
+ virtual QString toolTip( const int = NameId ) const;
int getId() const;
SalomeApp_SavePointRootObject( SUIT_DataObject* );
virtual QString name() const;
- virtual QString toolTip( const int = NameIdx ) const;
+ virtual QString toolTip( const int = NameId ) const;
};
#endif
<parameter name="auto_size" value="false" />
<parameter name="auto_size_first" value="true" />
<parameter name="resize_on_expand_item" value="false" />
- <parameter name="visibility_column_0" value="false" />
- <parameter name="visibility_column_1" value="true" />
- <parameter name="visibility_column_2" value="false" />
- <parameter name="visibility_column_3" value="false" />
+ <parameter name="visibility_column_id_1" value="true" />
+ <parameter name="visibility_column_id_2" value="true" />
+ <parameter name="visibility_column_id_3" value="true" />
+ <parameter name="visibility_column_id_4" value="true" />
</section>
<section name="PyConsole">
<!-- Python console preferences -->
-I$(srcdir)/../Style @LIBXML_INCLUDES@
if ENABLE_TESTRECORDER
- libSalomeSession_la_CPPFLAGS+= $(TESTRECORDER_INCLUDES)
-else !ENABLE_TESTRECORDER
- libSalomeSession_la_CPPFLAGS+= -DDISABLE_TESTRECORDER
+ libSalomeSession_la_CPPFLAGS+= -DENABLE_TESTRECORDER $(TESTRECORDER_INCLUDES)
endif
libSalomeSession_la_LDFLAGS = $(QT_MT_LIBS) $(KERNEL_LDFLAGS) -lSalomeNS \
#include <ConnectionManager_i.hxx>
#include <SALOME_LifeCycleCORBA.hxx>
-#ifndef DISABLE_TESTRECORDER
+#ifdef ENABLE_TESTRECORDER
#include <TestApplication.h>
#endif
#include <QtxSplash.h>
#include <Style_Salome.h>
-#include <Style_Model.h>
#include <SUIT_Tools.h>
#include <SUIT_Session.h>
#include <SUIT_Application.h>
}
};
-#ifndef DISABLE_TESTRECORDER
+#ifdef ENABLE_TESTRECORDER
class SALOME_QApplication : public TestApplication
#else
class SALOME_QApplication : public QApplication
#endif
{
public:
-#ifndef DISABLE_TESTRECORDER
+#ifdef ENABLE_TESTRECORDER
SALOME_QApplication( int& argc, char** argv ) : TestApplication( argc, argv ), myHandler ( 0 ) {}
#else
SALOME_QApplication( int& argc, char** argv ) : QApplication( argc, argv ), myHandler ( 0 ) {}
}
#endif
-#ifndef DISABLE_TESTRECORDER
+#ifdef ENABLE_TESTRECORDER
return myHandler ? myHandler->handle( receiver, e ) :
TestApplication::notify( receiver, e );
#else
// ...create resource manager
SUIT_ResourceMgr resMgr( "SalomeApp", QString( "%1Config" ) );
resMgr.setCurrentFormat( "xml" );
- resMgr.loadLanguage( false, "LightApp", "en" );
+ resMgr.setWorkingMode( QtxResourceMgr::IgnoreUserValues );
+ resMgr.loadLanguage( "LightApp", "en" );
//
splash = QtxSplash::splash( QPixmap() );
splash->readSettings( &resMgr );
SUIT_Application* aGUIApp = aGUISession->startApplication( "SalomeApp", 0, 0 );
if ( aGUIApp )
{
- // Set SALOME style to the application
- SUIT_ResourceMgr resMgr( "SalomeApp", QString( "%1Config" ) );
- resMgr.setCurrentFormat( "xml" );
- resMgr.loadLanguage( false, "LightApp", "en" );
- if ( bool isSSUse = resMgr.booleanValue( "Style", "use_salome_style", true ) )
- {
- Style_Salome* aStyle = new Style_Salome();
- aStyle->getModel()->initFromResource( aGUIApp->resourceMgr() );
- _qappl.setStyle( aStyle );
- }
+ Style_Salome::initialize( aGUIApp->resourceMgr() );
+ if ( aGUIApp->resourceMgr()->booleanValue( "Style", "use_salome_style", true ) )
+ Style_Salome::apply();
if ( !isFound( "noexcepthandler", argc, argv ) )
_qappl.setHandler( aGUISession->handler() ); // after loading SalomeApp application
#ifndef _SALOMEAPP_ENGINE_I_HXX_
#define _SALOMEAPP_ENGINE_I_HXX_
-#include <SALOME_Session.hxx>
+#include "SALOME_Session.hxx"
#include "SALOME_Component_i.hxx"
#ifndef _SESSION_SERVERLAUNCHER_HXX_
#define _SESSION_SERVERLAUNCHER_HXX_
-#include <SALOME_Session.hxx>
+#include "SALOME_Session.hxx"
#include <CORBA.h>
#include <list>
#ifndef _SESSION_SERVERTHREAD_HXX_
#define _SESSION_SERVERTHREAD_HXX_
-#include <SALOME_Session.hxx>
+#include "SALOME_Session.hxx"
#include <CORBA.h>
#include <string>
#ifndef _SESSION_SESSION_I_HXX_
#define _SESSION_SESSION_I_HXX_
-#include <SALOME_Session.hxx>
+#include "SALOME_Session.hxx"
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOME_Component)
# Libraries targets
lib_LTLIBRARIES = libSalomeStyle.la
-salomeinclude_HEADERS = \
- Style.h \
- Style_Tools.h \
- Style_Model.h \
+salomeinclude_HEADERS = \
+ Style.h \
+ Style_PrefDlg.h \
Style_Salome.h
-dist_libSalomeStyle_la_SOURCES = \
- Style_Tools.cxx \
- Style_Model.cxx \
- Style_Salome.cxx
+dist_libSalomeStyle_la_SOURCES =\
+ Style.h \
+ Style_Model.h \
+ Style_PrefDlg.h \
+ Style_Salome.h \
+ Style_Tools.h \
+ Style_ResourceMgr.h \
+ Style_Model.cxx \
+ Style_PrefDlg.cxx \
+ Style_ResourceMgr.cxx \
+ Style_Salome.cxx \
+ Style_Tools.cxx
MOC_FILES = \
+ Style_PrefDlg_moc.cxx \
Style_Salome_moc.cxx
QRC_FILES = \
libSalomeStyle_la_LDFLAGS = $(QT_MT_LIBS) \
../Qtx/libqtx.la
+
+dist_salomeres_DATA = resources/SalomeStyle.xml
// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : Style_Model.cxx
-// Author : Natalia Ermolaeva, Open CASCADE S.A.S.
+// Author : Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com)
//
#include "Style_Model.h"
+
#include <QtxResourceMgr.h>
-#include <QColor>
#include <QApplication>
-#include <QPalette>
+#include <QColor>
#include <QFont>
+#include <QPalette>
-Style_Model::Style_Model()
+/*!
+ \brief Mix two colors to get color with averaged red, green, blue and alpha-channel values
+ \internal
+ \param c1 first color
+ \param c2 second color
+ \return averaged color
+*/
+static QColor mixColors( const QColor& c1, const QColor& c2 )
{
- // grp_style group
- fillValue( defined_style, "defined-style", "Style:", grp_style, Selector );
- myPStyles<<"Default"<<"Steel-blue"<<"Dark-green";
- // grp_colors group
- fillValue( bg_clr, "bg-color", "Window", grp_color );
- fillValue( pal_base_clr, "base-color", "Base", grp_color );
- fillValue( header_clr, "header-color", "Header", grp_color );
-
- fillValue( pal_text_clr, "text-color", "Text", grp_color );
- fillValue( pal_btext_clr, "text-button-color", "Text button", grp_color );
- fillValue( pal_wtext_clr, "text-window-color", "Text window", grp_color );
-
- fillValue( slider_clr, "slider-color", "Slider", grp_color );
- fillValue( button_clr, "button-color", "Button", grp_color );
- fillValue( prbar_clr, "progress-bar-color", "Progress bar", grp_color );
-
- fillValue( checked_clr, "checked-color", "Checked", grp_color );
- fillValue( pointer_clr, "pointer-color", "Pointer", grp_color );
- fillValue( tbl_grline_clr, "table-grid-color", "Table grid", grp_color );
-
- fillValue( ttip_is_change, "ttip-is-change", "Change ToolTip", grp_color, Bool );
- fillValue( ttip_bg_clr, "ttip-bg-color", "Background", grp_color );
- fillValue( ttip_text_clr, "ttip-text-color", "Text color", grp_color );
-
- fillValue( highlight_wdg, "is-highlight-widget", "Highlight widget", grp_color, Bool );
- fillValue( high_wdg_clr, "highlight-widget-color", "Widget center", grp_color );
- fillValue( high_brd_wdg_clr, "highligh-brd-widget-color", "Widget border", grp_color );
-
- fillValue( auto_raising_wdg, "is-raising-widget", "Auto raising widget", grp_color, Bool );
- fillValue( pal_high_clr, "highlight-color", "Highlight", grp_color );
- fillValue( pal_high_text_clr, "highlight-text-color", "Highlight text", grp_color );
- // grp_col_values group
- fillValue( fld_light_clr, "fld-light-color", "Field light", grp_col_values );
- fillValue( fld_dark_clr, "fld-dark-color", "Field dark", grp_col_values );
- fillValue( pal_light_clr, "light-color", "Light", grp_col_values );
- fillValue( pal_dark_clr, "dark-color", "Dark", grp_col_values );
-
- fillValue( border_top_clr, "brd-top-color", "Border top", grp_col_values );
- fillValue( border_bot_clr, "brd-bottom-color", "Border bottom", grp_col_values );
- fillValue( border_tab_top_clr, "brd-tab-top-color", "Border widget top", grp_col_values );
- fillValue( border_tab_bot_clr, "brd-tab-bottom-color", "Border widget bottom", grp_col_values );
-
- // lines group
- fillValue( is_lines, "is-lines", "Draw lines", grp_lines, Bool );
- fillValue( lines_type, "lines-type", "Type", grp_lines, Selector );
- myLines<<"Horizontal"<<"Incline";
- fillValue( lines_clr, "lines-color", "Color", grp_lines, Color );
- fillValue( lines_transp, "lines-transp", "Transparency", grp_lines, DblSpin );
-
- // grp_font group
- fillValue( font_value, "app-font", "Font", grp_font, Font );
- // grp_values group
- fillValue( edit_rad, "edit-rad", "Rounding of edit", grp_value, DblSpin );
- fillValue( btn_rad, "button-rad", "Rounding of button", grp_value, DblSpin );
- fillValue( frame_rad, "frame-rad", "Rounding of frame", grp_value, DblSpin );
- fillValue( slider_rad, "slider-rad", "Rounding of slider", grp_value, DblSpin );
- fillValue( hor_handle_delta, "hor-hadle-delta", "Hor spacinig of handle ", grp_value, DblSpin );
- fillValue( ver_handle_delta, "ver-handle-delta", "Ver spacing of handle", grp_value, DblSpin );
- fillValue( split_handle_len, "split-handle-len", "Length of splitter handle", grp_value, DblSpin );
- fillValue( slider_increase, "slider-increase", "Slider increase", grp_value, IntSpin );
- fillValue( all_antialized, "all-antialized", "All borders antialized", grp_value, Bool );
-
- fillGroup( grp_style, tab_value, "Predefined style", 1 );
- fillGroup( grp_color, tab_color, "Colors", 3 );
- fillGroup( grp_col_values, tab_color, "ColorValues", 2 );
- fillGroup( grp_lines, tab_value, "Lines", 2 );
- fillGroup( grp_font, tab_value, "Font", 1 );
- fillGroup( grp_value, tab_value, "Values", 2 );
-
- myTabs[tab_color] = QString( "Colors" );
- myTabs[tab_value] = QString( "Values" );
+ return QColor( (c1.red() + c2.red() ) / 2,
+ (c1.green() + c2.green() ) / 2,
+ (c1.blue() + c2.blue() ) / 2,
+ (c1.alpha() + c2.alpha() ) / 2 );
}
-Style_Model::~Style_Model()
+/*!
+ \class Style_Model
+ \brief SALOME style model
+
+ 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.
+
+ \sa Style_Salome class
+*/
+
+/*!
+ \brief Application style data
+ \internal
+*/
+Style_Model::AppData* Style_Model::myAppData = 0;
+
+/*!
+ \brief Constructor
+
+ Create new SALOME style model with default properties.
+*/
+Style_Model::Style_Model()
+ : myResourceMgr( 0 )
{
+ initDefaults(); // init from default values
}
-QString Style_Model::sectionName()
+/*!
+ \brief Destructor
+*/
+Style_Model::~Style_Model()
{
- return "Theme";
}
-void Style_Model::reset()
+/*!
+ \brief Initialize model from the current application style
+
+ 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()
+
+ \param reset if \c true model is first restores default values of all properties
+ \sa restore(), fromResources()
+ \sa Style_Salome class
+*/
+void Style_Model::fromApplication( bool reset )
{
- ValuesMap::iterator anIt = myValues.begin(), anEnd = myValues.end();
- int anId;
- for ( ; anIt != anEnd; ++anIt ) {
- anId = anIt.key();
- myValues[anId].myValue = myValues[anId].myDefValue;
+ if ( reset ) initDefaults();
+
+ if ( !QApplication::instance() ) // application object is not created yet
+ return;
+
+ if ( !myAppData ) {
+ // if not yes initialized from the application,
+ // store current application's style, palette, etc
+ myAppData = new AppData;
+ myAppData->myStyle = QApplication::style();
+ myAppData->myPalette = QApplication::palette();
+ myAppData->myFont = QApplication::font();
}
-}
-void Style_Model::setDefaults( QApplication* app )
-{
- setDefValue( defined_style, QVariant( 0 ) );
-
- QPalette aPal = app->palette();
- setDefValue( bg_clr, QVariant( aPal.color( QPalette::Window ) ) );
- setDefValue( pal_base_clr, aPal.color ( QPalette::Base ) );
- setDefValue( header_clr, QVariant( aPal.color( QPalette::Button ) ) );
- setDefValue( pal_text_clr, aPal.color( QPalette::Text ) );
- setDefValue( pal_btext_clr, aPal.color( QPalette::ButtonText ) );
- setDefValue( pal_wtext_clr, aPal.color( QPalette::WindowText ) );
-
- setDefValue( slider_clr, QVariant( aPal.color( QPalette::Button ) ) );
- setDefValue( button_clr, QVariant( aPal.color( QPalette::Button ) ) );
- setDefValue( prbar_clr, QVariant( aPal.color( QPalette::Highlight ) ) );
-
- setDefValue( checked_clr, QVariant( aPal.color( QPalette::Base ) ) );
- setDefValue( pointer_clr, QVariant( QColor( Qt::black ) ) );
- setDefValue( tbl_grline_clr, QVariant( aPal.color( QPalette::Mid ) ) );
-
- setDefValue( ttip_is_change, QVariant( false ) );
- setDefValue( ttip_bg_clr, myValues[bg_clr].myValue );
- setDefValue( ttip_text_clr, myValues[pal_text_clr].myValue );
-
- setDefValue( highlight_wdg, QVariant( false ) );
- setDefValue( high_wdg_clr, myValues[button_clr].myValue );
- setDefValue( high_brd_wdg_clr, myValues[high_wdg_clr].myValue );
-
- setDefValue( pal_high_clr, aPal.color( QPalette::Highlight ) );
- setDefValue( pal_high_text_clr, aPal.color( QPalette::HighlightedText ) );
-
- setDefValue( fld_light_clr, QVariant( aPal.color( QPalette::Light ) ) );
- setDefValue( fld_dark_clr, QVariant( aPal.color( QPalette::Mid ).light( 125 ) ) );
- setDefValue( pal_light_clr, aPal.color( QPalette::Light ) );
- setDefValue( pal_dark_clr, aPal.color( QPalette::Dark ) );
-
- QColor aDark = aPal.color( QPalette::Dark );
- setDefValue( border_top_clr, QVariant( aDark.light() ) );
- setDefValue( border_bot_clr, QVariant( aDark.dark() ) );
- setDefValue( border_tab_top_clr, QVariant( aDark.light().light().light() ) );
- setDefValue( border_tab_bot_clr, QVariant( aDark.dark().dark() ) );
-
- setDefValue( is_lines, QVariant( false ) );
- setDefValue( lines_type, QVariant( 0 ) );
- setDefValue( lines_clr, QVariant( aPal.color( QPalette::Mid ) ) );
-
- // not color settings
- QFont aFont = app->font();
- setDefValue( font_value, QVariant( aFont ) );
-
- setDefValue( slider_rad, QVariant( 0 ) );
- setDefValue( edit_rad, QVariant( 0 ) );
- setDefValue( btn_rad, QVariant( 0 ) );
- setDefValue( frame_rad, QVariant( 0 ) );
- setDefValue( slider_increase,QVariant( 2 ) );
- setDefValue( all_antialized, QVariant( false ) );
- setDefValue( highlight_wdg, QVariant( false ) );
- setDefValue( auto_raising_wdg, QVariant( false ) );
- setDefValue( hor_handle_delta, QVariant( 3 ) );
- setDefValue( ver_handle_delta, QVariant( 3 ) );
- setDefValue( split_handle_len, QVariant( 20 ) );
-}
-
-void Style_Model::initFromResource( QtxResourceMgr* theResMgr )
-{
- ValuesMap::iterator anIt = myValues.begin(), anEnd = myValues.end();
- for ( ; anIt != anEnd; ++anIt )
- setValueFrom( theResMgr, anIt.key() );
-}
-
-bool Style_Model::updateFromResource( QtxResourceMgr* theResMgr, const QString& thePropName )
-{
- bool retrieve = false;
- if ( !theResMgr )
- return retrieve;
- ValuesMap::iterator anIt = myValues.begin(), anEnd = myValues.end();
- int anId = -1;
- for ( ; anIt != anEnd && anId == -1; ++anIt )
- if ( anIt.value().myName == thePropName )
- anId = anIt.key();
- if ( anId == -1 )
- return retrieve;
- setValueFrom( theResMgr, anId );
-
- if ( anId == defined_style ) {
- setPredefinedStyle( getIntValue( defined_style ) );
- retrieve = true;
- // update for resources all datas
- for ( anIt = myValues.begin(); anIt != anEnd; ++anIt ) {
- if ( anIt.key() != anId )
- getValueTo( theResMgr, anIt.key(), false );
+ // initialize style properties from the application
+
+ // font
+ myFont = myAppData->myFont;
+ // colors
+ for ( int i = (int)QPalette::Active; i <= (int)QPalette::Inactive; i++ ) {
+ for ( int j = (int)Style_Model::WindowText; j < (int)Style_Model::NColorRoles; j++ ) {
+ myColors[ (QPalette::ColorGroup)i ][ (Style_Model::ColorRole)j ] =
+ myAppData->myPalette.color( (QPalette::ColorGroup)i, (QPalette::ColorRole)j );
}
}
- return retrieve;
+
+ QColor dark = myAppData->myPalette.color( QPalette::Dark );
+ setColor( BorderTop, dark.lighter() );
+ setColor( BorderBottom, dark.darker() );
+ setColor( TabBorderTop, dark.lighter().lighter() );
+ setColor( TabBorderBottom, dark.darker().darker() );
+ setColor( FieldLight, myAppData->myPalette.color( QPalette::Light ) );
+ setColor( FieldDark, myAppData->myPalette.color( QPalette::Mid ).light( 125 ) );
+ setColor( ProgressBar, myAppData->myPalette.color( QPalette::Highlight ) );
+ setColor( Pointer, myAppData->myPalette.color( QPalette::WindowText ) );
+ setColor( Checked, myAppData->myPalette.color( QPalette::Base ) );
+ setColor( GridLine, myAppData->myPalette.color( QPalette::Mid ) );
+ setColor( Header, myAppData->myPalette.color( QPalette::Button ) );
+ setColor( Slider, myAppData->myPalette.color( QPalette::Button ) );
+ setColor( HighlightWidget, myAppData->myPalette.color( QPalette::Button ) );
+ setColor( HighlightBorder, myAppData->myPalette.color( QPalette::Button ) );
+ setColor( Lines, myAppData->myPalette.color( QPalette::Mid ) );
}
-void Style_Model::getValueTo( QtxResourceMgr* theResMgr, int theId, bool theIsDef )
+/*!
+ \brief Initialize model from the resources
+
+ This function can be used to retrieve SALOME style properties from the resource file(s).
+ Note, that paremeters \a resMgr and \a resSection are stored by the model to be used
+ later with save() method.
+
+ \param resMgr resources manager
+ \param resSection resources section name; if empty (default), "Theme" section is used instead
+ \sa fromApplication(), save(), update()
+*/
+void Style_Model::fromResources( QtxResourceMgr* resMgr, const QString& resSection )
{
- if ( !theResMgr )
+ // init from application
+ fromApplication( true );
+
+ myResourceMgr = resMgr;
+ myResourceSection = resSection;
+
+ // init from resource manager
+ if ( !resourceMgr() )
return;
- QString aSection = sectionName(),
- aPropName = getPropName( theId );
- switch( getPropType( theId ) ) {
- case Bool: {
- bool aValue;
- if ( !theIsDef || !theResMgr->value( aSection, aPropName, aValue ) )
- theResMgr->setValue( aSection, aPropName, getBoolValue( theId, theIsDef ) );
- break;
- }
- case Color: {
- QColor aColor;
- if ( !theIsDef || !theResMgr->value( aSection, aPropName, aColor ) )
- theResMgr->setValue( aSection, aPropName, getColorValue( theId, theIsDef ) );
- break;
- }
- case String: {
- QString aStr;
- if ( !theIsDef || !theResMgr->value( aSection, aPropName, aStr ) )
- theResMgr->setValue( aSection, aPropName, getStringValue( theId, theIsDef ) );
- break;
- }
- case IntSpin: {
- int aValue;
- if ( !theIsDef || !theResMgr->value( aSection, aPropName, aValue ) )
- theResMgr->setValue( aSection, aPropName, getIntValue( theId, theIsDef ) );
- break;
- }
- case DblSpin: {
- double aValue;
- if ( !theIsDef || !theResMgr->value( aSection, aPropName, aValue ) )
- theResMgr->setValue( aSection, aPropName, getDblValue( theId, theIsDef ) );
- break;
- }
- case Selector: {
- int aValue;
- if ( !theIsDef || !theResMgr->value( aSection, aPropName, aValue ) )
- theResMgr->setValue( aSection, aPropName, getIntValue( theId, theIsDef ) );
- break;
- }
- case Font: {
- QFont aFont;
- if ( !theIsDef || !theResMgr->value( aSection, aPropName, aFont ) )
- theResMgr->setValue( aSection, aPropName, getFontValue( theId, theIsDef ) );
- break;
- }
- default: break;
+
+ QString section = resourceSection();
+
+ // colors
+ // Button
+ readColorValue( Button, "button" );
+ // Window text
+ readColorValue( WindowText, "window-text" );
+ // Light
+ readColorValue( Light, "light" );
+ // Dark
+ readColorValue( Dark, "dark" );
+ // Mid
+ readColorValue( Mid, "mid" );
+ // Text
+ readColorValue( Text, "text" );
+ // BrightText
+ readColorValue( BrightText, "bright-text" );
+ // ButtonText
+ readColorValue( ButtonText, "button-text" );
+ // Base
+ readColorValue( Base, "base" );
+ // Window
+ readColorValue( Window, "window" );
+ // AlternateBase
+ readColorValue( AlternateBase, "alternate-base" );
+ // Midlight
+ readColorValue( Midlight, "midlight" );
+ // Shadow
+ readColorValue( Shadow, "shadow" );
+ // Highlight
+ readColorValue( Highlight, "highlight" );
+ // HighlightedText
+ readColorValue( HighlightedText, "highlight-text" );
+ // Link
+ readColorValue( Link, "link" );
+ // LinkVisited
+ readColorValue( LinkVisited, "link-visited" );
+ // ToolTipBase
+ readColorValue( ToolTipBase, "tooltip-base" );
+ // ToolTipText
+ readColorValue( ToolTipText, "tooltip-text" );
+ // BorderTop
+ readColorValue( BorderTop, "border-top" );
+ // BorderBottom
+ readColorValue( BorderBottom, "border-bottom" );
+ // TabBorderTop
+ readColorValue( TabBorderTop, "tab-border-top" );
+ // TabBorderBottom
+ readColorValue( TabBorderBottom, "tab-border-bottom" );
+ // FieldLight
+ readColorValue( FieldLight, "field-light" );
+ // FieldDark
+ readColorValue( FieldDark, "field-dark" );
+ // ProgressBar
+ readColorValue( ProgressBar, "progress-bar" );
+ // Pointer
+ readColorValue( Pointer, "pointer" );
+ // Checked
+ readColorValue( Checked, "checked" );
+ // GridLine
+ readColorValue( GridLine, "grid-line" );
+ // Header
+ readColorValue( Header, "header" );
+ // Slider
+ readColorValue( Slider, "slider" );
+ // HighlightWidget
+ readColorValue( HighlightWidget, "highlight-widget" );
+ // HighlightBorder
+ readColorValue( HighlightBorder, "highlight-border" );
+ // Lines
+ readColorValue( Lines, "lines" );
+ // auto-palette flag (internal)
+ if ( resourceMgr()->hasValue( section, "auto-palette" ) ) {
+ setAutoPalette( resourceMgr()->booleanValue( section, "auto-palette" ) );
+ }
+ // lines type
+ if ( resourceMgr()->hasValue( section, "lines-type" ) ) {
+ int ltype = resourceMgr()->integerValue( section, "lines-type" );
+ if ( ltype >= NoLines && ltype <= Inclined )
+ setLinesType( (LineType)ltype );
+ }
+ // lines transparency
+ if ( resourceMgr()->hasValue( section, "lines-transparency" ) ) {
+ int ltransp = resourceMgr()->integerValue( section, "lines-transparency" );
+ if ( ltransp >= 0 && ltransp <= 100 )
+ setLinesTransparency( ltransp );
+ }
+ // application font
+ if ( resourceMgr()->hasValue( section, "application-font" ) ) {
+ setApplicationFont( resourceMgr()->fontValue( section, "application-font" ) );
+ }
+ // widgets rounding
+ if ( resourceMgr()->hasValue( section, "button-rad" ) ) {
+ setWidgetRounding( ButtonRadius, resourceMgr()->doubleValue( section, "button-rad" ) );
+ }
+ if ( resourceMgr()->hasValue( section, "edit-rad" ) ) {
+ setWidgetRounding( EditRadius, resourceMgr()->doubleValue( section, "edit-rad" ) );
+ }
+ if ( resourceMgr()->hasValue( section, "frame-rad" ) ) {
+ setWidgetRounding( FrameRadius, resourceMgr()->doubleValue( section, "frame-rad" ) );
+ }
+ if ( resourceMgr()->hasValue( section, "slider-rad" ) ) {
+ setWidgetRounding( SliderRadius, resourceMgr()->doubleValue( section, "slider-rad" ) );
+ }
+ // widget effect
+ if ( resourceMgr()->hasValue( section, "widget-effect" ) ) {
+ int effect = resourceMgr()->integerValue( section, "widget-effect" );
+ if ( effect >= NoEffect && effect <= AutoRaiseEffect )
+ setWidgetEffect( (WidgetEffect)effect );
+ }
+ else if ( resourceMgr()->hasValue( section, "is-highlight-widget" ) ||
+ resourceMgr()->hasValue( section, "is-raising-widget" ) ) {
+ bool highlight = resourceMgr()->booleanValue( section, "is-highlight-widget", false );
+ bool autoraise = resourceMgr()->booleanValue( section, "is-highlight-widget", false );
+ if ( highlight )
+ setWidgetEffect( HighlightEffect );
+ else if ( autoraise )
+ setWidgetEffect( AutoRaiseEffect );
+ }
+ if ( resourceMgr()->hasValue( section, "all-antialized" ) ) {
+ setAntialiasing( resourceMgr()->booleanValue( section, "all-antialized" ) );
+ }
+ // handles
+ if ( resourceMgr()->hasValue( section, "hor-hadle-delta" ) ) {
+ setHandleDelta( Qt::Horizontal, resourceMgr()->integerValue( section, "hor-hadle-delta" ) );
+ }
+ if ( resourceMgr()->hasValue( section, "ver-hadle-delta" ) ) {
+ setHandleDelta( Qt::Vertical, resourceMgr()->integerValue( section, "vsr-hadle-delta" ) );
+ }
+ if ( resourceMgr()->hasValue( section, "slider-size" ) ) {
+ setSliderSize( resourceMgr()->integerValue( section, "slider-size" ) );
+ }
+ else if ( resourceMgr()->hasValue( section, "slider-increase" ) ) {
+ setSliderSize( resourceMgr()->integerValue( section, "slider-increase" ) );
+ }
+ if ( resourceMgr()->hasValue( section, "split-handle-len" ) ) {
+ setSplitHandleLength( resourceMgr()->integerValue( section, "split-handle-len" ) );
}
}
-void Style_Model::setValueFrom( QtxResourceMgr* theResMgr, int theId )
+/*!
+ \brief Save SALOME stype properties to the resource file.
+
+ If paremeters \a resMgr and \a resSection are not specified, default ones
+ (those passed to the fromResources() function) are used instead.
+
+ \param resMgr resources manager
+ \param resSection resources section name
+ \sa fromResources(), update()
+*/
+void Style_Model::save( QtxResourceMgr* resMgr, const QString& resSection )
{
- if ( !theResMgr )
+ if ( !resMgr )
+ resMgr = resourceMgr();
+ if ( !resMgr )
return;
- QString aSection = sectionName(),
- aPropName = getPropName( theId );
- QVariant aValue = myValues[theId].myDefValue;
- switch( getPropType( theId ) ) {
- case Bool:
- aValue = theResMgr->booleanValue( aSection, aPropName, getBoolValue( theId, true ) );
- break;
- case Color:
- aValue = theResMgr->colorValue( aSection, aPropName, getColorValue( theId , true ) );
- break;
- case String:
- aValue = theResMgr->stringValue( aSection, aPropName, getStringValue( theId, true ) );
- break;
- case IntSpin:
- aValue = theResMgr->integerValue( aSection, aPropName, getIntValue( theId, true ) );
- break;
- case DblSpin:
- aValue = theResMgr->doubleValue( aSection, aPropName, getDblValue( theId, true ) );
- break;
- case Selector:
- aValue = theResMgr->integerValue( aSection, aPropName, getIntValue( theId, true ) );
- break;
- case Font:
- aValue = theResMgr->fontValue( aSection, aPropName, getFontValue( theId, true ) );
- break;
- default: break;
- }
- myValues[theId].myValue = aValue;
+
+ QString section = resSection.isEmpty() ? resourceSection() : resSection;
+
+ // colors
+ // Button
+ writeColorValue( Button, "button", resMgr, section );
+ // Window text
+ writeColorValue( WindowText, "window-text", resMgr, section );
+ // Light
+ writeColorValue( Light, "light", resMgr, section );
+ // Dark
+ writeColorValue( Dark, "dark", resMgr, section );
+ // Mid
+ writeColorValue( Mid, "mid", resMgr, section );
+ // Text
+ writeColorValue( Text, "text", resMgr, section );
+ // BrightText
+ writeColorValue( BrightText, "bright-text", resMgr, section );
+ // ButtonText
+ writeColorValue( ButtonText, "button-text", resMgr, section );
+ // Base
+ writeColorValue( Base, "base", resMgr, section );
+ // Window
+ writeColorValue( Window, "window", resMgr, section );
+ // AlternateBase
+ writeColorValue( AlternateBase, "alternate-base", resMgr, section );
+ // Midlight
+ writeColorValue( Midlight, "midlight", resMgr, section );
+ // Shadow
+ writeColorValue( Shadow, "shadow", resMgr, section );
+ // Highlight
+ writeColorValue( Highlight, "highlight", resMgr, section );
+ // HighlightedText
+ writeColorValue( HighlightedText, "highlight-text", resMgr, section );
+ // Link
+ writeColorValue( Link, "link", resMgr, section );
+ // LinkVisited
+ writeColorValue( LinkVisited, "link-visited", resMgr, section );
+ // ToolTipBase
+ writeColorValue( ToolTipBase, "tooltip-base", resMgr, section );
+ // ToolTipText
+ writeColorValue( ToolTipText, "tooltip-text", resMgr, section );
+ // BorderTop
+ writeColorValue( BorderTop, "border-top", resMgr, section );
+ // BorderBottom
+ writeColorValue( BorderBottom, "border-bottom", resMgr, section );
+ // TabBorderTop
+ writeColorValue( TabBorderTop, "tab-border-top", resMgr, section );
+ // TabBorderBottom
+ writeColorValue( TabBorderBottom, "tab-border-bottom", resMgr, section );
+ // FieldLight
+ writeColorValue( FieldLight, "field-light", resMgr, section );
+ // FieldDark
+ writeColorValue( FieldDark, "field-dark", resMgr, section );
+ // ProgressBar
+ writeColorValue( ProgressBar, "progress-bar", resMgr, section );
+ // Pointer
+ writeColorValue( Pointer, "pointer", resMgr, section );
+ // Checked
+ writeColorValue( Checked, "checked", resMgr, section );
+ // GridLine
+ writeColorValue( GridLine, "grid-line", resMgr, section );
+ // Header
+ writeColorValue( Header, "header", resMgr, section );
+ // Slider
+ writeColorValue( Slider, "slider", resMgr, section );
+ // HighlightWidget
+ writeColorValue( HighlightWidget, "highlight-widget", resMgr, section );
+ // HighlightBorder
+ writeColorValue( HighlightBorder, "highlight-border", resMgr, section );
+ // Lines
+ writeColorValue( Lines, "lines", resMgr, section );
+ // auto-palette flag (internal)
+ resMgr->setValue( section, "auto-palette", isAutoPalette() );
+
+ // lines type
+ resMgr->setValue( section, "lines-type", (int)linesType() );
+ // lines transparency
+ resMgr->setValue( section, "lines-transparency", linesTransparency() );
+ // application font
+ resMgr->setValue( section, "application-font", applicationFont() );
+ // widgets rounding
+ resMgr->setValue( section, "button-rad", widgetRounding( ButtonRadius ) );
+ resMgr->setValue( section, "edit-rad", widgetRounding( EditRadius ) );
+ resMgr->setValue( section, "frame-rad", widgetRounding( FrameRadius ) );
+ resMgr->setValue( section, "slider-rad", widgetRounding( SliderRadius ) );
+ resMgr->setValue( section, "all-antialized", antialiasing() );
+ // widget effect
+ resMgr->setValue( section, "widget-effect", (int)widgetEffect() );
+ // handles
+ resMgr->setValue( section, "hor-hadle-delta", handleDelta( Qt::Horizontal ) );
+ resMgr->setValue( section, "vsr-hadle-delta", handleDelta( Qt::Vertical ) );
+ resMgr->setValue( section, "slider-size", sliderSize() );
+ resMgr->setValue( section, "split-handle-len", splitHandleLength() );
+}
+
+/*!
+ \brief Reload SALOME style properties from the resources file(s).
+ \sa fromResources(), save()
+*/
+void Style_Model::update()
+{
+ fromResources( resourceMgr(), resourceSection() );
+}
+
+/*!
+ \brief Restore original style, palette and font to the application
+
+ 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.
+
+ \sa fromApplication()
+*/
+void Style_Model::restore()
+{
+ if ( !QApplication::instance() ) // application object is not created yet
+ return;
+ if ( !myAppData ) // not initialized from the application yet
+ return;
+
+ QApplication::setStyle( myAppData->myStyle );
+ QApplication::setPalette( myAppData->myPalette );
+ QApplication::setFont( myAppData->myFont );
}
-void Style_Model::setPredefinedStyle( int theType )
+/*!
+ \brief Get resource manager used by this SALOME style model.
+
+ \return pointer to the resource manager passed previously to the fromResources() method
+ \sa initFromResources(), resourceSection()
+*/
+QtxResourceMgr* Style_Model::resourceMgr() const
+{
+ return myResourceMgr;
+}
+
+/*!
+ \brief Get resources section name
+
+ If section name is empty, default "Theme" is returned
+
+ \return resource section name passed previously to the fromResources() method
+ \sa initFromResources(), resourceMgr()
+*/
+QString Style_Model::resourceSection() const
+{
+ return !myResourceSection.isEmpty() ? myResourceSection : "Theme";
+}
+
+/*!
+ \brief Get palette color value
+ \param role color role
+ \param cg color group
+ \return a color which should be used to draw the corresponding part of the application
+ \sa setColor()
+*/
+QColor Style_Model::color( ColorRole role, QPalette::ColorGroup cg ) const
+{
+ QColor c = myColors[ cg ][ role ];
+ if ( !c.isValid() ) c = myColors[ QPalette::Active ][ role ];
+ return c;
+}
+
+/*!
+ \brief Set palette color value
+
+ If \a inactive and/or \a disabled colors are not specified, they are automatically
+ calculated from \a active color.
+
+ \param role color role
+ \param active a color to be used with active color group (QPalette::Active)
+ \param inactive a color to be used with inactive color group (QPalette::Inactive)
+ \param disabled a color to be used with disabled color group (QPalette::Disabled)
+ \sa color()
+*/
+void Style_Model::setColor( Style_Model::ColorRole role, const QColor& active,
+ const QColor& inactive, const QColor& disabled )
{
- reset();
- switch ( theType ) {
- case 0: {
- setValue( slider_rad, QVariant( 3 ) );
- setValue( slider_increase, QVariant( 5 ) );
- setValue( auto_raising_wdg, QVariant( true ) );
+ QColor ac = active, ic = inactive, dc = disabled;
+
+ if ( !ic.isValid() ) {
+ ic = ac;
+ }
+ if ( !dc.isValid() ) {
+ switch ( role ) {
+ case WindowText:
+ case Text:
+ dc = color( Button ).darker();
break;
- }
- case 1: {
- //light blue variant
- setValue( bg_clr, QVariant( QColor( "lightsteelblue" ) ) );
- setValue( lines_type, QVariant( 0 ) );
- setValue( lines_clr, QVariant( QColor( "blue" ) ) );
- setValue( checked_clr, QVariant( QColor( "cornflowerblue" ) ) );
- setValue( header_clr, QVariant( QColor( "silver" ) ) );
- setValue( slider_clr, QVariant( QColor( "cornflowerblue" ) ) );
- setValue( button_clr, QVariant( QColor( "silver" ) ) );
- setValue( pointer_clr, QVariant( QColor( "midnightblue" ) ) );
- setValue( fld_light_clr, QVariant( QColor( "whitesmoke" ) ) );
- setValue( fld_dark_clr, QVariant( QColor( "grey" ).light( 145 ) ) );
- setValue( prbar_clr, QVariant( QColor ("cornflowerblue" ) ) );
- setValue( slider_rad, QVariant( 3 ) );
- setValue( edit_rad, QVariant( 6 ) );
- setValue( btn_rad, QVariant( 10 ) );
- setValue( frame_rad, QVariant( 10 ) );
- setValue( slider_increase, QVariant( 5 ) );
- setValue( all_antialized, QVariant( false ) ); // true
-
- setValue( highlight_wdg, QVariant( true ) );
- setValue( high_wdg_clr, QVariant("skyblue") );
- setValue( high_brd_wdg_clr, QVariant("cornflowerblue") );
- setValue( pal_base_clr, QVariant( QColor( "white" ) ) );
- //setValue( auto_raising_wdg, QVariant( true ) );
+ case Base:
+ dc = color( Button );
break;
- }
- case 2: {
- QColor aDarkGreen = QColor( "darkgreen" ).dark(195);
- setValue( bg_clr, QVariant( QColor( "black" ) ) );
- setValue( lines_type, QVariant( 0 ) );
- setValue( checked_clr, QVariant( QColor( "black" ) ) );
- setValue( header_clr, QVariant( aDarkGreen ) );
- setValue( slider_clr, QVariant( QColor( "goldenrod" ) ) );
- setValue( button_clr, QVariant( aDarkGreen ) );
-
- setValue( border_top_clr, QVariant( "goldenrod" ) );
- setValue( border_bot_clr, QVariant( "saddlebrown" ) );
- setValue( border_tab_top_clr, QVariant( "goldenrod" ) );
- setValue( border_tab_bot_clr, QVariant( "saddlebrown" ) );
-
- setValue( pointer_clr, QVariant( QColor( "gold" ) ) );
- setValue( fld_light_clr, QVariant( QColor( "green" ) ) );
- setValue( fld_dark_clr, QVariant( aDarkGreen ) );
- setValue( prbar_clr, QVariant( QColor( "goldenrod" ) ) );
- setValue( tbl_grline_clr,QVariant( "saddlebrown" ) );
- setValue( ttip_is_change,QVariant( true ) );
- setValue( ttip_bg_clr, QVariant( "green" ) );
-
- setValue( pal_text_clr, QVariant( QColor( "white" ) ) );
- setValue( pal_btext_clr, QVariant( QColor( "gold" ) ) );
- setValue( pal_wtext_clr, QVariant( QColor( "gold" ) ) );
- setValue( pal_base_clr, QVariant( QColor( "black" ) ) );
- setValue( pal_high_clr, QVariant( QColor( "gold" ) ) );
- setValue( pal_high_text_clr, QVariant( QColor( "goldenrod" ) ) );
- setValue( pal_light_clr, QVariant( QColor( "goldenrod" ) ) );
- setValue( pal_dark_clr, QVariant( QColor( "saddlebrown" ) ) );
-
- setValue( slider_rad, QVariant( 3 ) );
- setValue( edit_rad, QVariant( 6 ) );
- setValue( frame_rad, QVariant( 10 ) );
- setValue( btn_rad, QVariant( 10 ) );
- setValue( slider_increase, QVariant( 6 ) );
- setValue( all_antialized, QVariant( false ) );
-
- setValue( highlight_wdg, QVariant( true ) );
- setValue( high_wdg_clr, QVariant("green") );
- setValue( high_brd_wdg_clr, QVariant( aDarkGreen ) );
+ case AlternateBase:
+ dc = mixColors( color( Base, QPalette::Inactive ), color( Button, QPalette::Inactive ) );
+ break;
+ case Midlight:
+ dc = mixColors( color( Light, QPalette::Inactive ), color( Button, QPalette::Inactive ) );
break;
- }
default:
- return;
+ dc = ac;
+ break;
+ }
}
+
+ setColor( role, QPalette::Active, ac );
+ setColor( role, QPalette::Inactive, ic );
+ setColor( role, QPalette::Disabled, dc );
}
-double Style_Model::getDblValue( int theId, const bool theIsDef ) const
+/*!
+ \brief Set palette color value
+
+ If \a inactive and/or \a disabled colors are not specified, they are automatically
+ calculated from \a active color.
+
+ \param role color role
+ \param cg color group
+ \param c color which should be used to draw the corresponding part of the application
+ \sa color()
+*/
+void Style_Model::setColor( Style_Model::ColorRole role, QPalette::ColorGroup cg, const QColor& c )
{
- double aRes = 0;
- QVariant aValue;
- if ( myValues.contains(theId) && myValues[theId].myType == DblSpin ) {
- if ( theIsDef )
- aValue = myValues[theId].myDefValue;
- else
- aValue = myValues[theId].myValue;
- if ( aValue.canConvert( QVariant::Double ) )
- aRes = myValues[theId].myValue.toDouble();
- }
- return aRes;
+ myColors[ cg ][ role ] = c;
}
-int Style_Model::getIntValue( int theId, const bool theIsDef ) const
+/*!
+ \brief Returns 'auto-calculating color values' flag
+ \return 'auto-calculating color values' flag
+ \internal
+ \sa setAutoPalette()
+*/
+bool Style_Model::isAutoPalette() const
{
- int aRes = 0;
- QVariant aValue;
- if ( myValues.contains(theId) && ( myValues[theId].myType == IntSpin
- || myValues[theId].myType == Selector ) ) {
- if ( theIsDef )
- aValue = myValues[theId].myDefValue;
- else
- aValue = myValues[theId].myValue;
- if ( aValue.canConvert( QVariant::Int ) )
- aRes = myValues[theId].myValue.toInt();
- }
- return aRes;
+ return myAutoPalette;
}
-bool Style_Model::getBoolValue( int theId, const bool theIsDef ) const
+/*!
+ \brief Set/clear 'auto-calculating color values' flag
+ \param on new value of 'auto-calculating color values' flag
+ \internal
+ \sa isAutoPalette()
+*/
+void Style_Model::setAutoPalette( bool on )
{
- bool aRes = false;
- QVariant aValue;
- if ( myValues.contains(theId) && myValues[theId].myType == Bool ) {
- if ( theIsDef )
- aValue = myValues[theId].myDefValue;
- else
- aValue = myValues[theId].myValue;
- if ( aValue.canConvert( QVariant::Bool ) )
- aRes = myValues[theId].myValue.toBool();
- }
- return aRes;
+ myAutoPalette = on;
}
-QColor Style_Model::getColorValue( int theId, const bool theIsDef ) const
+/*!
+ \brief Get lines type
+ \return current lines type
+ \sa setLinesType(), linesTransparency()
+*/
+Style_Model::LineType Style_Model::linesType() const
{
- QColor aColor = Qt::gray;
- QVariant aValue;
- if ( myValues.contains(theId) && myValues[theId].myType == Color ) {
- if ( theIsDef )
- aValue = myValues[theId].myDefValue;
- else
- aValue = myValues[theId].myValue;
+ return myLinesType;
+}
- if ( aValue.canConvert( QVariant::Color ) )
- aColor = myValues[theId].myValue.value<QColor>();
- }
- return aColor;
+/*!
+ \brief Set lines type
+ \param lt new lines type
+ \sa linesType(), linesTransparency()
+*/
+void Style_Model::setLinesType( LineType lt )
+{
+ myLinesType = lt;
}
-QString Style_Model::getStringValue( int theId, const bool theIsDef ) const
+/*!
+ \brief Get lines transparency value
+ \return current lines transparency
+ \sa setLinesTransparency(), linesType()
+*/
+int Style_Model::linesTransparency() const
{
- QString aRes = false;
- QVariant aValue;
- if ( myValues.contains(theId) && myValues[theId].myType == String ) {
- if ( theIsDef )
- aValue = myValues[theId].myDefValue;
- else
- aValue = myValues[theId].myValue;
- if ( aValue.canConvert( QVariant::String ) )
- aRes = myValues[theId].myValue.toString();
- }
- return aRes;
+ return myLinesTransparency;
}
-QFont Style_Model::getFontValue( int theId, const bool theIsDef ) const
+/*!
+ \brief Set lines transparency value
+ \param transparency new lines transparency
+ \sa linesTransparency(), linesType()
+*/
+void Style_Model::setLinesTransparency( int transparency )
{
- QFont aFont;
- QVariant aValue;
- if ( myValues.contains(theId) && myValues[theId].myType == Font ) {
- if ( theIsDef )
- aValue = myValues[theId].myDefValue;
- else
- aValue = myValues[theId].myValue;
- if ( aValue.canConvert( QVariant::Font ) )
- aFont = myValues[theId].myValue.value<QFont>();
- }
- return aFont;
+ myLinesTransparency = transparency;
}
-QList<int> Style_Model::getTabs() const
+/*!
+ \brief Get application font
+ \return current application font
+ \sa setApplicationFont()
+*/
+QFont Style_Model::applicationFont() const
{
- return myTabs.keys();
+ return myFont;
}
-QString Style_Model::getTabTitle( int theId ) const
+/*!
+ \brief Set application font
+ \param font new application font
+ \sa applicationFont()
+*/
+void Style_Model::setApplicationFont( const QFont& font )
{
- return myTabs.contains( theId ) ? myTabs[theId] : "";
+ myFont = font;
}
-QList<int> Style_Model::getGroups( int theId ) const
+/*!
+ \brief Get widget corners rounding radius value
+ \param wr widget type
+ \return current widget corners rounding
+ \sa setWidgetRounding(), antialiasing()
+*/
+double Style_Model::widgetRounding( Style_Model::WidgetRounding wr ) const
{
- QList<int> groups;
- GroupMap::const_iterator anIt = myGroups.begin(), anEnd = myGroups.end();
- for ( ; anIt != anEnd; ++anIt )
- if ( anIt.value().myTabType == theId )
- groups.append( anIt.key() );
- return groups;
+ return myWidgetRounding[ wr ];
}
-QString Style_Model::getGroupTitle( int theId ) const
+/*!
+ \brief Set widget corners rounding radius value
+ \param wr widget type
+ \param value new widget corners rounding
+ \sa widgetRounding(), antialiasing()
+*/
+void Style_Model::setWidgetRounding( WidgetRounding wr, double value )
{
- return myGroups.contains( theId ) ? myGroups[theId].myTitle : "";
+ myWidgetRounding[ wr ] = value;
}
-int Style_Model::getGroupNbColumns( int theId ) const
+/*!
+ \brief Get anti-aliasing flag value
+ \return \c true if widgets borders should be antialiased
+ \sa setAntialiasing(), widgetRounding()
+*/
+bool Style_Model::antialiasing() const
{
- return myGroups.contains( theId ) ? myGroups[theId].myNbColumns : 1;
+ return myAntiAliasing;
}
-QList<int> Style_Model::getGroupProps( int theId ) const
+/*!
+ \brief Set anti-aliasing flag value
+ \param value if \c true, widgets borders should be antialiased
+ \sa antialiasing(), widgetRounding()
+*/
+void Style_Model::setAntialiasing( bool value )
{
- QList<int> values;
- ValuesMap::const_iterator anIt = myValues.begin(), anEnd = myValues.end();
- for ( ; anIt != anEnd; ++anIt )
- if ( anIt.value().myGroupId == theId )
- values.append( anIt.key() );
- return values;
+ myAntiAliasing = value;
}
-QString Style_Model::getPropTitle( int theId ) const
+/*!
+ \brief Get widget effect
+ \return current widget effect
+ \sa setWidgetEffect()
+*/
+Style_Model::WidgetEffect Style_Model::widgetEffect() const
{
- return myValues.contains( theId ) ? myValues[theId].myTitle : "";
+ return myWidgetEffect;
}
-Style_Model::PropType Style_Model::getPropType( int theId ) const
+/*!
+ \brief Set widget effect
+ \param we new widget effect
+ \sa widgetEffect()
+*/
+void Style_Model::setWidgetEffect( WidgetEffect we )
{
- return myValues.contains( theId ) ? myValues[theId].myType : None;
+ myWidgetEffect = we;
}
-QString Style_Model::getPropName( int theId ) const
+/*!
+ \brief Get handle spacing value
+ \param o handle spacing direction
+ \return current handle spacing value
+ \sa setHandleDelta()
+*/
+int Style_Model::handleDelta( Qt::Orientation o ) const
{
- return myValues.contains( theId ) ? myValues[theId].myName : "";
+ return myHandleDelta[ o ];
}
-void Style_Model::getSelector( int theId, QStringList& theLst, QList<QVariant>& theIds ) const
+/*!
+ \brief Set handle spacing value
+ \param o handle spacing direction
+ \param value new handle spacing value
+ \sa handleDelta()
+*/
+void Style_Model::setHandleDelta( Qt::Orientation o, int value )
{
- theLst.clear();
- theIds.clear();
- switch ( theId ) {
- case defined_style: theLst = myPStyles; break;
- case lines_type: theLst = myLines; break;
- default: break;
- }
- QStringList::iterator anIt = theLst.begin(), anEnd = theLst.end();
- int i = 0;
- for ( ; anIt != anEnd; ++anIt )
- theIds.append( QVariant( i++ ) );
+ myHandleDelta[ o ] = value;
}
-void Style_Model::setDefValue( Properties theId, const QVariant& theValue )
+/*!
+ \brief Get splitter handle length
+ \return current splitter handle length
+ \sa setSplitHandleLength()
+*/
+int Style_Model::splitHandleLength() const
{
- myValues[theId].myDefValue = theValue;
- setValue( theId, theValue );
+ return mySplitHandleLength;
}
-void Style_Model::setValue( Properties theId, const QVariant& theValue )
+/*!
+ \brief Set splitted handle length
+ \param value new splitter handle length
+ \sa splitHandleLength()
+*/
+void Style_Model::setSplitHandleLength( int value )
{
- myValues[theId].myValue = theValue;
+ mySplitHandleLength = value;
}
-void Style_Model::fillValue( Properties theId, const QString& theName,
- const QString& theTitle, Groups theGroupId, PropType theType )
+/*!
+ \brief Get slider handle extra size
+ \return current slider handle extra size
+ \sa setSliderSize()
+*/
+int Style_Model::sliderSize() const
{
- StyleValue aValue;
- aValue.myName = theName;
- aValue.myTitle = theTitle;
- aValue.myGroupId = theGroupId;
- aValue.myType = theType;
- aValue.myValue = QVariant();
+ return mySliderSize;
+}
- myValues[theId] = aValue;
+/*!
+ \brief Set slider handle extra size
+ \param value new slider handle extra size
+ \sa sliderSize()
+*/
+void Style_Model::setSliderSize( int value )
+{
+ mySliderSize = value;
}
-void Style_Model::fillGroup( Groups theId, Tabs theTab, const QString& theTitle, int theNbCols )
+/*!
+ \brief Initialize model with the default values
+*/
+void Style_Model::initDefaults()
{
- GroupValue aValue;
- aValue.myTabType = theTab;
- aValue.myTitle = theTitle;
- aValue.myNbColumns = theNbCols;
+ // default application font
+ myFont.fromString( "Sans Serif,9,-1,5,50,0,0,0,0,0" );
+
+ // default palette colors
+ myAutoPalette = false;
+ QColor btn = QColor( "#e6e7e6" );
+ QColor fg = QColor( "#000000" );
+ QColor bg = QColor( "#ffffff" );
+ setColor( Button, btn ); // = (230, 231, 230)
+ setColor( WindowText, fg ); // = ( 0, 0, 0)
+ setColor( Light, bg ); // = (255, 255, 255)
+ setColor( Dark, btn.darker() ); // = (115, 115, 115) // btn.darker( 130 ) = (177, 178, 177)
+ setColor( Mid, btn.darker( 150 ) ); // = (153, 154, 153)
+ setColor( Text, fg ); // = ( 0, 0, 0)
+ setColor( BrightText, bg ); // = (255, 255, 255) // fg = ( 0, 0, 0)
+ setColor( ButtonText, fg ); // = ( 0, 0, 0)
+ setColor( Base, bg ); // = (255, 255, 255)
+ setColor( Window, btn ); // = (230, 231, 230)
+ setColor( AlternateBase, mixColors( bg, btn ) ); // = (242, 243, 242)
+ setColor( Midlight, mixColors( bg, btn ) ); // = (242, 243, 242)
+ setColor( Shadow, fg ); // = ( 0, 0, 0)
+ setColor( Highlight, "#000080" ); // = ( 0, 0, 128) // ( 33, 68, 156 )
+ setColor( HighlightedText, bg ); // = (255, 255, 255)
+ setColor( Link, "#0000ff" ); // = ( 0, 0, 255)
+ setColor( LinkVisited, "#ff00ff" ); // = (255, 0, 255)
+ setColor( ToolTipBase, "#ffffdc" ); // = (255, 255, 220) // ( 230, 231, 230 )
+ setColor( ToolTipText, fg ); // = ( 0, 0, 0)
+ setColor( BorderTop, "#adadad" ); // = (173, 173, 173) // ( 255, 255, 255 )
+ setColor( BorderBottom, "#393939" ); // = ( 57, 57, 57) // ( 88, 89, 88 )
+ setColor( TabBorderTop, "#ffffff" ); // = (255, 255, 255)
+ setColor( TabBorderBottom, "#0e0e0e" ); // = ( 14, 14, 14) // ( 44, 44, 44 )
+ setColor( FieldLight, "#ffffff" ); // = (255, 255, 255)
+ setColor( FieldDark, "#c0c1c0" ); // = (192, 193, 192) // ( 240, 241, 240 )
+ setColor( ProgressBar, "#000080" ); // = ( 0, 0, 128) // ( 33, 68, 156 )
+ setColor( Pointer, "#000000" ); // = ( 0, 0, 0)
+ setColor( Checked, "#ffffff" ); // = (255, 255, 255)
+ setColor( GridLine, "#999a99" ); // = (153, 154, 153) // ( 192, 192, 192 )
+ setColor( Header, "#e6e7e6" ); // = (230, 231, 230)
+ setColor( Slider, "#e6e7e6" ); // = (230, 231, 230)
+ setColor( HighlightWidget, "#e6e7e6" ); // = (230, 231, 230)
+ setColor( HighlightBorder, "#e6e7e6" ); // = (230, 231, 230)
+ setColor( Lines, "#999a99" ); // = (153, 154, 153) // ( 192, 193, 192 )
+
+ // default values
+ myLinesType = NoLines;
+ myWidgetEffect = NoEffect;
+ myAntiAliasing = false;
+ myLinesTransparency = 0;
+ myWidgetRounding[ EditRadius ] = 0.0;
+ myWidgetRounding[ ButtonRadius ] = 0.0;
+ myWidgetRounding[ FrameRadius ] = 0.0;
+ myWidgetRounding[ SliderRadius ] = 0.0;
+ myHandleDelta[ Qt::Horizontal ] = 3;
+ myHandleDelta[ Qt::Vertical ] = 3;
+ mySplitHandleLength = 20;
+ mySliderSize = 2;
+}
- myGroups[theId] = aValue;
+/*!
+ \brief Read palette color values from resources manager
+ \param role color role
+ \param prefix palette color value resource name prefix
+ \sa writeColorValue()
+*/
+void Style_Model::readColorValue( ColorRole role, const QString& prefix )
+{
+ if ( !resourceMgr() ) return;
+
+ QString section = resourceSection();
+ QString active = QString( "%1-color" ).arg( prefix );
+ QString inactive = QString( "%1-color-inactive" ).arg( prefix );
+ QString disabled = QString( "%1-color-disabled" ).arg( prefix );
+
+ if ( resourceMgr()->hasValue( section, active ) )
+ setColor( role, resourceMgr()->colorValue( section, active ) );
+ if ( resourceMgr()->hasValue( section, inactive ) )
+ setColor( role, QPalette::Inactive, resourceMgr()->colorValue( section, inactive ) );
+ if ( resourceMgr()->hasValue( section, disabled ) )
+ setColor( role, QPalette::Disabled, resourceMgr()->colorValue( section, disabled ) );
}
+/*!
+ \brief Write palette color values to resources manager
+ \param role color role
+ \param prefix palette color value resource name prefix
+ \param resMgr resource manager
+ \param resSection resource section name
+ \sa readColorValue()
+*/
+void Style_Model::writeColorValue( ColorRole role, const QString& prefix,
+ QtxResourceMgr* resMgr, const QString& resSection ) const
+{
+ QString active = QString( "%1-color" ).arg( prefix );
+ QString inactive = QString( "%1-color-inactive" ).arg( prefix );
+ QString disabled = QString( "%1-color-disabled" ).arg( prefix );
+
+ resMgr->setValue( resSection, active, color( role, QPalette::Active ) );
+ resMgr->setValue( resSection, inactive, color( role, QPalette::Inactive ) );
+ resMgr->setValue( resSection, disabled, color( role, QPalette::Disabled ) );
+}
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : Style_Model.h
-// Author : Natalia Ermolaeva, Open CASCADE S.A.S.
+// Author : Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com)
//
#ifndef STYLE_MODEL_H
#define STYLE_MODEL_H
-#include "Style.h"
-
#include <QMap>
#include <QString>
-#include <QVariant>
-#include <QStringList>
+#include <QPalette>
+#include <QFont>
+class QStyle;
class QtxResourceMgr;
-class QApplication;
-class QColor;
-class QFont;
-class STYLE_SALOME_EXPORT Style_Model
+//
+// This class is private for Style package.
+// Normally it should not be exported.
+//
+class Style_Model
{
public:
+ //! Color palette instance enumeration
+ typedef enum {
+ WindowText = QPalette::WindowText, //!< A general foreground color
+ Button = QPalette::Button, //!< The general button background color
+ Light = QPalette::Light, //!< Usually lighter than Button color
+ Midlight = QPalette::Midlight, //!< Usually between Button and Light
+ Dark = QPalette::Dark, //!< Usually darker than Button
+ Mid = QPalette::Mid, //!< Usualliy between Button and Dark
+ Text = QPalette::Text, //!< The foreground color used with Base
+ BrightText = QPalette::BrightText, //!< A text color that is very different from WindowText, and contrasts well with e.g. Dark
+ ButtonText = QPalette::ButtonText, //!< A foreground color used with the Button color
+ Base = QPalette::Base, //!< Used mostly as the background color for text entry widgets
+ Window = QPalette::Window, //!< A general background color
+ Shadow = QPalette::Shadow, //!< Usually a very dark palette color
+ Highlight = QPalette::Highlight, //!< A color to indicate a selected item or the current item
+ HighlightedText = QPalette::HighlightedText, //!< A text color that contrasts with Highlight
+ Link = QPalette::Link, //!< A text color used for unvisited hyperlinks
+ LinkVisited = QPalette::LinkVisited, //!< A text color used for already visited hyperlinks
+ AlternateBase = QPalette::AlternateBase, //!< Used as the alternate background color in views with alternating row colors
+ NoRole = QPalette::NoRole, //!< No role; this special role is often used to indicate that a role has not been assigned
+ ToolTipBase = QPalette::ToolTipBase, //!< Used as the background color for QToolTip and QWhatsThis
+ ToolTipText = QPalette::ToolTipText, //!< Used as the foreground color for QToolTip and QWhatsThis
+ NColorRoles = QPalette::NColorRoles, //!< Used to indicate last standard palette color
+ BorderTop = NColorRoles, //!< 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
+ } ColorRole;
+
+ //! Lines type
+ typedef enum {
+ NoLines, //!< Do not draw lines
+ Horizontal, //!< Draw horozontal lines
+ Inclined, //!< Draw inclined lines
+ } LineType;
+
+ //!< Widget roundings
+ typedef enum {
+ ButtonRadius, //!< Buttons rounding
+ EditRadius, //!< Text entry widgets rounding
+ FrameRadius, //!< Frames rounding
+ SliderRadius, //!< Sliders rounding
+ } WidgetRounding;
+
+ //! Widget effect
+ typedef enum {
+ NoEffect, //!< Do not use widget effects
+ HighlightEffect, //!< Highlight widget when it is hovered
+ AutoRaiseEffect //!< Raise widget when it is hovered
+ } WidgetEffect;
+
Style_Model();
virtual ~Style_Model();
- static QString sectionName();
-
- typedef enum { tab_value, tab_color } Tabs;
- typedef enum { grp_style, grp_color, grp_col_values, grp_lines, grp_font, grp_value } Groups;
- typedef enum { None, Bool, Color, String, IntSpin, DblSpin, Selector, Font } PropType;
- typedef enum { // grp_style
- defined_style,
- // grp colors
- bg_clr, pal_base_clr, header_clr,
- pal_text_clr, pal_btext_clr, pal_wtext_clr,
- slider_clr, button_clr, prbar_clr,
- checked_clr, pointer_clr, tbl_grline_clr,
- ttip_is_change, ttip_bg_clr, ttip_text_clr,
- highlight_wdg, high_wdg_clr, high_brd_wdg_clr,
- auto_raising_wdg, pal_high_clr, pal_high_text_clr,
- // grp_col_values
- fld_light_clr, fld_dark_clr, pal_light_clr, pal_dark_clr,
- border_top_clr, border_bot_clr, border_tab_top_clr, border_tab_bot_clr,
- // grp_lines
- is_lines, lines_type, lines_clr, lines_transp,
- // grp_font
- font_value,
- // grp_values
- edit_rad, btn_rad, frame_rad, slider_rad,
- hor_handle_delta, ver_handle_delta,
- split_handle_len, slider_increase, all_antialized } Properties;
-
- void reset();
- void setDefaults( QApplication* );
- void initFromResource( QtxResourceMgr* );
- bool updateFromResource( QtxResourceMgr*, const QString& );
-
- void getValueTo( QtxResourceMgr*, int, bool );
- void setValueFrom( QtxResourceMgr*, int );
-
- void setPredefinedStyle( int );
-
- double getDblValue( int, const bool = false ) const;
- int getIntValue( int, const bool = false ) const;
- bool getBoolValue( int, const bool = false ) const;
- QColor getColorValue( int, const bool = false ) const;
- QString getStringValue( int, const bool = false ) const;
- QFont getFontValue( int, const bool = false ) const;
-
- QList<int> getTabs() const;
- QString getTabTitle( int ) const;
- QList<int> getGroups( int ) const;
- QString getGroupTitle( int ) const;
- int getGroupNbColumns( int ) const;
- QList<int> getGroupProps( int ) const;
- QString getPropTitle( int ) const;
- PropType getPropType( int ) const;
- QString getPropName( int ) const;
- void getSelector( int, QStringList&, QList<QVariant>& ) const;
+ void fromApplication( bool = false );
+ void fromResources( QtxResourceMgr*, const QString& = QString() );
-private:
- void setDefValue( Properties, const QVariant& );
- void setValue( Properties, const QVariant& );
+ void save( QtxResourceMgr* = 0, const QString& = QString() );
+ void update();
+ void restore();
+
+ QtxResourceMgr* resourceMgr() const;
+ QString resourceSection() const;
+
+
+ QColor color( ColorRole, QPalette::ColorGroup = QPalette::Active ) const;
+ void setColor( ColorRole, const QColor&, const QColor& = QColor(), const QColor& = QColor() );
+ void setColor( ColorRole, QPalette::ColorGroup, const QColor& );
+
+ bool isAutoPalette() const;
+ void setAutoPalette( bool );
- void fillValue( Properties, const QString&, const QString&,
- Groups, PropType = Color );
- void fillGroup( Groups, Tabs, const QString&, int );
+ LineType linesType() const;
+ void setLinesType( LineType );
+
+ int linesTransparency() const;
+ void setLinesTransparency( int );
+
+ QFont applicationFont() const;
+ void setApplicationFont( const QFont& );
+
+ double widgetRounding( WidgetRounding ) const;
+ void setWidgetRounding( WidgetRounding, double );
+
+ bool antialiasing() const;
+ void setAntialiasing( bool );
+
+ WidgetEffect widgetEffect() const;
+ void setWidgetEffect( WidgetEffect );
+
+ int handleDelta( Qt::Orientation ) const;
+ void setHandleDelta( Qt::Orientation, int );
+
+ int splitHandleLength() const;
+ void setSplitHandleLength( int );
+
+ int sliderSize() const;
+ void setSliderSize( int );
+
+private:
+ void initDefaults();
+ void readColorValue( ColorRole, const QString& );
+ void writeColorValue( ColorRole, const QString&, QtxResourceMgr*, const QString& ) const;
private:
- typedef struct {
- QString myName;
- QString myTitle;
- Groups myGroupId;
- PropType myType;
- QVariant myValue;
- QVariant myDefValue;
- } StyleValue;
-
- typedef struct {
- Tabs myTabType;
- QString myTitle;
- int myNbColumns;
- } GroupValue;
-
- typedef QMap<int, StyleValue> ValuesMap;
- typedef QMap<int, GroupValue> GroupMap;
- typedef QMap<int, QString> StringMap;
- ValuesMap myValues;
- GroupMap myGroups;
- StringMap myTabs;
-
- QStringList myPStyles;
- QStringList myLines;
+ typedef QMap<ColorRole, QColor> ColorMap;
+ typedef QMap<QPalette::ColorGroup, ColorMap> ColorGroupMap;
+ typedef QMap<WidgetRounding, double> RoundMap;
+ typedef QMap<Qt::Orientation, int> DeltaMap;
+
+ QtxResourceMgr* myResourceMgr;
+ QString myResourceSection;
+
+ ColorGroupMap myColors;
+ bool myAutoPalette;
+ RoundMap myWidgetRounding;
+ DeltaMap myHandleDelta;
+ QFont myFont;
+ LineType myLinesType;
+ WidgetEffect myWidgetEffect;
+ bool myAntiAliasing;
+ int myLinesTransparency;
+ int mySplitHandleLength;
+ int mySliderSize;
+
+ struct AppData {
+ QStyle* myStyle;
+ QPalette myPalette;
+ QFont myFont;
+ };
+
+ static AppData* myAppData;
};
#endif // STYLE_MODEL_H
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : Style_PrefDlg.cxx
+// Author : Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com)
+//
+
+#include "Style_PrefDlg.h"
+#include "Style_ResourceMgr.h"
+#include "Style_Model.h"
+#include "Style_Salome.h"
+
+#include <QtxColorButton.h>
+#include <QtxDoubleSpinBox.h>
+#include <QtxFontEdit.h>
+
+#include <QApplication>
+#include <QButtonGroup>
+#include <QCheckBox>
+#include <QColorDialog>
+#include <QComboBox>
+#include <QGridLayout>
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QKeyEvent>
+#include <QLabel>
+#include <QListWidget>
+#include <QMap>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QSlider>
+#include <QSpinBox>
+#include <QStackedWidget>
+#include <QTabWidget>
+#include <QVBoxLayout>
+
+static const int MARGIN = 9;
+static const int SPACING = 6;
+
+/*!
+ \class Style_PrefDlg::PaletteEditor
+ \brief SALOME style palette editor widget
+ \internal
+*/
+
+/*!
+ \brief Constructor
+ \param parent parent widget
+ \internal
+*/
+Style_PrefDlg::PaletteEditor::PaletteEditor( QWidget* parent )
+ : QFrame( parent ), myCurrentRow( 0 ), myCurrentColumn( -1 )
+{
+ QGridLayout* l = new QGridLayout( this );
+ l->setMargin( MARGIN ); l->setSpacing( SPACING );
+ l->addWidget( myQuickButton = new QPushButton( tr( "Quick" ), this ), 0, 0 );
+ l->addWidget( myAutoCheck = new QCheckBox( tr( "Auto" ), this ), 0, 1 );
+ l->addWidget( myContainer = new QFrame( this ), 1, 0, 1, 2 );
+
+ l = new QGridLayout( myContainer );
+ l->setMargin( 0 ); l->setSpacing( SPACING );
+
+ addColumn( tr( "Base colors" ) );
+ for ( int i = (int)Style_Model::WindowText; i < (int)Style_Model::NColorRoles; i++ ) {
+ if ( i == Style_Model::NoRole ) continue;
+ addItem( i );
+ }
+
+ addColumn( tr( "Additional colors" ) );
+ for ( int i = (int)Style_Model::BorderTop; i < (int)Style_Model::LastColor; i++ )
+ addItem( i );
+
+ connect( myQuickButton, SIGNAL( clicked() ), this, SLOT( onQuick() ) );
+ connect( myAutoCheck, SIGNAL( toggled( bool ) ), this, SLOT( onAuto() ) );
+}
+
+/*!
+ \brief Destructor
+ \internal
+*/
+Style_PrefDlg::PaletteEditor::~PaletteEditor()
+{
+}
+
+/*!
+ \brief Add new color properties column to the widget
+ \param title column title
+ \sa addItem()
+ \internal
+*/
+void Style_PrefDlg::PaletteEditor::addColumn( const QString& title )
+{
+ QGridLayout* l = qobject_cast<QGridLayout*>( myContainer->layout() );
+ myCurrentRow = 0;
+ myCurrentColumn++;
+
+ if ( !title.isEmpty() ) {
+ QHBoxLayout* hbox = new QHBoxLayout;
+ hbox->setMargin( 0 ); hbox->setSpacing( SPACING );
+ QWidget* ln = line();
+ hbox->addWidget( ln );
+ hbox->setStretchFactor( ln, 5 );
+ QLabel* tlt = new QLabel( title, myContainer );
+ tlt->setAlignment( Qt::AlignCenter );
+ hbox->addWidget( tlt );
+ ln = line();
+ hbox->addWidget( ln );
+ hbox->setStretchFactor( ln, 5 );
+ l->addLayout( hbox, myCurrentRow++, myCurrentColumn*4, 1, 4 );
+ }
+
+ l->addWidget( myActiveLab = new QLabel( tr( "Active" ), myContainer ), myCurrentRow, myCurrentColumn*4+1 );
+ l->addWidget( myInactiveLab = new QLabel( tr( "Inactive" ), myContainer ), myCurrentRow, myCurrentColumn*4+2 );
+ l->addWidget( myDisabledLab = new QLabel( tr( "Disable" ), myContainer ), myCurrentRow, myCurrentColumn*4+3 );
+ int w = 0;
+ w = qMax( w, myActiveLab->sizeHint().width() );
+ w = qMax( w, myInactiveLab->sizeHint().width() );
+ w = qMax( w, myDisabledLab->sizeHint().width() );
+ myActiveLab->setMinimumWidth( w );
+ myInactiveLab->setMinimumWidth( w );
+ myDisabledLab->setMinimumWidth( w );
+
+ for( int i = 1; i < 4; i++ ) l->setColumnStretch( myCurrentColumn*4+i, 5 );
+
+ myCurrentRow++;
+}
+
+/*!
+ \brief Add color item to the widget (to the current column)
+ \param id color palette identifier (Style_Model::ColorRole)
+ \sa addColumn(), items()
+ \internal
+*/
+void Style_PrefDlg::PaletteEditor::addItem( int id )
+{
+ if ( myButtons.contains( id ) )
+ return;
+
+ myButtons[ id ] = Btns();
+ myButtons[ id ][ QPalette::Active ] = new QtxColorButton( myContainer );
+ myButtons[ id ][ QPalette::Inactive ] = new QtxColorButton( myContainer );
+ myButtons[ id ][ QPalette::Disabled ] = new QtxColorButton( myContainer );
+ myButtons[ id ][ QPalette::Active ]->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myButtons[ id ][ QPalette::Inactive ]->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myButtons[ id ][ QPalette::Disabled ]->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ QGridLayout* l = qobject_cast<QGridLayout*>( myContainer->layout() );
+ l->addWidget( new QLabel( idToName( id ), myContainer ), myCurrentRow, myCurrentColumn*4 );
+ l->addWidget( myButtons[ id ][ QPalette::Active ], myCurrentRow, myCurrentColumn*4+1 );
+ l->addWidget( myButtons[ id ][ QPalette::Inactive ], myCurrentRow, myCurrentColumn*4+2 );
+ l->addWidget( myButtons[ id ][ QPalette::Disabled ], myCurrentRow, myCurrentColumn*4+3 );
+
+ connect( myButtons[ id ][ QPalette::Active ], SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) );
+ connect( myButtons[ id ][ QPalette::Inactive ], SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) );
+ connect( myButtons[ id ][ QPalette::Disabled ], SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) );
+
+ myCurrentRow++;
+}
+
+/*!
+ \brief Get list of currently available color items
+ \return list of items identifiers (Style_Model::ColorRole)
+ \sa addColumn(), addItem()
+ \internal
+*/
+QList<int> Style_PrefDlg::PaletteEditor::items() const
+{
+ return myButtons.keys();
+}
+
+/*!
+ \brief Set color value to the item
+ \param id item identifier (Style_Model::ColorRole)
+ \param cg color group
+ \param c color value
+ \sa color()
+ \internal
+*/
+void Style_PrefDlg::PaletteEditor::setColor( int id, QPalette::ColorGroup cg, const QColor& c )
+{
+ if ( myButtons.contains( id ) ) {
+ myButtons[ id ][ cg ]->setColor( c );
+ }
+}
+
+/*!
+ \brief Set color value to the item
+ \param id item identifier (Style_Model::ColorRole)
+ \param active color to be used with active color group (QPalette::Active)
+ \param inactive color to be used with inactive color group (QPalette::Inactive)
+ \param disabled color to be used with disabled color group (QPalette::Disabled)
+ \sa color()
+ \internal
+*/
+void Style_PrefDlg::PaletteEditor::setColor( int id, const QColor& active,
+ const QColor& inactive, const QColor& disabled )
+{
+ setColor( id, QPalette::Active, active );
+ setColor( id, QPalette::Inactive, inactive.isValid() ? inactive : active );
+ setColor( id, QPalette::Disabled, disabled.isValid() ? disabled : active );
+}
+
+/*!
+ \brief Get color value assigned to the item
+ \param id item identifier (Style_Model::ColorRole)
+ \param cg color group
+ \return color value
+ \sa setColor()
+ \internal
+*/
+QColor Style_PrefDlg::PaletteEditor::color( int id, QPalette::ColorGroup cg ) const
+{
+ QColor c;
+ if ( myButtons.contains( id ) ) {
+ c = myButtons[ id ][ cg ]->color();
+ }
+ return c;
+}
+
+/*!
+ \brief Get 'auto-palette' flag value
+ \return \c true if inactive/disabled palette colors should be calculated from active one
+ \sa setAuto()
+ \internal
+*/
+bool Style_PrefDlg::PaletteEditor::isAuto() const
+{
+ return myAutoCheck->isChecked();
+}
+
+/*!
+ \brief Set/clear 'auto-palette' flag value
+ \param on if \c true, inactive/disabled palette colors should be calculated from active one
+ \sa isAuto()
+ \internal
+*/
+void Style_PrefDlg::PaletteEditor::setAuto( bool on )
+{
+ myAutoCheck->setChecked( on );
+}
+
+/*!
+ \brief Initialize all palette colors from color \a c
+ \param c button color value
+ \internal
+*/
+void Style_PrefDlg::PaletteEditor::fromColor( const QColor& c )
+{
+ const QPalette pal = QPalette( c );
+ for ( int i = 0; i < (int)Style_Model::NColorRoles; i++ ) {
+ setColor( i,
+ pal.color( QPalette::Active, (QPalette::ColorRole)i ),
+ pal.color( QPalette::Inactive, (QPalette::ColorRole)i ),
+ pal.color( QPalette::Disabled, (QPalette::ColorRole)i ) );
+ }
+
+ // Header
+ setColor( Style_Model::Header,
+ pal.color( QPalette::Active, QPalette::Button ),
+ pal.color( QPalette::Inactive, QPalette::Button ),
+ pal.color( QPalette::Disabled, QPalette::Button ) );
+ // Checked
+ setColor( Style_Model::Checked,
+ pal.color( QPalette::Active, QPalette::Base ),
+ pal.color( QPalette::Inactive, QPalette::Base ),
+ pal.color( QPalette::Disabled, QPalette::Base ) );
+ // Lines
+ setColor( Style_Model::Lines,
+ pal.color( QPalette::Active, QPalette::Mid ),
+ pal.color( QPalette::Inactive, QPalette::Mid ),
+ pal.color( QPalette::Disabled, QPalette::Mid ) );
+ // Slider
+ setColor( Style_Model::Slider,
+ pal.color( QPalette::Active, QPalette::Button ),
+ pal.color( QPalette::Inactive, QPalette::Button ),
+ pal.color( QPalette::Disabled, QPalette::Button ) );
+ // ProgressBar
+ setColor( Style_Model::ProgressBar,
+ pal.color( QPalette::Active, QPalette::Highlight ),
+ pal.color( QPalette::Inactive, QPalette::Highlight ),
+ pal.color( QPalette::Disabled, QPalette::Highlight ) );
+ // FieldLight
+ setColor( Style_Model::FieldLight,
+ pal.color( QPalette::Active, QPalette::Light ),
+ pal.color( QPalette::Inactive, QPalette::Light ),
+ pal.color( QPalette::Disabled, QPalette::Light ) );
+ // FieldDark
+ setColor( Style_Model::FieldDark,
+ pal.color( QPalette::Active, QPalette::Mid ).light( 125 ),
+ pal.color( QPalette::Inactive, QPalette::Mid ).light( 125 ),
+ pal.color( QPalette::Disabled, QPalette::Mid ).light( 125 ) );
+ // GridLine
+ setColor( Style_Model::GridLine,
+ pal.color( QPalette::Active, QPalette::Mid ),
+ pal.color( QPalette::Inactive, QPalette::Mid ),
+ pal.color( QPalette::Disabled, QPalette::Mid ) );
+ // HighlightWidget
+ setColor( Style_Model::HighlightWidget,
+ pal.color( QPalette::Active, QPalette::Button ),
+ pal.color( QPalette::Inactive, QPalette::Button ),
+ pal.color( QPalette::Disabled, QPalette::Button ) );
+ // HighlightWidget
+ setColor( Style_Model::HighlightBorder,
+ pal.color( QPalette::Active, QPalette::Button ).dark( 100 ),
+ pal.color( QPalette::Inactive, QPalette::Button ).dark( 100 ),
+ pal.color( QPalette::Disabled, QPalette::Button ).dark( 100 ) );
+ // Pointer
+ setColor( Style_Model::Pointer, Qt::black, Qt::black, Qt::black );
+
+ QColor aDarkActive = pal.color( QPalette::Active, QPalette::Dark );
+ QColor aDarkInactive = pal.color( QPalette::Inactive, QPalette::Dark );
+ QColor aDarkDisabled = pal.color( QPalette::Disabled, QPalette::Dark );
+
+ // BorderTop
+ setColor( Style_Model::BorderTop,
+ aDarkActive.lighter(),
+ aDarkInactive.lighter(),
+ aDarkDisabled.lighter() );
+ // BorderBottom
+ setColor( Style_Model::BorderBottom,
+ aDarkActive.darker(),
+ aDarkInactive.darker(),
+ aDarkDisabled.darker() );
+ // TabBorderTop
+ setColor( Style_Model::TabBorderTop,
+ aDarkActive.light().light().light(),
+ aDarkInactive.light().light().light(),
+ aDarkDisabled.light().light().light() );
+ // TabBorderBottom
+ setColor( Style_Model::TabBorderBottom,
+ aDarkActive.dark().dark().dark(),
+ aDarkInactive.dark().dark().dark(),
+ aDarkDisabled.dark().dark().dark() );
+}
+
+/*!
+ \brief Get title of the item
+ \param id item identifier (Style_Model::ColorRole)
+ \return item title
+ \internal
+*/
+QString Style_PrefDlg::PaletteEditor::idToName( int id )
+{
+ QString name;
+ switch ( id ) {
+ case Style_Model::WindowText: // 0
+ name = tr( "Window text" ); break;
+ case Style_Model::Button: // 1
+ name = tr( "Button" ); break;
+ case Style_Model::Light: // 2
+ name = tr( "Light" ); break;
+ case Style_Model::Midlight: // 3
+ name = tr( "Midlight" ); break;
+ case Style_Model::Dark: // 4
+ name = tr( "Dark" ); break;
+ case Style_Model::Mid: // 5
+ name = tr( "Mid" ); break;
+ case Style_Model::Text: // 6
+ name = tr( "Text" ); break;
+ case Style_Model::BrightText: // 7
+ name = tr( "Bright text" ); break;
+ case Style_Model::ButtonText: // 8
+ name = tr( "Buttont text" ); break;
+ case Style_Model::Base: // 9
+ name = tr( "Base" ); break;
+ case Style_Model::Window: // 10
+ name = tr( "Window" ); break;
+ case Style_Model::Shadow: // 11
+ name = tr( "Shadow" ); break;
+ case Style_Model::Highlight: // 12
+ name = tr( "Highlight" ); break;
+ case Style_Model::HighlightedText: // 13
+ name = tr( "Highlighted text" ); break;
+ case Style_Model::Link: // 14
+ name = tr( "Link" ); break;
+ case Style_Model::LinkVisited: // 15
+ name = tr( "Visited link" ); break;
+ case Style_Model::AlternateBase: // 16
+ name = tr( "Alternate base" ); break;
+ case Style_Model::ToolTipBase: // 18
+ name = tr( "Tooltip base" ); break;
+ case Style_Model::ToolTipText: // 19
+ name = tr( "Tooltip text" ); break;
+ case Style_Model::BorderTop:
+ name = tr( "Border top" ); break;
+ case Style_Model::BorderBottom:
+ name = tr( "Border bottom" ); break;
+ case Style_Model::TabBorderTop:
+ name = tr( "Tab border top" ); break;
+ case Style_Model::TabBorderBottom:
+ name = tr( "Tab border bottom" ); break;
+ case Style_Model::FieldLight:
+ name = tr( "Field light" ); break;
+ case Style_Model::FieldDark:
+ name = tr( "Field dark" ); break;
+ case Style_Model::Slider:
+ name = tr( "Slider" ); break;
+ case Style_Model::Lines:
+ name = tr( "Lines" ); break;
+ case Style_Model::HighlightWidget:
+ name = tr( "Widget center" ); break;
+ case Style_Model::HighlightBorder:
+ name = tr( "Widget border" ); break;
+ case Style_Model::Header:
+ name = tr( "Header" ); break;
+ case Style_Model::ProgressBar:
+ name = tr( "Progress bar" ); break;
+ case Style_Model::Pointer:
+ name = tr( "Pointer" ); break;
+ case Style_Model::Checked:
+ name = tr( "Checked" ); break;
+ case Style_Model::GridLine:
+ name = tr( "Table grid" ); break;
+ default:
+ break;
+ }
+ return name;
+}
+
+/*!
+ \brief Create horizontal line widget
+ \return new line widget
+ \internal
+*/
+QWidget* Style_PrefDlg::PaletteEditor::line()
+{
+ QFrame* hline = new QFrame( myContainer );
+ hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
+ return hline;
+}
+
+/*!
+ \brief Called when "Quick" button is clicked
+ \internal
+*/
+void Style_PrefDlg::PaletteEditor::onQuick()
+{
+ static QColor lastColor = Qt::white;
+ QColor c = QColorDialog::getColor( lastColor, this );
+ if ( c.isValid() ) {
+ fromColor( lastColor = c );
+ emit( changed() );
+ }
+}
+
+/*!
+ \brief Called when "Auto" check box is clicked
+ \internal
+*/
+void Style_PrefDlg::PaletteEditor::onAuto()
+{
+ foreach( Btns btn, myButtons ) {
+ btn[ QPalette::Inactive ]->setEnabled( !myAutoCheck->isChecked() );
+ btn[ QPalette::Disabled ]->setEnabled( !myAutoCheck->isChecked() );
+ }
+ emit( changed() );
+}
+
+/*!
+ \class Style_PrefDlg
+ \brief SALOME style prefences dialog box class.
+
+ The dialog box lists all SALOME style themes available via the application and allows
+ user to create own schemas.
+*/
+
+/*!
+ \brief Constructor
+ \param parent parent widget
+*/
+Style_PrefDlg::Style_PrefDlg( QWidget* parent )
+ : QtxDialog( parent, true, true, OK | Close | Apply ),
+ myResMgr( 0 )
+{
+ // set title
+ setWindowTitle( tr( "SALOME style preferences" ) );
+
+ // create main layout
+ QVBoxLayout* main = new QVBoxLayout( mainFrame() );
+ main->setMargin( 0 ); main->setSpacing( SPACING );
+
+ // create main widgets
+ myStyleCheck = new QCheckBox( tr( "Use SALOME Style" ), this );
+ QFrame* fr = new QFrame( this );
+ fr->setFrameStyle( QFrame::Box | QFrame::Sunken );
+
+ main->addWidget( myStyleCheck );
+ main->addWidget( fr );
+
+ // create editor widgets
+ myStylesList = new QListWidget( fr );
+ myStylesTab = new QTabWidget( fr );
+
+ QHBoxLayout* frLayout = new QHBoxLayout( fr );
+ frLayout->setMargin( MARGIN ); frLayout->setSpacing( SPACING );
+ frLayout->addWidget( myStylesList );
+ frLayout->addWidget( myStylesTab );
+ frLayout->setStretchFactor( myStylesList, 1 );
+ frLayout->setStretchFactor( myStylesTab, 2 );
+
+ // ...
+ QWidget* w1 = new QWidget( myStylesTab );
+ QVBoxLayout* vLayout = new QVBoxLayout( w1 );
+ vLayout->setMargin( 0 ); vLayout->setSpacing( SPACING );
+
+ myPaletteEditor = new PaletteEditor( w1 );
+ vLayout->addWidget( myPaletteEditor );
+ vLayout->addStretch();
+
+ // ...
+ QWidget* w2 = new QWidget( myStylesTab );
+ vLayout = new QVBoxLayout( w2 );
+ vLayout->setMargin( MARGIN ); vLayout->setSpacing( SPACING );
+
+ QGroupBox* fontGroup = new QGroupBox( tr( "Font" ), w2 );
+ myFontEdit = new QtxFontEdit( fontGroup );
+
+ QHBoxLayout* fontLayout = new QHBoxLayout( fontGroup );
+ fontLayout->setMargin( MARGIN ); fontLayout->setSpacing( SPACING );
+ fontLayout->addWidget( myFontEdit );
+
+ QGroupBox* linesGroup = new QGroupBox( tr( "Lines" ), w2 );
+ QLabel* linesTypeLab = new QLabel( tr( "Type" ), linesGroup );
+ myLinesCombo = new QComboBox( linesGroup );
+ myLinesCombo->addItem( tr( "None" ), Style_Model::NoLines );
+ myLinesCombo->addItem( tr( "Horizontal" ), Style_Model::Horizontal );
+ myLinesCombo->addItem( tr( "Inclined" ), Style_Model::Inclined );
+ QLabel* linesTranspLab = new QLabel( tr( "Transparency" ), linesGroup );
+ myLinesTransparency = new QSlider( Qt::Horizontal, linesGroup );
+ myLinesTransparency->setMinimum( 0 );
+ myLinesTransparency->setMaximum( 100 );
+ myLinesTransparency->setSingleStep( 1 );
+ myLinesTransparency->setTracking( false );
+
+ QHBoxLayout* linesLayout = new QHBoxLayout( linesGroup );
+ linesLayout->setMargin( MARGIN ); linesLayout->setSpacing( SPACING );
+ linesLayout->addWidget( linesTypeLab );
+ linesLayout->addWidget( myLinesCombo );
+ linesLayout->addWidget( linesTranspLab );
+ linesLayout->addWidget( myLinesTransparency );
+
+ QGroupBox* roundGroup = new QGroupBox( tr( "Widgets rounding" ), w2 );
+ QLabel* roundButtonLab = new QLabel( tr( "Buttons" ), roundGroup );
+ myButtonRound = new QtxDoubleSpinBox( roundGroup );
+ QLabel* roundEditLab = new QLabel( tr( "Edit boxes" ), roundGroup );
+ myEditRound = new QtxDoubleSpinBox( roundGroup );
+ QLabel* roundFrameLab = new QLabel( tr( "Frames" ), roundGroup );
+ myFrameRound = new QtxDoubleSpinBox( roundGroup );
+ QLabel* roundSliderLab = new QLabel( tr( "Sliders" ), roundGroup );
+ mySliderRound = new QtxDoubleSpinBox( roundGroup );
+ myAntiAliasing = new QCheckBox( tr( "Anti-aliased borders" ), roundGroup );
+
+ QGridLayout* roundLayout = new QGridLayout( roundGroup );
+ roundLayout->setMargin( MARGIN ); roundLayout->setSpacing( SPACING );
+ roundLayout->addWidget( roundButtonLab, 0, 0 );
+ roundLayout->addWidget( myButtonRound, 0, 1 );
+ roundLayout->addWidget( roundEditLab, 0, 2 );
+ roundLayout->addWidget( myEditRound, 0, 3 );
+ roundLayout->addWidget( roundFrameLab, 1, 0 );
+ roundLayout->addWidget( myFrameRound, 1, 1 );
+ roundLayout->addWidget( roundSliderLab, 1, 2 );
+ roundLayout->addWidget( mySliderRound, 1, 3 );
+ roundLayout->addWidget( myAntiAliasing, 2, 0, 1, 4 );
+
+ QGroupBox* handleGroup = new QGroupBox( tr( "Handle" ), w2 );
+ QLabel* horHandleLab = new QLabel( tr( "Horizontal spacing" ), handleGroup );
+ myHorHandleDelta = new QSpinBox( handleGroup );
+ QLabel* verHandleLab = new QLabel( tr( "Vertical spacing" ), handleGroup );
+ myVerHandleDelta = new QSpinBox( handleGroup );
+ QLabel* splitterLengthLab = new QLabel( tr( "Splitter handle size" ), handleGroup );
+ mySplitterLength = new QSpinBox( handleGroup );
+ QLabel* sliderLengthLab = new QLabel( tr( "Slider handle size" ), handleGroup );
+ mySliderSize = new QSpinBox( handleGroup );
+
+ QGridLayout* handleLayout = new QGridLayout( handleGroup );
+ handleLayout->setMargin( MARGIN ); handleLayout->setSpacing( SPACING );
+ handleLayout->addWidget( horHandleLab, 0, 0 );
+ handleLayout->addWidget( myHorHandleDelta, 0, 1 );
+ handleLayout->addWidget( verHandleLab, 0, 2);
+ handleLayout->addWidget( myVerHandleDelta, 0, 3 );
+ handleLayout->addWidget( splitterLengthLab, 1, 0 );
+ handleLayout->addWidget( mySplitterLength, 1, 1 );
+ handleLayout->addWidget( sliderLengthLab, 1, 2 );
+ handleLayout->addWidget( mySliderSize, 1, 3 );
+
+ QGroupBox* effectGroup = new QGroupBox( tr( "Widget effect" ), w2 );
+ myEffectNone = new QRadioButton( tr( "None" ), effectGroup );
+ myEffectHighlight = new QRadioButton( tr( "Highlight widgets" ), effectGroup );
+ myEffectAutoRaise = new QRadioButton( tr( "Auto raise widgets" ), effectGroup );
+ QButtonGroup* aGroup = new QButtonGroup( w2 );
+ aGroup->addButton( myEffectNone );
+ aGroup->addButton( myEffectHighlight );
+ aGroup->addButton( myEffectAutoRaise );
+ myEffectNone->setChecked( true );
+ myCurrentEffect = myEffectNone;
+
+ QHBoxLayout* effectLayout = new QHBoxLayout( effectGroup );
+ effectLayout->setMargin( MARGIN ); effectLayout->setSpacing( SPACING );
+ effectLayout->addWidget( myEffectNone );
+ effectLayout->addWidget( myEffectHighlight );
+ effectLayout->addWidget( myEffectAutoRaise );
+
+ vLayout->addWidget( fontGroup );
+ vLayout->addWidget( linesGroup );
+ vLayout->addWidget( roundGroup );
+ vLayout->addWidget( handleGroup );
+ vLayout->addWidget( effectGroup );
+ vLayout->addStretch();
+
+ // ...
+ myStylesTab->addTab( w1, tr( "Colors" ) );
+ myStylesTab->addTab( w2, tr( "Properties" ) );
+
+ // initialize dialog box
+ setFocusProxy( fr );
+ setButtonPosition( Right, Close );
+ setDialogFlags( AlignOnce );
+ myStylesList->setEditTriggers( QAbstractItemView::EditKeyPressed );
+
+ QStringList globalStyles = resourceMgr()->styles( Style_ResourceMgr::Global );
+ QStringList userStyles = resourceMgr()->styles( Style_ResourceMgr::User );
+
+ QListWidgetItem* item;
+
+ // current style
+ item = new QListWidgetItem( tr( "[ Current ]" ) );
+ item->setForeground( QColor( Qt::red ) );
+ item->setData( TypeRole, QVariant( Current ) );
+ myStylesList->addItem( item );
+ // default style
+ item = new QListWidgetItem( tr( "[ Default ]" ) );
+ item->setForeground( QColor( Qt::green ) );
+ item->setData( TypeRole, QVariant( Default ) );
+ myStylesList->addItem( item );
+ // global styles
+ foreach ( QString sname, globalStyles ) {
+ item = new QListWidgetItem( sname );
+ item->setForeground( QColor( Qt::blue ) );
+ item->setData( TypeRole, QVariant( Global ) );
+ item->setData( NameRole, QVariant( sname ) );
+ myStylesList->addItem( item );
+ }
+ // user styles
+ foreach ( QString sname, userStyles ) {
+ item = new QListWidgetItem( sname );
+ item->setData( TypeRole, QVariant( User ) );
+ item->setData( NameRole, QVariant( sname ) );
+ item->setFlags( item->flags() | Qt::ItemIsEditable );
+ myStylesList->addItem( item );
+ }
+
+ // connect widgets
+ connect( myStyleCheck, SIGNAL( toggled( bool ) ), fr, SLOT( setEnabled( bool ) ) );
+ connect( myStylesList, SIGNAL( itemSelectionChanged() ), this, SLOT( onStyleChanged() ) );
+ connect( myStylesList, SIGNAL( itemChanged( QListWidgetItem* ) ),
+ this, SLOT( onItemChanged( QListWidgetItem* ) ) );
+ connect( myStylesList, SIGNAL( itemDoubleClicked( QListWidgetItem* ) ),
+ this, SLOT( onApply() ) );
+ connect( myLinesCombo, SIGNAL( activated( int ) ), this, SLOT( onLinesType() ) );
+ connect( myPaletteEditor, SIGNAL( changed() ), this, SIGNAL( styleChanged() ) );
+ connect( myFontEdit, SIGNAL( changed( QFont ) ), this, SIGNAL( styleChanged() ) );
+ connect( myLinesTransparency, SIGNAL( valueChanged( int ) ), this, SIGNAL( styleChanged() ) );
+ connect( myButtonRound, SIGNAL( valueChanged( double ) ), this, SIGNAL( styleChanged() ) );
+ connect( myEditRound, SIGNAL( valueChanged( double ) ), this, SIGNAL( styleChanged() ) );
+ connect( myFrameRound, SIGNAL( valueChanged( double ) ), this, SIGNAL( styleChanged() ) );
+ connect( mySliderRound, SIGNAL( valueChanged( double ) ), this, SIGNAL( styleChanged() ) );
+ connect( myAntiAliasing, SIGNAL( toggled( bool ) ), this, SIGNAL( styleChanged() ) );
+ connect( myHorHandleDelta, SIGNAL( valueChanged( int ) ), this, SIGNAL( styleChanged() ) );
+ connect( myVerHandleDelta, SIGNAL( valueChanged( int ) ), this, SIGNAL( styleChanged() ) );
+ connect( mySplitterLength, SIGNAL( valueChanged( int ) ), this, SIGNAL( styleChanged() ) );
+ connect( mySliderSize, SIGNAL( valueChanged( int ) ), this, SIGNAL( styleChanged() ) );
+ connect( aGroup, SIGNAL( buttonClicked( QAbstractButton* ) ),
+ this, SLOT( onEffectChanged( QAbstractButton* ) ) );
+ connect( this, SIGNAL( styleChanged() ), this, SLOT( onChanged() ) );
+
+ connect( this, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
+ connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
+
+ myStylesList->setCurrentRow( 0 );
+
+ myStyleCheck->setChecked( Style_Salome::isActive() );
+ fr->setEnabled( Style_Salome::isActive() );
+}
+
+/*!
+ \brief Destructor
+*/
+Style_PrefDlg::~Style_PrefDlg()
+{
+}
+
+/*!
+ \brief Called when "OK" button is clicked
+*/
+void Style_PrefDlg::accept()
+{
+ onApply();
+ QtxDialog::accept();
+}
+
+/*!
+ \brief Process key press event
+ \param e key event
+*/
+void Style_PrefDlg::keyPressEvent( QKeyEvent* e )
+{
+ if ( e->key() == Qt::Key_Delete ) {
+ QListWidgetItem* item = myStylesList->currentItem();
+ if ( item && item->data( TypeRole ).toInt() == User ) {
+ if ( QMessageBox::question( this,
+ tr( "Delete user theme" ),
+ tr( "Remove theme %1?" ).arg( item->text() ),
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::Yes ) == QMessageBox::Yes ) {
+ resourceMgr()->remove( item->data( NameRole ).toString() );
+ resourceMgr()->save();
+ delete item;
+ }
+ }
+ }
+ QtxDialog::keyPressEvent( e );
+}
+
+/*!
+ \brief Get SALOME themes resource manager
+ \return themes resource manager
+*/
+Style_ResourceMgr* Style_PrefDlg::resourceMgr()
+{
+ if ( !myResMgr )
+ myResMgr = new Style_ResourceMgr();
+ return myResMgr;
+}
+
+/*!
+ \brief Initialize dialog box fields from SALOME style model
+ \param model style model
+*/
+void Style_PrefDlg::fromModel( Style_Model* model )
+{
+ if ( !model ) return;
+
+ // colors
+ for ( int i = (int)Style_Model::WindowText; i < (int)Style_Model::LastColor; i++ ) {
+ if ( i == Style_Model::NoRole ) continue;
+ myPaletteEditor->setColor( i, QPalette::Active, model->color( (Style_Model::ColorRole)i, QPalette::Active ) );
+ myPaletteEditor->setColor( i, QPalette::Inactive, model->color( (Style_Model::ColorRole)i, QPalette::Inactive ) );
+ myPaletteEditor->setColor( i, QPalette::Disabled, model->color( (Style_Model::ColorRole)i, QPalette::Disabled ) );
+ }
+ myPaletteEditor->setAuto( model->isAutoPalette() );
+ // font
+ myFontEdit->setCurrentFont( model->applicationFont() );
+ // lines type
+ int idx = myLinesCombo->findData( QVariant( model->linesType() ) );
+ if ( idx >= 0 ) myLinesCombo->setCurrentIndex( idx );
+ // lines transparency
+ myLinesTransparency->setValue( model->linesTransparency() );
+ // widgets rounding
+ myButtonRound->setValue( model->widgetRounding( Style_Model::ButtonRadius ) );
+ myEditRound->setValue( model->widgetRounding( Style_Model::EditRadius ) );
+ myFrameRound->setValue( model->widgetRounding( Style_Model::FrameRadius ) );
+ mySliderRound->setValue( model->widgetRounding( Style_Model::SliderRadius ) );
+ // widgets antialiasing
+ myAntiAliasing->setChecked( model->antialiasing() );
+ // handle delta
+ myHorHandleDelta->setValue( model->handleDelta( Qt::Horizontal ) );
+ myVerHandleDelta->setValue( model->handleDelta( Qt::Vertical ) );
+ // splitter handle lentgh
+ mySplitterLength->setValue( model->splitHandleLength() );
+ // slider size
+ mySliderSize->setValue( model->sliderSize() );
+ // widgets effect
+ Style_Model::WidgetEffect we = model->widgetEffect();
+ if ( we == Style_Model::HighlightEffect ) myEffectHighlight->setChecked( true );
+ else if ( we == Style_Model::AutoRaiseEffect ) myEffectAutoRaise->setChecked( true );
+ else myEffectNone->setChecked( true );
+}
+
+/*!
+ \brief Save values from dialog box fields to SALOME style model
+ \param model style model
+*/
+void Style_PrefDlg::toModel( Style_Model* model ) const
+{
+ if ( !model ) return;
+
+ // colors
+ // ... first set Button color 'cause it is used to calculate other ones
+ if ( myPaletteEditor->isAuto() )
+ model->setColor( Style_Model::Button,
+ myPaletteEditor->color( Style_Model::Button, QPalette::Active ) );
+ else
+ model->setColor( Style_Model::Button,
+ myPaletteEditor->color( Style_Model::Button, QPalette::Active ),
+ myPaletteEditor->color( Style_Model::Button, QPalette::Inactive ),
+ myPaletteEditor->color( Style_Model::Button, QPalette::Disabled ));
+ // ... then set all other colors
+ for ( int i = (int)Style_Model::WindowText; i < (int)Style_Model::LastColor; i++ ) {
+ if ( i == Style_Model::NoRole ) continue; // not supported
+ if ( i == Style_Model::Button ) continue; // already set
+ if ( myPaletteEditor->isAuto() )
+ model->setColor( (Style_Model::ColorRole)i,
+ myPaletteEditor->color( i, QPalette::Active ) );
+ else
+ model->setColor( (Style_Model::ColorRole)i,
+ myPaletteEditor->color( i, QPalette::Active ),
+ myPaletteEditor->color( i, QPalette::Inactive ),
+ myPaletteEditor->color( i, QPalette::Disabled ));
+ }
+ model->setAutoPalette( myPaletteEditor->isAuto() ); // internal
+ // font
+ model->setApplicationFont( myFontEdit->currentFont() );
+ // lines type
+ model->setLinesType( (Style_Model::LineType)myLinesCombo->itemData( myLinesCombo->currentIndex() ).toInt() );
+ // lines transparency
+ model->setLinesTransparency( myLinesTransparency->value() );
+ // widgets rounding
+ model->setWidgetRounding( Style_Model::ButtonRadius, myButtonRound->value() );
+ model->setWidgetRounding( Style_Model::EditRadius, myEditRound->value() );
+ model->setWidgetRounding( Style_Model::FrameRadius, myFrameRound->value() );
+ model->setWidgetRounding( Style_Model::SliderRadius, mySliderRound->value() );
+ // widgets antialiasing
+ model->setAntialiasing( myAntiAliasing->isChecked() );
+ // handle delta
+ model->setHandleDelta( Qt::Horizontal, myHorHandleDelta->value() );
+ model->setHandleDelta( Qt::Vertical, myVerHandleDelta->value() );
+ // splitter handle lentgh
+ model->setSplitHandleLength( mySplitterLength->value() );
+ // slider size
+ model->setSliderSize( mySliderSize->value() );
+ // widgets effect
+ if ( myEffectHighlight->isChecked() ) model->setWidgetEffect( Style_Model::HighlightEffect );
+ else if ( myEffectAutoRaise->isChecked() ) model->setWidgetEffect( Style_Model::AutoRaiseEffect );
+ else model->setWidgetEffect( Style_Model::NoEffect );
+}
+
+/*!
+ \brief Find unique name for the theme name
+ \param name theme name template
+ \param item if not 0, used to be ignored when browsing through items list
+ \param addSuffix if \c true, the integrer suffix is always added to the theme name (otherwise
+ suffix is added only if item name is not unique)
+ \return new unique theme name
+*/
+QString Style_PrefDlg::findUniqueName( const QString& name, QListWidgetItem* item, bool addSuffix )
+{
+ bool found = false;
+ int idx = 0;
+ for( int i = 2; i < myStylesList->count(); i++ ) {
+ if ( item == myStylesList->item( i ) ) continue;
+ QString iname = myStylesList->item( i )->text();
+ if ( iname == name ) {
+ found = true;
+ }
+ else {
+ iname = iname.mid( name.length() ).trimmed();
+ bool ok = false;
+ int nx = iname.toInt( &ok );
+ if ( ok ) idx = qMax( idx, nx );
+ }
+ }
+ return found || addSuffix ? QString( "%1 %2" ).arg( name ).arg( idx+1 ) : name;
+}
+
+/*!
+ \brief Called when "Apply" button is pressed
+*/
+void Style_PrefDlg::onApply()
+{
+ // save user schemas
+ resourceMgr()->save();
+ // set selected schema as current
+ if ( myStylesList->currentRow() >= 0 ) {
+ Style_Model* model = Style_Salome::model();
+ toModel( model );
+ model->save();
+ Style_Salome::update();
+ if ( myStyleCheck->isChecked() )
+ Style_Salome::apply();
+ else
+ Style_Salome::restore();
+ }
+}
+
+/*!
+ \brief Called when "Help" button is pressed
+*/
+void Style_PrefDlg::onHelp()
+{
+}
+
+/*!
+ \brief Called when user selects any theme item in the themes list
+*/
+void Style_PrefDlg::onStyleChanged()
+{
+ blockSignals( true );
+
+ QListWidgetItem* item = myStylesList->currentItem();
+ int type = item->data( TypeRole ).toInt();
+
+ Style_Model* model = 0;
+
+ switch ( type ) {
+ case Current:
+ // current style
+ model = Style_Salome::model();
+ break;
+ case Default:
+ // default style
+ model = new Style_Model();
+ break;
+ case Global:
+ case User:
+ // global style, user style
+ model = new Style_Model();
+ model->fromResources( resourceMgr(), item->data( NameRole ).toString() );
+ break;
+ default:
+ break;
+ }
+
+ fromModel( model );
+ if ( type != Current )
+ delete model;
+
+ onLinesType();
+
+ blockSignals( false );
+}
+
+/*!
+ \brief Called when lines type is changed
+*/
+void Style_PrefDlg::onLinesType()
+{
+ myLinesTransparency->setEnabled( myLinesCombo->itemData( myLinesCombo->currentIndex() ) != Style_Model::NoLines );
+ emit( styleChanged() );
+}
+
+/*!
+ \brief Called when any style parameter is changed by the user
+*/
+void Style_PrefDlg::onChanged()
+{
+ QListWidgetItem* item = myStylesList->currentItem();
+ int type = item->data( TypeRole ).toInt();
+
+ // for the current and user schemas do not perform any actions
+ if ( type == Current ) {
+ Style_Model model = *( Style_Salome::model() );
+ toModel( &model );
+ model.save();
+ blockSignals( true );
+ fromModel( &model );
+ blockSignals( false );
+ }
+ else if ( type == User ) {
+ Style_Model model;
+ toModel( &model );
+ QString oldName = item->data( NameRole ).toString(), newName = item->text();
+ if ( oldName == newName ) {
+ model.save( resourceMgr(), oldName );
+ }
+ else {
+ resourceMgr()->remove( oldName );
+ model.save( resourceMgr(), newName );
+ item->setData( NameRole, newName );
+ }
+ blockSignals( true );
+ fromModel( &model );
+ blockSignals( false );
+ }
+ else {
+ // if user tries to change global (or default) schema, we create new user schema basing on selected one
+ QString newName = findUniqueName( tr( "Custom schema" ), 0, true );
+ item = new QListWidgetItem( newName );
+ item->setData( TypeRole, QVariant( User ) );
+ item->setData( NameRole, QVariant( newName ) );
+ item->setFlags( item->flags() | Qt::ItemIsEditable );
+ myStylesList->addItem( item );
+
+ Style_Model model;
+ toModel( &model );
+ model.save( resourceMgr(), newName );
+
+ myStylesList->setCurrentItem( item );
+ }
+}
+
+/*!
+ \brief Called when user theme is renamed by the user
+*/
+void Style_PrefDlg::onItemChanged( QListWidgetItem* item )
+{
+ QString newName = item->text();
+ QString uniqueName = findUniqueName( newName, item );
+ if ( uniqueName != newName ) {
+ myStylesList->blockSignals( true );
+ item->setText( uniqueName );
+ myStylesList->blockSignals( false );
+ }
+ onChanged();
+}
+
+/*!
+ \brief Called when widget effect is changed
+*/
+void Style_PrefDlg::onEffectChanged( QAbstractButton* rb )
+{
+ if ( rb != myCurrentEffect )
+ emit( styleChanged() );
+ myCurrentEffect = qobject_cast<QRadioButton*>( rb );
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : Style_PrefDlg.h
+// Author : Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com)
+//
+
+#ifndef STYLE_PREFDLG_H
+#define STYLE_PREFDLG_H
+
+#include "Style.h"
+
+#include <QtxDialog.h>
+#include <QFrame>
+#include <QMap>
+
+class QCheckBox;
+class QComboBox;
+class QLabel;
+class QListWidget;
+class QListWidgetItem;
+class QPushButton;
+class QRadioButton;
+class QSlider;
+class QSpinBox;
+class QTabWidget;
+class QtxColorButton;
+class QtxDoubleSpinBox;
+class QtxFontEdit;
+class Style_ResourceMgr;
+class Style_Model;
+
+class STYLE_SALOME_EXPORT Style_PrefDlg : public QtxDialog
+{
+ Q_OBJECT
+
+ class PaletteEditor;
+ enum { Current, Default, Global, User };
+ enum { TypeRole = Qt::UserRole + 123, NameRole };
+
+public:
+ Style_PrefDlg( QWidget* = 0 );
+ ~Style_PrefDlg();
+
+ void accept();
+
+protected:
+ void keyPressEvent( QKeyEvent* );
+
+private:
+ Style_ResourceMgr* resourceMgr();
+ void fromModel( Style_Model* );
+ void toModel( Style_Model* ) const;
+
+ QString findUniqueName( const QString&, QListWidgetItem* = 0, bool = false );
+
+signals:
+ void styleChanged();
+
+private slots:
+ void onApply();
+ void onHelp();
+
+ void onStyleChanged();
+ void onLinesType();
+ void onChanged();
+ void onItemChanged( QListWidgetItem* );
+ void onEffectChanged( QAbstractButton* );
+
+private:
+ Style_ResourceMgr* myResMgr;
+ QCheckBox* myStyleCheck;
+ QListWidget* myStylesList;
+ QTabWidget* myStylesTab;
+
+ PaletteEditor* myPaletteEditor;
+ QtxFontEdit* myFontEdit;
+ QComboBox* myLinesCombo;
+ QSlider* myLinesTransparency;
+ QtxDoubleSpinBox* myEditRound;
+ QtxDoubleSpinBox* myButtonRound;
+ QtxDoubleSpinBox* myFrameRound;
+ QtxDoubleSpinBox* mySliderRound;
+ QCheckBox* myAntiAliasing;
+ QSpinBox* myHorHandleDelta;
+ QSpinBox* myVerHandleDelta;
+ QSpinBox* mySplitterLength;
+ QSpinBox* mySliderSize;
+ QRadioButton* myEffectNone;
+ QRadioButton* myEffectHighlight;
+ QRadioButton* myEffectAutoRaise;
+
+ QRadioButton* myCurrentEffect;
+};
+
+class Style_PrefDlg::PaletteEditor : public QFrame
+{
+ Q_OBJECT
+
+public:
+ PaletteEditor( QWidget* = 0 );
+ ~PaletteEditor();
+
+ void addColumn( const QString& );
+ void addItem( int );
+ QList<int> items() const;
+
+ void setColor( int, QPalette::ColorGroup, const QColor& );
+ void setColor( int, const QColor&, const QColor& = QColor(), const QColor& = QColor() );
+ QColor color( int, QPalette::ColorGroup ) const;
+
+ bool isAuto() const;
+ void setAuto( bool );
+
+ void fromColor( const QColor& );
+
+private:
+ static QString idToName( int );
+ QWidget* line();
+
+private slots:
+ void onQuick();
+ void onAuto();
+
+signals:
+ void changed();
+
+private:
+ typedef QMap<QPalette::ColorGroup, QtxColorButton*> Btns;
+
+ QFrame* myContainer;
+ QPushButton* myQuickButton;
+ QCheckBox* myAutoCheck;
+ QLabel* myActiveLab;
+ QLabel* myInactiveLab;
+ QLabel* myDisabledLab;
+
+ QMap<int, Btns> myButtons;
+ int myCurrentRow;
+ int myCurrentColumn;
+
+ friend class Style_PrefDlg;
+};
+
+#endif // STYLE_PREFDLG_H
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : Style_ResourceMgr.cxx
+// Author : Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com)
+//
+
+#include "Style_ResourceMgr.h"
+
+/*!
+ \class Style_ResourceMgr
+ \brief SALOME style resources manager.
+
+ This class is used to manage the SALOME style themes throughout the application
+ in the similar way as QtxResourceMgr does it with application preferences.
+
+ Standard SALOME themes are stored in the global application settings files
+ (named as SalomeStyle.xml). User-defined themes are stored in user's home
+ directory - in the file .SalomeStylerc.
+
+ The Style_ResourceMgr class is used by SALOME style preferences dialog box
+ (Style_PrefDlg class).
+*/
+
+/*!
+ \brief Constructor
+*/
+Style_ResourceMgr::Style_ResourceMgr()
+ : QtxResourceMgr( "SalomeStyle", "%1Config" )
+{
+ if ( dirList().isEmpty() && ::getenv( "GUI_ROOT_DIR" ) )
+ setDirList( QStringList() << Qtx::addSlash( ::getenv( "GUI_ROOT_DIR" ) ) + "share/salome/resources/gui" );
+ setCurrentFormat( "xml" );
+}
+
+/*!
+ \brief Destructor
+*/
+Style_ResourceMgr::~Style_ResourceMgr()
+{
+}
+
+/*!
+ \brief Get list of avaiable SALOME themes
+ \param type themes type
+ \param sort if \c true (default), returns a list of themes sorted by name
+ \return list of avaiable themes names
+*/
+QStringList Style_ResourceMgr::styles( StyleType type, bool sort )
+{
+ QStringList sl;
+
+ WorkingMode m = workingMode();
+
+ switch ( type ) {
+ case Global:
+ setWorkingMode( IgnoreUserValues );
+ sl = sections();
+ break;
+ case User:
+ {
+ setWorkingMode( AllowUserValues );
+ sl = sections();
+ setWorkingMode( IgnoreUserValues );
+ QMutableListIterator<QString> it( sl );
+ while ( it.hasNext() ) {
+ QString s = it.next();
+ if ( hasSection( s ) ) it.remove();
+ }
+ }
+ break;
+ case All:
+ setWorkingMode( AllowUserValues );
+ sl = sections();
+ break;
+ default:
+ break;
+ }
+
+ setWorkingMode( m );
+
+ if ( sort )
+ qSort( sl );
+
+ return sl;
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : Style_ResourceMgr.h
+// Author : Vadim SANDLER, Open CASCADE S.A.S (vadim.sandler@opencascade.com)
+//
+
+#ifndef STYLE_RESOURCEMGR_H
+#define STYLE_RESOURCEMGR_H
+
+#include <QtxResourceMgr.h>
+
+//
+// This class is private for Style package.
+// Normally it should not be exported.
+//
+class Style_ResourceMgr : public QtxResourceMgr
+{
+public:
+ //! Style type
+ typedef enum {
+ Global, //!< Global styles
+ User, //!< User styles
+ All //!< All style
+ } StyleType;
+
+ Style_ResourceMgr();
+ ~Style_ResourceMgr();
+
+ QStringList styles( StyleType = All, bool = true );
+};
+
+#endif // STYLE_RESOURCEMGR_H
#include <QApplication>
#include <QPainter>
#include <QMap>
-#include <QVariant>
#include <QPainterPath>
#include <QWidget>
#include <QComboBox>
#include <QScrollBar>
#include <QSlider>
#include <QMainWindow>
+#include <QPixmapCache>
+
+#include <limits.h>
#define SHADOW 1
#define LINE_GR_MARGIN 10
///////////////////////////////////////////////////////////
// FOR debug purposes only!!!
//
-const int DEBUG_LEVEL = 0;
+int DEBUG_LEVEL = 0;
static bool checkDebugLevel( int level )
{
- return DEBUG_LEVEL == level;
+ return DEBUG_LEVEL == level || DEBUG_LEVEL == -1;
}
//
///////////////////////////////////////////////////////////
+Style_Model* Style_Salome::myModel = 0;
+
+/*!
+ \class Style_Salome
+ \brief 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:
+ \code
+ Style_Salome::initialize( resourceMgr() ); // initialize SALOME style from resources
+ if ( needSalomeStyle ) Style_Salome::apply(); // set SALOME style to the application
+ \endcode
+
+ Style_PrefDlg class can be then used to change style properties, select one of the
+ predefined style themes or even create user themes:
+ \code
+ Style_PrefDlg dlg( desktop() );
+ dlg.exec();
+ \endcode
+*/
+
+/*!
+ \brief Constructor
+
+ Use Style_Salome::apply() static function to set SALOME style to the application.
+*/
Style_Salome::Style_Salome()
: QWindowsStyle()
{
- Q_INIT_RESOURCE(Style);
+ // initialize SALOME style resources
+ Q_INIT_RESOURCE( Style );
+}
+
+/*!
+ \brief Destructor
+*/
+Style_Salome::~Style_Salome()
+{
+}
+
+
+/*!
+ \brief Initialize SALOME style.
- myModel = new Style_Model();
- myModel->setDefaults( qApp );
+ 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.
- QPalette ttipPal = QToolTip::palette(); // from current system
- myTTipWnd = ttipPal.color( QPalette::Window );
- myTTipText = ttipPal.color( QPalette::Text );
+ If the parameter \a resMgr is not 0, the style is initialized from the
+ resources manager.
+
+ The parameter \a section allows customizing of the resources file section
+ used to store style's properties. By default "Theme" section name is used.
+
+ \param resMgr resources manager
+ \param section resources file section name
+ \sa apply(), restore()
+*/
+void Style_Salome::initialize( QtxResourceMgr* resMgr, const QString& section )
+{
+ model()->fromResources( resMgr, section );
}
-Style_Salome::~Style_Salome()
+/*!
+ \brief Set SALOME style to the application
+ \sa initialize(), restore()
+*/
+void Style_Salome::apply()
{
+ // application object is not created yet
+ if ( !QApplication::instance() )
+ return;
+
+ // update model (from the resources manager if needed)
+ model()->update();
+
+ // check if SALOME style is already set to the application
+ if ( !isActive() ) {
+ // set SALOME style
+ QApplication::style()->setParent( 0 ); // avoid deleting original application style
+ QApplication::setStyle( new Style_Salome() ); // set style
+ }
+ update(); // update style
}
-Style_Model* Style_Salome::getModel() const
+/*!
+ \brief Restore original style to the application
+ \sa initialize(), apply()
+*/
+void Style_Salome::restore()
{
- return myModel;
+ // application object is not created yet
+ if ( !QApplication::instance() )
+ return;
+ // check if SALOME style is set to the application
+ if ( !isActive() )
+ return;
+ // restore previous style
+ model()->restore();
+}
+
+/*!
+ \brief Check if the SALOME style is currently set to application.
+ \return \c true if SALOME style is set to the applcation or \c false otherwise
+*/
+bool Style_Salome::isActive()
+{
+ return QApplication::instance() != 0 && qobject_cast<Style_Salome*>( QApplication::style() ) != 0;
}
-void Style_Salome::updateSettings( QApplication* app )
+/*!
+ \brief Update style from resources.
+*/
+void Style_Salome::update()
{
- updatePaletteColors();
- QFont aFont = myModel->getFontValue( Style_Model::font_value );
- app->setFont( aFont );
- updateAllWidgets( app );
+ // application object is not created yet
+ if ( !QApplication::instance() )
+ return;
+ // check if SALOME style is set to the application
+ if ( Style_Salome* style = qobject_cast<Style_Salome*>( QApplication::style() ) )
+ style->polish( qobject_cast<QApplication*>( QApplication::instance() ) );
+}
+
+/*!
+ \brief Get style model
+ \return style model
+*/
+Style_Model* Style_Salome::model()
+{
+ if ( !myModel )
+ myModel = new Style_Model();
+ return myModel;
}
+/*!
+ \brief Initialize the appearance of the application.
+
+ Performs late initialization of the given application object.
+
+ \param app application object
+*/
void Style_Salome::polish ( QApplication* app )
{
+ QWindowsStyle::polish( app );
+
if ( checkDebugLevel(1) ) {
- QWindowsStyle::polish( app );
return;
}
- QWindowsStyle::polish( app );
- updateSettings( app );
+ updatePaletteColors();
+ app->setFont( model()->applicationFont() );
+ updateAllWidgets( app );
}
+/*!
+ \brief 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.
+
+ \param w widget object
+*/
void Style_Salome::polish ( QWidget* w )
{
if ( checkDebugLevel(2) ) {
return;
}
- if ( !w )
- return;
if ( w && hasHover() ) {
- if ( qobject_cast<QPushButton*>(w) || qobject_cast<QToolButton*>(w) ||
- qobject_cast<QCheckBox*>(w) || qobject_cast<QRadioButton*>(w) ||
- qobject_cast<QComboBox*>(w) || qobject_cast<QAbstractSpinBox*>(w) ||
- qobject_cast<QLineEdit*>(w) || qobject_cast<QScrollBar*>(w) ||
- qobject_cast<QTabBar*>(w) || qobject_cast<QSlider*>(w) ||
- qobject_cast<QMenuBar*>(w) || qobject_cast<QDockWidget*>(w) )
+ if ( qobject_cast<QPushButton*>(w) || qobject_cast<QToolButton*>(w) ||
+ qobject_cast<QCheckBox*>(w) || qobject_cast<QRadioButton*>(w) ||
+ qobject_cast<QComboBox*>(w) || qobject_cast<QAbstractSpinBox*>(w) ||
+ qobject_cast<QLineEdit*>(w) || qobject_cast<QScrollBar*>(w) ||
+ qobject_cast<QTabBar*>(w) || qobject_cast<QSlider*>(w) ||
+ qobject_cast<QMenuBar*>(w) || qobject_cast<QDockWidget*>(w) )
w->setAttribute( Qt::WA_Hover );
}
+
QWindowsStyle::polish( w );
}
+/*!
+ \brief 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.
+
+ \param w widget object
+*/
void Style_Salome::unpolish( QWidget* w )
{
if ( checkDebugLevel(3) ) {
qobject_cast<QMenuBar*>(w) || qobject_cast<QDockWidget*>(w) )
w->setAttribute( Qt::WA_Hover, false );
}
+
QWindowsStyle::unpolish( w );
}
+/*!
+ \brief Draws the given control using the provided painter \p with the style options specified by \a opt.
+ \param cc complex control type
+ \param opt style option
+ \param p painter
+ \param w widget
+*/
void Style_Salome::drawComplexControl( ComplexControl cc, const QStyleOptionComplex* opt,
QPainter* p, const QWidget* w ) const
{
bool hover = hasHover() && (opt->state & State_Enabled) && (opt->state & State_MouseOver);
QRect optr = opt->rect, arUp = subControlRect( cc, spin, SC_SpinBoxUp, w );
optr.setWidth( arUp.x()-optr.x()+1 );
- double aRad = getDblValue( Style_Model::edit_rad );
- bool antialized = getBoolValue( Style_Model::all_antialized );
- QColor aBrdTopCol = getColor( Style_Model::border_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_bot_clr );
+ double aRad = model()->widgetRounding( Style_Model::EditRadius );
+ bool antialized = model()->antialiasing();
+ QColor aBrdTopCol = model()->color( Style_Model::BorderTop ); // Style_Model::border_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::BorderBottom ); // Style_Model::border_bot_clr
if ( hover )
drawHoverRect(p, optr, opt->palette.color( QPalette::Window ), aRad, Style_Tools::Left, true);
else
Style_Tools::shadowRect( p, optr, aRad, LINE_GR_MARGIN, SHADOW, Style_Tools::Left,
- getColor( Style_Model::fld_light_clr ),
- getColor( Style_Model::fld_dark_clr ), aBrdTopCol,
- aBrdBotCol, antialized, false );
+ model()->color( Style_Model::FieldLight ), // Style_Model::fld_light_clr,
+ model()->color( Style_Model::FieldDark ), // Style_Model::fld_dark_clr,
+ aBrdTopCol, aBrdBotCol, antialized, false );
QRect aBtnRect = QRect( QPoint( arUp.x(), optr.y() ), QPoint( arUp.right(), optr.bottom() ) );
QColor aBtnCol = opt->palette.color( QPalette::Button );
bool aStateOn = opt->state & ( State_Sunken | State_On );
optr.setY( ar.y() );
optr.setHeight( ar.height() );
optr.setWidth( ar.x()-optr.x()+1 );
- bool antialized = getBoolValue( Style_Model::all_antialized );
- double aRad = getDblValue( Style_Model::edit_rad );
- QColor aBrdTopCol = getColor( Style_Model::border_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_bot_clr );
+ bool antialized = model()->antialiasing();
+ double aRad = model()->widgetRounding( Style_Model::EditRadius );
+ QColor aBrdTopCol = model()->color( Style_Model::BorderTop ); // Style_Model::border_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::BorderBottom ); // Style_Model::border_bot_clr
if ( hover )
drawHoverRect(p, optr, opt->palette.color( QPalette::Window ), aRad, Style_Tools::Left, true);
else
Style_Tools::shadowRect( p, optr, aRad, LINE_GR_MARGIN, SHADOW, Style_Tools::Left,
- getColor( Style_Model::fld_light_clr ),
- getColor( Style_Model::fld_dark_clr ), aBrdTopCol,
- aBrdBotCol, antialized, false );
+ model()->color( Style_Model::FieldLight ), // Style_Model::fld_light_clr,
+ model()->color( Style_Model::FieldDark ), // Style_Model::fld_dark_clr,
+ aBrdTopCol, aBrdBotCol, antialized, false );
if (cmb->subControls & SC_ComboBoxArrow) {
State flags = State_None;
QColor aBtnCol = opt->palette.color( QPalette::Button );
(slider->state & State_MouseOver) ) {
QRect moderated = w->rect();
drawHoverRect(p, moderated, opt->palette.color( QPalette::Window ),
- getDblValue( Style_Model::btn_rad ), Style_Tools::All, false);
+ model()->widgetRounding( Style_Model::ButtonRadius ), Style_Tools::All, false);
}
if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
bool horiz = slider->orientation == Qt::Horizontal;
bool tickAbove = slider->tickPosition == QSlider::TicksAbove;
bool tickBelow = slider->tickPosition == QSlider::TicksBelow;
- QColor aBtnCol = getColor( Style_Model::slider_clr ),
- aBrdTopCol = getColor( Style_Model::border_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_bot_clr );
+ QColor aBtnCol = model()->color( Style_Model::Slider ); // Style_Model::slider_clr
+ QColor aBrdTopCol = model()->color( Style_Model::BorderTop ); // Style_Model::border_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::BorderBottom ); // Style_Model::border_bot_clr
// rect was changed on +/-DELTA_SLIDER value for correct painting Antialised border of slider
int aDelta = DELTA_SLIDER-1;
QRect slRect = QRect(x+aDelta, y+aDelta, wi-aDelta, he-aDelta);
slRect.setRight( slRect.right()+aXAdd );
}
}
- Style_Tools::drawSlider( p, slRect, getDblValue( Style_Model::slider_rad ), type,
+ Style_Tools::drawSlider( p, slRect, model()->widgetRounding( Style_Model::SliderRadius ), type,
aBtnCol.light( BUT_PERCENT_COL ),
aBtnCol.dark( BUT_PERCENT_COL ), aBrdTopCol, aBrdBotCol );
QRect aHRect = handle;
QWindowsStyle::drawComplexControl( cc, opt, p, w );
return;
}
- int aMinDelta = (int)getDblValue( Style_Model::btn_rad );
+ int aMinDelta = (int)model()->widgetRounding( Style_Model::ButtonRadius );
if ( !toolbutton->icon.isNull() )
aMinDelta = Style_Tools::getMinDelta( toolbutton->rect, toolbutton->iconSize, aMinDelta );
bool aStateOn = opt->state & ( State_Sunken | State_On );
top = aBtnCol.light( BUT_PERCENT_COL ),
bottom = aBtnCol.dark( BUT_PERCENT_COL );
bool isMenuBtn = toolbutton->features == QStyleOptionToolButton::Menu;
- bool antialized = getBoolValue( Style_Model::all_antialized );
- bool isAutoRaising = getBoolValue( Style_Model::auto_raising_wdg );
- bool isHighWdg = getBoolValue( Style_Model::highlight_wdg );
+ bool antialized = model()->antialiasing();
+ bool isAutoRaising = model()->widgetEffect() == Style_Model::AutoRaiseEffect;
+ bool isHighWdg = model()->widgetEffect() == Style_Model::HighlightEffect;
bool hover = hasHover() && (opt->state & State_Enabled) && ( opt->state & State_MouseOver );
- QColor aBrdTopCol = getColor( Style_Model::border_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_bot_clr );
+ QColor aBrdTopCol = model()->color( Style_Model::BorderTop ); // Style_Model::border_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::BorderBottom ); // Style_Model::border_bot_clr
QRect aRect = button;
int aType = isMenuBtn ? Style_Tools::Left : Style_Tools::All;
if ( toolbutton->subControls & SC_ToolButton ) {
QRect checkBoxRect = subControlRect( cc, opt, SC_GroupBoxCheckBox, w);
if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
QRect aRect = subControlRect( cc, opt, SC_GroupBoxFrame, w);
- QColor aBrdTopCol = getColor( Style_Model::border_tab_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_tab_bot_clr );
- Style_Tools::shadowRect( p, aRect, getDblValue( Style_Model::frame_rad ), 0.,
+ QColor aBrdTopCol = model()->color( Style_Model::TabBorderTop ); // Style_Model::border_tab_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::TabBorderBottom ); // Style_Model::border_tab_bot_clr
+ Style_Tools::shadowRect( p, aRect, model()->widgetRounding( Style_Model::FrameRadius ), 0.,
SHADOW, Style_Tools::All,
- getColor( Style_Model::fld_light_clr ),
- getColor( Style_Model::fld_dark_clr ), aBrdTopCol,
- aBrdBotCol, false, false, false, false);
+ model()->color( Style_Model::FieldLight ), // Style_Model::fld_light_clr
+ model()->color( Style_Model::FieldDark ), // Style_Model::fld_dark_clr
+ aBrdTopCol, aBrdBotCol, false, false, false, false);
}
// Draw title
if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
}
}
+/*!
+ \brief Draws the given element with the provided painter \p with the style options specified by \a opt.
+ \param ce control element type
+ \param opt style option
+ \param p painter
+ \param w widget
+*/
void Style_Salome::drawControl( ControlElement ce, const QStyleOption* opt,
QPainter* p, const QWidget* w ) const
{
drawControl(CE_PushButtonLabel, &subopt, p, w);
if (btn->state & State_HasFocus) {
QRect aRect = subElementRect( SE_PushButtonFocusRect, btn, w );
- Style_Tools::drawFocus( p, aRect, getDblValue(Style_Model:: btn_rad ),
- Style_Tools::All, getColor( Style_Model::border_bot_clr ) );
+ Style_Tools::drawFocus( p, aRect, model()->widgetRounding( Style_Model::ButtonRadius ),
+ Style_Tools::All, model()->color( Style_Model::BorderBottom ) );
}
break;
}
case CE_PushButtonBevel:
if ( qstyleoption_cast<const QStyleOptionButton *>(opt) ) {
- double aRad = getDblValue( Style_Model::btn_rad );
+ double aRad = model()->widgetRounding( Style_Model::ButtonRadius );
bool aStateOn = opt->state & ( State_Sunken | State_On );
- bool isAutoRaising = getBoolValue( Style_Model::auto_raising_wdg );
- bool isHighWdg = getBoolValue( Style_Model::highlight_wdg );
+ bool isAutoRaising = model()->widgetEffect() == Style_Model::AutoRaiseEffect;
+ bool isHighWdg = model()->widgetEffect() == Style_Model::HighlightEffect;
bool enabled = opt->state & State_Enabled;
bool hover = hasHover() && enabled && ( opt->state & State_MouseOver );
QColor aBtnCol = opt->palette.color( QPalette::Button );
QColor top = aBtnCol.light( BUT_PERCENT_COL ),
bottom = aBtnCol.dark( BUT_PERCENT_COL );
- QColor aBrdTopCol = getColor( Style_Model::border_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_bot_clr );
+ QColor aBrdTopCol = model()->color( Style_Model::BorderTop ); // Style_Model::border_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::BorderBottom ); // Style_Model::border_bot_clr
QRect r = opt->rect;
- bool antialized = getBoolValue( Style_Model::all_antialized );
+ bool antialized = model()->antialiasing();
if ( isAutoRaising && hover && !aStateOn )
Style_Tools::shadowRect( p, r, aRad, -1, SHADOW, Style_Tools::All, bottom, top,
aBrdTopCol, aBrdBotCol, antialized, true, aStateOn );
gr.setColorAt( 1.0, top );
p->fillRect( r, gr );
- QColor aBrdTopCol = getColor( Style_Model::border_tab_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_tab_bot_clr );
+ QColor aBrdTopCol = model()->color( Style_Model::TabBorderTop ); // Style_Model::border_tab_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::TabBorderBottom ); // Style_Model::border_tab_bot_clr
p->setPen( aBrdTopCol );
p->drawLine( r.x(), r.bottom(), r.x(), r.y() );
p->drawLine( r.x(), r.y(), r.right(), r.y() );
QWindowsStyle::drawControl( ce, opt, p, w );
QRect r = opt->rect;
bool horiz = r.width() > r.height();
- int aLen = (int)getDblValue( Style_Model::split_handle_len );
+ int aLen = model()->splitHandleLength();
if ( horiz )
r = QRect( r.x() +(int)((r.width()-aLen)/2), r.y(), aLen, r.height());
else
tab->position == QStyleOptionTab::OnlyOneTab;
QColor aColor = opt->palette.color( QPalette::Window ),
aDarkColor = aColor.dark( BUT_PERCENT_ON );
- QColor aBrdTopCol = getColor( Style_Model::border_tab_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_tab_bot_clr );
+ QColor aBrdTopCol = model()->color( Style_Model::TabBorderTop ); // Style_Model::border_tab_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::TabBorderBottom ); // Style_Model::border_tab_bot_clr
bool isHover = hasHover() && (opt->state & State_Enabled) &&
(opt->state & State_MouseOver);
- if ( isHover && !isSelected && !getBoolValue( Style_Model::auto_raising_wdg ) &&
- getBoolValue( Style_Model::highlight_wdg) ) {
- aColor = getColor( Style_Model::high_wdg_clr );
- aDarkColor = getColor( Style_Model::high_brd_wdg_clr );
+ if ( isHover && !isSelected && model()->widgetEffect() == Style_Model::HighlightEffect ) {
+ aColor = model()->color( Style_Model::HighlightWidget ); // Style_Model::high_wdg_clr
+ aDarkColor = model()->color( Style_Model::HighlightBorder ); // Style_Model::high_brd_wdg_clr
}
Style_Tools::tabRect( p, tabRect, (int)tab->shape,
- getDblValue( Style_Model::frame_rad ),
+ model()->widgetRounding( Style_Model::FrameRadius ),
DELTA_H_TAB, aColor, aDarkColor,
aBrdTopCol, aBrdBotCol, isSelected, isLast, isHover );
p->restore();
QColor aBtnCol = opt->palette.color( QPalette::Window ),
top = aBtnCol.light( BUT_PERCENT_ON ),
bottom = aBtnCol.dark( BUT_PERCENT_ON );
- QColor aBrdTopCol = getColor( Style_Model::border_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_bot_clr );
- bool aHighWdg = hasHover() && !getBoolValue( Style_Model::auto_raising_wdg ) &&
- getBoolValue( Style_Model::highlight_wdg );
+ QColor aBrdTopCol = model()->color( Style_Model::BorderTop ); // Style_Model::border_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::BorderBottom ); // Style_Model::border_bot_clr
+ bool aHighWdg = model()->widgetEffect() == Style_Model::HighlightEffect;
if ( !aStateOn && aHighWdg && (opt->state & State_Enabled) &&
(opt->state & State_Selected) )
drawHoverRect(p, opt->rect, opt->palette.color( QPalette::Window ), 0, Style_Tools::All, true);
else {
Style_Tools::shadowRect( p, opt->rect, 0, 0., SHADOW, Style_Tools::All, top, bottom,
aBrdTopCol, aBrdBotCol,
- getBoolValue( Style_Model::all_antialized ), true, aStateOn );
+ model()->antialiasing(), true, aStateOn );
}
}
if (active && down) {
QColor aBgColor = opt->palette.color( QPalette::Window ),
top = aBgColor.light( BUT_PERCENT_ON ),
bottom = aBgColor.dark( BUT_PERCENT_ON );
- QColor aBrdTopCol = getColor( Style_Model::border_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_bot_clr );
- Style_Tools::shadowRect( p, opt->rect, getDblValue( Style_Model::edit_rad ), -1,
+ QColor aBrdTopCol = model()->color( Style_Model::BorderTop ); // Style_Model::border_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::BorderBottom ); // Style_Model::border_bot_clr
+ Style_Tools::shadowRect( p, opt->rect, model()->widgetRounding( Style_Model::EditRadius ), -1,
SHADOW, Style_Tools::All, top, bottom, aBrdTopCol, aBrdBotCol,
- getBoolValue( Style_Model::all_antialized ), true );
+ model()->antialiasing(), true );
break;
}
case CE_ProgressBarLabel:
int myHeight = pbBits.rect.height();
pbBits.state = State_None;
QRect aRect;
- QColor aColor = getColor( Style_Model::prbar_clr ),
- top = aColor.light( BUT_PERCENT_COL ),
- bottom = aColor.dark( BUT_PERCENT_COL );
+ QColor aColor = model()->color( Style_Model::ProgressBar ); // Style_Model::prbar_clr
+ QColor top = aColor.light( BUT_PERCENT_COL );
+ QColor bottom = aColor.dark( BUT_PERCENT_COL );
int aType;
for (int i = 0; i <= nu; ++i) {
aType = Style_Tools::None;
aTopClr = aColor.light();
aBotClr = aColor.dark();
}
- Style_Tools::shadowRect( p, aRect, getDblValue( Style_Model::edit_rad ), -1, 0,
+ Style_Tools::shadowRect( p, aRect, model()->widgetRounding( Style_Model::EditRadius ), -1, 0,
aType, top, bottom, aTopClr, aBotClr, false, true );
x += reverse ? -unit_width : unit_width;
}
double aMargin = LINE_GR_MARGIN;
QLinearGradient gr(x,y,menuitem->rect.right(),y);
gr.setColorAt( 0.0, aBgColor );
- gr.setColorAt( aMargin/width, getColor( Style_Model::fld_light_clr ) );
- gr.setColorAt( 1.0, getColor( Style_Model::fld_light_clr ) );
+ gr.setColorAt( aMargin/width, model()->color( Style_Model::FieldLight ) ); // Style_Model::fld_light_clr
+ gr.setColorAt( 1.0, model()->color( Style_Model::FieldLight ) );
QBrush fill;
if ( act )
fill = menuitem->palette.brush( QPalette::Highlight );
p->fillRect(menuitem->rect, fill);
if (menuitem->menuItemType == QStyleOptionMenuItem::Separator){
int yoff = y-1 + h / 2;
- QColor aBrdTopCol = getColor( Style_Model::border_tab_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_tab_bot_clr );
+ QColor aBrdTopCol = model()->color( Style_Model::TabBorderTop ); // Style_Model::border_tab_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::TabBorderBottom ); // Style_Model::border_tab_bot_clr
p->setPen( aBrdBotCol );
p->drawLine(x + 2, yoff, x + width - 4, yoff);
p->setPen( aBrdTopCol );
*/
case CE_HeaderSection: {
bool aStateOn = opt->state & State_On;
- QColor aColor = getColor( Style_Model::header_clr );
+ QColor aColor = model()->color( Style_Model::Header ); // Style_Model::header_clr
QColor top = aColor.light( BUT_PERCENT_COL ),
bottom = aColor.dark( BUT_PERCENT_COL );
- QColor aBrdTopCol = getColor( Style_Model::border_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_bot_clr );
+ QColor aBrdTopCol = model()->color( Style_Model::BorderTop ); // Style_Model::border_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::BorderBottom ); // Style_Model::border_bot_clr
Style_Tools::shadowRect( p, opt->rect, 0, -1, 0, Style_Tools::All, top, bottom, aBrdTopCol,
- aBrdBotCol, getBoolValue( Style_Model::all_antialized ), true, aStateOn );
+ aBrdBotCol, model()->antialiasing(), true, aStateOn );
break;
}
case CE_ComboBoxLabel:
QRect alignRect = editRect;
if ( cb->editable ) {
int aHalfRect = (int)Style_Tools::getMaxRect( iconRect,
- (int)getDblValue( Style_Model::edit_rad )/2 );
+ (int)model()->widgetRounding( Style_Model::EditRadius )/2 );
alignRect.setLeft( alignRect.left() + aHalfRect );
alignRect.setRight( alignRect.right() - aHalfRect );
}
QColor aBtnCol = opt->palette.color( QPalette::Button );
QColor top = aBtnCol.light( BUT_PERCENT_COL ),
bottom = aBtnCol.dark( BUT_PERCENT_COL );
- QColor aBrdTopCol = getColor( Style_Model::border_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_bot_clr );
+ QColor aBrdTopCol = model()->color( Style_Model::BorderTop ); // Style_Model::border_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::BorderBottom ); // Style_Model::border_bot_clr
Style_Tools::shadowRect( p, opt->rect, 0, -1, 0, Style_Tools::All, top, bottom, aBrdTopCol,
aBrdBotCol, false, true, aStateOn, true );
PrimitiveElement arrow;
p->setRenderHint( QPainter::Antialiasing, true );
bool enabled = opt->state & State_Enabled;
bool horiz = scrollbar->orientation == Qt::Horizontal;
- double aRad = getDblValue( Style_Model::btn_rad );
+ double aRad = model()->widgetRounding( Style_Model::ButtonRadius );
if ( hasHover() && enabled && (opt->state & State_MouseOver) )
drawHoverRect(p, opt->rect, opt->palette.color( QPalette::Window ), aRad, Style_Tools::All, false);
else {
- QColor aColor = getColor( Style_Model::slider_clr );
+ QColor aColor = model()->color( Style_Model::Slider ); // Style_Model::slider_clr
if ( !enabled )
aColor = opt->palette.button().color();
QColor top = aColor.light( BUT_PERCENT_ON ),
bottom = aColor.dark( BUT_PERCENT_ON );
- QColor aBrdTopCol = getColor( Style_Model::border_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_bot_clr );
+ QColor aBrdTopCol = model()->color( Style_Model::BorderTop ); // Style_Model::border_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::BorderBottom ); // Style_Model::border_bot_clr
QRect r = opt->rect;
QPainterPath path = Style_Tools::roundRect( r, aRad,
Style_Tools::All );
}
}
+/*!
+ \brief Draws the given primitive element with the provided painter \p using the style options specified by \a opt.
+ \param pe primitive type
+ \param opt style option
+ \param p painter
+ \param w widget (optional)
+*/
void Style_Salome::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt,
QPainter* p, const QWidget* w ) const
{
QColor aBtnCol = opt->palette.color( QPalette::Window ),
top = aBtnCol.light( BUT_PERCENT_ON ),
bottom = aBtnCol.dark( BUT_PERCENT_ON );
- QColor aBrdTopCol = getColor( Style_Model::border_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_bot_clr );
+ QColor aBrdTopCol = model()->color( Style_Model::BorderTop ); // Style_Model::border_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::BorderBottom ); // Style_Model::border_bot_clr
Style_Tools::shadowRect( p, opt->rect, 0, 0., SHADOW, Style_Tools::All, top,
bottom, aBrdTopCol, aBrdBotCol, false, false, false, false );
break;
( w->inherits("QDockWidgetTitleButton") ) ||
( w->inherits("QtxWorkstackAreaTitleButton") ) ) ) {
bool aStateOn = opt->state & (State_Sunken | State_On);
- bool aHighWdg = hasHover() && !getBoolValue( Style_Model::auto_raising_wdg ) &&
- getBoolValue( Style_Model::highlight_wdg );
+ bool aHighWdg = model()->widgetEffect() == Style_Model::HighlightEffect;
if ( !aStateOn && aHighWdg && (opt->state & State_Enabled) &&
(opt->state & State_MouseOver) )
drawHoverRect(p, opt->rect, opt->palette.color( QPalette::Window ), 0, Style_Tools::All, true);
else {
QColor aBtnCol = opt->palette.color( QPalette::Window );
- QColor aBrdTopCol = getColor( Style_Model::border_tab_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_tab_bot_clr );
+ QColor aBrdTopCol = model()->color( Style_Model::TabBorderTop ); // Style_Model::border_tab_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::TabBorderBottom ); // Style_Model::border_tab_bot_clr
QColor top = aBtnCol.light( BUT_PERCENT_COL ),
bottom = aBtnCol.dark( BUT_PERCENT_COL );
Style_Tools::shadowRect( p, opt->rect, 0.0, 0, SHADOW, Style_Tools::All, top, bottom,
- aBrdTopCol, aBrdBotCol, getBoolValue( Style_Model::all_antialized ), true, aStateOn );
+ aBrdTopCol, aBrdBotCol, model()->antialiasing(), true, aStateOn );
}
break;
}
case PE_FrameFocusRect: {
if (w && qobject_cast<QTabBar*>((QWidget*)w)) {
QTabBar* tabBar = qobject_cast<QTabBar*>((QWidget*)w);
- QColor aBrdTopCol = getColor( Style_Model::border_tab_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_tab_bot_clr );
+ QColor aBrdTopCol = model()->color( Style_Model::TabBorderTop ); // Style_Model::border_tab_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::TabBorderBottom ); // Style_Model::border_tab_bot_clr
bool isHover = hasHover() && (opt->state & State_Enabled) && (opt->state & State_MouseOver);
Style_Tools::tabRect( p, opt->rect, (int)tabBar->shape(),
- getDblValue( Style_Model::frame_rad ), DELTA_H_TAB,
+ model()->widgetRounding( Style_Model::FrameRadius ), DELTA_H_TAB,
pal.color( QPalette::Window ),
- getColor( Style_Model::border_bot_clr ),
+ model()->color( Style_Model::BorderTop ), // Style_Model::border_bot_clr
aBrdTopCol, aBrdBotCol, false, false, isHover, true );
}
else {
QRect rect = opt->rect;
QColor pen, brush;
if ( opt->state & State_Enabled ) {
- pen = getColor( Style_Model::pointer_clr );
+ pen = model()->color( Style_Model::Pointer ); // Style_Model::pointer_clr
brush = opt->palette.color( QPalette::Button );
if ( ( opt->state & State_Sunken ) && (opt->state & State_Enabled ) )
rect.moveTo( rect.x()+1, rect.y()+1 );
}
case PE_IndicatorCheckBox: {
if ( hasHover() && (opt->state & State_Enabled) && (opt->state & State_MouseOver) )
- drawHoverRect(p, w->rect(), opt->palette.color( QPalette::Window ), getDblValue( Style_Model::edit_rad ),
+ drawHoverRect(p, w->rect(), opt->palette.color( QPalette::Window ),
+ model()->widgetRounding( Style_Model::EditRadius ),
Style_Tools::All, false);
QBrush fill;
if (opt->state & State_NoChange)
fill = opt->palette.color( QPalette::Window );
else if (opt->state & State_Enabled) {
if (!(opt->state & State_Off) )
- fill = QBrush( getColor( Style_Model::checked_clr ) );
+ fill = QBrush( model()->color( Style_Model::Checked ) ); // Style_Model::checked_clr
else
fill = QBrush( opt->palette.color( QPalette::Base ) );
}
p->save();
doRestore = true;
QColor color = fill.color();
- QColor aBrdTopCol = getColor( Style_Model::border_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_bot_clr );
- if ( getBoolValue( Style_Model::all_antialized ) )
+ QColor aBrdTopCol = model()->color( Style_Model::BorderTop ); // Style_Model::border_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::BorderBottom ); // Style_Model::border_bot_clr
+ if ( model()->antialiasing() )
p->setRenderHint( QPainter::Antialiasing, true );
// make sure the indicator is square
Style_Tools::shadowCheck( p, ir, 2., Style_Tools::All,
color, color.dark( BUT_PERCENT_ON ), aBrdTopCol, aBrdBotCol );
- if ( getBoolValue( Style_Model::all_antialized ) )
+ if ( model()->antialiasing() )
p->setRenderHint( QPainter::Antialiasing, false );
if (opt->state & State_NoChange)
p->setPen(opt->palette.dark().color());
++xx;
--yy;
}
- QColor aColor = getColor( Style_Model::pointer_clr );
+ QColor aColor = model()->color( Style_Model::Pointer ); // Style_Model::pointer_clr
if ( !(opt->state & State_Enabled ) )
aColor = opt->palette.mid().color();
if ( opt->state & State_Selected && itemViewOpt && itemViewOpt->showDecorationSelected )
}
case PE_IndicatorRadioButton: {
if ( hasHover() && (opt->state & State_Enabled) && (opt->state & State_MouseOver) )
- drawHoverRect(p, w->rect(), opt->palette.color( QPalette::Window ), getDblValue( Style_Model::btn_rad ),
+ drawHoverRect(p, w->rect(), opt->palette.color( QPalette::Window ),
+ model()->widgetRounding( Style_Model::ButtonRadius ),
Style_Tools::All, false);
#define PTSARRLEN(x) sizeof(x)/(sizeof(QPoint))
static const QPoint pts_border[] = { // border line
else {
QColor fillColor = opt->palette.color( QPalette::Base );
if ( enabled && on )
- fillColor = getColor( Style_Model::checked_clr );
+ fillColor = model()->color( Style_Model::Checked ); // Style_Model::checked_clr
QLinearGradient gr( 3, 3, 8, 8 );
gr.setColorAt( 0.0, fillColor.dark( BUT_PERCENT_ON ) );
gr.setColorAt( 1.0, fillColor );
p->drawPolygon(pts_border, PTSARRLEN(pts_border));
int aSize = PTSARRLEN(pts_border),
aHalfSize = (int)aSize/2;
- if ( getBoolValue( Style_Model::all_antialized ) )
+ if ( model()->antialiasing() )
p->setRenderHint( QPainter::Antialiasing, true );
- p->setPen( getColor( Style_Model::border_top_clr ) );
+ p->setPen( model()->color( Style_Model::BorderTop) ); // Style_Model::border_top_clr
p->drawPolyline(pts_border, aHalfSize);
-
- p->setPen( getColor( Style_Model::border_bot_clr ) );
+ p->setPen( model()->color( Style_Model::BorderBottom ) ); // Style_Model::border_bot_clr
QPolygon aPolygon;
for ( int i = aHalfSize; i < aSize; i++ )
aPolygon << pts_border[i];
p->drawPolyline( aPolygon );
- if ( getBoolValue( Style_Model::all_antialized ) )
+ if ( model()->antialiasing() )
p->setRenderHint( QPainter::Antialiasing, false );
if (on) {
- QColor aPointerCol = getColor( Style_Model::pointer_clr );
+ QColor aPointerCol = model()->color( Style_Model::Pointer ); // Style_Model::pointer_clr
if ( !enabled )
aPointerCol = opt->palette.mid().color();
p->setPen( Qt::NoPen );
break;
}
if ( pe == PE_FrameLineEdit ) {
- QColor aBrdTopCol = getColor( Style_Model::border_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_bot_clr );
+ QColor aBrdTopCol = model()->color( Style_Model::BorderTop ); // Style_Model::border_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::BorderBottom ); // Style_Model::border_bot_clr
bool hover = hasHover() && (opt->state & State_Enabled) && (opt->state & State_MouseOver);
- double aRad = getDblValue(Style_Model::edit_rad);
+ double aRad = model()->widgetRounding( Style_Model::EditRadius );
if ( hover )
drawHoverRect(p, opt->rect, opt->palette.color( QPalette::Window ), aRad, Style_Tools::All, true);
else {
Style_Tools::shadowRect( p, opt->rect, aRad, LINE_GR_MARGIN, SHADOW,
Style_Tools::All, opt->palette.color( QPalette::Base ), // getColor( Style_Model::fld_light_clr ),
- getColor( Style_Model::fld_dark_clr ), aBrdTopCol, aBrdBotCol,
- getBoolValue( Style_Model::all_antialized ), false );
+ model()->color( Style_Model::FieldDark ), aBrdTopCol, aBrdBotCol,
+ model()->antialiasing(), false );
}
}
else {
aRoundType = aRoundType | Style_Tools::BottomLeft;
if ( aTabPos != QTabWidget::East )
aRoundType = aRoundType | Style_Tools::TopRight;
- QColor aBrdTopCol = getColor( Style_Model::border_tab_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_tab_bot_clr );
- Style_Tools::shadowRect( p, opt->rect, getDblValue( Style_Model::frame_rad ),
+ QColor aBrdTopCol = model()->color( Style_Model::TabBorderTop ); // Style_Model::border_tab_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::TabBorderBottom ); // Style_Model::border_tab_bot_clr
+ Style_Tools::shadowRect( p, opt->rect, model()->widgetRounding( Style_Model::FrameRadius ),
0., SHADOW, aRoundType,
- getColor( Style_Model::fld_light_clr ),
+ model()->color( Style_Model::FieldLight ),
opt->palette.color( QPalette::Dark ),
aBrdTopCol, aBrdBotCol, false, false, false, false );
break;
if ( tabBar )
isLast = tabBar->currentIndex() == tabBar->count() -1;
QColor aColor = opt->palette.color( QPalette::Window );
- QColor aBrdTopCol = getColor( Style_Model::border_tab_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_tab_bot_clr );
+ QColor aBrdTopCol = model()->color( Style_Model::TabBorderTop ); // Style_Model::border_tab_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::TabBorderBottom ); // Style_Model::border_tab_bot_clr
bool isHover = hasHover() && (opt->state & State_Enabled) &&
(opt->state & State_MouseOver);
QPainterPath aSelPath = Style_Tools::tabRect( p, aSelRect, (int)tbb->shape,
- getDblValue( Style_Model::frame_rad ), DELTA_H_TAB, aColor, aColor,
+ model()->widgetRounding( Style_Model::FrameRadius ),
+ DELTA_H_TAB, aColor, aColor,
aColor, aColor, isSelected, isLast, isHover, false, false );
if ( !aSelPath.isEmpty() )
aSelRect = aSelPath.controlPointRect().toRect();
if ( hover )
drawHoverRect(p, r, opt->palette.color( QPalette::Window ), 0, Style_Tools::All, false);
bool horiz = r.width() > r.height();
- int aLen = (int)getDblValue( Style_Model::split_handle_len );
+ int aLen = model()->splitHandleLength();
if ( horiz )
r = QRect( r.x() +(int)((r.width()-aLen)/2), r.y(), aLen, r.height());
else
}
QPalette aPal = aWdg->palette();
double aMarg = LINE_GR_MARGIN;
- QColor base = getColor( Style_Model::pal_base_clr ),
- light = base,
- light_alt = base.dark(110),//AlternateBase color
- dark = getColor( Style_Model::fld_dark_clr );
+ QColor base = model()->color( Style_Model::Base ), // Style_Model::pal_base_clr
+ light = base,
+ light_alt = base.dark(110),//AlternateBase color
+ dark = model()->color( Style_Model::FieldDark ); // Style_Model::fld_dark_clr
light.setAlpha( 0 ); // VSR commented: IPAL19262
QLinearGradient gr_h(r.x(), r.y(), r.right(), r.y());
gr_h.setColorAt( 0.0, dark );
}
}
+/*!
+ \brief Returns the value of the given pixel \a metric.
+ \param metric metric type
+ \param opt style option
+ \param w widget
+ \return metric value
+*/
int Style_Salome::pixelMetric( PixelMetric metric, const QStyleOption* opt,
- const QWidget* w ) const
+ const QWidget* w ) const
{
if ( checkDebugLevel(7) ) {
return QWindowsStyle::pixelMetric( metric, opt, w );
int aRes = QWindowsStyle::pixelMetric( metric, opt, w );
switch( metric ) {
case PM_SliderLength: {
- aRes += (int)(getIntValue( Style_Model::slider_increase )/2);
+ aRes += (int)((double)model()->sliderSize()/2);
break;
}
case PM_DockWidgetFrameWidth:
return aRes;
}
+/*!
+ \brief Returns the size of the element described by the specified option \a opt
+ and type \a ct, based on the provided \a contentsSize.
+ \param ct contents type
+ \param opt style option
+ \param contentsSize contents size
+ \param w widget (optional)
+ \return size of the element
+*/
QSize Style_Salome::sizeFromContents( ContentsType ct, const QStyleOption* opt,
const QSize& contentsSize, const QWidget* w ) const
{
}
break;
case CT_Slider: {
- int aValue = getIntValue( Style_Model::slider_increase );
+ int aValue = model()->sliderSize();
sz.setWidth( sz.width() + aValue );
sz.setHeight( sz.height() + aValue );
break;
if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
QRect res = QRect( 0, 0, sz.width(), sz.height() );
int aHalfRect = (int)Style_Tools::getMaxRect( res,
- (int)getDblValue( Style_Model::edit_rad )/2 ); // left value
+ (int)model()->widgetRounding( Style_Model::EditRadius )/2 ); // left value
QRect old_arrow = QWindowsStyle::subControlRect( CC_ComboBox, cmb,
SC_ComboBoxArrow, w );
int aDelta = res.height() - old_arrow.width(); // right value
return sz;
}
+/*!
+ \brief Returns a pixmap for the given \a standardPixmap.
+ \param stPixmap standard pixmap type
+ \param opt style option
+ \param w widget (optional)
+ \return standard pixmap
+*/
QPixmap Style_Salome::standardPixmap(StandardPixmap stPixmap, const QStyleOption *opt,
const QWidget *w) const
{
}
}
+/*!
+ \brief Returns an icon for the given \a standardIcon.
+ \param standardIcon standard icon type
+ \param opt style option
+ \param w widget (optional)
+ \return standard icon
+*/
QIcon Style_Salome::standardIconImplementation( StandardPixmap standardIcon,
const QStyleOption* opt,
- const QWidget* widget ) const
+ const QWidget* w ) const
{
if ( checkDebugLevel(10) ) {
- return QWindowsStyle::standardIconImplementation( standardIcon, opt, widget );
+ return QWindowsStyle::standardIconImplementation( standardIcon, opt, w );
}
switch ( standardIcon )
default:
break;
}
- return QWindowsStyle::standardIconImplementation( standardIcon, opt, widget );
+ return QWindowsStyle::standardIconImplementation( standardIcon, opt, w );
}
-int Style_Salome::styleHint( StyleHint hint, const QStyleOption* opt, const QWidget* widget,
+/*!
+ \brief Returns an integer representing the specified style \a hint for the
+ given widget \a w described by the provided style option \a opt.
+ \param hint hint type
+ \param opt style option
+ \param w widget (optional)
+ \param returnData (currently not used)
+ \return style hint value
+*/
+int Style_Salome::styleHint( StyleHint hint, const QStyleOption* opt, const QWidget* w,
QStyleHintReturn* returnData ) const
{
if ( checkDebugLevel(11) ) {
- return QWindowsStyle::styleHint( hint, opt, widget, returnData );
+ return QWindowsStyle::styleHint( hint, opt, w, returnData );
}
- int aRes = QWindowsStyle::styleHint( hint, opt, widget, returnData );
+ int aRes = QWindowsStyle::styleHint( hint, opt, w, returnData );
switch( hint ) {
case SH_Table_GridLineColor: {
if ( opt )
- aRes = getColor( Style_Model::tbl_grline_clr ).rgb();
+ aRes = model()->color( Style_Model::GridLine ).rgb(); // Style_Model::tbl_grline_clr
else
return aRes;
break;
return aRes;
}
+/*!
+ \brief Get the rectangle containing the specified subcontrol \a sc of the given
+ complex control \a cc (with the style specified by option \a opt).
+ The rectangle is defined in screen coordinates.
+ \param cc complex control type
+ \param opt style option
+ \param sc subcontrol type
+ \param wid widget (optional)
+ \return subcontrol rectangle
+*/
QRect Style_Salome::subControlRect( ComplexControl cc, const QStyleOptionComplex* opt,
SubControl sc, const QWidget* wid ) const
{
case CC_ComboBox: {
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
res = cb->rect;
- int aHalfRect = (int)Style_Tools::getMaxRect( res, (int)getDblValue( Style_Model::edit_rad )/2 );
+ int aHalfRect = (int)Style_Tools::getMaxRect( res, (int)model()->widgetRounding( Style_Model::EditRadius )/2 );
int x = res.x(), w = res.width(), h = res.height();
switch( sc ) {
case SC_ComboBoxEditField: {
case CC_ScrollBar:
if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
QRect slider_r = QWindowsStyle::subControlRect( cc, opt, SC_ScrollBarSlider, wid );
- int aRect = Style_Tools::getMaxRect( slider_r, (int)getDblValue( Style_Model::btn_rad ) );
+ int aRect = Style_Tools::getMaxRect( slider_r, (int)model()->widgetRounding( Style_Model::ButtonRadius ) );
switch( sc ) {
case SC_ScrollBarSubPage: // between top/left button and slider
if (scrollbar->orientation == Qt::Horizontal)
return res;
}
+/*!
+ \brief Returns the sub-area for the given element \a se as described
+ in the provided style option \a opt.
+ The returned rectangle is defined in screen coordinates.
+ \param se subelement type
+ \param opt style option
+ \param wid widget (optional)
+ \return subelement rectangle
+*/
QRect Style_Salome::subElementRect( SubElement se, const QStyleOption* opt,
const QWidget* wid ) const
{
}
QRect res = QWindowsStyle::subElementRect( se, opt, wid );
- int aHalfRect = (int)Style_Tools::getMaxRect( res, (int)getDblValue( Style_Model::edit_rad )/2 );
+ int aHalfRect = (int)Style_Tools::getMaxRect( res, (int)model()->widgetRounding( Style_Model::EditRadius )/2 );
int w = res.width(), h = res.height();
switch ( se ) {
case SE_ComboBoxFocusRect: {
return res;
}
+/*!
+ \brief Update palette colors from style model
+*/
void Style_Salome::updatePaletteColors()
{
- QPalette aPal = QApplication::palette();
- aPal.setColor( QPalette::WindowText, getColor( Style_Model::pal_wtext_clr ) );
- aPal.setColor( QPalette::Button, getColor( Style_Model::button_clr ) );
- aPal.setColor( QPalette::Light, getColor( Style_Model::pal_light_clr ) );
- aPal.setColor( QPalette::Midlight, getColor( Style_Model::pal_light_clr ).light(115) );
- aPal.setColor( QPalette::Dark, getColor( Style_Model::pal_dark_clr ) );
- aPal.setColor( QPalette::Mid, aPal.color( QPalette::Active, QPalette::Button ).dark(150) );
- aPal.setColor( QPalette::Text, getColor( Style_Model::pal_text_clr ) );
- //aPal.setColor( QPalette::BrightText, ??? );
- aPal.setColor( QPalette::ButtonText, getColor( Style_Model::pal_btext_clr ) );
- aPal.setColor( QPalette::Base, getColor( Style_Model::pal_base_clr ) );
- aPal.setColor( QPalette::AlternateBase, getColor( Style_Model::pal_base_clr ).dark( 110 ) );
- aPal.setColor( QPalette::Window, getColor( Style_Model::bg_clr ) );
- //aPal.setColor( QPalette::Shadow, ??? );
- QColor hc = getColor( Style_Model::pal_high_clr );
- hc.setAlpha(100);
- aPal.setColor( QPalette::Highlight, hc );
- aPal.setColor( QPalette::HighlightedText, getColor( Style_Model::pal_high_text_clr ) );
- //aPal.setColor( QPalette::Link, ??? );
- //aPal.setColor( QPalette::LinkVisited, ??? );
-
- // dependant colors
- if (aPal.midlight() == aPal.button())
- aPal.setColor(QPalette::Inactive, QPalette::Midlight, aPal.color(QPalette::Active, QPalette::Button).light(110));
- if (aPal.window() != aPal.base()) {
- QColor hc1 = aPal.color(QPalette::Inactive, QPalette::Window);
- hc1.setAlpha(100);
- aPal.setColor(QPalette::Inactive, QPalette::Highlight, hc1);
- aPal.setColor(QPalette::Inactive, QPalette::HighlightedText, aPal.color(QPalette::Inactive, QPalette::Text));
- }
-
- const QColor bg = aPal.window().color();
- const QColor fg = aPal.windowText().color();
- const QColor btn = aPal.button().color();
-
- QColor disabled((fg.red()+btn.red())/2,(fg.green()+btn.green())/2,
- (fg.blue()+btn.blue())/2);
-
- aPal.setColor(QPalette::Disabled, QPalette::WindowText, disabled);
- aPal.setColor(QPalette::Disabled, QPalette::Text, disabled);
- aPal.setColor(QPalette::Disabled, QPalette::ButtonText, disabled);
- aPal.setColor(QPalette::Disabled, QPalette::Base, bg);
-
- QApplication::setPalette( aPal );
-
- QColor aWndCol = myTTipWnd,
- aTextCol = myTTipText;
- if( getBoolValue( Style_Model::ttip_is_change ) ) {
- if ( getColor( Style_Model::ttip_bg_clr ).isValid() )
- aWndCol = getColor( Style_Model::ttip_bg_clr );
- if ( getColor( Style_Model::ttip_text_clr ).isValid() )
- aTextCol = getColor( Style_Model::ttip_text_clr );
- }
- QPalette tiplabel = QToolTip::palette();
- bool isChangeWnd = aWndCol != tiplabel.color( QPalette::Window ),
- isChangeTxt = aTextCol != tiplabel.color( QPalette::Text );
- if ( isChangeWnd || isChangeTxt ) {
- if ( isChangeWnd ) {
- tiplabel.setColor(QPalette::Window, aWndCol);
- tiplabel.setColor(QPalette::Button, aWndCol);
+ QPalette pal = QApplication::palette();
+ // colors
+ for ( int i = (int)QPalette::Active; i <= (int)QPalette::Inactive; i++ ) {
+ for ( int j = (int)Style_Model::WindowText; j < (int)Style_Model::NColorRoles; j++ ) {
+ if ( j == QPalette::NoRole ) continue;
+ pal.setColor( (QPalette::ColorGroup)i, (QPalette::ColorRole)j,
+ model()->color( (Style_Model::ColorRole)j, (QPalette::ColorGroup)i ) );
}
- if ( isChangeTxt ) {
- tiplabel.setColor(QPalette::Text, aTextCol);
- tiplabel.setColor(QPalette::WindowText, aTextCol);
- tiplabel.setColor(QPalette::ButtonText, aTextCol);
- }
- const QColor fg = tiplabel.foreground().color(), btn = tiplabel.button().color();
- QColor disabled((fg.red()+btn.red())/2,(fg.green()+btn.green())/2,
- (fg.blue()+btn.blue())/2);
- tiplabel.setColor(QPalette::Disabled, QPalette::WindowText, disabled);
- tiplabel.setColor(QPalette::Disabled, QPalette::Text, disabled);
- tiplabel.setColor(QPalette::Disabled, QPalette::Base, Qt::white);
- tiplabel.setColor(QPalette::Disabled, QPalette::BrightText, Qt::white);
- QToolTip::setPalette(tiplabel);
}
+ QPixmapCache::clear();
+ QApplication::setPalette( pal );
}
+/*!
+ \brief Update all widgets with the current style properties.
+ \param app application object
+*/
void Style_Salome::updateAllWidgets( QApplication* app )
{
if ( !app )
return;
+
QWidgetList all = app->allWidgets();
QWidget* w;
for (QWidgetList::ConstIterator it2 = all.constBegin(); it2 != all.constEnd(); ++it2) {
}
}
+/*!
+ \brief Check if any widget effect is currently used
+ \return \c true if any widget effect is currently used
+*/
bool Style_Salome::hasHover() const
{
- return getBoolValue( Style_Model::auto_raising_wdg ) ||
- getBoolValue( Style_Model::highlight_wdg );
+ return model()->widgetEffect() != Style_Model::NoEffect;
}
+/*!
+ \brief Draw rectangle for the hovered widget
+ \param p painter
+ \param r rectangle
+ \param bgCol background color
+ \param rad corners rounding radius
+ \param type shadow type
+ \param border if \c true border is colored with specific color
+*/
void Style_Salome::drawHoverRect( QPainter* p, const QRect& r, const QColor& bgCol, const double rad,
const int type, const bool border ) const
{
if ( !hasHover() )
return;
- bool isAutoRaising = getBoolValue( Style_Model::auto_raising_wdg );
- bool isHighWdg = getBoolValue( Style_Model::highlight_wdg );
- QColor aBorder = getColor( Style_Model::border_bot_clr ),
+ bool isAutoRaising = model()->widgetEffect() == Style_Model::AutoRaiseEffect;
+ bool isHighWdg = model()->widgetEffect() == Style_Model::HighlightEffect;
+ QColor aBorder = model()->color( Style_Model::BorderTop ), // Style_Model::border_bot_clr
aCol, aBrdCol;
double aMargin = HIGH_WDG_MARGIN;
if ( isAutoRaising ) {
aMargin = 0;
}
else if ( isHighWdg ) {
- aCol = getColor( Style_Model::high_wdg_clr );
- aBrdCol = getColor( Style_Model::high_brd_wdg_clr );
+ aCol = model()->color( Style_Model::HighlightWidget ); // Style_Model::high_wdg_clr
+ aBrdCol = model()->color( Style_Model::HighlightBorder ); // Style_Model::high_brd_wdg_clr
if ( !border )
aBorder = aBrdCol;
}
Style_Tools::highlightRect( p, r, rad, type, aMargin, aCol, aBrdCol, aBorder );
}
+/*!
+ \brief Draw widget handle
+ \param p painter
+ \param r rectangle
+ \param horiz if \c true draw horizontal handle, otherwise draw vertical handle
+ \param isRect if \c true surrounding rectangle is also drawn
+*/
void Style_Salome::drawHandle( QPainter* p, const QRect& r, bool horiz, bool isRect ) const
{
QPixmap hole( (const char**)hole_xpm );
int i, j;
- double d_hor = getDblValue( Style_Model::hor_handle_delta );
- double d_ver = getDblValue( Style_Model::ver_handle_delta );
+ double d_hor = model()->handleDelta( Qt::Horizontal );
+ double d_ver = model()->handleDelta( Qt::Vertical );
if ( !d_hor || !d_ver || !r.width() || !r.height() )
return;
int c_hor = (int)(r.width()/d_hor)-1;
}
}
+/*!
+ \brief Draw background.
+ \param p painter
+ \param r rectangle
+ \param bgCol background color
+ \param fill 'fill rectangle' flag
+ \param grad 'draw gradient' flag
+ \param horix 'draw horizontal item' flag (usefull for gradient background)
+*/
void Style_Salome::drawBackground( QPainter* p, const QRect& r, const QColor& bgCol,
const bool fill, const bool grad, const bool horiz ) const
{
p->fillRect( r, gr );
}
}
- if ( !getBoolValue( Style_Model::is_lines ) )
- return;
- QColor c = getColor( Style_Model::lines_clr );
- int anAlpha = (int)( 255*( 1 - getDblValue( Style_Model::lines_transp )/100 ) );
- c.setAlpha( anAlpha );
- p->setPen( c );
- p->setRenderHint( QPainter::Antialiasing );
- int aLines = getIntValue( Style_Model::lines_type );
int x = r.x(), y = r.y(), left = r.left(), top = r.top();
int w = r.width(), h = r.height();
+
QVector<QLine> lines;
- if ( aLines == 0 ) { // horizontal lines
- const int d = 3;
- for( int i=0; i<=h; i+=d )
- lines.append( QLine( x, y+i, w, r.y()+i ) );
+
+ switch ( model()->linesType() ) {
+ case Style_Model::Horizontal:
+ {
+ const int d = 3;
+ for ( int i = 0; i <= h; i += d )
+ lines.append( QLine( x, y+i, w, r.y()+i ) );
+ }
+ break;
+ case Style_Model::Inclined:
+ {
+ const int d = 5;
+ w = w/d*d;
+ h = h/d*d;
+ for ( int i = 0; i <= w; i += d )
+ lines.append( QLine( x+i, y, x, y+i ) );
+ for ( int i = 0; i < h; i += d )
+ lines.append( QLine( left+w-i, top+h, left+w, top+h-i ) );
+ }
+ break;
+ default:
+ break;
}
- else if ( aLines == 1 ) {
- const int d = 5;
- w = w/d*d;
- h = h/d*d;
- for( int i=0; i<=w; i+=d )
- lines.append( QLine( x+i, y, x, y+i ) );
- for( int i=0; i<h; i+=d )
- lines.append( QLine( left+w-i, top+h, left+w, top+h-i ) );
+
+ if ( !lines.isEmpty() ) {
+ QColor c = model()->color( Style_Model::Lines );
+ int anAlpha = (int)( 255*( 1 - model()->linesTransparency()/100 ) );
+ c.setAlpha( anAlpha );
+ p->setPen( c );
+ p->setRenderHint( QPainter::Antialiasing );
+ p->drawLines( lines );
}
- p->drawLines( lines );
}
+/*!
+ \brief Draw border
+ \param p painter
+ \param r rectangle
+ \param horiz 'draw horizontal item' flag
+*/
void Style_Salome::drawBorder( QPainter* p, const QRect& r, bool horiz ) const
{
QPen oldPen = p->pen();
- QColor aBrdTopCol = getColor( Style_Model::border_tab_top_clr ),
- aBrdBotCol = getColor( Style_Model::border_tab_bot_clr );
+ QColor aBrdTopCol = model()->color( Style_Model::TabBorderTop ); // Style_Model::border_tab_top_clr
+ QColor aBrdBotCol = model()->color( Style_Model::TabBorderBottom ); // Style_Model::border_tab_bot_clr
p->setPen( aBrdTopCol );
if (horiz) {
p->drawLine(r.left(), r.top(), r.right(), r.top());
p->setPen(oldPen);
}
-QColor Style_Salome::getColor( int type ) const
-{
- return myModel->getColorValue( type );
-}
-
-double Style_Salome::getDblValue( int type ) const
-{
- return myModel->getDblValue( type );
-}
-
-int Style_Salome::getIntValue( int type ) const
-{
- return myModel->getIntValue( type );
-}
-
-bool Style_Salome::getBoolValue( int type ) const
-{
- return myModel->getBoolValue( type );
-}
-
-QString Style_Salome::getStringValue( int type ) const
-{
- return myModel->getStringValue( type );
-}
-
/*!
- \return corrected title text \param txt - title text
- \param w - possible width
- \param fm - font metrics
+ \brief Get corrected title text
+ \param txt original text
+ \param W possible width
+ \param H possible height
+ \param f used font
+ \return corrected title text
*/
QString Style_Salome::titleText( const QString& txt, const int W, const int H, QFont& f ) const
{
#include "Style.h"
#include <QWindowsStyle>
-#include <QMap>
class Style_Model;
class QApplication;
class QWidget;
-class QStyleOption;
class QPainter;
-class QSize;
-class QVariant;
+class QtxResourceMgr;
class STYLE_SALOME_EXPORT Style_Salome : public QWindowsStyle
{
Q_OBJECT
-public:
+
+private:
Style_Salome();
+
+public:
virtual ~Style_Salome();
- Style_Model* getModel() const;
+ static void initialize( QtxResourceMgr* = 0, const QString& = QString() );
+ static void apply();
+ static void restore();
- void updateSettings( QApplication* );
+ static bool isActive();
- virtual void polish( QApplication* );
- virtual void polish( QWidget* );
- virtual void unpolish( QWidget* );
- virtual void drawComplexControl( ComplexControl, const QStyleOptionComplex*,
- QPainter*, const QWidget* = 0 ) const;
+ static Style_Model* model();
+
+ static void update();
+
+ virtual void polish( QApplication* );
+ virtual void polish( QWidget* );
+ virtual void unpolish( QWidget* );
+ virtual void drawComplexControl( ComplexControl, const QStyleOptionComplex*,
+ QPainter*, const QWidget* = 0 ) const;
- virtual void drawControl( ControlElement, const QStyleOption*, QPainter*, const QWidget* ) const;
- virtual void drawPrimitive( PrimitiveElement, const QStyleOption*,
- QPainter*, const QWidget* = 0 ) const;
- virtual int pixelMetric( PixelMetric, const QStyleOption* = 0,
- const QWidget* = 0 ) const;
- virtual QSize sizeFromContents ( ContentsType, const QStyleOption*,
- const QSize&, const QWidget* = 0 ) const;
- virtual QPixmap standardPixmap( StandardPixmap, const QStyleOption*,
- const QWidget* = 0) const;
- virtual int styleHint( StyleHint, const QStyleOption* = 0,
- const QWidget* = 0, QStyleHintReturn* = 0 ) const;
- virtual QRect subControlRect( ComplexControl, const QStyleOptionComplex*,
- SubControl, const QWidget* = 0 ) const;
- virtual QRect subElementRect( SubElement, const QStyleOption*, const QWidget* = 0 ) const;
+ virtual void drawControl( ControlElement, const QStyleOption*, QPainter*, const QWidget* ) const;
+ virtual void drawPrimitive( PrimitiveElement, const QStyleOption*,
+ QPainter*, const QWidget* = 0 ) const;
+ virtual int pixelMetric( PixelMetric, const QStyleOption* = 0,
+ const QWidget* = 0 ) const;
+ virtual QSize sizeFromContents ( ContentsType, const QStyleOption*,
+ const QSize&, const QWidget* = 0 ) const;
+ virtual QPixmap standardPixmap( StandardPixmap, const QStyleOption*,
+ const QWidget* = 0) const;
+ virtual int styleHint( StyleHint, const QStyleOption* = 0,
+ const QWidget* = 0, QStyleHintReturn* = 0 ) const;
+ virtual QRect subControlRect( ComplexControl, const QStyleOptionComplex*,
+ SubControl, const QWidget* = 0 ) const;
+ virtual QRect subElementRect( SubElement, const QStyleOption*, const QWidget* = 0 ) const;
protected slots:
- QIcon standardIconImplementation( StandardPixmap, const QStyleOption* = 0,
- const QWidget* = 0 ) const;
-
+ QIcon standardIconImplementation( StandardPixmap, const QStyleOption* = 0,
+ const QWidget* = 0 ) const;
private:
- void updatePaletteColors();
- void updateAllWidgets( QApplication* );
- bool hasHover() const;
- void drawHoverRect( QPainter*, const QRect&, const QColor&, const double,
- const int, const bool ) const;
- void drawHandle( QPainter*, const QRect&, bool, bool = true ) const;
- void drawBackground( QPainter*, const QRect&, const QColor&, const bool,
- const bool = false, const bool = true ) const;
- void drawBorder( QPainter*, const QRect&, bool ) const;
-
- QColor getColor( int ) const;
- double getDblValue( int ) const;
- int getIntValue( int ) const;
- bool getBoolValue( int ) const;
- QString getStringValue( int ) const;
- QString titleText( const QString&, const int, const int, QFont& ) const;
+ void updatePaletteColors();
+ void updateAllWidgets( QApplication* );
+ bool hasHover() const;
+ void drawHoverRect( QPainter*, const QRect&, const QColor&, const double,
+ const int, const bool ) const;
+ void drawHandle( QPainter*, const QRect&, bool, bool = true ) const;
+ void drawBackground( QPainter*, const QRect&, const QColor&, const bool,
+ const bool = false, const bool = true ) const;
+ void drawBorder( QPainter*, const QRect&, bool ) const;
+
+ QString titleText( const QString&, const int, const int, QFont& ) const;
private:
- Style_Model* myModel;
- QColor myTTipWnd, myTTipText;
+ static Style_Model* myModel;
};
#endif // STYLE_SALOME_H
#include <QSize>
#include <QTabWidget>
+/*!
+ \class Style_Tools
+ \brief A set of utility functions used by SALOME style to draw widgets
+*/
+
+/*!
+ \brief Create painter path for specified rectangle
+ \param r rectangle on which painter path is build
+ \return resulting painter path
+*/
QPainterPath Style_Tools::painterPath( const QRect& r )
{
QPainterPath res;
return res;
}
+/*!
+ \brief Create painter path by subtracting painter path \a path from another
+ painter path \a fromPath
+ \param fromPath initial painter path
+ \param path painter path being subtracted from \a fromPath
+ \return resulting painter path
+*/
QPainterPath Style_Tools::substractPath( const QPainterPath& fromPath,
const QPainterPath& path )
{
return res;
}
+/*!
+ \brief Create painter path basing on specified rectangle \a r with rounded corners
+ specified by radius \a r, operation \a type and shadow type \a shType.
+ \param r initial rectangle
+ \param rad rounding radius
+ \param type rounding type operation (Style_Tools::RoundType)
+ \param shType shadow type (Style_Tools::ShadowType)
+ \return resulting painter path
+*/
QPainterPath Style_Tools::roundRect( const QRect& r, const double rad, int type,
int shType )
{
return res;
}
+/*!
+ \brief Draw rectangle with rounded corners.
+ \param p painter
+ \param r drawing rectangle
+ \param rad corner rounding radius
+ \param type rounding type operation (Style_Tools::RoundType)
+ \param c1 first gradient color
+ \param c2 second gradient color
+ \param fill if \c true rectangle is filled with gradiented background according to \a c1 and \a c2
+ \param antial if \c true, rectangle corners are anti-aliased
+*/
void Style_Tools::roundRect( QPainter* p, const QRect& r, const double rad, const int type,
const QColor& c1, const QColor& c2, bool fill, bool antial )
{
p->strokePath( path, QPen( c2, Qt::SolidLine ) );
}
+/*!
+ \brief Draw rectangle with rounded corners and shadow.
+ \param p painter
+ \param r drawing rectangle
+ \param rad corner rounding radius
+ \param marg drawing margin
+ \param shad shadow size
+ \param type rounding type operation (Style_Tools::RoundType)
+ \param light background's first gradient color
+ \param dark background's second gradient color
+ \param border_top top-left border's color
+ \param border_bot bottom-right border's color
+ \param antialize if \c true, rectangle corners are anti-aliased
+ \param isButton \c true if button is drawn
+ \param btnOn \c true if button is drawn and it is pressed
+ \param fill if \c true rectangle is filled with gradiented background according to \a light and \a dark
+*/
void Style_Tools::shadowRect( QPainter* p, const QRect& r, const double rad, const double marg,
const int shad, int type, const QColor& light, const QColor& dark,
const QColor& border_top, const QColor& border_bot, const bool antialize,
p->restore();
}
+/*!
+ \brief Draw shadow of the check-mark
+ \param p painter
+ \param r drawing rectangle
+ \param rad corner rounding radius
+ \param type rounding type operation (Style_Tools::RoundType)
+ \param light background's first gradient color
+ \param dark background's second gradient color
+ \param border_top top-left border's color
+ \param border_bot bottom-right border's color
+*/
void Style_Tools::shadowCheck( QPainter* p, const QRect& r, const double rad, const int type,
const QColor& light, const QColor& dark,
const QColor& border_top, const QColor& border_bot )
p->strokePath( topPath, border_top );
}
-
+/*!
+ \brief Draw rectnagle arrow
+ \param p painter
+ \param re drawing rectangle
+ \param frame frame color
+ \param gr1 background's first gradient color
+ \param gr2 background's second gradient color
+*/
void Style_Tools::arrowRect( QPainter* p, const QRect& re, const QColor& frame,
const QColor& gr1, const QColor& gr2 )
{
p->strokePath( path, QPen( frame, Qt::SolidLine ) );
}
-void Style_Tools::fillRect( QPainter* p, const QRect& re, const QColor& _c1,
- const QColor& _c2, const int alpha )
+/*!
+ \brief Fill rectangle with gradiented background
+ \param p painter
+ \param re drawing rectangle
+ \param c1 background's first gradient color
+ \param c2 background's second gradient color
+*/
+void Style_Tools::fillRect( QPainter* p, const QRect& re, const QColor& c1,
+ const QColor& c2, const int alpha )
{
QLinearGradient gr( re.x(), re.y(), re.x()+re.width(), re.y()+re.height() );
- QColor c1 = _c1, c2 = _c2;
- c1.setAlpha( alpha );
- c2.setAlpha( alpha );
- gr.setColorAt( 0.0, c1 );
- gr.setColorAt( 1.0, c2 );
+ QColor cc1 = c1, cc2 = c2;
+ cc1.setAlpha( alpha );
+ cc2.setAlpha( alpha );
+ gr.setColorAt( 0.0, cc1 );
+ gr.setColorAt( 1.0, cc2 );
p->fillRect( re, gr );
}
+/*!
+ \brief Draw arrow (for example, for combo-box drop-down menu button)
+ \param type primitive type
+ \param p painter
+ \param r drawing rectangle
+ \param pen foreground painter pen
+ \param brush background painter brush
+*/
void Style_Tools::drawArrow( QStyle::PrimitiveElement type, QPainter* p, const QRect& r,
const QColor& pen, const QColor& brush )
{
p->restore();
}
+/*!
+ \brief Draw indicator (for example, for spin box's increment/decrement buttons)
+ \param type primitive type
+ \param p painter
+ \param r drawing rectangle
+ \param pen foreground painter pen
+ \param brush background painter brush
+*/
void Style_Tools::drawSign( QStyle::PrimitiveElement type, QPainter* p, const QRect& r,
const QColor& pen, const QColor& brush )
{
p->restore();
}
+/*!
+ \brief Create painter path for tab bar and optionally draw it
+ \param p painter
+ \param r drawing rectangle
+ \param position tab position
+ \param rad rounding radius
+ \param delta gap between tabs
+ \param light background's first gradient color
+ \param dark background's second gradient color
+ \param border_top top-left border's color
+ \param border_bot bottom-right border's color
+ \param selected \c true if tab is selected
+ \param isLast \c true if tab is last in the tabs list
+ \param isHover \c true if tab is hovered
+ \param focusRect focus rectangle
+ \param draw if \c true, tab bar is drawn
+ \return tab bar's painter path
+*/
QPainterPath Style_Tools::tabRect( QPainter* p, const QRect& r, const int position, const double rad,
const double delta, const QColor& light, const QColor& dark,
const QColor& border_top, const QColor& border_bot,
return path;
}
+/*!
+ \brief Draw widget's focus
+ \param p painter
+ \param aRect drawing rectangle
+ \param rad rounding radius
+ \param type rounding operation type
+ \param border focus rectangle color
+*/
void Style_Tools::drawFocus( QPainter* p, const QRect& aRect, const double rad, const int type,
const QColor& border )
{
drawFocus( p, path, border );
}
+/*!
+ \brief Draw widget's focus
+ \param p painter
+ \param path drawing painter path
+ \param border focus rectangle color
+ \param line if \c true, focus is drawn as dotted line
+*/
void Style_Tools::drawFocus( QPainter* p, const QPainterPath& path, const QColor& border,
const bool line )
{
p->setPen( oldPen );
}
+/*!
+ \brief Draw slider
+ \param p painter
+ \param r drawing rectangle
+ \param rad rounding radius
+ \param slider slider type
+ \param light background's first gradient color
+ \param dark background's second gradient color
+ \param border_top top-left border's color
+ \param border_bot bottom-right border's color
+*/
void Style_Tools::drawSlider( QPainter* p, const QRect& r, const double rad,
SliderType type, const QColor& light, const QColor& dark,
const QColor& border_top, const QColor& border_bot )
p->restore();
}
+/*!
+ \brief Draw highlighted rectangle
+ \param p painter
+ \param rect drawing rectangle
+ \param rad rounding radius
+ \param type rounding operation type
+ \parma marg margin size
+ \param center background's center gradient color
+ \param out_center background's second color
+ \param border border color
+*/
void Style_Tools::highlightRect( QPainter* p, const QRect& rect, const double rad, const int type,
const double marg, const QColor& center, const QColor& out_center,
const QColor& border )
p->strokePath( path, border );
}
+/*!
+ \brief Get minimal delta value (the minimum between \a rect and \a size dimensions)
+ \param rect rectangle
+ \param size size
+ \param defDelta default minimum delta
+ \return resulting minimum value
+*/
int Style_Tools::getMinDelta( const QRect& rect, const QSize& size, const int defDelta )
{
int aDelta = defDelta;
return aDelta;
}
+/*!
+ \brief Get halved size of the quadrangle covering specified rectangle
+ \param rect rectangle
+ \param defRect default quadranle size value
+ \return resulting value
+*/
int Style_Tools::getMaxRect( const QRect& rect, const int defRect )
{
int aRect = defRect;
aRect = qMin( aRect, rect.width() / 2 );
return aRect;
}
-
#ifndef STYLE_TOOLS_H
#define STYLE_TOOLS_H
-#include "Style.h"
#include <QPainterPath>
#include <QRect>
#include <QColor>
#include <QStyle>
-class STYLE_SALOME_EXPORT Style_Tools
+//
+// This class is private for Style package.
+// Normally it should not be exported.
+//
+class Style_Tools
{
public:
- typedef enum { None = 0x00000000,
- All = 0x00000001,
- Right = 0x00000002,
- Left = 0x00000004,
- TopLeft = 0x00000008,
- TopRight = 0x00000010,
- BottomLeft = 0x00000020,
- BottomRight = 0x00000040
- } RoundType;
+ //! Rounding operation type
+ typedef enum {
+ None = 0x00000000, //!< No rounding required
+ All = 0x00000001, //!< All corners
+ Right = 0x00000002, //!< Right corners
+ Left = 0x00000004, //!< Left corners
+ TopLeft = 0x00000008, //!< Top-left corner
+ TopRight = 0x00000010, //!< Top-right corner
+ BottomLeft = 0x00000020, //!< Bottom-left corner
+ BottomRight = 0x00000040 //!< Bottom-right corner
+ } RoundType;
- typedef enum { WholePath, BottomPath, TopPath } ShadowType;
+ //! Shadow type
+ typedef enum {
+ WholePath, //!< Whole path
+ BottomPath, //!< Bottom path
+ TopPath //!< Top path
+ } ShadowType;
- typedef enum { SlUp, SlDown, SlLeft, SlRight, SlNone } SliderType;
+ //! Slider type
+ typedef enum {
+ SlUp, //!< Up-to-down gradient
+ SlDown, //!< Down-to-up gradient
+ SlLeft, //!< Left-to-right gradient
+ SlRight, //!< Right-to-left gradient
+ SlNone //!< No gradient
+ } SliderType;
static QPainterPath painterPath( const QRect& );
static QPainterPath substractPath( const QPainterPath&, const QPainterPath& );
--- /dev/null
+<document>
+ <section name="Steel-Blue">
+ <parameter name="button-color" value="silver" />
+ <parameter name="base-color" value="white" />
+ <parameter name="window-color" value="lightsteelblue" />
+ <parameter name="lines-color" value="blue" />
+ <parameter name="checked-color" value="cornflowerblue" />
+ <parameter name="header-color" value="silver" />
+ <parameter name="slider-color" value="cornflowerblue" />
+ <parameter name="pointer-color" value="midnightblue" />
+ <parameter name="field-light-color" value="whitesmoke" />
+ <parameter name="field-dark-color" value="#bababa" />
+ <parameter name="progress-bar-color" value="cornflowerblue" />
+ <parameter name="highlight-widget-color" value="skyblue" />
+ <parameter name="highlight-border-color" value="cornflowerblue" />
+ <parameter name="lines-type" value="0" />
+ <parameter name="slider-rad" value="3" />
+ <parameter name="edit-rad" value="6" />
+ <parameter name="button-rad" value="10" />
+ <parameter name="frame-rad" value="10" />
+ <parameter name="all-antialized" value="false" />
+ <parameter name="widget-effect" value="1" />
+ <parameter name="slider-size" value="5" />
+ </section>
+ <section name="Dark-Green">
+ <parameter name="button-color" value="#003300" />
+ <parameter name="window-color" value="black" />
+ <parameter name="text-color" value="white" />
+ <parameter name="bright-text-color" value="gold" />
+ <parameter name="window-text-color" value="gold" />
+ <parameter name="base-color" value="black" />
+ <parameter name="highlight-color" value="gold" />
+ <parameter name="highlight-text-color" value="goldenrod" />
+ <parameter name="light-color" value="goldenrod" />
+ <parameter name="dark-color" value="saddlebrown" />
+ <parameter name="lines-type" value="0" />
+ <parameter name="checked-color" value="black" />
+ <parameter name="header-color" value="#003300" />
+ <parameter name="slider-color" value="goldenrod" />
+ <parameter name="border-top-color" value="goldenrod" />
+ <parameter name="border-bottom-color" value="saddlebrown" />
+ <parameter name="tab-border-top-color" value="goldenrod" />
+ <parameter name="tab-border-bottom-color" value="saddlebrown" />
+ <parameter name="pointer-color" value="gold" />
+ <parameter name="field-light-color" value="green" />
+ <parameter name="field-dark-color" value="#003300" />
+ <parameter name="progress-bar-color" value="goldenrod" />
+ <parameter name="grid-line-color" value="saddlebrown" />
+ <parameter name="highlight-widget-color" value="green" />
+ <parameter name="highlight-border-color" value="#003300" />
+ <parameter name="tooltip-base-color" value="green" />
+ <parameter name="slider-rad" value="3" />
+ <parameter name="edit-rad" value="6" />
+ <parameter name="frame-rad" value="10" />
+ <parameter name="button-rad" value="10" />
+ <parameter name="all-antialized" value="false" />
+ <parameter name="slider-size" value="6" />
+ <parameter name="widget-effect" value="1" />
+ </section>
+ <section name="Green Sunset" >
+ <parameter name="button-color" value="#e6e7e6" />
+ <parameter name="text-color" value="#000000" />
+ <parameter name="base-color" value="#ffff7f" />
+ <parameter name="window-color" value="#aaff7f" />
+ <parameter name="light-color" value="#ffaaff" />
+ <parameter name="dark-color" value="#55aa00" />
+ <parameter name="button-text-color" value="#000000" />
+ <parameter name="window-text-color" value="#000000" />
+ <parameter name="tooltip-base-color" value="#e6e7e6" />
+ <parameter name="tooltip-text-color" value="#000000" />
+ <parameter name="highlight-color" value="#21449c" />
+ <parameter name="highlight-text-color" value="#ffffff" />
+ <parameter name="header-color" value="#e6e7e6" />
+ <parameter name="slider-color" value="#e6e7e6" />
+ <parameter name="progress-bar-color" value="#21449c" />
+ <parameter name="checked-color" value="#ffffff" />
+ <parameter name="pointer-color" value="#000000" />
+ <parameter name="grid-line-color" value="#c0c1c0" />
+ <parameter name="highlight-widget-color" value="#e6e7e6" />
+ <parameter name="highlight-border-color" value="#e6e7e6" />
+ <parameter name="lines-color" value="#c0c1c0" />
+ <parameter name="field-light-color" value="#ffaa7f" />
+ <parameter name="field-dark-color" value="#aa557f" />
+ <parameter name="lines-type" value="0" />
+ <parameter name="lines-transparency" value="0" />
+ <parameter name="hor-hadle-delta" value="3" />
+ <parameter name="ver-handle-delta" value="3" />
+ <parameter name="split-handle-len" value="20" />
+ <parameter name="all-antialized" value="false" />
+ <parameter name="slider-rad" value="3" />
+ <parameter name="edit-rad" value="0" />
+ <parameter name="button-rad" value="0" />
+ <parameter name="frame-rad" value="0" />
+ <parameter name="slider-size" value="5" />
+ <parameter name="widget-effect" value="2" />
+ <parameter name="application-font" value="DejaVu Sans,9" />
+ <parameter name="border-top-color" value="#00ff7f" />
+ <parameter name="border-bottom-color" value="#55557f" />
+ <parameter name="tab-border-top-color" value="#ff007f" />
+ <parameter name="tab-border-bottom-color" value="#55aaff" />
+ </section>
+</document>
#include <set>
#include <map>
-
-#ifdef WIN32
#include <algorithm>
-#endif
#include <vtkUnstructuredGrid.h>
#include <vtkGeometryFilter.h>