]> git.lyx.org Git - lyx.git/blob - src/insets/insetcollapsable.h
Various updates for insets mostly regarding fixes for text-insets.
[lyx.git] / src / insets / insetcollapsable.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *
7  *           Copyright (C) 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     InsetCollapsable(Buffer *);
38     ///
39     ~InsetCollapsable() {}
40     ///
41     Inset * InsetCollapsable::Clone();
42     ///
43     int ascent(Painter &, LyXFont const &) const;
44     ///
45     int descent(Painter &, LyXFont const &) const;
46     ///
47     int width(Painter &, LyXFont const & f) const;
48     ///
49     void draw(Painter & pain, const LyXFont &, int , float &) const;
50     ///
51     void Edit(BufferView *, int, int, unsigned int);
52     ///
53     EDITABLE Editable() const;
54     ///
55     void InsetUnlock(BufferView *);
56     ///
57     bool display() const { return (!collapsed); }
58     ///
59     void InsetButtonRelease(BufferView *, int, int, int);
60     ///
61     void InsetButtonPress(BufferView *, int, int, int);
62     ///
63     void InsetMotionNotify(BufferView *, int, int, int);
64     ///
65     void setLabel(string const & l) { label = l; }
66     ///
67     void setLabelFont(LyXFont & f) { labelfont = f; }
68     ///
69     void setAutoCollapse(bool f) { autocolapse = f; }
70
71 protected:
72     ///
73     int ascent_collapsed(Painter &, LyXFont const &) const;
74     ///
75     int descent_collapsed(Painter &, LyXFont const &) const;
76     ///
77     int width_collapsed(Painter &, LyXFont const & f) const;
78     ///
79     void draw_collapsed(Painter & pain, const LyXFont &, int , float &) const;
80     ///
81     void UpdateLocal(BufferView *, bool);
82     
83     ///
84     bool collapsed;
85     ///
86     LColor::color framecolor;
87
88 private:
89     ///
90     string label;
91     ///
92     LyXFont labelfont;
93     ///
94     bool autocolapse;
95     ///
96     mutable int
97         top_baseline, top_x,
98         button_x;
99 };
100
101 #endif