]> git.lyx.org Git - lyx.git/blob - src/insets/InsetCharStyle.h
Streamlining CollapseStatus stuff
[lyx.git] / src / insets / InsetCharStyle.h
1 // -*- C++ -*-
2 /**
3  * \file InsetCharStyle.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  * \author Martin Vermeer
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef INSETCHARSTYLE_H
14 #define INSETCHARSTYLE_H
15
16 #include "InsetCollapsable.h"
17 #include "TextClass.h"
18
19
20 namespace lyx {
21
22
23 class InsetCharStyleParams {
24 public:
25         ///
26         void write(std::ostream & os) const;
27         ///
28         void read(Lexer & lex);
29         ///
30         std::string type;
31         ///
32         std::string latextype;
33         ///
34         std::string latexname;
35         ///
36         std::string latexparam;
37         ///
38         Font font;
39         ///
40         Font labelfont;
41         ///
42         bool show_label;
43 };
44
45
46 /** The CharStyle inset, also XML short element
47
48 */
49 class InsetCharStyle : public InsetCollapsable {
50 public:
51         /// Construct an undefined character style
52         InsetCharStyle(BufferParams const &, std::string const);
53         ///
54         InsetCharStyle(BufferParams const &, CharStyles::iterator);
55         ///
56         docstring name() const { return from_ascii("CharStyle"); }
57         /// Is this character style defined in the document's textclass?
58         /// May be wrong after textclass change or paste from another document
59         bool undefined() const;
60         /// Set the character style to "undefined"
61         void setUndefined();
62         /// (Re-)set the character style parameters from \p cs
63         void setDefined(CharStyles::iterator cs);
64         ///
65         virtual docstring const editMessage() const;
66         ///
67         Inset::Code lyxCode() const { return Inset::CHARSTYLE_CODE; }
68         ///
69         void write(Buffer const &, std::ostream &) const;
70         ///
71         void read(Buffer const & buf, Lexer & lex);
72         ///
73         bool metrics(MetricsInfo &, Dimension &) const;
74         ///
75         void draw(PainterInfo &, int, int) const;
76         ///
77         void getDrawFont(Font &) const;
78         ///
79         bool forceDefaultParagraphs(idx_type) const { return true; }
80         ///
81         virtual Decoration decoration() const { return Conglomerate; }
82
83         ///
84         int latex(Buffer const &, odocstream &,
85                   OutputParams const &) const;
86         ///
87         int plaintext(Buffer const &, odocstream &,
88                       OutputParams const &) const;
89         ///
90         int docbook(Buffer const &, odocstream &,
91                     OutputParams const &) const;
92         /// the string that is passed to the TOC
93         virtual void textString(Buffer const &, odocstream &) const;
94         ///
95         void validate(LaTeXFeatures &) const;
96
97         ///
98         InsetCharStyleParams const & params() const { return params_; }
99
100         /// should paragraph indendation be ommitted in any case?
101         bool neverIndent(Buffer const &) const { return true; }
102
103 protected:
104         InsetCharStyle(InsetCharStyle const &);
105         virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
106         ///
107         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
108
109 private:
110         friend class InsetCharStyleParams;
111
112         virtual std::auto_ptr<Inset> doClone() const;
113
114         /// used by the constructors
115         void init();
116         ///
117         InsetCharStyleParams params_;
118 };
119
120
121 } // namespace lyx
122
123 #endif