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() 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 *);
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 &, bool fragile, bool free_spc) const;
96 int Ascii(Buffer const *, std::ostream &) 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(Painter & pain, UpdatableInset const *) const;
122 LyXText * getLyXText(BufferView *) const;
123 void deleteLyXText(BufferView *, bool recursive=true) const;
124 void resizeLyXText(BufferView *) const;
128 int ascent_collapsed(Painter &, LyXFont const &) const;
130 int descent_collapsed(Painter &, LyXFont const &) const;
132 int width_collapsed(Painter &, LyXFont const & f) const;
134 void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
136 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
141 LColor::color framecolor;
146 // Instead of making these ints protected we could have a
147 // protected method "clickInButton" (Lgb)
150 button_length, button_top_y, button_bottom_y;
160 mutable int oldWidth;
163 mutable int topbaseline;
164 mutable UpdateCodes need_update;