]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormUrl.C
Introduce LFUN_PRINT.
[lyx.git] / src / frontends / xforms / FormUrl.C
index 78b2cad0f04e1f0e5da6d2255c43f661f21e7851..9d52023ac98915d318de207cadb3eda311e673c2 100644 (file)
-// -*- C++ -*-
-/* This file is part of
- * ====================================================== 
+/**
+ * \file FormUrl.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *           LyX, The Document Processor
+ * \author Angus Leeming
  *
- *           Copyright 2000 The LyX Team.
- *
- * ======================================================
+ * Full author contact details are available in file CREDITS.
  */
 
-#include <config.h>
-
-#include FORMS_H_LOCATION
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include <config.h>
 
-#include "Dialogs.h"
 #include "FormUrl.h"
-#include "LyXView.h"
-#include "buffer.h"
-#include "form_url.h"
-#include "lyxfunc.h"
+#include "ControlCommand.h"
+#include "forms/form_url.h"
 
-using SigC::slot;
+#include "xformsBC.h"
 
-FormUrl::FormUrl(LyXView * lv, Dialogs * d)
-       : FormCommand(lv, d, _("Url"))
-{
-       // 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));
-}
+#include "lyx_forms.h"
 
 
-FL_FORM * FormUrl::form() const
-{
-       if (dialog_.get()) return dialog_->form;
-       return 0;
-}
+typedef  FormController<ControlCommand, FormView<FD_url> > base_class;
 
+FormUrl::FormUrl(Dialog & parent)
+       : base_class(parent, _("URL"))
+{}
 
-void FormUrl::connect()
-{
-       fl_set_form_maxsize(form(), 2 * minw_, minh_);
-       FormCommand::connect();
-}
-       
 
 void FormUrl::build()
 {
-       dialog_.reset(build_url());
+       dialog_.reset(build_url(this));
 
-       fl_set_input_return(dialog_->name, FL_RETURN_CHANGED);
-       fl_set_input_return(dialog_->url,  FL_RETURN_CHANGED);
+       fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
+       fl_set_input_return(dialog_->input_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();
+       setPrehandler(dialog_->input_name);
+       setPrehandler(dialog_->input_url);
 
-       bc().addReadOnly(dialog_->name);
-       bc().addReadOnly(dialog_->url);
-       bc().addReadOnly(dialog_->radio_html);
+       // Manage the ok, apply, restore and cancel/close buttons
+       bcview().setOK(dialog_->button_ok);
+       bcview().setApply(dialog_->button_apply);
+       bcview().setCancel(dialog_->button_close);
+       bcview().setRestore(dialog_->button_restore);
+
+       bcview().addReadOnly(dialog_->input_name);
+       bcview().addReadOnly(dialog_->input_url);
+       bcview().addReadOnly(dialog_->check_html);
 }
 
 
 void FormUrl::update()
 {
-       fl_set_input(dialog_->url,  params.getContents().c_str());
-       fl_set_input(dialog_->name, params.getOptions().c_str());
+       fl_set_input(dialog_->input_url,
+                    controller().params().getContents().c_str());
+       fl_set_input(dialog_->input_name,
+                    controller().params().getOptions().c_str());
 
-       if (params.getCmdName() == "url")
-               fl_set_button(dialog_->radio_html, 0);
+       if (controller().params().getCmdName() == "url")
+               fl_set_button(dialog_->check_html, 0);
        else
-               fl_set_button(dialog_->radio_html, 1);
-
-       bc().readOnly(lv_->buffer()->isReadonly());
+               fl_set_button(dialog_->check_html, 1);
 }
 
 
 void FormUrl::apply()
 {
-       if (lv_->buffer()->isReadonly()) return;
-
-       params.setContents(fl_get_input(dialog_->url));
-       params.setOptions(fl_get_input(dialog_->name));
+       controller().params().setContents(fl_get_input(dialog_->input_url));
+       controller().params().setOptions(fl_get_input(dialog_->input_name));
 
-       if (fl_get_button(dialog_->radio_html))
-               params.setCmdName("htmlurl");
+       if (fl_get_button(dialog_->check_html))
+               controller().params().setCmdName("htmlurl");
        else
-               params.setCmdName("url");
-
-       if (inset_ != 0) {
-               // Only update if contents have changed
-               if (params != inset_->params()) {
-                       inset_->setParams(params);
-                       lv_->view()->updateInset(inset_, true);
-               }
-       } else {
-               lv_->getLyXFunc()->Dispatch(LFUN_INSERT_URL,
-                                           params.getAsString());
-       }
+               controller().params().setCmdName("url");
 }