]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormIndex.C
2002-07-02 Lars Gullik Bj�nnes <larsbj@birdstep.com>
[lyx.git] / src / frontends / xforms / FormIndex.C
index c817ddb169d044b83f5e16bb8809785512aeac41..ec704bb07a9762cce63253f2c77263dbbf9d7a61 100644 (file)
-// -*- C++ -*-
-/* This file is part of
- * ====================================================== 
+/**
+ * \file xforms/FormIndex.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
-
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
-
-#include "Dialogs.h"
+#include "xformsBC.h"
+#include "ControlIndex.h"
 #include "FormIndex.h"
-#include "LyXView.h"
-#include "buffer.h"
-#include "form_index.h"
-#include "lyxfunc.h"
-
-FormIndex::FormIndex(LyXView * lv, Dialogs * d)
-       : FormCommand(lv, d, _("Index"), new NoRepeatedApplyPolicy),
-         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->showIndex.connect(slot(this, &FormIndex::showInset));
-       d->createIndex.connect(slot(this, &FormIndex::createInset));
-}
-
-
-FormIndex::~FormIndex()
-{
-       delete dialog_;
-}
+#include "frontends/LyXView.h"
+#include "forms/form_index.h"
+#include FORMS_H_LOCATION
 
+typedef FormCB<ControlIndex, FormDB<FD_index> > base_class;
 
-FL_FORM * FormIndex::form() const
-{
-       if (dialog_) return dialog_->form;
-       return 0;
-}
+FormIndex::FormIndex(ControlIndex & c, Dialogs & d)
+       : base_class(c, d, _("Index"))
+{}
 
 
-void FormIndex::connect()
-{
-       fl_set_form_maxsize(form(), 2 * minw_, minh_);
-       FormCommand::connect();
-}
-       
-
 void FormIndex::build()
 {
-       dialog_ = build_index();
-
-       // Workaround dumb xforms sizing bug
-       minw_ = form()->w;
-       minh_ = form()->h;
+       dialog_.reset(build_index(this));
 
        fl_set_input_return(dialog_->input_key, FL_RETURN_CHANGED);
+       setPrehandler(dialog_->input_key);
+
+       // 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);
 
-        // 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_->input_key);
 
-       bc_.addReadOnly(dialog_->input_key);
 }
 
 
 void FormIndex::update()
 {
-       fl_set_input(dialog_->input_key, params.getContents().c_str());
-       // Surely, this should reset the buttons to their original state?
-       // It doesn't. Instead "Restore" becomes a "Close"
-       //bc_.refresh();
-       bc_.readOnly(lv_->buffer()->isReadonly());
+       fl_set_input(dialog_->input_key,
+                    controller().params().getContents().c_str());
 }
 
 
 void FormIndex::apply()
 {
-       if (lv_->buffer()->isReadonly()) return;
-
-       params.setContents(fl_get_input(dialog_->input_key));
-
-       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_INDEX_INSERT,
-                                           params.getAsString());
-       }
+       controller().params().setContents(fl_get_input(dialog_->input_key));
 }