]> git.lyx.org Git - features.git/blob - src/frontends/qt3/GuiImplementation.h
60f03aad95c44c13d996f8c445118d19f624814f
[features.git] / src / frontends / qt3 / GuiImplementation.h
1 // -*- C++ -*-
2 /**
3  * \file qt3/Gui.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Abdelrazak Younes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef GUI_IMPLEMENTATION_H
13 #define GUI_IMPLEMENTATION_H
14
15 #include "frontends/Gui.h"
16
17 #include "QtView.h"
18 #include "qscreen.h"
19 #include "QWorkArea.h"
20
21 #include "GuiWorkArea.h"
22
23 #include "BufferView.h"
24
25 #include <boost/shared_ptr.hpp>
26
27 namespace lyx {
28 namespace frontend {
29
30 typedef QtView FView;
31 typedef QScreen FScreen;
32 typedef QWorkArea FWorkArea;
33
34 /**
35  * The Gui class is the interface to all Qt3 components.
36  */
37 class GuiImplementation: public lyx::frontend::Gui
38 {
39 public:
40         GuiImplementation()
41         {
42         }
43
44         virtual ~GuiImplementation()
45         {
46         }
47
48         int newView(unsigned int /*w*/, unsigned int /*h*/)
49         {
50                 view_.reset(new FView);
51                 return 0;
52         }
53
54
55         LyXView& view(int /*id*/)
56         {
57                 return *view_;
58         }
59
60
61         void destroyView(int /*id*/)
62         {
63                 view_.reset();
64         }
65
66         int newWorkArea(unsigned int w, unsigned int h, int /*view_id*/)
67         {
68                 old_work_area_.reset(new FWorkArea(*view_.get(), w, h));
69                 old_screen_.reset(new FScreen(*old_work_area_.get()));
70                 work_area_.reset(new GuiWorkArea(old_screen_.get(), old_work_area_.get()));
71
72                 // FIXME BufferView creation should be independant of WorkArea creation
73                 buffer_views_[0].reset(new BufferView);
74                 work_area_->setBufferView(buffer_views_[0].get());
75                 view_->setWorkArea(work_area_.get());
76                 return 0;
77         }
78
79         lyx::frontend::WorkArea& workArea(int /*id*/)
80         {
81                 return *work_area_;
82         }
83
84         void destroyWorkArea(int /*id*/)
85         {
86                 work_area_.reset();
87                 old_work_area_.reset();
88                 old_screen_.reset();
89         }
90
91 private:
92         ///
93         boost::shared_ptr<GuiWorkArea> work_area_;
94         ///
95         boost::shared_ptr<FView> view_;
96         ///
97         boost::shared_ptr<FWorkArea> old_work_area_;
98         ///
99         boost::shared_ptr<FScreen> old_screen_;
100 };
101
102 } // namespace frontend
103 } // namespace lyx
104
105 #endif // GUI_IMPLEMENTATION_H