]> git.lyx.org Git - lyx.git/blob - src/frontends/qt3/GuiImplementation.h
adf345b7b660a24aebe83d4eaa29cda85a17cc9d
[lyx.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 "GuiClipboard.h"
22 #include "GuiWorkArea.h"
23
24 #include "BufferView.h"
25
26 #include <boost/shared_ptr.hpp>
27
28 namespace lyx {
29 namespace frontend {
30
31 typedef QtView FView;
32 typedef QScreen FScreen;
33 typedef QWorkArea FWorkArea;
34
35 /**
36  * The Gui class is the interface to all Qt3 components.
37  */
38 class GuiImplementation: public lyx::frontend::Gui
39 {
40 public:
41         GuiImplementation()
42         {
43         }
44
45         virtual ~GuiImplementation()
46         {
47         }
48
49         lyx::frontend::Clipboard& clipboard()
50         {
51                 return *clipboard_;
52         }
53
54         int newView(unsigned int /*w*/, unsigned int /*h*/)
55         {
56                 view_.reset(new FView(*this));
57                 return 0;
58         }
59
60
61         LyXView& view(int /*id*/)
62         {
63                 return *view_;
64         }
65
66
67         void destroyView(int /*id*/)
68         {
69                 view_.reset();
70         }
71
72         int newWorkArea(unsigned int w, unsigned int h, int /*view_id*/)
73         {
74                 old_work_area_.reset(new FWorkArea(*view_.get(), w, h));
75                 old_screen_.reset(new FScreen(*old_work_area_.get()));
76                 work_area_.reset(new GuiWorkArea(old_screen_.get(), old_work_area_.get()));
77                 clipboard_.reset(new GuiClipboard(old_work_area_.get()));
78                 guiCursor().connect(work_area_.get());
79
80                 // FIXME BufferView creation should be independant of WorkArea creation
81                 buffer_views_[0].reset(new BufferView(view_.get(), work_area_.get()));
82                 work_area_->setBufferView(buffer_views_[0].get());
83                 view_->setBufferView(buffer_views_[0].get());
84                 return 0;
85         }
86
87         lyx::frontend::WorkArea& workArea(int /*id*/)
88         {
89                 return *work_area_;
90         }
91
92         void destroyWorkArea(int /*id*/)
93         {
94                 clipboard_.reset();
95                 work_area_.reset();
96                 old_work_area_.reset();
97                 old_screen_.reset();
98         }
99
100 private:
101         ///
102         boost::shared_ptr<GuiClipboard> clipboard_;
103         ///
104         boost::shared_ptr<GuiWorkArea> work_area_;
105         ///
106         boost::shared_ptr<FView> view_;
107         ///
108         boost::shared_ptr<FWorkArea> old_work_area_;
109         ///
110         boost::shared_ptr<FScreen> old_screen_;
111 };
112
113 } // namespace frontend
114 } // namespace lyx
115
116 #endif // GUI_IMPLEMENTATION_H