]> git.lyx.org Git - lyx.git/blob - src/insets/insetcollapsable.h
reformatting and remove using delc
[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 *,
81                                 bool lr = false);
82         ///
83         bool UpdateInsetInInset(BufferView *, Inset *);
84         ///
85         unsigned int InsetInInsetY();
86         ///
87         void InsetButtonRelease(BufferView *, int, int, int);
88         ///
89         void InsetButtonPress(BufferView *, int, int, int);
90         ///
91         void InsetMotionNotify(BufferView *, int, int, int);
92         ///
93         void InsetKeyPress(XKeyEvent *);
94         ///
95         UpdatableInset::RESULT LocalDispatch(BufferView *, kb_action,
96                                              string const &);
97         ///
98         int Latex(Buffer const *, std::ostream &,
99                   bool fragile, bool free_spc) const;
100         ///
101         int Ascii(Buffer const *, std::ostream &, int) const { return 0; }
102         ///
103         int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
104         ///
105         int DocBook(Buffer const *, std::ostream &) const { return 0; }
106         ///
107         void Validate(LaTeXFeatures & features) const;
108         ///
109         void GetCursorPos(BufferView *, int & x, int & y) const;
110         ///
111         void ToggleInsetCursor(BufferView *);
112         ///
113         UpdatableInset * GetLockingInset();
114         ///
115         UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
116         ///
117         void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
118         ///
119         void setLabel(string const & l) { label = l; }
120         ///
121         void setLabelFont(LyXFont & f) { labelfont = f; }
122         ///
123         void setAutoCollapse(bool f) { autocollapse = f; }
124         ///
125         int getMaxWidth(BufferView *, UpdatableInset const *) const;
126         ///
127         LyXText * getLyXText(BufferView const *, bool const recursive) const;
128         ///
129         void deleteLyXText(BufferView *, bool recursive=true) const;
130         ///
131         void resizeLyXText(BufferView *) const;
132
133 protected:
134         ///
135         int ascent_collapsed(Painter &, LyXFont const &) const;
136         ///
137         int descent_collapsed(Painter &, LyXFont const &) const;
138         ///
139         int width_collapsed(Painter &, LyXFont const & f) const;
140         ///
141         void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
142         ///
143         int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
144         
145         ///
146         bool collapsed;
147         ///
148         LColor::color framecolor;
149         ///
150         LyXFont labelfont;
151 #ifdef NEW_INSETS
152 public:
153 #endif
154         ///
155         InsetText inset;
156 protected:
157         ///
158         mutable int button_length;
159         ///
160         mutable int button_top_y;
161         ///
162         mutable int button_bottom_y;
163
164 private:
165         ///
166         string label;
167         ///
168         bool autocollapse;
169         ///
170         int widthCollapsed;
171         ///
172         mutable int oldWidth;
173         ///
174         mutable int topx;
175         mutable int topbaseline;
176         mutable UpdateCodes need_update;
177 };
178
179 #endif