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")), minh(0), minw(0), 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));
48 dialog_ = build_url();
50 // XFORMS bug workaround
51 // Define the min/max dimensions. Actually applied in update()
52 minw = form()->w; minh = form()->h;
56 FL_FORM * const FormUrl::form() const
58 if( dialog_ ) // no need to test for dialog_->form
65 void FormUrl::update()
67 fl_set_form_minsize(form(), minw, minh);
68 fl_set_form_maxsize(form(), 2*minw, minh);
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");
107 // Only update if contents have changed
108 if(params != inset_->params()) {
109 inset_->setParams(params);
110 lv_->view()->updateInset(inset_, true);
113 lv_->getLyXFunc()->Dispatch(LFUN_INSERT_URL,
114 params.getAsString());