]> git.lyx.org Git - lyx.git/blob - src/insets/insetcommand.h
Some more changes for updating text-insets.
[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 "insetbutton.h"
20
21 // Created by Alejandro 970222
22 /** Used to insert a LaTeX command automatically
23  *
24  * Similar to InsetLaTeX but having control of the basic structure of a
25  *   LaTeX command: \name[options]{contents}. 
26  */
27 class InsetCommand: public InsetButton {
28 public:
29         ///
30         InsetCommand();
31         ///
32         explicit
33         InsetCommand(string const & name, string const & arg = string(), 
34                      string const & opt = string());
35         ///
36         void Write(Buffer const *, std::ostream &) const;
37
38         /// Parse the command.
39         void scanCommand(string const & cmd);
40         /// Will not be used when lyxf3
41         void Read(Buffer const *, LyXLex & lex);
42         /// 
43         virtual int Latex(Buffer const *, std::ostream &,
44                           bool fragile, bool free_spc) const;
45         ///
46         int Ascii(Buffer const *, std::ostream &) const;
47         ///
48         virtual int Linuxdoc(Buffer const *, std::ostream &) const;
49         ///
50         virtual int DocBook(Buffer const *, std::ostream &) const;
51         ///
52         Inset * Clone() const;
53         ///  
54         Inset::Code LyxCode() const
55         {
56                 return Inset::NO_CODE;
57         }
58         
59         /** Get the label that appears at screen.
60           
61          I thought it was enough to eliminate the argument to avoid
62          confusion with lyxinset::getLabel(int), but I've seen that
63          it wasn't. I hope you never confuse again both methods.  (ale)
64          */
65         virtual string getScreenLabel() const
66         {
67                 return getCommand();
68         }
69
70         /// Build the complete LaTeX command
71         string getCommand() const;
72         ///
73         string const & getCmdName() const {
74                 return cmdname;
75         }
76         ///
77         string const & getOptions() const {
78                 return options;
79         }
80         ///
81         string const & getContents() const {
82                 return contents;
83         }
84         ///
85         void setCmdName(string const & n) {
86                 cmdname = n;
87         }
88         ///
89         void setOptions(string const & o) {
90                 options = o;
91         }
92         ///
93         virtual void setContents(string const & c) {
94                 contents = c;
95         }
96         ///
97         void addContents(string const & c) {
98                 contents += c;
99         }
100 private:
101         ///    
102         string cmdname;
103         ///    
104         string options;
105         ///    
106         string contents;
107 };
108
109 #endif