]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormIndex.C
update patch from Angus
[lyx.git] / src / frontends / xforms / FormIndex.C
index 8e718e46d111f091a56152180ab02815f0364f78..c817ddb169d044b83f5e16bb8809785512aeac41 100644 (file)
@@ -26,7 +26,8 @@
 #include "lyxfunc.h"
 
 FormIndex::FormIndex(LyXView * lv, Dialogs * d)
-       : FormCommand(lv, d, _("Index")), minh(0), minw(0), dialog_(0)
+       : FormCommand(lv, d, _("Index"), new NoRepeatedApplyPolicy),
+         dialog_(0)
 {
        // let the dialog be shown
        // These are permanent connections so we won't bother
@@ -44,45 +45,46 @@ FormIndex::~FormIndex()
 
 FL_FORM * FormIndex::form() const
 {
-       if ( dialog_ ) return dialog_->form;
+       if (dialog_) return dialog_->form;
        return 0;
 }
 
 
+void FormIndex::connect()
+{
+       fl_set_form_maxsize(form(), 2 * minw_, minh_);
+       FormCommand::connect();
+}
+       
+
 void FormIndex::build()
 {
        dialog_ = build_index();
 
-#ifdef WITH_WARNINGS
-#warning use the buttoncontroller
-#endif
-       // XFORMS bug workaround
-       // Define the min/max dimensions. Actually applied in update()
-       minw = form()->w; minh = form()->h;
-}
+       // Workaround dumb xforms sizing bug
+       minw_ = form()->w;
+       minh_ = form()->h;
 
+       fl_set_input_return(dialog_->input_key, FL_RETURN_CHANGED);
 
-void FormIndex::update(bool switched)
-{
-       if (switched) {
-               hide();
-               return;
-       }
+        // 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();
 
-       fl_set_form_minsize(form(), minw, minh);
-       fl_set_form_maxsize(form(), 2*minw, minh);
+       bc_.addReadOnly(dialog_->input_key);
+}
 
-       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 );
-       }
+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());
 }
 
 
@@ -90,7 +92,7 @@ void FormIndex::apply()
 {
        if (lv_->buffer()->isReadonly()) return;
 
-       params.setContents(fl_get_input(dialog_->key));
+       params.setContents(fl_get_input(dialog_->input_key));
 
        if (inset_ != 0) {
                // Only update if contents have changed