2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000-2001 The LyX Team.
9 *======================================================
13 #ifndef INSETCOLLAPSABLE_H
14 #define INSETCOLLAPSABLE_H
21 #include "insettext.h"
28 /** A colapsable text inset
31 class InsetCollapsable : public UpdatableInset {
39 static int const TEXT_TO_TOP_OFFSET = 2;
41 static int const TEXT_TO_BOTTOM_OFFSET = 2;
45 void Read(Buffer const *, LyXLex &);
47 void Write(Buffer const *, std::ostream &) const;
49 int ascent(BufferView *, LyXFont const &) const;
51 int descent(BufferView *, LyXFont const &) const;
53 int width(BufferView *, LyXFont const & f) const;
55 void draw(BufferView *, const LyXFont &, int , float &, bool) const;
57 void update(BufferView *, LyXFont const &, bool =false);
59 void Edit(BufferView *, int, int, unsigned int);
61 EDITABLE Editable() const;
63 bool InsertInset(BufferView *, Inset * inset);
65 bool IsTextInset() const { return true; }
67 bool doClearArea() const;
69 void InsetUnlock(BufferView *);
71 bool needFullRow() const { return !collapsed; }
73 bool LockInsetInInset(BufferView *, UpdatableInset *);
75 bool UnlockInsetInInset(BufferView *, UpdatableInset *,
78 bool UpdateInsetInInset(BufferView *, Inset *);
80 unsigned int InsetInInsetY();
82 void InsetButtonRelease(BufferView *, int, int, int);
84 void InsetButtonPress(BufferView *, int, int, int);
86 void InsetMotionNotify(BufferView *, int, int, int);
88 void InsetKeyPress(XKeyEvent *);
90 UpdatableInset::RESULT LocalDispatch(BufferView *, kb_action,
93 int Latex(Buffer const *, std::ostream &,
94 bool fragile, bool free_spc) const;
96 int Ascii(Buffer const *, std::ostream &, int) const { return 0; }
98 int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
100 int DocBook(Buffer const *, std::ostream &) const { return 0; }
102 void Validate(LaTeXFeatures & features) const;
104 void GetCursorPos(BufferView *, int & x, int & y) const;
106 void ToggleInsetCursor(BufferView *);
108 UpdatableInset * GetLockingInset();
110 UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
112 void SetFont(BufferView *, LyXFont const &, bool toggleall = false,
113 bool selectall = false);
115 void setLabel(string const & l) { label = l; }
117 void setLabelFont(LyXFont & f) { labelfont = f; }
119 void setAutoCollapse(bool f) { autocollapse = f; }
121 int getMaxWidth(BufferView *, UpdatableInset const *) const;
123 LyXText * getLyXText(BufferView const *, bool const recursive) const;
125 void deleteLyXText(BufferView *, bool recursive=true) const;
127 void resizeLyXText(BufferView *) const;
129 std::vector<string> const getLabelList() const;
133 int scroll(bool recursive=true) const;
135 void scroll(BufferView *bv, float sx) const {
136 UpdatableInset::scroll(bv, sx);
139 void scroll(BufferView *bv, int offset) const {
140 UpdatableInset::scroll(bv, offset);
145 int ascent_collapsed(Painter &, LyXFont const &) const;
147 int descent_collapsed(Painter &, LyXFont const &) const;
149 int width_collapsed(Painter &, LyXFont const & f) const;
151 void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
153 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
158 LColor::color framecolor;
166 mutable int button_length;
168 mutable int button_top_y;
170 mutable int button_bottom_y;
179 mutable int oldWidth;
182 mutable int topbaseline;
183 mutable UpdateCodes need_update;