]> git.lyx.org Git - lyx.git/blob - src/insets/insetcollapsable.h
remove Inset::getParagraphs()
[lyx.git] / src / insets / insetcollapsable.h
1 // -*- C++ -*-
2 /**
3  * \file insetcollapsable.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Alejandro Aguilar Sierra
8  * \author Jürgen Vigna
9  * \author Lars Gullik Bjønnes
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef INSETCOLLAPSABLE_H
15 #define INSETCOLLAPSABLE_H
16
17 #include "inset.h"
18 #include "insettext.h"
19
20 #include "box.h"
21 #include "lyxfont.h"
22
23 class Painter;
24 class LyXText;
25 class Paragraph;
26 class LyXCursor;
27
28 /** A collapsable text inset
29
30 */
31 class InsetCollapsable : public UpdatableInset {
32 public:
33         ///
34         static int const TEXT_TO_TOP_OFFSET = 2;
35         ///
36         static int const TEXT_TO_BOTTOM_OFFSET = 2;
37         ///
38         enum CollapseStatus {
39                 Open,
40                 Collapsed,
41                 Inlined
42         };
43         /// inset is initially collapsed if bool = true
44         InsetCollapsable(BufferParams const &, bool collapsed = false);
45         ///
46         InsetCollapsable(InsetCollapsable const & in);
47         ///
48         void read(Buffer const &, LyXLex &);
49         ///
50         void write(Buffer const &, std::ostream &) const;
51         ///
52         void metrics(MetricsInfo &, Dimension &) const;
53         ///
54         void draw(PainterInfo & pi, int x, int y) const;
55         ///
56         bool hitButton(FuncRequest const &) const;
57         ///
58         std::string const getNewLabel(std::string const & l) const;
59         ///
60         EDITABLE editable() const;
61         /// can we go further down on mouse click?
62         bool descendable() const;
63         ///
64         bool insertInset(BufferView *, InsetOld * inset);
65         ///
66         bool insetAllowed(InsetOld::Code code) const;
67         ///
68         bool isTextInset() const { return true; }
69         ///
70         int latex(Buffer const &, std::ostream &,
71                   OutputParams const &) const;
72         ///
73         int plaintext(Buffer const &, std::ostream &,
74                   OutputParams const &) const;
75         ///
76         int linuxdoc(Buffer const &, std::ostream &,
77                      OutputParams const &) const;
78         ///
79         int docbook(Buffer const &, std::ostream &,
80                     OutputParams const & runparams) const;
81         ///
82         void validate(LaTeXFeatures & features) const;
83         /// get the screen x,y of the cursor
84         void getCursorPos(int & x, int & y) const;
85         ///
86         void setLabel(std::string const & l) const;
87         ///
88         void setLabelFont(LyXFont & f);
89 #if 0
90         ///
91         void setAutoCollapse(bool f);
92 #endif
93         /// Appends \c list with all labels found within this inset.
94         void getLabelList(Buffer const &, std::vector<std::string> & list) const;
95         ///
96         int scroll(bool recursive=true) const;
97         ///
98         void scroll(BufferView *bv, float sx) const;
99         ///
100         void scroll(BufferView *bv, int offset) const;
101         ///
102         int numParagraphs() const;
103         ///
104         LyXText * getText(int) const;
105         ///
106         bool isOpen() const { return status_ == Open || status_ == Inlined; }
107         ///
108         bool inlined() const { return status_ == Inlined; }
109         ///
110         CollapseStatus status() const { return status_; }
111         ///
112         void open();
113         ///
114         void close();
115         ///
116         void markErased();
117         ///
118         void addPreview(lyx::graphics::PreviewLoader &) const;
119         ///
120         void setBackgroundColor(LColor_color);
121         ///
122         virtual void setStatus(CollapseStatus st);
123
124 protected:
125         ///
126         virtual
127         DispatchResult
128         priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
129         ///
130         void dimension_collapsed(Dimension &) const;
131         ///
132         int height_collapsed() const;
133         ///
134         void draw_collapsed(PainterInfo & pi, int x, int y) const;
135         ///
136         int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
137         ///
138         Box const & buttonDim() const;
139         ///
140         void edit(BufferView *, bool);
141         ///
142         void edit(BufferView *, int, int);
143
144 private:
145         ///
146         DispatchResult lfunMouseRelease(FuncRequest const &);
147         ///
148         FuncRequest adjustCommand(FuncRequest const &);
149
150 public:
151         ///
152         mutable InsetText inset;
153 protected:
154         ///
155         mutable CollapseStatus status_;
156         ///
157         LyXFont labelfont_;
158         ///
159         mutable Box button_dim;
160         ///
161         mutable int topx;
162         ///
163         mutable int topbaseline;
164         ///
165         mutable std::string label;
166 #if 0
167         ///
168         bool autocollapse;
169 #endif
170 };
171
172 #endif