]> git.lyx.org Git - lyx.git/blob - src/insets/insetcollapsable.h
get rid of same_id from function signatures
[lyx.git] / src / insets / insetcollapsable.h
1 // -*- C++ -*-
2 /**
3  * \file insetcollapsable.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Alejandro Aguilar Sierra
8  * \author Jürgen Vigna
9  * \author Lars Gullik Bjønnes
10  *
11  * Full author contact details are available in file CREDITS
12  */
13
14 #ifndef INSETCOLLAPSABLE_H
15 #define INSETCOLLAPSABLE_H
16
17 #include "inset.h"
18 #include "insettext.h"
19 #include "lyxfont.h"
20 #include "funcrequest.h" // for adjustCommand
21 #include "LColor.h"
22
23 #include <boost/weak_ptr.hpp>
24
25 class Painter;
26 class LyXText;
27 class Paragraph;
28 class LyXCursor;
29
30 /** A collapsable text inset
31
32 */
33 class InsetCollapsable : public UpdatableInset {
34 public:
35         ///
36         static int const TEXT_TO_TOP_OFFSET = 2;
37         ///
38         static int const TEXT_TO_BOTTOM_OFFSET = 2;
39         /// inset is initially collapsed if bool = true
40         InsetCollapsable(BufferParams const &, bool collapsed = false);
41         ///
42         InsetCollapsable(InsetCollapsable const & in);
43         ///
44         //InsetCollapsable(InsetCollapsable const & in, bool same_id);
45         ///
46         void read(Buffer const *, LyXLex &);
47         ///
48         void write(Buffer const *, std::ostream &) const;
49         ///
50         void dimension(BufferView *, LyXFont const &, Dimension &) const;
51         ///
52         void draw(BufferView *, const LyXFont &, int, float &) const;
53         /// draw, either inlined (no button) or collapsed/open
54         void draw(BufferView * bv, LyXFont const & f,
55                   int baseline, float & x, bool inlined) const;
56         ///
57         void update(BufferView *, bool = false);
58         ///
59         EDITABLE editable() const;
60         ///
61         bool insertInset(BufferView *, Inset * inset);
62         ///
63         virtual bool insetAllowed(Inset::Code code) const {
64                 return inset.insetAllowed(code);
65         }
66         ///
67         bool isTextInset() const { return true; }
68         ///
69         void insetUnlock(BufferView *);
70         ///
71         bool needFullRow() const { return isOpen(); }
72         ///
73         bool lockInsetInInset(BufferView *, UpdatableInset *);
74         ///
75         bool unlockInsetInInset(BufferView *, UpdatableInset *,
76                                 bool lr = false);
77         ///
78         bool updateInsetInInset(BufferView *, Inset *);
79         ///
80         int insetInInsetY() const;
81         ///
82         RESULT localDispatch(FuncRequest const &);
83         ///
84         int latex(Buffer const *, std::ostream &,
85                   LatexRunParams const &) const;
86         ///
87         int ascii(Buffer const *, std::ostream &, int) const;
88         ///
89         int linuxdoc(Buffer const *, std::ostream &) const;
90         ///
91         int docbook(Buffer const *, std::ostream &, bool mixcont) const;
92         ///
93         void validate(LaTeXFeatures & features) const;
94         /// FIXME, document
95         void getCursorPos(BufferView *, int & x, int & y) const;
96         /// Get the absolute document x,y of the cursor
97         virtual void getCursor(BufferView &, int &, int &) const;
98         ///
99         void fitInsetCursor(BufferView * bv) const {
100                 inset.fitInsetCursor(bv);
101         }
102         UpdatableInset * getLockingInset() const;
103         ///
104         UpdatableInset * getFirstLockingInsetOfType(Inset::Code);
105         ///
106         void setFont(BufferView *, LyXFont const &, bool toggleall = false,
107                  bool selectall = false);
108         ///
109         void setLabel(string const & l) const;
110         ///
111         void setLabelFont(LyXFont & f) { labelfont = f; }
112 #if 0
113         ///
114         void setAutoCollapse(bool f) { autocollapse = f; }
115 #endif
116         ///
117         LyXText * getLyXText(BufferView const *, bool const recursive) const;
118         ///
119         void deleteLyXText(BufferView *, bool recursive=true) const;
120         ///
121         void resizeLyXText(BufferView *, bool force = false) const;
122         ///
123         std::vector<string> const getLabelList() const;
124         ///
125         bool nodraw() const;
126         ///
127         int scroll(bool recursive=true) const;
128         ///
129         void scroll(BufferView *bv, float sx) const {
130                 UpdatableInset::scroll(bv, sx);
131         }
132         ///
133         void scroll(BufferView *bv, int offset) const {
134                 UpdatableInset::scroll(bv, offset);
135         }
136         ///
137         Inset * getInsetFromID(int id) const;
138         ///
139         ParagraphList * getParagraphs(int) const;
140         ///
141         LyXCursor const & cursor(BufferView *) const;
142         ///
143         bool isOpen() const { return !collapsed_; }
144         ///
145         void open(BufferView *);
146         ///
147         void close(BufferView *) const;
148         ///
149         bool allowSpellcheck() const { return inset.allowSpellcheck(); }
150         ///
151         WordLangTuple const
152         selectNextWordToSpellcheck(BufferView *, float &) const;
153         ///
154         void selectSelectedWord(BufferView * bv) {
155                 inset.selectSelectedWord(bv);
156         }
157         ///
158         void toggleSelection(BufferView * bv, bool kill_selection) {
159                 inset.toggleSelection(bv, kill_selection);
160         }
161
162         void markErased();
163
164         bool nextChange(BufferView * bv, lyx::pos_type & length);
165
166         ///
167         bool searchForward(BufferView * bv, string const & str,
168                            bool = true, bool = false);
169         bool searchBackward(BufferView * bv, string const & str,
170                             bool = true, bool = false);
171
172         ///
173         void addPreview(grfx::PreviewLoader &) const;
174
175 protected:
176         ///
177         virtual void cache(BufferView *) const;
178         ///
179         virtual BufferView * view() const;
180
181         ///
182         void dimension_collapsed(Dimension &) const;
183         ///
184         int height_collapsed() const;
185         ///
186         void draw_collapsed(Painter & pain, int, float &) const;
187         ///
188         int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
189
190         ///
191         mutable bool collapsed_;
192         ///
193         LColor::color framecolor;
194         ///
195         LyXFont labelfont;
196 public:
197         ///
198         mutable InsetText inset;
199 protected:
200         ///
201         mutable int button_length;
202         ///
203         mutable int button_top_y;
204         ///
205         mutable int button_bottom_y;
206         ///
207         mutable int topx;
208         mutable int topbaseline;
209
210 private:
211         ///
212         void lfunMouseRelease(FuncRequest const &);
213         ///
214         FuncRequest adjustCommand(FuncRequest const &);
215
216         ///
217         mutable string label;
218 #if 0
219         ///
220         bool autocollapse;
221 #endif
222         ///
223         mutable int oldWidth;
224         ///
225         bool in_update;
226         ///
227         mutable bool first_after_edit;
228         ///
229         mutable boost::weak_ptr<BufferView> view_;
230 };
231
232 #endif