]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormIndex.C
More pref work from Angus
[lyx.git] / src / frontends / xforms / FormIndex.C
index 2d64ae01a4cc1fdbe41c7b10d3d489c8834f2081..45bcebe8dc2a4e41d21dc18d66ac2906853f9f77 100644 (file)
@@ -18,7 +18,6 @@
 #endif
 
 
-#include "gettext.h"
 #include "Dialogs.h"
 #include "FormIndex.h"
 #include "LyXView.h"
@@ -27,7 +26,7 @@
 #include "lyxfunc.h"
 
 FormIndex::FormIndex(LyXView * lv, Dialogs * d)
-       : FormCommand(lv, d, _("Index")), dialog_(0), minh(0), minw(0)
+       : FormCommand(lv, d, _("Index")), dialog_(0)
 {
        // let the dialog be shown
        // These are permanent connections so we won't bother
@@ -39,38 +38,42 @@ FormIndex::FormIndex(LyXView * lv, Dialogs * d)
 
 FormIndex::~FormIndex()
 {
-       free();
        delete dialog_;
 }
 
 
-void FormIndex::build()
+FL_FORM * FormIndex::form() const
 {
-       dialog_ = build_index();
-
-       // XFORMS bug workaround
-       // Define the min/max dimensions. Actually applied in update()
-       minw = form()->w; minh = form()->h;
+       if ( dialog_ ) return dialog_->form;
+       return 0;
 }
 
 
-FL_FORM * const FormIndex::form() const
+void FormIndex::connect()
 {
-       if( dialog_ ) // no need to test for dialog_->form_index
-               return dialog_->form_index;
-       else
-               return 0;
+       fl_set_form_maxsize( form(), 2*minw_, minh_ );
+       FormCommand::connect();
+}
+       
+
+void FormIndex::build()
+{
+       dialog_ = build_index();
+
+#ifdef WITH_WARNINGS
+#warning use the buttoncontroller
+#endif
+       // Workaround dumb xforms sizing bug
+       minw_ = form()->w;
+       minh_ = form()->h;
 }
 
 
 void FormIndex::update()
 {
-       fl_set_form_minsize(form(), minw, minh);
-       fl_set_form_maxsize(form(), 2*minw, minh);
-
        fl_set_input(dialog_->key, params.getContents().c_str());
 
-       if( lv_->buffer()->isReadonly() ) {
+       if ( lv_->buffer()->isReadonly() ) {
                fl_deactivate_object( dialog_->key );
                fl_deactivate_object( dialog_->ok );
                fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
@@ -84,19 +87,18 @@ void FormIndex::update()
 
 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_->key));
 
-       if( inset_ != 0 )
-       {
+       if (inset_ != 0) {
                // Only update if contents have changed
-               if( params != inset_->params() ) {
-                       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());
        }
 }