]> git.lyx.org Git - lyx.git/blob - src/insets/insettext.h
Small compilation fixes for compaq cxx; updated ca.po
[lyx.git] / src / insets / insettext.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *
7  *           Copyright 1998 The LyX Team.
8  *
9  *======================================================
10  */
11 // The pristine updatable inset: Text
12
13
14 #ifndef INSETTEXT_H
15 #define INSETTEXT_H
16
17 #ifdef __GNUG__
18 #pragma interface
19 #endif
20
21 #include "lyxinset.h"
22 #include "lyxparagraph.h"
23 #include "LString.h"
24 #include "buffer.h"
25
26 class Painter;
27 class BufferView;
28
29 /** A text inset is like a TeX box
30   
31   To write full text (including styles and other insets) in a given
32   space. 
33 */
34 class InsetText : public UpdatableInset {
35 public:
36         ///
37         enum { TEXT_TO_INSET_OFFSET = 1 };
38     ///
39     InsetText(Buffer *);
40     ///
41     InsetText(InsetText const &, Buffer *);
42     ///
43     ~InsetText();
44     ///
45     Inset * Clone() const;
46     ///
47     void Read(LyXLex &);
48     ///
49     void Write(ostream &) const;
50     ///
51     int ascent(Painter &, LyXFont const &) const;
52     ///
53     int descent(Painter &, LyXFont const &) const;
54     ///
55     int width(Painter &, LyXFont const & f) const;
56     ///
57     int getMaxWidth(UpdatableInset *) const;
58     ///
59     void draw(Painter & pain, LyXFont const &, int , float &) const;
60     ///
61     char const * EditMessage() const;
62     ///
63     void Edit(BufferView *, int, int, unsigned int);
64     ///
65     void InsetUnlock(BufferView *);
66     ///
67     bool UnlockInsetInInset(BufferView *, Inset *, bool lr = false);
68     ///
69     //void UpdateLocal(bool flag=true);
70     ///
71     bool UpdateInsetInInset(BufferView *, Inset *);
72     ///
73     void InsetButtonRelease(BufferView *, int, int, int);
74     ///
75     void InsetButtonPress(BufferView *, int, int, int);
76     ///
77     void InsetMotionNotify(BufferView *, int, int, int);
78     ///
79     void InsetKeyPress(XKeyEvent *);
80     ///
81     UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
82     ///
83     int Latex(ostream &, signed char) const;
84     ///
85     int Latex(string &, signed char) const;
86     ///
87     int Linuxdoc(string &) const { return 0; }
88     ///
89     int DocBook(string &) const { return 0; }
90     ///
91     void Validate(LaTeXFeatures & features) const;
92     ///
93     Inset::Code LyxCode() const { return Inset::TEXT_CODE; }
94     ///
95     void GetCursorPos(int & x, int & y) const;
96     ///
97     int InsetInInsetY();
98     ///
99     void ToggleInsetCursor(BufferView *);
100     ///
101     bool InsertInset(BufferView *, Inset *);
102     ///
103     UpdatableInset * GetLockingInset();
104     ///
105     void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
106
107     LyXParagraph * par;
108
109 protected:
110     ///
111     void WriteParagraphData(ostream &) const;
112     ///
113     void resetPos(BufferView *);
114     ///
115     void drawSelection(Painter &, int pos, int baseline, float x);
116     ///
117     void SingleHeight(Painter &, LyXParagraph * par,int pos,
118                       int & asc, int & desc) const;
119     ///
120     int SingleWidth(Painter &, LyXParagraph * par, int pos) const;
121     ///
122     LyXFont GetFont(LyXParagraph * par, int pos) const;
123     ///
124     Buffer * buffer;
125     ///
126     LyXFont current_font;
127     ///
128     LyXFont real_current_font;
129     ///
130     int maxWidth;
131     ///
132     mutable int maxAscent;
133     ///
134     mutable int maxDescent;
135     ///
136     mutable int insetWidth;
137
138 private:
139     ///
140     void drawRowSelection(Painter &, int startpos, int endpos, int row,
141                           int baseline, float x) const;
142     ///
143     void drawRowText(Painter &, int startpos, int endpos, int baseline,
144                      float x) const;
145     ///
146     void computeTextRows(Painter &) const;
147     ///
148     void computeBaselines(int) const;
149     ///
150     int BeginningOfMainBody(LyXParagraph * par) const;
151     ///
152     void ShowInsetCursor(BufferView *);
153     ///
154     void HideInsetCursor(BufferView *);
155     ///
156     void setPos(BufferView *, int x, int y, bool activate_inset = true);
157     ///
158     bool moveRight(BufferView *, bool activate_inset = true);
159     bool moveLeft(BufferView *, bool activate_inset = true);
160     bool moveUp(BufferView *, bool activate_inset = true);
161     bool moveDown(BufferView *, bool activate_inset = true);
162     bool Delete();
163     ///
164     bool hasSelection() const { return selection_start != selection_end; }
165     ///
166     void SetCharFont(int pos, LyXFont const & font);
167     ///
168     string getText(int);
169         
170     /* Private structures and variables */
171     ///
172     int inset_pos;
173     ///
174     int inset_x;
175     ///
176     int inset_y;
177     ///
178     int interline_space;
179     ///
180     int selection_start;
181     ///
182     int selection_end;
183     ///
184     int old_x;
185     ///
186     int cx;
187     ///
188     int cy;
189     ///
190     int actpos;
191     ///
192     int actrow;
193     ///
194     bool no_selection;
195     ///
196     mutable bool init_inset;
197     ///
198     UpdatableInset * the_locking_inset;
199     ///
200     struct row_struct {
201         ///
202         int asc;
203         ///
204         int desc;
205         ///
206         int pos;
207         ///
208         int baseline;
209     };
210     ///
211     typedef vector<row_struct> RowList;
212     ///
213     mutable RowList rows;
214     InsetText & operator = (InsetText const & it) {
215         par = it.par;
216         buffer = it.buffer; // suspect
217         current_font = it.current_font;
218         real_current_font = it.real_current_font;
219         maxWidth = it.maxWidth;
220         maxAscent = it.maxAscent;
221         maxDescent = it.maxDescent;
222         insetWidth = it.insetWidth;
223         inset_pos = it.inset_pos;
224         inset_x = it.inset_x;
225         inset_y = it.inset_y;
226         interline_space = it.interline_space;
227         selection_start = it.selection_start;
228         selection_end = it.selection_end;
229         old_x = it.old_x;
230         cx = it.cx;
231         cy = it.cy;
232         actpos = it.actpos;
233         actrow = it.actrow;
234         no_selection = it.no_selection;
235         the_locking_inset = it.the_locking_inset; // suspect
236         rows = it.rows;
237         return * this;
238     }
239 };
240 #endif