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();
53 FL_FORM * const FormUrl::form() const
55 if( dialog_ && dialog_->form_url )
56 return dialog_->form_url;
62 void FormUrl::update()
64 static int ow = -1, oh;
67 ow = dialog_->form_url->w;
68 oh = dialog_->form_url->h;
70 fl_set_form_minsize(dialog_->form_url, ow, oh);
71 fl_set_form_maxsize(dialog_->form_url, 2*ow, oh);
74 fl_freeze_form( dialog_->form_url );
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_->ok );
89 fl_set_object_lcol( dialog_->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_->ok );
95 fl_set_object_lcol( dialog_->ok, FL_BLACK );
98 fl_unfreeze_form( dialog_->form_url );
102 void FormUrl::apply()
104 if( lv_->buffer()->isReadonly() ) return;
106 params.setContents( fl_get_input(dialog_->url) );
107 params.setOptions( fl_get_input(dialog_->name) );
109 if (fl_get_button(dialog_->radio_html))
110 params.setCmdName("htmlurl");
112 params.setCmdName("url");
116 // Only update if contents have changed
117 if( params.getCmdName() != inset_->getCmdName() ||
118 params.getContents() != inset_->getContents() ||
119 params.getOptions() != inset_->getOptions() ) {
120 inset_->setParams( params );
121 lv_->view()->updateInset( inset_, true );
124 lv_->getLyXFunc()->Dispatch( LFUN_INSERT_URL,
125 params.getAsString().c_str() );