]> git.lyx.org Git - lyx.git/blob - src/insets/insettext.h
Introduce wide streams. This fixes the remaining problems of plain text
[lyx.git] / src / insets / insettext.h
1 // -*- C++ -*-
2 /**
3  * \file insettext.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jürgen Vigna
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSETTEXT_H
13 #define INSETTEXT_H
14
15 #include "inset.h"
16 #include "RowList_fwd.h"
17 #include "lyxfont.h"
18 #include "lyxtext.h"
19 #include "ParagraphList_fwd.h"
20
21 #include "support/types.h"
22
23 #include "frontends/mouse_state.h"
24
25 class Buffer;
26 class BufferParams;
27 class BufferView;
28 class CursorSlice;
29 class Dimension;
30 class LColor_color;
31
32
33 /**
34  A text inset is like a TeX box to write full text
35  (including styles and other insets) in a given space.
36  */
37 class InsetText : public InsetOld {
38 public:
39         ///
40         explicit InsetText(BufferParams const &);
41         ///
42         InsetText();
43         /// empty inset to empty par
44         void clear();
45         ///
46         void read(Buffer const & buf, LyXLex & lex);
47         ///
48         void write(Buffer const & buf, std::ostream & os) const;
49         ///
50         void metrics(MetricsInfo & mi, Dimension & dim) const;
51         ///
52         void draw(PainterInfo & pi, int x, int y) const;
53         /// draw inset selection
54         void drawSelection(PainterInfo & pi, int x, int y) const;
55         ///
56         virtual lyx::docstring const editMessage() const;
57         ///
58         EDITABLE editable() const { return HIGHLY_EDITABLE; }
59         ///
60         bool canTrackChanges() const { return true; }
61         ///
62         InsetText const * asTextInset() const { return this; }
63         ///
64         int latex(Buffer const &, std::ostream &,
65                   OutputParams const &) const;
66         ///
67         int plaintext(Buffer const &, lyx::odocstream &,
68                   OutputParams const &) const;
69         ///
70         int docbook(Buffer const &, std::ostream &,
71                     OutputParams const &) const;
72         ///
73         void validate(LaTeXFeatures & features) const;
74
75         /// return x,y of given position relative to the inset's baseline
76         void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
77         ///
78         Code lyxCode() const { return TEXT_CODE; }
79         ///
80         void setText(lyx::docstring const &, LyXFont const &);
81         ///
82         void setAutoBreakRows(bool);
83         ///
84         bool getAutoBreakRows() const { return text_.autoBreakRows_; }
85         ///
86         void setDrawFrame(bool);
87         ///
88         LColor_color frameColor() const;
89         ///
90         void setFrameColor(LColor_color);
91         ///
92         void setViewCache(BufferView const * bv) const;
93         ///
94         bool showInsetDialog(BufferView *) const;
95         ///
96         LyXText * getText(int i) const {
97                 return (i == 0) ? const_cast<LyXText*>(&text_) : 0;
98         }
99         ///
100         bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
101
102         /// mark as erased for change tracking
103         void markErased(bool erased);
104
105         /**
106          * Mark as new. Used when pasting in tabular, and adding rows
107          * or columns. Note that pasting will ensure that tracking already
108          * happens, and this just resets the changes for the copied text,
109          * whereas for row/col add, we need to start tracking changes
110          * for the (empty) paragraph contained.
111          */
112         void markNew(bool track_changes = false);
113
114         /// append text onto the existing text
115         void appendParagraphs(Buffer * bp, ParagraphList &);
116
117         ///
118         void addPreview(lyx::graphics::PreviewLoader &) const;
119
120         ///
121         void edit(LCursor & cur, bool left);
122         ///
123         InsetBase * editXY(LCursor & cur, int x, int y);
124
125         /// number of cells in this inset
126         size_t nargs() const { return 1; }
127         ///
128         ParagraphList & paragraphs();
129         ///
130         ParagraphList const & paragraphs() const;
131         ///
132         bool insetAllowed(Code) const { return true; }
133         ///
134         bool allowSpellCheck() const { return true; }
135         /// should paragraph indendation be ommitted in any case?
136         bool neverIndent() const;
137         ///
138         InsetText(InsetText const &);
139         ///
140         bool & Wide() const { return wide_inset_; }
141
142 protected:
143         ///
144         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
145
146 private:
147         ///
148         virtual std::auto_ptr<InsetBase> doClone() const;
149         ///
150         void init();
151
152         ///
153         bool drawFrame_;
154         /** We store the LColor::color value as an int to get LColor.h out
155          *  of the header file.
156          */
157         int frame_color_;
158         ///
159         mutable lyx::pit_type old_pit;
160         ///
161         static int border_;
162         ///
163         mutable bool wide_inset_;
164 public:
165         ///
166         mutable LyXText text_;
167         ///
168         mutable LyXFont font_;
169 };
170 #endif