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 //Inset * Clone(Buffer const &) const;
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);
116 void setLabel(string const & l) { label = l; }
118 void setLabelFont(LyXFont & f) { labelfont = f; }
120 void setAutoCollapse(bool f) { autocollapse = f; }
122 int getMaxWidth(BufferView *, UpdatableInset const *) const;
124 LyXText * getLyXText(BufferView const *, bool const recursive) const;
126 void deleteLyXText(BufferView *, bool recursive=true) const;
128 void resizeLyXText(BufferView *) const;
130 std::vector<string> const getLabelList() const;
134 int scroll(bool recursive=true) const;
135 void scroll(BufferView *bv, float sx) const {
136 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;
179 mutable int oldWidth;
182 mutable int topbaseline;
183 mutable UpdateCodes need_update;