]> git.lyx.org Git - features.git/commitdiff
text2 chane, XFormsView
authorLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 3 Jul 2001 15:19:04 +0000 (15:19 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 3 Jul 2001 15:19:04 +0000 (15:19 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2175 a592a061-630c-0410-9148-cb99ea01b6c8

30 files changed:
po/POTFILES.in
src/BufferView_pimpl.C
src/ChangeLog
src/FontLoader.C
src/LyXView.C
src/LyXView.h
src/Makefile.am
src/XFormsView.C [new file with mode: 0644]
src/XFormsView.h [new file with mode: 0644]
src/buffer.C
src/bufferlist.C
src/bufferview_funcs.C
src/bufferview_funcs.h
src/converter.C
src/frontends/ChangeLog
src/frontends/GUIRunTime.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/FileDialog.C
src/frontends/xforms/FormDocument.C
src/frontends/xforms/GUIRunTime.C
src/frontends/xforms/Menubar_pimpl.C
src/frontends/xforms/Toolbar_pimpl.C
src/frontends/xforms/Toolbar_pimpl.h
src/insets/insettext.C
src/lyx_cb.C
src/lyx_gui.C
src/lyx_gui_misc.C
src/lyxfunc.C
src/minibuffer.C
src/text2.C

index 336d2f748ec1f159a7c2ea9e3d0dc2227e8a1a9c..300a18a53dbc3f31c72a0295744ef0fd59ab2ed8 100644 (file)
@@ -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
index 7fb0cc1c1ac9246d6f129b559454fd73e84cf937..81a5ab2d5bb677fb64225c6dc9923f68aa701853 100644 (file)
@@ -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("");
index f7694dc788f3d0e323a0c9ffad79353fd65e0def..4f0f214f780d4849202d79f8c09a2460f616935f 100644 (file)
@@ -1,3 +1,24 @@
+2001-07-03  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * 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  <larsbj@birdstep.com>
+
+       * 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  <Jean-Marc.Lasgouttes@inria.fr>
 
        * tabular.C (GetCellInset): update cur_cell also in the row/col
index e01669d1244ba1842fa4a787d2520b4bfd1d0958..2d456a6b22213dea75a971187f2f47fde7100c9a 100644 (file)
 #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"
index 04e318f76ae133733adcd9fec01687320628da06..03550c4a1f5c92b48a8b5383f2902d294153a574 100644 (file)
 #include <unistd.h>
 
 #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 *);
+LyXTextClass::size_type current_layout = 0;
 
 
-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);
        }
 }
 
index 646ac775092a2a7b8701dd5d92447209acfdcabe..71cb18000744cae06c87ad0489b2726f161e0a23 100644 (file)
@@ -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 <config.h>
-#include FORMS_H_LOCATION
+#include <boost/utility.hpp>
+#include <sigc++/signal_system.h>
 
 #include "LString.h"
 #include "frontends/Timeout.h"
-#include <boost/utility.hpp>
 #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;
        ///
-       Menubar * menubar;
+       virtual void prohibitInput() const = 0;
        ///
-       Intl * intl;
+       virtual void allowInput() const = 0;
+protected:
        ///
-       Dialogs * dialogs_;
-
+       Menubar * menubar;
+       /// 
+       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 *);
+       Intl * intl;
+       ///
+       Timeout autosave_timeout;
        /// A callback
        void AutoSave();
+       ///
+       void invalidateLayoutChoice();
 private:
+       /// 
+       LyXFunc * lyxfunc;
        ///
-       Timeout autosave_timeout;
-       /// makes the main form.
-       void create_form_form_main(int width, int height);
-       /// A pointer to the form.      
-       FL_FORM * form_;
+       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) */
index cefe8d1433a33867eaa51a75702024fabfb6f088..c32b9a98963a9e112c3c76ea229e291bc4fd6b8f 100644 (file)
@@ -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 (file)
index 0000000..059e174
--- /dev/null
@@ -0,0 +1,257 @@
+
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2001 The LyX Team.
+ *
+ * ====================================================== */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+//#include <sys/time.h>
+//#include <unistd.h>
+
+#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 (file)
index 0000000..be7ce56
--- /dev/null
@@ -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 <config.h>
+#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
index 8f09fd92b215c60b9a526256c98e6ebbdedecc49..e0c1fb8124bb7e94d935773e1b8a695725487bec 100644 (file)
@@ -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;
 }
index cda8ce2ba10ec71be8a8a4c611dda232a24f206a..57f704e1cdc41c01323727a5dc0ae547dd09c9c6 100644 (file)
@@ -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);
index fde594460bbbdefbdbe62057716c95b34b8fca54..f44336ed1191146456333add476542b02e082982 100644 (file)
@@ -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);
index b073c98f1482c0f697ee4c5730460466ceaf0602..51b0823be3fa72df9a1f73f7c8a17f1d2467fa6e 100644 (file)
@@ -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 *);
index c9248c51502f42eacf43f19294522f488acb0254..e07402318ffb754d038b3452d73c5b2bbe788f25 100644 (file)
@@ -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 |
index 835ca7d7920e60fa459fe020391e9beab32b0058..b0e7172e4370d50f6bd69ae4c6f005c8bf2c787f 100644 (file)
@@ -1,3 +1,7 @@
+2001-07-03  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * GUIRunTime.h: add createMainView
+
 2001-06-27  John Levon  <moz@compsoc.man.ac.uk>
 
        * Dialogs.h: add showSpellcheckerPreferences
index 51223b9845621df77aa5369e2a17a85bdd3c8dbf..4f489728eece1b0ce63e195bc67aa0bca59fdf7d 100644 (file)
@@ -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
index 859b463922200955b7a9e5fe4c98d2408fa6135a..d8a556c6c1a452b7fa73f60955bee34941e6017f 100644 (file)
@@ -1,3 +1,10 @@
+2001-07-03  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * Toolbar_pimpl.h: make owner be a XFormsView, small changes
+       because of this.
+
+       * GUIRunTime.C (createMainView): implement
+
 2001-06-22  John Levon  <moz@compsoc.man.ac.uk>
 
        * FormCharacter.C:
index d64f0e9a6109949ed9a2f4a598588ac1a10c4b89..c876ffc0a379773a767909bac41e2b173527a160 100644 (file)
@@ -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;
 }
index 05d96eefaffc6ef0d512888f84312ffe5c4adfde..75c418227ed797447c905da72047390f2768dd7f 100644 (file)
@@ -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();
 }
 
 
index aefa36811df16ed5d9dbc1b7104db542ede28ba3..13dd471b58444c1a1d3d75e16dee4ed4ef99de3e 100644 (file)
@@ -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);
+}
index f15d7c79846af2fe9ee0bbd4904714423ca1644e..5fbcc6b7163de24475b69517a4fdb17a6809c06b 100644 (file)
@@ -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<XFormsView *>(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<XFormsView *>(view)->getForm()->x + ob->x,
+                                  static_cast<XFormsView *>(view)->getForm()->y + ob->y + ob->h + 10);   
                int choice = fl_dopup(menu);
                
                if (button == 1) {
index b80357e11e65564e6e62a09aedca88109ec4cb1d..4657f45b8ef98eab3c4162368fbc3be741176695 100644 (file)
@@ -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<XFormsView *>(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<LyXView *>(ob->u_vdata);
+       XFormsView * owner = static_cast<XFormsView *>(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;
index 128af77cb68548a83ae3be55e176c7752571cf88..21bf7ce629b82999406c083bbca482b9ea83cad9 100644 (file)
@@ -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;
index e4e845396f758e152e556a44b30f6bec68a359f4..ff1d9119197dcde2581f74a1a91a1dd3f8d9f049 100644 (file)
@@ -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;
index 8390461d15083d16a52c1173f6e8fe6ce712a7d7..01f8b860759dae73763be56c70b9143d7711526c 100644 (file)
@@ -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();
 }
 
 
index ed579f89c0ed4b8a68e8fc3e61adf43880c533be..27526090cb329cd6d8311cfc2578666e9651513f 100644 (file)
@@ -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();
 }
 
 
index 517031f1f50d150d64cc7460827e1453f0ae8da2..f6bd2605d5ad8b20e7370e494773e37e7d7463ce 100644 (file)
@@ -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
index fe755a51e18be6f40a21ee0202c654cc327f834f..9a5f2b241016db7f253534c311e9962728624d4f 100644 (file)
@@ -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;
        }
        
index f6b67c4cdb1aed6ebb4115a7d267eec60998799c..70015b2c2ef0088445d802f8a3702cb1c06ebab5 100644 (file)
@@ -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<XFormsView *>(owner_)->getForm(),
+                           the_buffer);
 }
 
 
index 7c7741710b8343e71547ae8dba2b12b42018a0c8..83c8261a997da4c8336951bd4daa6f57d477a176 100644 (file)
@@ -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;