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 InsetText {
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 void read(Buffer const &, LyXLex &);
48 void write(Buffer const &, std::ostream &) const;
50 void metrics(MetricsInfo &, Dimension &) const;
52 void draw(PainterInfo & pi, int x, int y) const;
54 bool hitButton(FuncRequest &) const;
56 std::string const getNewLabel(std::string const & l) const;
58 EDITABLE editable() const;
59 /// can we go further down on mouse click?
60 bool descendable() const;
62 bool isTextInset() const { return true; }
64 void setLabel(std::string const & l);
66 virtual void setButtonLabel() {}
68 void setLabelFont(LyXFont & f);
70 int scroll(bool recursive = true) const;
72 void scroll(BufferView & bv, float sx) const;
74 void scroll(BufferView & bv, int offset) const;
76 bool isOpen() const { return status_ == Open || status_ == Inlined; }
78 bool inlined() const { return status_ == Inlined; }
80 CollapseStatus status() const { return status_; }
86 bool allowSpellCheck() const { return true; }
90 void setStatus(CollapseStatus st);
92 void priv_dispatch(LCursor & cur, FuncRequest & cmd);
94 void dimension_collapsed(Dimension &) const;
96 void draw_collapsed(PainterInfo & pi, int x, int y) const;
98 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
100 Box const & buttonDim() const;
102 void edit(LCursor & cur, bool left);
104 InsetBase * editXY(LCursor & cur, int x, int y) const;
110 mutable Box button_dim;
114 mutable int topbaseline;
116 mutable std::string label;
119 mutable CollapseStatus status_;
120 /// a substatus of the Open status, determined automatically in metrics
121 mutable bool openinlined_;
123 mutable Dimension textdim_;
126 // A helper function that pushes the cursor out of the inset.
127 void leaveInset(LCursor & cur, InsetBase const & in);