Salome HOME
Update copyrights
[modules/shaper.git] / src / ModuleBase / ModuleBase_PagedContainer.h
1 // Copyright (C) 2014-2019  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 email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef MODULEBASE_PAGEDCONTAINER_H_
21 #define MODULEBASE_PAGEDCONTAINER_H_
22
23 #include <ModuleBase.h>
24 #include <ModuleBase_ModelWidget.h>
25
26 class ModuleBase_PageBase;
27
28 /**
29 * \ingroup GUI
30 * This is an abstract interface to be used for not model container widget such as switch or tool box.
31 */
32 class MODULEBASE_EXPORT ModuleBase_PagedContainer : public ModuleBase_ModelWidget
33 {
34   Q_OBJECT
35  public:
36    /// A constructor
37    /// \param theParent a parent widget
38    /// \param theData a data of the widget
39   ModuleBase_PagedContainer(QWidget* theParent, const Config_WidgetAPI* theData);
40   virtual ~ModuleBase_PagedContainer();
41
42   /// Add a new page
43   /// \param theWidget a page object
44   /// \param theName a name of the page
45   /// \param theCaseId an Id of the page
46   /// \param theIcon aqn Icon of the page
47   virtual int addPage( ModuleBase_PageBase* theWidget,
48                        const QString& theName,
49                        const QString& theCaseId,
50                        const QPixmap& theIcon,
51                        const QString& theTooltip);
52
53   /// Redefinition of virtual function
54   virtual QList<QWidget*> getControls() const;
55
56   /// Redefinition of virtual function
57   virtual bool focusTo();
58
59   /// Redefinition of virtual function
60   virtual void setHighlighted(bool isHighlighted);
61
62   /// Redefinition of virtual function
63   virtual void enableFocusProcessing();
64
65   /// The slot is called when user press Ok or OkPlus buttons in the parent property panel
66   virtual void onFeatureAccepted();
67
68  protected:
69    /// Returns index of current page
70   virtual int currentPageIndex() const = 0;
71
72   /// Set current page by index
73   virtual void setCurrentPageIndex(int ) = 0;
74
75   /// Redefinition of virtual function
76   virtual void activateCustom();
77
78   /// Redefinition of virtual function
79   virtual bool storeValueCustom();
80
81   /// Redefinition of virtual function
82   virtual bool restoreValueCustom();
83
84   // A flag which let to remeber last user choice and restore it on next launch
85   bool myRemeberChoice;
86
87  protected slots:
88    /// A slot called on page change
89   void onPageChanged();
90
91  private:
92   bool myIsFocusOnCurrentPage;
93   QStringList myCaseIds;
94   QList<ModuleBase_PageBase*> myPages;
95   bool myIsFirst;
96   std::string myDefValue;
97 };
98
99 #endif /* MODULEBASE_PAGEDCONTAINER_H_ */