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), minh(0), minw(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();
52 // XFORMS bug workaround
53 // Define the min/max dimensions. Actually applied in update()
54 minw = form()->w; minh = form()->h;
58 FL_FORM * const FormUrl::form() const
60 if( dialog_ ) // no need to test for dialog_->form_url
61 return dialog_->form_url;
67 void FormUrl::update()
69 fl_set_form_minsize(form(), minw, minh);
70 fl_set_form_maxsize(form(), 2*minw, minh);
72 fl_set_input(dialog_->url, params.getContents().c_str());
73 fl_set_input(dialog_->name, params.getOptions().c_str());
75 if ( params.getCmdName() == "url" )
76 fl_set_button(dialog_->radio_html, 0);
78 fl_set_button(dialog_->radio_html, 1);
80 if( lv_->buffer()->isReadonly() ) {
81 fl_deactivate_object( dialog_->url );
82 fl_deactivate_object( dialog_->name );
83 fl_deactivate_object( dialog_->radio_html );
84 fl_deactivate_object( dialog_->ok );
85 fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
87 fl_activate_object( dialog_->url );
88 fl_activate_object( dialog_->name );
89 fl_activate_object( dialog_->radio_html );
90 fl_activate_object( dialog_->ok );
91 fl_set_object_lcol( dialog_->ok, FL_BLACK );
98 if( lv_->buffer()->isReadonly() ) return;
100 params.setContents( fl_get_input(dialog_->url) );
101 params.setOptions( fl_get_input(dialog_->name) );
103 if (fl_get_button(dialog_->radio_html))
104 params.setCmdName("htmlurl");
106 params.setCmdName("url");
110 // Only update if contents have changed
111 if( params != inset_->params() ) {
112 inset_->setParams( params );
113 lv_->view()->updateInset( inset_, true );
116 lv_->getLyXFunc()->Dispatch( LFUN_INSERT_URL,
117 params.getAsString().c_str() );