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"
30 /** A colapsable text inset
33 class InsetCollapsable : public UpdatableInset {
41 static int const TEXT_TO_TOP_OFFSET = 2;
43 static int const TEXT_TO_BOTTOM_OFFSET = 2;
47 void read(Buffer const *, LyXLex &);
49 void write(Buffer const *, std::ostream &) const;
51 int ascent(BufferView *, LyXFont const &) const;
53 int descent(BufferView *, LyXFont const &) const;
55 int width(BufferView *, LyXFont const & f) const;
57 void draw(BufferView *, const LyXFont &, int , float &, bool) const;
59 void update(BufferView *, LyXFont const &, bool =false);
61 void edit(BufferView *, int, int, unsigned int);
63 EDITABLE editable() const;
65 bool insertInset(BufferView *, Inset * inset);
67 bool isTextInset() const { return true; }
69 bool doClearArea() const;
71 void insetUnlock(BufferView *);
73 bool needFullRow() const { return !collapsed; }
75 bool lockInsetInInset(BufferView *, UpdatableInset *);
77 bool unlockInsetInInset(BufferView *, UpdatableInset *,
80 bool updateInsetInInset(BufferView *, Inset *);
82 unsigned int insetInInsetY();
84 void insetButtonRelease(BufferView *, int, int, int);
86 void insetButtonPress(BufferView *, int, int, int);
88 void insetMotionNotify(BufferView *, int, int, int);
90 void insetKeyPress(XKeyEvent *);
92 UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
95 int latex(Buffer const *, std::ostream &,
96 bool fragile, bool free_spc) const;
98 int ascii(Buffer const *, std::ostream &, int) const { return 0; }
100 int linuxdoc(Buffer const *, std::ostream &) const { return 0; }
102 int docBook(Buffer const *, std::ostream &) const { return 0; }
104 void validate(LaTeXFeatures & features) const;
106 void getCursorPos(BufferView *, int & x, int & y) const;
108 void toggleInsetCursor(BufferView *);
110 UpdatableInset * getLockingInset();
112 UpdatableInset * getFirstLockingInsetOfType(Inset::Code);
114 void setFont(BufferView *, LyXFont const &, bool toggleall = false,
115 bool selectall = false);
117 void setLabel(string const & l) { label = l; }
119 void setLabelFont(LyXFont & f) { labelfont = f; }
121 void setAutoCollapse(bool f) { autocollapse = f; }
123 int getMaxWidth(BufferView *, UpdatableInset const *) const;
125 LyXText * getLyXText(BufferView const *, bool const recursive) const;
127 void deleteLyXText(BufferView *, bool recursive=true) const;
129 void resizeLyXText(BufferView *, bool force = false) const;
131 std::vector<string> const getLabelList() const;
135 int scroll(bool recursive=true) const;
137 void scroll(BufferView *bv, float sx) const {
138 UpdatableInset::scroll(bv, sx);
141 void scroll(BufferView *bv, int offset) const {
142 UpdatableInset::scroll(bv, offset);
145 Paragraph * getParFromID(int id) const;
147 Inset * getInsetFromID(int id) const;
149 Paragraph * firstParagraph() const;
151 LyXCursor const & cursor(BufferView *) const;
155 int ascent_collapsed(Painter &, LyXFont const &) const;
157 int descent_collapsed(Painter &, LyXFont const &) const;
159 int width_collapsed(Painter &, LyXFont const & f) const;
161 void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
163 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
168 LColor::color framecolor;
176 mutable int button_length;
178 mutable int button_top_y;
180 mutable int button_bottom_y;
189 mutable int oldWidth;
192 mutable int topbaseline;
193 mutable UpdateCodes need_update;