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 void drawSelection(PainterInfo & pi, int x, int y) const;
58 bool hitButton(FuncRequest &) const;
60 std::string const getNewLabel(std::string const & l) const;
62 EDITABLE editable() const;
63 /// can we go further down on mouse click?
64 bool descendable() const;
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(CursorSlice const & cur, int & x, int & y) const;
86 void setLabel(std::string const & l);
88 virtual void setButtonLabel() {}
90 void setLabelFont(LyXFont & f);
91 /// Appends \c list with all labels found within this inset.
92 void getLabelList(Buffer const &, std::vector<std::string> & list) const;
94 int scroll(bool recursive = true) const;
96 void scroll(BufferView & bv, float sx) const;
98 void scroll(BufferView & bv, int offset) const;
100 size_t nargs() const;
102 LyXText * getText(int) const;
104 bool isOpen() const { return status_ == Open || status_ == Inlined; }
106 bool inlined() const { return status_ == Inlined; }
108 CollapseStatus status() const { return status_; }
116 void addPreview(lyx::graphics::PreviewLoader &) const;
118 void setBackgroundColor(LColor_color);
120 void setStatus(CollapseStatus st);
122 bool allowSpellCheck() const { return true; }
126 void priv_dispatch(LCursor & cur, FuncRequest & cmd);
128 bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
130 void dimension_collapsed(Dimension &) const;
132 void draw_collapsed(PainterInfo & pi, int x, int y) const;
134 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
136 Box const & buttonDim() const;
138 void edit(LCursor & cur, bool left);
140 InsetBase * editXY(LCursor & cur, int x, int y);
144 void lfunMouseRelease(LCursor & cur, FuncRequest & cmd);
148 mutable InsetText inset;
153 mutable Box button_dim;
157 mutable int topbaseline;
159 mutable std::string label;
162 mutable CollapseStatus status_;
163 /// a substatus of the Open status, determined automatically in metrics
164 mutable bool openinlined_;