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
29 /** A colapsable text inset
32 class InsetCollapsable : public UpdatableInset {
40 static int const TEXT_TO_TOP_OFFSET = 2;
42 static int const TEXT_TO_BOTTOM_OFFSET = 2;
46 Inset * Clone(Buffer const &) const;
48 void Read(Buffer const *, LyXLex &);
50 void Write(Buffer const *, std::ostream &) const;
52 int ascent(BufferView *, LyXFont const &) const;
54 int descent(BufferView *, LyXFont const &) const;
56 int width(BufferView *, LyXFont const & f) const;
58 void draw(BufferView *, const LyXFont &, int , float &, bool) const;
60 void update(BufferView *, LyXFont const &, bool =false);
62 void Edit(BufferView *, int, int, unsigned int);
64 EDITABLE Editable() const;
66 bool InsertInset(BufferView *, Inset * inset);
68 bool IsTextInset() const { return true; }
70 bool doClearArea() const;
72 void InsetUnlock(BufferView *);
74 bool needFullRow() const { return !collapsed; }
76 bool LockInsetInInset(BufferView *, UpdatableInset *);
78 bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
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 *, int, string const &);
94 int Latex(Buffer const *, std::ostream &,
95 bool fragile, bool free_spc) const;
97 int Ascii(Buffer const *, std::ostream &, int) const { return 0; }
99 int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
101 int DocBook(Buffer const *, std::ostream &) const { return 0; }
103 void Validate(LaTeXFeatures & features) const;
105 void GetCursorPos(BufferView *, int & x, int & y) const;
107 void ToggleInsetCursor(BufferView *);
109 UpdatableInset * GetLockingInset();
111 UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
113 void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
115 void setLabel(string const & l) { label = l; }
117 void setLabelFont(LyXFont & f) { labelfont = f; }
119 void setAutoCollapse(bool f) { autocollapse = f; }
121 int getMaxWidth(Painter & pain, UpdatableInset const *) const;
123 LyXText * getLyXText(BufferView *) const;
125 void deleteLyXText(BufferView *, bool recursive=true) const;
127 void resizeLyXText(BufferView *) const;
131 int ascent_collapsed(Painter &, LyXFont const &) const;
133 int descent_collapsed(Painter &, LyXFont const &) const;
135 int width_collapsed(Painter &, LyXFont const & f) const;
137 void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
139 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
144 LColor::color framecolor;
149 // Instead of making these ints protected we could have a
150 // protected method "clickInButton" (Lgb)
153 button_length, button_top_y, button_bottom_y;
163 mutable int oldWidth;
166 mutable int topbaseline;
167 mutable UpdateCodes need_update;