]> git.lyx.org Git - lyx.git/blob - src/insets/insetcommand.h
use more explicit on constructors use the pimpl idom to reduce size with about 500k
[lyx.git] / src / insets / insetcommand.h
1 // -*- C++ -*-
2 /* This file is part of*
3  * ====================================================== 
4  *
5  *           LyX, The Document Processor
6  *       
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2000 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef INSET_LATEXCOMMAND_H
13 #define INSET_LATEXCOMMAND_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "lyxinset.h"
20 #include "LString.h"
21
22 // Created by Alejandro 970222
23 /** Used to insert a LaTeX command automatically
24  *
25  * Similar to InsetLaTeX but having control of the basic structure of a
26  *   LaTeX command: \name[options]{contents}. 
27  */
28 class InsetCommand: public Inset {
29 public:
30         ///
31         InsetCommand();
32         ///
33         explicit
34         InsetCommand(string const & name, string const & arg = string(), 
35                      string const & opt = string());
36         ///
37         int ascent(Painter &, LyXFont const &) const;
38         ///
39         int descent(Painter &, LyXFont const &) const;
40         ///
41         int width(Painter &, LyXFont const &) const;
42         ///
43         void draw(Painter &, LyXFont const &, int baseline, float & x) const;
44         ///
45         void Write(std::ostream &) const;
46         /// Parse the command.
47         void scanCommand(string const & cmd);
48         /// Will not be used when lyxf3
49         void Read(LyXLex & lex);
50         /// 
51         virtual int Latex(std::ostream &,
52                           signed char fragile, bool free_spc) const;
53         ///
54         virtual int Linuxdoc(std::ostream &) const;
55         ///
56         virtual int DocBook(std::ostream &) const;
57         ///
58         Inset * Clone() const;
59         ///  
60         Inset::Code LyxCode() const
61         {
62                 return Inset::NO_CODE;
63         }
64         
65         /** Get the label that appears at screen.
66           
67          I thought it was enough to eliminate the argument to avoid
68          confusion with lyxinset::getLabel(int), but I've seen that
69          it wasn't. I hope you never confuse again both methods.  (ale)
70          */
71         virtual string getScreenLabel() const
72         {
73                 return getCommand();
74         }
75         
76         /// Build the complete LaTeX command
77         string getCommand() const;
78         ///
79         string const & getCmdName() const {
80                 return command;
81         }
82         ///
83         string const & getOptions() const {
84                 return options;
85         }
86         ///
87         string const & getContents() const {
88                 return contents;
89         }
90         ///
91         void setCmdName(string const & n) {
92                 command = n;
93         }
94         ///
95         void setOptions(string const & o) {
96                 options = o;
97         }
98         ///
99         virtual void setContents(string const & c) {
100                 contents = c;
101         }
102 protected:
103         ///    
104         string command;
105         ///    
106         string options;
107         ///    
108         string contents;
109 };
110
111 #endif