Salome HOME
Fix for the issue #2753 : error when dump/load script
[modules/shaper.git] / src / ModuleBase / ModuleBase_PagedContainer.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef MODULEBASE_PAGEDCONTAINER_H_
22 #define MODULEBASE_PAGEDCONTAINER_H_
23
24 #include <ModuleBase.h>
25 #include <ModuleBase_ModelWidget.h>
26
27 class ModuleBase_PageBase;
28
29 /**
30 * \ingroup GUI
31 * This is an abstract interface to be used for not model container widget such as switch or tool box.
32 */
33 class MODULEBASE_EXPORT ModuleBase_PagedContainer : public ModuleBase_ModelWidget
34 {
35   Q_OBJECT
36  public:
37    /// A constructor
38    /// \param theParent a parent widget
39    /// \param theData a data of the widget
40   ModuleBase_PagedContainer(QWidget* theParent, const Config_WidgetAPI* theData);
41   virtual ~ModuleBase_PagedContainer();
42
43   /// Add a new page
44   /// \param theWidget a page object
45   /// \param theName a name of the page
46   /// \param theCaseId an Id of the page
47   /// \param theIcon aqn Icon of the page
48   virtual int addPage( ModuleBase_PageBase* theWidget,
49                        const QString& theName,
50                        const QString& theCaseId,
51                        const QPixmap& theIcon,
52                        const QString& theTooltip);
53
54   /// Redefinition of virtual function
55   virtual QList<QWidget*> getControls() const;
56
57   /// Redefinition of virtual function
58   virtual bool focusTo();
59
60   /// Redefinition of virtual function
61   virtual void setHighlighted(bool isHighlighted);
62
63   /// Redefinition of virtual function
64   virtual void enableFocusProcessing();
65
66   /// The slot is called when user press Ok or OkPlus buttons in the parent property panel
67   virtual void onFeatureAccepted();
68
69  protected:
70    /// Returns index of current page
71   virtual int currentPageIndex() const = 0;
72
73   /// Set current page by index
74   virtual void setCurrentPageIndex(int ) = 0;
75
76   /// Redefinition of virtual function
77   virtual void activateCustom();
78
79   /// Redefinition of virtual function
80   virtual bool storeValueCustom();
81
82   /// Redefinition of virtual function
83   virtual bool restoreValueCustom();
84
85   // A flag which let to remeber last user choice and restore it on next launch
86   bool myRemeberChoice;
87
88  protected slots:
89    /// A slot called on page change
90   void onPageChanged();
91
92  private:
93   bool myIsFocusOnCurrentPage;
94   QStringList myCaseIds;
95   QList<ModuleBase_PageBase*> myPages;
96   bool myIsFirst;
97   std::string myDefValue;
98 };
99
100 #endif /* MODULEBASE_PAGEDCONTAINER_H_ */