2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 *======================================================
13 #ifndef INSETCOLLAPSABLE_H
14 #define INSETCOLLAPSABLE_H
21 #include "insettext.h"
25 #include "lyxparagraph.h"
31 /** A colapsable text inset
34 class InsetCollapsable : public UpdatableInset {
42 static int const TEXT_TO_TOP_OFFSET = 2;
44 static int const TEXT_TO_BOTTOM_OFFSET = 2;
48 //Inset * Clone(Buffer const &) const;
50 void Read(Buffer const *, LyXLex &);
52 void Write(Buffer const *, std::ostream &) const;
54 int ascent(BufferView *, LyXFont const &) const;
56 int descent(BufferView *, LyXFont const &) const;
58 int width(BufferView *, LyXFont const & f) const;
60 void draw(BufferView *, const LyXFont &, int , float &, bool) const;
62 void update(BufferView *, LyXFont const &, bool =false);
64 void Edit(BufferView *, int, int, unsigned int);
66 EDITABLE Editable() const;
68 bool InsertInset(BufferView *, Inset * inset);
70 bool IsTextInset() const { return true; }
72 bool doClearArea() const;
74 void InsetUnlock(BufferView *);
76 bool needFullRow() const { return !collapsed; }
78 bool LockInsetInInset(BufferView *, UpdatableInset *);
80 bool UnlockInsetInInset(BufferView *, UpdatableInset *,
83 bool UpdateInsetInInset(BufferView *, Inset *);
85 unsigned int InsetInInsetY();
87 void InsetButtonRelease(BufferView *, int, int, int);
89 void InsetButtonPress(BufferView *, int, int, int);
91 void InsetMotionNotify(BufferView *, int, int, int);
93 void InsetKeyPress(XKeyEvent *);
95 UpdatableInset::RESULT LocalDispatch(BufferView *, kb_action,
98 int Latex(Buffer const *, std::ostream &,
99 bool fragile, bool free_spc) const;
101 int Ascii(Buffer const *, std::ostream &, int) const { return 0; }
103 int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
105 int DocBook(Buffer const *, std::ostream &) const { return 0; }
107 void Validate(LaTeXFeatures & features) const;
109 void GetCursorPos(BufferView *, int & x, int & y) const;
111 void ToggleInsetCursor(BufferView *);
113 UpdatableInset * GetLockingInset();
115 UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
117 void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
119 void setLabel(string const & l) { label = l; }
121 void setLabelFont(LyXFont & f) { labelfont = f; }
123 void setAutoCollapse(bool f) { autocollapse = f; }
125 int getMaxWidth(BufferView *, UpdatableInset const *) const;
127 LyXText * getLyXText(BufferView const *, bool const recursive) const;
129 void deleteLyXText(BufferView *, bool recursive=true) const;
131 void resizeLyXText(BufferView *) const;
133 vector<string> const getLabelList() const;
136 int ascent_collapsed(Painter &, LyXFont const &) const;
138 int descent_collapsed(Painter &, LyXFont const &) const;
140 int width_collapsed(Painter &, LyXFont const & f) const;
142 void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
144 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
149 LColor::color framecolor;
159 mutable int button_length;
161 mutable int button_top_y;
163 mutable int button_bottom_y;
173 mutable int oldWidth;
176 mutable int topbaseline;
177 mutable UpdateCodes need_update;