2000-07-27 08:55:59 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2000 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2000-07-27 10:26:38 +00:00
|
|
|
|
2000-07-27 08:55:59 +00:00
|
|
|
#include FORMS_H_LOCATION
|
2000-07-27 10:26:38 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-07-27 08:55:59 +00:00
|
|
|
#include "Dialogs.h"
|
|
|
|
#include "FormUrl.h"
|
|
|
|
#include "LyXView.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "form_url.h"
|
|
|
|
#include "lyxfunc.h"
|
|
|
|
|
|
|
|
FormUrl::FormUrl(LyXView * lv, Dialogs * d)
|
2000-11-29 15:06:42 +00:00
|
|
|
: FormCommand(lv, d, _("Url"), new NoRepeatedApplyReadOnlyPolicy),
|
2000-11-14 02:01:57 +00:00
|
|
|
dialog_(0)
|
2000-07-27 08:55:59 +00:00
|
|
|
{
|
|
|
|
// let the dialog be shown
|
|
|
|
// These are permanent connections so we won't bother
|
|
|
|
// storing a copy because we won't be disconnecting.
|
|
|
|
d->showUrl.connect(slot(this, &FormUrl::showInset));
|
|
|
|
d->createUrl.connect(slot(this, &FormUrl::createInset));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FormUrl::~FormUrl()
|
|
|
|
{
|
2000-08-01 17:33:32 +00:00
|
|
|
delete dialog_;
|
2000-07-27 08:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-05 07:57:00 +00:00
|
|
|
FL_FORM * FormUrl::form() const
|
|
|
|
{
|
2000-11-28 06:46:06 +00:00
|
|
|
if (dialog_) return dialog_->form;
|
2000-10-05 07:57:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-20 09:50:09 +00:00
|
|
|
void FormUrl::connect()
|
|
|
|
{
|
2000-11-14 02:01:57 +00:00
|
|
|
fl_set_form_maxsize(form(), 2 * minw_, minh_);
|
2000-10-20 09:50:09 +00:00
|
|
|
FormCommand::connect();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-27 08:55:59 +00:00
|
|
|
void FormUrl::build()
|
|
|
|
{
|
|
|
|
dialog_ = build_url();
|
2000-08-04 13:12:30 +00:00
|
|
|
|
2000-10-20 09:50:09 +00:00
|
|
|
// Workaround dumb xforms sizing bug
|
|
|
|
minw_ = form()->w;
|
|
|
|
minh_ = form()->h;
|
2000-11-28 06:46:06 +00:00
|
|
|
|
|
|
|
fl_set_input_return(dialog_->name, FL_RETURN_CHANGED);
|
|
|
|
fl_set_input_return(dialog_->url, FL_RETURN_CHANGED);
|
|
|
|
|
|
|
|
// Manage the ok, apply, restore and cancel/close buttons
|
|
|
|
bc_.setOK(dialog_->button_ok);
|
|
|
|
bc_.setApply(dialog_->button_apply);
|
|
|
|
bc_.setCancel(dialog_->button_cancel);
|
|
|
|
bc_.setUndoAll(dialog_->button_restore);
|
|
|
|
bc_.refresh();
|
|
|
|
|
|
|
|
bc_.addReadOnly(dialog_->name);
|
|
|
|
bc_.addReadOnly(dialog_->url);
|
|
|
|
bc_.addReadOnly(dialog_->radio_html);
|
2000-07-27 08:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
void FormUrl::update()
|
2000-07-27 08:55:59 +00:00
|
|
|
{
|
2000-08-01 17:33:32 +00:00
|
|
|
fl_set_input(dialog_->url, params.getContents().c_str());
|
|
|
|
fl_set_input(dialog_->name, params.getOptions().c_str());
|
2000-07-27 08:55:59 +00:00
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
if (params.getCmdName() == "url")
|
2000-07-27 08:55:59 +00:00
|
|
|
fl_set_button(dialog_->radio_html, 0);
|
|
|
|
else
|
|
|
|
fl_set_button(dialog_->radio_html, 1);
|
|
|
|
|
2000-11-28 06:46:06 +00:00
|
|
|
bc_.readOnly(lv_->buffer()->isReadonly());
|
2000-07-27 08:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormUrl::apply()
|
|
|
|
{
|
2000-10-03 05:53:25 +00:00
|
|
|
if (lv_->buffer()->isReadonly()) return;
|
2000-07-27 08:55:59 +00:00
|
|
|
|
2000-09-19 11:18:35 +00:00
|
|
|
params.setContents(fl_get_input(dialog_->url));
|
|
|
|
params.setOptions(fl_get_input(dialog_->name));
|
2000-07-27 08:55:59 +00:00
|
|
|
|
|
|
|
if (fl_get_button(dialog_->radio_html))
|
2000-08-01 17:33:32 +00:00
|
|
|
params.setCmdName("htmlurl");
|
2000-07-27 08:55:59 +00:00
|
|
|
else
|
2000-08-01 17:33:32 +00:00
|
|
|
params.setCmdName("url");
|
2000-07-27 08:55:59 +00:00
|
|
|
|
2000-10-03 05:53:25 +00:00
|
|
|
if (inset_ != 0) {
|
2000-08-01 17:33:32 +00:00
|
|
|
// Only update if contents have changed
|
2000-10-03 05:53:25 +00:00
|
|
|
if (params != inset_->params()) {
|
2000-09-19 11:18:35 +00:00
|
|
|
inset_->setParams(params);
|
|
|
|
lv_->view()->updateInset(inset_, true);
|
2000-08-01 17:33:32 +00:00
|
|
|
}
|
2000-07-27 08:55:59 +00:00
|
|
|
} else {
|
2000-09-19 11:18:35 +00:00
|
|
|
lv_->getLyXFunc()->Dispatch(LFUN_INSERT_URL,
|
|
|
|
params.getAsString());
|
2000-07-27 08:55:59 +00:00
|
|
|
}
|
|
|
|
}
|