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"
35 #warning Implement booktabs settings
41 GTabular::GTabular(Dialog & parent)
42 : GViewCB<ControlTabular, GViewGladeB>(parent, _("Table Settings"), false)
46 void GTabular::doBuild()
48 string const gladeName = findGladeFile("tabular");
49 xml_ = Gnome::Glade::Xml::create(gladeName);
52 xml_->get_widget("Close", button);
55 // **** Current cell coords ****
56 xml_->get_widget("CurrentRow", cellrowspin_);
57 xml_->get_widget("CurrentColumn", cellcolspin_);
59 // **** Table tab ****
61 xml_->get_widget("HorizontalAlignment", box);
62 horzaligncombo_ = Gtk::manage (new Gtk::ComboBoxText);
63 box->add(*horzaligncombo_);
65 xml_->get_widget("VerticalAlignment", vertaligncombo_);
66 xml_->get_widget("SpecifyWidth", specifywidthcheck_);
67 specifywidthcheck_->signal_toggled().connect(
68 sigc::mem_fun(*this, >abular::updateSensitivity));
70 xml_->get_widget_derived ("Width", widthlength_);
71 xml_->get_widget("LaTeXArgument", latexargsentry_);
72 xml_->get_widget("RotateTable", rotatetablecheck_);
74 // **** This Cell tab ****
75 xml_->get_widget("UpperBorder", upperbordercheck_);
76 xml_->get_widget("LowerBorder", lowerbordercheck_);
77 xml_->get_widget("LeftBorder", leftbordercheck_);
78 xml_->get_widget("RightBorder", rightbordercheck_);
79 xml_->get_widget("RotateCell", rotatecellcheck_);
80 xml_->get_widget("MultiColumn", multicolcheck_);
81 multicolcheck_->signal_toggled().connect(
82 sigc::mem_fun(*this, >abular::updateSensitivity));
83 xml_->get_widget("NoBorders", button);
84 button->signal_clicked().connect(
85 sigc::bind(sigc::mem_fun(*this, >abular::allBorders), false));
86 xml_->get_widget("AllBorders", button);
87 button->signal_clicked().connect(
88 sigc::bind(sigc::mem_fun(*this, >abular::allBorders), true));
90 // **** Longtable tab ****
91 xml_->get_widget("LongTable", longtablecheck_);
93 longtablecheck_->signal_toggled().connect(
94 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
96 xml_->get_widget("PageBreak", pagebreakcheck_);
98 xml_->get_widget("SpecialRows", specialrowstable_);
100 xml_->get_widget("HeaderOn",headeroncheck_);
101 xml_->get_widget("FooterOn",footeroncheck_);
102 xml_->get_widget("FirstHeaderOn",firstheaderoncheck_);
103 xml_->get_widget("LastFooterOn",lastfooteroncheck_);
104 xml_->get_widget("FirstHeaderEmpty",firstheaderemptycheck_);
105 xml_->get_widget("LastFooterEmpty",lastfooteremptycheck_);
106 xml_->get_widget("HeaderUpperBorderDouble",headerupperborderdoublecheck_);
107 xml_->get_widget("FooterUpperBorderDouble",footerupperborderdoublecheck_);
108 xml_->get_widget("FirstHeaderUpperBorderDouble",firstheaderupperborderdoublecheck_);
109 xml_->get_widget("LastFooterUpperBorderDouble",lastfooterupperborderdoublecheck_);
110 xml_->get_widget("HeaderLowerBorderDouble",headerlowerborderdoublecheck_);
111 xml_->get_widget("FooterLowerBorderDouble",footerlowerborderdoublecheck_);
112 xml_->get_widget("FirstHeaderLowerBorderDouble",firstheaderlowerborderdoublecheck_);
113 xml_->get_widget("LastFooterLowerBorderDouble",lastfooterlowerborderdoublecheck_);
115 headeroncheck_->signal_toggled().connect(
116 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
117 footeroncheck_->signal_toggled().connect(
118 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
119 firstheaderoncheck_->signal_toggled().connect(
120 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
121 lastfooteroncheck_->signal_toggled().connect(
122 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
123 firstheaderemptycheck_->signal_toggled().connect(
124 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
125 lastfooteremptycheck_->signal_toggled().connect(
126 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
127 headerupperborderdoublecheck_->signal_toggled().connect(
128 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
129 footerupperborderdoublecheck_->signal_toggled().connect(
130 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
131 firstheaderupperborderdoublecheck_->signal_toggled().connect(
132 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
133 lastfooterupperborderdoublecheck_->signal_toggled().connect(
134 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
135 headerlowerborderdoublecheck_->signal_toggled().connect(
136 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
137 footerlowerborderdoublecheck_->signal_toggled().connect(
138 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
139 firstheaderlowerborderdoublecheck_->signal_toggled().connect(
140 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
141 lastfooterlowerborderdoublecheck_->signal_toggled().connect(
142 sigc::mem_fun(*this, >abular::updateSpecialRowsSensitivity));
147 firstheaderemptycheck_;
148 lastfooteremptycheck_;
149 headerupperborderdoublecheck_;
150 footerupperborderdoublecheck_;
151 firstheaderupperborderdoublecheck_;
152 lastfooterupperborderdoublecheck_;
153 headerlowerborderdoublecheck_;
154 footerlowerborderdoublecheck_;
155 firstheaderlowerborderdoublecheck_;
156 lastfooterlowerborderdoublecheck_;*/
158 // Disable for read-only documents.
159 // bcview().addReadOnly(browsebutton_);
164 void GTabular::apply()
170 void GTabular::update()
174 LyXTabular const & tabular = controller().tabular();
175 LyXTabular::idx_type const cell = controller().getActiveCell();
176 bool const multicol = tabular.isMultiColumn(cell);
178 cellcolspin_->get_adjustment()->set_value(tabular.column_of_cell (cell)+1);
179 cellrowspin_->get_adjustment()->set_value(tabular.row_of_cell (cell));
181 // **** Table tab ****
187 special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
188 pwidth = tabular.getMColumnPWidth(cell);
190 special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
191 pwidth = tabular.getColumnPWidth(cell);
194 updateHorzAlignCombo(!multicol && !pwidth.zero());
196 int halign = tabular.getAlignment(cell);
197 if (halign == LYX_ALIGN_RIGHT)
198 horzaligncombo_->set_active(2);
199 else if (halign == LYX_ALIGN_CENTER)
200 horzaligncombo_->set_active(1);
201 else if (halign == LYX_ALIGN_BLOCK)
202 horzaligncombo_->set_active(3);
204 horzaligncombo_->set_active(0);
206 int valign = tabular.getVAlignment(cell);
207 if (valign == LyXTabular::LYX_VALIGN_BOTTOM)
208 vertaligncombo_->set_active(2);
209 else if (valign == LyXTabular::LYX_VALIGN_MIDDLE)
210 vertaligncombo_->set_active(1);
212 vertaligncombo_->set_active(0);
214 latexargsentry_->set_text(special);
215 specifywidthcheck_->set_active(!pwidth.zero());
216 widthlength_->set_length(pwidth);
217 rotatetablecheck_->set_active(tabular.getRotateTabular());
219 // **** This Cell tab ****
220 multicolcheck_->set_active(multicol);
221 rotatecellcheck_->set_active(tabular.getRotateCell(cell));
223 upperbordercheck_->set_active(tabular.topLine(cell));
224 lowerbordercheck_->set_active(tabular.bottomLine(cell));
225 leftbordercheck_->set_active(tabular.leftLine(cell));
226 rightbordercheck_->set_active(tabular.rightLine(cell));
228 // **** Long-table tab ****
229 LyXTabular::row_type const row(tabular.row_of_cell(cell));
230 bool const longtable = tabular.isLongTabular();
231 longtablecheck_->set_active(longtable);
232 pagebreakcheck_->set_active(tabular.getLTNewPage(row));
235 LyXTabular::ltType ltt;
237 bool row_set = tabular.getRowOfLTHead(row, ltt);
239 headeroncheck_->set_active(row_set);
240 lyxerr << "row_set for header = " << row_set << "\n";
242 headerupperborderdoublecheck_->set_active(ltt.topDL);
243 headerlowerborderdoublecheck_->set_active(ltt.bottomDL);
246 headerupperborderdoublecheck_->set_active(false);
247 headerlowerborderdoublecheck_->set_active(false);
248 /*headerupperborderdoublecheck_->set_sensitive(false);
249 headerlowerborderdoublecheck_->set_sensitive(false);*/
250 firstheaderemptycheck_->set_active(false);
251 /*firstheaderemptycheck_->set_sensitive(false);*/
255 row_set = tabular.getRowOfLTFirstHead(row, ltt);
256 firstheaderoncheck_->set_active(row_set);
257 if (ltt.set && (!ltt.empty || !use_empty)) {
258 firstheaderupperborderdoublecheck_->set_active(ltt.topDL);
259 firstheaderlowerborderdoublecheck_->set_active(ltt.bottomDL);
261 firstheaderupperborderdoublecheck_->set_active(false);
262 firstheaderlowerborderdoublecheck_->set_active(false);
263 /*firstheaderupperborderdoublecheck_->set_sensitive(false);
264 firstheaderlowerborderdoublecheck_->set_sensitive(false);*/
266 firstheaderemptycheck_->set_active(ltt.empty);
268 //firstheaderoncheck_->set_sensitive(false);
272 row_set = tabular.getRowOfLTFoot(row, ltt);
273 footeroncheck_->set_active(row_set);
275 footerupperborderdoublecheck_->set_active(ltt.topDL);
276 footerlowerborderdoublecheck_->set_active(ltt.bottomDL);
279 footerupperborderdoublecheck_->set_active(false);
280 footerlowerborderdoublecheck_->set_active(false);
281 //footerupperborderdoublecheck_->set_sensitive(false);
282 //footerlowerborderdoublecheck_->set_sensitive(false);
283 lastfooteremptycheck_->set_active(false);
284 //lastfooteremptycheck_->set_sensitive(false);
288 row_set = tabular.getRowOfLTLastFoot(row, ltt);
289 lastfooteroncheck_->set_active(row_set);
290 if (ltt.set && (!ltt.empty || !use_empty)) {
291 lastfooterupperborderdoublecheck_->set_active(ltt.topDL);
292 lastfooterlowerborderdoublecheck_->set_active(ltt.bottomDL);
294 lastfooterupperborderdoublecheck_->set_active(false);
295 lastfooterlowerborderdoublecheck_->set_active(false);
296 //lastfooterupperborderdoublecheck_->set_sensitive(false);
297 //lastfooterlowerborderdoublecheck_->set_sensitive(false);
299 lastfooteremptycheck_->set_active(ltt.empty);
301 //lastfooteroncheck_->set_sensitive(false);
310 updateSpecialRowsSensitivity();
314 void GTabular::onInput()
320 void GTabular::allBorders(bool borders)
322 if (upperbordercheck_->is_sensitive())
323 upperbordercheck_->set_active(borders);
324 if (lowerbordercheck_->is_sensitive())
325 lowerbordercheck_->set_active(borders);
326 if (leftbordercheck_->is_sensitive())
327 leftbordercheck_->set_active(borders);
328 if (rightbordercheck_->is_sensitive())
329 rightbordercheck_->set_active(borders);
333 void GTabular::updateSensitivity()
338 bool const specifywidth = specifywidthcheck_->get_active();
339 bool const multicol = multicolcheck_->get_active();
341 widthlength_->set_sensitive(specifywidth);
342 vertaligncombo_->set_sensitive(specifywidth);
344 updateHorzAlignCombo(!multicol && specifywidth);
348 void GTabular::updateHorzAlignCombo(bool extraoption)
353 //FIXME: check if we really need to completely rewrite combo data
354 // Deprecated in favor of clear_items in gtkmm >= 2.8
355 unsigned int const oldselection = horzaligncombo_->get_active_row_number();
356 horzaligncombo_->clear();
357 horzaligncombo_->append_text(_("Left"));
358 horzaligncombo_->append_text(_("Center"));
359 horzaligncombo_->append_text(_("Right"));
361 horzaligncombo_->append_text(_("Block"));
362 if (oldselection < horzaligncombo_->get_model()->children().size())
363 horzaligncombo_->set_active(oldselection);
365 horzaligncombo_->set_active(0);
369 void GTabular::updateSpecialRowsSensitivity()
374 bool const header = headeroncheck_->get_active();
375 bool const footer = footeroncheck_->get_active();
376 bool const firstheader = firstheaderoncheck_->get_active();
377 bool const firstheaderempty = firstheaderemptycheck_->get_active();
378 bool const lastfooter = lastfooteroncheck_->get_active();
379 bool const lastfooterempty = lastfooteremptycheck_->get_active();
380 firstheaderemptycheck_->set_sensitive(!firstheader);
381 lastfooteremptycheck_->set_sensitive(!lastfooter);
382 headerupperborderdoublecheck_->set_sensitive(header);
383 headerlowerborderdoublecheck_->set_sensitive(header);
384 footerupperborderdoublecheck_->set_sensitive(footer);
385 footerlowerborderdoublecheck_->set_sensitive(footer);
387 firstheaderoncheck_->set_sensitive(!firstheaderempty);
388 firstheaderupperborderdoublecheck_->set_sensitive(firstheaderempty || firstheader);
389 firstheaderlowerborderdoublecheck_->set_sensitive(firstheaderempty || firstheader);
390 lastfooteroncheck_->set_sensitive(!lastfooterempty);
391 lastfooterupperborderdoublecheck_->set_sensitive(lastfooterempty || lastfooter);
392 lastfooterlowerborderdoublecheck_->set_sensitive(lastfooterempty || lastfooter);
393 bool const longtable = longtablecheck_->get_active();
394 specialrowstable_->set_sensitive(longtable);
395 pagebreakcheck_->set_sensitive(longtable);
398 } // namespace frontend