2 * \file ControlTabular.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "ControlTabular.h"
14 #include "funcrequest.h"
16 #include "insets/insettabular.h"
17 #include "support/LAssert.h"
19 using namespace lyx::support;
22 ControlTabular::ControlTabular(Dialog & parent)
23 : Dialog::Controller(parent), active_cell_(-1)
27 bool ControlTabular::initialiseParams(string const & data)
29 Buffer * buffer = kernel().buffer();
33 InsetTabular tmp(*buffer);
34 int cell = InsetTabularMailer::string2params(data, tmp);
36 params_.reset(new LyXTabular(tmp.tabular));
43 void ControlTabular::clearParams()
50 int ControlTabular::getActiveCell() const
56 LyXTabular const & ControlTabular::tabular() const
58 Assert(params_.get());
59 return *params_.get();
63 void ControlTabular::set(LyXTabular::Feature f, string const & arg)
65 string const data = featureAsString(f) + ' ' + arg;
66 kernel().dispatch(FuncRequest(LFUN_TABULAR_FEATURE, data));
70 bool ControlTabular::useMetricUnits() const
72 return lyxrc.default_papersize > PAPER_EXECUTIVEPAPER;
76 void ControlTabular::toggleTopLine()
78 if (tabular().isMultiColumn(getActiveCell()))
79 set(LyXTabular::M_TOGGLE_LINE_TOP);
81 set(LyXTabular::TOGGLE_LINE_TOP);
85 void ControlTabular::toggleBottomLine()
87 if (tabular().isMultiColumn(getActiveCell()))
88 set(LyXTabular::M_TOGGLE_LINE_BOTTOM);
90 set(LyXTabular::TOGGLE_LINE_BOTTOM);
94 void ControlTabular::toggleLeftLine()
96 if (tabular().isMultiColumn(getActiveCell()))
97 set(LyXTabular::M_TOGGLE_LINE_LEFT);
99 set(LyXTabular::TOGGLE_LINE_LEFT);
103 void ControlTabular::toggleRightLine()
105 if (tabular().isMultiColumn(getActiveCell()))
106 set(LyXTabular::M_TOGGLE_LINE_RIGHT);
108 set(LyXTabular::TOGGLE_LINE_RIGHT);
112 void ControlTabular::setSpecial(string const & special)
114 if (tabular().isMultiColumn(getActiveCell()))
115 set(LyXTabular::SET_SPECIAL_MULTI, special);
117 set(LyXTabular::SET_SPECIAL_COLUMN, special);
121 void ControlTabular::setWidth(string const & width)
123 if (tabular().isMultiColumn(getActiveCell()))
124 set(LyXTabular::SET_MPWIDTH, width);
126 set(LyXTabular::SET_PWIDTH, width);
128 dialog().view().update();
132 void ControlTabular::toggleMultiColumn()
134 set(LyXTabular::MULTICOLUMN);
135 dialog().view().update();
139 void ControlTabular::rotateTabular(bool yes)
142 set(LyXTabular::SET_ROTATE_TABULAR);
144 set(LyXTabular::UNSET_ROTATE_TABULAR);
148 void ControlTabular::rotateCell(bool yes)
151 set(LyXTabular::SET_ROTATE_CELL);
153 set(LyXTabular::UNSET_ROTATE_CELL);
157 void ControlTabular::halign(ControlTabular::HALIGN h)
159 LyXTabular::Feature num = LyXTabular::ALIGN_LEFT;
160 LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
164 num = LyXTabular::ALIGN_LEFT;
165 multi_num = LyXTabular::M_ALIGN_LEFT;
168 num = LyXTabular::ALIGN_CENTER;
169 multi_num = LyXTabular::M_ALIGN_CENTER;
172 num = LyXTabular::ALIGN_RIGHT;
173 multi_num = LyXTabular::M_ALIGN_RIGHT;
176 num = LyXTabular::ALIGN_BLOCK;
177 //multi_num: no equivalent
181 if (tabular().isMultiColumn(getActiveCell()))
188 void ControlTabular::valign(ControlTabular::VALIGN v)
190 LyXTabular::Feature num = LyXTabular::VALIGN_MIDDLE;
191 LyXTabular::Feature multi_num = LyXTabular::M_VALIGN_MIDDLE;
195 num = LyXTabular::VALIGN_TOP;
196 multi_num = LyXTabular::M_VALIGN_TOP;
199 num = LyXTabular::VALIGN_MIDDLE;
200 multi_num = LyXTabular::M_VALIGN_MIDDLE;
203 num = LyXTabular::VALIGN_BOTTOM;
204 multi_num = LyXTabular::M_VALIGN_BOTTOM;
208 if (tabular().isMultiColumn(getActiveCell()))
215 void ControlTabular::longTabular(bool yes)
218 set(LyXTabular::SET_LONGTABULAR);
220 set(LyXTabular::UNSET_LONGTABULAR);