]> git.lyx.org Git - features.git/blob - src/insets/inset.C
Various small fixes, look in ChangeLog
[features.git] / src / insets / inset.C
1 /* This file is part of
2  * ====================================================== 
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 1995 Matthias Ettrich
7  *          Copyright 1995-2000 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation "lyxinset.h"
15 #endif
16
17 #include "lyxinset.h"
18 #include "debug.h"
19 #include "BufferView.h"
20 #include "support/lstrings.h"
21 #include "Painter.h"
22
23 using std::endl;
24
25 /* Insets default methods */
26
27 bool Inset::Deletable() const
28 {
29   return true;
30 }
31
32
33 bool Inset::DirectWrite() const
34 {
35   return false;
36 }
37
38
39 Inset::EDITABLE Inset::Editable() const
40 {
41   return NOT_EDITABLE;
42 }
43
44 bool Inset::IsTextInset() const
45 {
46         return ((LyxCode() == TEXT_CODE) ||
47                 (LyxCode() == ERT_CODE) ||
48                 (LyxCode() == FOOT_CODE) ||
49                 (LyxCode() == MARGIN_CODE));
50 }
51
52 void Inset::Validate(LaTeXFeatures &) const
53 {
54 }
55
56
57 bool Inset::AutoDelete() const
58 {
59   return false;
60 }
61
62
63 void Inset::Edit(BufferView *, int, int, unsigned int)
64 {
65 }
66
67
68 LyXFont Inset::ConvertFont(LyXFont font)
69 {
70   return font;
71 }
72
73
74  /* some stuff for inset locking */
75
76 void UpdatableInset::InsetButtonPress(BufferView *, int x, int y, int button)
77 {
78         lyxerr.debug() << "Inset Button Press x=" << x
79                        << ", y=" << y << ", button=" << button << endl;
80 }
81
82
83 void UpdatableInset::InsetButtonRelease(BufferView *, int x, int y, int button)
84 {
85         lyxerr.debug() << "Inset Button Release x=" << x
86                        << ", y=" << y << ", button=" << button << endl;
87 }
88
89
90 void UpdatableInset::InsetKeyPress(XKeyEvent *)
91 {
92         lyxerr.debug() << "Inset Keypress" << endl;
93 }
94
95
96 void UpdatableInset::InsetMotionNotify(BufferView *, int x, int y, int state)
97 {
98         lyxerr.debug() << "Inset Motion Notify x=" << x
99                        << ", y=" << y << ", state=" << state << endl;
100 }
101
102
103 void UpdatableInset::InsetUnlock(BufferView *)
104 {
105         lyxerr.debug() << "Inset Unlock" << endl;
106 }
107
108
109 // An updatable inset is highly editable by definition
110 Inset::EDITABLE UpdatableInset::Editable() const
111 {
112         return HIGHLY_EDITABLE;
113 }
114
115
116 void UpdatableInset::ToggleInsetCursor(BufferView *)
117 {
118 }
119
120
121 void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
122 {
123     LyXFont font;
124
125     scx = 0;
126
127     mx_scx = abs((width(bv->getPainter(), font) - bv->paperWidth()) / 2);
128 }
129
130
131 void UpdatableInset::draw(Painter &, LyXFont const &,
132                           int baseline, float & x) const
133 {
134     if (scx) x += float(scx);
135     top_x = int(x);
136     top_baseline = baseline;
137 }
138
139
140 void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool )
141 {
142 }
143
144
145 ///  An updatable inset could handle lyx editing commands
146 #ifdef SCROLL_INSET
147 UpdatableInset::RESULT
148 UpdatableInset::LocalDispatch(BufferView *, 
149                               int action, string const & arg) 
150 #else
151 UpdatableInset::RESULT
152 UpdatableInset::LocalDispatch(BufferView *, int, string const &)
153 #endif
154 {
155 #ifdef SCROLL_INSET
156     if (action==LFUN_SCROLL_INSET)
157         {
158             float xx;
159             sscanf(arg.c_str(), "%f", &xx);     
160             scroll(xx);
161
162             return DISPATCHED;
163         }
164 #endif
165     return UNDISPATCHED; 
166 }
167
168 int UpdatableInset::getMaxWidth(Painter & pain) const
169 {
170     if (owner_)
171         return owner_->getMaxWidth(pain);
172     return pain.paperWidth();
173 }
174