2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ======================================================
14 #include FORMS_H_LOCATION
17 #pragma implementation
29 FormUrl::FormUrl(LyXView * lv, Dialogs * d)
30 : FormCommand(lv, d, _("Url")), dialog_(0)
33 // let the dialog be shown
34 // These are permanent connections so we won't bother
35 // storing a copy because we won't be disconnecting.
36 d->showUrl.connect(slot(this, &FormUrl::showInset));
37 d->createUrl.connect(slot(this, &FormUrl::createInset));
50 dialog_ = build_url();
55 fl_set_form_minsize(form(), w, h);
56 fl_set_form_maxsize(form(), 2*w, h);
60 FL_FORM * const FormUrl::form() const
62 if( dialog_ ) // no need to test for dialog_->form_url
63 return dialog_->form_url;
69 void FormUrl::update()
71 fl_set_input(dialog_->url, params.getContents().c_str());
72 fl_set_input(dialog_->name, params.getOptions().c_str());
74 if ( params.getCmdName() == "url" )
75 fl_set_button(dialog_->radio_html, 0);
77 fl_set_button(dialog_->radio_html, 1);
79 if( lv_->buffer()->isReadonly() ) {
80 fl_deactivate_object( dialog_->url );
81 fl_deactivate_object( dialog_->name );
82 fl_deactivate_object( dialog_->radio_html );
83 fl_deactivate_object( dialog_->ok );
84 fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
86 fl_activate_object( dialog_->url );
87 fl_activate_object( dialog_->name );
88 fl_activate_object( dialog_->radio_html );
89 fl_activate_object( dialog_->ok );
90 fl_set_object_lcol( dialog_->ok, FL_BLACK );
97 if( lv_->buffer()->isReadonly() ) return;
99 params.setContents( fl_get_input(dialog_->url) );
100 params.setOptions( fl_get_input(dialog_->name) );
102 if (fl_get_button(dialog_->radio_html))
103 params.setCmdName("htmlurl");
105 params.setCmdName("url");
109 // Only update if contents have changed
110 if( params != inset_->params() ) {
111 inset_->setParams( params );
112 lv_->view()->updateInset( inset_, true );
115 lv_->getLyXFunc()->Dispatch( LFUN_INSERT_URL,
116 params.getAsString().c_str() );