]> git.lyx.org Git - lyx.git/blob - src/insets/insetcollapsable.h
Reindent files with tab-stops (instead of 4 spaces). It is allowed to change
[lyx.git] / src / insets / insetcollapsable.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *
7  *           Copyright 2000 The LyX Team.
8  *
9  *======================================================
10  */
11
12
13 #ifndef INSETCOLLAPSABLE_H
14 #define INSETCOLLAPSABLE_H
15
16 #ifdef __GNUG__
17 #pragma interface
18 #endif
19
20 #include "lyxinset.h"
21 #include "insettext.h"
22 #include "lyxfont.h"
23 #include "LColor.h"
24 #if 1 // NEW_INSETS
25 #include "lyxparagraph.h"
26 #endif
27
28 class Painter;
29 class LyXText;
30
31 /** A colapsable text inset
32   
33 */
34 class InsetCollapsable : public UpdatableInset {
35 public:
36         ///
37         enum UpdateCodes {
38         NONE = 0,
39         FULL
40         };
41         ///
42         static int const TEXT_TO_TOP_OFFSET = 2;
43         ///
44         static int const TEXT_TO_BOTTOM_OFFSET = 2;
45         ///
46         InsetCollapsable();
47         ///
48         Inset * Clone(Buffer const &) const;
49         ///
50         void Read(Buffer const *, LyXLex &);
51         ///
52         void Write(Buffer const *, std::ostream &) const;
53         ///
54         int ascent(BufferView *, LyXFont const &) const;
55         ///
56         int descent(BufferView *, LyXFont const &) const;
57         ///
58         int width(BufferView *, LyXFont const & f) const;
59         ///
60         void draw(BufferView *, const LyXFont &, int , float &, bool) const;
61         ///
62         void update(BufferView *, LyXFont const &, bool =false); 
63         ///
64         void Edit(BufferView *, int, int, unsigned int);
65         ///
66         EDITABLE Editable() const;
67         ///
68         bool InsertInset(BufferView *, Inset * inset);
69         ///
70         bool IsTextInset() const { return true; }
71         ///
72         bool doClearArea() const;
73         ///
74         void InsetUnlock(BufferView *);
75         ///
76         bool needFullRow() const { return !collapsed; }
77         ///
78         bool LockInsetInInset(BufferView *, UpdatableInset *);
79         ///
80         bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
81         ///
82         bool UpdateInsetInInset(BufferView *, Inset *);
83         ///
84         unsigned int InsetInInsetY();
85         ///
86         void InsetButtonRelease(BufferView *, int, int, int);
87         ///
88         void InsetButtonPress(BufferView *, int, int, int);
89         ///
90         void InsetMotionNotify(BufferView *, int, int, int);
91         ///
92         void InsetKeyPress(XKeyEvent *);
93         ///
94         UpdatableInset::RESULT LocalDispatch(BufferView *, kb_action,
95                                          string const &);
96         ///
97         int Latex(Buffer const *, std::ostream &,
98                   bool fragile, bool free_spc) const;
99         ///
100         int Ascii(Buffer const *, std::ostream &, int) const { return 0; }
101         ///
102         int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
103         ///
104         int DocBook(Buffer const *, std::ostream &) const { return 0; }
105         ///
106         void Validate(LaTeXFeatures & features) const;
107         ///
108         void GetCursorPos(BufferView *, int & x, int & y) const;
109         ///
110         void ToggleInsetCursor(BufferView *);
111         ///
112         UpdatableInset * GetLockingInset();
113         ///
114         UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
115         ///
116         void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
117         ///
118         void setLabel(string const & l) { label = l; }
119         ///
120         void setLabelFont(LyXFont & f) { labelfont = f; }
121         ///
122         void setAutoCollapse(bool f) { autocollapse = f; }
123         ///
124         int getMaxWidth(BufferView *, UpdatableInset const *) const;
125         ///
126         LyXText * getLyXText(BufferView const *, bool const recursive) const;
127         ///
128         void deleteLyXText(BufferView *, bool recursive=true) const;
129         ///
130         void resizeLyXText(BufferView *) const;
131
132 protected:
133         ///
134         int ascent_collapsed(Painter &, LyXFont const &) const;
135         ///
136         int descent_collapsed(Painter &, LyXFont const &) const;
137         ///
138         int width_collapsed(Painter &, LyXFont const & f) const;
139         ///
140         void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
141         ///
142         int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
143         
144         ///
145         bool collapsed;
146         ///
147         LColor::color framecolor;
148         ///
149         LyXFont labelfont;
150 #ifdef NEW_INSETS
151 public:
152 #endif
153         ///
154         InsetText inset;
155 protected:
156         ///
157         mutable int button_length;
158         ///
159         mutable int button_top_y;
160         ///
161         mutable int button_bottom_y;
162
163 private:
164         ///
165         string label;
166         ///
167         bool autocollapse;
168         ///
169         int widthCollapsed;
170         ///
171         mutable int oldWidth;
172         ///
173         mutable int topx;
174         mutable int topbaseline;
175         mutable UpdateCodes need_update;
176 };
177
178 #endif