/**
* \file FormBaseDeprecated.C
- * Copyright 2000-2001 The LyX Team.
- * See the file COPYING.
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * \author Angus Leeming, a.leeming@ic.ac.uk
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS
*/
#include <config.h>
#include "frontends/LyXView.h"
#include "support/LAssert.h"
+#include "support/filetools.h" // LibFileSearch
#include <boost/bind.hpp>
} // extern "C"
-FormBaseDeprecated::FormBaseDeprecated(LyXView * lv, Dialogs * d,
+FormBaseDeprecated::FormBaseDeprecated(LyXView & lv, Dialogs & d,
string const & t, bool allowResize)
- : lv_(lv), d_(d), title_(t),
+ : lv_(lv), d_(d), title_(t), icon_pixmap_(0), icon_mask_(0),
minw_(0), minh_(0), allow_resize_(allowResize),
tooltips_(new Tooltips())
-{
- lyx::Assert(lv && d);
-}
+{}
FormBaseDeprecated::~FormBaseDeprecated()
{
+ if (icon_pixmap_)
+ XFreePixmap(fl_get_display(), icon_pixmap_);
+
delete tooltips_;
}
void FormBaseDeprecated::connect()
{
fl_set_form_minsize(form(), minw_, minh_);
- r_ = d_->redrawGUI.connect(boost::bind(&FormBaseDeprecated::redraw, this));
+ r_ = d_.redrawGUI().connect(boost::bind(&FormBaseDeprecated::redraw, this));
}
}
-void FormBaseDeprecated::show()
+void FormBaseDeprecated::prepare_to_show()
{
- if (!form()) {
- build();
-
- double const scale = scale_to_fit_tabs(form());
- if (scale > 1.001)
- scale_form(form(), scale);
-
- bc().refresh();
+ build();
+
+ double const scale = scale_to_fit_tabs(form());
+ if (scale > 1.001)
+ scale_form(form(), scale);
+
+ bc().refresh();
+
+ // work around dumb xforms sizing bug
+ minw_ = form()->w;
+ minh_ = form()->h;
+
+ fl_set_form_atclose(form(), C_WMHideCB, 0);
+
+ // set the title for the minimized form
+ if (!lyxrc.dialogs_iconify_with_main)
+ fl_winicontitle(form()->window, title_.c_str());
+
+ // assign an icon to the form
+ string const iconname = LibFileSearch("images", "lyx", "xpm");
+ if (!iconname.empty()) {
+ unsigned int w, h;
+ icon_pixmap_ = fl_read_pixmapfile(fl_root,
+ iconname.c_str(),
+ &w,
+ &h,
+ &icon_mask_,
+ 0, 0, 0);
+ fl_set_form_icon(form(), icon_pixmap_, icon_mask_);
+ }
+}
- // work around dumb xforms sizing bug
- minw_ = form()->w;
- minh_ = form()->h;
- fl_set_form_atclose(form(), C_WMHideCB, 0);
+void FormBaseDeprecated::show()
+{
+ if (!form()) {
+ prepare_to_show();
}
+ // make sure the form is up to date.
fl_freeze_form(form());
update();
fl_unfreeze_form(form());
if (!allow_resize_)
fl_set_form_maxsize(form(), minw_, minh_);
+ string const maximize_title = "LyX: " + title_;
+ int const iconify_policy =
+ lyxrc.dialogs_iconify_with_main ? FL_TRANSIENT : 0;
+
fl_show_form(form(),
FL_PLACE_MOUSE | FL_FREE_SIZE,
- (lyxrc.dialogs_iconify_with_main ? FL_TRANSIENT : 0),
- title_.c_str());
+ iconify_policy,
+ maximize_title.c_str());
}
+ // For some strange reason known only to xforms, the tooltips can only
+ // be set on a form that is already visible...
tooltips().set();
}
}
-FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t,
+FormBaseBI::FormBaseBI(LyXView & lv, Dialogs & d, string const & t,
bool allowResize)
: FormBaseDeprecated(lv, d, t, allowResize)
{}
void FormBaseBI::connect()
{
- h_ = d_->hideAll.connect(boost::bind(&FormBaseBI::hide, this));
+ h_ = d_.hideAll.connect(boost::bind(&FormBaseBI::hide, this));
FormBaseDeprecated::connect();
}
-FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t,
+FormBaseBD::FormBaseBD(LyXView & lv, Dialogs & d, string const & t,
bool allowResize)
: FormBaseDeprecated(lv, d, t, allowResize)
{}
void FormBaseBD::connect()
{
- u_ = d_->updateBufferDependent.
+ u_ = d_.updateBufferDependent.
connect(boost::bind(&FormBaseBD::updateSlot, this, _1));
- h_ = d_->hideBufferDependent.
+ h_ = d_.hideBufferDependent.
connect(boost::bind(&FormBaseBD::hide, this));
FormBaseDeprecated::connect();
}