]> git.lyx.org Git - lyx.git/blob - src/insets/insetcollapsable.h
clear()->erase() ; lots of using directives for cxx
[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 "insettext.h"
21 #include "lyxfont.h"
22 #include "LColor.h"
23
24
25 class Painter;
26
27 /** A colapsable text inset
28   
29 */
30 class InsetCollapsable : public InsetText {
31 public:
32     ///
33     static int const TEXT_TO_TOP_OFFSET = 2;
34     ///
35     static int const TEXT_TO_BOTTOM_OFFSET = 2;
36     ///
37         explicit
38     InsetCollapsable(Buffer *);
39     ///
40     ~InsetCollapsable() {}
41     ///
42     Inset * Clone() const;
43     ///
44     void Read(LyXLex &);
45     ///
46     void Write(std::ostream &) const;
47     ///
48     int ascent(Painter &, LyXFont const &) const;
49     ///
50     int descent(Painter &, LyXFont const &) const;
51     ///
52     int width(Painter &, LyXFont const & f) const;
53     ///
54     void draw(Painter & pain, const LyXFont &, int , float &) const;
55     ///
56     void Edit(BufferView *, int, int, unsigned int);
57     ///
58     EDITABLE Editable() const;
59     ///
60     void InsetUnlock(BufferView *);
61     ///
62     bool display() const { return (!collapsed); }
63     ///
64     void InsetButtonRelease(BufferView *, int, int, int);
65     ///
66     void InsetButtonPress(BufferView *, int, int, int);
67     ///
68     void InsetMotionNotify(BufferView *, int, int, int);
69     ///
70     void setLabel(string const & l) { label = l; }
71     ///
72     void setLabelFont(LyXFont & f) { labelfont = f; }
73     ///
74     void setAutoCollapse(bool f) { autocollapse = f; }
75     ///
76     int getMaxWidth(Painter & pain, UpdatableInset const *) const;
77
78 protected:
79     ///
80     int ascent_collapsed(Painter &, LyXFont const &) const;
81     ///
82     int descent_collapsed(Painter &, LyXFont const &) const;
83     ///
84     int width_collapsed(Painter &, LyXFont const & f) const;
85     ///
86     void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
87     ///
88     void UpdateLocal(BufferView *, bool);
89     ///
90     int getMaxTextWidth(Painter & pain, UpdatableInset const *, int x=0) const;
91     
92     ///
93     bool collapsed;
94     ///
95     LColor::color framecolor;
96
97 private:
98     ///
99     string label;
100     ///
101     LyXFont labelfont;
102     ///
103     bool autocollapse;
104     ///
105     mutable int
106         button_length, button_top_y, button_bottom_y;
107     ///
108     int widthOffset;
109 };
110
111 #endif