]> git.lyx.org Git - lyx.git/blob - src/mathed/command_inset.C
Changes due to the removal of using directives from support/std_sstream.h.
[lyx.git] / src / mathed / command_inset.C
1 /**
2  * \file command_inset.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "command_inset.h"
14 #include "math_mathmlstream.h"
15 #include "funcrequest.h"
16 #include "support/std_sstream.h"
17
18 using std::auto_ptr;
19 using std::ostringstream;
20
21
22 CommandInset::CommandInset(string const & name)
23         : MathNestInset(2),
24           name_(name),
25           set_label_(false)
26 {
27         lock_ = true;
28 }
29
30
31 auto_ptr<InsetBase> CommandInset::clone() const
32 {
33         return auto_ptr<InsetBase>(new CommandInset(*this));
34 }
35
36
37 void CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const
38 {
39         if (!set_label_) {
40                 set_label_ = true;
41                 button_.update(screenLabel(), true);
42         }
43         button_.metrics(mi, dim);
44 }
45
46
47 void CommandInset::draw(PainterInfo & pi, int x, int y) const
48 {
49         button_.draw(pi, x, y);
50 }
51
52 dispatch_result
53 CommandInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
54 {
55         switch (cmd.action) {
56                 default:
57                         return MathNestInset::dispatch(cmd, idx, pos);
58         }
59         return UNDISPATCHED;
60 }
61
62
63 void CommandInset::write(WriteStream & os) const
64 {
65         os << '\\' << name_.c_str();
66         if (cell(1).size())
67                 os << '[' << cell(1) << ']';
68         os << '{' << cell(0) << '}';
69 }
70
71
72 string const CommandInset::screenLabel() const
73 {
74        return name_;
75 }
76
77
78 string const CommandInset::createDialogStr(string const & name) const
79 {
80         ostringstream data;
81         data << name << " LatexCommand ";
82         WriteStream wsdata(data);
83         write(wsdata);
84         wsdata << "\n\\end_inset\n\n";
85         return STRCONV(data.str());
86 }