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;
47 ~InsetCollapsable() {}
49 Inset * Clone() const;
51 void Read(Buffer const *, LyXLex &);
53 void Write(Buffer const *, std::ostream &) const;
55 int ascent(Painter &, LyXFont const &) const;
57 int descent(Painter &, LyXFont const &) const;
59 int width(Painter &, LyXFont const & f) const;
61 void draw(BufferView *, const LyXFont &, int , float &, bool) const;
63 void update(BufferView *, LyXFont const &, bool =false);
65 void Edit(BufferView *, int, int, unsigned int);
67 EDITABLE Editable() const;
69 bool IsTextInset() const { return true; }
71 bool doClearArea() const;
73 void InsetUnlock(BufferView *);
75 bool needFullRow() const { return !collapsed; }
77 bool LockInsetInInset(BufferView *, UpdatableInset *);
79 bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
81 bool UpdateInsetInInset(BufferView *, Inset *);
85 void InsetButtonRelease(BufferView *, int, int, int);
87 void InsetButtonPress(BufferView *, int, int, int);
89 void InsetMotionNotify(BufferView *, int, int, int);
91 void InsetKeyPress(XKeyEvent *);
93 UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
95 int Latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const;
97 int Ascii(Buffer const *, std::ostream &) 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;
124 void deleteLyXText(BufferView *);
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;
163 mutable int topbaseline;
164 mutable UpdateCodes need_update;