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
24 #include "lyxparagraph.h"
31 /** A colapsable text inset
34 class InsetCollapsable : public UpdatableInset {
42 static int const TEXT_TO_TOP_OFFSET = 2;
44 static int const TEXT_TO_BOTTOM_OFFSET = 2;
48 Inset * Clone(Buffer const &) const;
50 void Read(Buffer const *, LyXLex &);
52 void Write(Buffer const *, std::ostream &) const;
54 int ascent(BufferView *, LyXFont const &) const;
56 int descent(BufferView *, LyXFont const &) const;
58 int width(BufferView *, LyXFont const & f) const;
60 void draw(BufferView *, const LyXFont &, int , float &, bool) const;
62 void update(BufferView *, LyXFont const &, bool =false);
64 void Edit(BufferView *, int, int, unsigned int);
66 EDITABLE Editable() const;
68 bool InsertInset(BufferView *, Inset * inset);
70 bool IsTextInset() const { return true; }
72 bool doClearArea() const;
74 void InsetUnlock(BufferView *);
76 bool needFullRow() const { return !collapsed; }
78 bool LockInsetInInset(BufferView *, UpdatableInset *);
80 bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
82 bool UpdateInsetInInset(BufferView *, Inset *);
84 unsigned int InsetInInsetY();
86 void InsetButtonRelease(BufferView *, int, int, int);
88 void InsetButtonPress(BufferView *, int, int, int);
90 void InsetMotionNotify(BufferView *, int, int, int);
92 void InsetKeyPress(XKeyEvent *);
94 UpdatableInset::RESULT LocalDispatch(BufferView *, kb_action,
97 int Latex(Buffer const *, std::ostream &,
98 bool fragile, bool free_spc) const;
100 int Ascii(Buffer const *, std::ostream &, int) const { return 0; }
102 int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
104 int DocBook(Buffer const *, std::ostream &) const { return 0; }
106 void Validate(LaTeXFeatures & features) const;
108 void GetCursorPos(BufferView *, int & x, int & y) const;
110 void ToggleInsetCursor(BufferView *);
112 UpdatableInset * GetLockingInset();
114 UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
116 void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
118 void setLabel(string const & l) { label = l; }
120 void setLabelFont(LyXFont & f) { labelfont = f; }
122 void setAutoCollapse(bool f) { autocollapse = f; }
124 int getMaxWidth(Painter & pain, UpdatableInset const *) const;
126 LyXText * getLyXText(BufferView const *, bool const recursive) const;
128 void deleteLyXText(BufferView *, bool recursive=true) const;
130 void resizeLyXText(BufferView *) const;
134 int ascent_collapsed(Painter &, LyXFont const &) const;
136 int descent_collapsed(Painter &, LyXFont const &) const;
138 int width_collapsed(Painter &, LyXFont const & f) const;
140 void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
142 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
147 LColor::color framecolor;
155 // Instead of making these ints protected we could have a
156 // protected method "clickInButton" (Lgb)
160 button_length, button_top_y, button_bottom_y;
170 mutable int oldWidth;
173 mutable int topbaseline;
174 mutable UpdateCodes need_update;