]> git.lyx.org Git - lyx.git/blob - src/insets/insetcommand.h
1657ce931cb6a463f7d5fd0b59d9b4da691b4a01
[lyx.git] / src / insets / insetcommand.h
1 // -*- C++ -*-
2 /* This file is part of*
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *       
7  *          Copyright (C) 1995 Matthias Ettrich
8  *          Copyright (C) 1996-1998 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         ~InsetCommand();
37         ///
38         int Ascent(LyXFont const &font) const;
39         ///
40         int Descent(LyXFont const &font) const;
41         ///
42         int Width(LyXFont const &font) const;
43         ///
44         void Draw(LyXFont, LyXScreen &scr, int baseline, float &x);
45         ///
46         void Write(FILE *file);
47         /// Parse the command.
48         void scanCommand(string const &cmd);
49         /// Will not be used when lyxf3
50         void Read(LyXLex &lex);
51         /// 
52         virtual int Latex(FILE *file, signed char fragile);
53         ///
54         virtual int Latex(string &file, signed char fragile);
55         ///
56         virtual int Linuxdoc(string &file);
57         ///
58         virtual int DocBook(string &file);
59         ///
60         Inset* Clone();
61         ///  
62         Inset::Code LyxCode() const
63         {
64                 return Inset::NO_CODE;
65         }
66         
67         /** Get the label that appears at screen.
68           
69          I thought it was enough to eliminate the argument to avoid
70          confusion with lyxinset::getLabel(int), but I've seen that
71          it wasn't. I hope you never confuse again both methods.  (ale)
72          */
73         virtual string getScreenLabel() const
74         {
75                 return getCommand();
76         }
77         
78         /// Build the complete LaTeX command
79         string getCommand() const;
80         ///
81         string const &getCmdName() const {
82                 return command;
83         }
84         ///
85         string const &getOptions() const {
86                 return options;
87         }
88         ///
89         string const &getContents() const {
90                 return contents;
91         }
92         ///
93         void setCmdName(string const & n) {
94                 command = n;
95         }
96         ///
97         void setOptions(string const & o) {
98                 options = o;
99         }
100         ///
101         virtual void setContents(string const & c) {
102                 contents = c;
103         }
104 protected:
105         ///    
106         string command;
107         ///    
108         string options;
109         ///    
110         string contents;
111 };
112
113 #endif