]> git.lyx.org Git - features.git/blob - src/frontends/xforms/GuiImplementation.h
This is the merging of the GUI API cleanup branch that was developed in svn+ssh:...
[features.git] / src / frontends / xforms / GuiImplementation.h
1 // -*- C++ -*-
2 /**
3  * \file xforms/GuiImplementation.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 #include "frontends/LyXView.h"
17
18 #include "xscreen.h"
19 #include "XWorkArea.h"
20
21 #include "GuiClipboard.h"
22 #include "GuiWorkArea.h"
23
24 #include <boost/shared_ptr.hpp>
25
26 #include <map>
27
28 namespace lyx {
29 namespace frontend {
30
31 typedef XScreen FScreen;
32 typedef XWorkArea FWorkArea;
33
34 /**
35  * The Gui class is the interface to all XForms components.
36  */
37 class GuiImplementation: public lyx::frontend::Gui
38 {
39 public:
40         GuiImplementation(LyXView & owner): owner_(owner)
41         {
42         }
43
44         virtual ~GuiImplementation()
45         {
46         }
47
48         lyx::frontend::Clipboard& clipboard()
49         {
50                 return *clipboard_;
51         }
52
53         int newWorkArea(int w, int h)
54         {
55                 old_work_area_.reset(new FWorkArea(owner_, w, h));
56                 old_screen_.reset(new FScreen(*old_work_area_.get()));
57                 work_area_.reset(new GuiWorkArea(owner_, w, h, old_screen_.get(), old_work_area_.get()));
58                 clipboard_.reset(new GuiClipboard(old_work_area_.get()));
59                 guiCursor().connect(work_area_.get());
60         }
61
62         lyx::frontend::WorkArea& workArea(int id)
63         {
64                 return *work_area_;
65         }
66
67         void destroyWorkArea(int id)
68         {
69                 clipboard_.reset();
70                 work_area_.reset();
71                 old_work_area_.reset();
72                 old_screen_.reset();
73         }
74
75 private:
76         ///
77         boost::shared_ptr<GuiClipboard> clipboard_;
78         ///
79         boost::shared_ptr<GuiWorkArea> work_area_;
80         ///
81         boost::shared_ptr<FWorkArea> old_work_area_;
82         ///
83         boost::shared_ptr<FScreen> old_screen_;
84         ///
85         LyXView & owner_;
86 };
87
88 } // namespace frontend
89 } // namespace lyx
90
91 #endif // GUI_IMPLEMENTATION_H