]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiImplementation.C
Extracted from r14281 from the younes branch.
[lyx.git] / src / frontends / qt4 / GuiImplementation.C
1 // -*- C++ -*-
2 /**
3  * \file GuiImplementation.C
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  * \author Abdelrazak Younes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 // This include must be declared before everything else because
14 // of boost/Qt/LyX clash...
15 #include "GuiView.h"
16
17 #include "GuiImplementation.h"
18 #include "GuiWorkArea.h"
19
20 #include "BufferView.h"
21
22 using boost::shared_ptr;
23
24 namespace lyx {
25 namespace frontend {
26
27 GuiImplementation::GuiImplementation(): max_view_id_(0), max_wa_id_(0)
28 {
29 }
30
31
32 Clipboard& GuiImplementation::clipboard()
33 {
34         return clipboard_;
35 }
36
37
38 int GuiImplementation::newView(unsigned int /*w*/, unsigned int /*h*/)
39 {
40         size_t const id = max_view_id_;
41         ++max_view_id_;
42
43         views_[id].reset(new GuiView(*this));
44
45         return id;
46 }
47
48
49 LyXView& GuiImplementation::view(int id)
50 {
51         BOOST_ASSERT(views_.find(id) != views_.end());
52
53         return *views_[id].get();
54 }
55
56
57 void GuiImplementation::destroyView(int id)
58 {
59         views_.erase(id);
60 }
61
62
63 int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int view_id)
64 {
65         size_t const id = max_wa_id_;
66         ++max_wa_id_;
67
68         GuiView * view = views_[view_id].get();
69
70         work_areas_[id].reset(new GuiWorkArea(w, h, view));
71
72         // FIXME BufferView creation should be independant of WorkArea creation
73         buffer_views_[id].reset(new BufferView(view));
74         work_areas_[id]->setBufferView(buffer_views_[id].get());
75         view->setWorkArea(work_areas_[id].get());
76
77         view->mainWidget()->setCentralWidget(work_areas_[id].get());
78
79         guiCursor().connect(work_areas_[id].get());
80
81         return id;
82 }
83
84
85 WorkArea& GuiImplementation::workArea(int id)
86 {
87         BOOST_ASSERT(work_areas_.find(id) != work_areas_.end());
88
89         return *work_areas_[id].get();
90 }
91
92
93 void GuiImplementation::destroyWorkArea(int id)
94 {
95         work_areas_.erase(id);
96 }
97
98 } // namespace frontend
99 } // namespace lyx