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 bool insetAllowed(InsetOld::Code code) const;
60 bool isTextInset() const { return true; }
62 int insetInInsetY() const;
64 int latex(Buffer const &, std::ostream &,
65 OutputParams const &) const;
67 int plaintext(Buffer const &, std::ostream &,
68 OutputParams const &) const;
70 int linuxdoc(Buffer const &, std::ostream &,
71 OutputParams const &) const;
73 int docbook(Buffer const &, std::ostream &,
74 OutputParams const & runparams) const;
76 void validate(LaTeXFeatures & features) const;
77 /// get the screen x,y of the cursor
78 void getCursorPos(BufferView *, int & x, int & y) const;
80 void fitInsetCursor(BufferView * bv) const;
82 void setFont(BufferView *, LyXFont const &, bool toggleall = false,
83 bool selectall = false);
85 void setLabel(std::string const & l) const;
87 void setLabelFont(LyXFont & f);
90 void setAutoCollapse(bool f);
93 void deleteLyXText(BufferView *, bool recursive=true) const;
94 /// Appends \c list with all labels found within this inset.
95 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
97 int scroll(bool recursive=true) const;
99 void scroll(BufferView *bv, float sx) const;
101 void scroll(BufferView *bv, int offset) const;
103 ParagraphList * getParagraphs(int) const;
105 int numParagraphs() const;
107 LyXText * getText(int) const;
109 bool display() const { return isOpen(); }
113 void open(BufferView *);
115 void close(BufferView *) const;
119 void addPreview(lyx::graphics::PreviewLoader &) const;
125 priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
127 void dimension_collapsed(Dimension &) const;
129 int height_collapsed() const;
131 void draw_collapsed(PainterInfo & pi, int x, int y) const;
133 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
134 /// Should be non-const...
135 void setCollapsed(bool) const;
137 Box const & buttonDim() const;
139 void edit(BufferView *, bool);
141 void edit(BufferView *, int, int);
145 DispatchResult lfunMouseRelease(FuncRequest const &);
147 FuncRequest adjustCommand(FuncRequest const &);
151 mutable InsetText inset;
154 mutable bool collapsed_;
158 mutable Box button_dim;
162 mutable int topbaseline;
164 mutable std::string label;