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"
36 /** A collapsable text inset
39 class InsetCollapsable : public InsetText {
42 static int const TEXT_TO_TOP_OFFSET = 2;
44 static int const TEXT_TO_BOTTOM_OFFSET = 2;
46 InsetCollapsable(BufferParams const &, CollapseStatus status = Open);
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 void drawSelection(PainterInfo & pi, int x, int y) const;
57 /// return x,y of given position relative to the inset's baseline
58 void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
60 bool hitButton(FuncRequest const &) const;
62 lyx::docstring const getNewLabel(lyx::docstring const & l) const;
64 EDITABLE editable() const;
65 /// can we go further down on mouse click?
66 bool descendable() const;
68 void setLabel(lyx::docstring const & l);
70 virtual void setButtonLabel() {}
72 void setLabelFont(LyXFont & f);
74 bool isOpen() const { return status_ == Open || status_ == Inlined; }
76 bool inlined() const { return status_ == Inlined; }
78 CollapseStatus status() const;
80 bool allowSpellCheck() const { return true; }
82 bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
84 void setStatus(LCursor & cur, CollapseStatus st);
88 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
90 Dimension dimensionCollapsed() const;
92 Box const & buttonDim() const;
94 void edit(LCursor & cur, bool left);
96 InsetBase * editXY(LCursor & cur, int x, int y);
98 void setInlined() { status_ = Inlined; }
100 lyx::docstring floatName(std::string const & type, BufferParams const &);
106 mutable Box button_dim;
110 mutable int topbaseline;
112 mutable lyx::docstring label;
115 mutable CollapseStatus status_;
116 /// a substatus of the Open status, determined automatically in metrics
117 mutable bool openinlined_;
118 /// the inset will automatically open when the cursor is inside
119 mutable bool autoOpen_;
121 mutable Dimension textdim_;
124 // A helper function that pushes the cursor out of the inset.
125 void leaveInset(LCursor & cur, InsetBase const & in);