]> git.lyx.org Git - lyx.git/blob - src/insets/insetbase.C
more IU
[lyx.git] / src / insets / insetbase.C
1 /**
2  * \file insetbase.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "insetbase.h"
14 #include "debug.h"
15 #include "dispatchresult.h"
16 #include "gettext.h"
17 #include "lyxtext.h"
18
19
20 DispatchResult InsetBase::dispatch(LCursor & cur, FuncRequest const & cmd)
21 {
22         return priv_dispatch(cur, cmd);
23 }
24
25
26 DispatchResult InsetBase::priv_dispatch(LCursor &, FuncRequest const &)
27 {
28         return DispatchResult(false);
29 }
30
31
32 void InsetBase::edit(LCursor &, bool)
33 {
34         lyxerr << "InsetBase: edit left/right" << std::endl;
35 }
36
37
38 void InsetBase::edit(LCursor & cur, int, int)
39 {
40         lyxerr << "InsetBase: edit xy" << std::endl;
41         edit(cur, true);
42 }
43
44
45 InsetBase::idx_type InsetBase::index(row_type row, col_type col) const
46 {
47         if (row != 0)
48                 lyxerr << "illegal row: " << row << std::endl;
49         if (col != 0)
50                 lyxerr << "illegal col: " << col << std::endl;
51         return 0;
52 }
53
54
55 bool InsetBase::idxBetween(idx_type idx, idx_type from, idx_type to) const
56 {
57         return from <= idx && idx <= to;
58 }
59
60
61 bool InsetBase::idxUpDown(LCursor &, bool) const
62 {
63         return false;
64 }
65
66
67 bool InsetBase::idxUpDown2(LCursor &, bool) const
68 {
69         return false;
70 }
71
72
73 void InsetBase::getScreenPos(idx_type, pos_type, int & x, int & y) const
74 {
75         lyxerr << "InsetBase::getScreenPos() called directly!" << std::endl;
76         x = y = 0;
77 }
78
79
80 int InsetBase::plaintext(Buffer const &,
81         std::ostream &, OutputParams const &) const
82 {
83         return 0;
84 }
85
86
87 int InsetBase::linuxdoc(Buffer const &,
88         std::ostream &, OutputParams const &) const
89 {
90         return 0;
91 }
92
93
94 int InsetBase::docbook(Buffer const &,
95         std::ostream &, OutputParams const &) const
96 {
97         return 0;
98 }
99
100
101 bool InsetBase::directWrite() const
102 {
103         return false;
104 }
105
106
107 InsetBase::EDITABLE InsetBase::editable() const
108 {
109         return NOT_EDITABLE;
110 }
111
112
113 bool InsetBase::autoDelete() const
114 {
115         return false;
116 }
117
118
119 std::string const InsetBase::editMessage() const
120 {
121         return _("Opened inset");
122 }
123
124
125 bool InsetBase::insetAllowed(InsetBase * inset) const
126 {
127         return insetAllowed(inset->lyxCode());
128 }
129
130
131 std::string const & InsetBase::getInsetName() const
132 {
133         static std::string const name = "unknown";
134         return name;
135 }
136
137
138 int InsetBase::getCell(int x, int y) const
139 {
140         for (int i = 0, n = numParagraphs(); i < n; ++i) {
141                 LyXText * text = getText(i);
142                 //lyxerr << "### text: " << text << " i: " << i
143                 //      << " xo: " << text->xo_ << "..." << text->xo_ + text->width
144                 //      << " yo: " << text->yo_ 
145                 //      << " yo: " << text->yo_ - text->ascent() << "..."
146                 //              <<  text->yo_ + text->descent()
147                 //      << std::endl;   
148                 if (x >= text->xo_
149                                 && x <= text->xo_ + text->width
150                                 && y >= text->yo_ 
151                                 && y <= text->yo_ + text->height)
152                 {
153                         lyxerr << "### found text # " << i << std::endl;        
154                         return i;
155                 }
156         }
157         return -1;
158 }
159
160
161 void InsetBase::markErased()
162 {}
163
164 /////////////////////////////////////////
165
166 bool isEditableInset(InsetBase const * i)
167 {
168         return i && i->editable();
169 }
170
171
172 bool isHighlyEditableInset(InsetBase const * i)
173 {
174         return i && i->editable() == InsetBase::HIGHLY_EDITABLE;
175 }
176
177