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 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
22 #include "ControlTabular.h"
26 #include "controllers/helper_funcs.h"
37 GTabular::GTabular(Dialog & parent)
38 : GViewCB<ControlTabular, GViewGladeB>(parent, _("Table Settings"), false)
42 void GTabular::doBuild()
44 string const gladeName = findGladeFile("tabular");
45 xml_ = Gnome::Glade::Xml::create(gladeName);
48 xml_->get_widget("Close", button);
51 // **** Current cell coords ****
52 xml_->get_widget("CurrentRow", cellrowspin_);
53 xml_->get_widget("CurrentColumn", cellcolspin_);
55 // **** Table tab ****
57 xml_->get_widget("HorizontalAlignment", box);
58 horzaligncombo_ = Gtk::manage (new Gtk::ComboBoxText);
59 box->add(*horzaligncombo_);
61 xml_->get_widget("VerticalAlignment", vertaligncombo_);
62 xml_->get_widget("SpecifyWidth", specifywidthcheck_);
63 specifywidthcheck_->signal_toggled().connect(
64 sigc::mem_fun(*this, >abular::updateSensitivity));
66 xml_->get_widget_derived ("Width", widthlength_);
67 xml_->get_widget("LaTeXArgument", latexargsentry_);
68 xml_->get_widget("RotateTable", rotatetablecheck_);
70 // **** This Cell tab ****
71 xml_->get_widget("UpperBorder", upperbordercheck_);
72 xml_->get_widget("LowerBorder", lowerbordercheck_);
73 xml_->get_widget("LeftBorder", leftbordercheck_);
74 xml_->get_widget("RightBorder", rightbordercheck_);
75 xml_->get_widget("RotateCell", rotatecellcheck_);
76 xml_->get_widget("MultiColumn", multicolcheck_);
77 multicolcheck_->signal_toggled().connect(
78 sigc::mem_fun(*this, >abular::updateSensitivity));
79 xml_->get_widget("NoBorders", button);
80 button->signal_clicked().connect(
81 sigc::bind(sigc::mem_fun(*this, >abular::allBorders), false));
82 xml_->get_widget("AllBorders", button);
83 button->signal_clicked().connect(
84 sigc::bind(sigc::mem_fun(*this, >abular::allBorders), true));
86 // **** Longtable tab ****
87 xml_->get_widget("LongTable", longtablecheck_);
89 longtablecheck_->signal_toggled().connect(
90 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
92 xml_->get_widget("PageBreak", pagebreakcheck_);
94 xml_->get_widget("SpecialRows", specialrowstable_);
96 xml_->get_widget("HeaderOn",headeroncheck_);
97 xml_->get_widget("FooterOn",footeroncheck_);
98 xml_->get_widget("FirstHeaderOn",firstheaderoncheck_);
99 xml_->get_widget("LastFooterOn",lastfooteroncheck_);
100 xml_->get_widget("FirstHeaderEmpty",firstheaderemptycheck_);
101 xml_->get_widget("LastFooterEmpty",lastfooteremptycheck_);
102 xml_->get_widget("HeaderUpperBorderDouble",headerupperborderdoublecheck_);
103 xml_->get_widget("FooterUpperBorderDouble",footerupperborderdoublecheck_);
104 xml_->get_widget("FirstHeaderUpperBorderDouble",firstheaderupperborderdoublecheck_);
105 xml_->get_widget("LastFooterUpperBorderDouble",lastfooterupperborderdoublecheck_);
106 xml_->get_widget("HeaderLowerBorderDouble",headerlowerborderdoublecheck_);
107 xml_->get_widget("FooterLowerBorderDouble",footerlowerborderdoublecheck_);
108 xml_->get_widget("FirstHeaderLowerBorderDouble",firstheaderlowerborderdoublecheck_);
109 xml_->get_widget("LastFooterLowerBorderDouble",lastfooterlowerborderdoublecheck_);
111 headeroncheck_->signal_toggled().connect(
112 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
113 footeroncheck_->signal_toggled().connect(
114 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
115 firstheaderoncheck_->signal_toggled().connect(
116 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
117 lastfooteroncheck_->signal_toggled().connect(
118 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
119 firstheaderemptycheck_->signal_toggled().connect(
120 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
121 lastfooteremptycheck_->signal_toggled().connect(
122 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
123 headerupperborderdoublecheck_->signal_toggled().connect(
124 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
125 footerupperborderdoublecheck_->signal_toggled().connect(
126 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
127 firstheaderupperborderdoublecheck_->signal_toggled().connect(
128 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
129 lastfooterupperborderdoublecheck_->signal_toggled().connect(
130 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
131 headerlowerborderdoublecheck_->signal_toggled().connect(
132 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
133 footerlowerborderdoublecheck_->signal_toggled().connect(
134 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
135 firstheaderlowerborderdoublecheck_->signal_toggled().connect(
136 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
137 lastfooterlowerborderdoublecheck_->signal_toggled().connect(
138 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
143 firstheaderemptycheck_;
144 lastfooteremptycheck_;
145 headerupperborderdoublecheck_;
146 footerupperborderdoublecheck_;
147 firstheaderupperborderdoublecheck_;
148 lastfooterupperborderdoublecheck_;
149 headerlowerborderdoublecheck_;
150 footerlowerborderdoublecheck_;
151 firstheaderlowerborderdoublecheck_;
152 lastfooterlowerborderdoublecheck_;*/
154 // Disable for read-only documents.
155 // bcview().addReadOnly(browsebutton_);
160 void GTabular::apply()
166 void GTabular::update()
170 LyXTabular const & tabular = controller().tabular();
171 LyXTabular::idx_type const cell = controller().getActiveCell();
172 bool const multicol = tabular.isMultiColumn(cell);
174 cellcolspin_->get_adjustment()->set_value(tabular.column_of_cell (cell)+1);
175 cellrowspin_->get_adjustment()->set_value(tabular.row_of_cell (cell));
177 // **** Table tab ****
183 special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
184 pwidth = tabular.getMColumnPWidth(cell);
186 special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
187 pwidth = tabular.getColumnPWidth(cell);
190 updateHorzAlignCombo(!multicol && !pwidth.zero());
192 int halign = tabular.getAlignment(cell);
193 if (halign == LYX_ALIGN_RIGHT)
194 horzaligncombo_->set_active(2);
195 else if (halign == LYX_ALIGN_CENTER)
196 horzaligncombo_->set_active(1);
197 else if (halign == LYX_ALIGN_BLOCK)
198 horzaligncombo_->set_active(3);
200 horzaligncombo_->set_active(0);
202 int valign = tabular.getVAlignment(cell);
203 if (valign == LyXTabular::LYX_VALIGN_BOTTOM)
204 vertaligncombo_->set_active(2);
205 else if (valign == LyXTabular::LYX_VALIGN_MIDDLE)
206 vertaligncombo_->set_active(1);
208 vertaligncombo_->set_active(0);
210 latexargsentry_->set_text(special);
211 specifywidthcheck_->set_active(!pwidth.zero());
212 widthlength_->set_length(pwidth);
213 rotatetablecheck_->set_active(tabular.getRotateTabular());
215 // **** This Cell tab ****
216 multicolcheck_->set_active(multicol);
217 rotatecellcheck_->set_active(tabular.getRotateCell(cell));
219 upperbordercheck_->set_active(tabular.topLine(cell));
220 lowerbordercheck_->set_active(tabular.bottomLine(cell));
221 leftbordercheck_->set_active(tabular.leftLine(cell));
222 rightbordercheck_->set_active(tabular.rightLine(cell));
224 // **** Long-table tab ****
225 LyXTabular::row_type const row(tabular.row_of_cell(cell));
226 bool const longtable = tabular.isLongTabular();
227 longtablecheck_->set_active(longtable);
228 pagebreakcheck_->set_active(tabular.getLTNewPage(row));
231 LyXTabular::ltType ltt;
233 bool row_set = tabular.getRowOfLTHead(row, ltt);
235 headeroncheck_->set_active(row_set);
236 lyxerr << "row_set for header = " << row_set << "\n";
238 headerupperborderdoublecheck_->set_active(ltt.topDL);
239 headerlowerborderdoublecheck_->set_active(ltt.bottomDL);
242 headerupperborderdoublecheck_->set_active(false);
243 headerlowerborderdoublecheck_->set_active(false);
244 /*headerupperborderdoublecheck_->set_sensitive(false);
245 headerlowerborderdoublecheck_->set_sensitive(false);*/
246 firstheaderemptycheck_->set_active(false);
247 /*firstheaderemptycheck_->set_sensitive(false);*/
251 row_set = tabular.getRowOfLTFirstHead(row, ltt);
252 firstheaderoncheck_->set_active(row_set);
253 if (ltt.set && (!ltt.empty || !use_empty)) {
254 firstheaderupperborderdoublecheck_->set_active(ltt.topDL);
255 firstheaderlowerborderdoublecheck_->set_active(ltt.bottomDL);
257 firstheaderupperborderdoublecheck_->set_active(false);
258 firstheaderlowerborderdoublecheck_->set_active(false);
259 /*firstheaderupperborderdoublecheck_->set_sensitive(false);
260 firstheaderlowerborderdoublecheck_->set_sensitive(false);*/
262 firstheaderemptycheck_->set_active(ltt.empty);
264 //firstheaderoncheck_->set_sensitive(false);
268 row_set = tabular.getRowOfLTFoot(row, ltt);
269 footeroncheck_->set_active(row_set);
271 footerupperborderdoublecheck_->set_active(ltt.topDL);
272 footerlowerborderdoublecheck_->set_active(ltt.bottomDL);
275 footerupperborderdoublecheck_->set_active(false);
276 footerlowerborderdoublecheck_->set_active(false);
277 //footerupperborderdoublecheck_->set_sensitive(false);
278 //footerlowerborderdoublecheck_->set_sensitive(false);
279 lastfooteremptycheck_->set_active(false);
280 //lastfooteremptycheck_->set_sensitive(false);
284 row_set = tabular.getRowOfLTLastFoot(row, ltt);
285 lastfooteroncheck_->set_active(row_set);
286 if (ltt.set && (!ltt.empty || !use_empty)) {
287 lastfooterupperborderdoublecheck_->set_active(ltt.topDL);
288 lastfooterlowerborderdoublecheck_->set_active(ltt.bottomDL);
290 lastfooterupperborderdoublecheck_->set_active(false);
291 lastfooterlowerborderdoublecheck_->set_active(false);
292 //lastfooterupperborderdoublecheck_->set_sensitive(false);
293 //lastfooterlowerborderdoublecheck_->set_sensitive(false);
295 lastfooteremptycheck_->set_active(ltt.empty);
297 //lastfooteroncheck_->set_sensitive(false);
306 updateSpecialRowsSensitivity();
310 void GTabular::onInput()
316 void GTabular::allBorders(bool borders)
318 if (upperbordercheck_->is_sensitive())
319 upperbordercheck_->set_active(borders);
320 if (lowerbordercheck_->is_sensitive())
321 lowerbordercheck_->set_active(borders);
322 if (leftbordercheck_->is_sensitive())
323 leftbordercheck_->set_active(borders);
324 if (rightbordercheck_->is_sensitive())
325 rightbordercheck_->set_active(borders);
329 void GTabular::updateSensitivity()
334 bool const specifywidth = specifywidthcheck_->get_active();
335 bool const multicol = multicolcheck_->get_active();
337 widthlength_->set_sensitive(specifywidth);
338 vertaligncombo_->set_sensitive(specifywidth);
340 updateHorzAlignCombo(!multicol && specifywidth);
344 void GTabular::updateHorzAlignCombo(bool extraoption)
349 //FIXME: check if we really need to completely rewrite combo data
350 // Deprecated in favor of clear_items in gtkmm >= 2.8
351 int const oldselection = horzaligncombo_->get_active_row_number();
352 horzaligncombo_->clear();
353 horzaligncombo_->append_text(_("Left"));
354 horzaligncombo_->append_text(_("Center"));
355 horzaligncombo_->append_text(_("Right"));
357 horzaligncombo_->append_text(_("Block"));
358 if (oldselection < horzaligncombo_->get_model()->children().size())
359 horzaligncombo_->set_active(oldselection);
361 horzaligncombo_->set_active(0);
365 void GTabular::updateSpecialRowsSensitivity()
370 bool const header = headeroncheck_->get_active();
371 bool const footer = footeroncheck_->get_active();
372 bool const firstheader = firstheaderoncheck_->get_active();
373 bool const firstheaderempty = firstheaderemptycheck_->get_active();
374 bool const lastfooter = lastfooteroncheck_->get_active();
375 bool const lastfooterempty = lastfooteremptycheck_->get_active();
376 firstheaderemptycheck_->set_sensitive(!firstheader);
377 lastfooteremptycheck_->set_sensitive(!lastfooter);
378 headerupperborderdoublecheck_->set_sensitive(header);
379 headerlowerborderdoublecheck_->set_sensitive(header);
380 footerupperborderdoublecheck_->set_sensitive(footer);
381 footerlowerborderdoublecheck_->set_sensitive(footer);
383 firstheaderoncheck_->set_sensitive(!firstheaderempty);
384 firstheaderupperborderdoublecheck_->set_sensitive(firstheaderempty || firstheader);
385 firstheaderlowerborderdoublecheck_->set_sensitive(firstheaderempty || firstheader);
386 lastfooteroncheck_->set_sensitive(!lastfooterempty);
387 lastfooterupperborderdoublecheck_->set_sensitive(lastfooterempty || lastfooter);
388 lastfooterlowerborderdoublecheck_->set_sensitive(lastfooterempty || lastfooter);
389 bool const longtable = longtablecheck_->get_active();
390 specialrowstable_->set_sensitive(longtable);
391 pagebreakcheck_->set_sensitive(longtable);
394 } // namespace frontend