]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormTabular.C
major GUII cleanup + Baruchs patch + Angus's patch + removed a couple of generated...
[lyx.git] / src / frontends / xforms / FormTabular.C
1 /* FormTabular.C
2  * FormTabular Interface Class Implementation
3  */
4
5 #include <config.h>
6 #include "lyx_gui_misc.h"
7 #include "gettext.h"
8 #include FORMS_H_LOCATION
9
10 #include "FormTabular.h"
11 #include "form_tabular.h"
12 #include "xform_macros.h"
13 #include "input_validators.h"
14 #include "LyXView.h"
15 #include "lyxfunc.h"
16 #include "Dialogs.h"
17 #include "lyxrc.h"
18 #include "debug.h"
19 #include "insets/insettabular.h"
20 #include "buffer.h"
21
22
23 #ifdef SIGC_CXX_NAMESPACES
24 using SigC::slot;
25 #endif
26
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)
33
34
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) 
39 {
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));
47 }
48
49
50 FormTabular::~FormTabular()
51 {
52     // we don't need to disconnect u and h here because
53     // their destructors do that.
54     delete dialog_;
55     delete tabular_options_;
56     delete column_options_;
57     delete cell_options_;
58     delete longtable_options_;
59     delete create_tabular_;
60 }
61
62
63 void FormTabular::build()
64 {
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();
71
72     fl_set_input_return(column_options_->input_column_width,
73                         FL_RETURN_END);
74     fl_set_input_return(column_options_->input_special_alignment,
75                         FL_RETURN_CHANGED);
76     fl_set_input_return(cell_options_->input_mcolumn_width,
77                         FL_RETURN_CHANGED);
78     fl_set_input_return(cell_options_->input_special_multialign,
79                         FL_RETURN_CHANGED);
80
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"),
86                        cell_options_->form);
87     fl_addto_tabfolder(dialog_->tabFolder, _("LongTable"),
88                        longtable_options_->form);
89     
90     fl_set_form_atclose(dialog_->form,
91                         C_FormTabularWMHideCB, 0);
92
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);
101 }
102
103
104 void FormTabular::show()
105 {
106     if (!dialog_) {
107         build();
108     }
109     update();  // make sure its up-to-date
110
111     if (dialog_->form->visible) {
112         fl_raise_form(dialog_->form);
113     } else {
114         fl_show_form(dialog_->form,
115                      FL_PLACE_MOUSE | FL_FREE_SIZE,
116                      FL_TRANSIENT,
117                      _("Tabular Layout"));
118 //      u_ = d_->updateBufferDependent.connect(slot(this,
119 //                                                  &FormTabular::update));
120         h_ = d_->hideBufferDependent.connect(slot(this,
121                                                   &FormTabular::hide));
122     }
123 }
124
125 void FormTabular::showInset(InsetTabular * ti)
126 {
127     inset_ = ti;
128     if (ti) {
129         show();
130     }
131 }
132
133 void FormTabular::hide()
134 {
135     if (dialog_ && dialog_->form && dialog_->form->visible) {
136         fl_hide_form(dialog_->form);
137         u_.disconnect();
138         h_.disconnect();
139         inset_ = 0;
140     }
141 }
142
143
144 void FormTabular::hideInset(InsetTabular * ti)
145 {
146     if (inset_ == ti) {
147         inset_ = 0;
148         hide();
149     }
150 }
151
152
153 void FormTabular::update()
154 {
155     if (dialog_) {
156         local_update(true);
157     }
158 }
159
160 void FormTabular::updateInset(InsetTabular * ti)
161 {
162     inset_ = ti;
163     if (ti && dialog_ && dialog_->form->visible) {
164         update();
165     }
166 }
167
168
169 int FormTabular::WMHideCB(FL_FORM * form, void *)
170 {
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);
174     pre->hide();
175     return FL_CANCEL;
176 }
177
178
179 void FormTabular::CloseCB(FL_OBJECT * ob, long)
180 {
181     FormTabular * pre = static_cast<FormTabular*>(ob->form->u_vdata);
182     pre->hide();
183 }
184
185
186 void FormTabular::InputCB(FL_OBJECT * ob, long l)
187 {
188     FormTabular * pre = static_cast<FormTabular*>(ob->form->u_vdata);
189     pre->SetTabularOptions(ob, l);
190 }
191
192
193 bool FormTabular::local_update(bool)
194 {
195     if (!inset_ || !inset_->tabular)
196         return false;
197
198     LyXTabular
199         * tabular = inset_->tabular;
200     int
201         align,
202         cell,
203         column,row;
204     char
205         buf[12];
206     string
207         pwidth, special;
208
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);
246         else
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);
262         else
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,
276                                FL_BLACK);
277             fl_activate_object(cell_options_->input_mcolumn_width);
278             fl_set_object_lcol(cell_options_->input_mcolumn_width, FL_BLACK);
279         }
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);
293         } else {
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);
306         }
307     } else {
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);
345     }
346     if (tabular->GetRotateCell(cell))
347         fl_set_button(cell_options_->radio_rotate_cell, 1);
348     else
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);
352     else
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);
356     else
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);
360     else
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);
364     else
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);
370     else
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);
376     } else {
377         fl_activate_object(column_options_->input_column_width);
378     }
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);
384         else
385             fl_set_button(cell_options_->radio_useminipage, 0);
386     } else {
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);
390     }
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);
399     else
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);
409     else
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);
424     } else {
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);
437     }
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);
451         int dummy;
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));
462     } else {
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);
478     }
479     fl_set_button(tabular_options_->radio_rotate_tabular,
480                   tabular->GetRotateTabular());
481     return true;
482 }
483
484 void FormTabular::SetTabularOptions(FL_OBJECT * ob, long)
485 {
486     if (!inset_)
487         return;
488
489     LyXTabular
490         * tabular = inset_->tabular;
491     int
492         cell,
493         s,
494         num = 0;
495     string
496         special,
497         str;
498
499     cell = inset_->GetActCell();
500     if (actCell_ != cell) {
501         local_update(false);
502         fl_set_object_label(dialog_->text_warning,
503                      _("Warning: Wrong Cursor position, updated window"));
504         fl_show_object(dialog_->text_warning);
505         return;
506     }
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()) {
510       local_update(false);
511       return;
512     }
513     if (ob == column_options_->input_column_width) {
514         string
515             str;
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);
521             return;
522         }
523         inset_->TabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH,str);
524         local_update(false); // update for alignment
525         return;
526     }
527     if (ob == cell_options_->input_mcolumn_width) {
528         string
529             str;
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);
535             return;
536         }
537         inset_->TabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH,str);
538         local_update(false); // update for alignment
539         return;
540     }
541     str = fl_get_input(column_options_->input_column_width);
542     if (!str.empty() && !isValidLength(str)) {
543         fl_set_object_label(
544             dialog_->text_warning,
545             _("Warning: Invalid Length (valid example: 10mm)"));
546         fl_show_object(dialog_->text_warning);
547         return;
548     }
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);
585         if (s) {
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);
592             int dummy;
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));
603         } else {
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,
616                                FL_INACTIVE);
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,
620                                FL_INACTIVE);
621             fl_set_object_lcol(longtable_options_->radio_lt_newpage,
622                                FL_INACTIVE);
623         }
624     } else if (ob == tabular_options_->radio_rotate_tabular) {
625         s=fl_get_button(tabular_options_->radio_rotate_tabular);
626         if (s)
627             num = LyXTabular::SET_ROTATE_TABULAR;
628         else
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);
632         if (s)
633             num = LyXTabular::SET_ROTATE_CELL;
634         else
635             num = LyXTabular::UNSET_ROTATE_CELL;
636     } else if (ob == cell_options_->radio_useminipage) {
637         num = LyXTabular::SET_USEBOX;
638         special = "2";
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;
675     else
676         return;
677     
678     inset_->TabularFeatures(lv_->view(), num, special);
679     local_update(false);
680 }
681
682 // +-----------------------------------------------------------------------+
683 // |          Functions/Dialogs for creating tabular insets                |
684 // +-----------------------------------------------------------------------+
685
686 void FormTabular::show_create()
687 {
688     if (!dialog_) {
689         build();
690     }
691     if (create_tabular_->form->visible) {
692         fl_raise_form(create_tabular_->form);
693     } else {
694         fl_show_form(create_tabular_->form,
695                      FL_PLACE_MOUSE | FL_FREE_SIZE,
696                      FL_FULLBORDER, _("Insert Tabular"));
697     }
698 }
699
700
701 void FormTabular::apply_create()
702 {
703     int
704         xsize,ysize;
705
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)) {
711         delete in;
712     }
713 //    comm->setMinibuffer(_("Tabular mode"));
714 }
715
716
717 void FormTabular::hide_create()
718 {
719     if (create_tabular_->form &&
720         create_tabular_->form->visible)
721         fl_hide_form(create_tabular_->form);
722 }
723
724
725 void FormTabular::OKCB(FL_OBJECT * ob, long)
726 {
727     FormTabular * pre = (FormTabular*)ob->form->u_vdata;
728     pre->apply_create();
729     pre->hide_create();
730 }
731
732
733 void FormTabular::ApplyCB(FL_OBJECT * ob, long)
734 {
735     FormTabular * pre = (FormTabular*)ob->form->u_vdata;
736     pre->apply_create();
737 }
738
739
740 void FormTabular::CancelCB(FL_OBJECT * ob, long)
741 {
742     FormTabular * pre = (FormTabular*)ob->form->u_vdata;
743     pre->hide_create();
744 }
745
746