]> git.lyx.org Git - lyx.git/blob - src/insets/inset.C
small fix to the doublespace handling in deleteemptyparagraphmechanism that might...
[lyx.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-1999 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 /* Insets default methods */
24
25 bool Inset::Deletable() const
26 {
27   return true;
28 }
29
30
31 bool Inset::DirectWrite() const
32 {
33   return false;
34 }
35
36
37 Inset::EDITABLE Inset::Editable() const
38 {
39   return NOT_EDITABLE;
40 }
41
42
43 void Inset::Validate(LaTeXFeatures &) const
44 {
45 }
46
47
48 bool Inset::AutoDelete() const
49 {
50   return false;
51 }
52
53
54 void Inset::Edit(BufferView *, int, int, unsigned int)
55 {
56 }
57
58
59 LyXFont Inset::ConvertFont(LyXFont font)
60 {
61   return font;
62 }
63
64
65  /* some stuff for inset locking */
66
67 void UpdatableInset::InsetButtonPress(BufferView *, int x, int y, int button)
68 {
69         lyxerr.debug() << "Inset Button Press x=" << x
70                        << ", y=" << y << ", button=" << button << endl;
71 }
72
73
74 void UpdatableInset::InsetButtonRelease(BufferView *, int x, int y, int button)
75 {
76         lyxerr.debug() << "Inset Button Release x=" << x
77                        << ", y=" << y << ", button=" << button << endl;
78 }
79
80
81 void UpdatableInset::InsetKeyPress(XKeyEvent *)
82 {
83         lyxerr.debug() << "Inset Keypress" << endl;
84 }
85
86
87 void UpdatableInset::InsetMotionNotify(BufferView *, int x, int y, int state)
88 {
89         lyxerr.debug() << "Inset Motion Notify x=" << x
90                        << ", y=" << y << ", state=" << state << endl;
91 }
92
93
94 void UpdatableInset::InsetUnlock(BufferView *)
95 {
96         lyxerr.debug() << "Inset Unlock" << endl;
97 }
98
99
100 // An updatable inset is highly editable by definition
101 Inset::EDITABLE UpdatableInset::Editable() const
102 {
103         return HIGHLY_EDITABLE;
104 }
105
106
107 void UpdatableInset::ToggleInsetCursor(BufferView *)
108 {
109 }
110
111
112 void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
113 {
114     LyXFont font;
115
116     scx = 0;
117
118     mx_scx = abs((width(bv->getPainter(), font) - bv->paperWidth()) / 2);
119 }
120
121
122 void UpdatableInset::draw(Painter &, LyXFont const &,
123                           int baseline, float & x) const
124 {
125     if (scx) x += float(scx);
126     top_x = int(x);
127     top_baseline = baseline;
128 }
129
130
131 void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool )
132 {
133 }
134
135
136 ///  An updatable inset could handle lyx editing commands
137 #ifdef SCROLL_INSET
138 UpdatableInset::RESULT
139 UpdatableInset::LocalDispatch(BufferView *, 
140                               int action, string const & arg) 
141 #else
142 UpdatableInset::RESULT
143 UpdatableInset::LocalDispatch(BufferView *, int, string const &)
144 #endif
145 {
146 #ifdef SCROLL_INSET
147     if (action==LFUN_SCROLL_INSET)
148         {
149             float xx;
150             sscanf(arg.c_str(), "%f", &xx);     
151             scroll(xx);
152
153             return DISPATCHED;
154         }
155 #endif
156     return UNDISPATCHED; 
157 }
158
159 int UpdatableInset::getMaxWidth(Painter & pain) const
160 {
161     if (owner_)
162         return owner_->getMaxWidth(pain);
163     return pain.paperWidth();
164 }
165