Salome HOME
Implement level() method for the SUIT_DataObject class
[modules/gui.git] / src / SUIT / SUIT_ViewModel.h
1 #ifndef SUIT_VIEWMODEL_H
2 #define SUIT_VIEWMODEL_H
3
4 #include "SUIT.h"
5 #include "SUIT_Desktop.h"
6 #include "SUIT_ViewWindow.h"
7 #include "SUIT_ViewManager.h"
8
9 #include <qobject.h>
10 #include <qcursor.h>
11
12 /*!
13         This object manages the definition and behaviour of a View Window. 
14         In case of definition of this object in an external lib that lib must 
15         have an exported function "createViewModel" which returns newly created 
16         instance of SUIT_ViewModel.
17 */
18
19 #ifdef WIN32
20 #pragma warning( disable:4251 )
21 #endif
22
23 class SUIT_EXPORT SUIT_ViewModel : public QObject
24 {
25         Q_OBJECT
26 public:
27   enum HotOperation { PAN, ZOOM, ROTATE, FIT_AREA };
28
29   typedef QMap<HotOperation, Qt::ButtonState> StatesMap;
30   typedef QMap<HotOperation, Qt::ButtonState> ButtonsMap;
31   
32         SUIT_ViewModel();
33         virtual ~SUIT_ViewModel();
34
35         virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
36
37         virtual void      setViewManager(SUIT_ViewManager* theViewManager) { myViewManager = theViewManager; }
38         SUIT_ViewManager* getViewManager() const { return myViewManager; }
39
40   virtual QString   getType() const { return "SUIT_ViewModel"; }
41
42   virtual void      contextMenuPopup(QPopupMenu*) {}
43
44   static void       setHotButton(HotOperation theOper, Qt::ButtonState theState,
45                                                        Qt::ButtonState theButton);
46   static void       getHotButton(HotOperation theOper, Qt::ButtonState& theState,
47                                                        Qt::ButtonState& theButton);
48
49 protected:
50         SUIT_ViewManager* myViewManager;
51
52 public:
53   static StatesMap  myStateMap;
54   static ButtonsMap myButtonMap;
55 };
56
57 #ifdef WIN32
58 #pragma warning( default:4251 )
59 #endif
60
61 extern "C"
62 {
63   typedef SUIT_ViewModel* (*VIEWMODEL_CREATE_FUNC)();
64 }
65
66 #define VIEWMODEL_CREATE_NAME   "createViewModel"
67
68 #endif