Salome HOME
PR: Merge V1_2c etape 1
[modules/kernel.git] / src / SALOMEGUI / QAD_Menus.cxx
1 //  SALOME SALOMEGUI : implementation of desktop and GUI kernel
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : QAD_Menus.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 using namespace std;
30 #include "QAD_Menus.h"
31
32 /*!
33   Constructor.
34 */
35 QAD_Menus::QAD_Menus(QMainWindow* theParent)
36 {
37   myMainWindow=theParent;
38   myToolBarList.setAutoDelete(TRUE);
39 }
40
41 /*!
42   Desctructor.
43 */
44 QAD_Menus::~QAD_Menus()
45 {
46   myToolBarList.clear();
47   myPopupMenuList.clear();
48   myMenuBarList.clear();
49   myMenuList.clear();
50 }
51
52 /*!
53   Appends a MenuBar
54 */
55 void QAD_Menus::append(QMenuBar* theMenuBar)
56 {
57   myMenuBarList.append(theMenuBar);
58 }
59
60 /*!
61   Appends a ToolBar
62 */
63 void QAD_Menus::append(QToolBar* theToolBar)
64 {
65   myToolBarList.append(theToolBar);
66 }
67
68 /*!
69   Appends a PopupMenu
70 */
71 void QAD_Menus::append(QAD_ListPopupMenu* thePopupMenu)
72 {
73   myPopupMenuList.append(thePopupMenu);
74 }
75
76 /*!
77   Appends a MenuId
78 */
79 void QAD_Menus::append(QAD_ListMenuIdAction* theMenu)
80 {
81   myMenuList.append(theMenu);
82 }
83
84 /*!
85   Shows a ToolBar
86 */
87 void QAD_Menus::showToolBar(QToolBar* theToolBar)
88 {
89   if(theToolBar!=NULL && theToolBar->isHidden()) {
90     theToolBar->show();
91   }
92 }
93
94 /*!
95   Shows all ToolBars
96 */
97 void QAD_Menus::showAllToolBars()
98 {
99   QToolBar* aToolBar;
100   
101   for(aToolBar=myToolBarList.first();aToolBar!=NULL;aToolBar=myToolBarList.next()) {
102     if(aToolBar->isHidden()) {
103       aToolBar->show();
104     }
105   }
106 }
107
108 /*!
109   Hides a ToolBar
110 */
111 void QAD_Menus::hideToolBar(QToolBar* theToolBar)
112 {
113   if(theToolBar!=NULL && theToolBar->isVisible()) {
114     theToolBar->hide();
115   }
116 }
117
118 /*!
119   Hides all ToolBars
120 */
121 void QAD_Menus::hideAllToolBars()
122 {
123   QToolBar* aToolBar;
124   
125   for(aToolBar=myToolBarList.first();aToolBar!=NULL;aToolBar=myToolBarList.next()) {
126     if(aToolBar->isVisible()) {
127       aToolBar->hide();
128     }
129   }
130 }
131
132 /*!
133   Sets current MenuBar
134 */
135 void QAD_Menus::setActiveMenuBar(QMenuBar* theMenuBar)
136 {
137   myActiveMenuBar=theMenuBar;
138 }
139
140 /*!
141   Sets current setActivePopupMenu with index \a thePopupMenuIndex
142 */
143 void QAD_Menus::setActivePopupMenu(int thePopupMenuIndex)
144 {
145   myActivePopupMenu=myPopupMenuList.at(thePopupMenuIndex)->getPopup();
146 }
147
148 /*!
149   Sets current PopupMenu
150 */
151 void QAD_Menus::setActivePopupMenu(QPopupMenu* thePopupMenu)
152 {
153   myActivePopupMenu=thePopupMenu;
154 }
155
156 /*!
157   Sets current ToolBar with index \a theToolBarIndex
158 */
159 void QAD_Menus::setActiveToolBar(int theToolBarIndex)
160 {
161   myActiveToolBar=myToolBarList.at(theToolBarIndex);
162 }
163
164 /*!
165   Sets current ToolBar
166 */
167 void QAD_Menus::setActiveToolBar(QToolBar* theToolBar)
168 {
169   myActiveToolBar=theToolBar;
170 }