X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FFormIndex.C;h=7c09d69658c220b78ed7b4f84a095b81781d356d;hb=e918b1cc2b149a60f55543db38c62f9fa1f00477;hp=cefacea8dba19096a5e2f929c73dde0c58b2bbf9;hpb=8effd3eec4f9f143572875416ed8815e2a26cd12;p=lyx.git diff --git a/src/frontends/xforms/FormIndex.C b/src/frontends/xforms/FormIndex.C index cefacea8db..7c09d69658 100644 --- a/src/frontends/xforms/FormIndex.C +++ b/src/frontends/xforms/FormIndex.C @@ -1,109 +1,56 @@ -// -*- C++ -*- -/* This file is part of - * ====================================================== +/** + * \file 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 -#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")), 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)); -} +typedef FormCB > base_class; -FormIndex::~FormIndex() -{ - delete dialog_; -} +FormIndex::FormIndex(ControlIndex & c) + : base_class(c, _("Index")) +{} -FL_FORM * FormIndex::form() const +void FormIndex::build() { - if ( dialog_ ) return dialog_->form; - return 0; -} + dialog_.reset(build_index()); + fl_set_input_return(dialog_->input_key, FL_RETURN_CHANGED); + setPrehandler(dialog_->input_key); -void FormIndex::connect() -{ - fl_set_form_maxsize( form(), 2*minw_, minh_ ); - FormCommand::connect(); -} - + // 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().setRestore(dialog_->button_restore); -void FormIndex::build() -{ - dialog_ = build_index(); + bc().addReadOnly(dialog_->input_key); -#ifdef WITH_WARNINGS -#warning use the buttoncontroller -#endif - // Workaround dumb xforms sizing bug - minw_ = form()->w; - minh_ = form()->h; } -void FormIndex::update(bool switched) +void FormIndex::update() { - if (switched) { - hide(); - return; - } - - fl_set_input(dialog_->key, params.getContents().c_str()); - - if ( lv_->buffer()->isReadonly() ) { - fl_deactivate_object( dialog_->key ); - fl_deactivate_object( dialog_->ok ); - fl_set_object_lcol( dialog_->ok, FL_INACTIVE ); - } else { - fl_activate_object( dialog_->key ); - fl_activate_object( dialog_->ok ); - fl_set_object_lcol( dialog_->ok, FL_BLACK ); - } + 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_->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)); }