]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormIndex.C
try this for distinguishing inner and outer tabs
[lyx.git] / src / frontends / xforms / FormIndex.C
index 528c3e7338c7b830a82569c19145b9e3577dd387..c817ddb169d044b83f5e16bb8809785512aeac41 100644 (file)
@@ -18,7 +18,6 @@
 #endif
 
 
-#include "gettext.h"
 #include "Dialogs.h"
 #include "FormIndex.h"
 #include "LyXView.h"
@@ -27,7 +26,8 @@
 #include "lyxfunc.h"
 
 FormIndex::FormIndex(LyXView * lv, Dialogs * d)
-       : FormCommand(lv, d, _("Index")), dialog_(0)
+       : FormCommand(lv, d, _("Index"), new NoRepeatedApplyPolicy),
+         dialog_(0)
 {
        // let the dialog be shown
        // These are permanent connections so we won't bother
@@ -39,71 +39,69 @@ FormIndex::FormIndex(LyXView * lv, Dialogs * d)
 
 FormIndex::~FormIndex()
 {
-       free();
        delete dialog_;
 }
 
 
-void FormIndex::build()
+FL_FORM * FormIndex::form() const
 {
-       dialog_ = build_index();
+       if (dialog_) return dialog_->form;
+       return 0;
 }
 
 
-FL_FORM * const FormIndex::form() const
+void FormIndex::connect()
 {
-       if( dialog_ && dialog_->form_index )
-               return dialog_->form_index;
-       else
-               return 0;
+       fl_set_form_maxsize(form(), 2 * minw_, minh_);
+       FormCommand::connect();
 }
+       
 
-
-void FormIndex::update()
+void FormIndex::build()
 {
-       static int ow = -1, oh;
+       dialog_ = build_index();
 
-       if (ow < 0) {
-               ow = dialog_->form_index->w;
-               oh = dialog_->form_index->h;
+       // Workaround dumb xforms sizing bug
+       minw_ = form()->w;
+       minh_ = form()->h;
 
-               fl_set_form_minsize(dialog_->form_index, ow, oh);
-               fl_set_form_maxsize(dialog_->form_index, 2*ow, oh);
-       }
+       fl_set_input_return(dialog_->input_key, FL_RETURN_CHANGED);
 
-       fl_freeze_form( dialog_->form_index );
+        // 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_input(dialog_->key, params.getContents().c_str());
+       bc_.addReadOnly(dialog_->input_key);
+}
 
-       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_unfreeze_form( dialog_->form_index );
+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());
 }
 
 
 void FormIndex::apply()
 {
-       if( lv_->buffer()->isReadonly() ) return;
+       if (lv_->buffer()->isReadonly()) return;
 
-       params.setContents( fl_get_input(dialog_->key) );
+       params.setContents(fl_get_input(dialog_->input_key));
 
-       if( inset_ != 0 )
-       {
+       if (inset_ != 0) {
                // Only update if contents have changed
-               if( params.getContents() != inset_->getContents() ) {
-                       inset_->setParams( params );
-                       lv_->view()->updateInset( inset_, true );
+               if (params != inset_->params()) {
+                       inset_->setParams(params);
+                       lv_->view()->updateInset(inset_, true);
                }
        } else {
-               lv_->getLyXFunc()->Dispatch( LFUN_INDEX_INSERT,
-                                            params.getAsString().c_str() );
+               lv_->getLyXFunc()->Dispatch(LFUN_INDEX_INSERT,
+                                           params.getAsString());
        }
 }