3 * \file ControlTabular.C
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS
14 #include "ControlTabular.h"
15 #include "funcrequest.h"
17 #include "insets/insettabular.h"
18 #include "support/LAssert.h"
21 ControlTabular::ControlTabular(Dialog & parent)
22 : Dialog::Controller(parent), active_cell_(-1)
26 bool ControlTabular::initialiseParams(string const & data)
28 Buffer * buffer = kernel().buffer();
32 InsetTabular tmp(*buffer);
33 int cell = InsetTabularMailer::string2params(data, tmp);
35 params_.reset(new LyXTabular(tmp.tabular));
42 void ControlTabular::clearParams()
49 int ControlTabular::getActiveCell() const
55 LyXTabular const & ControlTabular::tabular() const
57 lyx::Assert(params_.get());
58 return *params_.get();
62 void ControlTabular::set(LyXTabular::Feature f, string const & arg)
64 string const data = featureAsString(f) + ' ' + arg;
65 kernel().dispatch(FuncRequest(LFUN_TABULAR_FEATURE, data));
69 bool ControlTabular::useMetricUnits() const
71 return lyxrc.default_papersize > BufferParams::PAPER_EXECUTIVEPAPER;
75 void ControlTabular::toggleTopLine()
77 if (tabular().isMultiColumn(getActiveCell()))
78 set(LyXTabular::M_TOGGLE_LINE_TOP);
80 set(LyXTabular::TOGGLE_LINE_TOP);
84 void ControlTabular::toggleBottomLine()
86 if (tabular().isMultiColumn(getActiveCell()))
87 set(LyXTabular::M_TOGGLE_LINE_BOTTOM);
89 set(LyXTabular::TOGGLE_LINE_BOTTOM);
93 void ControlTabular::toggleLeftLine()
95 if (tabular().isMultiColumn(getActiveCell()))
96 set(LyXTabular::M_TOGGLE_LINE_LEFT);
98 set(LyXTabular::TOGGLE_LINE_LEFT);
102 void ControlTabular::toggleRightLine()
104 if (tabular().isMultiColumn(getActiveCell()))
105 set(LyXTabular::M_TOGGLE_LINE_RIGHT);
107 set(LyXTabular::TOGGLE_LINE_RIGHT);
111 void ControlTabular::setSpecial(string const & special)
113 if (tabular().isMultiColumn(getActiveCell()))
114 set(LyXTabular::SET_SPECIAL_MULTI, special);
116 set(LyXTabular::SET_SPECIAL_COLUMN, special);
120 void ControlTabular::setWidth(string const & width)
122 if (tabular().isMultiColumn(getActiveCell()))
123 set(LyXTabular::SET_MPWIDTH, width);
125 set(LyXTabular::SET_PWIDTH, width);
127 dialog().view().update();
131 void ControlTabular::toggleMultiColumn()
133 set(LyXTabular::MULTICOLUMN);
134 dialog().view().update();
138 void ControlTabular::rotateTabular(bool yes)
141 set(LyXTabular::SET_ROTATE_TABULAR);
143 set(LyXTabular::UNSET_ROTATE_TABULAR);
147 void ControlTabular::rotateCell(bool yes)
150 set(LyXTabular::SET_ROTATE_CELL);
152 set(LyXTabular::UNSET_ROTATE_CELL);
156 void ControlTabular::halign(ControlTabular::HALIGN h)
158 LyXTabular::Feature num = LyXTabular::ALIGN_LEFT;
159 LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
163 num = LyXTabular::ALIGN_LEFT;
164 multi_num = LyXTabular::M_ALIGN_LEFT;
167 num = LyXTabular::ALIGN_CENTER;
168 multi_num = LyXTabular::M_ALIGN_CENTER;
171 num = LyXTabular::ALIGN_RIGHT;
172 multi_num = LyXTabular::M_ALIGN_RIGHT;
175 num = LyXTabular::ALIGN_BLOCK;
176 //multi_num: no equivalent
180 if (tabular().isMultiColumn(getActiveCell()))
187 void ControlTabular::valign(ControlTabular::VALIGN v)
189 LyXTabular::Feature num = LyXTabular::VALIGN_CENTER;
190 LyXTabular::Feature multi_num = LyXTabular::M_VALIGN_CENTER;
194 num = LyXTabular::VALIGN_TOP;
195 multi_num = LyXTabular::M_VALIGN_TOP;
198 num = LyXTabular::VALIGN_CENTER;
199 multi_num = LyXTabular::M_VALIGN_CENTER;
202 num = LyXTabular::VALIGN_BOTTOM;
203 multi_num = LyXTabular::M_VALIGN_BOTTOM;
207 if (tabular().isMultiColumn(getActiveCell()))
214 void ControlTabular::longTabular(bool yes)
217 set(LyXTabular::SET_LONGTABULAR);
219 set(LyXTabular::UNSET_LONGTABULAR);