/**
* \file XFormsView.C
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
* \author unknown
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include "XFormsView.h"
-#include FORMS_H_LOCATION
-#if FL_VERSION < 1 && (FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5))
-#include "frontends/xforms/lyxlookup.h"
-#endif
-#include "frontends/xforms/XMiniBuffer.h"
+
+#include "XFormsMenubar.h"
+#include "XFormsToolbar.h"
+#include "XMiniBuffer.h"
+
+#include "BufferView.h"
#include "debug.h"
-#include "intl.h"
-#include "lyxrc.h"
-#include "support/filetools.h" // OnlyFilename()
-#include "frontends/Toolbar.h"
-#include "frontends/Menubar.h"
-#include "frontends/Timeout.h"
-#include "frontends/Dialogs.h"
-#include "MenuBackend.h"
-#include "ToolbarDefaults.h"
#include "lyxfunc.h"
-#include "bufferview_funcs.h"
-#include "BufferView.h"
+#include "MenuBackend.h"
+
+#include "frontends/Dialogs.h"
+
+#include "support/filetools.h" // OnlyFilename()
#include <boost/bind.hpp>
-#include <boost/signals/connection.hpp>
+
+using lyx::support::LibFileSearch;
+
using std::abs;
using std::endl;
+using std::string;
+
//extern void AutoSave(BufferView *);
extern void QuitLyX();
-// This is very temporary
-BufferView * current_view;
-
extern "C" {
static
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_);
fl_show_form(form, placement, FL_FULLBORDER, title.c_str());
show_view_state();
-#if FL_VERSION < 1 && (FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5))
- InitLyXLookup(fl_get_display(), form_->window);
-#endif
}
int const air = 2;
int const bw = abs(fl_get_border_width());
- menubar_.reset(new Menubar(this, menubackend));
+ menubar_.reset(new XFormsMenubar(this, menubackend));
- toolbar_.reset(new Toolbar(this, air, 30 + air + bw, toolbardefaults));
+ toolbar_.reset(new XFormsToolbar(this, air, 30 + air + bw));
+ toolbar_->init();
int const ywork = 60 + 2 * air + bw;
int const workheight = height - ywork - (25 + 2 * air);
bufferview_.reset(new BufferView(this, air, ywork,
width - 3 * air, workheight));
- ::current_view = bufferview_.get();
- minibuffer_.reset(new XMiniBuffer(this, *controlcommand_,
+ minibuffer_.reset(new XMiniBuffer(*controlcommand_,
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
fl_set_form_minsize(getForm(), 50, 50);
fl_end_form();
-
- minibuffer_->dd_init();
}
}
-void XFormsView::show_view_state()
+void XFormsView::clearMessage()
{
message(getLyXFunc().view_status_message());
}
-// How should this actually work? Should it prohibit input in all BufferViews,
-// or just in the current one? If "just the current one", then it should be
-// placed in BufferView. If "all BufferViews" then LyXGUI (I think) should
-// run "prohibitInput" on all LyXViews which will run prohibitInput on all
-// BufferViews. Or is it perhaps just the (input in) BufferViews in the
-// current LyXView that should be prohibited (Lgb) (This applies to
-// "allowInput" as well.)
-void XFormsView::prohibitInput() const
+void XFormsView::show_view_state()
{
- view()->hideCursor();
+ message(getLyXFunc().view_status_message());
+}
- static Cursor cursor;
- static bool cursor_undefined = true;
- if (cursor_undefined) {
- cursor = XCreateFontCursor(fl_get_display(), XC_watch);
- XFlush(fl_get_display());
- cursor_undefined = false;
- }
+void XFormsView::busy(bool yes) const
+{
+ if (yes) {
+ view()->hideCursor();
- /* set the cursor to the watch for all forms and the canvas */
- XDefineCursor(fl_get_display(), getForm()->window, cursor);
+ static Cursor cursor;
+ static bool cursor_undefined = true;
- XFlush(fl_get_display());
- fl_deactivate_all_forms();
-}
+ if (cursor_undefined) {
+ cursor = XCreateFontCursor(fl_get_display(), XC_watch);
+ XFlush(fl_get_display());
+ cursor_undefined = false;
+ }
+ /// set the cursor to the watch for all forms and the canvas
+ XDefineCursor(fl_get_display(), getForm()->window, cursor);
-void XFormsView::allowInput() const
-{
- /* reset the cursor from the watch for all forms and the canvas */
+ XFlush(fl_get_display());
+
+ /// we only need to deactivate to prevent resetting the cursor
+ /// to I-beam over the workarea
+ fl_deactivate_all_forms();
+ } else {
+ /// reset the cursor from the watch for all forms and the canvas
- XUndefineCursor(fl_get_display(), getForm()->window);
+ XUndefineCursor(fl_get_display(), getForm()->window);
- XFlush(fl_get_display());
- fl_activate_all_forms();
+ XFlush(fl_get_display());
+ fl_activate_all_forms();
+ }
}