Choreonoid  1.8
View.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_BASE_VIEW_H
6 #define CNOID_BASE_VIEW_H
7 
8 #include <cnoid/Signal>
9 #include <cnoid/Widget>
10 #include "exportdecl.h"
11 
12 namespace cnoid {
13 
14 class ExtensionManager;
15 class Archive;
16 class MenuManager;
17 class ViewManager;
18 class ViewArea;
19 class ViewAreaImpl;
20 
21 class CNOID_EXPORT ViewClass
22 {
23 public:
24  virtual const std::string& className() const = 0;
25 };
26 
27 class CNOID_EXPORT View : public Widget
28 {
29 public:
30  View();
31  virtual ~View();
32 
33  ViewClass* viewClass() const;
34 
35  const std::string& name() const;
36  virtual void setName(const std::string& name);
37  void setTitleFormat(const std::string& title);
38  void resetTitleFormat();
39  const std::string& titleFormat() const;
40 
41  ViewArea* viewArea() const;
42 
43  bool isActive() const;
44  bool hasFocus() const;
45 
46  void bringToFront();
47 
48  SignalProxy<void()> sigActivated();
49  SignalProxy<void()> sigDeactivated();
50  SignalProxy<void()> sigResized();
51  SignalProxy<void()> sigRemoved();
52 
53  enum LayoutArea {
54  TopLeftArea = 0,
55  MiddleLeftArea = 1,
56  BottomLeftArea = 2,
57  TopCenterArea = 3,
58  CenterArea = 4,
59  BottomCenterArea = 5,
60  TopRightArea = 6,
61  MiddleRightArea = 7,
62  BottomRightArea = 8,
63  NumLayoutAreas = 9,
64  // deprecated
65  LEFT = TopLeftArea,
66  LEFT_TOP = TopLeftArea,
67  LEFT_BOTTOM = BottomLeftArea,
68  CENTER = CenterArea,
69  RIGHT = TopRightArea,
70  BOTTOM = BottomCenterArea,
71  };
72 
73  void setDefaultLayoutArea(LayoutArea area);
74  LayoutArea defaultLayoutArea() const;
75 
76  void setLayout(QLayout* layout, double marginRatio = 0.0);
77 
78  void setLayout(
79  QLayout* layout,
80  double leftMarginRatio, double topMarginRatio, double rightMarginRatio, double bottomMarginRatio);
81 
82  QPoint viewAreaPos() const;
83 
84  virtual QWidget* indicatorOnInfoBar();
85 
86  void enableFontSizeZoomKeys(bool on);
87 
88  virtual bool storeState(Archive& archive);
89  virtual bool restoreState(const Archive& archive);
90 
91  static View* lastFocusView();
92 
93 protected:
94  void setLayoutContentsMarginRatio(
95  QLayout* layout,
96  double leftMarginRatio, double topMarginRatio, double rightMarginRatio, double bottomMarginRatio);
97  void zoomFontSize(int zoom);
98 
99  virtual void onActivated();
100  virtual void onDeactivated();
101  virtual void onFocusChanged(bool on);
102  virtual void onAttachedMenuRequest(MenuManager& menuManager);
103  virtual void keyPressEvent(QKeyEvent* event);
104  virtual void resizeEvent(QResizeEvent* event);
105 
106 private:
107  class Impl;
108  Impl* impl;
109 
110  friend class ViewManager;
111  friend class ViewArea;
112 
113  // Called from the view manager initialization
114  static void initializeClass();
115 
116  static void onApplicationFocusChanged(QWidget* widget);
117 
118  // Qt events (make hidden)
119  virtual void showEvent(QShowEvent* event);
120  virtual void hideEvent(QHideEvent* event);
121 
122  void setViewArea(ViewArea* area);
123  void notifySigRemoved();
124 };
125 
126 }
127 
128 #endif
cnoid::View
Definition: View.h:27
cnoid::Archive
Definition: Archive.h:22
cnoid::MenuManager
Definition: MenuManager.h:14
cnoid::ViewArea
Definition: ViewArea.h:16
cnoid::View::LayoutArea
LayoutArea
Definition: View.h:53
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::ViewManager
Definition: ViewManager.h:19
cnoid::Widget
Definition: Widget.h:10
cnoid::SignalProxy
Definition: Signal.h:470
cnoid::ViewClass
Definition: View.h:21