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