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 insertInsetAllowed(Inset * in) const {
68 return inset.insertInsetAllowed(in);
71 bool isTextInset() const { return true; }
73 bool doClearArea() const;
75 void insetUnlock(BufferView *);
77 bool needFullRow() const { return !collapsed; }
79 bool lockInsetInInset(BufferView *, UpdatableInset *);
81 bool unlockInsetInInset(BufferView *, UpdatableInset *,
84 bool updateInsetInInset(BufferView *, Inset *);
86 unsigned int insetInInsetY();
88 void insetButtonRelease(BufferView *, int, int, int);
90 void insetButtonPress(BufferView *, int, int, int);
92 void insetMotionNotify(BufferView *, int, int, int);
94 void insetKeyPress(XKeyEvent *);
96 UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
99 int latex(Buffer const *, std::ostream &,
100 bool fragile, bool free_spc) const;
102 int ascii(Buffer const *, std::ostream &, int) const { return 0; }
104 int linuxdoc(Buffer const *, std::ostream &) const { return 0; }
106 int docBook(Buffer const *, std::ostream &) const { return 0; }
108 void validate(LaTeXFeatures & features) const;
110 void getCursorPos(BufferView *, int & x, int & y) const;
112 void toggleInsetCursor(BufferView *);
114 UpdatableInset * getLockingInset();
116 UpdatableInset * getFirstLockingInsetOfType(Inset::Code);
118 void setFont(BufferView *, LyXFont const &, bool toggleall = false,
119 bool selectall = false);
121 void setLabel(string const & l) { label = l; }
123 void setLabelFont(LyXFont & f) { labelfont = f; }
125 void setAutoCollapse(bool f) { autocollapse = f; }
127 int getMaxWidth(BufferView *, UpdatableInset const *) const;
129 LyXText * getLyXText(BufferView const *, bool const recursive) const;
131 void deleteLyXText(BufferView *, bool recursive=true) const;
133 void resizeLyXText(BufferView *, bool force = false) const;
135 std::vector<string> const getLabelList() const;
139 int scroll(bool recursive=true) const;
141 void scroll(BufferView *bv, float sx) const {
142 UpdatableInset::scroll(bv, sx);
145 void scroll(BufferView *bv, int offset) const {
146 UpdatableInset::scroll(bv, offset);
149 Paragraph * getParFromID(int id) const;
151 Inset * getInsetFromID(int id) const;
153 Paragraph * firstParagraph() const;
155 LyXCursor const & cursor(BufferView *) const;
159 int ascent_collapsed(Painter &, LyXFont const &) const;
161 int descent_collapsed(Painter &, LyXFont const &) const;
163 int width_collapsed(Painter &, LyXFont const & f) const;
165 void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
167 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
172 LColor::color framecolor;
180 mutable int button_length;
182 mutable int button_top_y;
184 mutable int button_bottom_y;
193 mutable int oldWidth;
196 mutable int topbaseline;
197 mutable UpdateCodes need_update;