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;
38 InsetCollapsable(BufferParams const &, CollapseStatus status = Open);
40 void read(Buffer const &, LyXLex &);
42 void write(Buffer const &, std::ostream &) const;
44 void metrics(MetricsInfo &, Dimension &) const;
46 void draw(PainterInfo & pi, int x, int y) const;
48 void drawSelection(PainterInfo & pi, int x, int y) const;
49 /// return x,y of given position relative to the inset's baseline
50 void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
52 bool hitButton(FuncRequest const &) const;
54 std::string const getNewLabel(std::string const & l) const;
56 EDITABLE editable() const;
57 /// can we go further down on mouse click?
58 bool descendable() const;
60 bool isTextInset() const { return true; }
62 void setLabel(std::string const & l);
64 virtual void setButtonLabel() {}
66 void setLabelFont(LyXFont & f);
68 bool isOpen() const { return status_ == Open || status_ == Inlined; }
70 bool inlined() const { return status_ == Inlined; }
72 CollapseStatus status() const { return status_; }
74 bool allowSpellCheck() const { return true; }
76 bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
78 void setStatus(LCursor & cur, CollapseStatus st);
82 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
84 Dimension dimensionCollapsed() const;
86 Box const & buttonDim() const;
88 void edit(LCursor & cur, bool left);
90 InsetBase * editXY(LCursor & cur, int x, int y);
92 void setInlined() { status_ = Inlined; }
98 mutable Box button_dim;
102 mutable int topbaseline;
104 mutable std::string label;
107 mutable CollapseStatus status_;
108 /// a substatus of the Open status, determined automatically in metrics
109 mutable bool openinlined_;
111 mutable Dimension textdim_;
114 // A helper function that pushes the cursor out of the inset.
115 void leaveInset(LCursor & cur, InsetBase const & in);