]> git.lyx.org Git - lyx.git/blob - src/insets/insetcommand.h
fix the smallcaps drawing, move xfont metrics functions out from LyXFont, move non...
[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         ///
36         int ascent(Painter &, LyXFont const &) const;
37         ///
38         int descent(Painter &, LyXFont const &) const;
39         ///
40         int width(Painter &, LyXFont const &) const;
41         ///
42         void draw(Painter &, LyXFont const &, int baseline, float & x) const;
43         ///
44         void Write(std::ostream &) const;
45         /// Parse the command.
46         void scanCommand(string const & cmd);
47         /// Will not be used when lyxf3
48         void Read(LyXLex & lex);
49         /// 
50         virtual int Latex(std::ostream &,
51                           signed char fragile, bool free_spc) const;
52         ///
53         virtual int Linuxdoc(std::ostream &) const;
54         ///
55         virtual int DocBook(std::ostream &) const;
56         ///
57         Inset * Clone() const;
58         ///  
59         Inset::Code LyxCode() const
60         {
61                 return Inset::NO_CODE;
62         }
63         
64         /** Get the label that appears at screen.
65           
66          I thought it was enough to eliminate the argument to avoid
67          confusion with lyxinset::getLabel(int), but I've seen that
68          it wasn't. I hope you never confuse again both methods.  (ale)
69          */
70         virtual string getScreenLabel() const
71         {
72                 return getCommand();
73         }
74         
75         /// Build the complete LaTeX command
76         string getCommand() const;
77         ///
78         string const & getCmdName() const {
79                 return command;
80         }
81         ///
82         string const & getOptions() const {
83                 return options;
84         }
85         ///
86         string const & getContents() const {
87                 return contents;
88         }
89         ///
90         void setCmdName(string const & n) {
91                 command = n;
92         }
93         ///
94         void setOptions(string const & o) {
95                 options = o;
96         }
97         ///
98         virtual void setContents(string const & c) {
99                 contents = c;
100         }
101 protected:
102         ///    
103         string command;
104         ///    
105         string options;
106         ///    
107         string contents;
108 };
109
110 #endif