From 3c7c1720aeda4744c4fb473b009af2314e67b1d7 Mon Sep 17 00:00:00 2001 From: ptv Date: Thu, 30 Nov 2006 08:47:34 +0000 Subject: [PATCH] add widget action --- src/Qtx/Makefile.in | 9 ++- src/Qtx/QtxWidgetAction.cxx | 123 ++++++++++++++++++++++++++++++++++++ src/Qtx/QtxWidgetAction.h | 57 +++++++++++++++++ 3 files changed, 186 insertions(+), 3 deletions(-) create mode 100755 src/Qtx/QtxWidgetAction.cxx create mode 100755 src/Qtx/QtxWidgetAction.h diff --git a/src/Qtx/Makefile.in b/src/Qtx/Makefile.in index 68bb37831..4c21f4c93 100755 --- a/src/Qtx/Makefile.in +++ b/src/Qtx/Makefile.in @@ -70,7 +70,8 @@ EXPORT_HEADERS= Qtx.h \ QtxDirListEditor.h \ QtxDblValidator.h \ QtxSplash.h \ - QtxStyleWrap.h + QtxStyleWrap.h \ + QtxWidgetAction.h # .po files to transform in .qm @@ -120,7 +121,8 @@ LIB_SRC= \ QtxDirListEditor.cxx \ QtxDblValidator.cxx \ QtxSplash.cxx \ - QtxStyleWrap.cxx + QtxStyleWrap.cxx \ + QtxWidgetAction.cxx LIB_MOC = \ QtxAction.h \ @@ -155,7 +157,8 @@ LIB_MOC = \ QtxDirListEditor.h \ QtxDblValidator.h \ QtxSplash.h \ - QtxStyleWrap.h + QtxStyleWrap.h \ + QtxWidgetAction.h RESOURCES_FILES = \ diff --git a/src/Qtx/QtxWidgetAction.cxx b/src/Qtx/QtxWidgetAction.cxx new file mode 100755 index 000000000..13247c9a5 --- /dev/null +++ b/src/Qtx/QtxWidgetAction.cxx @@ -0,0 +1,123 @@ +// 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: QtxWidgetAction.ñxx +// Author: Sergey LITONIN + +#include "QtxWidgetAction.h" + +#include + +/* + Class : QtxWidgetAction + Description : Action having look and fill of arbitrary widget +*/ + +//================================================================ +// Function : QtxWidgetAction +// Purpose : +//================================================================ +QtxWidgetAction::QtxWidgetAction( QObject* theParent, + const char* theName, + bool theIsToggle ) +: QtxAction( theParent, theName, theIsToggle ), + myWg( 0 ) +{ +} + +QtxWidgetAction::~QtxWidgetAction() +{ + if ( myWg && !myWg->parent() ) + delete myWg; +} + +/*! + addTo + redefined to reparent action +*/ +bool QtxWidgetAction::addTo( QWidget* theParent ) +{ + if ( myWg ) + myWg->reparent( theParent, QPoint(), isVisible() ); + + //return QtxAction::addTo( theParent ); + return true; +} + +/*! + addTo + redefined to reparent action +*/ +bool QtxWidgetAction::addTo( QWidget* theParent, const int theIndex ) +{ + if ( myWg ) + myWg->reparent( theParent, QPoint(), isVisible() ); + return true; +} + +/*! + removeFrom + redefined to remove widget action from parent +*/ +bool QtxWidgetAction::removeFrom( QWidget* theParent ) +{ + if ( myWg ) + myWg->reparent( 0, QPoint(), false ); + return QtxAction::removeFrom( theParent ); +} + +/*! + setEnabled + enable/disbale widget of action +*/ +void QtxWidgetAction::setEnabled( bool theState ) +{ + QtxAction::setEnabled( theState ); + if ( myWg ) + myWg->setEnabled( theState ); +} + +/*! + setVisible + enable/disbale widget of action +*/ +void QtxWidgetAction::setVisible( bool theState ) +{ + QtxAction::setVisible( theState ); + if ( myWg ) + myWg->setShown( parent() && theState ); +} + +/*! + setWidget + sets widget to action +*/ +void QtxWidgetAction::setWidget( QWidget* theWg ) +{ + myWg = theWg; +} + +/*! + widget + \return widget of action +*/ +QWidget* QtxWidgetAction::widget() const +{ + return myWg; +} + diff --git a/src/Qtx/QtxWidgetAction.h b/src/Qtx/QtxWidgetAction.h new file mode 100755 index 000000000..6c5e14dc5 --- /dev/null +++ b/src/Qtx/QtxWidgetAction.h @@ -0,0 +1,57 @@ +// 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: QtxWidgetAction.h +// Author: Sergey LITONIN + +#ifndef QTXWIDGETACTION_H +#define QTXWIDGETACTION_H + +#include "QtxAction.h" + +/* + Class : QtxWidgetAction + Description : Action having look and fill of arbitrary widget +*/ + +class QTX_EXPORT QtxWidgetAction : public QtxAction +{ + Q_OBJECT + +public: + + QtxWidgetAction( QObject* theParent = 0, const char* theName = 0, bool theIsToggle = false ); + virtual ~QtxWidgetAction(); + + virtual bool addTo( QWidget* ); + virtual bool addTo( QWidget*, const int ); + virtual bool removeFrom( QWidget* ); + + void setWidget( QWidget* ); + QWidget* widget() const; + +public slots: + virtual void setEnabled( bool ); + virtual void setVisible( bool ); + +private: + + QWidget* myWg; +}; + +#endif -- 2.39.2