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);
70 bool insertInsetAllowed(Inset::Code code) const {
71 return inset.insertInsetAllowed(code);
74 bool isTextInset() const { return true; }
76 bool doClearArea() const;
78 void insetUnlock(BufferView *);
80 bool needFullRow() const { return !collapsed_; }
82 bool lockInsetInInset(BufferView *, UpdatableInset *);
84 bool unlockInsetInInset(BufferView *, UpdatableInset *,
87 bool updateInsetInInset(BufferView *, Inset *);
89 unsigned int insetInInsetY();
91 void insetButtonRelease(BufferView *, int, int, int);
93 void insetButtonPress(BufferView *, int, int, int);
95 void insetMotionNotify(BufferView *, int, int, int);
97 void insetKeyPress(XKeyEvent *);
99 UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
102 int latex(Buffer const *, std::ostream &,
103 bool fragile, bool free_spc) const;
105 int ascii(Buffer const *, std::ostream &, int) const { return 0; }
107 int linuxdoc(Buffer const *, std::ostream &) const { return 0; }
109 int docBook(Buffer const *, std::ostream &) const { return 0; }
111 void validate(LaTeXFeatures & features) const;
113 void getCursorPos(BufferView *, int & x, int & y) const;
115 void toggleInsetCursor(BufferView *);
117 UpdatableInset * getLockingInset() const;
119 UpdatableInset * getFirstLockingInsetOfType(Inset::Code);
121 void setFont(BufferView *, LyXFont const &, bool toggleall = false,
122 bool selectall = false);
124 void setLabel(string const & l) { label = l; }
126 void setLabelFont(LyXFont & f) { labelfont = f; }
128 void setAutoCollapse(bool f) { autocollapse = f; }
130 int getMaxWidth(BufferView *, UpdatableInset const *) const;
132 LyXText * getLyXText(BufferView const *, bool const recursive) const;
134 void deleteLyXText(BufferView *, bool recursive=true) const;
136 void resizeLyXText(BufferView *, bool force = false) const;
138 std::vector<string> const getLabelList() const;
142 int scroll(bool recursive=true) const;
144 void scroll(BufferView *bv, float sx) const {
145 UpdatableInset::scroll(bv, sx);
148 void scroll(BufferView *bv, int offset) const {
149 UpdatableInset::scroll(bv, offset);
152 Paragraph * getParFromID(int id) const;
154 Inset * getInsetFromID(int id) const;
156 Paragraph * firstParagraph() const;
158 LyXCursor const & cursor(BufferView *) const;
160 bool isCollapsable() const { return true; }
161 bool collapsed() const { return collapsed_; }
162 void collapsed(BufferView *, bool);
166 int ascent_collapsed(Painter &, LyXFont const &) const;
168 int descent_collapsed(Painter &, LyXFont const &) const;
170 int width_collapsed(Painter &, LyXFont const & f) const;
172 void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
174 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
179 LColor::color framecolor;
187 mutable int button_length;
189 mutable int button_top_y;
191 mutable int button_bottom_y;
200 mutable int oldWidth;
203 mutable int topbaseline;
204 mutable UpdateCodes need_update;