+2002-09-30 Angus Leeming <leeming@lyx.org>
+
+ * FormBase.[Ch]:
+ * FormBaseDeprecated.[Ch]:
+ (icon_pixmap_, icon_mask_) new member variables.
+ (prepare_to_show) new method, containing initialisation code invoked
+ the first time show() is called.
+ (d-tor) destroy icon_pixmap_, if it exists.
+ (show) ensure that the icon pixmap is generated only once.
+
+ * XFormsView.[Ch]:
+ (icon_pixmap_, icon_mask_) new member variables.
+ (d-tor) destroy icon_pixmap_, if it exists.
+ (create_form_form_main) assign the generated pixmap to the new
+ icon_pixmap_ member variable.
+
2002-09-26 Angus Leeming <leeming@lyx.org>
* xscreen.h: don't #include "XWorkArea.h", forward-declare XWorkArea.
FormBase::FormBase(string const & t, bool allowResize)
: ViewBase(), minw_(0), minh_(0), allow_resize_(allowResize),
- title_(t), tooltips_(new Tooltips())
+ title_(t), icon_pixmap_(0), icon_mask_(0),
+ tooltips_(new Tooltips())
{}
FormBase::~FormBase()
{
+ if (icon_pixmap_)
+ XFreePixmap(fl_get_display(), icon_pixmap_);
+
delete tooltips_;
}
}
-void FormBase::show()
+void FormBase::prepare_to_show()
{
- if (!form()) {
- 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 (!getController().IconifyWithMain())
+ 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_);
}
+}
- // use minw_ to flag whether the dialog has ever been shown
- // (Needed now that build() is/should be called from the controller)
- if (minw_ == 0) {
- 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;
+void FormBase::show()
+{
+ // build() is/should be called from the controller, so form() should
+ // always exist.
+ lyx::Assert(form());
- fl_set_form_atclose(form(), C_WMHideCB, 0);
+ // we use minw_ to flag whether the dialog has ever been shown.
+ // In turn, prepare_to_show() initialises various bits 'n' pieces
+ // (including minw_).
+ if (minw_ == 0) {
+ prepare_to_show();
}
+ // make sure the form is up to date.
fl_freeze_form(form());
- update(); // make sure its up-to-date
+ update();
fl_unfreeze_form(form());
if (form()->visible) {
fl_set_form_maxsize(form(), minw_, minh_);
string const maximize_title = "LyX: " + title_;
- int const iconify_policy = getController().IconifyWithMain() ?
- FL_TRANSIENT : 0;
+ int const iconify_policy =
+ getController().IconifyWithMain() ? FL_TRANSIENT : 0;
fl_show_form(form(),
FL_PLACE_MOUSE | FL_FREE_SIZE,
iconify_policy,
maximize_title.c_str());
-
- if (iconify_policy == 0) {
- // set title for minimized form
- string const minimize_title = title_;
- fl_winicontitle(form()->window, minimize_title.c_str());
-
- // assign an icon to form
- string const iconname = LibFileSearch("images", "lyx", "xpm");
- if (!iconname.empty()) {
- unsigned int w, h;
- Pixmap icon_mask;
- Pixmap const icon_p = fl_read_pixmapfile(fl_root,
- iconname.c_str(),
- &w,
- &h,
- &icon_mask,
- 0, 0, 0); // this leaks
- fl_set_form_icon(form(), icon_p, icon_mask);
- }
- }
}
+ // For some strange reason known only to xforms, the tooltips can only
+ // be set on a form that is already visible...
tooltips().set();
}
#endif
#include "ViewBase.h"
-#include "LString.h"
#include "ButtonPolicies.h"
#include "FeedbackController.h"
+#include "forms_fwd.h"
+#include "LString.h"
#include <boost/scoped_ptr.hpp>
-
-#include "forms_fwd.h"
+#include <X11/Xlib.h> // for Pixmap
class xformsBC;
class Tooltips;
*/
virtual void redraw();
+ /** Called on the first show() request, initialising various bits and
+ * pieces.
+ */
+ void prepare_to_show();
+
/// The dialog's minimum allowable dimensions.
int minw_;
///
int minh_;
/// Can the dialog be resized after it has been created?
bool allow_resize_;
- /// dialog title, displayed by WM.
+ /// dialog title, displayed by the window manager.
string title_;
+ /// Passed to the window manager to give a pretty little symbol ;-)
+ Pixmap icon_pixmap_;
+ ///
+ Pixmap icon_mask_;
///
Tooltips * tooltips_;
};
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())
{}
FormBaseDeprecated::~FormBaseDeprecated()
{
+ if (icon_pixmap_)
+ XFreePixmap(fl_get_display(), icon_pixmap_);
+
delete tooltips_;
}
}
-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());
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;
+ int const iconify_policy =
+ lyxrc.dialogs_iconify_with_main ? FL_TRANSIENT : 0;
fl_show_form(form(),
FL_PLACE_MOUSE | FL_FREE_SIZE,
iconify_policy,
maximize_title.c_str());
-
- if (iconify_policy == 0) {
- // set title for minimized form
- string const minimize_title = title_;
- fl_winicontitle(form()->window, minimize_title.c_str());
-
- // assign an icon to form
- string const iconname = LibFileSearch("images", "lyx", "xpm");
- if (!iconname.empty()) {
- unsigned int w, h;
- Pixmap icon_mask;
- Pixmap const icon_p = fl_read_pixmapfile(fl_root,
- iconname.c_str(),
- &w,
- &h,
- &icon_mask,
- 0, 0, 0); // this leaks
- fl_set_form_icon(form(), icon_p, icon_mask);
- }
- }
}
+ // For some strange reason known only to xforms, the tooltips can only
+ // be set on a form that is already visible...
tooltips().set();
}
#pragma interface
#endif
-#include "LString.h"
#include "xformsBC.h"
#include "FeedbackController.h"
-
#include "forms_fwd.h"
+#include "LString.h"
#include <boost/utility.hpp>
#include <boost/signals/connection.hpp>
+#include <X11/Xlib.h> // for Pixmap
class Buffer;
class Dialogs;
string title_;
private:
+ /** Called on the first show() request, initialising various bits and
+ * pieces.
+ */
+ void prepare_to_show();
+
+ /// Passed to the window manager to give a pretty little symbol ;-)
+ Pixmap icon_pixmap_;
+ ///
+ Pixmap icon_mask_;
/// The dialog's minimum allowable dimensions.
int minw_;
///
XFormsView::XFormsView(int width, int height)
- : LyXView()
+ : LyXView(),
+ icon_pixmap_(0), icon_mask_(0)
{
create_form_form_main(width, height);
fl_set_form_atclose(getForm(), C_XFormsView_atCloseMainFormCB, 0);
XFormsView::~XFormsView()
{
+ if (icon_pixmap_)
+ XFreePixmap(fl_get_display(), icon_pixmap_);
+
minibuffer_->freeze();
fl_hide_form(form_);
fl_free_form(form_);
air, height - (25 + air), width - (2 * air), 25));
// assign an icon to main form
- string iconname = LibFileSearch("images", "lyx", "xpm");
+ string const iconname = LibFileSearch("images", "lyx", "xpm");
if (!iconname.empty()) {
unsigned int w, h;
- Pixmap lyx_p, lyx_mask;
- lyx_p = fl_read_pixmapfile(fl_root,
+ icon_pixmap_ = fl_read_pixmapfile(fl_root,
iconname.c_str(),
&w,
&h,
- &lyx_mask,
+ &icon_mask_,
0,
0,
- 0); // this leaks
- fl_set_form_icon(getForm(), lyx_p, lyx_mask);
+ 0);
+ fl_set_form_icon(getForm(), icon_pixmap_, icon_mask_);
}
// set min size
#include "forms_fwd.h"
#include "frontends/LyXView.h"
+#include <X11/Xlib.h> // for Pixmap
class XMiniBuffer;
/// the main form.
FL_FORM * form_;
+ /// Passed to the window manager to give a pretty little symbol ;-)
+ Pixmap icon_pixmap_;
+ ///
+ Pixmap icon_mask_;
};
#endif