]> git.lyx.org Git - lyx.git/blob - src/insets/insetcommand.h
new painter,workarea and lcolor. Read the diff/sources and ChangeLog...
[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         InsetCommand(string const & name, string const & arg = string(), 
34                      string const & opt = string());
35 #ifdef USE_PAINTER
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 #else
45         ///
46         int Ascent(LyXFont const & font) const;
47         ///
48         int Descent(LyXFont const & font) const;
49         ///
50         int Width(LyXFont const & font) const;
51         ///
52         void Draw(LyXFont, LyXScreen & scr, int baseline, float & x);
53 #endif
54         ///
55         void Write(ostream &);
56         /// Parse the command.
57         void scanCommand(string const & cmd);
58         /// Will not be used when lyxf3
59         void Read(LyXLex & lex);
60         /// 
61         virtual int Latex(ostream &, signed char fragile);
62         ///
63         virtual int Latex(string & file, signed char fragile);
64         ///
65         virtual int Linuxdoc(string & file);
66         ///
67         virtual int DocBook(string & file);
68         ///
69         Inset * Clone() const;
70         ///  
71         Inset::Code LyxCode() const
72         {
73                 return Inset::NO_CODE;
74         }
75         
76         /** Get the label that appears at screen.
77           
78          I thought it was enough to eliminate the argument to avoid
79          confusion with lyxinset::getLabel(int), but I've seen that
80          it wasn't. I hope you never confuse again both methods.  (ale)
81          */
82         virtual string getScreenLabel() const
83         {
84                 return getCommand();
85         }
86         
87         /// Build the complete LaTeX command
88         string getCommand() const;
89         ///
90         string const & getCmdName() const {
91                 return command;
92         }
93         ///
94         string const & getOptions() const {
95                 return options;
96         }
97         ///
98         string const & getContents() const {
99                 return contents;
100         }
101         ///
102         void setCmdName(string const & n) {
103                 command = n;
104         }
105         ///
106         void setOptions(string const & o) {
107                 options = o;
108         }
109         ///
110         virtual void setContents(string const & c) {
111                 contents = c;
112         }
113 protected:
114         ///    
115         string command;
116         ///    
117         string options;
118         ///    
119         string contents;
120 };
121
122 #endif