From b9d61343fc76a681b0264d65703ef2119647df56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Tue, 3 Jul 2001 15:19:04 +0000 Subject: [PATCH] text2 chane, XFormsView git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2175 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 1 + src/BufferView_pimpl.C | 4 +- src/ChangeLog | 21 +++ src/FontLoader.C | 3 +- src/LyXView.C | 177 +----------------- src/LyXView.h | 103 ++++------- src/Makefile.am | 2 + src/XFormsView.C | 257 +++++++++++++++++++++++++++ src/XFormsView.h | 60 +++++++ src/buffer.C | 4 +- src/bufferlist.C | 8 +- src/bufferview_funcs.C | 40 ----- src/bufferview_funcs.h | 4 - src/converter.C | 8 +- src/frontends/ChangeLog | 4 + src/frontends/GUIRunTime.h | 5 + src/frontends/xforms/ChangeLog | 7 + src/frontends/xforms/FileDialog.C | 6 +- src/frontends/xforms/FormDocument.C | 4 +- src/frontends/xforms/GUIRunTime.C | 7 + src/frontends/xforms/Menubar_pimpl.C | 8 +- src/frontends/xforms/Toolbar_pimpl.C | 7 +- src/frontends/xforms/Toolbar_pimpl.h | 4 +- src/insets/insettext.C | 4 +- src/lyx_cb.C | 4 +- src/lyx_gui.C | 5 +- src/lyx_gui_misc.C | 4 +- src/lyxfunc.C | 12 +- src/minibuffer.C | 4 +- src/text2.C | 43 ++++- 30 files changed, 491 insertions(+), 329 deletions(-) create mode 100644 src/XFormsView.C create mode 100644 src/XFormsView.h diff --git a/po/POTFILES.in b/po/POTFILES.in index 336d2f748e..300a18a53d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -9,6 +9,7 @@ src/converter.C src/CutAndPaste.C src/debug.C src/exporter.C +src/ext_l10n.h src/figure_form.C src/figureForm.C src/FontLoader.C diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 7fb0cc1c1a..81a5ab2d5b 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -289,7 +289,7 @@ int BufferView::Pimpl::resizeCurrentBuffer() bool selection = false; bool mark_set = false; - ProhibitInput(bv_); + owner_->prohibitInput(); owner_->message(_("Formatting document...")); @@ -350,7 +350,7 @@ int BufferView::Pimpl::resizeCurrentBuffer() redraw(); setState(); - AllowInput(bv_); + owner_->allowInput(); /// clear the "Formatting Document" message owner_->message(""); diff --git a/src/ChangeLog b/src/ChangeLog index f7694dc788..4f0f214f78 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,24 @@ +2001-07-03 Lars Gullik Bjønnes + + * text2.C (redoHeightOfParagraph): comment out stuff we don't need + in NEW_INSETS + (redoDrawingOfParagraph): ditto + (redoParagraphs): ditto + + * bufferview_funcs.[Ch]: move ProhibitInput and AllowInput to + LyXview (+ rename) + +2001-07-03 Lars Gullik Bjønnes + + * modifications to some other files because of this. + + * Makefile.am (lyx_SOURCES): add XFormsView + + * XFormsView.[Ch]: new files + + * LyXView.[Ch]: make LyXView a base class for the gui handling for + the main window. Move the gui dependand stuff to XFormsView + 2001-07-03 Jean-Marc Lasgouttes * tabular.C (GetCellInset): update cur_cell also in the row/col diff --git a/src/FontLoader.C b/src/FontLoader.C index e01669d124..2d456a6b22 100644 --- a/src/FontLoader.C +++ b/src/FontLoader.C @@ -15,9 +15,10 @@ #pragma implementation "FontLoader.h" #endif -#include "gettext.h" +#include FORMS_H_LOCATION #include "FontLoader.h" #include "FontInfo.h" +#include "gettext.h" #include "debug.h" #include "lyxrc.h" // lyxrc.font_* #include "BufferView.h" diff --git a/src/LyXView.C b/src/LyXView.C index 04e318f76a..03550c4a1f 100644 --- a/src/LyXView.C +++ b/src/LyXView.C @@ -19,23 +19,17 @@ #include #include "LyXView.h" -#include "lyx_main.h" -#if FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5) -#include "lyxlookup.h" -#endif #include "minibuffer.h" #include "debug.h" #include "intl.h" #include "lyxrc.h" #include "support/filetools.h" // OnlyFilename() -#include "layout.h" #include "lyxtext.h" #include "buffer.h" #include "frontends/Dialogs.h" #include "frontends/Toolbar.h" #include "frontends/Menubar.h" #include "MenuBackend.h" -#include "ToolbarDefaults.h" #include "lyx_gui_misc.h" // [update,Close,Redraw]AllBufferRelatedDialogs #include "bufferview_funcs.h" // CurrentState() #include "gettext.h" @@ -46,33 +40,17 @@ using std::endl; extern void AutoSave(BufferView *); extern void QuitLyX(); + LyXTextClass::size_type current_layout = 0; -// This is very temporary -BufferView * current_view; -extern "C" int C_LyXView_atCloseMainFormCB(FL_FORM *, void *); - - -LyXView::LyXView(int width, int height) +LyXView::LyXView() { - create_form_form_main(width, height); - fl_set_form_atclose(form_, C_LyXView_atCloseMainFormCB, 0); lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl; lyxfunc = new LyXFunc(this); - // Connect the minibuffer signals - minibuffer->stringReady.connect(SigC::slot(lyxfunc, - &LyXFunc::miniDispatch)); - minibuffer->timeout.connect(SigC::slot(lyxfunc, - &LyXFunc::initMiniBuffer)); - intl = new Intl; - // Make sure the buttons are disabled if needed. - toolbar->update(); - menubar->update(); - dialogs_ = new Dialogs(this); // temporary until all dialogs moved into Dialogs. dialogs_->updateBufferDependent @@ -96,14 +74,6 @@ LyXView::~LyXView() } -/// Redraw the main form. -void LyXView::redraw() { - lyxerr[Debug::INFO] << "LyXView::redraw()" << endl; - fl_redraw_form(form_); - minibuffer->redraw(); -} - - void LyXView::resize() { view()->resize(); @@ -123,12 +93,6 @@ BufferView * LyXView::view() const } -FL_FORM * LyXView::getForm() const -{ - return form_; -} - - Toolbar * LyXView::getToolbar() const { return toolbar; @@ -217,139 +181,6 @@ void LyXView::resetAutosaveTimer() } -// Callback for close main form from window manager -int LyXView::atCloseMainFormCB(FL_FORM *, void *) -{ - QuitLyX(); - return FL_IGNORE; -} - - -// Wrapper for the above -extern "C" -int C_LyXView_atCloseMainFormCB(FL_FORM * form, void * p) -{ - return LyXView::atCloseMainFormCB(form, p); -} - - -void LyXView::setPosition(int x, int y) -{ - fl_set_form_position(form_, x, y); -} - - -void LyXView::show(int place, int border, string const & title) -{ - fl_show_form(form_, place, border, title.c_str()); - lyxfunc->initMiniBuffer(); -#if FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5) - InitLyXLookup(fl_get_display(), form_->window); -#endif -} - - -void LyXView::create_form_form_main(int width, int height) - /* to make this work as it should, .lyxrc should have been - * read first; OR maybe this one should be made dynamic. - * Hmmmm. Lgb. - * We will probably not have lyxrc before the main form is - * initialized, because error messages from lyxrc parsing - * are presented (and rightly so) in GUI popups. Asger. - */ -{ - // the main form - form_ = fl_bgn_form(FL_NO_BOX, width, height); - form_->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); - - // Parameters for the appearance of the main form - int const air = 2; - int const bw = abs(fl_get_border_width()); - - // - // THE MENUBAR - // - menubar = new Menubar(this, menubackend); - - // - // TOOLBAR - // - - toolbar = new Toolbar(this, air, 30 + air + bw, toolbardefaults); - - // Setup the toolbar - toolbar->set(true); - - // - // WORKAREA - // - - 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); - - // - // TIMERS - // - - autosave_timeout.timeout.connect(SigC::slot(this, &LyXView::AutoSave)); - - // - // Misc - // - - // assign an icon to main form - string iconname = LibFileSearch("images", "lyx", "xpm"); - if (!iconname.empty()) { - unsigned int w, h; - Pixmap lyx_p, lyx_mask; - lyx_p = fl_read_pixmapfile(fl_root, - iconname.c_str(), - &w, - &h, - &lyx_mask, - 0, - 0, - 0); // this leaks - fl_set_form_icon(form_, lyx_p, lyx_mask); - } - - // set min size - fl_set_form_minsize(form_, 50, 50); - - fl_end_form(); -} - - -void LyXView::init() -{ - // Set the textclass choice - invalidateLayoutChoice(); - updateLayoutChoice(); - updateMenubar(); - - // Start autosave timer - if (lyxrc.autosave) { - autosave_timeout.setTimeout(lyxrc.autosave * 1000); - autosave_timeout.start(); - } - - intl->InitKeyMapper(lyxrc.use_kbmap); -} - - void LyXView::invalidateLayoutChoice() { last_textclass = -1; @@ -401,10 +232,8 @@ void LyXView::updateWindowTitle() title += _(" (read only)"); } } - // Don't update title if it's the same as last time if (title != last_title) { - fl_set_form_title(form_, title.c_str()); - last_title = title; + setWindowTitle(title); } } diff --git a/src/LyXView.h b/src/LyXView.h index 646ac77509..71cb180007 100644 --- a/src/LyXView.h +++ b/src/LyXView.h @@ -1,63 +1,44 @@ // -*- C++ -*- -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. - * - * ====================================================== */ -#ifndef LyXView_H -#define LyXView_H +#ifndef LYXVIEW_BASE_H +#define LYXVIEW_BASE_H #ifdef __GNUG__ #pragma interface #endif -#include -#include FORMS_H_LOCATION +#include +#include #include "LString.h" #include "frontends/Timeout.h" -#include #include "layout.h" -class LyXFunc; +class Buffer; class Toolbar; class MiniBuffer; class Intl; -class Buffer; class Menubar; class BufferView; class Dialogs; +class LyXFunc; -/** - This class is the form containing the view of the buffer. The actual buffer - view is supposed (at least IMHO) to be another class, that shows its output - in one or more LyXView's. - */ +/// class LyXView : public SigC::Object, boost::noncopyable { public: - /// constructor - LyXView(int w, int h); - - /// destructor - ~LyXView(); - - /// Where to place the form. - void setPosition(int, int); - - /// Show the main form. - void show(int, int, string const & t = string("LyX")); - - /// init (should probably be removed later) (Lgb) - void init(); - + /// + LyXView(); + /// + virtual ~LyXView(); + /// + virtual void init() = 0; + /// + virtual void setPosition(int, int) = 0; + /// + virtual void show(int, int, string const &) = 0; /// Redraw the main form. - void redraw(); + virtual void redraw() = 0; /// Resize all BufferViews in this LyXView (because the width changed) void resize(); @@ -68,9 +49,6 @@ public: /// BufferView * view() const; - /// returns a pointer to the form. - FL_FORM * getForm() const; - /// return a pointer to the toolbar Toolbar * getToolbar() const; @@ -116,39 +94,36 @@ public: /// Reset autosave timer void resetAutosaveTimer(); -private: - /// - LyXFunc * lyxfunc; - /// - Toolbar * toolbar; - /// - MiniBuffer * minibuffer; + /// + virtual void prohibitInput() const = 0; + /// + virtual void allowInput() const = 0; +protected: /// Menubar * menubar; - /// - Intl * intl; - /// - Dialogs * dialogs_; - + /// + Toolbar * toolbar; /** This is supposed to be a pointer or a list of pointers to the BufferViews currently being shown in the LyXView. So far this is not used, but that should change pretty soon. (Lgb) */ BufferView * bufferview; + /// + MiniBuffer * minibuffer; /// - void invalidateLayoutChoice(); -public: - /** This callback is run when a close event is sent from the - window manager. */ - static int atCloseMainFormCB(FL_FORM *, void *); - /// A callback - void AutoSave(); -private: + Intl * intl; /// Timeout autosave_timeout; - /// makes the main form. - void create_form_form_main(int width, int height); - /// A pointer to the form. - FL_FORM * form_; + /// A callback + void AutoSave(); + /// + void invalidateLayoutChoice(); +private: + /// + LyXFunc * lyxfunc; + /// + Dialogs * dialogs_; + /// + virtual void setWindowTitle(string const &) = 0; /** The last textclass layout list in the layout choice selector This should probably be moved to the toolbar, but for now it's here. (Asger) */ diff --git a/src/Makefile.am b/src/Makefile.am index cefe8d1433..c32b9a9896 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -83,6 +83,8 @@ lyx_SOURCES = \ Variables.h \ WorkArea.C \ WorkArea.h \ + XFormsView.C \ + XFormsView.h \ broken_headers.h \ buffer.C \ buffer.h \ diff --git a/src/XFormsView.C b/src/XFormsView.C new file mode 100644 index 0000000000..059e174a43 --- /dev/null +++ b/src/XFormsView.C @@ -0,0 +1,257 @@ + +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 1995 Matthias Ettrich + * Copyright 1995-2001 The LyX Team. + * + * ====================================================== */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +//#include +//#include + +#include "XFormsView.h" +#if FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5) +#include "lyxlookup.h" +#endif +#include "minibuffer.h" +#include "debug.h" +#include "intl.h" +#include "lyxrc.h" +#include "support/filetools.h" // OnlyFilename() +#include "frontends/Toolbar.h" +#include "frontends/Menubar.h" +#include "MenuBackend.h" +#include "ToolbarDefaults.h" +#include "lyxfunc.h" +#include "BufferView.h" + +using std::endl; + +//extern void AutoSave(BufferView *); +extern void QuitLyX(); + +// This is very temporary +BufferView * current_view; + +extern "C" int C_XFormsView_atCloseMainFormCB(FL_FORM *, void *); + + +XFormsView::XFormsView(int width, int height) + : LyXView() +{ + create_form_form_main(width, height); + fl_set_form_atclose(form_, C_XFormsView_atCloseMainFormCB, 0); + + // Connect the minibuffer signals + minibuffer->stringReady.connect(SigC::slot(getLyXFunc(), + &LyXFunc::miniDispatch)); + minibuffer->timeout.connect(SigC::slot(getLyXFunc(), + &LyXFunc::initMiniBuffer)); + + // Make sure the buttons are disabled if needed. + updateToolbar(); +} + + +XFormsView::~XFormsView() {} + + +/// Redraw the main form. +void XFormsView::redraw() { + lyxerr[Debug::INFO] << "XFormsView::redraw()" << endl; + fl_redraw_form(form_); + getMiniBuffer()->redraw(); +} + + +FL_FORM * XFormsView::getForm() const +{ + return form_; +} + + +// Callback for close main form from window manager +int XFormsView::atCloseMainFormCB(FL_FORM *, void *) +{ + QuitLyX(); + return FL_IGNORE; +} + + +// Wrapper for the above +extern "C" +int C_XFormsView_atCloseMainFormCB(FL_FORM * form, void * p) +{ + return XFormsView::atCloseMainFormCB(form, p); +} + + +void XFormsView::setPosition(int x, int y) +{ + fl_set_form_position(form_, x, y); +} + + +void XFormsView::show(int place, int border, string const & title) +{ + 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 +} + + +void XFormsView::create_form_form_main(int width, int height) + /* to make this work as it should, .lyxrc should have been + * read first; OR maybe this one should be made dynamic. + * Hmmmm. Lgb. + * We will probably not have lyxrc before the main form is + * initialized, because error messages from lyxrc parsing + * are presented (and rightly so) in GUI popups. Asger. + */ +{ + // the main form + form_ = fl_bgn_form(FL_NO_BOX, width, height); + form_->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); + + // Parameters for the appearance of the main form + int const air = 2; + int const bw = abs(fl_get_border_width()); + + // + // THE MENUBAR + // + menubar = new Menubar(this, menubackend); + + // + // TOOLBAR + // + + toolbar = new Toolbar(this, air, 30 + air + bw, toolbardefaults); + + // Setup the toolbar + toolbar->set(true); + + // + // WORKAREA + // + + 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); + + // + // TIMERS + // + + autosave_timeout.timeout.connect(SigC::slot(this, &XFormsView::AutoSave)); + + // + // Misc + // + + // assign an icon to main form + string iconname = LibFileSearch("images", "lyx", "xpm"); + if (!iconname.empty()) { + unsigned int w, h; + Pixmap lyx_p, lyx_mask; + lyx_p = fl_read_pixmapfile(fl_root, + iconname.c_str(), + &w, + &h, + &lyx_mask, + 0, + 0, + 0); // this leaks + fl_set_form_icon(form_, lyx_p, lyx_mask); + } + + // set min size + fl_set_form_minsize(form_, 50, 50); + + fl_end_form(); +} + + +void XFormsView::init() +{ + // Set the textclass choice + invalidateLayoutChoice(); + updateLayoutChoice(); + updateMenubar(); + + // Start autosave timer + if (lyxrc.autosave) { + autosave_timeout.setTimeout(lyxrc.autosave * 1000); + autosave_timeout.start(); + } + + intl->InitKeyMapper(lyxrc.use_kbmap); +} + + +void XFormsView::setWindowTitle(string const & title) +{ + fl_set_form_title(form_, title.c_str()); +} + + +// 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 +{ + view()->hideCursor(); + + 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; + } + + /* set the cursor to the watch for all forms and the canvas */ + XDefineCursor(fl_get_display(), getForm()->window, cursor); + + XFlush(fl_get_display()); + fl_deactivate_all_forms(); +} + + +void XFormsView::allowInput() const +{ + /* reset the cursor from the watch for all forms and the canvas */ + + XUndefineCursor(fl_get_display(), getForm()->window); + + XFlush(fl_get_display()); + fl_activate_all_forms(); +} diff --git a/src/XFormsView.h b/src/XFormsView.h new file mode 100644 index 0000000000..be7ce56a36 --- /dev/null +++ b/src/XFormsView.h @@ -0,0 +1,60 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 1995 Matthias Ettrich + * Copyright 1995-2001 The LyX Team. + * + * ====================================================== */ + +#ifndef LyXView_H +#define LyXView_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include +#include FORMS_H_LOCATION + +#include "LyXView.h" + +/** + This class is the form containing the view of the buffer. The actual buffer + view is supposed (at least IMHO) to be another class, that shows its output + in one or more LyXView's. + */ +class XFormsView : public LyXView { +public: + /// constructor + XFormsView(int w, int h); + /// destructor + ~XFormsView(); + /// Where to place the form. + virtual void setPosition(int, int); + /// Show the main form. + virtual void show(int, int, string const & t = string("LyX")); + /// init (should probably be removed later) (Lgb) + virtual void init(); + /// Redraw the main form. + virtual void redraw(); + /// returns a pointer to the form. + FL_FORM * getForm() const; + /// + virtual void prohibitInput() const; + /// + virtual void allowInput() const; + /** This callback is run when a close event is sent from the + window manager. */ + static int atCloseMainFormCB(FL_FORM *, void *); +private: + /// + virtual void setWindowTitle(string const &); + /// makes the main form. + void create_form_form_main(int width, int height); + /// A pointer to the form. + FL_FORM * form_; +}; +#endif diff --git a/src/buffer.C b/src/buffer.C index 8f09fd92b2..e0c1fb8124 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -3229,7 +3229,7 @@ int Buffer::runChktex() { if (!users->text) return 0; - ProhibitInput(users); + users->owner()->prohibitInput(); // get LaTeX-Filename string const name = getLatexName(); @@ -3267,7 +3267,7 @@ int Buffer::runChktex() users->redraw(); users->fitCursor(users->text); } - AllowInput(users); + users->owner()->allowInput(); return res; } diff --git a/src/bufferlist.C b/src/bufferlist.C index cda8ce2ba1..57f704e1cd 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -174,7 +174,7 @@ bool BufferList::close(Buffer * buf) if (buf->getUser()) buf->getUser()->insetUnlock(); if (buf->paragraph && !buf->isLyxClean() && !quitting) { if (buf->getUser()) - ProhibitInput(buf->getUser()); + buf->getUser()->owner()->prohibitInput(); string fname; if (buf->isUnnamed()) fname = OnlyFilename(buf->fileName()); @@ -193,7 +193,7 @@ bool BufferList::close(Buffer * buf) reask = false; } else { if (buf->getUser()) - AllowInput(buf->getUser()); + buf->getUser()->owner()->allowInput(); return false; } break; @@ -205,12 +205,12 @@ bool BufferList::close(Buffer * buf) break; case 3: // Cancel if (buf->getUser()) - AllowInput(buf->getUser()); + buf->getUser()->owner()->allowInput(); return false; } } if (buf->getUser()) - AllowInput(buf->getUser()); + buf->getUser()->owner()->allowInput(); } bstore.release(buf); diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index fde594460b..f44336ed11 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -103,46 +103,6 @@ void changeDepth(BufferView * bv, LyXText * text, int decInc) } -// 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 ProhibitInput(BufferView * bv) -{ - bv->hideCursor(); - - 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; - } - - /* set the cursor to the watch for all forms and the canvas */ - XDefineCursor(fl_get_display(), bv->owner()->getForm()->window, - cursor); - - XFlush(fl_get_display()); - fl_deactivate_all_forms(); -} - - -void AllowInput(BufferView * bv) -{ - /* reset the cursor from the watch for all forms and the canvas */ - - XUndefineCursor(fl_get_display(), bv->owner()->getForm()->window); - - XFlush(fl_get_display()); - fl_activate_all_forms(); -} - - void Code(BufferView * bv) { LyXFont font(LyXFont::ALL_IGNORE); diff --git a/src/bufferview_funcs.h b/src/bufferview_funcs.h index b073c98f14..51b0823be3 100644 --- a/src/bufferview_funcs.h +++ b/src/bufferview_funcs.h @@ -41,10 +41,6 @@ extern void Tex(BufferView *); /// extern void changeDepth(BufferView *, LyXText *, int); /// -extern void ProhibitInput(BufferView *); -/// -extern void AllowInput(BufferView *); -/// extern void Code(BufferView *); /// extern void Sans(BufferView *); diff --git a/src/converter.C b/src/converter.C index c9248c5150..e07402318f 100644 --- a/src/converter.C +++ b/src/converter.C @@ -761,7 +761,7 @@ bool Converters::scanLog(Buffer const * buffer, string const & command, BufferView * bv = buffer->getUser(); bool need_redraw = false; if (bv) { - ProhibitInput(bv); + bv->owner()->prohibitInput(); // Remove all error insets need_redraw = bv->removeAutoInsets(); } @@ -779,7 +779,7 @@ bool Converters::scanLog(Buffer const * buffer, string const & command, bv->redraw(); bv->fitCursor(bv->text); } - AllowInput(bv); + bv->owner()->allowInput(); } if ((result & LaTeX::ERRORS)) { @@ -819,7 +819,7 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command) bool need_redraw = false; if (bv) { - ProhibitInput(bv); + bv->owner()->prohibitInput(); bv->owner()->message(_("Running LaTeX...")); // Remove all error insets need_redraw = bv->removeAutoInsets(); @@ -873,7 +873,7 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command) } if (bv) - AllowInput(bv); + bv->owner()->allowInput(); int const ERROR_MASK = LaTeX::NO_LOGFILE | diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 835ca7d792..b0e7172e43 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,7 @@ +2001-07-03 Lars Gullik Bjønnes + + * GUIRunTime.h: add createMainView + 2001-06-27 John Levon * Dialogs.h: add showSpellcheckerPreferences diff --git a/src/frontends/GUIRunTime.h b/src/frontends/GUIRunTime.h index 51223b9845..4f489728ee 100644 --- a/src/frontends/GUIRunTime.h +++ b/src/frontends/GUIRunTime.h @@ -15,6 +15,8 @@ #pragma interface #endif +class LyXView; + /** The LyX GUI independent guiruntime class The GUI interface is implemented in the corresponding frontends GUIRunTime.C file. @@ -33,5 +35,8 @@ public: /// This is run first in the LyXGUI constructor. static void setDefaults(); + /// + static + LyXView * createMainView(int w, int h); }; #endif diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 859b463922..d8a556c6c1 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,10 @@ +2001-07-03 Lars Gullik Bjønnes + + * Toolbar_pimpl.h: make owner be a XFormsView, small changes + because of this. + + * GUIRunTime.C (createMainView): implement + 2001-06-22 John Levon * FormCharacter.C: diff --git a/src/frontends/xforms/FileDialog.C b/src/frontends/xforms/FileDialog.C index d64f0e9a61..c876ffc0a3 100644 --- a/src/frontends/xforms/FileDialog.C +++ b/src/frontends/xforms/FileDialog.C @@ -18,7 +18,7 @@ #include "support/lstrings.h" -// temp. hack until Allow/ProhibitInput is not +// temp. hack until Allow/prohibitInput is not // needed any more in src/ - for now it's simplest // to leave it there #include "LyXView.h" @@ -67,14 +67,14 @@ FileDialog::Result const FileDialog::Select(string const & path, string const & // no support for asynchronous selection yet - ProhibitInput(lv_->view()); + lv_->prohibitInput(); FileDialog::Result result; result.first = FileDialog::Chosen; result.second = private_->Select(title_, path, filter, suggested); - AllowInput(lv_->view()); + lv_->allowInput(); return result; } diff --git a/src/frontends/xforms/FormDocument.C b/src/frontends/xforms/FormDocument.C index 05d96eefaf..75c418227e 100644 --- a/src/frontends/xforms/FormDocument.C +++ b/src/frontends/xforms/FormDocument.C @@ -1025,7 +1025,7 @@ void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long) if (!ob) ob = class_->choice_doc_class; - ProhibitInput(lv_->view()); + lv_->prohibitInput(); unsigned int tc = combo_doc_class->get() - 1; if (textclasslist.Load(tc)) { @@ -1047,7 +1047,7 @@ void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long) _("Reverting to original document class.")); combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1); } - AllowInput(lv_->view()); + lv_->allowInput(); } diff --git a/src/frontends/xforms/GUIRunTime.C b/src/frontends/xforms/GUIRunTime.C index aefa36811d..13dd471b58 100644 --- a/src/frontends/xforms/GUIRunTime.C +++ b/src/frontends/xforms/GUIRunTime.C @@ -16,6 +16,7 @@ #endif #include "GUIRunTime.h" +#include "XFormsView.h" #include "debug.h" // I keep these here so that it will be processed as early in @@ -110,3 +111,9 @@ void GUIRunTime::setDefaults() | FL_PDMenuFontSize | FL_PDBorderWidth, &cntl); } + + +LyXView * GUIRunTime::createMainView(int w, int h) +{ + return new XFormsView(w, h); +} diff --git a/src/frontends/xforms/Menubar_pimpl.C b/src/frontends/xforms/Menubar_pimpl.C index f15d7c7984..5fbcc6b716 100644 --- a/src/frontends/xforms/Menubar_pimpl.C +++ b/src/frontends/xforms/Menubar_pimpl.C @@ -21,7 +21,7 @@ #include "kbmap.h" #include "buffer.h" #include "Dialogs.h" -#include "LyXView.h" +#include "XFormsView.h" #include "lyxfunc.h" #include "FloatList.h" #include "support/lstrings.h" @@ -97,7 +97,7 @@ Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mb) void Menubar::Pimpl::makeMenubar(Menu const & menu) { - FL_FORM * form = owner_->getForm(); + FL_FORM * form = static_cast(owner_)->getForm(); int moffset = 0; // Create menu frame if there is non yet. @@ -565,8 +565,8 @@ void Menubar::Pimpl::MenuCallback(FL_OBJECT * ob, long button) item->submenu(), submenus); if (menu != -1) { // place popup - fl_setpup_position(view->getForm()->x + ob->x, - view->getForm()->y + ob->y + ob->h + 10); + fl_setpup_position(static_cast(view)->getForm()->x + ob->x, + static_cast(view)->getForm()->y + ob->y + ob->h + 10); int choice = fl_dopup(menu); if (button == 1) { diff --git a/src/frontends/xforms/Toolbar_pimpl.C b/src/frontends/xforms/Toolbar_pimpl.C index b80357e11e..4657f45b8e 100644 --- a/src/frontends/xforms/Toolbar_pimpl.C +++ b/src/frontends/xforms/Toolbar_pimpl.C @@ -21,7 +21,7 @@ #include "Toolbar_pimpl.h" #include "debug.h" -#include "LyXView.h" +#include "XFormsView.h" #include "lyxfunc.h" #include "func_status.h" #include "BufferView.h" @@ -81,7 +81,7 @@ Toolbar::Pimpl::toolbarItem::operator=(toolbarItem const & ti) { Toolbar::Pimpl::Pimpl(LyXView * o, int x, int y) - : owner(o), sxpos(x), sypos(y) + : owner(static_cast(o)), sxpos(x), sypos(y) { combox = 0; #if FL_REVISION < 89 @@ -268,7 +268,7 @@ namespace { void ToolbarCB(FL_OBJECT * ob, long ac) { - LyXView * owner = static_cast(ob->u_vdata); + XFormsView * owner = static_cast(ob->u_vdata); string res = owner->getLyXFunc()->Dispatch(int(ac)); if (!res.empty()) @@ -530,6 +530,7 @@ void Toolbar::Pimpl::reset() lightReset(); } + void Toolbar::Pimpl::lightReset() { xpos = sxpos - standardspacing; ypos = sypos; diff --git a/src/frontends/xforms/Toolbar_pimpl.h b/src/frontends/xforms/Toolbar_pimpl.h index 128af77cb6..21bf7ce629 100644 --- a/src/frontends/xforms/Toolbar_pimpl.h +++ b/src/frontends/xforms/Toolbar_pimpl.h @@ -27,6 +27,8 @@ #pragma interface #endif +class XFormsView; + /** The LyX xforms toolbar class */ struct Toolbar::Pimpl { @@ -98,7 +100,7 @@ public: /// The list containing all the buttons ToolbarList toollist; /// - LyXView * owner; + XFormsView * owner; #if FL_REVISION < 89 /// FL_OBJECT * bubble_timer; diff --git a/src/insets/insettext.C b/src/insets/insettext.C index e4e845396f..ff1d911919 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -1702,7 +1702,7 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const bool selection = false; bool mark_set = false; -// ProhibitInput(bv); +// bv->owner()->prohibitInput(); if (locked) { LyXText * t = getLyXText(bv); @@ -1746,7 +1746,7 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const // this will scroll the screen such that the cursor becomes visible bv->updateScrollbar(); -// AllowInput(bv); +// bv->owner()->allowInput(); if (the_locking_inset) { /// then resize all LyXText in text-insets inset_x = cx(bv) - top_x + drawTextXOffset; diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 8390461d15..01f8b86075 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -472,7 +472,7 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph) void MenuInsertLabel(BufferView * bv, string const & arg) { string label(arg); - ProhibitInput(bv); + bv->owner()->prohibitInput(); if (label.empty()) { Paragraph * par = bv->text->cursor.par(); LyXLayout const * layout = @@ -520,7 +520,7 @@ void MenuInsertLabel(BufferView * bv, string const & arg) InsetLabel * inset = new InsetLabel( p ); bv->insertInset( inset ); } - AllowInput(bv); + bv->owner()->allowInput(); } diff --git a/src/lyx_gui.C b/src/lyx_gui.C index ed579f89c0..27526090cb 100644 --- a/src/lyx_gui.C +++ b/src/lyx_gui.C @@ -49,7 +49,6 @@ FD_form_figure * fd_form_figure; extern LyXServer * lyxserver; extern bool finished; // flag, that we are quitting the program extern BufferList bufferlist; -extern GUIRunTime guiruntime; extern string user_lyxdir; FL_CMD_OPT cmdopt[] = @@ -267,7 +266,7 @@ void LyXGUI::init() void LyXGUI::create_forms() { lyxerr[Debug::INIT] << "Initializing LyXView..." << endl; - lyxViews = new LyXView(width, height); + lyxViews = GUIRunTime::createMainView(width, height); lyxerr[Debug::INIT] << "Initializing LyXView...done" << endl; // From here down should be done by somebody else. (Lgb) @@ -312,7 +311,7 @@ void LyXGUI::runTime() { if (!gui) return; - guiruntime.runTime(); + GUIRunTime::runTime(); } diff --git a/src/lyx_gui_misc.C b/src/lyx_gui_misc.C index 517031f1f5..f6bd2605d5 100644 --- a/src/lyx_gui_misc.C +++ b/src/lyx_gui_misc.C @@ -137,12 +137,12 @@ void WriteAlert(string const & s1, string const & s2, string const & s3) lview = current_view->owner(); if (lview) { /// Write to minibuffer - ProhibitInput(current_view); + lview->prohibitInput(); string const msg = s1 + ' ' + s2 + ' ' + s3; lview->message(msg); fl_set_resource("flAlert.dismiss.label", _("Dismiss")); fl_show_alert(s1.c_str(), s2.c_str(), s3.c_str(), 0); - AllowInput(current_view); + lview->allowInput(); } else { /// Write to lyxerr lyxerr << "----------------------------------------" << endl diff --git a/src/lyxfunc.C b/src/lyxfunc.C index fe755a51e1..9a5f2b2410 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1070,25 +1070,25 @@ string const LyXFunc::Dispatch(int ac, setErrorMessage(N_("Missing argument")); break; } - ProhibitInput(owner->view()); + owner->prohibitInput(); string const fname = i18nLibFileSearch("doc", arg, "lyx"); if (fname.empty()) { lyxerr << "LyX: unable to find documentation file `" << arg << "'. Bad installation?" << endl; - AllowInput(owner->view()); + owner->allowInput(); break; } ostringstream str; str << _("Opening help file") << ' ' << MakeDisplayPath(fname) << "..."; owner->message(str.str().c_str()); - owner->view()->buffer(bufferlist.loadLyXFile(fname,false)); - AllowInput(owner->view()); + owner->view()->buffer(bufferlist.loadLyXFile(fname, false)); + owner->allowInput(); break; } case LFUN_HELP_VERSION: { - ProhibitInput(owner->view()); + owner->prohibitInput(); string msg(_("LyX Version ")); msg += LYX_VERSION; msg += " of "; @@ -1098,7 +1098,7 @@ string const LyXFunc::Dispatch(int ac, + MakeDisplayPath(system_lyxdir)).c_str(), (_("User directory: ") + MakeDisplayPath(user_lyxdir)).c_str()); - AllowInput(owner->view()); + owner->allowInput(); break; } diff --git a/src/minibuffer.C b/src/minibuffer.C index f6b67c4cdb..70015b2c2e 100644 --- a/src/minibuffer.C +++ b/src/minibuffer.C @@ -23,6 +23,7 @@ #include "support/lyxalgo.h" #include "support/filetools.h" #include "LyXView.h" +#include "XFormsView.h" #include "gettext.h" #include "LyXAction.h" #include "BufferView.h" @@ -246,7 +247,8 @@ void MiniBuffer::prepare() text.erase(); fl_set_input(the_buffer, ""); activate(); - fl_set_focus_object(owner_->getForm(), the_buffer); + fl_set_focus_object(static_cast(owner_)->getForm(), + the_buffer); } diff --git a/src/text2.C b/src/text2.C index 7c7741710b..83c8261a99 100644 --- a/src/text2.C +++ b/src/text2.C @@ -758,6 +758,8 @@ void LyXText::redoHeightOfParagraph(BufferView * bview, LyXCursor const & cur) int y = cur.y() - tmprow->baseline(); setHeightOfRow(bview, tmprow); + +#if 0 Paragraph * first_phys_par = tmprow->par(); // find the first row of the paragraph @@ -773,6 +775,13 @@ void LyXText::redoHeightOfParagraph(BufferView * bview, LyXCursor const & cur) y -= tmprow->height(); setHeightOfRow(bview, tmprow); } +#else + while (tmprow->previous() && tmprow->previous()->par() == tmprow->par()) { + tmprow = tmprow->previous(); + y -= tmprow->height(); + setHeightOfRow(bview, tmprow); + } +#endif // we can set the refreshing parameters now status = LyXText::NEED_MORE_REFRESH; @@ -788,6 +797,8 @@ void LyXText::redoDrawingOfParagraph(BufferView * bview, LyXCursor const & cur) int y = cur.y() - tmprow->baseline(); setHeightOfRow(bview, tmprow); + +#if 0 Paragraph * first_phys_par = tmprow->par(); // find the first row of the paragraph @@ -800,7 +811,12 @@ void LyXText::redoDrawingOfParagraph(BufferView * bview, LyXCursor const & cur) tmprow = tmprow->previous(); y -= tmprow->height(); } - +#else + while (tmprow->previous() && tmprow->previous()->par() == tmprow->par()) { + tmprow = tmprow->previous(); + y -= tmprow->height(); + } +#endif // we can set the refreshing parameters now if (status == LyXText::UNCHANGED || y < refresh_y) { refresh_y = y; @@ -818,13 +834,15 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur, Paragraph const * endpar) const { Row * tmprow2; - Paragraph * tmppar = 0, * first_phys_par = 0; + Paragraph * tmppar = 0; + Paragraph * first_phys_par = 0; Row * tmprow = cur.row(); int y = cur.y() - tmprow->baseline(); - - if (!tmprow->previous()){ + +#if 0 + if (!tmprow->previous()) { first_phys_par = firstParagraph(); // a trick/hack for UNDO } else { first_phys_par = tmprow->par(); @@ -841,7 +859,22 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur, y -= tmprow->height(); } } - +#else + if (!tmprow->previous()) { + // a trick/hack for UNDO + // Can somebody please tell me _why_ this solves + // anything. (Lgb) + first_phys_par = firstParagraph(); + } else { + first_phys_par = tmprow->par(); + while (tmprow->previous() + && tmprow->previous()->par() == first_phys_par) { + tmprow = tmprow->previous(); + y -= tmprow->height(); + } + } +#endif + // we can set the refreshing parameters now status = LyXText::NEED_MORE_REFRESH; refresh_y = y;