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));
45 FL_FORM * FormUrl::form() const
47 if ( dialog_ ) return dialog_->form;
54 dialog_ = build_url();
57 #warning use the buttoncontroller
59 // XFORMS bug workaround
60 // Define the min/max dimensions. Actually applied in update()
66 void FormUrl::update(bool switched)
73 fl_set_form_minsize(form(), minw, minh);
74 fl_set_form_maxsize(form(), 2*minw, minh);
76 fl_set_input(dialog_->url, params.getContents().c_str());
77 fl_set_input(dialog_->name, params.getOptions().c_str());
79 if ( params.getCmdName() == "url" )
80 fl_set_button(dialog_->radio_html, 0);
82 fl_set_button(dialog_->radio_html, 1);
84 if ( lv_->buffer()->isReadonly() ) {
85 fl_deactivate_object( dialog_->url );
86 fl_deactivate_object( dialog_->name );
87 fl_deactivate_object( dialog_->radio_html );
88 fl_deactivate_object( dialog_->button_ok );
89 fl_set_object_lcol( dialog_->button_ok, FL_INACTIVE );
91 fl_activate_object( dialog_->url );
92 fl_activate_object( dialog_->name );
93 fl_activate_object( dialog_->radio_html );
94 fl_activate_object( dialog_->button_ok );
95 fl_set_object_lcol( dialog_->button_ok, FL_BLACK );
100 void FormUrl::apply()
102 if (lv_->buffer()->isReadonly()) return;
104 params.setContents(fl_get_input(dialog_->url));
105 params.setOptions(fl_get_input(dialog_->name));
107 if (fl_get_button(dialog_->radio_html))
108 params.setCmdName("htmlurl");
110 params.setCmdName("url");
113 // Only update if contents have changed
114 if (params != inset_->params()) {
115 inset_->setParams(params);
116 lv_->view()->updateInset(inset_, true);
119 lv_->getLyXFunc()->Dispatch(LFUN_INSERT_URL,
120 params.getAsString());