Consider the case where there is not any layout name.
[lyx.git] / src / BufferView_pimpl.h
blob73d6d4262df881a15a0d399bb685fdf07e97dfce
1 // -*- C++ -*-
2 /**
3 * \file BufferView_pimpl.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Asger Alstrup
8 * \author Alfredo Braustein
9 * \author Lars Gullik Bjønnes
10 * \author John Levon
11 * \author André Pönitz
12 * \author Dekel Tsur
13 * \author Jürgen Vigna
15 * Full author contact details are available in file CREDITS.
18 #ifndef BUFFERVIEW_PIMPL_H
19 #define BUFFERVIEW_PIMPL_H
21 #include "BufferView.h"
22 #include "cursor.h"
23 #include "errorlist.h"
25 #include "insets/inset.h"
27 #include "frontends/key_state.h"
28 #include "frontends/Timeout.h"
30 #include "support/types.h"
32 #include <boost/scoped_ptr.hpp>
33 #include <boost/shared_ptr.hpp>
34 #include <boost/signals/trackable.hpp>
37 class Change;
38 class LyXKeySym;
39 class LyXView;
40 class WorkArea;
41 class LyXScreen;
42 class FuncRequest;
43 class FuncStatus;
44 class ViewMetricsInfo;
47 ///
48 class BufferView::Pimpl : public boost::signals::trackable {
49 public:
50 ///
51 Pimpl(BufferView & bv, LyXView * owner, int width, int height);
52 ///
53 Painter & painter() const;
54 /// return the screen for this bview
55 LyXScreen & screen() const;
56 ///
57 void setBuffer(Buffer * buf);
58 ///
59 void resizeCurrentBuffer();
61 bool fitCursor();
62 ///
63 void update(Update::flags flags = Update::Force);
64 ///
65 void newFile(std::string const &, std::string const &, bool);
66 ///
67 bool loadLyXFile(std::string const &, bool);
68 ///
69 void workAreaResize();
70 ///
71 void updateScrollbar();
72 ///
73 void scrollDocView(int value);
74 /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
75 void scroll(int lines);
76 ///
77 typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
78 ///
79 void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
80 ///
81 void selectionRequested();
82 ///
83 void selectionLost();
84 ///
85 void cursorToggle();
86 ///
87 bool available() const;
88 /// get the change at the cursor position
89 Change const getCurrentChange();
90 ///
91 void savePosition(unsigned int i);
92 ///
93 void restorePosition(unsigned int i);
94 ///
95 bool isSavedPosition(unsigned int i);
96 ///
97 void switchKeyMap();
98 ///
99 void center();
100 /// a function should be executed from the workarea
101 bool workAreaDispatch(FuncRequest const & ev);
102 /// return true for events that will handle
103 FuncStatus getStatus(FuncRequest const & cmd);
104 /// a function should be executed
105 bool dispatch(FuncRequest const & ev);
106 private:
107 /// An error list (replaces the error insets)
108 ErrorList errorlist_;
109 /// add an error to the list
110 void addError(ErrorItem const &);
111 /// buffer errors signal connection
112 boost::signals::connection errorConnection_;
113 /// buffer messages signal connection
114 boost::signals::connection messageConnection_;
115 /// buffer busy status signal connection
116 boost::signals::connection busyConnection_;
117 /// buffer title changed signal connection
118 boost::signals::connection titleConnection_;
119 /// buffer reset timers signal connection
120 boost::signals::connection timerConnection_;
121 /// buffer readonly status changed signal connection
122 boost::signals::connection readonlyConnection_;
123 /// buffer closing signal connection
124 boost::signals::connection closingConnection_;
125 /// connect to signals in the given buffer
126 void connectBuffer(Buffer & buf);
127 /// disconnect from signals in the given buffer
128 void disconnectBuffer();
129 /// track changes for the document
130 void trackChanges();
131 /// notify readonly status
132 void showReadonly(bool);
136 friend class BufferView;
139 BufferView * bv_;
141 LyXView * owner_;
143 Buffer * buffer_;
145 boost::scoped_ptr<LyXScreen> screen_;
147 boost::scoped_ptr<WorkArea> workarea_;
149 Timeout cursor_timeout;
151 void stuffClipboard(std::string const &) const;
153 bool using_xterm_cursor;
155 class Position {
156 public:
157 /// Filename
158 std::string filename;
159 /// Cursor paragraph Id
160 int par_id;
161 /// Cursor position
162 lyx::pos_type par_pos;
164 Position() : par_id(0), par_pos(0) {}
166 Position(std::string const & f, int id, lyx::pos_type pos)
167 : filename(f), par_id(id), par_pos(pos) {}
170 std::vector<Position> saved_positions;
172 void MenuInsertLyXFile(std::string const & filen);
173 /// our workarea
174 WorkArea & workarea() const;
175 /// this is used to handle XSelection events in the right manner
176 struct {
177 CursorSlice cursor;
178 CursorSlice anchor;
179 bool set;
180 } xsel_cache_;
182 LCursor cursor_;
185 lyx::pit_type anchor_ref_;
187 int offset_ref_;
189 ViewMetricsInfo metrics(bool singlepar = false);
193 #endif // BUFFERVIEW_PIMPL_H