Salome HOME
sources v1.2
[modules/kernel.git] / src / SALOMEGUI / QAD_Popup.h
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_Popup.h
25 //  Author : UI team
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef QAD_POPUP_H
30 #define QAD_POPUP_H
31
32 #include "QAD.h"
33 #include <qvaluelist.h>
34 #include <qpopupmenu.h>
35
36 /****************************************************************************
37 **
38 **  Interface QAD_PopupServer: must be implemented by a class which is going
39 **  to be a popup server for clients i.e. be able to create a popup menu 
40 **
41 *****************************************************************************/
42 class QAD_EXPORT QAD_PopupServer 
43 {
44 public:
45   QAD_PopupServer();
46   virtual ~QAD_PopupServer();
47
48 public:
49   virtual QPopupMenu*  createPopup();   
50   virtual void         destroyPopup();
51   void                 enablePopup( bool );
52
53 protected:
54   virtual void         onCreatePopup () = 0;    /* addition of menu items goes here */
55
56 protected:
57   QPopupMenu*           myPopup;      /* resulting popup menu */
58   bool            myEnablePopup;      /* enable/disable popup creation */    
59 };
60
61 /****************************************************************************
62 **
63 **  Class QAD_PopupClient: must be inherited by a class which is going
64 **  to be a popup client i.e. be able to show its server's popup menu
65 **
66 *****************************************************************************/
67 class QAD_EXPORT QAD_PopupClient
68 {
69 public:
70         QAD_PopupClient();
71         virtual ~QAD_PopupClient();
72
73 public:
74         void                    setPopupServer ( QAD_PopupServer* );
75         QAD_PopupServer*        getPopupServer () const;
76
77 protected:
78         QAD_PopupServer*        myPopupServer;  
79 };
80
81 /****************************************************************************
82 **
83 **  Class QAD_PopupClientServer: both client and server. Can be used as
84 **  a server only or as a client only ( if server is not set ).
85 **
86 *****************************************************************************/
87 class QAD_EXPORT QAD_PopupClientServer : public QAD_PopupClient, 
88   public QAD_PopupServer
89 {
90 public:
91         QAD_PopupClientServer( bool separateItems = true, bool smartSeparator = true );
92         ~QAD_PopupClientServer();
93
94 public:
95         QPopupMenu*             createPopup();
96         void                    destroyPopup();
97
98 protected:
99         QValueList<int> myIDs;                          // ids of the items added by myself as a server 
100         bool                    myOnlyServer;           // true if I`m fully responsible for the menu  
101         bool                    mySeparateItems;        // to insert separator  before my items
102         bool                    mySmartSeparator;       // if true then separator is inserted after own items,
103                                                         // not at the end of menu
104 };
105
106 #endif