]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormUrl.C
(John): translate dialog titles.
[lyx.git] / src / frontends / xforms / FormUrl.C
index 41873282c3902179fc505b1ee6b2974969a31443..276965721708acc310ef2b43e0c74594d0292b05 100644 (file)
-// -*- C++ -*-
-/* This file is part of
- * ====================================================== 
+/**
+ * \file xforms/FormUrl.C
+ * Copyright 2000-2001 The LyX Team.
+ * See the file COPYING.
  *
- *           LyX, The Document Processor
- *
- *           Copyright 2000 The LyX Team.
- *
- * ======================================================
+ * \author Angus Leeming, a.leeming@ic.ac.uk
  */
 
-#include <config.h>
 
-#include FORMS_H_LOCATION
+#include <config.h>
 
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
-
-#include "gettext.h"
-#include "BufferView.h"
-#include "Dialogs.h"
+#include "xformsBC.h"
+#include "ControlUrl.h"
 #include "FormUrl.h"
-#include "LyXView.h"
-#include "buffer.h"
 #include "form_url.h"
-#include "lyxfunc.h"
-#include "xform_macros.h"
-#include "insets/insetcommand.h"
-#include "insets/inseturl.h"
-#include "support/filetools.h"
-
-FormUrl::FormUrl(LyXView * lv, Dialogs * d)
-  : FormCommand(lv, d, _("Url")), dialog_(0)
-{
-       // 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));
-}
 
+typedef FormCB<ControlUrl, FormDB<FD_form_url> > base_class;
 
-FormUrl::~FormUrl()
-{
-       free();
-       delete dialog_;
-}
+FormUrl::FormUrl(ControlUrl & c)
+       : base_class(c, _("Url"))
+{}
 
 
 void FormUrl::build()
 {
-       dialog_ = build_url();
-}
+       dialog_.reset(build_url());
 
+       fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
+       fl_set_input_return(dialog_->input_url,  FL_RETURN_CHANGED);
 
-FL_FORM * const FormUrl::form() const
-{
-       if( dialog_ && dialog_->form_url )
-               return dialog_->form_url;
-       else
-               return 0;
+       setPrehandler(dialog_->input_name);
+       setPrehandler(dialog_->input_url);
+
+       // Manage the ok, apply, restore and cancel/close buttons
+       bc().setOK(dialog_->button_ok);
+       bc().setApply(dialog_->button_apply);
+       bc().setCancel(dialog_->button_close);
+       bc().setRestore(dialog_->button_restore);
+
+       bc().addReadOnly(dialog_->input_name);
+       bc().addReadOnly(dialog_->input_url);
+       bc().addReadOnly(dialog_->check_html);
 }
 
 
 void FormUrl::update()
 {
-       static int ow = -1, oh;
-
-       if (ow < 0) {
-               ow = dialog_->form_url->w;
-               oh = dialog_->form_url->h;
+       fl_set_input(dialog_->input_url,
+                    controller().params().getContents().c_str());
+       fl_set_input(dialog_->input_name,
+                    controller().params().getOptions().c_str());
 
-               fl_set_form_minsize(dialog_->form_url, ow, oh);
-               fl_set_form_maxsize(dialog_->form_url, 2*ow, oh);
-       }
-
-       fl_freeze_form( dialog_->form_url );
-
-       fl_set_input(dialog_->url,  params.getContents().c_str());
-       fl_set_input(dialog_->name, 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);
-
-       if( lv_->buffer()->isReadonly() ) {
-               fl_deactivate_object( dialog_->url );
-               fl_deactivate_object( dialog_->name );
-               fl_deactivate_object( dialog_->radio_html );
-               fl_deactivate_object( dialog_->ok );
-               fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
-       } else {
-               fl_activate_object( dialog_->url );
-               fl_activate_object( dialog_->name );
-               fl_activate_object( dialog_->radio_html );
-               fl_activate_object( dialog_->ok );
-               fl_set_object_lcol( dialog_->ok, FL_BLACK );
-       }
-
-       fl_unfreeze_form( dialog_->form_url );
+               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.getCmdName()  != inset_->getCmdName()  ||
-                   params.getContents() != inset_->getContents() ||
-                   params.getOptions()  != inset_->getOptions() ) {
-                       inset_->setParams( params );
-                       lv_->view()->updateInset( inset_, true );
-               }
-       } else {
-               lv_->getLyXFunc()->Dispatch( LFUN_INSERT_URL,
-                                            params.getAsString().c_str() );
-       }
+               controller().params().setCmdName("url");
 }