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;
44 InsetCollapsable(BufferParams const &, CollapseStatus status = Open);
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 insetAllowed(InsetOld::Code code) const;
66 bool isTextInset() const { return true; }
68 int latex(Buffer const &, std::ostream &,
69 OutputParams const &) const;
71 int plaintext(Buffer const &, std::ostream &,
72 OutputParams const &) const;
74 int linuxdoc(Buffer const &, std::ostream &,
75 OutputParams const &) const;
77 int docbook(Buffer const &, std::ostream &,
78 OutputParams const & runparams) const;
80 void validate(LaTeXFeatures & features) const;
81 /// get the screen x,y of the cursor
82 void getCursorPos(int cell, int & x, int & y) const;
84 void setLabel(std::string const & l);
86 virtual void setButtonLabel() {};
88 void setLabelFont(LyXFont & f);
89 /// Appends \c list with all labels found within this inset.
90 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
92 int scroll(bool recursive=true) const;
94 void scroll(BufferView *bv, float sx) const;
96 void scroll(BufferView *bv, int offset) const;
98 int numParagraphs() const;
100 LyXText * getText(int) const;
102 bool isOpen() const { return status_ == Open || status_ == Inlined; }
104 bool inlined() const { return status_ == Inlined; }
106 CollapseStatus status() const { return status_; }
114 void addPreview(lyx::graphics::PreviewLoader &) const;
116 void setBackgroundColor(LColor_color);
118 void setStatus(CollapseStatus st);
124 priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
126 void dimension_collapsed(Dimension &) const;
128 int height_collapsed() const;
130 void draw_collapsed(PainterInfo & pi, int x, int y) const;
132 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
134 Box const & buttonDim() const;
136 void edit(BufferView *, bool);
138 void edit(BufferView *, int, int);
142 DispatchResult lfunMouseRelease(FuncRequest const &);
144 FuncRequest adjustCommand(FuncRequest const &);
148 mutable InsetText inset;
151 mutable CollapseStatus status_;
156 mutable Box button_dim;
160 mutable int topbaseline;
162 mutable std::string label;