]> git.lyx.org Git - lyx.git/blob - src/insets/insettext.h
insetcharstyle drawing cosmetics
[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 "updatableinset.h"
16 #include "RowList_fwd.h"
17 #include "lyxfont.h"
18 #include "lyxtext.h"
19
20 #include "support/types.h"
21
22 #include "frontends/mouse_state.h"
23
24 class Buffer;
25 class BufferParams;
26 class BufferView;
27 class Dimension;
28 class LColor_color;
29 class CursorSlice;
30 class Painter;
31 class ParagraphList;
32 class Row;
33
34
35 /**
36  A text inset is like a TeX box to write full text
37  (including styles and other insets) in a given space.
38  */
39 class InsetText : public UpdatableInset {
40 public:
41         ///
42         explicit InsetText(BufferParams const &);
43         ///
44         explicit InsetText();
45         ///
46         InsetText(InsetText const &);
47         ///
48         virtual std::auto_ptr<InsetBase> clone() const;
49         ///
50         void operator=(InsetText const & it);
51         /// empty inset to empty par, or just mark as erased
52         void clear(bool just_mark_erased);
53         ///
54         void read(Buffer const & buf, LyXLex & lex);
55         ///
56         void write(Buffer const & buf, std::ostream & os) const;
57         ///
58         void metrics(MetricsInfo & mi, Dimension & dim) const;
59         ///
60         void draw(PainterInfo & pi, int x, int y) const;
61         /// draw inset selection
62         void drawSelection(PainterInfo & pi, int x, int y) const;
63         ///
64         std::string const editMessage() const;
65         ///
66         bool isTextInset() const { return true; }
67         ///
68         int latex(Buffer const &, std::ostream &,
69                   OutputParams const &) const;
70         ///
71         int plaintext(Buffer const &, std::ostream &,
72                   OutputParams const &) const;
73         ///
74         int linuxdoc(Buffer const &, std::ostream &,
75                      OutputParams const &) const;
76         ///
77         int docbook(Buffer const &, std::ostream &,
78                     OutputParams const &) const;
79         ///
80         void validate(LaTeXFeatures & features) const;
81         ///
82         InsetOld::Code lyxCode() const { return InsetOld::TEXT_CODE; }
83         /// FIXME, document
84         void getCursorPos(LCursor const & cur, int & x, int & y) const;
85         ///
86         void setFont(BufferView *, LyXFont const &,
87                      bool toggleall = false,
88                      bool selectall = false);
89         ///
90         void setText(std::string const &, LyXFont const &);
91         ///
92         void setAutoBreakRows(bool);
93         ///
94         bool getAutoBreakRows() const { return autoBreakRows_; }
95         ///
96         void setDrawFrame(bool);
97         ///
98         LColor_color frameColor() const;
99         ///
100         void setFrameColor(LColor_color);
101         ///
102         void setViewCache(BufferView const * bv) const;
103         ///
104         bool showInsetDialog(BufferView *) const;
105         /// Appends \c list with all labels found within this inset.
106         void getLabelList(Buffer const &, std::vector<std::string> & list) const;
107         ///
108         LyXText * getText(int) const;
109         ///
110         bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
111
112         /// mark as erased for change tracking
113         void markErased() { clear(true); }
114         /**
115          * Mark as new. Used when pasting in tabular, and adding rows
116          * or columns. Note that pasting will ensure that tracking already
117          * happens, and this just resets the changes for the copied text,
118          * whereas for row/col add, we need to start tracking changes
119          * for the (empty) paragraph contained.
120          */
121         void markNew(bool track_changes = false);
122
123         /// append text onto the existing text
124         void appendParagraphs(Buffer * bp, ParagraphList &);
125
126         ///
127         void addPreview(lyx::graphics::PreviewLoader &) const;
128
129         ///
130         void edit(LCursor & cur, bool left);
131         ///
132         InsetBase * editXY(LCursor & cur, int x, int y) const;
133
134         /// number of cells in this inset
135         size_t nargs() const { return 1; }
136         ///
137         ParagraphList & paragraphs();
138         ///
139         ParagraphList const & paragraphs() const;
140         ///
141         bool insetAllowed(Code) const { return true; }
142         ///
143         bool allowSpellCheck() const { return true; }
144
145 protected:
146         ///
147         void priv_dispatch(LCursor & cur, FuncRequest & cmd);
148 private:
149         ///
150         void updateLocal(LCursor &);
151         ///
152         void init();
153         ///
154         void setCharFont(Buffer const &, int pos, LyXFont const & font);
155         ///
156         void removeNewlines();
157         ///
158         void drawFrame(Painter &, int x, int y) const;
159         ///
160         void clearInset(Painter &, int x, int y) const;
161
162         ///
163         bool autoBreakRows_;
164         ///
165         bool drawFrame_;
166         /** We store the LColor::color value as an int to get LColor.h out
167          *  of the header file.
168          */
169         int frame_color_;
170         ///
171         mutable lyx::par_type old_par;
172 public:
173         ///
174         mutable LyXText text_;
175         ///
176         mutable LyXFont font_;
177 };
178 #endif