X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FFormParagraph.C;h=66e2b819e701a5e399fe4f7df3e7e7c5f2c2a576;hb=eba67bc3120dc301bf193c3f3b570f51f00a4654;hp=32dec9b53795df904127b710d12269a52a93f9ae;hpb=e1cd54a1a23175d6ef84dd00609c96ed1470438c;p=lyx.git diff --git a/src/frontends/xforms/FormParagraph.C b/src/frontends/xforms/FormParagraph.C index 32dec9b537..66e2b819e7 100644 --- a/src/frontends/xforms/FormParagraph.C +++ b/src/frontends/xforms/FormParagraph.C @@ -15,44 +15,24 @@ #pragma implementation #endif -#include "lyx_gui_misc.h" -#include "gettext.h" #include FORMS_H_LOCATION -#include XPM_H_LOCATION #include "FormParagraph.h" #include "form_paragraph.h" -#include "xform_macros.h" #include "Dialogs.h" -#include "ButtonController.h" #include "Liason.h" #include "LyXView.h" -#include "BufferView.h" #include "buffer.h" #include "lyxtext.h" -#ifdef SIGC_CXX_NAMESPACES -using SigC::slot; -#endif - #ifdef CXX_WORKING_NAMESPACES using Liason::setMinibuffer; #endif -C_RETURNCB(FormParagraph, WMHideCB) -C_GENERICCB(FormParagraph, InputCB) -C_GENERICCB(FormParagraph, OKCB) -C_GENERICCB(FormParagraph, ApplyCB) -C_GENERICCB(FormParagraph, CancelCB) -C_GENERICCB(FormParagraph, RestoreCB) -C_GENERICCB(FormParagraph, VSpaceCB) - FormParagraph::FormParagraph(LyXView * lv, Dialogs * d) - : dialog_(0), general_(0), extra_(0), - lv_(lv), d_(d), u_(0), h_(0), - status(POPUP_UNMODIFIED) , - bc_(new ButtonController(_("Cancel"), - _("Close"))) + : FormBaseBD(lv, d, _("Paragraph Layout"), + new NoRepeatedApplyReadOnlyPolicy), + dialog_(0), general_(0), extra_(0) { // let the popup be shown // This is a permanent connection so we won't bother @@ -63,8 +43,29 @@ FormParagraph::FormParagraph(LyXView * lv, Dialogs * d) FormParagraph::~FormParagraph() { - free(); - delete bc_; + delete general_; + delete extra_; + delete dialog_; +} + + +void FormParagraph::redraw() +{ + if( form() && form()->visible ) + fl_redraw_form( form() ); + else + return; + + FL_FORM * outer_form = fl_get_active_folder(dialog_->tabbed_folder); + if (outer_form && outer_form->visible) + fl_redraw_form( outer_form ); +} + + +FL_FORM * FormParagraph::form() const +{ + if (dialog_) return dialog_->form; + return 0; } @@ -73,12 +74,16 @@ void FormParagraph::build() // the tabbed folder dialog_ = build_tabbed_paragraph(); - // manage the restore, ok, apply and cancel/close buttons - bc_->setOK(dialog_->button_ok); - bc_->setApply(dialog_->button_apply); - bc_->setCancel(dialog_->button_cancel); - bc_->setUndoAll(dialog_->button_restore); - bc_->refresh(); + // Workaround dumb xforms sizing bug + minw_ = form()->w; + minh_ = form()->h; + + // Manage the ok, apply, restore and cancel/close buttons + bc_.setOK(dialog_->button_ok); + bc_.setApply(dialog_->button_apply); + bc_.setCancel(dialog_->button_cancel); + bc_.setUndoAll(dialog_->button_restore); + bc_.refresh(); // the general paragraph data form general_ = build_paragraph_general(); @@ -94,22 +99,22 @@ void FormParagraph::build() fl_set_input_return(general_->input_space_below, FL_RETURN_CHANGED); fl_set_input_return(general_->input_labelwidth, FL_RETURN_CHANGED); - bc_->addReadOnly (general_->radio_align_right); - bc_->addReadOnly (general_->radio_align_left); - bc_->addReadOnly (general_->radio_align_block); - bc_->addReadOnly (general_->radio_align_center); - bc_->addReadOnly (general_->check_lines_top); - bc_->addReadOnly (general_->check_lines_bottom); - bc_->addReadOnly (general_->check_pagebreaks_top); - bc_->addReadOnly (general_->check_pagebreaks_bottom); - bc_->addReadOnly (general_->choice_space_above); - bc_->addReadOnly (general_->input_space_above); - bc_->addReadOnly (general_->check_space_above); - bc_->addReadOnly (general_->choice_space_below); - bc_->addReadOnly (general_->input_space_below); - bc_->addReadOnly (general_->check_space_below); - bc_->addReadOnly (general_->check_noindent); - bc_->addReadOnly (general_->input_labelwidth); + bc_.addReadOnly (general_->radio_align_right); + bc_.addReadOnly (general_->radio_align_left); + bc_.addReadOnly (general_->radio_align_block); + bc_.addReadOnly (general_->radio_align_center); + bc_.addReadOnly (general_->check_lines_top); + bc_.addReadOnly (general_->check_lines_bottom); + bc_.addReadOnly (general_->check_pagebreaks_top); + bc_.addReadOnly (general_->check_pagebreaks_bottom); + bc_.addReadOnly (general_->choice_space_above); + bc_.addReadOnly (general_->input_space_above); + bc_.addReadOnly (general_->check_space_above); + bc_.addReadOnly (general_->choice_space_below); + bc_.addReadOnly (general_->input_space_below); + bc_.addReadOnly (general_->check_space_below); + bc_.addReadOnly (general_->check_noindent); + bc_.addReadOnly (general_->input_labelwidth); // the document class form extra_ = build_paragraph_extra(); @@ -117,53 +122,18 @@ void FormParagraph::build() fl_set_input_return(extra_->input_pextra_width, FL_RETURN_CHANGED); fl_set_input_return(extra_->input_pextra_widthp, FL_RETURN_CHANGED); - bc_->addReadOnly (extra_->radio_pextra_indent); - bc_->addReadOnly (extra_->radio_pextra_minipage); - bc_->addReadOnly (extra_->radio_pextra_floatflt); - bc_->addReadOnly (extra_->input_pextra_width); - bc_->addReadOnly (extra_->input_pextra_widthp); - bc_->addReadOnly (extra_->radio_pextra_top); - bc_->addReadOnly (extra_->radio_pextra_middle); - bc_->addReadOnly (extra_->radio_pextra_bottom); - bc_->addReadOnly (extra_->radio_pextra_hfill); - bc_->addReadOnly (extra_->radio_pextra_startmp); + bc_.addReadOnly (extra_->radio_pextra_indent); + bc_.addReadOnly (extra_->radio_pextra_minipage); + bc_.addReadOnly (extra_->radio_pextra_floatflt); + bc_.addReadOnly (extra_->radio_pextra_hfill); + bc_.addReadOnly (extra_->radio_pextra_startmp); // now make them fit together - fl_set_form_atclose(dialog_->form, C_FormParagraphWMHideCB, 0); fl_addto_tabfolder(dialog_->tabbed_folder,_("General"), general_->form); fl_addto_tabfolder(dialog_->tabbed_folder,_("Extra"), extra_->form); } -void FormParagraph::show() -{ - if (!dialog_) - build(); - - update(); // make sure its up-to-date - if (dialog_->form->visible) { - fl_raise_form(dialog_->form); - } else { - fl_show_form(dialog_->form, FL_PLACE_MOUSE | FL_FREE_SIZE, - FL_TRANSIENT, _("Paragraph Layout")); - u_ = d_->updateBufferDependent.connect( - slot(this, &FormParagraph::update)); - h_ = d_->hideBufferDependent.connect( - slot(this, &FormParagraph::hide)); - } -} - - -void FormParagraph::hide() -{ - if (dialog_->form->visible) { - fl_hide_form(dialog_->form); - u_.disconnect(); - h_.disconnect(); - } -} - - void FormParagraph::apply() { if (!lv_->view()->available() || !dialog_) @@ -179,6 +149,17 @@ void FormParagraph::apply() } +void FormParagraph::update() +{ + if (!dialog_) + return; + + general_update(); + extra_update(); + bc_.readOnly(lv_->buffer()->isReadonly()); +} + + void FormParagraph::general_apply() { VSpace space_top, space_bottom; @@ -224,7 +205,8 @@ void FormParagraph::general_apply() space_top = VSpace(VSpace::VFILL); break; case 7: - space_top = VSpace(LyXGlueLength(fl_get_input(general_->input_space_above))); + space_top = + VSpace(LyXGlueLength(fl_get_input(general_->input_space_above))); break; } if (fl_get_button (general_->check_space_above)) @@ -249,7 +231,8 @@ void FormParagraph::general_apply() space_bottom = VSpace(VSpace::VFILL); break; case 7: - space_bottom = VSpace(LyXGlueLength(fl_get_input(general_->input_space_below))); + space_bottom = + VSpace(LyXGlueLength(fl_get_input(general_->input_space_below))); break; } if (fl_get_button (general_->check_space_below)) @@ -268,8 +251,8 @@ void FormParagraph::general_apply() noindent = fl_get_button(general_->check_noindent); LyXText * text = 0; - if (lv_->view()->the_locking_inset) - text = lv_->view()->the_locking_inset->getLyXText(lv_->view()); + if (lv_->view()->theLockingInset()) + text = lv_->view()->theLockingInset()->getLyXText(lv_->view()); if (!text) text = lv_->view()->text; text->SetParagraph(lv_->view(), line_top, line_bottom, pagebreak_top, @@ -310,21 +293,6 @@ void FormParagraph::extra_apply() } -void FormParagraph::cancel() -{ -} - - -void FormParagraph::update() -{ - if (!dialog_) - return; - - general_update(); - extra_update(); -} - - void FormParagraph::general_update() { if (!general_) @@ -333,8 +301,8 @@ void FormParagraph::general_update() Buffer * buf = lv_->view()->buffer(); LyXText * text = 0; - if (lv_->view()->the_locking_inset) - text = lv_->view()->the_locking_inset->getLyXText(lv_->view()); + if (lv_->view()->theLockingInset()) + text = lv_->view()->theLockingInset()->getLyXText(lv_->view()); if (!text) text = lv_->view()->text; @@ -420,12 +388,12 @@ void FormParagraph::general_update() case VSpace::LENGTH: fl_set_choice (general_->choice_space_above, 7); #ifndef NEW_INSETS - fl_set_input (general_->input_space_above, - text->cursor.par()->FirstPhysicalPar()-> - added_space_top.length().asString().c_str()); + fl_set_input(general_->input_space_above, + text->cursor.par()->FirstPhysicalPar()-> + added_space_top.length().asString().c_str()); #else - fl_set_input (general_->input_space_above, text->cursor.par()-> - added_space_top.length().asString().c_str()); + fl_set_input(general_->input_space_above, text->cursor.par()-> + added_space_top.length().asString().c_str()); #endif break; } @@ -463,9 +431,9 @@ void FormParagraph::general_update() case VSpace::LENGTH: fl_set_choice (general_->choice_space_below, 7); #ifndef NEW_INSETS - fl_set_input (general_->input_space_below, - text->cursor.par()->FirstPhysicalPar()-> - added_space_bottom.length().asString().c_str()); + fl_set_input(general_->input_space_below, + text->cursor.par()->FirstPhysicalPar()-> + added_space_bottom.length().asString().c_str()); break; } fl_set_button(general_->check_space_below, @@ -473,6 +441,19 @@ void FormParagraph::general_update() added_space_bottom.keep()); fl_set_button(general_->check_noindent, text->cursor.par()->FirstPhysicalPar()->noindent); + if (text->cursor.par()->FirstPhysicalPar()->InInset()) { + fl_set_button(general_->check_pagebreaks_top, 0); + fl_deactivate_object(general_->check_pagebreaks_top); + fl_set_object_lcol(general_->check_pagebreaks_top, FL_INACTIVE); + fl_set_button(general_->check_pagebreaks_bottom, 0); + fl_deactivate_object(general_->check_pagebreaks_bottom); + fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_INACTIVE); + } else { + fl_activate_object(general_->check_pagebreaks_top); + fl_set_object_lcol(general_->check_pagebreaks_top, FL_BLACK); + fl_activate_object(general_->check_pagebreaks_bottom); + fl_set_object_lcol(general_->check_pagebreaks_bottom, FL_BLACK); + } #else fl_set_input(general_->input_space_below, text->cursor.par()-> added_space_bottom.length().asString().c_str()); @@ -494,12 +475,14 @@ void FormParagraph::extra_update() LyXParagraph * par = lv_->view()->text->cursor.par(); fl_activate_object(extra_->input_pextra_width); + fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK); fl_activate_object(extra_->input_pextra_widthp); + fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK); fl_set_input(extra_->input_pextra_width, par->pextra_width.c_str()); fl_set_input(extra_->input_pextra_widthp, par->pextra_widthp.c_str()); - switch(par->pextra_alignment) { + switch (par->pextra_alignment) { case LyXParagraph::MINIPAGE_ALIGN_TOP: fl_set_button(extra_->radio_pextra_top, 1); break; @@ -514,193 +497,239 @@ void FormParagraph::extra_update() par->pextra_hfill); fl_set_button(extra_->radio_pextra_startmp, par->pextra_start_minipage); -// CheckInputWidth(); if (par->pextra_type == LyXParagraph::PEXTRA_INDENT) { fl_set_button(extra_->radio_pextra_indent, 1); fl_set_button(extra_->radio_pextra_minipage, 0); fl_set_button(extra_->radio_pextra_floatflt, 0); fl_deactivate_object(extra_->radio_pextra_top); + fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE); fl_deactivate_object(extra_->radio_pextra_middle); + fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE); fl_deactivate_object(extra_->radio_pextra_bottom); + fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE); + input(extra_->radio_pextra_indent, 0); } else if (par->pextra_type == LyXParagraph::PEXTRA_MINIPAGE) { fl_set_button(extra_->radio_pextra_indent, 0); fl_set_button(extra_->radio_pextra_minipage, 1); fl_set_button(extra_->radio_pextra_floatflt, 0); fl_activate_object(extra_->radio_pextra_top); + fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK); fl_activate_object(extra_->radio_pextra_middle); + fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK); fl_activate_object(extra_->radio_pextra_bottom); + fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK); + input(extra_->radio_pextra_minipage, 0); } else if (par->pextra_type == LyXParagraph::PEXTRA_FLOATFLT) { fl_set_button(extra_->radio_pextra_indent, 0); fl_set_button(extra_->radio_pextra_minipage, 0); fl_set_button(extra_->radio_pextra_floatflt, 1); fl_deactivate_object(extra_->radio_pextra_top); + fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE); fl_deactivate_object(extra_->radio_pextra_middle); + fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE); fl_deactivate_object(extra_->radio_pextra_bottom); + fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE); + input(extra_->radio_pextra_floatflt, 0); } else { fl_set_button(extra_->radio_pextra_indent, 0); fl_set_button(extra_->radio_pextra_minipage, 0); + fl_set_button(extra_->radio_pextra_floatflt, 0); fl_deactivate_object(extra_->input_pextra_width); + fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE); fl_deactivate_object(extra_->input_pextra_widthp); + fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE); fl_deactivate_object(extra_->radio_pextra_top); + fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE); fl_deactivate_object(extra_->radio_pextra_middle); + fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE); fl_deactivate_object(extra_->radio_pextra_bottom); + fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE); + input(0, 0); } -// if (par->pextra_type == LyXParagraph::PEXTRA_NONE) -// ActivateParagraphExtraButtons(); - - fl_hide_object(extra_->text_warning); -} - - -void FormParagraph::free() -{ - if (dialog_) { - hide(); - if (general_) { -// fl_free_form(general_->form); - delete general_; - general_ = 0; - } - if (extra_) { -// fl_free_form(extra_->form); - delete extra_; - extra_ = 0; - } -// fl_free_form(dialog_->form); - delete dialog_; - dialog_ = 0; - } -} - - -int FormParagraph::WMHideCB(FL_FORM * form, void *) -{ - // Ensure that the signals (u and h) are disconnected even if the - // window manager is used to close the popup. - FormParagraph * pre = static_cast(form->u_vdata); - pre->hide(); - pre->bc_->hide(); - return FL_CANCEL; + fl_hide_object(dialog_->text_warning); } -void FormParagraph::OKCB(FL_OBJECT * ob, long) -{ - FormParagraph * pre = static_cast(ob->form->u_vdata); - pre->apply(); - pre->hide(); - pre->bc_->ok(); -} - - -void FormParagraph::ApplyCB(FL_OBJECT * ob, long) -{ - FormParagraph * pre = static_cast(ob->form->u_vdata); - pre->apply(); - pre->bc_->apply(); -} - - -void FormParagraph::CancelCB(FL_OBJECT * ob, long) -{ - FormParagraph * pre = static_cast(ob->form->u_vdata); - pre->cancel(); - pre->hide(); - pre->bc_->cancel(); -} - - -void FormParagraph::RestoreCB(FL_OBJECT * ob, long) -{ - FormParagraph * pre = static_cast(ob->form->u_vdata); - pre->update(); - pre->bc_->undoAll(); -} - - -void FormParagraph::InputCB(FL_OBJECT * ob, long) -{ - FormParagraph * pre = static_cast(ob->form->u_vdata); - pre->bc_->valid(pre->CheckParagraphInput(ob,0)); -} - - -void FormParagraph::VSpaceCB(FL_OBJECT * ob, long) -{ - FormParagraph * pre = static_cast(ob->form->u_vdata); - pre->bc_->valid(pre->CheckParagraphInput(ob,0)); -} - - -bool FormParagraph::CheckParagraphInput(FL_OBJECT * ob, long) +bool FormParagraph::input(FL_OBJECT * ob, long) { bool ret = true; - fl_hide_object(extra_->text_warning); + fl_hide_object(dialog_->text_warning); + // First check the buttons which are exclusive and you have to + // check only the actuall de/activated button. // - // first the general form + // general form first // // "Synchronize" the choices and input fields, making it // impossible to commit senseless data. - if (ob == general_->choice_space_above) { - if (fl_get_choice (general_->choice_space_above) != 7) - fl_set_input (general_->input_space_above, ""); - } else if (ob == general_->choice_space_below) { - if (fl_get_choice (general_->choice_space_below) != 7) - fl_set_input (general_->input_space_below, ""); + + if (fl_get_choice (general_->choice_space_above) != 7) + fl_set_input (general_->input_space_above, ""); + + if (fl_get_choice (general_->choice_space_below) != 7) + fl_set_input (general_->input_space_below, ""); + + // + // then the extra form + // + if (ob == extra_->radio_pextra_indent) { + int n = fl_get_button(extra_->radio_pextra_indent); + if (n) { + fl_set_button(extra_->radio_pextra_minipage, 0); + fl_set_button(extra_->radio_pextra_floatflt, 0); + fl_activate_object(extra_->input_pextra_width); + fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK); + fl_activate_object(extra_->input_pextra_widthp); + fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK); + } else { + fl_deactivate_object(extra_->input_pextra_width); + fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE); + fl_deactivate_object(extra_->input_pextra_widthp); + fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE); + } + fl_deactivate_object(extra_->radio_pextra_top); + fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE); + fl_deactivate_object(extra_->radio_pextra_middle); + fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE); + fl_deactivate_object(extra_->radio_pextra_bottom); + fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE); + fl_activate_object(extra_->radio_pextra_hfill); + fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE); + fl_activate_object(extra_->radio_pextra_startmp); + fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE); + } else if (ob == extra_->radio_pextra_minipage) { + int n = fl_get_button(extra_->radio_pextra_minipage); + if (n) { + fl_set_button(extra_->radio_pextra_indent, 0); + fl_set_button(extra_->radio_pextra_floatflt, 0); + fl_activate_object(extra_->input_pextra_width); + fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK); + fl_activate_object(extra_->input_pextra_widthp); + fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK); + fl_activate_object(extra_->radio_pextra_top); + fl_set_object_lcol(extra_->radio_pextra_top, FL_BLACK); + fl_activate_object(extra_->radio_pextra_middle); + fl_set_object_lcol(extra_->radio_pextra_middle, FL_BLACK); + fl_activate_object(extra_->radio_pextra_bottom); + fl_set_object_lcol(extra_->radio_pextra_bottom, FL_BLACK); + fl_activate_object(extra_->radio_pextra_hfill); + fl_set_object_lcol(extra_->radio_pextra_hfill, FL_BLACK); + fl_activate_object(extra_->radio_pextra_startmp); + fl_set_object_lcol(extra_->radio_pextra_startmp, FL_BLACK); + } else { + fl_deactivate_object(extra_->input_pextra_width); + fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE); + fl_deactivate_object(extra_->input_pextra_widthp); + fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE); + fl_deactivate_object(extra_->radio_pextra_top); + fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE); + fl_deactivate_object(extra_->radio_pextra_middle); + fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE); + fl_deactivate_object(extra_->radio_pextra_bottom); + fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE); + fl_activate_object(extra_->radio_pextra_hfill); + fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE); + fl_activate_object(extra_->radio_pextra_startmp); + fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE); + } + } else if (ob == extra_->radio_pextra_floatflt) { + int n = fl_get_button(extra_->radio_pextra_floatflt); + if (n) { + fl_set_button(extra_->radio_pextra_indent, 0); + fl_set_button(extra_->radio_pextra_minipage, 0); + fl_activate_object(extra_->input_pextra_width); + fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK); + fl_activate_object(extra_->input_pextra_widthp); + fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK); + } else { + fl_deactivate_object(extra_->input_pextra_width); + fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE); + fl_deactivate_object(extra_->input_pextra_widthp); + fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE); + } + fl_deactivate_object(extra_->radio_pextra_top); + fl_set_object_lcol(extra_->radio_pextra_top, FL_INACTIVE); + fl_deactivate_object(extra_->radio_pextra_middle); + fl_set_object_lcol(extra_->radio_pextra_middle, FL_INACTIVE); + fl_deactivate_object(extra_->radio_pextra_bottom); + fl_set_object_lcol(extra_->radio_pextra_bottom, FL_INACTIVE); + fl_activate_object(extra_->radio_pextra_hfill); + fl_set_object_lcol(extra_->radio_pextra_hfill, FL_INACTIVE); + fl_activate_object(extra_->radio_pextra_startmp); + fl_set_object_lcol(extra_->radio_pextra_startmp, FL_INACTIVE); } + // + // first the general form + // string input = fl_get_input (general_->input_space_above); + bool invalid = false; - if (input.empty()) { - fl_set_choice (general_->choice_space_above, 1); - } else if (isValidGlueLength (input)) { - fl_set_choice (general_->choice_space_above, 7); - } else { - fl_set_choice (general_->choice_space_above, 7); - ret = false; - } - + if (fl_get_choice(general_->choice_space_above)==7) + invalid = !input.empty() && !isValidGlueLength(input); + input = fl_get_input (general_->input_space_below); - - if (input.empty()) { - fl_set_choice (general_->choice_space_below, 1); - } else if (isValidGlueLength (input)) { - fl_set_choice (general_->choice_space_below, 7); - } else { - fl_set_choice (general_->choice_space_below, 7); - ret = false; + + if (fl_get_choice(general_->choice_space_below)==7) + invalid = invalid || (!input.empty() && !isValidGlueLength(input)); + + if (ob == general_->input_space_above || ob == general_->input_space_below) { + if (invalid) { + fl_set_object_label(dialog_->text_warning, + _("Warning: Invalid Length (valid example: 10mm)")); + fl_show_object(dialog_->text_warning); + return false; + } else { + fl_hide_object(dialog_->text_warning); + return true; + } } + // // then the extra form // + int n = fl_get_button(extra_->radio_pextra_indent) + + fl_get_button(extra_->radio_pextra_minipage) + + fl_get_button(extra_->radio_pextra_floatflt); string s1 = fl_get_input(extra_->input_pextra_width); string s2 = fl_get_input(extra_->input_pextra_widthp); - if (s1.empty() && s2.empty()) { + if (!n) { // no button pressed both should be deactivated now + fl_deactivate_object(extra_->input_pextra_width); + fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE); + fl_deactivate_object(extra_->input_pextra_widthp); + fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE); + fl_hide_object(dialog_->text_warning); + } else if (s1.empty() && s2.empty()) { fl_activate_object(extra_->input_pextra_width); + fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK); fl_activate_object(extra_->input_pextra_widthp); - fl_hide_object(extra_->text_warning); + fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK); + fl_hide_object(dialog_->text_warning); ret = false; - } - if (!s1.empty()) { // LyXLength parameter + } else if (!s1.empty()) { // LyXLength parameter fl_activate_object(extra_->input_pextra_width); + fl_set_object_lcol(extra_->input_pextra_width, FL_BLACK); fl_deactivate_object(extra_->input_pextra_widthp); + fl_set_object_lcol(extra_->input_pextra_widthp, FL_INACTIVE); if (!isValidLength(s1)) { - fl_set_object_label(extra_->text_warning, - _("Warning: Invalid Length (valid example: 10mm)")); - fl_show_object(extra_->text_warning); + fl_set_object_label(dialog_->text_warning, + _("Warning: Invalid Length (valid example: 10mm)")); + fl_show_object(dialog_->text_warning); ret = false; } } else { // !s2.empty() % parameter fl_deactivate_object(extra_->input_pextra_width); + fl_set_object_lcol(extra_->input_pextra_width, FL_INACTIVE); fl_activate_object(extra_->input_pextra_widthp); - if ((atoi(s2.c_str()) < 0 ) || (atoi(s2.c_str()) > 100)) { + fl_set_object_lcol(extra_->input_pextra_widthp, FL_BLACK); + if ((lyx::atoi(s2) < 0 ) || (lyx::atoi(s2) > 100)) { ret = false; - fl_set_object_label(extra_->text_warning, - _("Warning: Invalid percent value (0-100)")); - fl_show_object(extra_->text_warning); + fl_set_object_label(dialog_->text_warning, + _("Warning: Invalid percent value (0-100)")); + fl_show_object(dialog_->text_warning); } } return ret; } +