Salome HOME
sources v1.2
[modules/kernel.git] / src / SALOMEGUI / QAD_OperatorMenus.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_OperatorMenus.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 using namespace std;
30 #include "QAD_OperatorMenus.h"
31 #include "QAD_Desktop.h"
32
33 /*!
34   Constructor.
35 */
36 QAD_OperatorMenus::QAD_OperatorMenus(QAD_Desktop* theDesktop)
37 {
38   myDesktop=theDesktop;
39 }
40
41 /*!
42   Destructor.
43 */
44 QAD_OperatorMenus::~QAD_OperatorMenus()
45 {
46 }
47
48 /*!
49   Builds popup menu with a 'Context', a 'Parent' and an 'Object'.
50   Parent is equal to 'Objectbrowser' or 'Viewer'.
51 */
52 QAD_ListPopupMenu* QAD_OperatorMenus::createPopupMenu(const QString & theContext,
53                                                       const QString & theParent,
54                                                       const QString & theObject)
55 {
56   QAD_Menus* aMenus = myDesktop->getActiveMenus();
57   QAD_ListPopupMenu* aPopup;
58
59   QList<QAD_ListPopupMenu> PopupList = aMenus->getPopupMenuList();
60
61   for(aPopup=PopupList.first();aPopup!=NULL;aPopup=PopupList.next()){
62     if ((aPopup->getContext().compare(theContext)==0) &&
63         (aPopup->getParent().compare(theParent)==0) &&
64         (aPopup->getObject().compare(theObject)==0)) {
65       return aPopup;
66     }
67   }
68   return NULL;
69 }
70
71 QAD_ListPopupMenu* QAD_OperatorMenus::createPopupMenu(int thePopupMenuId)
72 {
73   QAD_Menus* aMenus = myDesktop->getActiveMenus();
74
75   if(!aMenus->getPopupMenuList().isEmpty() && 
76      aMenus->getPopupMenuList().at(thePopupMenuId)!=NULL) {
77     return aMenus->getPopupMenuList().at(thePopupMenuId);
78   } else
79     return NULL;
80 }
81
82 void QAD_OperatorMenus::showMenuBar(int theMenuBarId)
83
84 {
85   QAD_Menus* aMenus = myDesktop->getActiveMenus();
86   if(!aMenus->getMenuBarList().isEmpty() && 
87      aMenus->getMenuBarList().at(theMenuBarId)!=NULL) {
88     aMenus->getMenuBarList().at(theMenuBarId)->show();
89   }
90 }
91
92 void QAD_OperatorMenus::hideMenuBar(int theMenuBarId)
93
94 {
95   QAD_Menus* aMenus;
96   aMenus=myDesktop->getActiveMenus();
97   if(!aMenus->getMenuBarList().isEmpty() && 
98      aMenus->getMenuBarList().at(theMenuBarId)!=NULL) {
99     aMenus->getMenuBarList().at(theMenuBarId)->hide();
100   }
101 }
102
103 void QAD_OperatorMenus::showToolBar(int theToolBarId)
104
105 {
106   QAD_Menus* aMenus;
107   
108   aMenus=myDesktop->getActiveMenus();
109   if(!aMenus->getToolBarList().isEmpty() && 
110      aMenus->getToolBarList().at(theToolBarId)!=NULL) {
111     aMenus->getToolBarList().at(theToolBarId)->show();
112   }
113 }
114
115 void QAD_OperatorMenus::hideToolBar(int theToolBarId)
116
117 {
118   QAD_Menus* aMenus;
119   
120   aMenus=myDesktop->getActiveMenus();
121   if(!aMenus->getToolBarList().isEmpty() && 
122      aMenus->getToolBarList().at(theToolBarId)!=NULL) {
123     aMenus->getToolBarList().at(theToolBarId)->hide();
124   }
125 }
126
127
128
129
130
131