X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FFormUrl.C;h=f14e32633935b742d2cc2cd49c23a67636d7f046;hb=eba67bc3120dc301bf193c3f3b570f51f00a4654;hp=f0495b546b489000584a59c80c6172b50636aab8;hpb=612a097878de07556b76f7445a5564320987ff97;p=lyx.git diff --git a/src/frontends/xforms/FormUrl.C b/src/frontends/xforms/FormUrl.C index f0495b546b..f14e326339 100644 --- a/src/frontends/xforms/FormUrl.C +++ b/src/frontends/xforms/FormUrl.C @@ -18,7 +18,6 @@ #endif -#include "gettext.h" #include "Dialogs.h" #include "FormUrl.h" #include "LyXView.h" @@ -27,9 +26,9 @@ #include "lyxfunc.h" FormUrl::FormUrl(LyXView * lv, Dialogs * d) - : FormCommand(lv, d, _("Url")), dialog_(0) + : FormCommand(lv, d, _("Url"), new NoRepeatedApplyReadOnlyPolicy), + dialog_(0) { - dialog_ = 0; // let the dialog be shown // These are permanent connections so we won't bother // storing a copy because we won't be disconnecting. @@ -40,29 +39,45 @@ FormUrl::FormUrl(LyXView * lv, Dialogs * d) FormUrl::~FormUrl() { - free(); delete dialog_; } +FL_FORM * FormUrl::form() const +{ + if (dialog_) return dialog_->form; + return 0; +} + + +void FormUrl::connect() +{ + fl_set_form_maxsize(form(), 2 * minw_, minh_); + FormCommand::connect(); +} + + void FormUrl::build() { dialog_ = build_url(); - int w = form()->w; - int h = form()->h; + // Workaround dumb xforms sizing bug + minw_ = form()->w; + minh_ = form()->h; - fl_set_form_minsize(form(), w, h); - fl_set_form_maxsize(form(), 2*w, h); -} + fl_set_input_return(dialog_->name, FL_RETURN_CHANGED); + fl_set_input_return(dialog_->url, FL_RETURN_CHANGED); + // 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(); -FL_FORM * const FormUrl::form() const -{ - if( dialog_ ) // no need to test for dialog_->form_url - return dialog_->form_url; - else - return 0; + bc_.addReadOnly(dialog_->name); + bc_.addReadOnly(dialog_->url); + bc_.addReadOnly(dialog_->radio_html); } @@ -71,48 +86,35 @@ void FormUrl::update() fl_set_input(dialog_->url, params.getContents().c_str()); fl_set_input(dialog_->name, params.getOptions().c_str()); - if ( params.getCmdName() == "url" ) + if (params.getCmdName() == "url") fl_set_button(dialog_->radio_html, 0); else fl_set_button(dialog_->radio_html, 1); - if( lv_->buffer()->isReadonly() ) { - fl_deactivate_object( dialog_->url ); - fl_deactivate_object( dialog_->name ); - fl_deactivate_object( dialog_->radio_html ); - fl_deactivate_object( dialog_->ok ); - fl_set_object_lcol( dialog_->ok, FL_INACTIVE ); - } else { - fl_activate_object( dialog_->url ); - fl_activate_object( dialog_->name ); - fl_activate_object( dialog_->radio_html ); - fl_activate_object( dialog_->ok ); - fl_set_object_lcol( dialog_->ok, FL_BLACK ); - } + bc_.readOnly(lv_->buffer()->isReadonly()); } void FormUrl::apply() { - if( lv_->buffer()->isReadonly() ) return; + if (lv_->buffer()->isReadonly()) return; - params.setContents( fl_get_input(dialog_->url) ); - params.setOptions( fl_get_input(dialog_->name) ); + params.setContents(fl_get_input(dialog_->url)); + params.setOptions(fl_get_input(dialog_->name)); if (fl_get_button(dialog_->radio_html)) params.setCmdName("htmlurl"); else params.setCmdName("url"); - if( inset_ != 0 ) - { + if (inset_ != 0) { // Only update if contents have changed - if( params != inset_->params() ) { - inset_->setParams( params ); - lv_->view()->updateInset( inset_, true ); + if (params != inset_->params()) { + inset_->setParams(params); + lv_->view()->updateInset(inset_, true); } } else { - lv_->getLyXFunc()->Dispatch( LFUN_INSERT_URL, - params.getAsString().c_str() ); + lv_->getLyXFunc()->Dispatch(LFUN_INSERT_URL, + params.getAsString()); } }