]> git.lyx.org Git - lyx.git/blob - src/insets/inset.C
Fixed the display bug for text-insets we still had and now ERT-insets do
[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
22 /* Insets default methods */
23
24 bool Inset::Deletable() const
25 {
26   return true;
27 }
28
29
30 bool Inset::DirectWrite() const
31 {
32   return false;
33 }
34
35
36 unsigned char Inset::Editable() const
37 {
38   return 0;
39 }
40
41
42 void Inset::Validate(LaTeXFeatures &) const
43 {
44 }
45
46
47 bool Inset::AutoDelete() const
48 {
49   return false;
50 }
51
52
53 void Inset::Edit(BufferView *, int, int, unsigned int)
54 {
55 }
56
57
58 LyXFont Inset::ConvertFont(LyXFont font)
59 {
60   return font;
61 }
62
63
64  /* some stuff for inset locking */
65
66 void UpdatableInset::InsetButtonPress(BufferView *, int x, int y, int button)
67 {
68         lyxerr.debug() << "Inset Button Press x=" << x
69                        << ", y=" << y << ", button=" << button << endl;
70 }
71
72
73 void UpdatableInset::InsetButtonRelease(BufferView *, int x, int y, int button)
74 {
75         lyxerr.debug() << "Inset Button Release x=" << x
76                        << ", y=" << y << ", button=" << button << endl;
77 }
78
79
80 void UpdatableInset::InsetKeyPress(XKeyEvent *)
81 {
82         lyxerr.debug() << "Inset Keypress" << endl;
83 }
84
85
86 void UpdatableInset::InsetMotionNotify(BufferView *, int x, int y, int state)
87 {
88         lyxerr.debug() << "Inset Motion Notify x=" << x
89                        << ", y=" << y << ", state=" << state << endl;
90 }
91
92
93 void UpdatableInset::InsetUnlock(BufferView *)
94 {
95         lyxerr.debug() << "Inset Unlock" << endl;
96 }
97
98
99 // An updatable inset is highly editable by definition
100 unsigned char UpdatableInset::Editable() const
101 {
102         return 2; // and what does "2" siginify? (Lgb)
103 }
104
105
106 void UpdatableInset::ToggleInsetCursor(BufferView *)
107 {
108 }
109
110
111 void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
112 {
113     LyXFont
114         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 ///  An updatable inset could handle lyx editing commands
136 #ifdef SCROLL_INSET
137 UpdatableInset::RESULT
138 UpdatableInset::LocalDispatch(BufferView *, 
139                               int action, string const & arg) 
140 #else
141 UpdatableInset::RESULT
142 UpdatableInset::LocalDispatch(BufferView *, int, string const &)
143 #endif
144 {
145 #ifdef SCROLL_INSET
146     if (action==LFUN_SCROLL_INSET)
147         {
148             float xx;
149             sscanf(arg.c_str(), "%f", &xx);     
150             scroll(xx);
151
152             return DISPATCHED;
153         }
154 #endif
155     return UNDISPATCHED; 
156 }