3 // Descr : Popup menu management
8 // Copyright : Open CASCADE
15 #include <qvaluelist.h>
16 #include <qpopupmenu.h>
18 /****************************************************************************
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
23 *****************************************************************************/
24 class QAD_EXPORT QAD_PopupServer
28 virtual ~QAD_PopupServer();
31 virtual QPopupMenu* createPopup();
32 virtual void destroyPopup();
33 void enablePopup( bool );
36 virtual void onCreatePopup () = 0; /* addition of menu items goes here */
39 QPopupMenu* myPopup; /* resulting popup menu */
40 bool myEnablePopup; /* enable/disable popup creation */
43 /****************************************************************************
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
48 *****************************************************************************/
49 class QAD_EXPORT QAD_PopupClient
53 virtual ~QAD_PopupClient();
56 void setPopupServer ( QAD_PopupServer* );
57 QAD_PopupServer* getPopupServer () const;
60 QAD_PopupServer* myPopupServer;
63 /****************************************************************************
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 ).
68 *****************************************************************************/
69 class QAD_EXPORT QAD_PopupClientServer : public QAD_PopupClient,
70 public QAD_PopupServer
73 QAD_PopupClientServer( bool separateItems = true, bool smartSeparator = true );
74 ~QAD_PopupClientServer();
77 QPopupMenu* createPopup();
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