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"
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);
114 void setLabel(string const & l) { label = l; }
116 void setLabelFont(LyXFont & f) { labelfont = f; }
118 void setAutoCollapse(bool f) { autocollapse = f; }
120 int getMaxWidth(BufferView *, UpdatableInset const *) const;
122 LyXText * getLyXText(BufferView const *, bool const recursive) const;
124 void deleteLyXText(BufferView *, bool recursive=true) const;
126 void resizeLyXText(BufferView *) const;
128 std::vector<string> const getLabelList() const;
132 int scroll(bool recursive=true) const;
134 void scroll(BufferView *bv, float sx) const {
135 UpdatableInset::scroll(bv, sx);
138 void scroll(BufferView *bv, int offset) const {
139 UpdatableInset::scroll(bv, offset);
144 int ascent_collapsed(Painter &, LyXFont const &) const;
146 int descent_collapsed(Painter &, LyXFont const &) const;
148 int width_collapsed(Painter &, LyXFont const & f) const;
150 void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
152 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
157 LColor::color framecolor;
165 mutable int button_length;
167 mutable int button_top_y;
169 mutable int button_bottom_y;
178 mutable int oldWidth;
181 mutable int topbaseline;
182 mutable UpdateCodes need_update;