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;
43 /// inset is initially collapsed if bool = true
44 InsetCollapsable(BufferParams const &, bool collapsed = false);
46 InsetCollapsable(InsetCollapsable const & in);
48 void read(Buffer const &, LyXLex &);
50 void write(Buffer const &, std::ostream &) const;
52 void metrics(MetricsInfo &, Dimension &) const;
54 void draw(PainterInfo & pi, int x, int y) const;
56 bool hitButton(FuncRequest const &) const;
58 std::string const getNewLabel(std::string const & l) const;
60 EDITABLE editable() const;
61 /// can we go further down on mouse click?
62 bool descendable() const;
64 bool insertInset(BufferView *, InsetOld * inset);
66 bool insetAllowed(InsetOld::Code code) const;
68 bool isTextInset() const { return true; }
70 int latex(Buffer const &, std::ostream &,
71 OutputParams const &) const;
73 int plaintext(Buffer const &, std::ostream &,
74 OutputParams const &) const;
76 int linuxdoc(Buffer const &, std::ostream &,
77 OutputParams const &) const;
79 int docbook(Buffer const &, std::ostream &,
80 OutputParams const & runparams) const;
82 void validate(LaTeXFeatures & features) const;
83 /// get the screen x,y of the cursor
84 void getCursorPos(int & x, int & y) const;
86 void setLabel(std::string const & l) const;
88 void setLabelFont(LyXFont & f);
91 void setAutoCollapse(bool f);
93 /// Appends \c list with all labels found within this inset.
94 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
96 int scroll(bool recursive=true) const;
98 void scroll(BufferView *bv, float sx) const;
100 void scroll(BufferView *bv, int offset) const;
102 ParagraphList * getParagraphs(int) const;
104 int numParagraphs() const;
106 LyXText * getText(int) const;
108 bool isOpen() const { return status_ == Open || status_ == Inlined; }
110 bool inlined() const { return status_ == Inlined; }
112 CollapseStatus status() const { return status_; }
120 void addPreview(lyx::graphics::PreviewLoader &) const;
122 void setBackgroundColor(LColor_color);
124 virtual void setStatus(CollapseStatus st);
130 priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
132 void dimension_collapsed(Dimension &) const;
134 int height_collapsed() const;
136 void draw_collapsed(PainterInfo & pi, int x, int y) const;
138 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
140 Box const & buttonDim() const;
142 void edit(BufferView *, bool);
144 void edit(BufferView *, int, int);
148 DispatchResult lfunMouseRelease(FuncRequest const &);
150 FuncRequest adjustCommand(FuncRequest const &);
154 mutable InsetText inset;
157 mutable CollapseStatus status_;
161 mutable Box button_dim;
165 mutable int topbaseline;
167 mutable std::string label;