]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormRef.C
More pref work from Angus
[lyx.git] / src / frontends / xforms / FormRef.C
index 23070c366109e3a1a0a07ae3389b9a1c94038b25..fafb1475ec1dd879d6f9a3a5d428a467c0d68743 100644 (file)
@@ -30,8 +30,8 @@
 using std::sort;
 using std::vector;
 
-static int formw;
-static int formh;
+static int const minw_hb = 250;
+static int minw_sb;
 
 FormRef::FormRef(LyXView * lv, Dialogs * d)
        : FormCommand(lv, d, _("Reference")), toggle(GOBACK), dialog_(0)
@@ -57,6 +57,13 @@ FL_FORM * FormRef::form() const
 }
 
 
+void FormRef::connect()
+{
+       fl_set_form_maxsize( form(), 2*minw_, minh_ );
+       FormCommand::connect();
+}
+       
+
 void FormRef::disconnect()
 {
        refs.clear();
@@ -71,9 +78,10 @@ void FormRef::build()
        fl_addto_choice(dialog_->type,
                        _(" Ref | Page | TextRef | TextPage | PrettyRef "));
 
-       // XFORMS bug workaround
-       // Define the min/max dimensions. Actually applied in update()
-       formw = form()->w, formh = form()->h;
+       // Workaround dumb xforms sizing bug
+       minw_ = form()->w;
+       minh_ = form()->h;
+       minw_sb = minw_;
 
        // Name is irrelevant to LaTeX documents
        if ( lv_->buffer()->isLatex() ) {
@@ -91,13 +99,8 @@ void FormRef::build()
 }
 
 
-void FormRef::update(bool switched)
+void FormRef::update()
 {
-       if (switched) {
-               hide();
-               return;
-       }
-
        fl_set_input(dialog_->ref,  params.getContents().c_str());
        fl_set_input(dialog_->name, params.getOptions().c_str());
 
@@ -157,7 +160,7 @@ void FormRef::showBrowser() const
        fl_show_object( dialog_->button_update );
        fl_show_object( dialog_->sort );
 
-       setSize( formw, formh, 0 );
+       setSize( minw_sb, 0 );
 
        fl_deactivate_object( dialog_->type );
        fl_set_object_lcol( dialog_->type, FL_INACTIVE );
@@ -174,7 +177,7 @@ void FormRef::hideBrowser() const
        fl_hide_object( dialog_->button_update );
        fl_hide_object( dialog_->sort );
 
-       setSize( 250, formh, 280 );
+       setSize( minw_hb, 280 );
 
        fl_activate_object( dialog_->type );
        fl_set_object_lcol( dialog_->type, FL_BLACK );
@@ -185,7 +188,7 @@ void FormRef::hideBrowser() const
 }
 
 
-void FormRef::setSize( int w, int h, int dx ) const
+void FormRef::setSize( int w, int dx ) const
 {
        static int x1 = dialog_->name->x;
        static int y1 = dialog_->name->y;
@@ -200,14 +203,12 @@ void FormRef::setSize( int w, int h, int dx ) const
        static int x6 = dialog_->button_cancel->x;
        static int y6 = dialog_->button_cancel->y;
 
-       if ( form()->w != w )
-               fl_set_form_size( form(), w, h );
-
-       fl_set_form_minsize( form(), w, h );
-       fl_set_form_maxsize( form(), 2*w, h );
-
-       if ( form()->w == w ) return;
-
+       if ( form()->w != w ) {
+               minw_ = w;
+               fl_set_form_size( form(), minw_, minh_ );
+       } else
+               return;
+       
        fl_set_object_position( dialog_->name,   x1-dx, y1 );
        fl_set_object_position( dialog_->ref,    x2-dx, y2 );
        fl_set_object_position( dialog_->type,   x3-dx, y3 );