From: vsr Date: Mon, 6 Aug 2007 13:40:28 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: qt4_porting_delivery_220807~48 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1494402ad9850174bac32aef98bebf4f54118fbe;p=modules%2Fgui.git *** empty log message *** --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 4c7c22f81..98f5c142a 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1732,6 +1732,9 @@ LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const _prefs_->addPreference( mod->moduleName() ); if( toCreate ) mod->createPreferences(); + QtxPreferenceItem* item = _prefs_->findItem( mod->moduleName(), true ); + if ( item && item->isEmpty() ) + delete item; } } } @@ -1758,8 +1761,8 @@ void LightApp_Application::moduleAdded( CAM_Module* mod ) { int modCat = myPrefs->addPreference( mod->moduleName() ); lightMod->createPreferences(); - QtxPreferenceItem* item = myPrefs->findItem( modCat ); - if ( item && item->isEmpty() ) + QtxPreferenceItem* item = myPrefs->findItem( mod->moduleName(), true ); + if ( item && item->isEmpty() ) delete item; } } diff --git a/src/LightApp/Makefile.am b/src/LightApp/Makefile.am index 961bc5f5f..d6dcdba84 100755 --- a/src/LightApp/Makefile.am +++ b/src/LightApp/Makefile.am @@ -161,7 +161,7 @@ nodist_salomeres_DATA= \ libLightApp_la_CPPFLAGS=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(CAS_CPPFLAGS) \ $(HDF5_INCLUDES) @KERNEL_CXXFLAGS@ -I$(srcdir)/../SUIT -I$(srcdir)/../STD \ -I$(srcdir)/../CAM -I$(srcdir)/../ObjBrowser -I$(srcdir)/../LogWindow \ - -I$(srcdir)/../Prs -I$(srcdir)/../Qtx -I$(srcdir)/../Event -I$(srcdir)/../Style + -I$(srcdir)/../Prs -I$(srcdir)/../Qtx -I$(srcdir)/../Event -I$(srcdir)/../Style libLightApp_la_LDFLAGS=$(QT_MT_LIBS) if ENABLE_VTKVIEWER @@ -220,7 +220,7 @@ endif libLightApp_la_LIBADD= ../SUIT/libsuit.la ../STD/libstd.la ../CAM/libCAM.la \ ../LogWindow/libLogWindow.la $(CAS_KERNEL) \ - ../Prs/libSalomePrs.la ../ObjBrowser/libObjBrowser.la \ + ../Prs/libSalomePrs.la ../ObjBrowser/libObjBrowser.la ../Style/libSalomeStyle.la \ $(HDF5_LIBS) $(KERNEL_LDFLAGS) -lSalomeHDFPersist if ENABLE_SALOMEOBJECT diff --git a/src/Makefile.am b/src/Makefile.am index a3c6c5637..f15e72d6e 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,10 +24,7 @@ # Module : SALOME # $Header$ -# VSR: this is the original packages list -#SUBDIRS = Qtx Style DDS QDS SUIT STD CAF CAM SUITApp LogWindow ObjBrowser Prs -# VSR: already migrated to Qt4 packages -SUBDIRS = Qtx DDS QDS SUIT SUITApp STD CAF CAM LogWindow Prs ObjBrowser +SUBDIRS = Qtx Style DDS QDS SUIT SUITApp STD CAF CAM LogWindow Prs ObjBrowser if ENABLE_SALOMEOBJECT SUBDIRS += OBJECT @@ -64,7 +61,7 @@ endif if ENABLE_QXGRAPHVIEWER SUBDIRS += QxGraph endif -SUBDIRS += Event Style LightApp ResExporter +SUBDIRS += Event LightApp ResExporter if GUI_ENABLE_CORBA SUBDIRS += TOOLSGUI SalomeApp Session SALOME_SWIG SALOME_PY SALOME_PYQT diff --git a/src/SUITApp/Makefile.am b/src/SUITApp/Makefile.am index e79026278..5fcd21897 100644 --- a/src/SUITApp/Makefile.am +++ b/src/SUITApp/Makefile.am @@ -40,10 +40,10 @@ nodist_libSUITApp_la_SOURCES= $(MOC_FILES) nodist_salomeres_DATA= SUITApp_msg_en.qm libSUITApp_la_CPPFLAGS=$(QT_INCLUDES) $(PYTHON_INCLUDES) \ - -I$(srcdir)/../SUIT -I$(srcdir)/../Qtx + -I$(srcdir)/../SUIT -I$(srcdir)/../Qtx -I$(srcdir)/../Style libSUITApp_la_LDFLAGS=$(QT_MT_LIBS) -libSUITApp_la_LIBADD=../Qtx/libqtx.la ../SUIT/libsuit.la +libSUITApp_la_LIBADD=../Qtx/libqtx.la ../SUIT/libsuit.la ../Style/libSalomeStyle.la if ENABLE_PYCONSOLE libSUITApp_la_LDFLAGS+= -Xlinker -export-dynamic $(PYTHON_LIBS) @@ -55,6 +55,6 @@ bin_PROGRAMS= SUITApp dist_SUITApp_SOURCES=SUITApp.cxx SUITApp_CPPFLAGS=$(QT_INCLUDES) $(PYTHON_INCLUDES) \ - -I$(srcdir)/../SUIT -I$(srcdir)/../Qtx + -I$(srcdir)/../SUIT -I$(srcdir)/../Qtx -I$(srcdir)/../Style -SUITApp_LDADD= libSUITApp.la ../Qtx/libqtx.la ../SUIT/libsuit.la +SUITApp_LDADD= libSUITApp.la ../Qtx/libqtx.la ../SUIT/libsuit.la ../Style/libSalomeStyle.la diff --git a/src/SUITApp/SUITApp.cxx b/src/SUITApp/SUITApp.cxx index 5647e6bad..bb0b155f7 100644 --- a/src/SUITApp/SUITApp.cxx +++ b/src/SUITApp/SUITApp.cxx @@ -28,6 +28,8 @@ #include //#include #include +#include +#include // TODO //#include @@ -224,6 +226,10 @@ int main( int args, char* argv[] ) SUIT_Application* theApp = aSession->startApplication( argList.first() ); if ( theApp ) { + Style_Salome* aStyle = new Style_Salome(); + aStyle->getModel()->initFromResource( theApp->resourceMgr() ); + app.setStyle( aStyle ); + if ( !noExceptHandling ) app.setHandler( aSession->handler() ); diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 6828a87ea..111284dae 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -26,9 +26,9 @@ // Module : SALOME #include -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" -#include "SALOME_NamingService.hxx" +#include +#include +#include #include #include @@ -37,9 +37,9 @@ #include #include -#include "Utils_SALOME_Exception.hxx" -#include "Utils_CorbaException.hxx" -#include "SALOME_Event.h" +#include +#include +#include #include #include CORBA_SERVER_HEADER(SALOME_Session) @@ -52,12 +52,12 @@ #include #include #include -#include "SUIT_Tools.h" -#include "SUIT_Session.h" -#include "SUIT_Application.h" -#include "SUIT_Desktop.h" -#include "SUIT_ResourceMgr.h" -#include "SUIT_ExceptionHandler.h" +#include +#include +#include +#include +#include +#include /*! - read arguments, define list of server to launch with their arguments. * - wait for naming service diff --git a/src/Style/Makefile.am b/src/Style/Makefile.am index 2573ee252..c56fdb1a2 100644 --- a/src/Style/Makefile.am +++ b/src/Style/Makefile.am @@ -36,9 +36,13 @@ dist_libSalomeStyle_la_SOURCES= \ Style_Model.cxx \ Style_Salome.cxx +MOC_FILES= \ + Style_Salome_moc.cxx +nodist_libSalomeStyle_la_SOURCES= $(MOC_FILES) + libSalomeStyle_la_CPPFLAGS=$(QT_INCLUDES) \ - -I$(srcdir)/../Qtx -I$(srcdir)/../SUIT + -I$(srcdir)/../Qtx libSalomeStyle_la_LDFLAGS=$(QT_MT_LIBS) \ - ../Qtx/libqtx.la ../SUIT/libsuit.la + ../Qtx/libqtx.la diff --git a/src/Style/Style.h b/src/Style/Style.h index 829cf08df..10bc1f785 100644 --- a/src/Style/Style.h +++ b/src/Style/Style.h @@ -16,21 +16,21 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: Style.h -// Created: July, 2007 -// Author: OCC team +// File : Style.h +// Author : Natalia Ermolaeva, Open CASCADE S.A.S. +// + +#ifndef STYLE_H +#define STYLE_H -#if defined STYLE_SALOME_EXPORTS -#if defined WIN32 -#define STYLE_SALOME_EXPORT _declspec( dllexport ) -#else -#define STYLE_SALOME_EXPORT -#endif -#else #if defined WIN32 -#define STYLE_SALOME_EXPORT _declspec( dllimport ) +# if defined STYLE_SALOME_EXPORTS +# define STYLE_SALOME_EXPORT _declspec( dllexport ) +# else +# define STYLE_SALOME_EXPORT _declspec( dllimport ) +# endif #else -#define STYLE_SALOME_EXPORT -#endif +# define STYLE_SALOME_EXPORT #endif +#endif // STYLE_H diff --git a/src/Style/Style_Model.cxx b/src/Style/Style_Model.cxx index f35decc63..30195dc08 100644 --- a/src/Style/Style_Model.cxx +++ b/src/Style/Style_Model.cxx @@ -16,10 +16,11 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: Style_Model.cxx -// Author: Natalia Ermolaeva +// File : Style_Model.cxx +// Author : Natalia Ermolaeva, Open CASCADE S.A.S. +// -#include +#include "Style_Model.h" #include #include @@ -102,6 +103,11 @@ Style_Model::~Style_Model() { } +QString Style_Model::sectionName() +{ + return "Theme"; +} + void Style_Model::reset() { ValuesMap::iterator anIt = myValues.begin(), anEnd = myValues.end(); @@ -186,7 +192,7 @@ void Style_Model::initFromResource( QtxResourceMgr* theResMgr ) setPredefinedStyle( getIntValue( defined_style ) ); } -bool Style_Model::updateFromResource( QtxResourceMgr* theResMgr, QString thePropName ) +bool Style_Model::updateFromResource( QtxResourceMgr* theResMgr, const QString& thePropName ) { bool retrieve = false; if ( !theResMgr ) @@ -475,29 +481,25 @@ QFont Style_Model::getFontValue( int theId, const bool theIsDef ) const return aFont; } -QList Style_Model::getGroups() +QList Style_Model::getGroups() const { - QList values; - StringMap::iterator anIt = myGroups.begin(), anEnd = myGroups.end(); - for ( ; anIt != anEnd; ++anIt ) - values.append( anIt.key() ); - return values; + return myGroups.keys(); } -QString Style_Model::getGroupTitle( int theId ) +QString Style_Model::getGroupTitle( int theId ) const { return myGroups.contains( theId ) ? myGroups[theId].myTitle : ""; } -int Style_Model::getGroupNbColumns( int theId ) +int Style_Model::getGroupNbColumns( int theId ) const { return myGroups.contains( theId ) ? myGroups[theId].myNbColumns : 1; } -QList Style_Model::getGroupProps( int theId ) +QList Style_Model::getGroupProps( int theId ) const { QList values; - ValuesMap::iterator anIt = myValues.begin(), anEnd = myValues.end(); + ValuesMap::const_iterator anIt = myValues.begin(), anEnd = myValues.end(); for ( ; anIt != anEnd; ++anIt ) if ( anIt.value().myGroupId == theId ) values.append( anIt.key() ); @@ -505,22 +507,22 @@ QList Style_Model::getGroupProps( int theId ) } -QString Style_Model::getPropTitle( int theId ) +QString Style_Model::getPropTitle( int theId ) const { return myValues.contains( theId ) ? myValues[theId].myTitle : ""; } -Style_Model::PropType Style_Model::getPropType( int theId ) +Style_Model::PropType Style_Model::getPropType( int theId ) const { return myValues.contains( theId ) ? myValues[theId].myType : None; } -QString Style_Model::getPropName( int theId ) +QString Style_Model::getPropName( int theId ) const { return myValues.contains( theId ) ? myValues[theId].myName : ""; } -void Style_Model::getSelector( int theId, QStringList& theLst, QList& theIds ) +void Style_Model::getSelector( int theId, QStringList& theLst, QList& theIds ) const { theLst.clear(); theIds.clear(); @@ -535,19 +537,19 @@ void Style_Model::getSelector( int theId, QStringList& theLst, QList& theIds.append( QVariant( i++ ) ); } -void Style_Model::setDefValue( Properties theId, QVariant theValue ) +void Style_Model::setDefValue( Properties theId, const QVariant& theValue ) { myValues[theId].myDefValue = theValue; setValue( theId, theValue ); } -void Style_Model::setValue( Properties theId, QVariant theValue ) +void Style_Model::setValue( Properties theId, const QVariant& theValue ) { myValues[theId].myValue = theValue; } -void Style_Model::fillValue( Properties theId, QString theName, - QString theTitle, Groups theGroupId, PropType theType ) +void Style_Model::fillValue( Properties theId, const QString& theName, + const QString& theTitle, Groups theGroupId, PropType theType ) { StyleValue aValue; aValue.myName = theName; @@ -559,7 +561,7 @@ void Style_Model::fillValue( Properties theId, QString theName, myValues[theId] = aValue; } -void Style_Model::fillGroup( Groups theId, QString theTitle, int theNbCols ) +void Style_Model::fillGroup( Groups theId, const QString& theTitle, int theNbCols ) { GroupValue aValue; aValue.myTitle = theTitle; diff --git a/src/Style/Style_Model.h b/src/Style/Style_Model.h index 01a3aa666..4428c08c0 100644 --- a/src/Style/Style_Model.h +++ b/src/Style/Style_Model.h @@ -16,13 +16,14 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: Style_Model.h -// Author: Natalia Ermolaeva +// File : Style_Model.h +// Author : Natalia Ermolaeva, Open CASCADE S.A.S. +// -#ifndef STYLE_MODEL_HEADER -#define STYLE_MODEL_HEADER +#ifndef STYLE_MODEL_H +#define STYLE_MODEL_H -#include +#include "Style.h" #include #include @@ -40,7 +41,7 @@ public: Style_Model(); virtual ~Style_Model(); - static QString sectionName() { return "Theme"; } + static QString sectionName(); typedef enum { grp_style, grp_color, grp_col_values, grp_lines, grp_font, grp_value } Groups; @@ -66,41 +67,42 @@ public: edit_rad, btn_rad, slider_rad, slider_increase, hor_handle_delta, ver_handle_delta, split_handle_len, dock_wdg_sep_extent } Properties; + typedef enum { None, Bool, Color, String, IntSpin, DblSpin, Selector, Font } PropType; void reset(); - void setDefaults( QApplication* app ); - void initFromResource( QtxResourceMgr* theResMgr ); - bool updateFromResource( QtxResourceMgr* theResMgr, QString thePropName ); - - void getValueTo( QtxResourceMgr* theResMgr, int theId, bool theIsDef ); - void setValueFrom( QtxResourceMgr* theResMgr, int theId ); - - void setPredefinedStyle( int theType ); - - double getDblValue( int theId, const bool theIsDef = false ) const; - int getIntValue( int theId, const bool theIsDef = false ) const; - bool getBoolValue( int theId, const bool theIsDef = false ) const; - QColor getColorValue( int theId, const bool theIsDef = false ) const; - QString getStringValue( int theId, const bool theIsDef = false ) const; - QFont getFontValue( int theId, const bool theIsDef = false ) const; - - QList getGroups(); - QString getGroupTitle( int theId ); - int getGroupNbColumns( int theId ); - QList getGroupProps( int theId ); - QString getPropTitle( int theId ); - PropType getPropType( int theId ); - QString getPropName( int theId ); - void getSelector( int theId, QStringList& theLst, QList& theIds ); + 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 getGroups() const; + QString getGroupTitle( int ) const; + int getGroupNbColumns( int ) const; + QList getGroupProps( int ) const; + QString getPropTitle( int ) const; + PropType getPropType( int ) const; + QString getPropName( int ) const; + void getSelector( int, QStringList&, QList& ) const; private: - void setDefValue( Properties theId, QVariant theValue ); - void setValue( Properties theId, QVariant theValue ); + void setDefValue( Properties, const QVariant& ); + void setValue( Properties, const QVariant& ); - void fillValue( Properties theId, QString theName, QString theTitle, - Groups theGroupId, PropType theType = Color ); - void fillGroup( Groups theId, QString theTitle, int theNbCols ); + void fillValue( Properties, const QString&, const QString&, + Groups, PropType = Color ); + void fillGroup( Groups, const QString&, int ); private: typedef struct { @@ -126,4 +128,4 @@ private: QStringList myLines; }; -#endif +#endif // STYLE_MODEL_H diff --git a/src/Style/Style_Salome.cxx b/src/Style/Style_Salome.cxx index e0d9db3c2..1b050fd19 100644 --- a/src/Style/Style_Salome.cxx +++ b/src/Style/Style_Salome.cxx @@ -16,12 +16,13 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: Style_Salome.cxx -// Author: Natalia Ermolaeva +// File : Style_Salome.cxx +// Author : Natalia Ermolaeva, Open CASCADE S.A.S. +// -#include -#include -#include +#include "Style_Salome.h" +#include "Style_Tools.h" +#include "Style_Model.h" #include #include @@ -170,6 +171,11 @@ Style_Salome::~Style_Salome() { } +Style_Model* Style_Salome::getModel() const +{ + return myModel; +} + void Style_Salome::updateSettings( QApplication* app ) { updatePaletteColors(); diff --git a/src/Style/Style_Salome.h b/src/Style/Style_Salome.h index fe2daf615..25c09e0c3 100644 --- a/src/Style/Style_Salome.h +++ b/src/Style/Style_Salome.h @@ -16,16 +16,16 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: Style_Salome.h -// Author: Natalia Ermolaeva +// File : Style_Salome.h +// Author : Natalia Ermolaeva, Open CASCADE S.A.S. +// -#ifndef STYLE_SALOME_HEADER -#define STYLE_SALOME_HEADER +#ifndef STYLE_SALOME_H +#define STYLE_SALOME_H -#include +#include "Style.h" #include -#include #include class Style_Model; @@ -39,55 +39,56 @@ class QVariant; class STYLE_SALOME_EXPORT Style_Salome : public QWindowsStyle { + Q_OBJECT public: Style_Salome(); virtual ~Style_Salome(); - Style_Model* getModel() { return myModel; } - - void updateSettings( QApplication* app ); + Style_Model* getModel() const; - virtual void polish( QApplication* app ); - virtual void polish( QWidget *widget ); - virtual void unpolish( QWidget *widget ); - virtual void drawComplexControl( ComplexControl, const QStyleOptionComplex*, - QPainter*, const QWidget* = 0 ) const; + void updateSettings( QApplication* ); - 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 metric, const QStyleOption* opt = 0, - const QWidget* w = 0 ) const; - virtual QSize sizeFromContents ( ContentsType ct, const QStyleOption* opt, - const QSize& contentsSize, const QWidget* w = 0 ) const; - virtual QPixmap standardPixmap(StandardPixmap stPixmap, const QStyleOption *opt, - const QWidget *widget = 0) const; - virtual int styleHint ( StyleHint hint, const QStyleOption * option = 0, - const QWidget * widget = 0, QStyleHintReturn * returnData = 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 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; private: - void updatePaletteColors(); - void updateAllWidgets( QApplication* app ); - bool hasHover() const; - void drawHoverRect( QPainter* p, const QRect& r, const double rad, const int type, - const bool border ) const; - void drawHandle( QPainter* p, const QRect& r, bool horiz, bool isRect = true ) const; - void drawBackground( QPainter* p, const QRect& r, const bool fill, - const bool grad = false, const bool horiz = true ) const; - void drawBorder( QPainter* p, const QRect& r, bool horiz ) const; + void updatePaletteColors(); + void updateAllWidgets( QApplication* ); + bool hasHover() const; + void drawHoverRect( QPainter*, const QRect&, const double, const int, + const bool ) const; + void drawHandle( QPainter*, const QRect&, bool, bool = true ) const; + void drawBackground( QPainter*, const QRect&, const bool, + const bool = false, const bool = true ) const; + void drawBorder( QPainter*, const QRect&, bool ) const; - QColor getColor( int id ) const; - double getDblValue( int id ) const; - int getIntValue( int id ) const; - bool getBoolValue( int id ) const; - QString getStringValue( int id ) const; - QString titleText( const QString&, const int, const int, QFont& f ) 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; private: - Style_Model* myModel; + Style_Model* myModel; }; -#endif +#endif // STYLE_SALOME_H diff --git a/src/Style/Style_Tools.cxx b/src/Style/Style_Tools.cxx index 81da27c66..43d455010 100644 --- a/src/Style/Style_Tools.cxx +++ b/src/Style/Style_Tools.cxx @@ -16,10 +16,11 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: Style_Tools.cxx -// Author: Natalia Ermolaeva +// File : Style_Tools.cxx +// Author : Natalia Ermolaeva, Open CASCADE S.A.S. +// -#include +#include "Style_Tools.h" #include #include @@ -471,7 +472,7 @@ void Style_Tools::drawFocus( QPainter* p, const QRect& aRect, const double rad, } void Style_Tools::drawFocus( QPainter* p, const QPainterPath& path, const QColor& border, - const bool& line ) + const bool line ) { QPen oldPen = p->pen(); QPen aPen = oldPen; @@ -587,27 +588,19 @@ void Style_Tools::highlightRect( QPainter* p, const QRect& rect, const double ra p->strokePath( path, border ); } -int Style_Tools::getMinDelta( const QRect& rect, QSize size, const int defDelta ) +int Style_Tools::getMinDelta( const QRect& rect, const QSize& size, const int defDelta ) { int aDelta = defDelta; - int height = rect.height(), width = rect.width(); - int aTmpDelta = (height - size.rheight())/2; - if ( aTmpDelta < aDelta ) - aDelta = aTmpDelta; - aTmpDelta = (width - size.width())/2; - if ( aTmpDelta < aDelta ) - aDelta = aTmpDelta; + aDelta = qMin( aDelta, ( rect.height() - size.height() ) / 2 ); + aDelta = qMin( aDelta, ( rect.width() - size.width() ) / 2 ); return aDelta; } int Style_Tools::getMaxRect( const QRect& rect, const int defRect ) { int aRect = defRect; - int height2 = (int)rect.height()/2, width2 = (int)rect.width()/2; - if ( aRect > height2 ) - aRect = height2; - if ( aRect > width2 ) - aRect = width2; + aRect = qMin( aRect, rect.height() / 2 ); + aRect = qMin( aRect, rect.width() / 2 ); return aRect; } diff --git a/src/Style/Style_Tools.h b/src/Style/Style_Tools.h index bffca3cfb..381c5a3d2 100644 --- a/src/Style/Style_Tools.h +++ b/src/Style/Style_Tools.h @@ -16,13 +16,14 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: Style_Tools.h -// Author: Natalia Ermolaeva +// File : Style_Tools.h +// Author : Natalia Ermolaeva, Open CASCADE S.A.S. +// -#ifndef STYLE_TOOLS_HEADER -#define STYLE_TOOLS_HEADER +#ifndef STYLE_TOOLS_H +#define STYLE_TOOLS_H -#include +#include "Style.h" #include #include #include @@ -40,50 +41,50 @@ public: BottomLeft = 0x00000020, BottomRight = 0x00000040 } RoundType; + typedef enum { WholePath, BottomPath, TopPath } ShadowType; typedef enum { SlUp, SlDown, SlLeft, SlRight, SlNone } SliderType; - static QPainterPath painterPath( const QRect& r ); - static QPainterPath substractPath( const QPainterPath& fromPath, const QPainterPath& path ); + static QPainterPath painterPath( const QRect& ); + static QPainterPath substractPath( const QPainterPath&, const QPainterPath& ); + + static QPainterPath roundRect( const QRect&, const double, int = 0, int = 0 ); - static QPainterPath roundRect( const QRect& r, const double rad, int type = 0, - int shType = 0 ); + static void roundRect( QPainter*, const QRect&, const double, const int, + const QColor&, const QColor&, bool = true, bool = true ); - static void roundRect( QPainter* p, const QRect& r, const double rad, const int type, - const QColor& c1, const QColor& c2, bool fill = true, - bool antial = true ); - static void 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, const bool isButton, - const bool btnOn = false, const bool fill = true ); - static void 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 ); - static void arrowRect( QPainter* p, const QRect& re, const QColor& frame, - const QColor& gr1, const QColor& gr2 ); - static void fillRect( QPainter* p, const QRect& re, const QColor& _c1, - const QColor& _c2, const int alpha = 255 ); - static void drawArrow( QStyle::PrimitiveElement type, QPainter* p, const QRect& r, - const QColor& pen, const QColor& brush ); - static QPainterPath 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, - const bool selected, const bool isLast, const bool isHover, - const bool focusRect = false, const bool draw = true ); - static void drawFocus( QPainter* p, const QRect& aRect, const double rad, const int type, - const QColor& border ); - static void drawFocus( QPainter* p, const QPainterPath& path, const QColor& border, - const bool& line = true ); - static void 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 ); - static void 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 ); - static int getMinDelta( const QRect& rect, QSize size, const int defDelta ); - static int getMaxRect( const QRect& rect, const int defRect ); + static void shadowRect( QPainter*, const QRect&, const double, + const double, const int, int, + const QColor&, const QColor&, const QColor&, + const QColor&, const bool, const bool, + const bool = false, const bool = true ); + static void shadowCheck( QPainter*, const QRect&, const double, const int, + const QColor&, const QColor&, + const QColor&, const QColor& ); + static void arrowRect( QPainter*, const QRect&, const QColor&, + const QColor&, const QColor& ); + static void fillRect( QPainter*, const QRect&, const QColor&, + const QColor&, const int = 255 ); + static void drawArrow( QStyle::PrimitiveElement, QPainter*, const QRect&, + const QColor&, const QColor& ); + static QPainterPath tabRect( QPainter*, const QRect&, const int, const double, + const double, const QColor&, const QColor&, + const QColor&, const QColor&, + const bool, const bool, const bool, + const bool = false, const bool = true ); + static void drawFocus( QPainter*, const QRect&, const double, const int, + const QColor& ); + static void drawFocus( QPainter*, const QPainterPath&, const QColor&, + const bool = true ); + static void drawSlider( QPainter*, const QRect&, const double, + SliderType, const QColor&, const QColor&, + const QColor&, const QColor& ); + static void highlightRect( QPainter*, const QRect&, const double, const int, + const double, const QColor&, const QColor&, + const QColor& ); + static int getMinDelta( const QRect&, const QSize&, const int ); + static int getMaxRect( const QRect&, const int ); }; -#endif +#endif // STYLE_TOOLS_H