2 * FormTabular Interface Class Implementation
6 #include "lyx_gui_misc.h"
8 #include FORMS_H_LOCATION
10 #include "FormTabular.h"
11 #include "form_tabular.h"
12 #include "xform_macros.h"
13 #include "input_validators.h"
19 #include "insets/insettabular.h"
23 #ifdef SIGC_CXX_NAMESPACES
27 C_RETURNCB(FormTabular, WMHideCB)
28 C_GENERICCB(FormTabular, CloseCB)
29 C_GENERICCB(FormTabular, InputCB)
30 C_GENERICCB(FormTabular, OKCB)
31 C_GENERICCB(FormTabular, ApplyCB)
32 C_GENERICCB(FormTabular, CancelCB)
35 FormTabular::FormTabular(LyXView * lv, Dialogs * d)
36 : dialog_(0), tabular_options_(0), column_options_(0),
37 cell_options_(0), longtable_options_(0), create_tabular_(0),
38 lv_(lv), d_(d), u_(0), h_(0), inset_(0), actCell_(-1)
40 // let the dialog be shown
41 // This is a permanent connection so we won't bother
42 // storing a copy because we won't be disconnecting.
43 d->showTabular.connect(slot(this, &FormTabular::showInset));
44 d->updateTabular.connect(slot(this, &FormTabular::updateInset));
45 d->hideTabular.connect(slot(this, &FormTabular::hideInset));
46 d->showTabularCreate.connect(slot(this, &FormTabular::show_create));
50 FormTabular::~FormTabular()
52 // we don't need to disconnect u and h here because
53 // their destructors do that.
55 delete tabular_options_;
56 delete column_options_;
58 delete longtable_options_;
59 delete create_tabular_;
63 void FormTabular::build()
65 dialog_ = build_tabular();
66 tabular_options_ = build_tabular_options();
67 column_options_ = build_column_options();
68 cell_options_ = build_cell_options();
69 longtable_options_ = build_longtable_options();
70 create_tabular_ = build_create_tabular();
72 fl_set_input_return(column_options_->input_column_width,
74 fl_set_input_return(column_options_->input_special_alignment,
76 fl_set_input_return(cell_options_->input_mcolumn_width,
78 fl_set_input_return(cell_options_->input_special_multialign,
81 fl_addto_tabfolder(dialog_->tabFolder, _("Tabular"),
82 tabular_options_->form);
83 fl_addto_tabfolder(dialog_->tabFolder, _("Column/Row"),
84 column_options_->form);
85 fl_addto_tabfolder(dialog_->tabFolder, _("Cell"),
87 fl_addto_tabfolder(dialog_->tabFolder, _("LongTable"),
88 longtable_options_->form);
90 fl_set_form_atclose(dialog_->form,
91 C_FormTabularWMHideCB, 0);
93 fl_set_slider_bounds(create_tabular_->slider_rows, 1, 50);
94 fl_set_slider_bounds(create_tabular_->slider_columns, 1, 50);
95 fl_set_slider_value(create_tabular_->slider_rows, 5);
96 fl_set_slider_value(create_tabular_->slider_columns, 5);
97 fl_set_slider_precision(create_tabular_->slider_rows, 0);
98 fl_set_slider_precision(create_tabular_->slider_columns, 0);
99 fl_set_form_atclose(create_tabular_->form,
100 C_FormTabularWMHideCB, 0);
104 void FormTabular::show()
109 update(); // make sure its up-to-date
111 if (dialog_->form->visible) {
112 fl_raise_form(dialog_->form);
114 fl_show_form(dialog_->form,
115 FL_PLACE_MOUSE | FL_FREE_SIZE,
117 _("Tabular Layout"));
118 // u_ = d_->updateBufferDependent.connect(slot(this,
119 // &FormTabular::update));
120 h_ = d_->hideBufferDependent.connect(slot(this,
121 &FormTabular::hide));
125 void FormTabular::showInset(InsetTabular * ti)
133 void FormTabular::hide()
135 if (dialog_ && dialog_->form && dialog_->form->visible) {
136 fl_hide_form(dialog_->form);
144 void FormTabular::hideInset(InsetTabular * ti)
153 void FormTabular::update()
160 void FormTabular::updateInset(InsetTabular * ti)
163 if (ti && dialog_ && dialog_->form->visible) {
169 int FormTabular::WMHideCB(FL_FORM * form, void *)
171 // Ensure that the signals (u and h) are disconnected even if the
172 // window manager is used to close the dialog.
173 FormTabular * pre = static_cast<FormTabular*>(form->u_vdata);
179 void FormTabular::CloseCB(FL_OBJECT * ob, long)
181 FormTabular * pre = static_cast<FormTabular*>(ob->form->u_vdata);
186 void FormTabular::InputCB(FL_OBJECT * ob, long l)
188 FormTabular * pre = static_cast<FormTabular*>(ob->form->u_vdata);
189 pre->SetTabularOptions(ob, l);
193 bool FormTabular::local_update(bool)
195 if (!inset_ || !inset_->tabular)
199 * tabular = inset_->tabular;
209 actCell_ = cell = inset_->GetActCell();
210 column = tabular->column_of_cell(cell)+1;
211 fl_set_object_label(dialog_->text_warning,"");
212 fl_activate_object(column_options_->input_special_alignment);
213 fl_activate_object(cell_options_->input_special_multialign);
214 fl_activate_object(column_options_->input_column_width);
215 sprintf(buf,"%d",column);
216 fl_set_input(dialog_->input_tabular_column, buf);
217 fl_deactivate_object(dialog_->input_tabular_column);
218 row = tabular->row_of_cell(cell)+1;
219 sprintf(buf,"%d",row);
220 fl_set_input(dialog_->input_tabular_row, buf);
221 fl_deactivate_object(dialog_->input_tabular_row);
222 if (tabular->IsMultiColumn(cell)) {
223 fl_set_button(cell_options_->radio_multicolumn, 1);
224 fl_set_button(cell_options_->radio_border_top,
225 tabular->TopLine(cell)?1:0);
226 fl_activate_object(cell_options_->radio_border_top);
227 fl_set_object_lcol(cell_options_->radio_border_top, FL_BLACK);
228 fl_set_button(cell_options_->radio_border_bottom,
229 tabular->BottomLine(cell)?1:0);
230 fl_activate_object(cell_options_->radio_border_bottom);
231 fl_set_object_lcol(cell_options_->radio_border_bottom, FL_BLACK);
232 fl_set_button(cell_options_->radio_border_left,
233 tabular->LeftLine(cell)?1:0);
234 fl_activate_object(cell_options_->radio_border_left);
235 fl_set_object_lcol(cell_options_->radio_border_left, FL_BLACK);
236 fl_set_button(cell_options_->radio_border_right,
237 tabular->RightLine(cell)?1:0);
238 fl_activate_object(cell_options_->radio_border_right);
239 fl_set_object_lcol(cell_options_->radio_border_right, FL_BLACK);
240 pwidth = tabular->GetMColumnPWidth(cell);
241 align = tabular->GetAlignment(cell);
242 if (!pwidth.empty() || (align == LYX_ALIGN_LEFT))
243 fl_set_button(cell_options_->radio_align_left, 1);
244 else if (align == LYX_ALIGN_RIGHT)
245 fl_set_button(cell_options_->radio_align_right, 1);
247 fl_set_button(cell_options_->radio_align_center, 1);
248 fl_activate_object(cell_options_->radio_align_left);
249 fl_set_object_lcol(cell_options_->radio_align_left, FL_BLACK);
250 fl_activate_object(cell_options_->radio_align_right);
251 fl_set_object_lcol(cell_options_->radio_align_right, FL_BLACK);
252 fl_activate_object(cell_options_->radio_align_center);
253 fl_set_object_lcol(cell_options_->radio_align_center, FL_BLACK);
254 align = tabular->GetVAlignment(cell);
255 fl_set_button(cell_options_->radio_valign_top, 0);
256 fl_set_button(cell_options_->radio_valign_bottom, 0);
257 fl_set_button(cell_options_->radio_valign_center, 0);
258 if (pwidth.empty() || (align == LyXTabular::LYX_VALIGN_CENTER))
259 fl_set_button(cell_options_->radio_valign_center, 1);
260 else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
261 fl_set_button(cell_options_->radio_valign_bottom, 1);
263 fl_set_button(cell_options_->radio_valign_top, 1);
264 fl_activate_object(cell_options_->radio_valign_top);
265 fl_set_object_lcol(cell_options_->radio_valign_top, FL_BLACK);
266 fl_activate_object(cell_options_->radio_valign_bottom);
267 fl_set_object_lcol(cell_options_->radio_valign_bottom, FL_BLACK);
268 fl_activate_object(cell_options_->radio_valign_center);
269 fl_set_object_lcol(cell_options_->radio_valign_center, FL_BLACK);
270 special = tabular->GetAlignSpecial(cell,LyXTabular::SET_SPECIAL_MULTI);
271 fl_set_input(cell_options_->input_special_multialign, special.c_str());
272 fl_set_input(cell_options_->input_mcolumn_width,pwidth.c_str());
273 if (!lv_->buffer()->isReadonly()) {
274 fl_activate_object(cell_options_->input_special_multialign);
275 fl_set_object_lcol(cell_options_->input_special_multialign,
277 fl_activate_object(cell_options_->input_mcolumn_width);
278 fl_set_object_lcol(cell_options_->input_mcolumn_width, FL_BLACK);
280 if (!pwidth.empty()) {
281 fl_deactivate_object(cell_options_->radio_align_left);
282 fl_deactivate_object(cell_options_->radio_align_right);
283 fl_deactivate_object(cell_options_->radio_align_center);
284 fl_set_object_lcol(cell_options_->radio_align_left, FL_INACTIVE);
285 fl_set_object_lcol(cell_options_->radio_align_right, FL_INACTIVE);
286 fl_set_object_lcol(cell_options_->radio_align_center, FL_INACTIVE);
287 fl_activate_object(cell_options_->radio_valign_top);
288 fl_activate_object(cell_options_->radio_valign_bottom);
289 fl_activate_object(cell_options_->radio_valign_center);
290 fl_set_object_lcol(cell_options_->radio_valign_top, FL_BLACK);
291 fl_set_object_lcol(cell_options_->radio_valign_bottom, FL_BLACK);
292 fl_set_object_lcol(cell_options_->radio_valign_center, FL_BLACK);
294 fl_activate_object(cell_options_->radio_align_left);
295 fl_activate_object(cell_options_->radio_align_right);
296 fl_activate_object(cell_options_->radio_align_center);
297 fl_set_object_lcol(cell_options_->radio_align_left, FL_BLACK);
298 fl_set_object_lcol(cell_options_->radio_align_right, FL_BLACK);
299 fl_set_object_lcol(cell_options_->radio_align_center, FL_BLACK);
300 fl_deactivate_object(cell_options_->radio_valign_top);
301 fl_deactivate_object(cell_options_->radio_valign_bottom);
302 fl_deactivate_object(cell_options_->radio_valign_center);
303 fl_set_object_lcol(cell_options_->radio_valign_top, FL_INACTIVE);
304 fl_set_object_lcol(cell_options_->radio_valign_bottom,FL_INACTIVE);
305 fl_set_object_lcol(cell_options_->radio_valign_center,FL_INACTIVE);
308 fl_set_button(cell_options_->radio_multicolumn, 0);
309 fl_set_button(cell_options_->radio_border_top, 0);
310 fl_deactivate_object(cell_options_->radio_border_top);
311 fl_set_object_lcol(cell_options_->radio_border_top, FL_INACTIVE);
312 fl_set_button(cell_options_->radio_border_bottom, 0);
313 fl_deactivate_object(cell_options_->radio_border_bottom);
314 fl_set_object_lcol(cell_options_->radio_border_bottom, FL_INACTIVE);
315 fl_set_button(cell_options_->radio_border_left, 0);
316 fl_deactivate_object(cell_options_->radio_border_left);
317 fl_set_object_lcol(cell_options_->radio_border_left, FL_INACTIVE);
318 fl_set_button(cell_options_->radio_border_right, 0);
319 fl_deactivate_object(cell_options_->radio_border_right);
320 fl_set_object_lcol(cell_options_->radio_border_right, FL_INACTIVE);
321 fl_set_button(cell_options_->radio_align_left, 0);
322 fl_deactivate_object(cell_options_->radio_align_left);
323 fl_set_object_lcol(cell_options_->radio_align_left, FL_INACTIVE);
324 fl_set_button(cell_options_->radio_align_right, 0);
325 fl_deactivate_object(cell_options_->radio_align_right);
326 fl_set_object_lcol(cell_options_->radio_align_right, FL_INACTIVE);
327 fl_set_button(cell_options_->radio_align_center, 0);
328 fl_deactivate_object(cell_options_->radio_align_center);
329 fl_set_object_lcol(cell_options_->radio_align_center, FL_INACTIVE);
330 fl_set_button(cell_options_->radio_valign_top, 0);
331 fl_deactivate_object(cell_options_->radio_valign_top);
332 fl_set_object_lcol(cell_options_->radio_valign_top, FL_INACTIVE);
333 fl_set_button(cell_options_->radio_valign_bottom, 0);
334 fl_deactivate_object(cell_options_->radio_valign_bottom);
335 fl_set_object_lcol(cell_options_->radio_valign_bottom, FL_INACTIVE);
336 fl_set_button(cell_options_->radio_valign_center, 0);
337 fl_deactivate_object(cell_options_->radio_valign_center);
338 fl_set_object_lcol(cell_options_->radio_valign_center, FL_INACTIVE);
339 fl_set_input(cell_options_->input_special_multialign, "");
340 fl_deactivate_object(cell_options_->input_special_multialign);
341 fl_set_object_lcol(cell_options_->input_special_multialign, FL_INACTIVE);
342 fl_set_input(cell_options_->input_mcolumn_width,"");
343 fl_deactivate_object(cell_options_->input_mcolumn_width);
344 fl_set_object_lcol(cell_options_->input_mcolumn_width, FL_INACTIVE);
346 if (tabular->GetRotateCell(cell))
347 fl_set_button(cell_options_->radio_rotate_cell, 1);
349 fl_set_button(cell_options_->radio_rotate_cell, 0);
350 if (tabular->TopLine(cell, true))
351 fl_set_button(column_options_->radio_border_top, 1);
353 fl_set_button(column_options_->radio_border_top, 0);
354 if (tabular->BottomLine(cell, true))
355 fl_set_button(column_options_->radio_border_bottom, 1);
357 fl_set_button(column_options_->radio_border_bottom, 0);
358 if (tabular->LeftLine(cell, true))
359 fl_set_button(column_options_->radio_border_left, 1);
361 fl_set_button(column_options_->radio_border_left, 0);
362 if (tabular->RightLine(cell, true))
363 fl_set_button(column_options_->radio_border_right, 1);
365 fl_set_button(column_options_->radio_border_right, 0);
366 special = tabular->GetAlignSpecial(cell,LyXTabular::SET_SPECIAL_COLUMN);
367 fl_set_input(column_options_->input_special_alignment, special.c_str());
368 if (lv_->buffer()->isReadonly())
369 fl_deactivate_object(column_options_->input_special_alignment);
371 fl_activate_object(column_options_->input_special_alignment);
372 pwidth = tabular->GetColumnPWidth(cell);
373 fl_set_input(column_options_->input_column_width,pwidth.c_str());
374 if (lv_->buffer()->isReadonly()) {
375 fl_deactivate_object(column_options_->input_column_width);
377 fl_activate_object(column_options_->input_column_width);
379 if (!pwidth.empty()) {
380 fl_activate_object(cell_options_->radio_useminipage);
381 fl_set_object_lcol(cell_options_->radio_useminipage, FL_BLACK);
382 if (tabular->GetUsebox(cell) == 2)
383 fl_set_button(cell_options_->radio_useminipage, 1);
385 fl_set_button(cell_options_->radio_useminipage, 0);
387 fl_deactivate_object(cell_options_->radio_useminipage);
388 fl_set_object_lcol(cell_options_->radio_useminipage, FL_INACTIVE);
389 fl_set_button(cell_options_->radio_useminipage,0);
391 align = tabular->GetAlignment(cell, true);
392 fl_set_button(column_options_->radio_align_left, 0);
393 fl_set_button(column_options_->radio_align_right, 0);
394 fl_set_button(column_options_->radio_align_center, 0);
395 if (!pwidth.empty() || (align == LYX_ALIGN_LEFT))
396 fl_set_button(column_options_->radio_align_left, 1);
397 else if (align == LYX_ALIGN_RIGHT)
398 fl_set_button(column_options_->radio_align_right, 1);
400 fl_set_button(column_options_->radio_align_center, 1);
401 align = tabular->GetVAlignment(cell, true);
402 fl_set_button(column_options_->radio_valign_top, 0);
403 fl_set_button(column_options_->radio_valign_bottom, 0);
404 fl_set_button(column_options_->radio_valign_center, 0);
405 if (pwidth.empty() || (align == LyXTabular::LYX_VALIGN_CENTER))
406 fl_set_button(column_options_->radio_valign_center, 1);
407 else if (align == LyXTabular::LYX_VALIGN_BOTTOM)
408 fl_set_button(column_options_->radio_valign_bottom, 1);
410 fl_set_button(column_options_->radio_valign_top, 1);
411 if (!pwidth.empty()) {
412 fl_deactivate_object(column_options_->radio_align_left);
413 fl_deactivate_object(column_options_->radio_align_right);
414 fl_deactivate_object(column_options_->radio_align_center);
415 fl_set_object_lcol(column_options_->radio_align_left, FL_INACTIVE);
416 fl_set_object_lcol(column_options_->radio_align_right, FL_INACTIVE);
417 fl_set_object_lcol(column_options_->radio_align_center, FL_INACTIVE);
418 fl_activate_object(column_options_->radio_valign_top);
419 fl_activate_object(column_options_->radio_valign_bottom);
420 fl_activate_object(column_options_->radio_valign_center);
421 fl_set_object_lcol(column_options_->radio_valign_top, FL_BLACK);
422 fl_set_object_lcol(column_options_->radio_valign_bottom, FL_BLACK);
423 fl_set_object_lcol(column_options_->radio_valign_center, FL_BLACK);
425 fl_activate_object(column_options_->radio_align_left);
426 fl_activate_object(column_options_->radio_align_right);
427 fl_activate_object(column_options_->radio_align_center);
428 fl_set_object_lcol(column_options_->radio_align_left, FL_BLACK);
429 fl_set_object_lcol(column_options_->radio_align_right, FL_BLACK);
430 fl_set_object_lcol(column_options_->radio_align_center, FL_BLACK);
431 fl_deactivate_object(column_options_->radio_valign_top);
432 fl_deactivate_object(column_options_->radio_valign_bottom);
433 fl_deactivate_object(column_options_->radio_valign_center);
434 fl_set_object_lcol(column_options_->radio_valign_top, FL_INACTIVE);
435 fl_set_object_lcol(column_options_->radio_valign_bottom, FL_INACTIVE);
436 fl_set_object_lcol(column_options_->radio_valign_center, FL_INACTIVE);
438 fl_set_button(tabular_options_->radio_longtable,
439 tabular->IsLongTabular());
440 if (tabular->IsLongTabular()) {
441 fl_activate_object(longtable_options_->radio_lt_firsthead);
442 fl_activate_object(longtable_options_->radio_lt_head);
443 fl_activate_object(longtable_options_->radio_lt_foot);
444 fl_activate_object(longtable_options_->radio_lt_lastfoot);
445 fl_activate_object(longtable_options_->radio_lt_newpage);
446 fl_set_object_lcol(longtable_options_->radio_lt_firsthead, FL_BLACK);
447 fl_set_object_lcol(longtable_options_->radio_lt_head, FL_BLACK);
448 fl_set_object_lcol(longtable_options_->radio_lt_foot, FL_BLACK);
449 fl_set_object_lcol(longtable_options_->radio_lt_lastfoot, FL_BLACK);
450 fl_set_object_lcol(longtable_options_->radio_lt_newpage, FL_BLACK);
452 fl_set_button(longtable_options_->radio_lt_firsthead,
453 tabular->GetRowOfLTFirstHead(cell, dummy));
454 fl_set_button(longtable_options_->radio_lt_head,
455 tabular->GetRowOfLTHead(cell, dummy));
456 fl_set_button(longtable_options_->radio_lt_foot,
457 tabular->GetRowOfLTFoot(cell, dummy));
458 fl_set_button(longtable_options_->radio_lt_lastfoot,
459 tabular->GetRowOfLTLastFoot(cell, dummy));
460 fl_set_button(longtable_options_->radio_lt_newpage,
461 tabular->GetLTNewPage(cell));
463 fl_deactivate_object(longtable_options_->radio_lt_firsthead);
464 fl_deactivate_object(longtable_options_->radio_lt_head);
465 fl_deactivate_object(longtable_options_->radio_lt_foot);
466 fl_deactivate_object(longtable_options_->radio_lt_lastfoot);
467 fl_deactivate_object(longtable_options_->radio_lt_newpage);
468 fl_set_button(longtable_options_->radio_lt_firsthead,0);
469 fl_set_button(longtable_options_->radio_lt_head,0);
470 fl_set_button(longtable_options_->radio_lt_foot,0);
471 fl_set_button(longtable_options_->radio_lt_lastfoot,0);
472 fl_set_button(longtable_options_->radio_lt_newpage,0);
473 fl_set_object_lcol(longtable_options_->radio_lt_firsthead,FL_INACTIVE);
474 fl_set_object_lcol(longtable_options_->radio_lt_head, FL_INACTIVE);
475 fl_set_object_lcol(longtable_options_->radio_lt_foot, FL_INACTIVE);
476 fl_set_object_lcol(longtable_options_->radio_lt_lastfoot, FL_INACTIVE);
477 fl_set_object_lcol(longtable_options_->radio_lt_newpage, FL_INACTIVE);
479 fl_set_button(tabular_options_->radio_rotate_tabular,
480 tabular->GetRotateTabular());
484 void FormTabular::SetTabularOptions(FL_OBJECT * ob, long)
490 * tabular = inset_->tabular;
499 cell = inset_->GetActCell();
500 if (actCell_ != cell) {
502 fl_set_object_label(dialog_->text_warning,
503 _("Warning: Wrong Cursor position, updated window"));
504 fl_show_object(dialog_->text_warning);
507 // No point in processing directives that you can't do anything with
508 // anyhow, so exit now if the buffer is read-only.
509 if (lv_->buffer()->isReadonly()) {
513 if (ob == column_options_->input_column_width) {
516 str = fl_get_input(ob);
517 if (!str.empty() && !isValidLength(str)) {
518 fl_set_object_label(dialog_->text_warning,
519 _("Warning: Invalid Length (valid example: 10mm)"));
520 fl_show_object(dialog_->text_warning);
523 inset_->TabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH,str);
524 local_update(false); // update for alignment
527 if (ob == cell_options_->input_mcolumn_width) {
530 str = fl_get_input(ob);
531 if (!str.empty() && !isValidLength(str)) {
532 fl_set_object_label(dialog_->text_warning,
533 _("Warning: Invalid Length (valid example: 10mm)"));
534 fl_show_object(dialog_->text_warning);
537 inset_->TabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH,str);
538 local_update(false); // update for alignment
541 str = fl_get_input(column_options_->input_column_width);
542 if (!str.empty() && !isValidLength(str)) {
544 dialog_->text_warning,
545 _("Warning: Invalid Length (valid example: 10mm)"));
546 fl_show_object(dialog_->text_warning);
549 if (ob == tabular_options_->button_append_row)
550 num = LyXTabular::APPEND_ROW;
551 else if (ob == tabular_options_->button_append_column)
552 num = LyXTabular::APPEND_COLUMN;
553 else if (ob == tabular_options_->button_delete_row)
554 num = LyXTabular::DELETE_ROW;
555 else if (ob == tabular_options_->button_delete_column)
556 num = LyXTabular::DELETE_COLUMN;
557 else if (ob == tabular_options_->button_set_borders)
558 num = LyXTabular::SET_ALL_LINES;
559 else if (ob == tabular_options_->button_unset_borders)
560 num = LyXTabular::UNSET_ALL_LINES;
561 else if (ob == column_options_->radio_border_top)
562 num = LyXTabular::TOGGLE_LINE_TOP;
563 else if (ob == column_options_->radio_border_bottom)
564 num = LyXTabular::TOGGLE_LINE_BOTTOM;
565 else if (ob == column_options_->radio_border_left)
566 num = LyXTabular::TOGGLE_LINE_LEFT;
567 else if (ob == column_options_->radio_border_right)
568 num = LyXTabular::TOGGLE_LINE_RIGHT;
569 else if (ob == column_options_->radio_align_left)
570 num = LyXTabular::ALIGN_LEFT;
571 else if (ob == column_options_->radio_align_right)
572 num = LyXTabular::ALIGN_RIGHT;
573 else if (ob == column_options_->radio_align_center)
574 num = LyXTabular::ALIGN_CENTER;
575 else if (ob == column_options_->radio_valign_top)
576 num = LyXTabular::VALIGN_TOP;
577 else if (ob == column_options_->radio_valign_bottom)
578 num = LyXTabular::VALIGN_BOTTOM;
579 else if (ob == column_options_->radio_valign_center)
580 num = LyXTabular::VALIGN_CENTER;
581 else if (ob == cell_options_->radio_multicolumn)
582 num = LyXTabular::MULTICOLUMN;
583 else if (ob == tabular_options_->radio_longtable) {
584 s=fl_get_button(tabular_options_->radio_longtable);
586 num = LyXTabular::SET_LONGTABULAR;
587 fl_activate_object(longtable_options_->radio_lt_firsthead);
588 fl_activate_object(longtable_options_->radio_lt_head);
589 fl_activate_object(longtable_options_->radio_lt_foot);
590 fl_activate_object(longtable_options_->radio_lt_lastfoot);
591 fl_activate_object(longtable_options_->radio_lt_newpage);
593 fl_set_button(longtable_options_->radio_lt_firsthead,
594 tabular->GetRowOfLTFirstHead(cell, dummy));
595 fl_set_button(longtable_options_->radio_lt_head,
596 tabular->GetRowOfLTHead(cell, dummy));
597 fl_set_button(longtable_options_->radio_lt_foot,
598 tabular->GetRowOfLTFoot(cell, dummy));
599 fl_set_button(longtable_options_->radio_lt_lastfoot,
600 tabular->GetRowOfLTLastFoot(cell, dummy));
601 fl_set_button(longtable_options_->radio_lt_firsthead,
602 tabular->GetLTNewPage(cell));
604 num = LyXTabular::UNSET_LONGTABULAR;
605 fl_deactivate_object(longtable_options_->radio_lt_firsthead);
606 fl_deactivate_object(longtable_options_->radio_lt_head);
607 fl_deactivate_object(longtable_options_->radio_lt_foot);
608 fl_deactivate_object(longtable_options_->radio_lt_lastfoot);
609 fl_deactivate_object(longtable_options_->radio_lt_newpage);
610 fl_set_button(longtable_options_->radio_lt_firsthead,0);
611 fl_set_button(longtable_options_->radio_lt_head,0);
612 fl_set_button(longtable_options_->radio_lt_foot,0);
613 fl_set_button(longtable_options_->radio_lt_lastfoot,0);
614 fl_set_button(longtable_options_->radio_lt_newpage,0);
615 fl_set_object_lcol(longtable_options_->radio_lt_firsthead,
617 fl_set_object_lcol(longtable_options_->radio_lt_head, FL_INACTIVE);
618 fl_set_object_lcol(longtable_options_->radio_lt_foot, FL_INACTIVE);
619 fl_set_object_lcol(longtable_options_->radio_lt_lastfoot,
621 fl_set_object_lcol(longtable_options_->radio_lt_newpage,
624 } else if (ob == tabular_options_->radio_rotate_tabular) {
625 s=fl_get_button(tabular_options_->radio_rotate_tabular);
627 num = LyXTabular::SET_ROTATE_TABULAR;
629 num = LyXTabular::UNSET_ROTATE_TABULAR;
630 } else if (ob == cell_options_->radio_rotate_cell) {
631 s=fl_get_button(cell_options_->radio_rotate_cell);
633 num = LyXTabular::SET_ROTATE_CELL;
635 num = LyXTabular::UNSET_ROTATE_CELL;
636 } else if (ob == cell_options_->radio_useminipage) {
637 num = LyXTabular::SET_USEBOX;
639 } else if (ob == longtable_options_->radio_lt_firsthead) {
640 num = LyXTabular::SET_LTFIRSTHEAD;
641 } else if (ob == longtable_options_->radio_lt_head) {
642 num = LyXTabular::SET_LTHEAD;
643 } else if (ob == longtable_options_->radio_lt_foot) {
644 num = LyXTabular::SET_LTFOOT;
645 } else if (ob == longtable_options_->radio_lt_lastfoot) {
646 num = LyXTabular::SET_LTLASTFOOT;
647 } else if (ob == longtable_options_->radio_lt_newpage) {
648 num = LyXTabular::SET_LTNEWPAGE;
649 } else if (ob == column_options_->input_special_alignment) {
650 special = fl_get_input(column_options_->input_special_alignment);
651 num = LyXTabular::SET_SPECIAL_COLUMN;
652 } else if (ob == cell_options_->input_special_multialign) {
653 special = fl_get_input(cell_options_->input_special_multialign);
654 num = LyXTabular::SET_SPECIAL_MULTI;
655 } else if (ob == cell_options_->radio_border_top)
656 num = LyXTabular::M_TOGGLE_LINE_TOP;
657 else if (ob == cell_options_->radio_border_bottom)
658 num = LyXTabular::M_TOGGLE_LINE_BOTTOM;
659 else if (ob == cell_options_->radio_border_left)
660 num = LyXTabular::M_TOGGLE_LINE_LEFT;
661 else if (ob == cell_options_->radio_border_right)
662 num = LyXTabular::M_TOGGLE_LINE_RIGHT;
663 else if (ob == cell_options_->radio_align_left)
664 num = LyXTabular::M_ALIGN_LEFT;
665 else if (ob == cell_options_->radio_align_right)
666 num = LyXTabular::M_ALIGN_RIGHT;
667 else if (ob == cell_options_->radio_align_center)
668 num = LyXTabular::M_ALIGN_CENTER;
669 else if (ob == cell_options_->radio_valign_top)
670 num = LyXTabular::M_VALIGN_TOP;
671 else if (ob == cell_options_->radio_valign_bottom)
672 num = LyXTabular::M_VALIGN_BOTTOM;
673 else if (ob == cell_options_->radio_valign_center)
674 num = LyXTabular::M_VALIGN_CENTER;
678 inset_->TabularFeatures(lv_->view(), num, special);
682 // +-----------------------------------------------------------------------+
683 // | Functions/Dialogs for creating tabular insets |
684 // +-----------------------------------------------------------------------+
686 void FormTabular::show_create()
691 if (create_tabular_->form->visible) {
692 fl_raise_form(create_tabular_->form);
694 fl_show_form(create_tabular_->form,
695 FL_PLACE_MOUSE | FL_FREE_SIZE,
696 FL_FULLBORDER, _("Insert Tabular"));
701 void FormTabular::apply_create()
706 // comm->setMinibuffer(_("Inserting tabular inset..."));
707 ysize = int(fl_get_slider_value(create_tabular_->slider_columns) + 0.5);
708 xsize = int(fl_get_slider_value(create_tabular_->slider_rows) + 0.5);
709 InsetTabular * in = new InsetTabular(lv_->buffer(),xsize,ysize);
710 if (!lv_->view()->open_new_inset(in)) {
713 // comm->setMinibuffer(_("Tabular mode"));
717 void FormTabular::hide_create()
719 if (create_tabular_->form &&
720 create_tabular_->form->visible)
721 fl_hide_form(create_tabular_->form);
725 void FormTabular::OKCB(FL_OBJECT * ob, long)
727 FormTabular * pre = (FormTabular*)ob->form->u_vdata;
733 void FormTabular::ApplyCB(FL_OBJECT * ob, long)
735 FormTabular * pre = (FormTabular*)ob->form->u_vdata;
740 void FormTabular::CancelCB(FL_OBJECT * ob, long)
742 FormTabular * pre = (FormTabular*)ob->form->u_vdata;