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)
32 // let the dialog be shown
33 // These are permanent connections so we won't bother
34 // storing a copy because we won't be disconnecting.
35 d->showUrl.connect(slot(this, &FormUrl::showInset));
36 d->createUrl.connect(slot(this, &FormUrl::createInset));
49 dialog_ = build_url();
54 fl_set_form_minsize(form(), w, h);
55 fl_set_form_maxsize(form(), 2*w, h);
59 FL_FORM * const FormUrl::form() const
61 if( dialog_ ) // no need to test for dialog_->form_url
62 return dialog_->form_url;
68 void FormUrl::update()
70 fl_set_input(dialog_->url, params.getContents().c_str());
71 fl_set_input(dialog_->name, params.getOptions().c_str());
73 if ( params.getCmdName() == "url" )
74 fl_set_button(dialog_->radio_html, 0);
76 fl_set_button(dialog_->radio_html, 1);
78 if( lv_->buffer()->isReadonly() ) {
79 fl_deactivate_object( dialog_->url );
80 fl_deactivate_object( dialog_->name );
81 fl_deactivate_object( dialog_->radio_html );
82 fl_deactivate_object( dialog_->ok );
83 fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
85 fl_activate_object( dialog_->url );
86 fl_activate_object( dialog_->name );
87 fl_activate_object( dialog_->radio_html );
88 fl_activate_object( dialog_->ok );
89 fl_set_object_lcol( dialog_->ok, FL_BLACK );
96 if( lv_->buffer()->isReadonly() ) return;
98 params.setContents( fl_get_input(dialog_->url) );
99 params.setOptions( fl_get_input(dialog_->name) );
101 if (fl_get_button(dialog_->radio_html))
102 params.setCmdName("htmlurl");
104 params.setCmdName("url");
108 // Only update if contents have changed
109 if( params != inset_->params() ) {
110 inset_->setParams( params );
111 lv_->view()->updateInset( inset_, true );
114 lv_->getLyXFunc()->Dispatch( LFUN_INSERT_URL,
115 params.getAsString().c_str() );