3 * \file insetcollapsable.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Alejandro Aguilar Sierra
9 * \author Lars Gullik Bjønnes
11 * Full author contact details are available in file CREDITS.
14 #ifndef INSETCOLLAPSABLE_H
15 #define INSETCOLLAPSABLE_H
18 #include "insettext.h"
28 /** A collapsable text inset
31 class InsetCollapsable : public UpdatableInset {
34 static int const TEXT_TO_TOP_OFFSET = 2;
36 static int const TEXT_TO_BOTTOM_OFFSET = 2;
37 /// inset is initially collapsed if bool = true
38 InsetCollapsable(BufferParams const &, bool collapsed = false);
40 InsetCollapsable(InsetCollapsable const & in);
42 void read(Buffer const &, LyXLex &);
44 void write(Buffer const &, std::ostream &) const;
46 void metrics(MetricsInfo &, Dimension &) const;
48 void draw(PainterInfo & pi, int x, int y) const;
49 /// draw, either inlined (no button) or collapsed/open
50 void draw(PainterInfo & pi, int x, int y, bool inlined) const;
52 bool hitButton(FuncRequest const &) const;
54 EDITABLE editable() const;
56 bool insertInset(BufferView *, InsetOld * inset);
58 virtual bool insetAllowed(InsetOld::Code code) const;
60 bool isTextInset() const;
62 void insetUnlock(BufferView *);
64 bool lockInsetInInset(BufferView *, UpdatableInset *);
66 bool unlockInsetInInset(BufferView *, UpdatableInset *,
69 int insetInInsetY() const;
71 int latex(Buffer const &, std::ostream &,
72 OutputParams const &) const;
74 int plaintext(Buffer const &, std::ostream &,
75 OutputParams const &) const;
77 int linuxdoc(Buffer const &, std::ostream &,
78 OutputParams const &) const;
80 int docbook(Buffer const &, std::ostream &,
81 OutputParams const & runparams) const;
83 void validate(LaTeXFeatures & features) const;
85 void getCursorPos(BufferView *, int & x, int & y) const;
86 /// Get the absolute document x,y of the cursor
87 virtual void getCursor(BufferView &, int &, int &) const;
89 void fitInsetCursor(BufferView * bv) const;
91 UpdatableInset * getLockingInset() const;
93 UpdatableInset * getFirstLockingInsetOfType(InsetOld::Code);
95 void setFont(BufferView *, LyXFont const &, bool toggleall = false,
96 bool selectall = false);
98 void setLabel(std::string const & l) const;
100 void setLabelFont(LyXFont & f);
103 void setAutoCollapse(bool f);
106 LyXText * getLyXText(BufferView const *, bool const recursive) const;
108 void deleteLyXText(BufferView *, bool recursive=true) const;
109 /// Appends \c list with all labels found within this inset.
110 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
112 int scroll(bool recursive=true) const;
114 void scroll(BufferView *bv, float sx) const;
116 void scroll(BufferView *bv, int offset) const;
118 ParagraphList * getParagraphs(int) const;
120 int numParagraphs() const;
122 LyXText * getText(int) const;
124 LyXCursor const & cursor(BufferView *) const;
126 virtual bool display() const { return isOpen(); }
130 void open(BufferView *);
132 void close(BufferView *) const;
137 void addPreview(lyx::graphics::PreviewLoader &) const;
143 priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
145 void dimension_collapsed(Dimension &) const;
147 int height_collapsed() const;
149 void draw_collapsed(PainterInfo & pi, int x, int y) const;
151 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
152 /// Should be non-const...
153 void setCollapsed(bool) const;
155 Box const & buttonDim() const;
157 void edit(BufferView *, bool);
159 void edit(BufferView *, int, int);
161 UpdatableInset * lockingInset() const { return inset.lockingInset(); }
165 void lfunMouseRelease(FuncRequest const &);
167 FuncRequest adjustCommand(FuncRequest const &);
171 mutable InsetText inset;
174 mutable bool collapsed_;
178 mutable Box button_dim;
181 mutable int topbaseline;
184 mutable std::string label;
192 mutable bool first_after_edit;
197 bool InsetCollapsable::insetAllowed(InsetOld::Code code) const
199 return inset.insetAllowed(code);
204 bool InsetCollapsable::isTextInset() const
211 void InsetCollapsable::fitInsetCursor(BufferView * bv) const
213 inset.fitInsetCursor(bv);
217 void InsetCollapsable::setLabelFont(LyXFont & f)
224 void InsetCollapsable::setAutoCollapse(bool f)
231 void InsetCollapsable::scroll(BufferView *bv, float sx) const
233 UpdatableInset::scroll(bv, sx);
238 void InsetCollapsable::scroll(BufferView *bv, int offset) const
240 UpdatableInset::scroll(bv, offset);
245 bool InsetCollapsable::isOpen() const
252 Box const & InsetCollapsable::buttonDim() const