]> git.lyx.org Git - lyx.git/blob - src/insets/inset.C
* inset.h:
[lyx.git] / src / insets / inset.C
1 /**
2  * \file inset.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author Jürgen Vigna
8  * \author Lars Gullik Bjønnes
9  * \author Matthias Ettrich
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #include <config.h>
15
16 #include "inset.h"
17 #include "updatableinset.h"
18
19 #include "BufferView.h"
20 #include "debug.h"
21 #include "gettext.h"
22 #include "lyxtext.h"
23 #include "LColor.h"
24
25
26 using std::string;
27
28
29 InsetOld::InsetOld()
30         : InsetBase(),
31           xo_(0), yo_(0), scx(0), owner_(0),
32           //background_color_(LColor::inherit)
33           background_color_(LColor::background)
34 {}
35
36
37 InsetOld::InsetOld(InsetOld const & in)
38         : InsetBase(),
39           xo_(0), yo_(0), scx(0), owner_(0), name_(in.name_),
40           background_color_(in.background_color_)
41 {}
42
43
44 bool InsetOld::directWrite() const
45 {
46         return false;
47 }
48
49
50 InsetOld::EDITABLE InsetOld::editable() const
51 {
52         return NOT_EDITABLE;
53 }
54
55
56 bool InsetOld::autoDelete() const
57 {
58         return false;
59 }
60
61
62 string const InsetOld::editMessage() const
63 {
64         return _("Opened inset");
65 }
66
67
68 void InsetOld::setBackgroundColor(LColor_color color)
69 {
70         background_color_ = color;
71 }
72
73
74 LColor_color InsetOld::backgroundColor() const
75 {
76         return LColor::color(background_color_);
77 }
78
79
80 bool InsetOld::forceDefaultParagraphs(InsetOld const * inset) const
81 {
82         if (owner())
83                 return owner()->forceDefaultParagraphs(inset);
84         return false;
85 }
86
87
88 int InsetOld::ascent() const
89 {
90         return dim_.asc;
91 }
92
93
94 int InsetOld::descent() const
95 {
96         return dim_.des;
97 }
98
99
100 int InsetOld::width() const
101 {
102         return dim_.wid;
103 }
104
105
106 bool InsetOld::insetAllowed(InsetOld * in) const
107 {
108         return insetAllowed(in->lyxCode());
109 }
110
111
112 int InsetOld::scroll(bool recursive) const
113 {
114         if (!recursive || !owner_)
115                 return scx;
116         return 0;
117 }
118
119
120 int InsetOld::getCell(int x, int y) const
121 {
122         for (int i = 0, n = numParagraphs(); i < n; ++i) {
123                 LyXText * text = getText(i);
124                 //lyxerr << "### text: " << text << " i: " << i
125                 //      << " xo: " << text->xo_ << "..." << text->xo_ + text->width
126                 //      << " yo: " << text->yo_ 
127                 //      << " yo: " << text->yo_ - text->ascent() << "..."
128                 //              <<  text->yo_ + text->descent()
129                 //      << std::endl;   
130                 if (x >= text->xo_
131                                 && x <= text->xo_ + text->width
132                                 && y >= text->yo_ 
133                                 && y <= text->yo_ + text->height)
134                 {
135                         lyxerr << "### found text # " << i << std::endl;        
136                         return i;
137                 }
138         }
139         return -1;
140 }
141
142
143 bool isEditableInset(InsetOld const * i)
144 {
145         return i && i->editable();
146 }
147
148
149 bool isHighlyEditableInset(InsetOld const * i)
150 {
151         return i && i->editable() == InsetOld::HIGHLY_EDITABLE;
152 }
153
154