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
28 FormUrl::FormUrl(LyXView * lv, Dialogs * d)
29 : FormCommand(lv, d, _("Url")), minh(0), minw(0), dialog_(0)
31 // let the dialog be shown
32 // These are permanent connections so we won't bother
33 // storing a copy because we won't be disconnecting.
34 d->showUrl.connect(slot(this, &FormUrl::showInset));
35 d->createUrl.connect(slot(this, &FormUrl::createInset));
47 dialog_ = build_url();
49 // XFORMS bug workaround
50 // Define the min/max dimensions. Actually applied in update()
51 minw = form()->w; minh = form()->h;
55 FL_FORM * const FormUrl::form() const
57 if( dialog_ ) // no need to test for dialog_->form
64 void FormUrl::update()
66 fl_set_form_minsize(form(), minw, minh);
67 fl_set_form_maxsize(form(), 2*minw, minh);
69 fl_set_input(dialog_->url, params.getContents().c_str());
70 fl_set_input(dialog_->name, params.getOptions().c_str());
72 if ( params.getCmdName() == "url" )
73 fl_set_button(dialog_->radio_html, 0);
75 fl_set_button(dialog_->radio_html, 1);
77 if( lv_->buffer()->isReadonly() ) {
78 fl_deactivate_object( dialog_->url );
79 fl_deactivate_object( dialog_->name );
80 fl_deactivate_object( dialog_->radio_html );
81 fl_deactivate_object( dialog_->ok );
82 fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
84 fl_activate_object( dialog_->url );
85 fl_activate_object( dialog_->name );
86 fl_activate_object( dialog_->radio_html );
87 fl_activate_object( dialog_->ok );
88 fl_set_object_lcol( dialog_->ok, FL_BLACK );
95 if(lv_->buffer()->isReadonly()) return;
97 params.setContents(fl_get_input(dialog_->url));
98 params.setOptions(fl_get_input(dialog_->name));
100 if (fl_get_button(dialog_->radio_html))
101 params.setCmdName("htmlurl");
103 params.setCmdName("url");
106 // Only update if contents have changed
107 if(params != inset_->params()) {
108 inset_->setParams(params);
109 lv_->view()->updateInset(inset_, true);
112 lv_->getLyXFunc()->Dispatch(LFUN_INSERT_URL,
113 params.getAsString());