1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2000 The LyX Team.
10 *======================================================*/
15 #pragma implementation
18 #include "lyx_gui_misc.h"
20 #include FORMS_H_LOCATION
21 #include XPM_H_LOCATION
23 #include "FormParagraph.h"
24 #include "form_paragraph.h"
25 #include "xform_macros.h"
27 #include "ButtonController.h"
30 #include "BufferView.h"
34 #ifdef SIGC_CXX_NAMESPACES
38 #ifdef CXX_WORKING_NAMESPACES
39 using Liason::setMinibuffer;
42 C_RETURNCB(FormParagraph, WMHideCB)
43 C_GENERICCB(FormParagraph, InputCB)
44 C_GENERICCB(FormParagraph, OKCB)
45 C_GENERICCB(FormParagraph, ApplyCB)
46 C_GENERICCB(FormParagraph, CancelCB)
47 C_GENERICCB(FormParagraph, RestoreCB)
48 C_GENERICCB(FormParagraph, VSpaceCB)
50 FormParagraph::FormParagraph(LyXView * lv, Dialogs * d)
51 : dialog_(0), general_(0), extra_(0),
52 lv_(lv), d_(d), u_(0), h_(0),
53 status(POPUP_UNMODIFIED),
54 // this will leak till converted to use FormBase
55 bc_(new ButtonController(new NoRepeatedApplyReadOnlyPolicy,
59 // let the popup be shown
60 // This is a permanent connection so we won't bother
61 // storing a copy because we won't be disconnecting.
62 d->showLayoutParagraph.connect(slot(this, &FormParagraph::show));
66 FormParagraph::~FormParagraph()
73 void FormParagraph::build()
76 dialog_ = build_tabbed_paragraph();
78 // manage the restore, ok, apply and cancel/close buttons
79 bc_->setOK(dialog_->button_ok);
80 bc_->setApply(dialog_->button_apply);
81 bc_->setCancel(dialog_->button_cancel);
82 bc_->setUndoAll(dialog_->button_restore);
85 // the general paragraph data form
86 general_ = build_paragraph_general();
88 fl_addto_choice(general_->choice_space_above,
89 _(" None | Defskip | Smallskip "
90 "| Medskip | Bigskip | VFill | Length "));
91 fl_addto_choice(general_->choice_space_below,
92 _(" None | Defskip | Smallskip "
93 "| Medskip | Bigskip | VFill | Length "));
95 fl_set_input_return(general_->input_space_above, FL_RETURN_CHANGED);
96 fl_set_input_return(general_->input_space_below, FL_RETURN_CHANGED);
97 fl_set_input_return(general_->input_labelwidth, FL_RETURN_CHANGED);
99 bc_->addReadOnly (general_->radio_align_right);
100 bc_->addReadOnly (general_->radio_align_left);
101 bc_->addReadOnly (general_->radio_align_block);
102 bc_->addReadOnly (general_->radio_align_center);
103 bc_->addReadOnly (general_->check_lines_top);
104 bc_->addReadOnly (general_->check_lines_bottom);
105 bc_->addReadOnly (general_->choice_space_above);
106 bc_->addReadOnly (general_->input_space_above);
107 bc_->addReadOnly (general_->check_space_above);
108 bc_->addReadOnly (general_->choice_space_below);
109 bc_->addReadOnly (general_->input_space_below);
110 bc_->addReadOnly (general_->check_space_below);
111 bc_->addReadOnly (general_->check_noindent);
112 bc_->addReadOnly (general_->input_labelwidth);
114 // the document class form
115 extra_ = build_paragraph_extra();
117 fl_set_input_return(extra_->input_pextra_width, FL_RETURN_CHANGED);
118 fl_set_input_return(extra_->input_pextra_widthp, FL_RETURN_CHANGED);
120 bc_->addReadOnly (extra_->radio_pextra_indent);
121 bc_->addReadOnly (extra_->radio_pextra_minipage);
122 bc_->addReadOnly (extra_->radio_pextra_floatflt);
124 // now make them fit together
125 fl_set_form_atclose(dialog_->form, C_FormParagraphWMHideCB, 0);
126 fl_addto_tabfolder(dialog_->tabbed_folder,_("General"), general_->form);
127 fl_addto_tabfolder(dialog_->tabbed_folder,_("Extra"), extra_->form);
131 void FormParagraph::show()
136 update(); // make sure its up-to-date
137 if (dialog_->form->visible) {
138 fl_raise_form(dialog_->form);
140 fl_show_form(dialog_->form, FL_PLACE_MOUSE | FL_FREE_SIZE,
141 FL_TRANSIENT, _("Paragraph Layout"));
142 u_ = d_->updateBufferDependent.connect(
143 slot(this, &FormParagraph::update));
144 h_ = d_->hideBufferDependent.connect(
145 slot(this, &FormParagraph::hide));
150 void FormParagraph::hide()
152 if (dialog_->form->visible) {
153 fl_hide_form(dialog_->form);
160 void FormParagraph::apply()
162 if (!lv_->view()->available() || !dialog_)
168 lv_->view()->update(BufferView::SELECT | BufferView::FITCUR |
170 lv_->buffer()->markDirty();
171 setMinibuffer(lv_, _("Paragraph layout set"));
175 void FormParagraph::general_apply()
177 VSpace space_top, space_bottom;
179 string labelwidthstring;
182 // If a vspace kind is "Length" but there's no text in
183 // the input field, reset the kind to "None".
184 if ((fl_get_choice (general_->choice_space_above) == 7) &&
185 !*(fl_get_input (general_->input_space_above)))
187 fl_set_choice (general_->choice_space_above, 1);
189 if ((fl_get_choice (general_->choice_space_below) == 7) &&
190 !*(fl_get_input (general_->input_space_below)))
192 fl_set_choice (general_->choice_space_below, 1);
195 bool line_top = fl_get_button(general_->check_lines_top);
196 bool line_bottom = fl_get_button(general_->check_lines_bottom);
197 bool pagebreak_top = fl_get_button(general_->check_pagebreaks_top);
198 bool pagebreak_bottom = fl_get_button(general_->check_pagebreaks_bottom);
200 switch (fl_get_choice (general_->choice_space_above)) {
202 space_top = VSpace(VSpace::NONE);
205 space_top = VSpace(VSpace::DEFSKIP);
208 space_top = VSpace(VSpace::SMALLSKIP);
211 space_top = VSpace(VSpace::MEDSKIP);
214 space_top = VSpace(VSpace::BIGSKIP);
217 space_top = VSpace(VSpace::VFILL);
220 space_top = VSpace(LyXGlueLength(fl_get_input(general_->input_space_above)));
223 if (fl_get_button (general_->check_space_above))
224 space_top.setKeep (true);
225 switch (fl_get_choice (general_->choice_space_below)) {
227 space_bottom = VSpace(VSpace::NONE);
230 space_bottom = VSpace(VSpace::DEFSKIP);
233 space_bottom = VSpace(VSpace::SMALLSKIP);
236 space_bottom = VSpace(VSpace::MEDSKIP);
239 space_bottom = VSpace(VSpace::BIGSKIP);
242 space_bottom = VSpace(VSpace::VFILL);
245 space_bottom = VSpace(LyXGlueLength(fl_get_input(general_->input_space_below)));
248 if (fl_get_button (general_->check_space_below))
249 space_bottom.setKeep (true);
251 if (fl_get_button(general_->radio_align_left))
252 align = LYX_ALIGN_LEFT;
253 else if (fl_get_button(general_->radio_align_right))
254 align = LYX_ALIGN_RIGHT;
255 else if (fl_get_button(general_->radio_align_center))
256 align = LYX_ALIGN_CENTER;
258 align = LYX_ALIGN_BLOCK;
260 labelwidthstring = fl_get_input(general_->input_labelwidth);
261 noindent = fl_get_button(general_->check_noindent);
264 if (lv_->view()->theLockingInset())
265 text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
267 text = lv_->view()->text;
268 text->SetParagraph(lv_->view(), line_top, line_bottom, pagebreak_top,
269 pagebreak_bottom, space_top, space_bottom, align,
270 labelwidthstring, noindent);
274 void FormParagraph::extra_apply()
276 char const * width = fl_get_input(extra_->input_pextra_width);
277 char const * widthp = fl_get_input(extra_->input_pextra_widthp);
278 LyXText * text = lv_->view()->text;
279 int type = LyXParagraph::PEXTRA_NONE;
280 LyXParagraph::MINIPAGE_ALIGNMENT
281 alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
284 start_minipage = false;
286 if (fl_get_button(extra_->radio_pextra_indent)) {
287 type = LyXParagraph::PEXTRA_INDENT;
288 } else if (fl_get_button(extra_->radio_pextra_minipage)) {
289 type = LyXParagraph::PEXTRA_MINIPAGE;
290 hfill = fl_get_button(extra_->radio_pextra_hfill);
291 start_minipage = fl_get_button(extra_->radio_pextra_startmp);
292 if (fl_get_button(extra_->radio_pextra_top))
293 alignment = LyXParagraph::MINIPAGE_ALIGN_TOP;
294 else if (fl_get_button(extra_->radio_pextra_middle))
295 alignment = LyXParagraph::MINIPAGE_ALIGN_MIDDLE;
296 else if (fl_get_button(extra_->radio_pextra_bottom))
297 alignment = LyXParagraph::MINIPAGE_ALIGN_BOTTOM;
298 } else if (fl_get_button(extra_->radio_pextra_floatflt)) {
299 type = LyXParagraph::PEXTRA_FLOATFLT;
301 text->SetParagraphExtraOpt(lv_->view(), type, width, widthp, alignment,
302 hfill, start_minipage);
306 void FormParagraph::cancel()
311 void FormParagraph::update()
321 void FormParagraph::general_update()
326 Buffer * buf = lv_->view()->buffer();
329 if (lv_->view()->theLockingInset())
330 text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
332 text = lv_->view()->text;
334 fl_set_input(general_->input_labelwidth,
335 text->cursor.par()->GetLabelWidthString().c_str());
336 fl_set_button(general_->radio_align_right, 0);
337 fl_set_button(general_->radio_align_left, 0);
338 fl_set_button(general_->radio_align_center, 0);
339 fl_set_button(general_->radio_align_block, 0);
341 int align = text->cursor.par()->GetAlign();
342 if (align == LYX_ALIGN_LAYOUT)
343 align = textclasslist.Style(buf->params.textclass,
344 text->cursor.par()->GetLayout()).align;
347 case LYX_ALIGN_RIGHT:
348 fl_set_button(general_->radio_align_right, 1);
351 fl_set_button(general_->radio_align_left, 1);
353 case LYX_ALIGN_CENTER:
354 fl_set_button(general_->radio_align_center, 1);
357 fl_set_button(general_->radio_align_block, 1);
362 fl_set_button(general_->check_lines_top,
363 text->cursor.par()->FirstPhysicalPar()->line_top);
365 fl_set_button(general_->check_lines_bottom,
366 text->cursor.par()->FirstPhysicalPar()->line_bottom);
368 fl_set_button(general_->check_pagebreaks_top,
369 text->cursor.par()->FirstPhysicalPar()->pagebreak_top);
371 fl_set_button(general_->check_pagebreaks_bottom,
372 text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom);
373 fl_set_button(general_->check_noindent,
374 text->cursor.par()->FirstPhysicalPar()->noindent);
376 fl_set_button(general_->check_lines_top,
377 text->cursor.par()->line_top);
378 fl_set_button(general_->check_lines_bottom,
379 text->cursor.par()->line_bottom);
380 fl_set_button(general_->check_pagebreaks_top,
381 text->cursor.par()->pagebreak_top);
382 fl_set_button(general_->check_pagebreaks_bottom,
383 text->cursor.par()->pagebreak_bottom);
384 fl_set_button(general_->check_noindent,
385 text->cursor.par()->noindent);
387 fl_set_input (general_->input_space_above, "");
390 switch (text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) {
392 switch (text->cursor.par()->added_space_top.kind()) {
396 fl_set_choice (general_->choice_space_above, 1);
398 case VSpace::DEFSKIP:
399 fl_set_choice (general_->choice_space_above, 2);
401 case VSpace::SMALLSKIP:
402 fl_set_choice (general_->choice_space_above, 3);
404 case VSpace::MEDSKIP:
405 fl_set_choice (general_->choice_space_above, 4);
407 case VSpace::BIGSKIP:
408 fl_set_choice (general_->choice_space_above, 5);
411 fl_set_choice (general_->choice_space_above, 6);
414 fl_set_choice (general_->choice_space_above, 7);
416 fl_set_input (general_->input_space_above,
417 text->cursor.par()->FirstPhysicalPar()->
418 added_space_top.length().asString().c_str());
420 fl_set_input (general_->input_space_above, text->cursor.par()->
421 added_space_top.length().asString().c_str());
426 fl_set_button(general_->check_space_above,
427 text->cursor.par()->FirstPhysicalPar()->
428 added_space_top.keep());
429 fl_set_input(general_->input_space_below, "");
430 switch (text->cursor.par()->FirstPhysicalPar()->
431 added_space_bottom.kind()) {
433 fl_set_button (general_->check_space_above,
434 text->cursor.par()->added_space_top.keep());
435 fl_set_input (general_->input_space_below, "");
436 switch (text->cursor.par()->added_space_bottom.kind()) {
439 fl_set_choice (general_->choice_space_below, 1);
441 case VSpace::DEFSKIP:
442 fl_set_choice (general_->choice_space_below, 2);
444 case VSpace::SMALLSKIP:
445 fl_set_choice (general_->choice_space_below, 3);
447 case VSpace::MEDSKIP:
448 fl_set_choice (general_->choice_space_below, 4);
450 case VSpace::BIGSKIP:
451 fl_set_choice (general_->choice_space_below, 5);
454 fl_set_choice (general_->choice_space_below, 6);
457 fl_set_choice (general_->choice_space_below, 7);
459 fl_set_input (general_->input_space_below,
460 text->cursor.par()->FirstPhysicalPar()->
461 added_space_bottom.length().asString().c_str());
464 fl_set_button(general_->check_space_below,
465 text->cursor.par()->FirstPhysicalPar()->
466 added_space_bottom.keep());
467 fl_set_button(general_->check_noindent,
468 text->cursor.par()->FirstPhysicalPar()->noindent);
469 if (text->cursor.par()->FirstPhysicalPar()->InInset()) {
470 fl_set_button(general_->check_pagebreaks_top, 0);
471 fl_deactivate_object(general_->check_pagebreaks_top);
472 fl_set_object_lcol(general_->check_pagebreaks_top, FL_INACTIVE);
473 fl_set_button(general_->check_pagebreaks_bottom, 0);
474 fl_deactivate_object(general_->check_pagebreaks_bottom);
475 fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_INACTIVE);
477 fl_activate_object(general_->check_pagebreaks_top);
478 fl_set_object_lcol(general_->check_pagebreaks_top, FL_BLACK);
479 fl_activate_object(general_->check_pagebreaks_bottom);
480 fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_BLACK);
483 fl_set_input(general_->input_space_below, text->cursor.par()->
484 added_space_bottom.length().asString().c_str());
487 fl_set_button(general_->check_space_below,
488 text->cursor.par()->added_space_bottom.keep());
489 fl_set_button(general_->check_noindent,
490 text->cursor.par()->noindent);
495 void FormParagraph::extra_update()
497 if (!lv_->view()->available() || !extra_)
500 LyXParagraph * par = lv_->view()->text->cursor.par();
502 fl_activate_object(extra_->input_pextra_width);
503 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
504 fl_activate_object(extra_->input_pextra_widthp);
505 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
506 fl_set_input(extra_->input_pextra_width,
507 par->pextra_width.c_str());
508 fl_set_input(extra_->input_pextra_widthp,
509 par->pextra_widthp.c_str());
510 switch(par->pextra_alignment) {
511 case LyXParagraph::MINIPAGE_ALIGN_TOP:
512 fl_set_button(extra_->radio_pextra_top, 1);
514 case LyXParagraph::MINIPAGE_ALIGN_MIDDLE:
515 fl_set_button(extra_->radio_pextra_middle, 1);
517 case LyXParagraph::MINIPAGE_ALIGN_BOTTOM:
518 fl_set_button(extra_->radio_pextra_bottom, 1);
521 fl_set_button(extra_->radio_pextra_hfill,
523 fl_set_button(extra_->radio_pextra_startmp,
524 par->pextra_start_minipage);
525 if (par->pextra_type == LyXParagraph::PEXTRA_INDENT) {
526 fl_set_button(extra_->radio_pextra_indent, 1);
527 fl_set_button(extra_->radio_pextra_minipage, 0);
528 fl_set_button(extra_->radio_pextra_floatflt, 0);
529 fl_deactivate_object(extra_->radio_pextra_top);
530 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
531 fl_deactivate_object(extra_->radio_pextra_middle);
532 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
533 fl_deactivate_object(extra_->radio_pextra_bottom);
534 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
535 CheckParagraphInput(extra_->radio_pextra_indent, 0);
536 } else if (par->pextra_type == LyXParagraph::PEXTRA_MINIPAGE) {
537 fl_set_button(extra_->radio_pextra_indent, 0);
538 fl_set_button(extra_->radio_pextra_minipage, 1);
539 fl_set_button(extra_->radio_pextra_floatflt, 0);
540 fl_activate_object(extra_->radio_pextra_top);
541 fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
542 fl_activate_object(extra_->radio_pextra_middle);
543 fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
544 fl_activate_object(extra_->radio_pextra_bottom);
545 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
546 CheckParagraphInput(extra_->radio_pextra_minipage, 0);
547 } else if (par->pextra_type == LyXParagraph::PEXTRA_FLOATFLT) {
548 fl_set_button(extra_->radio_pextra_indent, 0);
549 fl_set_button(extra_->radio_pextra_minipage, 0);
550 fl_set_button(extra_->radio_pextra_floatflt, 1);
551 fl_deactivate_object(extra_->radio_pextra_top);
552 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
553 fl_deactivate_object(extra_->radio_pextra_middle);
554 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
555 fl_deactivate_object(extra_->radio_pextra_bottom);
556 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
557 CheckParagraphInput(extra_->radio_pextra_floatflt, 0);
559 fl_set_button(extra_->radio_pextra_indent, 0);
560 fl_set_button(extra_->radio_pextra_minipage, 0);
561 fl_set_button(extra_->radio_pextra_floatflt, 0);
562 fl_deactivate_object(extra_->input_pextra_width);
563 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
564 fl_deactivate_object(extra_->input_pextra_widthp);
565 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
566 fl_deactivate_object(extra_->radio_pextra_top);
567 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
568 fl_deactivate_object(extra_->radio_pextra_middle);
569 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
570 fl_deactivate_object(extra_->radio_pextra_bottom);
571 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
572 CheckParagraphInput(0, 0);
574 fl_hide_object(dialog_->text_warning);
578 void FormParagraph::free()
583 // fl_free_form(general_->form);
588 // fl_free_form(extra_->form);
592 // fl_free_form(dialog_->form);
599 int FormParagraph::WMHideCB(FL_FORM * form, void *)
601 // Ensure that the signals (u and h) are disconnected even if the
602 // window manager is used to close the popup.
603 FormParagraph * pre = static_cast<FormParagraph*>(form->u_vdata);
610 void FormParagraph::OKCB(FL_OBJECT * ob, long)
612 FormParagraph * pre = static_cast<FormParagraph*>(ob->form->u_vdata);
619 void FormParagraph::ApplyCB(FL_OBJECT * ob, long)
621 FormParagraph * pre = static_cast<FormParagraph*>(ob->form->u_vdata);
627 void FormParagraph::CancelCB(FL_OBJECT * ob, long)
629 FormParagraph * pre = static_cast<FormParagraph*>(ob->form->u_vdata);
636 void FormParagraph::RestoreCB(FL_OBJECT * ob, long)
638 FormParagraph * pre = static_cast<FormParagraph*>(ob->form->u_vdata);
644 void FormParagraph::InputCB(FL_OBJECT * ob, long)
646 FormParagraph * pre = static_cast<FormParagraph*>(ob->form->u_vdata);
647 pre->bc_->valid(pre->CheckParagraphInput(ob,0));
651 void FormParagraph::VSpaceCB(FL_OBJECT * ob, long)
653 FormParagraph * pre = static_cast<FormParagraph*>(ob->form->u_vdata);
654 pre->bc_->valid(pre->CheckParagraphInput(ob,0));
658 bool FormParagraph::CheckParagraphInput(FL_OBJECT * ob, long)
662 fl_hide_object(dialog_->text_warning);
664 // First check the buttons which are exclusive and you have to
665 // check only the actuall de/activated button.
667 // general form first
669 // "Synchronize" the choices and input fields, making it
670 // impossible to commit senseless data.
671 if (ob == general_->choice_space_above) {
672 if (fl_get_choice (general_->choice_space_above) != 7)
673 fl_set_input (general_->input_space_above, "");
674 } else if (ob == general_->choice_space_below) {
675 if (fl_get_choice (general_->choice_space_below) != 7)
676 fl_set_input (general_->input_space_below, "");
679 // then the extra form
681 else if (ob == extra_->radio_pextra_indent) {
682 int n = fl_get_button(extra_->radio_pextra_indent);
684 fl_set_button(extra_->radio_pextra_minipage, 0);
685 fl_set_button(extra_->radio_pextra_floatflt, 0);
686 fl_activate_object(extra_->input_pextra_width);
687 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
688 fl_activate_object(extra_->input_pextra_widthp);
689 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
691 fl_deactivate_object(extra_->input_pextra_width);
692 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
693 fl_deactivate_object(extra_->input_pextra_widthp);
694 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
696 fl_deactivate_object(extra_->radio_pextra_top);
697 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
698 fl_deactivate_object(extra_->radio_pextra_middle);
699 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
700 fl_deactivate_object(extra_->radio_pextra_bottom);
701 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
702 fl_activate_object(extra_->radio_pextra_hfill);
703 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
704 fl_activate_object(extra_->radio_pextra_startmp);
705 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
706 } else if (ob == extra_->radio_pextra_minipage) {
707 int n = fl_get_button(extra_->radio_pextra_minipage);
709 fl_set_button(extra_->radio_pextra_indent, 0);
710 fl_set_button(extra_->radio_pextra_floatflt, 0);
711 fl_activate_object(extra_->input_pextra_width);
712 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
713 fl_activate_object(extra_->input_pextra_widthp);
714 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
715 fl_activate_object(extra_->radio_pextra_top);
716 fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK);
717 fl_activate_object(extra_->radio_pextra_middle);
718 fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK);
719 fl_activate_object(extra_->radio_pextra_bottom);
720 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK);
721 fl_activate_object(extra_->radio_pextra_hfill);
722 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_BLACK);
723 fl_activate_object(extra_->radio_pextra_startmp);
724 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_BLACK);
726 fl_deactivate_object(extra_->input_pextra_width);
727 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
728 fl_deactivate_object(extra_->input_pextra_widthp);
729 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
730 fl_deactivate_object(extra_->radio_pextra_top);
731 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
732 fl_deactivate_object(extra_->radio_pextra_middle);
733 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
734 fl_deactivate_object(extra_->radio_pextra_bottom);
735 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
736 fl_activate_object(extra_->radio_pextra_hfill);
737 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
738 fl_activate_object(extra_->radio_pextra_startmp);
739 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
741 } else if (ob == extra_->radio_pextra_floatflt) {
742 int n = fl_get_button(extra_->radio_pextra_floatflt);
744 fl_set_button(extra_->radio_pextra_indent, 0);
745 fl_set_button(extra_->radio_pextra_minipage, 0);
746 fl_activate_object(extra_->input_pextra_width);
747 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
748 fl_activate_object(extra_->input_pextra_widthp);
749 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
751 fl_deactivate_object(extra_->input_pextra_width);
752 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
753 fl_deactivate_object(extra_->input_pextra_widthp);
754 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
756 fl_deactivate_object(extra_->radio_pextra_top);
757 fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE);
758 fl_deactivate_object(extra_->radio_pextra_middle);
759 fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE);
760 fl_deactivate_object(extra_->radio_pextra_bottom);
761 fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE);
762 fl_activate_object(extra_->radio_pextra_hfill);
763 fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE);
764 fl_activate_object(extra_->radio_pextra_startmp);
765 fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE);
769 // first the general form
771 string input = fl_get_input (general_->input_space_above);
774 fl_set_choice (general_->choice_space_above, 1);
775 } else if (isValidGlueLength (input)) {
776 fl_set_choice (general_->choice_space_above, 7);
778 fl_set_choice (general_->choice_space_above, 7);
779 fl_set_object_label(dialog_->text_warning,
780 _("Warning: Invalid Length (valid example: 10mm)"));
781 fl_show_object(dialog_->text_warning);
785 input = fl_get_input (general_->input_space_below);
788 fl_set_choice (general_->choice_space_below, 1);
789 } else if (isValidGlueLength(input)) {
790 fl_set_choice (general_->choice_space_below, 7);
792 fl_set_choice (general_->choice_space_below, 7);
793 fl_set_object_label(dialog_->text_warning,
794 _("Warning: Invalid Length (valid example: 10mm)"));
795 fl_show_object(dialog_->text_warning);
799 // then the extra form
801 int n = fl_get_button(extra_->radio_pextra_indent) +
802 fl_get_button(extra_->radio_pextra_minipage) +
803 fl_get_button(extra_->radio_pextra_floatflt);
804 string s1 = fl_get_input(extra_->input_pextra_width);
805 string s2 = fl_get_input(extra_->input_pextra_widthp);
806 if (!n) { // no button pressed both should be deactivated now
807 fl_deactivate_object(extra_->input_pextra_width);
808 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
809 fl_deactivate_object(extra_->input_pextra_widthp);
810 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
811 fl_hide_object(dialog_->text_warning);
812 } else if (s1.empty() && s2.empty()) {
813 fl_activate_object(extra_->input_pextra_width);
814 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
815 fl_activate_object(extra_->input_pextra_widthp);
816 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
817 fl_hide_object(dialog_->text_warning);
819 } else if (!s1.empty()) { // LyXLength parameter
820 fl_activate_object(extra_->input_pextra_width);
821 fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK);
822 fl_deactivate_object(extra_->input_pextra_widthp);
823 fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE);
824 if (!isValidLength(s1)) {
825 fl_set_object_label(dialog_->text_warning,
826 _("Warning: Invalid Length (valid example: 10mm)"));
827 fl_show_object(dialog_->text_warning);
830 } else { // !s2.empty() % parameter
831 fl_deactivate_object(extra_->input_pextra_width);
832 fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE);
833 fl_activate_object(extra_->input_pextra_widthp);
834 fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK);
835 if ((atoi(s2.c_str()) < 0 ) || (atoi(s2.c_str()) > 100)) {
837 fl_set_object_label(dialog_->text_warning,
838 _("Warning: Invalid percent value (0-100)"));
839 fl_show_object(dialog_->text_warning);