]> git.lyx.org Git - lyx.git/blob - src/insets/insetcommand.h
reformatting and remove using delc
[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 #include <sigc++/signal_system.h>
21 #include <boost/utility.hpp>
22
23 // Created by Alejandro 970222
24 /** Used to insert a LaTeX command automatically
25  *
26  * Similar to InsetLaTeX but having control of the basic structure of a
27  *   LaTeX command: \name[options]{contents}. 
28  */
29 class InsetCommandParams {
30 public:
31         ///
32         InsetCommandParams();
33         ///
34         explicit
35         InsetCommandParams( string const & n,
36                             string const & c = string(),
37                             string const & o = string());
38         ///
39         bool operator==(InsetCommandParams const &) const;
40         ///
41         bool operator!=(InsetCommandParams const &) const;
42         ///
43         void Read(LyXLex &);
44         /// Parse the command
45         void scanCommand(string const &);
46         ///
47         void Write(std::ostream &) const;
48         /// Build the complete LaTeX command
49         string const getCommand() const;
50         ///
51         string const & getCmdName() const { return cmdname; }
52         ///
53         string const & getOptions() const { return options; }
54         ///
55         string const & getContents() const { return contents; }
56         ///
57         void setCmdName( string const & n) { cmdname = n; }
58         ///
59         void setOptions(string const & o) { options = o; }
60         ///
61         void setContents(string const & c) { contents = c; }
62         ///
63         string const getAsString() const;
64         ///
65         void setFromString( string const & );
66 private:
67         ///    
68         string cmdname;
69         ///    
70         string contents;
71         ///    
72         string options;
73 };
74
75
76 ///
77 class InsetCommand : public InsetButton, public boost::noncopyable {
78 public:
79         ///
80         explicit
81         InsetCommand(InsetCommandParams const &);
82         ///
83         virtual ~InsetCommand() { hideDialog(); }
84         ///
85         void Write(Buffer const *, std::ostream & os) const
86                 { p_.Write( os ); }
87         ///
88         virtual void Read(Buffer const *, LyXLex & lex)
89                 { p_.Read( lex ); }
90         /// Can remove one InsetBibKey is modified
91         void scanCommand(string const & c) { p_.scanCommand( c ); };
92         /// 
93         virtual int Latex(Buffer const *, std::ostream &,
94                           bool fragile, bool free_spc) const;
95         ///
96         int Ascii(Buffer const *, std::ostream &, int linelen) const;
97         ///
98         virtual int Linuxdoc(Buffer const *, std::ostream &) const;
99         ///
100         virtual int DocBook(Buffer const *, std::ostream &) const;
101         ///
102         Inset::Code LyxCode() const { return Inset::NO_CODE; }
103         
104         /** Get the label that appears at screen.
105           
106          I thought it was enough to eliminate the argument to avoid
107          confusion with lyxinset::getLabel(int), but I've seen that
108          it wasn't. I hope you never confuse again both methods.  (ale)
109          */
110         virtual string const getScreenLabel() const = 0;
111         ///
112         string const getCommand() const { return p_.getCommand(); }
113         ///
114         string const & getCmdName() const { return p_.getCmdName(); }
115         ///
116         string const & getOptions() const { return p_.getOptions(); }
117         ///
118         string const & getContents() const { return p_.getContents(); }
119         ///
120         void setCmdName(string const & n) { p_.setCmdName(n); }
121         ///
122         void setOptions(string const & o) { p_.setOptions(o); }
123         ///
124         void setContents(string const & c) { p_.setContents(c); }
125         ///
126         InsetCommandParams const & params() const { return p_; }
127         ///
128         void setParams(InsetCommandParams const &);
129         ///
130         SigC::Signal0<void> hideDialog;
131 private:
132         ///
133         InsetCommandParams p_;
134 };
135
136 #endif