X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FXFormsView.C;h=e0b7208c1692f13299fc623ec013e5a9017436d6;hb=5ede7e4889b088219326a1d4a94a0a2a732a1379;hp=72d572a9d0bb8e0419f706fb13f277947f8a0e2d;hpb=1e394731004491d04abe436112b5a89521bbd19a;p=lyx.git diff --git a/src/frontends/xforms/XFormsView.C b/src/frontends/xforms/XFormsView.C index 72d572a9d0..e0b7208c16 100644 --- a/src/frontends/xforms/XFormsView.C +++ b/src/frontends/xforms/XFormsView.C @@ -1,46 +1,42 @@ -/* This file is part of - * ====================================================== +/** + * \file XFormsView.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * LyX, The Document Processor + * \author unknown * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. - * - * ====================================================== */ + * Full author contact details are available in file CREDITS. + */ #include -#ifdef __GNUG__ -#pragma implementation -#endif - #include "XFormsView.h" -#if FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5) -#include "frontends/xforms/lyxlookup.h" -#endif -#include "minibuffer.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 "MenuBackend.h" -#include "ToolbarDefaults.h" #include "lyxfunc.h" -#include "BufferView.h" +#include "MenuBackend.h" + +#include "frontends/Dialogs.h" + +#include "support/filetools.h" // OnlyFilename() #include +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 @@ -53,28 +49,41 @@ int C_XFormsView_atCloseMainFormCB(FL_FORM * form, void * p) XFormsView::XFormsView(int width, int height) - : LyXView() + : LyXView(), + icon_pixmap_(0), icon_mask_(0) { create_form_form_main(width, height); - fl_set_form_atclose(form_, C_XFormsView_atCloseMainFormCB, 0); + fl_set_form_atclose(getForm(), C_XFormsView_atCloseMainFormCB, 0); - // Connect the minibuffer signals - minibuffer->stringReady.connect(boost::bind(&LyXFunc::miniDispatch, getLyXFunc(), _1)); - minibuffer->timeout.connect(boost::bind(&LyXFunc::initMiniBuffer, getLyXFunc())); + view_state_con = + view_state_changed.connect(boost::bind(&XFormsView::show_view_state, this)); + focus_con = + focus_command_buffer.connect(boost::bind(&XMiniBuffer::focus, minibuffer_.get())); // Make sure the buttons are disabled if needed. updateToolbar(); + redraw_con = + getDialogs().redrawGUI().connect(boost::bind(&XFormsView::redraw, this)); } -XFormsView::~XFormsView() {} +XFormsView::~XFormsView() +{ + if (icon_pixmap_) + XFreePixmap(fl_get_display(), icon_pixmap_); + + minibuffer_->freeze(); + fl_hide_form(form_); + fl_free_form(form_); +} /// Redraw the main form. -void XFormsView::redraw() { +void XFormsView::redraw() +{ lyxerr[Debug::INFO] << "XFormsView::redraw()" << endl; - fl_redraw_form(form_); - getMiniBuffer()->redraw(); + fl_redraw_form(getForm()); + minibuffer_->redraw(); } @@ -92,20 +101,23 @@ int XFormsView::atCloseMainFormCB(FL_FORM *, void *) } -void XFormsView::setPosition(int x, int y) +void XFormsView::show(int x, int y, string const & title) { - fl_set_form_position(form_, x, y); -} + FL_FORM * form = getForm(); + fl_set_form_minsize(form, form->w, form->h); -void XFormsView::show(int place, int border, string const & title) -{ - fl_set_form_minsize(form_, form_->w, form_->h); - fl_show_form(form_, place, border, title.c_str()); - getLyXFunc()->initMiniBuffer(); -#if FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5) - InitLyXLookup(fl_get_display(), form_->window); -#endif + int placement = FL_PLACE_CENTER | FL_FREE_SIZE; + + // Did we get a valid geometry position ? + if (x >= 0 && y >= 0) { + fl_set_form_position(form, x, y); + placement = FL_PLACE_POSITION; + } + + fl_show_form(form, placement, FL_FULLBORDER, title.c_str()); + + show_view_state(); } @@ -120,7 +132,7 @@ void XFormsView::create_form_form_main(int width, int height) { // the main form form_ = fl_bgn_form(FL_NO_BOX, width, height); - form_->u_vdata = this; + getForm()->u_vdata = this; FL_OBJECT * obj = fl_add_box(FL_FLAT_BOX, 0, 0, width, height, ""); fl_set_object_color(obj, FL_MCOL, FL_MCOL); @@ -128,131 +140,95 @@ void XFormsView::create_form_form_main(int width, int height) int const air = 2; int const bw = abs(fl_get_border_width()); - // - // THE MENUBAR - // - menubar = new Menubar(this, menubackend); - - // - // TOOLBAR - // + menubar_.reset(new XFormsMenubar(this, menubackend)); - toolbar = new Toolbar(this, air, 30 + air + bw, toolbardefaults); - - // Setup the toolbar - toolbar->set(true); - - // - // WORKAREA - // + 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); - ::current_view = bufferview = new BufferView(this, air, ywork, - width - 3 * air, - workheight); - - // - // MINIBUFFER - // - - minibuffer = new MiniBuffer(this, air, height - (25 + air), - width - (2 * air), 25); + bufferview_.reset(new BufferView(this, air, ywork, + width - 3 * air, workheight)); - // - // TIMERS - // - - autosave_timeout->timeout.connect(boost::bind(&XFormsView::AutoSave, this)); - - // - // Misc - // + 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(form_, lyx_p, lyx_mask); + 0); + fl_set_form_icon(getForm(), icon_pixmap_, icon_mask_); } // set min size - fl_set_form_minsize(form_, 50, 50); + fl_set_form_minsize(getForm(), 50, 50); fl_end_form(); - - minibuffer->dd_init(); } -void XFormsView::init() +void XFormsView::setWindowTitle(string const & title, string const & icon_title) { - // Set the textclass choice - invalidateLayoutChoice(); - updateLayoutChoice(); - updateMenubar(); - - // Start autosave timer - if (lyxrc.autosave) { - autosave_timeout->setTimeout(lyxrc.autosave * 1000); - autosave_timeout->start(); - } + fl_set_form_title(getForm(), title.c_str()); + fl_winicontitle(form_->window, icon_title.c_str()); +} + - intl->InitKeyMapper(lyxrc.use_kbmap); +void XFormsView::message(string const & str) +{ + minibuffer_->message(str); } -void XFormsView::setWindowTitle(string const & title, string const & icon_title) +void XFormsView::clearMessage() { - fl_set_form_title(form_, title.c_str()); - fl_winicontitle(form_->window, icon_title.c_str()); + message(getLyXFunc().viewStatusMessage()); } -// 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().viewStatusMessage()); +} - 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()); - XUndefineCursor(fl_get_display(), getForm()->window); + /// 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 - XFlush(fl_get_display()); - fl_activate_all_forms(); + XUndefineCursor(fl_get_display(), getForm()->window); + + XFlush(fl_get_display()); + fl_activate_all_forms(); + } }