Salome HOME
Initialisation de la base KERNEL avec la version operationnelle de KERNEL_SRC issue...
[modules/kernel.git] / src / SALOMEGUI / QAD_Popup.h
1 //  File      : QAD_Popup.h
2 //  Created   : 22.09.00
3 //  Descr     : Popup menu management
4
5 //  Author    : UI team
6 //  Project   : SALOME
7 //  Module    : SALOMEGUI 
8 //  Copyright : Open CASCADE
9 //  $Header$
10
11 #ifndef QAD_POPUP_H
12 #define QAD_POPUP_H
13
14 #include "QAD.h"
15 #include <qvaluelist.h>
16 #include <qpopupmenu.h>
17
18 /****************************************************************************
19 **
20 **  Interface QAD_PopupServer: must be implemented by a class which is going
21 **  to be a popup server for clients i.e. be able to create a popup menu 
22 **
23 *****************************************************************************/
24 class QAD_EXPORT QAD_PopupServer 
25 {
26 public:
27   QAD_PopupServer();
28   virtual ~QAD_PopupServer();
29
30 public:
31   virtual QPopupMenu*  createPopup();   
32   virtual void         destroyPopup();
33   void                 enablePopup( bool );
34
35 protected:
36   virtual void         onCreatePopup () = 0;    /* addition of menu items goes here */
37
38 protected:
39   QPopupMenu*           myPopup;      /* resulting popup menu */
40   bool            myEnablePopup;      /* enable/disable popup creation */    
41 };
42
43 /****************************************************************************
44 **
45 **  Class QAD_PopupClient: must be inherited by a class which is going
46 **  to be a popup client i.e. be able to show its server's popup menu
47 **
48 *****************************************************************************/
49 class QAD_EXPORT QAD_PopupClient
50 {
51 public:
52         QAD_PopupClient();
53         virtual ~QAD_PopupClient();
54
55 public:
56         void                    setPopupServer ( QAD_PopupServer* );
57         QAD_PopupServer*        getPopupServer () const;
58
59 protected:
60         QAD_PopupServer*        myPopupServer;  
61 };
62
63 /****************************************************************************
64 **
65 **  Class QAD_PopupClientServer: both client and server. Can be used as
66 **  a server only or as a client only ( if server is not set ).
67 **
68 *****************************************************************************/
69 class QAD_EXPORT QAD_PopupClientServer : public QAD_PopupClient, 
70   public QAD_PopupServer
71 {
72 public:
73         QAD_PopupClientServer( bool separateItems = true, bool smartSeparator = true );
74         ~QAD_PopupClientServer();
75
76 public:
77         QPopupMenu*             createPopup();
78         void                    destroyPopup();
79
80 protected:
81         QValueList<int> myIDs;                          // ids of the items added by myself as a server 
82         bool                    myOnlyServer;           // true if I`m fully responsible for the menu  
83         bool                    mySeparateItems;        // to insert separator  before my items
84         bool                    mySmartSeparator;       // if true then separator is inserted after own items,
85                                                         // not at the end of menu
86 };
87
88 #endif