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 *, 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(Painter & pain, 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;
132 int ascent_collapsed(Painter &, LyXFont const &) const;
134 int descent_collapsed(Painter &, LyXFont const &) const;
136 int width_collapsed(Painter &, LyXFont const & f) const;
138 void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
140 int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
145 LColor::color framecolor;
150 // Instead of making these ints protected we could have a
151 // protected method "clickInButton" (Lgb)
154 button_length, button_top_y, button_bottom_y;
164 mutable int oldWidth;
167 mutable int topbaseline;
168 mutable UpdateCodes need_update;