]> git.lyx.org Git - features.git/commitdiff
GUI-indep toolbar and menus mostly work !
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 24 Jul 2000 13:53:19 +0000 (13:53 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 24 Jul 2000 13:53:19 +0000 (13:53 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@913 a592a061-630c-0410-9148-cb99ea01b6c8

86 files changed:
ChangeLog
lib/Makefile.am
lib/bind/emacs.bind
lib/bind/xemacs.bind
lib/lyxrc.example
lib/ui/default.ui [new file with mode: 0644]
po/POTFILES.in
src/BufferView_pimpl.C
src/LyXAction.C
src/LyXView.C
src/LyXView.h
src/Makefile.am
src/MenuBackend.C [new file with mode: 0644]
src/MenuBackend.h [new file with mode: 0644]
src/Spacing.C
src/Spacing.h
src/Timeout.C
src/Timeout.h
src/ToolbarDefaults.C
src/ToolbarDefaults.h
src/bmtable.c
src/bmtable.h
src/buffer.C
src/bufferview_funcs.C
src/bufferview_funcs.h
src/commandtags.h
src/counters.C
src/counters.h
src/debug.C
src/debug.h
src/encoding.C
src/encoding.h
src/font.C
src/font.h
src/frontends/Liason.C
src/frontends/Liason.h
src/frontends/Makefile.am
src/frontends/Menubar.C [new file with mode: 0644]
src/frontends/Menubar.h [new file with mode: 0644]
src/frontends/Toolbar.C [new file with mode: 0644]
src/frontends/Toolbar.h [new file with mode: 0644]
src/frontends/xforms/Makefile.am
src/frontends/xforms/Menubar_pimpl.C [new file with mode: 0644]
src/frontends/xforms/Menubar_pimpl.h [new file with mode: 0644]
src/frontends/xforms/Toolbar_pimpl.C [new file with mode: 0644]
src/frontends/xforms/Toolbar_pimpl.h [new file with mode: 0644]
src/insets/insetbib.C
src/insets/insettext.C
src/language.C
src/language.h
src/lyx_gui_misc.C
src/lyx_gui_misc.h
src/lyx_main.C
src/lyx_main.h
src/lyx_sty.C
src/lyx_sty.h
src/lyxcursor.C
src/lyxcursor.h
src/lyxfunc.C
src/lyxlex.C
src/lyxlookup.C
src/lyxlookup.h
src/lyxrc.C
src/lyxrc.h
src/lyxrow.C
src/lyxrow.h
src/spellchecker.C
src/spellchecker.h
src/support/DebugStream.C
src/support/DebugStream.h
src/support/FileInfo.C
src/support/FileInfo.h
src/support/LSubstring.C
src/support/Makefile.am
src/support/StrPool.C [new file with mode: 0644]
src/support/StrPool.h [new file with mode: 0644]
src/support/lstrings.C
src/support/lstrings.h
src/tex-accent.C
src/tex-accent.h
src/tex-strings.C
src/tex-strings.h
src/toolbar.C [deleted file]
src/toolbar.h [deleted file]
src/tracer.C
src/tracer.h

index 5c9c756b856f3dee63eed37152e07b7974983046..1888ab2f08015825a1788df0302d3fe2a1eb05df 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,79 @@
+2000-07-24  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+
+       * src/buffer.C (writeFileAscii): Define actcell as an int instead
+       of int*.
+
+2000-07-23  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+
+       * Lot of files: add pragma interface/implementation.
+       
+       * src/lyx_main.C (ReadUFile): new method. Read the UI file.
+
+       * lib/ui/default.ui: new file (ans new directory). Contains the
+       default menu and toolbar.
+
+       * src/lyxrc.[Ch]: new variable ui_file. Move toolbardefaults to
+       global space. Toolbars are now read (as menus) in ui files. 
+
+       * src/debug.C: change Debug::TOOLBAR to Debug::GUI.
+
+       * src/lyxfunc.C (getStatus): do not exit immediately if a command
+       is disabled because the document is read-only. We want to have the
+       toggle state of the function anyway.
+       (getStatus): add code for LFUN_VC* functions (mimicking what is
+       done in old-style menus)
+       
+       * src/lyxfunc.C (Dispatch): news functions LFUN_SWITCHBUFFER,
+       LFUN_HELP_CREDITS, LFUN_HELP_VERSION, LFUN_HELP_OPEN.
+
+       * src/LyXView.[Ch]: add code for the NEW_MENUBAR define.
+       * src/BufferView_pimpl.C: ditto. 
+       * src/lyxfunc.C: ditto.         
+
+       * src/LyXView.h: add a define NEW_MENUBAR (commented out by
+       default). This replaces old-style menus by new ones.
+       
+       * src/MenuBackend.[Ch]: new classes MenuBackend, Menu and
+       MenuItem. Contain the data structure of a menu.
+
+       * src/insets/insettext.C: use LyXView::setLayout instead of
+       accessing directly the toolbar combox.
+       * src/lyxfunc.C (Dispatch): ditto.
+
+       * src/LyXView.C (setLayout): new method, which just calls
+       Toolbar::setLayout(). 
+       (updateLayoutChoice): move part of this method in Toolbar.
+
+       * src/toolbar.[Ch]: removed.
+       
+       * src/frontend/xforms/Toolbar_pimpl.[Ch]: new files. The xforms
+       implementation the toolbar. 
+
+       * src/frontend/Toolbar.[Ch]: new files. The abstract interface of
+       the toolbar. It might make sense to merge it with ToolbarDefaults
+       later. 
+       (setLayout): new function. 
+       (updateLayoutList): ditto.
+       (openLayoutList): ditto.
+       
+       * src/frontend/xforms/Toolbar_pimpl.[Ch]: new files. Contain the
+       xforms implementation of the toolbar.
+       (get_toolbar_func): comment out, since I do not
+       know what it is good for. 
+       
+       * src/ToolbarDefaults.h: Add the ItemType enum.
+
+       * src/support/StrPool.[Ch]: new class. Acts as a reference holder
+       for a list of allocated C strings. Used in Menubar xforms
+       implementation to avoid memory leaks.
+
+       * src/support/lstrings.[Ch] (uppercase): new version taking and
+       returning a char.
+       (lowercase): ditto.
+
+       * lib/bind/xemacs.bind: remove bogus binding for lyx-quit.
+       * lib/bind/emacs.bind: ditto.
+
 2000-07-21  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
        * src/toolbar.h: include commandtags.h instead of lyxfunc.h,
@@ -23,7 +99,7 @@
        * src/paragraph.C (SimpleTeXOnePar): NEW_INSETS: move some #ifdef
        to correct place.
 
-       * src/buffer.C (parseSingleLyXformat2Token: NEW_INSETS: fix the
+       * src/buffer.C (parseSingleLyXformat2Token): NEW_INSETS: fix the
        planemet in reading of old style floats, fix the \end_deeper
        problem when reading old style floats. 
 
index e638725d1932211334c6eead55c9403fdbcc2aff..ec2a6764059bfc851e269bfca428b86a87c24c12 100644 (file)
@@ -17,17 +17,19 @@ LAYOUT = layouts/*.layout layouts/*.inc
 LYXSCRIPTS = scripts/*
 TEMPL = templates/*.lyx
 TEXSUPPORT = tex/*.cls
+UI = ui/*.ui
 
 LIBINSTFILES = $(BIND) $(CLIPART) $(DOCINST) $(EXAMPLES) $(IMAGES) $(KBD) \
-       $(LAYOUT) $(TEMPL) $(TEXSUPPORT) $(LYXSCRIPTS)
+       $(LAYOUT) $(TEMPL) $(TEXSUPPORT) $(UI) $(LYXSCRIPTS)
 
 LIBDISTFILES = $(BIND) $(CLIPART) $(DOCDIST) $(EXAMPLES) $(IMAGES) $(KBD) \
-       $(LAYOUT) $(TEMPL) $(TEXSUPPORT) $(LYXSCRIPTS)
+       $(LAYOUT) $(TEMPL) $(UI) $(TEXSUPPORT) $(LYXSCRIPTS)
 
 pkgdata_DATA = lyxrc.example CREDITS chkconfig.ltx lyxrc.defaults \
                textclass.lst packages.lst external_templates
 
-LYXLIBDIRS = bind clipart doc examples images kbd layouts scripts templates tex
+LYXLIBDIRS = bind clipart doc examples images kbd layouts scripts \
+             templates tex ui
 
 EXTRA_DIST = CREDITS chkconfig.ltx configure.cmd lyxrc.example \
        external_templates $(LYXLIBDIRS) build-listerrors
index 0cb72bed21dddeb22c85bdaf969e1b1c704a5091..8f920be4d7eb9686f5ab1309ee163cf2d9d0db40 100644 (file)
@@ -70,8 +70,7 @@
 \bind "S-C-quotedbl"           "quote-insert"
 
 \bind "C-x a"                  "buffer-auto-save"
-#\bind "C-x b"                  "buffer-previous"
-\bind "C-x c"                  "lyx-quit"
+#\bind "C-x b"                 "buffer-previous"
 \bind "C-x d"                  "buffer-new"
 \bind "C-x g"                  "buffer-view-ps"
 \bind "C-x k"                  "buffer-close"
index 0b8ed59939733f183bd590790587cd2451c21455..45c3bcf205716bb10c5ab047c8a4a2a7e2a43436 100644 (file)
@@ -73,8 +73,7 @@
 
 \bind "C-x a"                  "buffer-auto-save"
 # not currently supported
-#\bind "C-x b"                  "buffer-previous"
-\bind "C-x c"                  "lyx-quit"
+#\bind "C-x b"                 "buffer-previous"
 \bind "C-x d"                  "buffer-new"
 \bind "C-x g"                  "buffer-view-ps"
 \bind "C-x k"                  "buffer-close"
index 1a27d199ecc463b55ba92a2a6cc0ef7e4b9f0474..a9e9f51161e1a1c6cee1ce03c3bb16b69b7419c4 100644 (file)
 #\set_color mathlines yellow
 
 #
-# TOOLBAR SECTION ########################################################
-#
-
-# Setup your favorite Toolbar here:
-# Only three commands are allowed inside the begin_toolbar and end_toolbar
-# directives: 
-#   \add <action> [<parameter>] adds an icon to the toolbar performing
-#          "<action> <parameter>"
-#      Examples:
-#      \add font-size small
-#      \add set-emph
-#
-#   \layouts adds the layouts combo-box to the toolbar
-#
-#   \separator adds some spacing to the toolbar
-#
-# These actions have icons (please give us more :-):
-#   buffer-open, buffer-close, buffer-print, buffer-write, font-emph,
-#   font-noun, font-free, footnote-insert, depth-next, copy, cut, paste,
-#   tex-mode, math-mode, marginpar-insert, figure-insert, table-insert,
-#   melt, lyx-quit, buffer-export ascii|latex, font-bold, font-sans, 
-#   buffer-typeset, buffer-view, buffer-view-ps, symbol_insert [parameter]
-#
-#  All other lyx commands will get a "unknown" icon.
-#
-# This is the default toolbar:
-#\begin_toolbar
-#\layouts
-#\add buffer-open
-#\add buffer-write
-#\add buffer-print
-#\separator
-#\add cut
-#\add copy
-#\add paste
-#\separator
-#\add font-emph
-#\add font-noun
-#\add font-free
-#\separator
-#\add footnote-insert
-#\add marginpar-insert
-#\add depth-next
-#\separator
-#\add tex-mode
-#\add math-mode
-#\separator
-#\add figure-insert
-#\add table-insert
-#\end_toolbar
+# UI SECTION ########################################################
+#
+
+# Choose your UI (user interface) definition here. The .ui files are in the 
+# directory "lib/ui" and contains the definition of the menu and the toolbar.
+#\ui_file "default"
 
 #
 # PRINTER SECTION ########################################################
diff --git a/lib/ui/default.ui b/lib/ui/default.ui
new file mode 100644 (file)
index 0000000..79aa4b1
--- /dev/null
@@ -0,0 +1,285 @@
+# This is the default LyX user interface definition file. The syntax
+# should be straightforward enough. The menubar "main_nobuffer" (if it
+# exists) is used when there is no buffer open; otherwise, the menubar
+# "main" is used. 
+
+Menuset
+
+    Menubar "main"
+       Submenu "File|F" "file"
+       Submenu "Edit|E" "edit"
+       Submenu "Layout|L" "layout"
+       Submenu "Insert|I" "insert"
+       Submenu "Math|M" "math"
+       Submenu "Options|O" "options"
+       Submenu "Documents|D" "documents"
+       Submenu "Help|H" "help"
+    End
+
+    Menubar "main_nobuffer"
+       Submenu "File|F" "file_nobuffer"
+       Submenu "Options|O" "options"
+       Submenu "Help|H" "help"
+    End
+
+    Menu "file" 
+       Item "New...|N" "buffer-new"
+       Item "New from template|t" "buffer-new-template"
+       Item "Open...|O" "buffer-open"
+       Separator
+       Item "Close|C" "buffer-close"
+       Item "Save|S" "buffer-write"
+       Item "Save As|A" "buffer-write-as"
+       Item "Revert to saved|R" "buffer-reload"
+       Separator
+       Item "View dvi|d" "buffer-view"
+       Item "View Postscript|w" "buffer-view-ps"
+       Item "Update dvi|v" "buffer-typeset"
+       Item "Update Postscript|u" "buffer-typeset-ps"
+       Item "Build program|B" "build-program"
+       Separator
+       Item "Print...|P" "buffer-print"
+       Item "Fax...|F" "buffer-fax"
+       Submenu "Import|I" "import"
+       Submenu "Export|E" "export"
+       Separator
+       Item "Exit|x" "lyx-quit"
+       Separator
+       Lastfiles
+    End
+
+    Menu "file_nobuffer" 
+       Item "New...|N" "buffer-new"
+       Item "New from template|t" "buffer-new-template"
+       Item "Open...|O" "buffer-open"
+       Separator
+       Submenu "Import|I" "import"
+       Separator
+       Item "Exit|x" "lyx-quit"
+       Separator
+       Lastfiles
+    End
+
+    Menu "import"
+       Item "LaTeX|L" "buffer-import latex"
+       Item "Ascii text as lines|A" "buffer-import ascii"
+       Item "Ascii text as paragraphs|p" "buffer-import ascii"
+       Item "Noweb|N" "buffer-import noweb"
+    End
+
+    Menu "export"
+       Item "LaTeX|L" "buffer-export latex"
+       Item "DVI|D" "buffer-export dvi"
+       Item "Postscript|P" "buffer-export postscript"
+       Item "Ascii|A" "buffer-export ascii"
+       Item "Custom...|C" "buffer-export custom"
+    End
+
+    Menu "edit"
+       Item "Undo|U" "undo"
+       Item "Redo|R" "redo"
+       Separator
+       Item "Cut|C" "cut"
+       Item "Copy|o" "copy"
+       Item "Paste|P" "paste"
+       Separator
+       Item "Find & Replace...|F" "find-replace"
+       Item "Go to Error|E" "error-next"
+       Item "Go to Note|N" "note-next"
+       Submenu "Floats & Insets|I" "floats"
+       Submenu "Table" "table"
+       Item "Spellchecker...|S" "spellchecker"
+       Item "Check TeX|h" "buffer-chktex"
+       Item "Table of Contents|b" "toc-view"
+       Separator
+       Submenu "Version control" "vc"
+       Separator
+       Item "View LaTeX log file|w" "latex-view-log"
+       Separator
+       Item "Paste primary selection as Lines|L" "primary-selection-paste"
+       Item "Paste primary selection as Paragraphs|g" "primary-selection-paste paragraph"
+    End
+
+    Menu "floats"
+    End
+
+    Menu "table"
+    End
+
+    Menu "vc"
+        Item "Register|R" "vc-register"
+        Item "Check In Changes|I" "vc-check-in"
+        Item "Check Out for Edit|O" "vc-check-out"
+        Item "Revert to last version|l" "vc-revert"
+        Item "Undo last check in|U" "vc-undo-last"
+        Item "Show History|H" "vc-history"
+    End
+
+    Menu "layout"
+       Item "Character...|C" "layout-character"
+       Item "Paragraph...|P" "layout-paragraph"
+       Item "Paper...|a" "layout-paper"
+       Item "Document...|D" "layout-document"
+       Item "Table...|T" "layout-table"
+       Item "Quotes...|Q" "layout-quotes"
+       Separator
+       Item "Emphasize Style|E" "font-emph"
+       Item "Noun Style|N" "font-noun"
+       Item "Bold Style|B" "font-bold"
+       Item "TeX Style|x" "tex-mode"
+       Item "Change environment depth|v" "depth-increment"
+       Item "LaTeX preamble|a" "layout-preamble"
+       Item "Start of Appendix|x" "appendix"
+       Separator
+       Item "Save layout as default|S" "layout-save-default"
+    End
+
+    Menu "insert"
+       Item "Figure...|F" "figure-insert"
+       Item "Table...|T" "table-insert"
+       Separator
+       Item "Include File...|I" "buffer-child-insert"
+       Submenu "Import ascii file|a" "insert_ascii"
+       Item "Insert LyX file|X" "file-insert"
+       Separator
+       Item "Footnote|F" "footnote-insert"
+       Item "Marginnote|M" "marginpar-insert"
+       Submenu "Floats|a" "floats"
+       Separator
+       Submenu "Lists & TOC|T" "insert_toc"
+       Separator
+       Submenu "Special character|S" "insert_special"
+       Separator
+       Item "Note...|N" "note-insert"
+       Item "Label...|L" "label-insert"
+       Item "Cross reference...|r" "reference-insert"
+       Item "Citation reference...|i" "citation-insert"
+       Item "Index entry...|d" "index-insert"
+       Item "Index entry of last word|w" "index-insert-last"
+       Item "URL...|U" "url-insert"
+    End
+
+    Menu "insert_ascii"
+       Item "As lines|l" "file-insert-ascii lines"
+       Item "As paragraphs|p" "file-insert-ascii paragraphs"
+    End
+
+    Menu "insert_floats"
+       Item "Figure float|F" "buffer-float-insert figure"
+       Item "Table float|T" "buffer-float-insert table"
+       Item "Wide figure float|W" "buffer-float-insert wide-fig"
+       Item "Wide table float|d" "buffer-float-insert wide-tab"
+       Separator
+       Item "Algorithm float|A" "buffer-float-insert algorithm"
+    End
+
+    Menu "insert_toc"
+       Item "Table of Contents|C" "toc-view"
+       Item "List of Figures|F" "lof-insert"
+       Item "List of Tables|T" "lot-insert"
+       Item "List of Algorithms|A" "loa-insert"
+       Item "Index List|I" "index-print"
+       Item "BibTeX reference|B" "bibtex-insert"
+    End
+
+    Menu "insert_special"
+       Item "HFill|H" "hfill-insert"
+       Item "Hyphenation point|p" "hyphenation-point-insert"
+       Item "Protected blank|b" "protected-space-insert"
+       Item "Linebreak|L" "break-line"
+       Item "Ellipsis|i" "dots-insert"
+       Item "End of sentence|E" "end-of-sentence-period-insert"
+       Item "Ordinary Quote|Q" "quote-insert"
+    End
+
+    Menu "math"
+       Item "Fraction|F" "math-insert frac"
+       Item "Square root|S" "math-insert sqrt"
+       Item "Exponent|E" "math-insert ^"
+       Item "Index|x" "math-insert -"
+       Item "Sum|u" "math-insert sum"
+       Item "Integral|I" "math-insert int"
+       Separator
+       Item "Math mode|M" "math-mode"
+       Item "Display|D" "math-display"
+       Separator
+       Item "Math Panel...|P" "math-panel"
+    End
+
+    Menu "options"
+       Item "Screen Fonts...|F" "screen-options"
+       Item "Spellchecker Options...|S" "spellchecker-options"
+       Item "Keyboard...|K" "keyboard-options"
+       Separator
+       Item "Reconfigure|R" "reconfigure"
+       Item "Preferences|P" "options-preferences"
+    End
+    
+    Menu "documents"
+       Documents
+    End
+
+    Menu "help"
+       Item "Introduction|I" "help-open Intro"
+       Item "Tutorial|T" "help-open Tutorial"
+       Item "User's Guide|U" "help-open UserGuide"
+       Item "Extended Features|x" "help-open Extended"
+       Item "Customization|C" "help-open Customization"
+       Item "Reference Manual|R" "help-open Reference"
+       Item "FAQ|F" "help-open FAQ"
+       Item "Table of contents|a" "help-open TOC"
+       Item "Known Bugs|K" "help-open BUGS"
+       Item "LaTeX Configuration|L" "help-open LaTeXConfig"
+        Separator
+       Item "Copyright and Warranty...|o" "help-copyright"
+       Item "Credits...|e" "help-credits"
+       Item "Version...|V" "help-version"
+    End
+
+End
+
+# Setup your favorite Toolbar here:
+# Only three commands are allowed inside the begin_toolbar and end_toolbar
+# directives: 
+#   Icon "<action> [<parameter>]" adds an icon to the toolbar performing
+#          "<action> <parameter>"
+#      Examples:
+#      Icon "font-size small"
+#      Icon set-emph
+#
+#   Layouts adds the layouts combo-box to the toolbar
+#
+#   Separator adds some spacing to the toolbar
+#
+# The icons are found in the lib/image direcory under the name
+# action.xpm or action_parameter.xpm.
+#
+#  All other lyx commands will get a "unknown" icon.
+#
+# This is the default toolbar:
+
+Toolbar
+    Layouts
+    Icon "buffer-open"
+    Icon "buffer-write"
+    Icon "buffer-print"
+    Separator
+    Icon "cut"
+    Icon "copy"
+    Icon "paste"
+    Separator
+    Icon "font-emph"
+    Icon "font-noun"
+    Icon "font-free"
+    Separator
+    Icon "footnote-insert"
+    Icon "marginpar-insert"
+    Icon "depth-next"
+    Separator
+    Icon "tex-mode"
+    Icon "math-mode"
+    Separator
+    Icon "figure-insert"
+    Icon "table-insert"
+End
+
index 5b1c15fc341adbda1bcc14efc59a9c379d605c9b..c5665d0fc6ef5e281030da854952a3d5c3f13da5 100644 (file)
@@ -35,6 +35,7 @@ src/frontends/xforms/FormPrint.C
 src/frontends/xforms/form_print.C
 src/frontends/xforms/FormTabular.C
 src/frontends/xforms/form_tabular.C
+src/frontends/xforms/Menubar_pimpl.C
 src/gettext.h
 src/insets/figinset.C
 src/insets/form_graphics.C
index de3c38e4f90832400a83975ede320a612b3a67c2..3b407150f653730d3469c75dba49ebb015c650d4 100644 (file)
 #include "TextCache.h"
 #include "bufferlist.h"
 #include "insets/insetbib.h"
-#include "menus.h"
 #include "lyx_gui_misc.h"
 #include "lyxrc.h"
 #include "intl.h"
 #include "support/LAssert.h"
 #include "frontends/Dialogs.h"
+#ifndef NEW_MENUBAR
+# include "menus.h"
+#endif
 
 #ifdef SIGC_CXX_NAMESPACES
 using SigC::slot;
@@ -44,6 +46,7 @@ bool selection_possible = false;
 extern BufferList bufferlist;
 extern char ascii_type;
 
+extern "C" void TimerCB(FL_OBJECT *, long); 
 extern void sigchldhandler(pid_t pid, int * status);
 extern int bibitemMaxWidth(BufferView *, LyXFont const &);
 
@@ -130,7 +133,6 @@ void BufferView::Pimpl::buffer(Buffer * b)
        if (buffer_) {
                lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
                buffer_->addUser(bv_);
-               owner_->getMenus()->showMenus();
                // If we don't have a text object for this, we make one
                if (bv_->text == 0) {
                        resizeCurrentBuffer();
@@ -139,12 +141,21 @@ void BufferView::Pimpl::buffer(Buffer * b)
                        updateScrollbar();
                }
                bv_->text->first = screen_->TopCursorVisible(bv_->text);
+#ifdef NEW_MENUBAR
+               owner_->updateMenubar();
+#else
+               owner_->getMenus()->showMenus();
+#endif
                redraw();
                owner_->getDialogs()->updateBufferDependent();
                bv_->insetWakeup();
        } else {
                lyxerr[Debug::INFO] << "  No Buffer!" << endl;
+#ifdef NEW_MENUBAR
+               owner_->updateMenubar();
+#else
                owner_->getMenus()->hideMenus();
+#endif
                updateScrollbar();
                workarea_->redraw();
 
index 5edf46727c07c46ae7db2f66ebb443ca70de5717..ef71ce489ec4e029641d10064d5a34fd82b30d5a 100644 (file)
@@ -139,6 +139,8 @@ void LyXAction::init()
                { LFUN_MENUPRINT, "buffer-print", N_("Print"), ReadOnly },
                { LFUN_MENURELOAD, "buffer-reload",
                  N_("Revert to saved"), ReadOnly },
+               { LFUN_SWITCHBUFFER, "buffer-switch", 
+                 N_("Switch to an open document"), ReadOnly },
                { LFUN_READ_ONLY_TOGGLE, "buffer-toggle-read-only",
                  N_("Toggle read-only"), ReadOnly },
                { LFUN_RUNLATEX, "buffer-typeset", N_("Update DVI"),
@@ -226,6 +228,13 @@ void LyXAction::init()
                  N_("Insert horizontal fill"), Noop },
                { LFUN_HELP_COPYRIGHT, "help-copyright",
                  N_("Display copyright information"), NoBuffer },
+               { LFUN_HELP_CREDITS, "help-credits",
+                 N_("Show the list of people who helped writing LyX"), 
+                 NoBuffer},
+               { LFUN_HELP_OPEN, "help-open", N_("Open a Help file"), 
+                 NoBuffer|Argument},
+               { LFUN_HELP_VERSION, "help-version",
+                 N_("Show the actual LyX version"), NoBuffer},
                { LFUN_HTMLURL, "html-insert", "", Noop },
                { LFUN_HYPHENATION, "hyphenation-point-insert",
                  N_("Insert hyphenation point"), Noop },
index b22acf6a7ec53cd5cb961ea0889d15ab1ad21ed1..e7f5b6017ca4998d2af5f3e4fee45309a0d35931 100644 (file)
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* This file is part of
  * ====================================================== 
  * 
@@ -21,7 +20,6 @@
 #include "LyXView.h"
 #include "lyx_main.h"
 #include "lyxlookup.h"
-#include "toolbar.h"
 #include "minibuffer.h"
 #include "lyxfunc.h"
 #include "debug.h"
 #include "layout.h"
 #include "lyxtext.h"
 #include "buffer.h"
-#include "menus.h"
 #include "frontends/Dialogs.h"
+#include "frontends/Toolbar.h"
+#ifdef NEW_MENUBAR
+# include "frontends/Menubar.h"
+# include "MenuBackend.h"
+#else
+# include "menus.h"
+#endif
+#include "ToolbarDefaults.h"
 #include "lyx_gui_misc.h"      // [update,Close]AllBufferRelatedDialogs
 #include "bufferview_funcs.h" // CurrentState()
 
@@ -77,7 +82,11 @@ LyXView::LyXView(int width, int height)
 
 LyXView::~LyXView()
 {
+#ifdef NEW_MENUBAR
+       delete menubar;
+#else
        delete menus;
+#endif
        delete toolbar;
        delete bufferview;
        delete minibuffer;
@@ -119,6 +128,10 @@ Toolbar * LyXView::getToolbar() const
        return toolbar;
 }
 
+void LyXView::setLayout(int layout)
+{
+       toolbar->setLayout(layout);
+}
 
 LyXFunc * LyXView::getLyXFunc() const
 {
@@ -132,10 +145,28 @@ MiniBuffer * LyXView::getMiniBuffer() const
 }
 
 
+#ifdef NEW_MENUBAR
+Menubar * LyXView::getMenubar() const
+{
+       return menubar;
+}
+
+
+void LyXView::updateMenubar() 
+{
+       if ((!view() || !view()->buffer())
+           && menubackend.hasMenu("main_nobuffer"))
+               menubar->set("main_nobuffer");
+       else
+               menubar->set("main");
+}
+
+#else
 Menus * LyXView::getMenus() const
 {
        return menus;
 }
+#endif
 
 
 Intl * LyXView::getIntl() const
@@ -212,14 +243,17 @@ void LyXView::create_form_form_main(int width, int height)
        //
        // THE MENUBAR
        //
-
+#ifdef NEW_MENUBAR
+       menubar = new Menubar(this, menubackend);
+#else  
        menus = new Menus(this, air);
+#endif
 
        //
        // TOOLBAR
        //
 
-       toolbar = new Toolbar(this, air, 30 + air + bw);
+       toolbar = new Toolbar(this, air, 30 + air + bw, toolbardefaults);
 
        // Setup the toolbar
        toolbar->set(true);
@@ -284,6 +318,9 @@ void LyXView::init()
        invalidateLayoutChoice();
        updateLayoutChoice();
        UpdateDocumentClassChoice();
+#ifdef NEW_MENUBAR
+       updateMenubar();
+#endif
        
        // Start autosave timer
        if (lyxrc.autosave) {
@@ -307,41 +344,28 @@ void LyXView::invalidateLayoutChoice()
 
 void LyXView::updateLayoutChoice()
 {
-       // Update the layout display
-       if (!toolbar->combox) return;
-
        // This has a side-effect that the layouts are not showed when no
        // document is loaded.
-       if (bufferview == 0 || bufferview->buffer() == 0) {
-               toolbar->combox->clear();
-               toolbar->combox->Redraw();
+       if (!view() || !view()->buffer()) {
+               toolbar->clearLayoutList();
                return; 
        }
 
-       // If textclass is different, we need to update the list
-       if (toolbar->combox->empty() ||
-           (last_textclass != int(buffer()->params.textclass))) {
-               toolbar->combox->clear();
-               LyXTextClass const & tc =
-                       textclasslist.TextClass(buffer()->params.textclass);
-               for (LyXTextClass::const_iterator cit = tc.begin();
-                    cit != tc.end(); ++cit) {
-                       if ((*cit).obsoleted_by().empty())
-                               toolbar->combox->addline((*cit).name().c_str());
-                       else
-                               toolbar->combox->addline(("@N" + (*cit).name()).c_str());
-               }
+       // Update the layout display
+       if (last_textclass != int(buffer()->params.textclass)) {
+               toolbar->updateLayoutList(true);
                last_textclass = int(buffer()->params.textclass);
                current_layout = 0;
-       }
-       // we need to do this.
-       toolbar->combox->Redraw();
+       } else
+               toolbar->updateLayoutList(false);
+
+       
 
        LyXTextClass::size_type layout =
                bufferview->text->cursor.par()->GetLayout();
 
        if (layout != current_layout){
-               toolbar->combox->select(layout + 1);
+               toolbar->setLayout(layout);
                current_layout = layout;
        }
 }
index eb7a5c5a9b85401282e84a96b69713615866c11f..e09d69b7fc952910ca81fb2d79ad5a3b293952de 100644 (file)
 
 #include "Timeout.h"
 
+// uncomment this line to try out the new menus
+//#define NEW_MENUBAR
+
 class LyXFunc;
 class Toolbar;
 class MiniBuffer;
 class Intl;
 class Buffer;
+#ifdef NEW_MENUBAR
+class Menubar;
+#else
 class Menus;
+#endif
+
 class BufferView;
 class Dialogs;
 
@@ -71,15 +79,25 @@ public:
        /// return a pointer to the toolbar
        Toolbar * getToolbar() const;
 
+       /// sets the layout in the toolbar layout combox
+       void setLayout(int layout);
+
        /// return a pointer to the lyxfunc
        LyXFunc * getLyXFunc() const;
 
        /// return a pointer to the minibuffer
        MiniBuffer * getMiniBuffer() const;
 
+#ifdef NEW_MENUBAR
        ///
-       Menus * getMenus() const;
+       Menubar * getMenubar() const;
 
+       ///
+       void updateMenubar();
+#else
+       ///
+       Menus * getMenus() const;
+#endif
        ///
        Intl * getIntl() const;
 
@@ -105,8 +123,13 @@ private:
        Toolbar * toolbar;
        /// 
        MiniBuffer * minibuffer;
+#ifdef NEW_MENUBAR
+       ///
+       Menubar * menubar;
+#else
        ///
        Menus * menus;
+#endif
        ///
        Intl * intl;
        ///
index f44020a309e69d8f6af6ff9d508129e8a3a93d79..df75096cf28055e05476d33be0ffaec34f99ca4c 100644 (file)
@@ -3,9 +3,13 @@ SUBDIRS = mathed insets support frontends
 DISTCLEANFILES= *.orig *.rej *~ *.bak core libintl.h config.h
 MAINTAINERCLEANFILES = $(srcdir)/Makefile.in $(srcdir)/config.h.in
 bin_PROGRAMS = lyx
+## libfrontends is given twice on the link line because it needs stuff
+## from FRONTEND_GUILIB and inversely. If you do not like it, feel
+## free to provide another solution... Maybe signals would solve that
+## magically, but I do not understand them much (JMarc)
 lyx_DEPENDENCIES = mathed/libmathed.la insets/libinsets.la \
-       support/libsupport.la @FRONTEND_GUILIB@ frontends/libfrontends.la \
-       @INCLUDED_SIGC@
+       frontends/libfrontends.la @FRONTEND_GUILIB@ \
+       frontends/libfrontends.la support/libsupport.la @INCLUDED_SIGC@
 lyx_LDADD = $(lyx_DEPENDENCIES) @INTLLIBS@ $(LYX_LIBS) $(SIGC_LIBS) \
        @FRONTEND_LDFLAGS@ @FRONTEND_LIBS@
 EXTRA_DIST = config.h.in stamp-h.in cheaders
@@ -56,6 +60,8 @@ lyx_SOURCES = \
        LyXView.C \
        LyXView.h \
        Makefile.in \
+       MenuBackend.C \
+       MenuBackend.h \
        Painter.C \
        Painter.h \
        PainterBase.C \
@@ -208,8 +214,6 @@ lyx_SOURCES = \
        texrow.h \
        text.C \
        text2.C \
-       toolbar.C \
-       toolbar.h \
        tracer.C \
        tracer.h \
        trans.C \
diff --git a/src/MenuBackend.C b/src/MenuBackend.C
new file mode 100644 (file)
index 0000000..c95866a
--- /dev/null
@@ -0,0 +1,273 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ *
+ * ====================================================== */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+#include "MenuBackend.h"
+#include "lyxlex.h"
+#include "LyXAction.h"
+#include "debug.h"
+
+extern LyXAction lyxaction;
+
+using std::endl;
+
+// This is the global menu definition
+MenuBackend menubackend;
+
+MenuItem::MenuItem(MenuItem const & m) 
+  : kind_(m.kind_), label_(m.label_), action_(m.action_), submenu_(m.submenu_) 
+{}
+
+
+MenuItem::MenuItem(Kind kind, string const & label, string const & command) 
+  : kind_(kind), label_(label) 
+{
+       switch(kind) {
+       case Separator:
+       case Documents:
+       case Lastfiles:
+               break;
+       case Command:
+               action_ = lyxaction.LookupFunc(command);
+
+               if (action_ == LFUN_UNKNOWN_ACTION) {
+                       lyxerr << "MenuItem(): LyX command `"
+                              << command << "' does not exist." << endl; 
+               }
+               break;
+       case Submenu:
+               submenu_ = command;
+               break;
+       }
+}
+
+void Menu::add(MenuItem const & i)
+{
+       items_.push_back(i);
+}
+
+
+void Menu::read(LyXLex & lex)
+{
+       enum Menutags {
+               md_item = 1,
+               md_documents,
+               md_endmenu,
+               md_lastfiles,
+               md_submenu,
+               md_separator,
+               md_last
+       };
+
+       struct keyword_item menutags[md_last-1] = {
+               { "documents", md_documents },
+               { "end", md_endmenu },
+               { "item", md_item },
+               { "lastfiles", md_lastfiles },
+               { "separator", md_separator },
+               { "submenu", md_submenu }
+       };
+
+       lex.pushTable(menutags, md_last - 1);
+       if (lyxerr.debugging(Debug::PARSER))
+               lex.printTable(lyxerr);
+
+       string mlabel, mname;
+       bool quit = false;
+
+       while (lex.IsOK() && !quit) {
+               switch(lex.lex()) {
+               case md_item: {
+                       lex.next();
+                       string name = lex.GetString();
+                       lex.next();
+                       string command = lex.GetString();
+                       add(MenuItem(MenuItem::Command, name, command));
+                       break;
+               }
+               case md_separator:
+                       add(MenuItem(MenuItem::Separator));
+                       break;
+               case md_lastfiles:
+                       add(MenuItem(MenuItem::Lastfiles));
+                       break;
+               case md_documents:
+                       add(MenuItem(MenuItem::Documents));
+                       break;
+               case md_submenu: {
+                       lex.next();
+                       mlabel = lex.GetString();
+                       lex.next();
+                       mname = lex.GetString();
+                       add(MenuItem(MenuItem::Submenu, mlabel, mname));
+                       break;
+               }
+               case md_endmenu:
+                       quit = true;
+                       break;
+               default:
+                       lex.printError("menubar::read: "
+                                      "Unknown menu tag: `$$Token'");
+                       break;
+               }
+       }
+       lex.popTable();
+}
+
+
+void MenuBackend::read(LyXLex & lex)
+{
+       enum Menutags {
+               md_menu = 1,
+               md_menubar,
+               md_endmenuset,
+               md_last
+       };
+
+       struct keyword_item menutags[md_last-1] = {
+               { "end", md_endmenuset },
+               { "menu", md_menu },
+               { "menubar", md_menubar }
+       };
+
+       //consistency check
+       if (compare_no_case(lex.GetString(), "menuset"))
+               lyxerr << "Menubackend::read: ERROR wrong token:`"
+                      << lex.GetString() << '\'' << endl;
+
+       lex.pushTable(menutags, md_last - 1);
+       if (lyxerr.debugging(Debug::PARSER))
+               lex.printTable(lyxerr);
+
+       string mlabel, mname;
+       bool quit = false;
+
+       while (lex.IsOK() && !quit) {
+               switch(lex.lex()) {
+               case md_menu: {
+                       lex.next();
+                       string name = lex.GetString();
+                       Menu menu(name, false);
+                       menu.read(lex);
+                       add(menu);
+                       break;
+               }
+               case md_menubar: {
+                       lex.next();
+                       string name = lex.GetString();
+                       Menu menubar(name, true);
+                       menubar.read(lex);
+                       add(menubar);
+                       break;
+               }
+               case md_endmenuset:
+                       quit = true;
+                       break;
+               default:
+                       lex.printError("menubackend::read: "
+                                      "Unknown menu tag: `$$Token'");
+                       break;
+               }
+       }
+       lex.popTable();
+}
+
+void MenuBackend::defaults()
+{
+       if (menulist_.size() > 0)
+               menulist_.clear();
+
+       lyxerr[Debug::GUI] << "MenuBackend::defaults: using default values" 
+                          << endl;
+
+       Menu file("file");
+       file.add(MenuItem(MenuItem::Command,
+                         "New...|N", "buffer-new"));
+       file.add(MenuItem(MenuItem::Command,
+                         "Open...|O", "buffer-open"));
+       file.add(MenuItem(MenuItem::Submenu,
+                         "Import|I", "import"));
+       file.add(MenuItem(MenuItem::Command,
+                         "Quit|Q", "lyx-quit"));
+       file.add(MenuItem(MenuItem::Separator));
+       file.add(MenuItem(MenuItem::Lastfiles));
+       add(file);
+
+       Menu import("import");
+       import.add(MenuItem(MenuItem::Command,
+                           "LaTeX...|L", "buffer-import latex"));
+       import.add(MenuItem(MenuItem::Command,
+                           "LinuxDoc...|L", "buffer-import linuxdoc"));
+       add(import);
+       Menu edit("edit");
+       edit.add(MenuItem(MenuItem::Command,
+                         "Cut", "cut"));
+       edit.add(MenuItem(MenuItem::Command,
+                         "Copy", "copy"));
+       edit.add(MenuItem(MenuItem::Command,
+                         "Paste", "paste"));
+       edit.add(MenuItem(MenuItem::Command,
+                         "Emphasize", "font-emph"));
+       add(edit);
+
+       Menu documents("documents");
+       documents.add(MenuItem(MenuItem::Documents));
+       add(documents);
+
+       Menu main("main", true);
+       main.add(MenuItem(MenuItem::Submenu, "File|F", "file"));
+       main.add(MenuItem(MenuItem::Submenu, "Edit|E", "edit"));
+       main.add(MenuItem(MenuItem::Submenu, 
+                         "Documents|D", "documents"));
+       add(main);
+
+       Menu main_nobuffer("main_nobuffer", true);
+       main_nobuffer.add(MenuItem(MenuItem::Submenu, 
+                                  "File|F", "file"));
+       add(main_nobuffer);
+
+       if (lyxerr.debugging(Debug::GUI)) {
+               for(const_iterator cit = begin();
+                   cit != end() ; ++cit)
+                       lyxerr << "Menu name: " << cit->name() 
+                              << ", Menubar: " << cit->menubar() 
+                              << endl;
+       }
+}
+
+void MenuBackend::add(Menu const &menu)
+{
+       menulist_.push_back(menu);
+}
+
+bool MenuBackend::hasMenu(string const &name) const
+{
+       for (const_iterator cit = begin(); cit != end(); ++cit) {
+               if ((*cit).name() == name)
+                       return true;
+       }
+       return false;
+}
+
+Menu const & MenuBackend::getMenu(string const &name) const
+{
+       for (const_iterator cit = begin(); cit != end(); ++cit) {
+               if ((*cit).name() == name)
+                       return (*cit);
+       }
+       Assert(false); // we actually require the name to exist.
+       return menulist_.front();
+}
diff --git a/src/MenuBackend.h b/src/MenuBackend.h
new file mode 100644 (file)
index 0000000..4a1d16b
--- /dev/null
@@ -0,0 +1,138 @@
+/* This file is part of              -*- C++ -*-
+* ======================================================
+* 
+*           LyX, The Document Processor
+*
+*           Copyright (C) 1995 Matthias Ettrich
+*           Copyright (C) 1995-1999 The LyX Team.
+*
+*           This file is Copyright 1999
+*           Jean-Marc Lasgouttes
+*
+*======================================================*/
+
+#ifndef MENUBACKEND_H
+#define MENUBACKEND_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "LString.h"
+#include "support/LAssert.h"
+#include <vector>
+
+class LyXLex;
+class MenuItem;
+
+class MenuItem {
+public:
+       // The type of elements that can be in a menu
+       enum Kind { 
+               Command, 
+               Submenu, 
+               Separator, 
+               Lastfiles, // This is the list of last opened file,
+                          // typically for the File menu. 
+               Documents  // This is the list of opened Documents,
+                          // typically for the Documents menu.
+       };
+       // Create a copy of a given MenuItem
+       MenuItem(MenuItem const &);
+       // Create a Command type MenuItem
+       MenuItem(Kind kind_, string const & label_ = string(), 
+                string const & command_ = string());
+       //
+       ~MenuItem() {}
+
+       // The label of a given menuitem
+       string const & label() const { return label_; }
+       // The kind of entry
+       Kind kind() const { return kind_; } 
+       // the action (if relevant)
+       int action() const { return action_; }
+       // the description of the  submenu (if relevant)
+       string const & submenu() const { return submenu_; }
+       
+private:
+       Kind kind_;
+       string label_;
+       int action_;
+       string submenu_;
+       MenuItem() {}
+};
+
+
+class Menu {
+public:
+       //
+       typedef std::vector<MenuItem> ItemList;
+       //
+       typedef ItemList::const_iterator const_iterator;
+       //
+       explicit Menu(string const & name, bool mb = false) 
+               : menubar_(mb), name_(name) {}
+       //
+       void add(MenuItem const &);
+       //
+       void read(LyXLex &);
+       // 
+       bool menubar() const { return menubar_; }
+       // 
+       string const & name() const { return name_; }
+       //
+       bool empty() const { return items_.empty(); }
+        ///
+        const_iterator begin() const {
+                return items_.begin();
+        }
+        ///
+        const_iterator end() const {
+                return items_.end();
+        }
+    
+private:
+       ///
+       ItemList items_;
+       ///
+       bool menubar_;
+       ///
+       string name_;
+       ///
+};
+
+
+class MenuBackend {
+public:
+       ///
+       typedef std::vector<Menu> MenuList;
+       ///
+       typedef MenuList::const_iterator const_iterator;
+       ///
+       void read(LyXLex &);
+       /// Set default values for menu structure.
+       void defaults();
+       ///
+       void add(Menu const &);
+       ///
+       bool hasMenu (string const &) const;
+       ///
+       Menu const & getMenu (string const &) const;
+       //
+       bool empty() const { return menulist_.empty(); }
+        ///
+        const_iterator begin() const {
+                return menulist_.begin();
+        }
+        ///
+        const_iterator end() const {
+                return menulist_.end();
+        }
+private:
+       ///
+       MenuList menulist_;
+};
+
+extern MenuBackend menubackend;
+
+#endif /* MENUBACKEND_H */
index 14261b665ddd646bb5270eddcabc116fc3e21ee0..d34c163e770b611f569da15bcca109de435203fb 100644 (file)
@@ -1,5 +1,18 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
 
 #ifdef HAVE_SSTREAM
 #include <sstream>
index 8d466864a24dfa1a42d6d42e6ba8fbfa94abb652..120b14b97a875a06850acd39ee566ab6178e190a 100644 (file)
 #ifndef SPACING_H
 #define SPACING_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include <iosfwd>
 
 #include "LString.h"
index 4005c83884b8f6b0cc5ed4957818a4001b5ce167..543d8d2924262cdf07595c2f393e2b2ab6726a96 100644 (file)
@@ -1,3 +1,17 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include <config.h>
 
 #include FORMS_H_LOCATION
index 7afefc3f33d5d581b46fdfeab3e80a991e4dadfd..d4c538a327d982ff0bcae7b02c27d0ea63587ffe 100644 (file)
@@ -1,7 +1,21 @@
 // -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
 #ifndef TIMEOUT_H
 #define TIMEOUT_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include <sigc++/signal_system.h>
 
 #ifdef SIGC_CXX_NAMESPACES
index 60947b5872b6517780c4a289403436af1489a36d..75bdaef0292629bc72b792cc3bb36372d27c0325 100644 (file)
@@ -1,15 +1,30 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ *
+ * ====================================================== */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include <config.h>
 
 #include "ToolbarDefaults.h"
 #include "LyXAction.h"
-#include "toolbar.h"
+#include "lyxlex.h"
 #include "debug.h"
 #include "lyxlex.h"
 
 using std::endl;
 
 extern LyXAction lyxaction;
-
+ToolbarDefaults toolbardefaults;
 
 ToolbarDefaults::ToolbarDefaults()
 {
@@ -22,34 +37,33 @@ void ToolbarDefaults::add(int action)
        defaults.push_back(action);
 }
 
-
 void ToolbarDefaults::init() 
 {
-       add(Toolbar::TOOL_LAYOUTS);
+       add(LAYOUTS);
        add(LFUN_MENUOPEN);
        //add(LFUN_CLOSEBUFFER);
        add(LFUN_MENUWRITE);
        add(LFUN_MENUPRINT);
-       add(Toolbar::TOOL_SEPARATOR);
+       add(SEPARATOR);
 
        add(LFUN_CUT);
        add(LFUN_COPY);
        add(LFUN_PASTE);
-       add(Toolbar::TOOL_SEPARATOR);
+       add(SEPARATOR);
        
        add(LFUN_EMPH);
        add(LFUN_NOUN);
        add(LFUN_FREE);
-       add(Toolbar::TOOL_SEPARATOR);
+       add(SEPARATOR);
        
        add(LFUN_FOOTMELT);
        add(LFUN_MARGINMELT);
        add(LFUN_DEPTH);
-       add(Toolbar::TOOL_SEPARATOR);
+       add(SEPARATOR);
 
        add(LFUN_TEX);
         add(LFUN_MATH_MODE);
-       add(Toolbar::TOOL_SEPARATOR);
+       add(SEPARATOR);
 
        add(LFUN_FIGURE);
        add(LFUN_TABLE);
@@ -68,18 +82,18 @@ enum _tooltags {
 
 
 struct keyword_item toolTags[TO_LAST - 1] = {
-       { "\\add", TO_ADD },
-       { "\\end_toolbar", TO_ENDTOOLBAR },
-        { "\\layouts", TO_LAYOUTS },
-        { "\\newline", TO_NEWLINE },
-        { "\\separator", TO_SEPARATOR }
+       { "end", TO_ENDTOOLBAR },
+       { "icon", TO_ADD },
+        { "layouts", TO_LAYOUTS },
+        { "newline", TO_NEWLINE },
+        { "separator", TO_SEPARATOR }
 };
 
 
 void ToolbarDefaults::read(LyXLex & lex) 
 {
-               //consistency check
-       if (lex.GetString() != "\\begin_toolbar")
+       //consistency check
+       if (compare_no_case(lex.GetString(), "toolbar"))
                lyxerr << "Toolbar::read: ERROR wrong token:`"
                       << lex.GetString() << '\'' << endl;
 
@@ -95,14 +109,14 @@ void ToolbarDefaults::read(LyXLex & lex)
        
        while (lex.IsOK() && !quit) {
                
-               lyxerr[Debug::TOOLBAR] << "Toolbar::read: current lex text: `"
+               lyxerr[Debug::GUI] << "Toolbar::read: current lex text: `"
                                       << lex.GetString() << '\'' << endl;
 
                switch(lex.lex()) {
                case TO_ADD:
-                       if (lex.EatLine()) {
+                       if (lex.next()) {
                                func = lex.GetString();
-                               lyxerr[Debug::TOOLBAR]
+                               lyxerr[Debug::GUI]
                                        << "Toolbar::read TO_ADD func: `"
                                        << func << "'" << endl;
                                add(func);
@@ -110,15 +124,15 @@ void ToolbarDefaults::read(LyXLex & lex)
                        break;
                   
                case TO_SEPARATOR:
-                       add(Toolbar::TOOL_SEPARATOR);
+                       add(SEPARATOR);
                        break;
                   
                case TO_LAYOUTS:
-                       add(Toolbar::TOOL_LAYOUTS);
+                       add(LAYOUTS);
                        break;
                   
                case TO_NEWLINE:
-                       add(Toolbar::TOOL_NEWLINE);
+                       add(NEWLINE);
                        break;
                        
                case TO_ENDTOOLBAR:
@@ -133,6 +147,7 @@ void ToolbarDefaults::read(LyXLex & lex)
                }
        }
        lex.popTable();
+       lex.next();
 }
 
 
index 91fe0cc4c804806f6455650acbbc82c6d1d1a844..00f3c9182a10e9874862d9fa88301a7f9591ac3a 100644 (file)
@@ -1,8 +1,23 @@
 // -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ *
+ * ====================================================== */
+
 
 #ifndef TOOLBARDEFAULTS_H
 #define TOOLBARDEFAULTS_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include <vector>
 
 #include "LString.h"
@@ -12,6 +27,16 @@ class LyXLex;
 ///
 class ToolbarDefaults {
 public:
+        /// The special toolbar actions
+       enum  ItemType {
+               /// adds space between buttons in the toolbar
+               SEPARATOR=-3,
+               /// a special combox insead of a button
+               LAYOUTS=-2,
+               /// begin a new line of button (not working)
+               NEWLINE=-1
+       };
+
        ///
        typedef std::vector<int> Defaults;
        ///
@@ -49,7 +74,9 @@ private:
        Defaults defaults;
 };
 
-#endif
+//The global instance
+extern ToolbarDefaults toolbardefaults;
 
 
+#endif
 
index d4b4cc62c7cbcd75392f0ad66258d506eb2efa18..e8fca4b31e079ca2fde3fe3f5ce10815b432f14f 100644 (file)
 
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include <stdlib.h>
 #include "bmtable.h"
 #include XPM_H_LOCATION
index e0bb4af27d81888c5870519b54bead229ad8e409..a55c423f0926d59c3e4e34bea6d9c7046485052a 100644 (file)
 #ifndef BMTABLE_H
 #define BMTABLE_H 
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include FORMS_H_LOCATION
 
 #if defined(__cplusplus)
index a11b2d06f005362bd164810e60c2761307a14396..4b82b721041fd7b5eb3670e459712b94a340a9ad 100644 (file)
@@ -1292,7 +1292,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
        int j;
        int ltype = 0;
        int ltype_depth = 0;
-       int actcell = 0;
+       int actcell = 0;
        int actpos = 0;
 #ifndef NEW_TABULAR
        int h;
index baf340bd027618975e26f2aec2996d8911aee97f..48d23a6a9ab24abbe3e3d30cd790108527732b48 100644 (file)
@@ -1,5 +1,19 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include "bufferview_funcs.h"
 #include "LyXView.h"
 #include "BufferView.h"
index c479b430514023d5f72c0a2f95c70bfcb3e0eb40..e2f689249b0c4cb55a9cfd33fda6c9d20b5b2c93 100644 (file)
@@ -1,7 +1,21 @@
 // -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
 #ifndef BUFFERVIEW_FUNCS_H
 #define BUFFERVIEW_FUNCS_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include "LString.h"
 
 class BufferView;
index 595ebd6ad1fefa0e32391709973b652c00f836d8..32016ba11e9a2119aef81a28fa60f0bed1c89315 100644 (file)
@@ -52,6 +52,7 @@ enum kb_action {
        LFUN_TEX,
        LFUN_FOOTMELT,
        LFUN_MARGINMELT,
+       LFUN_SWITCHBUFFER,
        LFUN_EMPH,
        LFUN_BOLD,
        LFUN_ROMAN,
@@ -242,6 +243,9 @@ enum kb_action {
        LFUN_SEQUENCE,                  // Andre' 991111
        LFUN_SAVEPREFERENCES,           // Lgb 991127
        LFUN_HELP_COPYRIGHT,            // ARRae 20000129
+       LFUN_HELP_CREDITS,              // ARRae 981017
+        LFUN_HELP_OPEN,                        // Jug 990627
+        LFUN_HELP_VERSION,             // Jug 990627
        LFUN_DATE_INSERT,               // jdblair 20000131
        LFUN_LANGUAGE,                  // Dekel 20000203
        LFUN_INSET_TEXT,                // Jug 20000214
index 2a72bf99f4f50f1409a6c18a0c0438db6748f140..a9a89aef2878f182938c8763183cdd2bebdd9750 100644 (file)
@@ -1,3 +1,18 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ *
+ * ====================================================== */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include <config.h>
 
 #include "counters.h"
index 19014cc6fceb0b580eff76fe3fac767f9ee3b464..fcfeef73dc30be5a64b92f942eda41789d71d2d9 100644 (file)
@@ -1,8 +1,23 @@
 // -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ *
+ * ====================================================== */
+
 
 #ifndef COUNTERS_H
 #define COUTNERS_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include <map>
 #include <sigc++/signal_system.h>
 #include "LString.h"
index ed91682a129da0ddbb8ab1a74039612db4557d1a..46b6a39e36c59215e7660f4deedd2e3912081110 100644 (file)
@@ -31,7 +31,7 @@ static error_item errorTags[] = {
        { Debug::INFO,          "info",         "General information"},
        { Debug::INIT,          "init",         "Program initialisation"},
        { Debug::KEY,           "key",          "Keyboard events handling"},
-       { Debug::TOOLBAR,       "toolbar",      "Toolbar handling"},
+       { Debug::GUI,           "gui",          "GUI handling"},
        { Debug::PARSER,        "parser",       "Lyxlex grammer parser"},
        { Debug::LYXRC,         "lyxrc",        "Configuration files reading"},
        { Debug::KBMAP,         "kbmap",        "Custom keyboard definition"},
index 18a1e3216e869ab3848f6d95abdc599bcb2131da..4df1f6e0a813e4a81ab100271a0984d9132dc6ec 100644 (file)
@@ -1,8 +1,21 @@
 // -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
 
 #ifndef LYXDEBUG_H
 #define LYXDEBUG_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include <iosfwd>
 
 #include "LString.h"
@@ -24,7 +37,7 @@ struct Debug {
                ///
                KEY        = (1 << 2),   // 4
                ///
-               TOOLBAR    = (1 << 3),   // 8
+               GUI        = (1 << 3),   // 8
                ///
                PARSER     = (1 << 4),   // 16
                ///
@@ -55,7 +68,7 @@ struct Debug {
                INSETS     = (1 << 17)
        };
        ///
-       static const type ANY = type(INFO | INIT | KEY | TOOLBAR |
+       static const type ANY = type(INFO | INIT | KEY | GUI |
                                     PARSER | LYXRC | KBMAP | LATEX |
                                     MATHED | FONT | TCLASS | LYXVC |
                                     LYXSERVER | ROFF | ACTION | LYXLEX |
index 129a29a03678ee249e4d04fd8dc07da9ddbd9101..b41bde6c2cbf766b00776871d101563b728a4769 100644 (file)
 
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include "encoding.h"
 
 Uchar tab_iso8859_1[256] = {
index d8059d68ec89f307f4adf61fe4359d8207951608..d4c16709338776b8fcd4d60ac805e9f8af2f4b04 100644 (file)
 #ifndef ENCODING_H
 #define ENCODING_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include "LString.h"
 #include "lyxrc.h"
 
index 1aae9a6e43569a54828bf0afebd3b84673ad29c3..462241db9675eb7b1cb70853e239be2986f36f19 100644 (file)
@@ -1,5 +1,19 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include <cctype>
 
 #include "font.h"
index 28c3a017d9ccd0f733ccaa3a517274586b0788e9..89f04fa99d85e30cd93447afe037bc2e50de05e5 100644 (file)
@@ -1,7 +1,21 @@
 // -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
 #ifndef FONT_H
 #define FONT_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include <X11/Xlib.h>
 
 #include "LString.h"
index 7da6ed7da46c01cae2c1d0f6ae12096c87da1544..aff9ad98f5ba8699346738be75474dfe8718add6 100644 (file)
@@ -1,6 +1,19 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
 #include <config.h>
 
-//#include "config.h"
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include "Liason.h"
 #include "BufferView.h"
 #include "buffer.h"
index 8999f064a8a8e900b6c51c32acbe9758a09ecfea..2fab06fc6820d8d8b7f9c305df2490faf8927a36 100644 (file)
 #ifndef LIASON_H
 #define LIASON_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 class PrinterParams;
 class Buffer;
 
index f685f6dccee69abf22ea727ffa8c24e409880762..615c405777a78ef6b6a493f93c36e81f704f0f3e 100644 (file)
@@ -3,12 +3,16 @@ DISTCLEANFILES= *.orig *.rej *~ *.bak core
 MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
 SUBDIRS = @FRONTEND@
 ETAGS_ARGS = --lang=c++
-INCLUDES = -I${srcdir}/../
+INCLUDES = -I${srcdir}/.. -I${srcdir}/@FRONTEND@
 LIBS =
 noinst_LTLIBRARIES = libfrontends.la
 libfrontends_la_SOURCES=\
        Dialogs.h \
        DialogBase.h \
        Liason.C \
-       Liason.h
+       Liason.h \
+       Menubar.C \
+       Menubar.h \
+       Toolbar.C \
+       Toolbar.h
 
diff --git a/src/frontends/Menubar.C b/src/frontends/Menubar.C
new file mode 100644 (file)
index 0000000..82d5e9d
--- /dev/null
@@ -0,0 +1,46 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ *           This file is Copyright 2000 Jean-Marc Lasgouttes
+ *
+ * ====================================================== */
+
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "Menubar.h"
+#include "Menubar_pimpl.h"
+
+using std::endl;
+
+Menubar::Menubar(LyXView * o, MenuBackend const &md)
+{
+       pimpl_ = new Pimpl(o, md);
+}
+
+
+Menubar::~Menubar()
+{
+       delete pimpl_;
+}
+
+
+void Menubar::set(string const & name)
+{
+       pimpl_->set(name);
+}
+
+
+void Menubar::openByName(string const & name)
+{
+       pimpl_->openByName(name);
+}
diff --git a/src/frontends/Menubar.h b/src/frontends/Menubar.h
new file mode 100644 (file)
index 0000000..1d01b0e
--- /dev/null
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ *           This file is Copyright 1996-2000
+ *           Lars Gullik Bjønnes
+ *
+ * ====================================================== */
+
+#ifndef MENUBAR_H
+#define MENUBAR_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "LString.h"
+
+class LyXView;
+class MenuBackend;
+
+/** The LyX GUI independent menubar class
+  The GUI interface is implemented in the corresponding Menubar_pimpl class. 
+  */
+class Menubar {
+public:
+       ///
+       Menubar(LyXView * o, MenuBackend const &);
+       ///
+       ~Menubar();
+       ///
+       void set(string const &);
+       /// Opens a top-level submenu given its name
+       void openByName(string const &);
+
+
+       //I disable this temporarily until I find a nice way to make it work
+       //with compaq cxx.
+//private:
+       struct Pimpl;
+       friend struct Pimpl;
+       Pimpl * pimpl_;
+};
+#endif
diff --git a/src/frontends/Toolbar.C b/src/frontends/Toolbar.C
new file mode 100644 (file)
index 0000000..dc2b46b
--- /dev/null
@@ -0,0 +1,114 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ *           This file is Copyright 1996-1998
+ *           Lars Gullik Bjønnes
+ *
+ * ====================================================== */
+
+//  Added pseudo-action handling, asierra 180296
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation "Toolbar.h"
+#endif
+
+#include "Toolbar.h"
+#include "Toolbar_pimpl.h"
+#include "debug.h"
+#include "LyXAction.h"
+
+using std::endl;
+
+extern LyXAction lyxaction;
+
+
+Toolbar::Toolbar(LyXView * o, int x, int y, ToolbarDefaults const &tbd)
+{
+       pimpl_ = new Pimpl(o, x, y);
+
+       pimpl_->reset();
+
+       // extracts the toolbar actions from tbd
+       for (ToolbarDefaults::const_iterator cit = tbd.begin();
+            cit != tbd.end(); ++cit) {
+               pimpl_->add((*cit));
+               lyxerr[Debug::GUI] << "tool action: "
+                                      << (*cit) << endl;
+       }
+}
+
+Toolbar::~Toolbar()
+{
+       delete pimpl_;
+}
+
+
+void Toolbar::set(bool doingmain)
+{
+       pimpl_->set(doingmain);
+}
+
+
+void Toolbar::activate()
+{
+       pimpl_->activate();
+}
+
+
+void Toolbar::deactivate()
+{
+       pimpl_->deactivate();
+}
+
+void Toolbar::update()
+{
+       pimpl_->update();
+}
+
+
+void Toolbar::setLayout(int layout) {
+       pimpl_->setLayout(layout);
+}
+
+
+void Toolbar::updateLayoutList(bool force) {
+       pimpl_->updateLayoutList(force);
+}
+
+               
+void Toolbar::openLayoutList() {
+       pimpl_->openLayoutList();
+}
+
+
+void Toolbar::clearLayoutList()
+{
+       pimpl_->clearLayoutList();
+}
+
+
+void Toolbar::push(int nth)
+{
+       pimpl_->push(nth);}
+
+
+void Toolbar::add(string const & func, bool doclean)
+{
+       int tf = lyxaction.LookupFunc(func);
+
+       if (tf == -1) {
+               lyxerr << "Toolbar::add: no LyX command called`"
+                      << func << "'exists!" << endl; 
+       } else {
+               pimpl_->add(tf, doclean);
+       }
+}
+
+
diff --git a/src/frontends/Toolbar.h b/src/frontends/Toolbar.h
new file mode 100644 (file)
index 0000000..121f3ce
--- /dev/null
@@ -0,0 +1,70 @@
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ *           This file is Copyright 1996-2000
+ *           Lars Gullik Bjønnes
+ *
+ * ====================================================== */
+
+#ifndef TOOLBAR_H
+#define TOOLBAR_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "LString.h"
+
+class LyXView;
+class ToolbarDefaults;
+
+/** The LyX GUI independent toolbar class
+  The GUI interface is implemented in the corresponding Toolbar_pimpl class. 
+  */
+class Toolbar {
+public:
+       ///
+       Toolbar(LyXView * o, int x, int y, ToolbarDefaults const &);
+
+       ///
+       ~Toolbar();
+       
+       /// (re)sets the toolbar
+       void set(bool doingmain = false);
+
+       /** this is to be the entry point to the toolbar
+         frame, where you can change the toolbar realtime. */
+       void edit();
+       /// add a new button to the toolbar.
+       void add(int , bool doclean = true);
+       /// name of func instead of kb_action
+       void add(string const & , bool doclean = true);
+       /// invokes the n'th icon in the toolbar
+       void push(int);
+       /// activates the toolbar
+        void activate();
+       /// deactivates the toolbar
+        void deactivate();
+       /// update the state of the icons
+       void update();
+
+       /// update the layout combox
+       void setLayout(int layout);
+       /// Populate the layout combox; re-do everything if force is true.
+       void updateLayoutList(bool force);
+       /// Drop down the layout list
+       void openLayoutList();
+       /// Erase the layout list
+       void clearLayoutList();
+
+private:
+       struct Pimpl;
+       friend struct Toolbar::Pimpl;
+       Pimpl * pimpl_;
+};
+#endif
index b8cf600e185e1a028c4b345667727779ddbbd4d3..8d3cd47456cc165127d04611c2e27bba455fd82d 100644 (file)
@@ -31,6 +31,10 @@ libxforms_la_SOURCES = \
        FormTabular.h \
        form_tabular.C \
        form_tabular.h \
+       Toolbar_pimpl.C \
+       Toolbar_pimpl.h \
+       Menubar_pimpl.C \
+       Menubar_pimpl.h \
        input_validators.h \
        input_validators.c \
        xform_macros.h
diff --git a/src/frontends/xforms/Menubar_pimpl.C b/src/frontends/xforms/Menubar_pimpl.C
new file mode 100644 (file)
index 0000000..d3bd54c
--- /dev/null
@@ -0,0 +1,463 @@
+/* This file is part of
+* ======================================================
+* 
+*           LyX, The Document Processor
+*       
+*           Copyright (C) 1999 The LyX Team.
+*
+*======================================================*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+
+#include <algorithm>
+#include <cctype>
+#include "support/lstrings.h"
+#include "support/filetools.h"
+#include "support/StrPool.h"
+#include "support/LAssert.h"
+#include "debug.h"
+#include "LyXAction.h"
+#include "lyxfunc.h"
+#include "kbmap.h"
+#include "bufferlist.h"
+#include "lastfiles.h"
+#include "LyXView.h"
+#include "lyx_gui_misc.h"
+#include "MenuBackend.h"
+#include "Menubar_pimpl.h"
+
+using std::endl;
+
+extern kb_keymap * toplevel_keymap;
+extern LyXAction lyxaction;
+extern BufferList bufferlist;
+extern LastFiles * lastfiles; 
+
+// Some constants
+const int MENU_LABEL_SIZE = FL_NORMAL_SIZE;
+const int mheight = 30;
+const int mbheight= 22;
+// where to place the menubar?
+const int yloc = (mheight - mbheight)/2; //air + bw;
+const int mbadd = 20; // menu button add (to width)
+// Some space between buttons on the menubar 
+const int air = 2;
+char const * menu_tabstop = "aa";
+char const * default_tabstop = "aaaaaaaa";
+
+
+//Defined later.
+extern "C"
+void C_Menubar_Pimpl_MenuCallback(FL_OBJECT * ob, long button);
+
+
+Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mb) 
+       : frame_(0), owner_(view), menubackend_(&mb)
+{
+       // Should we do something here?
+}
+
+Menubar::Pimpl::~Pimpl() 
+{
+       // Should we do something here?
+}
+
+void Menubar::Pimpl::set(string const & menu_name) 
+{
+       lyxerr[Debug::GUI] << "Entering Menubar::Pimpl::set " 
+                          << "for menu `" << menu_name << "'" << endl;
+
+       if (menu_name == current_menu) {
+               lyxerr[Debug::GUI] << "Nothing to do." << endl;
+               return;
+       }
+
+       // If the backend has not been initialized yet, we use a
+       // default instead.  
+       if (menubackend_->empty()) {
+               lyxerr << "Menubar::Pimpl::set: menubackend is empty! "
+                       "using default values." << endl;
+               MenuBackend * mb = new MenuBackend();
+               mb->defaults();
+               menubackend_ = mb;
+       }
+
+       if (!menubackend_->hasMenu(menu_name)){ 
+               lyxerr << "ERROR:set: Unknown menu `" << menu_name
+                      << "'" << endl;
+               return;
+       }
+
+       Menu menu = menubackend_->getMenu(menu_name);
+
+       if (!menu.menubar()) {
+               lyxerr << "Only a menubar-type object can go in a "
+                       "toplevel menu" << endl;
+               return;
+       }
+
+       current_menu = menu_name;
+       FL_FORM * form = owner_->getForm(); 
+       int moffset = 0;
+       bool form_was_open, form_was_frozen;
+
+       if (fl_current_form == form)
+               form_was_open = true;
+       else if (fl_current_form == 0) {
+               form_was_open = false;
+               fl_addto_form(form);
+       } 
+       else {
+               lyxerr << "Something is wrong: unknown form " 
+                      << fl_current_form << " is already open" 
+                      << "(main form is " << form << ")" << endl;
+               return;
+       }
+       if (form->frozen)
+               form_was_frozen = true;
+       else {
+               form_was_frozen = false;
+               fl_freeze_form(form);
+       }
+
+       // Delete old buttons if there are some.
+       for(ButtonList::const_iterator cit = buttonlist_.begin();
+           cit != buttonlist_.end(); ++cit) {
+               if ((*cit)->obj_) {
+                       fl_delete_object((*cit)->obj_);
+                       fl_free_object((*cit)->obj_);
+               }
+               delete (*cit);
+       }
+       buttonlist_.clear();
+
+       // Create menu frame if there is non yet.
+       if (!frame_) {
+               frame_ = fl_add_frame(FL_UP_FRAME, 0, 0, form->w, mheight, "");
+               fl_set_object_resize(frame_, FL_RESIZE_ALL);
+               fl_set_object_gravity(frame_, NorthWestGravity, 
+                                     NorthEastGravity);
+       } 
+
+       for (Menu::const_iterator i = menu.begin(); 
+            i != menu.end(); ++i) {
+               FL_OBJECT * obj;
+               if (i->kind() != MenuItem::Submenu) {
+                       lyxerr << "ERROR: Menubar::Pimpl::Pimpl:"
+                               " only submenus can appear in a menubar";
+                       break;
+               }
+               char const * label = idex(i->label().c_str());
+               char const * shortcut = scex(i->label().c_str());
+               int width = fl_get_string_width(FL_NORMAL_STYLE,
+                                               MENU_LABEL_SIZE,
+                                               label,
+                                               strlen(label));
+               obj = fl_add_button(FL_TOUCH_BUTTON,
+                                   air + moffset, yloc,
+                                   width + mbadd,
+                                   mbheight, 
+                                   label);
+               fl_set_object_boxtype(obj, FL_FLAT_BOX);
+               fl_set_object_color(obj, FL_MCOL, FL_MCOL);
+               fl_set_object_lsize(obj, MENU_LABEL_SIZE);
+               fl_set_object_lstyle(obj, FL_NORMAL_STYLE);
+               fl_set_object_resize(obj, FL_RESIZE_ALL);
+               fl_set_object_gravity(obj, NorthWestGravity, 
+                                     NorthWestGravity);
+               moffset += obj->w + air;
+               fl_set_object_shortcut(obj, shortcut, 1);
+               fl_set_object_callback(obj, C_Menubar_Pimpl_MenuCallback, 1);
+               ItemInfo * iteminfo = new ItemInfo(this, 
+                                                  new MenuItem(*i), obj);
+               buttonlist_.push_back(iteminfo);
+               obj->u_vdata = iteminfo;
+//             lyxerr << "MenuCallback: ItemInfo address=" << iteminfo
+//                    << " Val=(pimpl_=" << iteminfo->pimpl_
+//                    << ", item_=" << iteminfo->item_
+//                    << ", obj_=" << iteminfo->obj_ << ")" <<endl;
+       }
+
+       if (!form_was_frozen) {
+               fl_unfreeze_form(form);
+       }
+       if (!form_was_open) 
+               fl_end_form();
+
+       lyxerr[Debug::GUI] << "Menubar set." << endl;
+} 
+
+void Menubar::Pimpl::openByName(string const & name)
+{
+       for(ButtonList::const_iterator cit = buttonlist_.begin();
+           cit != buttonlist_.end(); ++cit) {
+               if ((*cit)->item_->submenu() == name) {
+                       MenuCallback((*cit)->obj_, 1);
+                       return;
+               }
+       }
+       lyxerr << "Menubar::Pimpl::openByName: menu "
+              << name << " not found" << endl;
+}
+
+
+void Menubar::Pimpl::add_lastfiles(int menu, string const & extra_label,
+                                  std::vector<int> & /*smn*/, 
+                                  StrPool & strpool) 
+{
+       int ii = 1;
+       for (LastFiles::const_iterator cit = lastfiles->begin();
+            cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
+
+               int action =
+                       lyxaction.getPseudoAction(LFUN_FILE_OPEN, (*cit));
+               string label = tostr(ii) + ". "
+                       + MakeDisplayPath((*cit),30)
+                       + "%x" + tostr(action);
+               if ((cit + 1) == lastfiles->end())
+                       label += extra_label;
+               string shortcut = tostr(ii) + "#" + tostr(ii); 
+               lyxerr[Debug::GUI] << "shortcut is " << shortcut <<
+                       endl;
+
+               int n = fl_addtopup(menu, strpool.add(label));
+               fl_setpup_shortcut(menu, n, strpool.add(shortcut));
+       }
+
+}
+
+void Menubar::Pimpl::add_documents(int menu, string const & extra_label,
+                                  std::vector<int> & /*smn*/, 
+                                  StrPool & strpool) 
+{
+       std::vector<string> names = bufferlist.getFileNames();
+
+       if (names.empty()) {
+               fl_addtopup(menu,_("No Documents Open!%i"));
+               return;
+       }
+
+       for (std::vector<string>::const_iterator cit = names.begin();
+            cit != names.end() ; ++cit) {
+               int action =
+                       lyxaction.getPseudoAction(LFUN_SWITCHBUFFER, *cit);
+               string label = MakeDisplayPath(*cit, 30)
+                       + "%x" + tostr(action);
+               if ((cit + 1) == names.end())
+                       label += extra_label;
+                               
+               fl_addtopup(menu, strpool.add(label));
+       }
+
+}
+
+
+int Menubar::Pimpl::create_submenu(Window win, LyXView * view, 
+                                  string const & menu_name, 
+                                  std::vector<int> & smn, StrPool & strpool) 
+{
+       if (!menubackend_->hasMenu(menu_name)){ 
+               lyxerr << "ERROR:create_submenu: Unknown menu `" 
+                      << menu_name << "'" << endl;
+               return -1;
+       }
+       Menu md = menubackend_->getMenu(menu_name);
+
+       int menu = fl_newpup(win);
+       fl_setpup_softedge(menu, true);
+       fl_setpup_bw(menu, -1);
+       lyxerr[Debug::GUI] << "Adding menu " << menu 
+                          << " in deletion list" << endl;
+       smn.push_back(menu);
+
+       // Compute the size of the largest label (because xforms is
+       // not able to support shortcuts correctly...)
+       int max_width = 0, max_tabs = 0;
+       int tab_width = fl_get_string_width(FL_NORMAL_STYLE, MENU_LABEL_SIZE,
+                                           menu_tabstop, strlen(menu_tabstop));
+       for (Menu::const_iterator i = md.begin(); i != md.end(); ++i) {
+               MenuItem item = (*i);
+               if (item.kind() == MenuItem::Command) {
+                       string label = idex(item.label().c_str());
+                       int width = fl_get_string_width(FL_NORMAL_STYLE,
+                                                       MENU_LABEL_SIZE,
+                                                       label.c_str(),
+                                                       label.length());
+                       if (width > max_width)
+                               max_width = width;
+               }
+       }
+       max_tabs = (max_width + 5)/tab_width + 1;
+       lyxerr[Debug::GUI] << "tab_width=" << tab_width 
+                          << ", max_width=" << max_width 
+                          << ", max_tabs=" << max_tabs << endl;
+
+       for (Menu::const_iterator i = md.begin(); i != md.end(); ++i) {
+               MenuItem item = (*i);
+               // Is there a separator after this item?
+               string extra_label;
+               if ((i+1) != md.end()  
+                   && (i+1)->kind() == MenuItem::Separator)
+                       extra_label = "%l";
+
+               switch(item.kind()) {
+               case MenuItem::Command: {
+                       LyXFunc::func_status flag = 
+                               view->getLyXFunc()->getStatus(item.action()); 
+                       // Get the keys bound to this action, but keep only the
+                       // first one later
+                       string accel = toplevel_keymap->findbinding(item.action());
+                       lyxerr[Debug::GUI] << "Command: "  
+                                          << lyxaction.getActionName(item.action())
+                                          << " Binding " << accel << endl;
+
+                       // Build the menu label from all the info
+                       string label = idex(item.label().c_str());
+
+                       if (!accel.empty()) {
+                               // Try to be clever and add enough
+                               // tabs to align shortcuts.
+                               int width = 
+                                       fl_get_string_width(FL_NORMAL_STYLE,
+                                                           MENU_LABEL_SIZE,
+                                                           label.c_str(),
+                                                           label.length());
+                               int nb = max_tabs - width/tab_width;
+                               lyxerr[Debug::GUI] << "label=" << label 
+                                                  << ", tabs=" << nb 
+                                                  << endl;
+                               if (nb > 0)
+                                       label += string(nb, '\t');
+                               label += accel.substr(1,accel.find(']') - 1);
+                       }
+                       label += "%x" + tostr(item.action()) + extra_label;
+                       
+                       // Modify the entry using the function status
+                       string pupmode;
+                       if (flag & (LyXFunc::Disabled | LyXFunc::Unknown))
+                               pupmode += "%i";
+                       if (flag & LyXFunc::ToggleOn)
+                               pupmode += "%B";
+                       if (flag & LyXFunc::ToggleOff)
+                               pupmode += "%b";
+                       label += pupmode;
+
+                       // Finally the menu shortcut
+                       string shortcut = scex(item.label().c_str());
+
+                       if (!shortcut.empty()) {
+                               string xfshortcut;
+                               xfshortcut += uppercase(shortcut[0]);
+                               xfshortcut += '#';
+                               xfshortcut += uppercase(shortcut[0]);
+                               xfshortcut += lowercase(shortcut[0]);
+                               xfshortcut += '#';
+                               xfshortcut += lowercase(shortcut[0]);
+                               lyxerr[Debug::GUI] << "shortcut is " 
+                                                  << xfshortcut << endl;
+                               label += "%h";
+                               fl_addtopup(menu, strpool.add(label), 
+                                           strpool.add(xfshortcut));
+                       } else
+                               fl_addtopup(menu, strpool.add(label));
+
+                       break;
+               }
+
+               case MenuItem::Submenu: {
+                       int submenu = create_submenu(win, view, 
+                                                    item.submenu(),
+                                                    smn, strpool);
+                       if (submenu == -1)
+                               return -1;
+                       string label = idex(item.label().c_str());
+                       label += extra_label + "%m";
+                       string shortcut = scex(item.label().c_str());
+                       int n = fl_addtopup(menu, strpool.add(label), submenu);
+                       fl_setpup_shortcut(menu, n, strpool.add(shortcut));
+                       break;
+               }
+
+               case MenuItem::Separator:
+                       // already done, and if it was the first one,
+                       // we just ignore it.
+                       break;
+
+               case MenuItem::Documents: 
+                       add_documents(menu, extra_label, smn, strpool);
+                       break;
+
+
+               case MenuItem::Lastfiles: 
+                       add_lastfiles(menu, extra_label, smn, strpool);
+                       break;
+
+               }
+       }
+       return menu;
+}
+
+extern "C"
+void C_Menubar_Pimpl_MenuCallback(FL_OBJECT * ob, long button)
+{
+       Menubar::Pimpl::MenuCallback(ob, button);
+}
+
+
+void Menubar::Pimpl::MenuCallback(FL_OBJECT * ob, long button)
+{
+       ItemInfo * iteminfo = static_cast<ItemInfo *>(ob->u_vdata);
+//     lyxerr << "MenuCallback: ItemInfo address=" << iteminfo
+//            << "Val=(pimpl_=" << iteminfo->pimpl_
+//            << ", item_=" << iteminfo->item_
+//            << ", obj_=" << iteminfo->obj_ << ")" <<endl;
+
+       LyXView * view = iteminfo->pimpl_->owner_;
+       MenuItem const * item = iteminfo->item_;
+
+       if (button == 1) {
+               // set the pseudo menu-button
+               fl_set_object_boxtype(ob, FL_DOWN_BOX);
+               fl_set_button(ob, 0);
+               fl_redraw_object(ob);
+       }
+
+       // Paranoia check
+       Assert(item->kind() == MenuItem::Submenu);
+       
+       // set tabstop length
+       fl_set_tabstop(menu_tabstop);
+       std::vector<int> submenus;
+       StrPool strpool;
+       int menu = iteminfo->pimpl_->
+               create_submenu(FL_ObjWin(ob), view, 
+                              item->submenu(), 
+                              submenus, strpool);
+       if (menu != -1) {
+               // place popup
+               fl_setpup_position(view->getForm()->x + ob->x,
+                                  view->getForm()->y + ob->y + ob->h + 10);   
+               int choice = fl_dopup(menu);
+               
+               if (button == 1) {
+                               // set the pseudo menu-button back
+                       fl_set_object_boxtype(ob, FL_FLAT_BOX);
+                       fl_redraw_object(ob);
+               }
+               
+               if (choice >= 1) {
+                       view->getLyXFunc()->Dispatch(choice);
+               }
+       }
+       else 
+               lyxerr << "Error in MenuCallback" << endl;
+       
+       std::for_each(submenus.begin(), submenus.end(), fl_freepup);
+       // restore tabstop length
+       fl_set_tabstop(default_tabstop);
+
+}
diff --git a/src/frontends/xforms/Menubar_pimpl.h b/src/frontends/xforms/Menubar_pimpl.h
new file mode 100644 (file)
index 0000000..fadad73
--- /dev/null
@@ -0,0 +1,90 @@
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ *           This file is Copyright 1996-2000
+ *           Lars Gullik Bjønnes
+ *
+ * ====================================================== */
+
+#ifndef MENUBAR_PIMPL_H
+#define MENUBAR_PIMPL_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include <vector>
+#include "LString.h"
+#include "frontends/Menubar.h"
+#include FORMS_H_LOCATION
+class LyXView;
+class MenuBackend;
+class MenuItem;
+class StrPool;
+
+#include "debug.h"
+
+/** The LyX GUI independent menubar class
+  The GUI interface is implemented in the corresponding Menubar_pimpl class. 
+  */
+struct Menubar::Pimpl {
+public:
+       ///
+       Pimpl(LyXView *, MenuBackend const &);
+       ///
+       ~Pimpl();
+       ///
+       void set(string const &);
+       /// Opens a top-level submenu given its name
+       void openByName(string const &);
+
+       ///
+       static void MenuCallback(FL_OBJECT *, long);
+
+       /// Add to "menu" the list of last opened files
+       /// (add "extra_label" to the last entry)
+       void add_lastfiles(int menu, string const & extra_label,
+                          std::vector<int> & smn, StrPool & strpool);
+       /// Add to "menu" the list of opened documents
+       /// (add "extra_label" to the last entry)
+       void add_documents(int menu, string const & extra_label,
+                          std::vector<int> & smn, StrPool & strpool);
+       ///
+       int create_submenu(Window win, LyXView * view, 
+                          string const & menuname, 
+                          std::vector<int> & smn, StrPool & strpool);
+
+private:
+       ///
+       FL_OBJECT * frame_;
+       /// 
+       LyXView * owner_;
+       ///
+       MenuBackend const * menubackend_;
+       ///
+       string current_menu;
+       ///
+       struct ItemInfo {
+               ///
+               ItemInfo(Menubar::Pimpl * p, MenuItem const * i, 
+                          FL_OBJECT * o) 
+                       : pimpl_(p), item_(i), obj_(o) {}
+               ///
+               Menubar::Pimpl * pimpl_;
+               ///
+               MenuItem const * item_;
+               ///
+               FL_OBJECT * obj_;
+       };
+
+       ///
+       typedef std::vector<ItemInfo *> ButtonList;
+       ///
+       ButtonList buttonlist_;
+};
+#endif
diff --git a/src/frontends/xforms/Toolbar_pimpl.C b/src/frontends/xforms/Toolbar_pimpl.C
new file mode 100644 (file)
index 0000000..4fe3234
--- /dev/null
@@ -0,0 +1,488 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ *           This file is Copyright 1996-1998
+ *           Lars Gullik Bjønnes
+ *
+ * ====================================================== */
+
+//  Added pseudo-action handling, asierra 180296
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "Toolbar_pimpl.h"
+#include "lyxfunc.h"
+#include "debug.h"
+#include "LyXView.h"
+#include "BufferView.h"
+#include "buffer.h"
+#include "LyXAction.h"
+#include "support/filetools.h"
+
+using std::endl;
+
+// this one is not "C" because combox callbacks are really C++ %-|
+extern void LayoutsCB(int, void *);
+extern char const ** get_pixmap_from_symbol(char const * arg, int, int);
+extern LyXAction lyxaction;
+
+// some constants
+const int standardspacing = 2; // the usual space between items
+const int sepspace = 6; // extra space
+const int buttonwidth = 30; // the standard button width
+const int height = 30; // the height of all items in the toolbar
+
+Toolbar::Pimpl::toolbarItem::toolbarItem() {
+       action = LFUN_NOACTION;
+       icon = 0;
+}
+
+
+Toolbar::Pimpl::toolbarItem::~toolbarItem() {
+       clean();
+}
+
+
+void Toolbar::Pimpl::toolbarItem::clean() {
+       if (icon) {
+               fl_delete_object(icon);
+               fl_free_object(icon);
+               icon = 0;
+       }
+}
+
+
+Toolbar::Pimpl::toolbarItem & 
+Toolbar::Pimpl::toolbarItem::operator=(const toolbarItem & ti) {
+       // do we have to check icon too?
+       action = ti.action;
+       icon = 0; // locally we need to get the icon anew
+       
+       return *this;
+}
+
+
+
+Toolbar::Pimpl::Pimpl(LyXView * o, int x, int y)
+       : owner(o), sxpos(x), sypos(y)
+{
+       combox = 0;
+#if FL_REVISION < 89
+       bubble_timer = 0;
+#endif
+}
+
+
+#if FL_REVISION < 89
+// timer-cb for bubble-help (Matthias)
+static 
+void BubbleTimerCB(FL_OBJECT *, long data)
+{
+       FL_OBJECT * ob = reinterpret_cast<FL_OBJECT*>(data);
+       // The trick we use to get the help text is to read the
+       // argument of the callback that has been registered for
+       // ToolBarCB.  (JMarc)
+       string help = lyxaction.helpText(ob->argument);
+       fl_show_oneliner(help.c_str(), ob->form->x + ob->x,
+                        ob->form->y + ob->y + ob->h);
+}
+
+
+extern "C" void C_Toolbar_BubbleTimerCB(FL_OBJECT * ob, long data)
+{
+       BubbleTimerCB(ob, data);
+}
+
+
+// post_handler for bubble-help (Matthias)
+static
+int BubblePost(FL_OBJECT *ob, int event,
+                       FL_Coord /*mx*/, FL_Coord /*my*/,
+                       int /*key*/, void */*xev*/)
+{
+       FL_OBJECT * bubble_timer = reinterpret_cast<FL_OBJECT *>(ob->u_cdata);
+       
+       // We do not test for empty help here, since this can never happen
+       if(event == FL_ENTER){
+               fl_set_object_callback(bubble_timer,
+                                      C_Toolbar_BubbleTimerCB,
+                                      reinterpret_cast<long>(ob));
+               fl_set_timer(bubble_timer, 1);
+       }
+       else if(event != FL_MOTION){
+               fl_set_timer(bubble_timer, 0);
+               fl_hide_oneliner();
+       }
+       return 0;
+}
+
+
+extern "C" int C_Toolbar_BubblePost(FL_OBJECT * ob, int event,
+                                   FL_Coord /*mx*/, FL_Coord /*my*/, 
+                                   int key, void * xev)
+{
+       return BubblePost(ob, event, 0, 0, key, xev);
+}
+#endif
+
+
+void Toolbar::Pimpl::activate()
+{
+       ToolbarList::const_iterator p = toollist.begin();
+       for (; p != toollist.end(); ++p) {
+               if (p->icon) {
+                       fl_activate_object(p->icon);
+               }
+       }
+}
+
+
+void Toolbar::Pimpl::deactivate()
+{
+       ToolbarList::const_iterator p = toollist.begin();
+       for (; p != toollist.end(); ++p) {
+               if (p->icon) {
+                       fl_deactivate_object(p->icon);
+               }
+       }
+}
+
+void Toolbar::Pimpl::update()
+{
+       ToolbarList::const_iterator p = toollist.begin();
+       for (; p != toollist.end(); ++p) {
+               if (p->icon) {
+                       int status = owner->getLyXFunc()->getStatus(p->action);
+                       if (status & LyXFunc::ToggleOn) {
+                               // I'd like to use a different color
+                               // here, but then the problem is to
+                               // know how to use transparency with
+                               // Xpm library. It seems pretty
+                               // complicated to me (JMarc)
+                               fl_set_object_color(p->icon, FL_LEFT_BCOL, FL_BLUE);
+                               fl_set_object_boxtype(p->icon, FL_DOWN_BOX);
+                       } else {
+                               fl_set_object_color(p->icon, FL_MCOL, FL_BLUE);
+                               fl_set_object_boxtype(p->icon, FL_UP_BOX);
+                       }
+
+                       if (status & LyXFunc::Disabled) {
+                               // Is there a way here to specify a
+                               // mask in order to show that the
+                               // button is disabled? (JMarc)
+                               fl_deactivate_object(p->icon);
+                       }
+                       else
+                               fl_activate_object(p->icon);
+               }
+       }
+}
+
+
+void Toolbar::Pimpl::setLayout(int layout) {
+       if (combox)
+               combox->select(layout+1);
+}
+
+
+void Toolbar::Pimpl::updateLayoutList(bool force)
+{
+       // Update the layout display
+       if (!combox) return;
+
+       // If textclass is different, we need to update the list
+       if (combox->empty() || force) {
+               combox->clear();
+               LyXTextClass const & tc =
+                       textclasslist.TextClass(owner->buffer()->
+                                               params.textclass);
+               for (LyXTextClass::const_iterator cit = tc.begin();
+                    cit != tc.end(); ++cit) {
+                       if ((*cit).obsoleted_by().empty())
+                               combox->addline((*cit).name().c_str());
+                       else
+                               combox->addline(("@N" + (*cit).name()).c_str());
+               }
+       }
+       // we need to do this.
+       combox->Redraw();
+}
+
+void Toolbar::Pimpl::clearLayoutList()
+{
+       if (combox) {
+               combox->clear();
+               combox->Redraw();
+       }
+}
+
+void Toolbar::Pimpl::openLayoutList()
+{
+       if (combox)
+               combox->Show();
+}
+
+static
+void ToolbarCB(FL_OBJECT * ob, long ac)
+{
+       LyXView * owner = static_cast<LyXView *>(ob->u_vdata);
+       
+       string res = owner->getLyXFunc()->Dispatch(int(ac));
+       if(!res.empty())
+               lyxerr[Debug::GUI] << res << endl;
+}
+
+
+extern "C" void C_Toolbar_ToolbarCB(FL_OBJECT * ob, long data)
+{
+       ToolbarCB(ob, data);
+}
+
+#if 0
+// What are we supposed to do with that??
+int Toolbar::get_toolbar_func(string const & func)
+{
+       int action = lyxaction.LookupFunc(func.c_str());
+       if (action == -1) {
+               if (func == "separator"){
+                       action = TOOL_SEPARATOR;
+               } else if (func == "layouts"){
+                        action = TOOL_LAYOUTS;
+                } else action = 0;
+       }
+       return action;
+}
+#endif
+
+
+static
+void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) {
+       string name, arg, xpm_name;
+       kb_action act;
+
+       if (lyxaction.isPseudoAction(action)) {
+               act = lyxaction.retrieveActionArg(action, arg);
+               name = lyxaction.getActionName(act);
+               xpm_name = subst(name + ' ' + arg, ' ','_');
+       } else {
+               act = (kb_action)action;
+               name = lyxaction.getActionName(action);
+               xpm_name = name;
+       }
+
+       string fullname = LibFileSearch("images", xpm_name, "xpm");
+
+       if (!fullname.empty()) {
+               lyxerr[Debug::GUI] << "Full icon name is `" 
+                                      << fullname << "'" << endl;
+               fl_set_pixmapbutton_file(obj, fullname.c_str());
+               return;
+       }
+
+       if (act == LFUN_INSERT_MATH && !arg.empty()) {
+               lyxerr[Debug::GUI] << "Using mathed-provided icon" << endl;
+               char const ** pixmap = get_pixmap_from_symbol(arg.c_str(),
+                                                       buttonwidth,
+                                                       height);
+               fl_set_pixmapbutton_data(obj, const_cast<char **>(pixmap));
+               return;
+       }
+       
+       lyxerr << "Unable to find icon `" << xpm_name << "'" << endl;
+       fullname = LibFileSearch("images", "unknown", "xpm");
+       if (!fullname.empty()) {
+               lyxerr[Debug::GUI] << "Using default `unknown' icon" 
+                                      << endl;
+               fl_set_pixmapbutton_file(obj, fullname.c_str());
+       }
+}
+
+void Toolbar::Pimpl::set(bool doingmain)
+{
+       // we shouldn't set if we have not cleaned
+       if (!cleaned) return;
+       
+       FL_OBJECT * obj;
+       
+       if (!doingmain) {
+               fl_freeze_form(owner->getForm());
+               fl_addto_form(owner->getForm());
+       }
+
+#if FL_REVISION < 89
+       // add the time if it don't exist
+       if (bubble_timer == 0)
+               bubble_timer = fl_add_timer(FL_HIDDEN_TIMER,
+                                           xpos, ypos, 0, 0, "Timer");
+#endif
+       
+       ToolbarList::iterator item = toollist.begin();
+       for (; item != toollist.end(); ++item) {
+               switch(item->action){
+               case ToolbarDefaults::SEPARATOR:
+                       xpos += sepspace;
+                       break;
+               case ToolbarDefaults::NEWLINE:
+                       // Not supported yet.
+                       break;
+               case ToolbarDefaults::LAYOUTS:
+                       xpos += standardspacing;
+                       if (!combox)
+                               combox = new Combox(FL_COMBOX_DROPLIST);
+                       combox->add(xpos, ypos, 135, height, 400);
+                       combox->setcallback(LayoutsCB);
+                       combox->resize(FL_RESIZE_ALL);
+                       combox->gravity(NorthWestGravity, NorthWestGravity);
+                       xpos += 135;
+                       break;
+               default:
+                       xpos += standardspacing;
+                       item->icon = obj = 
+                               fl_add_pixmapbutton(FL_NORMAL_BUTTON,
+                                                   xpos, ypos,
+                                                   buttonwidth,
+                                                   height, "");
+                       fl_set_object_resize(obj, FL_RESIZE_ALL);
+                       fl_set_object_gravity(obj,
+                                             NorthWestGravity,
+                                             NorthWestGravity);
+                       fl_set_object_callback(obj, C_Toolbar_ToolbarCB,
+                                              static_cast<long>(item->action));
+                       // Remove the blue feedback rectangle
+                       fl_set_pixmapbutton_focus_outline(obj, 0);
+
+                       // Set the tooltip
+#if FL_REVISION >= 89
+                       string help = lyxaction.helpText(item->action);
+                       fl_set_object_helper(obj, help.c_str());        
+#else
+                       fl_set_object_posthandler(obj, C_Toolbar_BubblePost);
+                       obj->u_cdata = reinterpret_cast<char *>(bubble_timer);
+#endif
+
+                       // The view that this object belongs to.
+                       obj->u_vdata = owner;
+
+                       setPixmap(obj, item->action, buttonwidth, height);
+                       // we must remember to update the positions
+                       xpos += buttonwidth;
+                       // ypos is constant
+                       /* Here will come a check to see if the new
+                        * pos is within the bounds of the main frame,
+                        * and perhaps wrap the toolbar if not.
+                        */
+                       break;
+               }
+       }
+
+       if (!doingmain) {
+               fl_end_form();
+               fl_unfreeze_form(owner->getForm());
+               // Should be safe to do this here.
+               owner->updateLayoutChoice();
+       }
+
+       // set the state of the icons
+       //update();
+
+       cleaned = false;
+}
+
+
+void Toolbar::Pimpl::add(int action, bool doclean)
+{
+       if (doclean && !cleaned) clean();
+
+       // this is what we do if we want to add to an existing
+       // toolbar.
+       if (!doclean && owner) {
+               // first "hide" the toolbar buttons. This is not a real hide
+               // actually it deletes and frees the button altogether.
+               lyxerr << "Toolbar::add: \"hide\" the toolbar buttons." 
+                      << endl;
+
+               lightReset();
+               
+               fl_freeze_form(owner->getForm());
+
+               ToolbarList::iterator p = toollist.begin();
+               for (; p != toollist.end(); ++p) {
+                       p->clean();
+               }
+
+               if (combox) {
+                       delete combox;
+                       combox = 0;
+               }
+               fl_unfreeze_form(owner->getForm());
+               cleaned = true; // this is not completely true, but OK anyway
+       }
+       
+       // there exist some special actions not part of
+       // kb_action: SEPARATOR, LAYOUTS
+
+       toolbarItem newItem;
+       newItem.action = action;
+       toollist.push_back(newItem);
+}
+
+
+void Toolbar::Pimpl::clean()
+{
+       //reset(); // I do not understand what this reset() is, anyway
+
+       //now delete all the objects..
+       if (owner)
+               fl_freeze_form(owner->getForm());
+
+       // G++ vector does not have clear defined
+       //toollist.clear();
+       toollist.erase(toollist.begin(), toollist.end());
+
+       lyxerr[Debug::GUI] << "Combox: " << combox << endl;
+       if (combox) {
+               delete combox;
+               combox = 0;
+       }
+
+       if (owner)
+               fl_unfreeze_form(owner->getForm());
+       lyxerr[Debug::GUI] << "toolbar cleaned" << endl;
+       cleaned = true;
+}
+
+
+void Toolbar::Pimpl::push(int nth)
+{
+       lyxerr[Debug::GUI] << "Toolbar::push: trying to trigger no `"
+                              << nth << '\'' << endl;
+       
+       if (nth <= 0 || nth >= int(toollist.size())) {
+               // item nth not found...
+               return;
+       }
+
+       fl_trigger_object(toollist[nth - 1].icon);
+}
+
+
+void Toolbar::Pimpl::reset() 
+{
+       //toollist = 0; // what is this supposed to do?
+       cleaned = false;
+       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
new file mode 100644 (file)
index 0000000..43aa965
--- /dev/null
@@ -0,0 +1,121 @@
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ *           This file is Copyright 1996-2000
+ *           Lars Gullik Bjønnes
+ *
+ * ====================================================== */
+
+#ifndef TOOLBAR_PIMPL_H
+#define TOOLBAR_PIMPL_H
+
+#include "frontends/Toolbar.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include <vector>
+#include FORMS_H_LOCATION
+#include "commandtags.h"
+#include "combox.h"
+#include "ToolbarDefaults.h"
+
+/** The LyX xforms toolbar class
+  */
+struct Toolbar::Pimpl {
+public:
+       ///
+       Pimpl(LyXView * o, int x, int y);
+
+       ///
+       ~Pimpl() {
+               clean();
+       }
+       
+#if 0
+       ///
+       int get_toolbar_func(string const & func);
+#endif
+       
+       /// (re)sets the toolbar
+       void set(bool doingmain = false);
+
+       /** this is to be the entry point to the toolbar
+         frame, where you can change the toolbar realtime. */
+       void edit();
+       /// add a new button to the toolbar.
+       void add(int , bool doclean = true);
+       /// invokes the n'th icon in the toolbar
+       void push(int);
+       /// activates the toolbar
+        void activate();
+       /// deactivates the toolbar
+        void deactivate();
+       /// update the state of the icons
+       void update();
+
+       /// select the right layout in the combox
+       void setLayout(int layout);
+       /// Populate the layout combox; re-do everything if force is true.
+       void updateLayoutList(bool force);
+       /// Drop down the layout list
+       void openLayoutList();
+       /// Erase the layout list
+       void clearLayoutList();
+
+       ///
+       struct toolbarItem
+       {
+               ///
+               int action;
+               ///
+               FL_OBJECT * icon;
+               ///
+               toolbarItem();
+               ///
+               void clean();
+               ///
+               ~toolbarItem();
+               ///
+               toolbarItem & operator=(toolbarItem const & ti);
+       };
+
+       /// typedef to simplify things
+       typedef std::vector<toolbarItem> ToolbarList;
+       /// The list containing all the buttons
+       ToolbarList toollist;
+       ///
+       LyXView * owner;
+#if FL_REVISION < 89
+       ///
+       FL_OBJECT * bubble_timer;
+#endif
+       ///
+       Combox * combox;
+       /// Starting position
+       int sxpos, sypos;
+       ///
+       int xpos;
+       ///
+       int ypos;
+       ///
+       bool cleaned;
+
+       /// removes all toolbar buttons from the toolbar.
+       void clean();
+
+       /** more...
+        */
+       void reset();
+
+       /** more...
+        */
+       void lightReset();
+};
+#endif
index 73ac251a42d689b985b5dcd9b10c74645a7fe18c..7a72aeb96a2f383b98119901ad457602b77478e0 100644 (file)
@@ -9,7 +9,6 @@
 
 #include FORMS_H_LOCATION  
 #include "insetbib.h"
-#include "combox.h"
 #include "buffer.h"
 #include "debug.h"
 #include "lyx_gui_misc.h"
index 08968149271546f9dade5869bfcd59e405ed3195..855fb2c061f9fe30d43fc847b93bea639ee1b121 100644 (file)
@@ -38,7 +38,6 @@
 #include "CutAndPaste.h"
 #include "font.h"
 #include "minibuffer.h"
-#include "toolbar.h"
 #include "LColor.h"
 #include "support/textutils.h"
 #include "support/LAssert.h"
@@ -420,7 +419,7 @@ void InsetText::UpdateLocal(BufferView * bv, UpdateCodes what, bool mark_dirty)
        TEXT(bv)->selection)
            bv->updateInset(this, mark_dirty);
     if (old_par != cpar(bv)) {
-           bv->owner()->getToolbar()->combox->select(cpar(bv)->GetLayout()+1);
+           bv->owner()->setLayout(cpar(bv)->GetLayout());
            old_par = cpar(bv);
     }
 }
@@ -467,11 +466,10 @@ void InsetText::InsetUnlock(BufferView * bv)
     TEXT(bv)->selection = 0;
     UpdateLocal(bv, CLEAR_FRAME, false);
     if (owner())
-           bv->owner()->getToolbar()->combox->
-                   select(owner()->getLyXText(bv)->cursor.par()->GetLayout()+1);
+           bv->owner()->setLayout(owner()->getLyXText(bv)
+                                   ->cursor.par()->GetLayout());
     else
-           bv->owner()->getToolbar()->combox->select(bv->text->cursor.par()->
-                                                     GetLayout()+1);
+           bv->owner()->setLayout(bv->text->cursor.par()->GetLayout());
 }
 
 
@@ -594,7 +592,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
                                           y+TEXT(bv)->first+insetAscent);
        TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
        UpdateLocal(bv, CURSOR, false);
-       bv->owner()->getToolbar()->combox->select(cpar(bv)->GetLayout()+1);
+       bv->owner()->setLayout(cpar(bv)->GetLayout());
        old_par = cpar(bv);
     }
 }
@@ -866,7 +864,7 @@ InsetText::LocalDispatch(BufferView * bv,
        if (cur_layout != layout.second) {
            cur_layout = layout.second;
            TEXT(bv)->SetLayout(bv, layout.second);
-           bv->owner()->getToolbar()->combox->select(cpar(bv)->GetLayout()+1);
+           bv->owner()->setLayout(cpar(bv)->GetLayout());
            UpdateLocal(bv, CURSOR_PAR, true);
        }
     }
index b96c66a2ec0a8fb33ffa802a15f09dc7db7eb5f8..8ce45c04a47824451783aa6dc349ef68510ee0ae 100644 (file)
@@ -1,6 +1,19 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
 
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include "language.h"
 #include "gettext.h"
 #include "encoding.h"
index 3538c208d6d5dc1a24f5035dffd755382a4e3fc4..68f87abd9d28b4275c0986bf20b4dde55ddbfa4e 100644 (file)
@@ -1,7 +1,21 @@
 // -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
 #ifndef LANGUAGE_H
 #define LANGUAGE_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include <map>
 #include "LString.h"
 
index 1be9c7f4fc8ca97fc217d10d4f9511011962c883..9b849b6c5eb763b844e3598698606d1533ad7183 100644 (file)
 
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include <cerrno>
 #include "lyx_gui_misc.h"
 #include "BufferView.h"
index 92525efcea12ef430aeb69a47344d60ba5cd70c0..8b959bd0895064a7b6dc1ef60a37f56f8ad3479e 100644 (file)
 #ifndef LYX_GUI_MISC_H
 #define LYX_GUI_MISC_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include FORMS_H_LOCATION
 #include "LString.h"
 #include <utility>  /* needed for pair<> definition */
index b9b1700a1222cacfc812008d7813687ad0e395c5..48d0072268a6dc259e1402b61de63996ad915ada 100644 (file)
 #include <cstdlib>
 #include <csignal>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include "version.h"
 #include "lyx_main.h"
 #include "lyx_gui.h"
 #include "layout.h"
 #include "gettext.h"
 #include "kbmap.h"
+#ifdef NEW_MENUBAR
+# include "MenuBackend.h"
+#endif
+#include "ToolbarDefaults.h"
+#include "lyxlex.h"
 
 using std::endl;
 
@@ -89,8 +98,6 @@ LyX::LyX(int * argc, char * argv[])
                }
        }
        
-
-
        // Initialization of LyX (reads lyxrc and more)
        lyxerr[Debug::INIT] << "Initializing LyX::init..." << endl;
        init(argc, argv, gui);
@@ -403,6 +410,8 @@ void LyX::init(int */*argc*/, char **argv, bool gui)
        if (!lyxrc.hasBindFile)
                lyxrc.ReadBindFile();
 
+       // Read menus
+       ReadUIFile(lyxrc.ui_file);
 
        // Bind the X dead keys to the corresponding LyX functions if
        // necessary. 
@@ -575,6 +584,65 @@ void LyX::ReadRcFile(string const & name)
 }
 
 
+// Read the ui file `name'
+void LyX::ReadUIFile(string const & name)
+{
+       enum Uitags {
+               ui_menuset = 1,
+               ui_toolbar,
+               ui_last
+       };
+
+       struct keyword_item uitags[ui_last-1] = {
+               { "menuset", ui_menuset },
+               { "toolbar", ui_toolbar }
+       };
+
+       lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
+       
+       string ui_path = LibFileSearch("ui", name, "ui");
+
+       if (ui_path.empty()) {
+               lyxerr[Debug::INIT] << "Could not find " << name << endl;
+               return;
+       }
+       
+       lyxerr[Debug::INIT] << "Found " << name
+                           << " in " << ui_path << endl;
+       LyXLex lex(uitags, ui_last - 1);
+       lex.setFile(ui_path);
+       if (lyxerr.debugging(Debug::PARSER))
+               lex.printTable(lyxerr);
+
+       while (lex.IsOK()) {
+               switch(lex.lex()) {
+               case ui_menuset: 
+#ifdef NEW_MENUBAR
+                       menubackend.read(lex);
+                       break;
+#else
+                       // Skip any menu definition and fall over to toolbar.
+                       // This is a hack, but it is supposed to go away...
+                       do {
+                               lex.next();
+                               if (!lex.IsOK()) return;
+                       }
+                       while (lex.lex() != ui_toolbar);
+#endif
+
+               case ui_toolbar:
+                       toolbardefaults.read(lex);
+                       break;
+
+               default:
+                       lex.printError("LyX::ReadUFile: "
+                                      "Unknown menu tag: `$$Token'");
+                       break;
+               }
+       }
+}
+
+
 // Set debugging level and report result to user
 void setDebuggingLevel(string const & dbgLevel)
 {
index c992dfc80aa9276034194f401fe4968db0735370..7279b087d3bca0426615b9e43f916bd7d7b2be1d 100644 (file)
 #ifndef LYX_MAIN_H
 #define LYX_MAIN_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include <csignal>
 
 #include "LString.h"
@@ -83,6 +87,8 @@ private:
        void queryUserLyXDir(bool explicit_userdir);
        ///
         void ReadRcFile(string const & name);
+       /// Read the ui file `name'
+       void ReadUIFile(string const & name);
         ///
        bool easyParse(int * argc, char * argv[]);
        //@}
index 85e5662813ec07ee5f256deb3d6cadbe105252ad..be9138063ec22cf49a7e9a35afe35d5e8b095fba 100644 (file)
@@ -1,16 +1,19 @@
-/*
-  This file is part of
-  ====================================================== 
-  
-  LyX, The Document Processor
-  
-  Copyright 1995 Matthias Ettrich
-  Copyright 1995-2000 The LyX Team.
-  ====================================================== 
-  */
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
 
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include "lyx_sty.h"
 
 //\NeedsTeXFormat{LaTeX2e}
index eafab288dbd1977a9df9eac588bc95769fe4bb9d..56def33a5de92d2332b0f50da2d75601bf674ac1 100644 (file)
@@ -1,19 +1,21 @@
 // -*- C++ -*-
-/*
-  This file is part of
-  ======================================================
-  
-  LyX, The Document Processor
-  
-  Copyright 1995 Matthias Ettrich
-  copyright 1995-2000 The LyX Team.
-  
-  ======================================================
-  */
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
 
 #ifndef LYX_STY_H
 #define LYX_STY_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include "LString.h"
 
 // This seems to be fixed now (JMarc)
index 098b385689829e8892baa4e8544630f2543299d2..e30bd08eb3bba3d0e7df412970a0fb82b96d50f4 100644 (file)
 
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include "lyxcursor.h"
 
 
index 7c4bed06bac301329a819e05907ca08147d0d369..9137f48d4e4cc9ba2848c263ae34f22eed6e5d2a 100644 (file)
 #ifndef LYXCURSOR_H
 #define LYXCURSOR_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include "lyxparagraph.h"
 
 struct Row;
index dea07908c294d13a5301ac637974173416c23d4a..0e6564e9a379de10683be993ebb2a18affb16395 100644 (file)
@@ -28,6 +28,7 @@ using std::istringstream;
 #pragma implementation
 #endif
 
+#include "version.h"
 #include "lyxlookup.h"
 #include "kbmap.h"
 #include "lyxfunc.h"
@@ -64,7 +65,6 @@ using std::istringstream;
 #include "insets/insettheorem.h"
 #include "insets/insetcaption.h"
 #include "mathed/formulamacro.h"
-#include "toolbar.h"
 #include "spellchecker.h" // RVDK_PATCH_5
 #include "minibuffer.h"
 #include "vspace.h"
@@ -86,9 +86,14 @@ using std::istringstream;
 #include "layout.h"
 #include "WorkArea.h"
 #include "lyxfr1.h"
-#include "menus.h"
 #include "bufferview_funcs.h"
 #include "frontends/Dialogs.h"
+#include "frontends/Toolbar.h"
+#ifdef NEW_MENUBAR
+#include "frontends/Menubar.h"
+#else
+#include "menus.h"
+#endif
 #include "FloatList.h"
 
 using std::pair;
@@ -343,6 +348,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
                                // no
                                setErrorMessage(N_("Document is read-only"));
                                flag |= LyXFunc::Disabled;
+                               return flag;
                        }
                } else {
                        // no
@@ -352,9 +358,6 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
                }
        }
 
-       if (flag & LyXFunc::Disabled)
-               return flag;
-
        // I would really like to avoid having this switch and rather try to
        // encode this in the function itself.
         static bool noLaTeX = lyxrc.latex_command == "none";
@@ -409,6 +412,20 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
                disable = ! owner->view()->text->cursor.par()->table;
                break;
 #endif
+       case LFUN_VC_REGISTER:
+               disable = buf->lyxvc.inUse();
+               break;
+       case LFUN_VC_CHECKIN:
+               disable = !buf->lyxvc.inUse() || buf->isReadonly();
+               break;
+       case LFUN_VC_CHECKOUT:
+               disable = !buf->lyxvc.inUse() || !buf->isReadonly();
+               break;
+       case LFUN_VC_REVERT:
+       case LFUN_VC_UNDO:
+       case LFUN_VC_HISTORY:
+               disable = !buf->lyxvc.inUse();
+               break;
        default:
                break;
         }
@@ -1046,6 +1063,42 @@ string LyXFunc::Dispatch(int ac,
                owner->getDialogs()->showCopyright();
                break;
 
+       case LFUN_HELP_CREDITS:
+               owner->getDialogs()->showCredits();
+               break;
+
+        case LFUN_HELP_OPEN: {
+               string arg = argument;
+               if (arg.empty()) {
+                       setErrorMessage(N_("Missing argument"));
+                       break;
+               }
+               ProhibitInput(owner->view());
+               string fname = i18nLibFileSearch("doc", arg, "lyx");
+               if (fname.empty()) {
+                       lyxerr << "LyX: unable to find documentation file `"
+                              << arg << "'. Bad installation?" << endl;
+                       AllowInput(owner->view());
+                       break;
+               }
+               owner->getMiniBuffer()->Set(_("Opening help file"),
+                                           MakeDisplayPath(fname),"...");
+               owner->view()->buffer(bufferlist.loadLyXFile(fname,false));
+               AllowInput(owner->view());
+               break;
+        }
+
+       case LFUN_HELP_VERSION: 
+               ProhibitInput(owner->view());
+               fl_show_message((string(_("LyX Version ")) + LYX_VERSION 
+                                + _(" of ") + LYX_RELEASE).c_str(),
+                               (_("Library directory: ")
+                                + MakeDisplayPath(system_lyxdir)).c_str(),
+                               (_("User directory: ") 
+                                + MakeDisplayPath(user_lyxdir)).c_str());
+               AllowInput(owner->view());
+               break;
+
                // --- version control -------------------------------
        case LFUN_VC_REGISTER:
        {
@@ -1090,6 +1143,11 @@ string LyXFunc::Dispatch(int ac,
        
        // --- buffers ----------------------------------------
 
+        case LFUN_SWITCHBUFFER:
+                owner->view()->buffer(bufferlist.getBuffer(argument));
+               break;
+
+
        case LFUN_FILE_INSERT:
        {
                MenuInsertLyXFile(argument);
@@ -1174,10 +1232,7 @@ string LyXFunc::Dispatch(int ac,
                        owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
                        owner->view()->text->
                                SetLayout(owner->view(), layout.second);
-                       owner->getToolbar()->combox->
-                               select(owner->view()->
-                                      text->cursor.par()->
-                                      GetLayout() + 1);
+                       owner->setLayout(layout.second);
                        owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                        owner->view()->setState();
                }
@@ -1221,7 +1276,7 @@ string LyXFunc::Dispatch(int ac,
                break;
                
        case LFUN_DROP_LAYOUTS_CHOICE:
-               owner->getToolbar()->combox->Show();
+               owner->getToolbar()->openLayoutList();
                break;
 
        case LFUN_LANGUAGE:
@@ -1348,7 +1403,11 @@ string LyXFunc::Dispatch(int ac,
        break;
                
        case LFUN_MENU_OPEN_BY_NAME:
+#ifdef NEW_MENUBAR
+               owner->getMenubar()->openByName(argument);
+#else
                owner->getMenus()->openByName(argument);
+#endif
                break; // RVDK_PATCH_5
                
        case LFUN_SPELLCHECK:
@@ -2290,15 +2349,7 @@ string LyXFunc::Dispatch(int ac,
        case LFUN_PUSH_TOOLBAR:
        {
                int nth = strToInt(argument);
-               if (lyxerr.debugging(Debug::TOOLBAR)) {
-                       lyxerr << "LFUN_PUSH_TOOLBAR: argument = `"
-                              << argument << "'\n"
-                              << "LFUN_PUSH_TOOLBAR: nth = `"
-                              << nth << "'" << endl;
-               }
-               
                if (nth <= 0) {
-                       LyXBell();
                        setErrorMessage(N_("Push-toolbar needs argument > 0"));
                } else {
                        owner->getToolbar()->push(nth);
@@ -2308,7 +2359,7 @@ string LyXFunc::Dispatch(int ac,
        
        case LFUN_ADD_TO_TOOLBAR:
        {
-               if (lyxerr.debugging(Debug::TOOLBAR)) {
+               if (lyxerr.debugging(Debug::GUI)) {
                        lyxerr << "LFUN_ADD_TO_TOOLBAR:"
                                "argument = `" << argument << '\'' << endl;
                }
@@ -2316,7 +2367,6 @@ string LyXFunc::Dispatch(int ac,
                //lyxerr <<string("Argument: ") + argument);
                //lyxerr <<string("Tmp     : ") + tmp);
                if (tmp.empty()) {
-                       LyXBell();
                        setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
                } else {
                        owner->getToolbar()->add(argument, false);
index 178ad888337526791704706f1cd90ee35ab5c1bb..64273bf89b146c35c55a9143a07b553add34f64f 100644 (file)
@@ -1,8 +1,15 @@
-//  Generalized simple lexical analizer.
-//  It can be used for simple syntax parsers, like lyxrc,
-//  texclass and others to come.   [asierra30/03/96]
-//
-//   Copyright 1996 Lyx Team.
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *
+ *           Copyright 1996-2000 The LyX Team.
+ *
+ *   Generalized simple lexical analizer.
+ *   It can be used for simple syntax parsers, like lyxrc,
+ *   texclass and others to come.   [asierra30/03/96]
+ *
+ * ====================================================== */
 
 #include <config.h>
 
index 2a9c0778a1933b8c3a4572e131c38ff24896422d..16653062fb3695eb20be412446cc571f38724c7e 100644 (file)
@@ -8,6 +8,10 @@
  *
  * ====================================================== */
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include <config.h>
 
 #ifdef HAVE_XOPENIM
@@ -22,6 +26,7 @@
 #endif
 #include <clocale>
 
+#include "lyxlookup.h"
 #include "debug.h"
 #include "lyxrc.h"
 
index 582a13db35a144b1f93ddc5fc202f5f6ffc0d03d..5ed0e2e203dd23dfb2c03b561883b7c6ac89ccac 100644 (file)
    different input methods for different frames, but for now we can
    keep it as it is. */
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include <X11/Xlib.h>
 
 // Initialize the compose key handling
index 114dfcfc7cf64e67c09d78339b0be99a4d157b6e..03e8331c4d79ca79ef7e6cd66b00494828410883 100644 (file)
@@ -47,8 +47,7 @@ extern kb_keymap * toplevel_keymap;
 
 
 enum LyXRCTags {
-       RC_BEGINTOOLBAR = 1,
-       RC_FONT_ENCODING,
+       RC_FONT_ENCODING = 1,
        RC_PRINTER,
        RC_PRINT_COMMAND,
        RC_PRINTEVENPAGEFLAG,
@@ -98,6 +97,7 @@ enum LyXRCTags {
        RC_SERVERPIPE,
        RC_INPUT,
        RC_BINDFILE,
+       RC_UIFILE,
        RC_KBMAP,
        RC_KBMAP_PRIMARY,
        RC_KBMAP_SECONDARY,
@@ -169,7 +169,6 @@ keyword_item lyxrcTags[] = {
        { "\\auto_region_delete", RC_AUTOREGIONDELETE },
        { "\\autosave", RC_AUTOSAVE },
        { "\\backupdir_path", RC_BACKUPDIR_PATH },
-       { "\\begin_toolbar", RC_BEGINTOOLBAR },
        { "\\bind", RC_BIND },
        { "\\bind_file", RC_BINDFILE },
        { "\\build_command", RC_BUILD_COMMAND },
@@ -257,6 +256,7 @@ keyword_item lyxrcTags[] = {
        { "\\spell_command", RC_SPELL_COMMAND },
        { "\\tempdir_path", RC_TEMPDIRPATH },
        { "\\template_path", RC_TEMPLATEPATH },
+       { "\\ui_file", RC_UIFILE },
        { "\\use_alt_language", RC_USE_ALT_LANG },
        { "\\use_escape_chars", RC_USE_ESC_CHARS },
        { "\\use_gui", RC_USE_GUI },
@@ -282,6 +282,7 @@ LyXRC::LyXRC()
 
 
 void LyXRC::setDefaults() {
+       ui_file = "default";
        // Get printer from the environment. If fail, use default "",
        // assuming that everything is set up correctly.
        printer = GetEnv("PRINTER");
@@ -460,10 +461,10 @@ int LyXRC::read(string const & filename)
                        }
                        break;
                        
-               case RC_BEGINTOOLBAR:
-                       // this toolbar should be changed to be a completely
-                       // non gui toolbar. (Lgb)
-                       toolbardefaults.read(lexrc);
+               case RC_UIFILE: 
+                       if (lexrc.next()) {
+                               ui_file = lexrc.GetString();
+                       }
                        break;
                        
                case RC_KBMAP:
@@ -1145,8 +1146,8 @@ void LyXRC::output(ostream & os) const
                // bindings is not written to the preferences file.
        case RC_BINDFILE:
                // bind files are not done here.
-       case RC_BEGINTOOLBAR:
-               // Toolbar is not written here (yet).
+       case RC_UIFILE:
+               os << "\\ui_file \"" << ui_file << "\"\n";
        //case RC_SET_COLOR:
                // color bindings not written to preference file.
                // And we want to be warned about that. (Lgb)
index 3cf27a92435d4f315ba88e831665038e022b6e97..4844a92efe601b909f5c2e2c50a20d382a39ea59 100644 (file)
@@ -16,7 +16,6 @@
 #pragma interface
 #endif
 
-#include "ToolbarDefaults.h"
 #include "bufferparams.h"
 
 /// This contains the runtime configuration of LyX
@@ -38,10 +37,10 @@ public:
        ///
        int ReadBindFile(string const & name = "cua");
        ///
-       ToolbarDefaults toolbardefaults;
-       ///
        string bind_file;
        ///
+       string ui_file;
+       ///
        string printer;
        ///
        string print_command;
index f5b816e511806188a79a45a0280f0619779e6464..539253a3a6a40a7db2abd5a7ed9690f2bfbabe1c 100644 (file)
 
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include "lyxrow.h"
 
 
index 9da3170342946a616f99e1c04c768c614f563ee9..108f925f415faada6a2162effbf4e58750594220 100644 (file)
 #ifndef LYXROW_H
 #define LYXROW_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include "lyxparagraph.h"
 
 ///
index d555b26e981f0359963fa383817fd3280d8befb5..04a578affd791a636bf98aca837ba5c9bff223dd 100644 (file)
 
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include <unistd.h>
 #include <fcntl.h>
 #include <cstdlib>
index f09ab7e12793a7a2c2356610749e2a905824d039..8593ff6e6399493c60247cd662d71b4f622edbbf 100644 (file)
@@ -1,7 +1,21 @@
 // -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
 #ifndef SPELLCHECKER_H
 #define SPELLCHECKER_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 /* These functions are defined in lyx_cb.C */
 
 class BufferView;
index 5850d3a045a2ab01e450d817c302574485d321e9..a4b94004f5b4ae2f5c40dd9f477a6f2a45dfa2f9 100644 (file)
@@ -9,6 +9,10 @@
 
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 //#include "DebugStream.h"
 #include "debug.h"
 
index 795554fb5291fe5e3ed99f7f084da782d374a0b7..703bbdf4fbeb2b344e030137e1d64dc13054df13 100644 (file)
 #ifndef DEBUGSTREAM_H
 #define DEBUGSTREAM_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include "LOstream.h"
 
 #ifdef TEST_DEBUGSTREAM
index da836d2e8cc1dea0677df63948d265a370ca0e5d..1d2b9b88f4097f862db55551fe75c2cc4d7eb307 100644 (file)
 
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <cerrno>
index db826bdb4a3f7901c5ab1536ec9a4cf54450e680..47802465ba2f647fa664ffdb55b4f30cdc025a8e 100644 (file)
 #ifndef FILE_INFO_H
 #define FILE_INFO_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include <ctime>
 
 #include <unistd.h>
index 648cc4efbbffcac1d110f8c9ff427e78845a6580..3b9d1c379255f1d41056bc0c2d19f76b67a2991e 100644 (file)
 #include <config.h>
 #endif
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include "LSubstring.h"
 
 
index 9f5e17451f8816905315092448207c8bd38f619f..96d51d37867161dd30cb474154e3201069c99c2a 100644 (file)
@@ -28,6 +28,8 @@ libsupport_la_SOURCES = \
        LRegex.h \
        LSubstring.C \
        LSubstring.h \
+       StrPool.C \
+       StrPool.h \
        abort.C \
        block.h \
        chdir.C \
diff --git a/src/support/StrPool.C b/src/support/StrPool.C
new file mode 100644 (file)
index 0000000..17d9bab
--- /dev/null
@@ -0,0 +1,35 @@
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *      
+ *          Copyright 2000 Jean-Marc Lasgouttes
+ *
+ * ======================================================*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+#include "StrPool.h"
+
+StrPool::~StrPool()
+{
+        for (Pool::const_iterator cit = pool_.begin() ; 
+            cit != pool_.end() ; ++cit) {
+                delete[] (*cit);
+        }
+}
+
+char const * StrPool::add(string const & str)
+{
+       int s = str.length();
+        char * buf = new char [s + 1];
+        str.copy(buf, s);
+        buf[s] = '\0';
+        pool_.push_back(buf);
+        return buf;
+}
+
diff --git a/src/support/StrPool.h b/src/support/StrPool.h
new file mode 100644 (file)
index 0000000..826e985
--- /dev/null
@@ -0,0 +1,34 @@
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *      
+ *          Copyright 2000 Jean-Marc Lasgouttes
+ *
+ * ======================================================*/
+
+
+#ifndef STRPOOL_H
+#define STRPOOL_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "LString.h"
+#include <vector>
+
+class StrPool {
+public:
+        // delete all the strings that have been allocated by add()
+        ~StrPool();
+        // Make a copy of the string, and remember it in the pool
+        char const * add(string const & str);
+        
+private:
+       typedef std::vector<char const *> Pool;
+        Pool pool_;
+};
+
+#endif
index 3d2a1c00e8ecb55954103e2dd2da7dfb2eeb0d78..e0096dda2fb443283453943c243eecc74d90f453 100644 (file)
@@ -1,5 +1,19 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include <algorithm>
 
 #include <cctype>
@@ -141,7 +155,17 @@ double strToDbl(string const & str)
        }
 }
 
+/// 
+char lowercase(char c) 
+{ 
+       return tolower(c); 
+}
 
+/// 
+char uppercase(char c) 
+{ 
+       return toupper(c); 
+}
 
 string lowercase(string const & a)
 {
@@ -150,7 +174,7 @@ string lowercase(string const & a)
        string::iterator result = tmp.begin();
        for (string::iterator first = tmp.begin();
             first != tmp.end(); ++first, ++result) {
-               *result = tolower(*first);
+               *result = lowercase(*first);
        }
 //#else
 //     transform(tmp.begin(), tmp.end(), tmp.begin(), tolower);
@@ -166,7 +190,7 @@ string uppercase(string const & a)
        string::iterator result = tmp.begin();
        for (string::iterator first = tmp.begin();
             first != tmp.end(); ++first, ++result) {
-               *result = toupper(*first);
+               *result = uppercase(*first);
        }
 //#else
 //     transform(tmp.begin(), tmp.end(), tmp.begin(), toupper);
index 2fa07e6e1228daede4b399a8deca224514ed3f2f..9650f2d2206d4d0490e87c432c30712b9b3caf29 100644 (file)
@@ -8,6 +8,10 @@
 #ifndef LSTRINGS_H
 #define LSTRINGS_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include <cstring>
 #include <cctype>
 
@@ -54,6 +58,12 @@ bool isStrDbl(string const & str);
 ///
 double strToDbl(string const & str);
 
+/// 
+char lowercase(char c);
+
+/// 
+char uppercase(char c);
+
 ///
 string lowercase(string const &);
 
index 40671ec6a9f71587e9f7473fe4311f7b12a744c6..81abac3f94a4865997941cd939bd2b59fda70f2e 100644 (file)
@@ -1,5 +1,19 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include <cstdlib>
 #include "tex-accent.h"
 #include "commandtags.h"
index 1fc7e631790f2ce7a2783a240c7bdf3c527c5cd3..841829b056e3807c5e69b1a74e06b43325946851 100644 (file)
@@ -1,8 +1,21 @@
 // -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
 
 #ifndef TEX_ACCENT
 #define TEX_ACCENT
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include "commandtags.h"
 
 /* the names used by TeX and XWindows for deadkeys/accents are not the same
index 92371f029860c53719c06df8e85b8f48b792c050..1cb06a37c03e71486b1706abd816c287d8f33f00 100644 (file)
@@ -1,4 +1,19 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
 #include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include "tex-strings.h"
 
 // this file should perhaps be split into even smaller parts
index 2ca62772fecac256ca5c4ad123a87a275953464c..24e888d87369e50b3833b3ca117cde9a1156a271 100644 (file)
@@ -1,8 +1,21 @@
 // -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
 
 #ifndef TEX_STRINGS
 #define TEX_STRINGS
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 // this file should perhaps be split into even smaler parts
 
 ///
diff --git a/src/toolbar.C b/src/toolbar.C
deleted file mode 100644 (file)
index 29f9cec..0000000
+++ /dev/null
@@ -1,472 +0,0 @@
-/* This file is part of
- * ====================================================== 
- * 
- *           LyX, The Document Processor
- *
- *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 The LyX Team.
- *
- *           This file is Copyright 1996-1998
- *           Lars Gullik Bjønnes
- *
- * ====================================================== */
-
-//  Added pseudo-action handling, asierra 180296
-
-#include <config.h>
-
-#ifdef __GNUG__
-#pragma implementation "toolbar.h"
-#endif
-
-#include "lyx_main.h"
-#include "lyx_gui_misc.h"
-#include "lyx.h"
-#include "toolbar.h"
-#include "lyxfunc.h"
-#include "lyxlex.h"
-#include "debug.h"
-#include "combox.h"
-#include "LyXView.h"
-#include "LyXAction.h"
-#include "support/lstrings.h"
-#include "support/filetools.h"
-#include "lyxrc.h"
-
-using std::endl;
-
-// this one is not "C" because combox callbacks are really C++ %-|
-extern void LayoutsCB(int, void *);
-extern char const ** get_pixmap_from_symbol(char const * arg, int, int);
-extern LyXAction lyxaction;
-
-
-Toolbar::toolbarItem::toolbarItem()
-{
-       action = LFUN_NOACTION;
-       icon = 0;
-}
-
-
-void Toolbar::toolbarItem::clean()
-{
-       if (icon) {
-               fl_delete_object(icon);
-               fl_free_object(icon);
-               icon = 0;
-       }
-}
-
-
-Toolbar::toolbarItem::~toolbarItem()
-{
-       clean();
-}
-
-
-Toolbar::toolbarItem &
-Toolbar::toolbarItem::operator=(Toolbar::toolbarItem const & ti)
-{
-       // do we have to check icon and IsBitmap too?
-       action = ti.action;
-       icon = 0; // locally we need to get the icon anew
-       
-       return *this;
-}
-
-
-Toolbar::Toolbar(LyXView * o, int x, int y)
-       : owner(o), sxpos(x), sypos(y)
-{
-       combox = 0;
-#if FL_REVISION < 89
-       bubble_timer = 0;
-#endif
-       reset();
-
-       // extracts the default toolbar actions from LyXRC
-       for (ToolbarDefaults::const_iterator cit =
-                    lyxrc.toolbardefaults.begin();
-            cit != lyxrc.toolbardefaults.end(); ++cit) {
-               add((*cit));
-               lyxerr[Debug::TOOLBAR] << "tool action: "
-                                      << (*cit) << endl;
-       }
-}
-
-
-#if FL_REVISION < 89
-// timer-cb for bubble-help (Matthias)
-void Toolbar::BubbleTimerCB(FL_OBJECT *, long data)
-{
-       FL_OBJECT * ob = reinterpret_cast<FL_OBJECT*>(data);
-       // The trick we use to get the help text is to read the
-       // argument of the callback that has been registered for
-       // ToolBarCB.  (JMarc)
-       string help = lyxaction.helpText(ob->argument);
-       fl_show_oneliner(help.c_str(), ob->form->x + ob->x,
-                        ob->form->y + ob->y + ob->h);
-}
-
-
-extern "C" void C_Toolbar_BubbleTimerCB(FL_OBJECT * ob, long data)
-{
-       Toolbar::BubbleTimerCB(ob, data);
-}
-
-
-// post_handler for bubble-help (Matthias)
-int Toolbar::BubblePost(FL_OBJECT *ob, int event,
-                       FL_Coord /*mx*/, FL_Coord /*my*/,
-                       int /*key*/, void */*xev*/)
-{
-       Toolbar * t = reinterpret_cast<Toolbar*>(ob->u_vdata);
-       
-       // We do not test for empty help here, since this can never happen
-       if(event == FL_ENTER){
-               fl_set_object_callback(t->bubble_timer,
-                                      C_Toolbar_BubbleTimerCB,
-                                      reinterpret_cast<long>(ob));
-               fl_set_timer(t->bubble_timer, 1);
-       }
-       else if(event != FL_MOTION){
-               fl_set_timer(t->bubble_timer, 0);
-               fl_hide_oneliner();
-       }
-       return 0;
-}
-
-
-extern "C" int C_Toolbar_BubblePost(FL_OBJECT * ob, int event,
-                                   FL_Coord /*mx*/, FL_Coord /*my*/, 
-                                   int key, void * xev)
-{
-       return Toolbar::BubblePost(ob, event, 0, 0, key, xev);
-}
-#endif
-
-
-void Toolbar::activate()
-{
-       ToolbarList::const_iterator p = toollist.begin();
-       for (; p != toollist.end(); ++p) {
-               if (p->icon) {
-                       fl_activate_object(p->icon);
-               }
-       }
-}
-
-
-void Toolbar::deactivate()
-{
-       ToolbarList::const_iterator p = toollist.begin();
-       for (; p != toollist.end(); ++p) {
-               if (p->icon) {
-                       fl_deactivate_object(p->icon);
-               }
-       }
-}
-
-void Toolbar::update()
-{
-       ToolbarList::const_iterator p = toollist.begin();
-       for (; p != toollist.end(); ++p) {
-               if (p->icon) {
-                       int status = owner->getLyXFunc()->getStatus(p->action);
-                       if (status & LyXFunc::ToggleOn) {
-                               // I'd like to use a different color
-                               // here, but then the problem is to
-                               // know how to use transparency with
-                               // Xpm library. It seems pretty
-                               // complicated to me (JMarc)
-                               fl_set_object_color(p->icon, FL_LEFT_BCOL, FL_BLUE);
-                               fl_set_object_boxtype(p->icon, FL_DOWN_BOX);
-                       } else {
-                               fl_set_object_color(p->icon, FL_MCOL, FL_BLUE);
-                               fl_set_object_boxtype(p->icon, FL_UP_BOX);
-                       }
-
-                       if (status & LyXFunc::Disabled) {
-                               // Is there a way here to specify a
-                               // mask in order to show that the
-                               // button is disabled? (JMarc)
-                               fl_deactivate_object(p->icon);
-                       }
-                       else
-                               fl_activate_object(p->icon);
-               }
-       }
-}
-
-
-void Toolbar::ToolbarCB(FL_OBJECT * ob, long ac)
-{
-       Toolbar * t = static_cast<Toolbar*>(ob->u_vdata);
-       
-       string res = t->owner->getLyXFunc()->Dispatch(int(ac));
-       if(!res.empty())
-               lyxerr[Debug::TOOLBAR] << res << endl;
-}
-
-
-extern "C" void C_Toolbar_ToolbarCB(FL_OBJECT * ob, long data)
-{
-       Toolbar::ToolbarCB(ob, data);
-}
-
-
-int Toolbar::get_toolbar_func(string const & func)
-{
-       int action = lyxaction.LookupFunc(func.c_str());
-       if (action == -1) {
-               if (func == "separator"){
-                       action = TOOL_SEPARATOR;
-               } else if (func == "layouts"){
-                        action = TOOL_LAYOUTS;
-                } else action = 0;
-       }
-       return action;
-}
-
-static
-void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) {
-       string name, arg, xpm_name;
-       kb_action act;
-
-       if (lyxaction.isPseudoAction(action)) {
-               lyxerr[Debug::TOOLBAR] << "Pseudo action " << action << endl;
-
-               act = lyxaction.retrieveActionArg(action, arg);
-               name = lyxaction.getActionName(act);
-               xpm_name = subst(name + ' ' + arg, ' ','_');
-       } else {
-               act = (kb_action)action;
-               name = lyxaction.getActionName(action);
-               xpm_name = name;
-       }
-
-       lyxerr[Debug::TOOLBAR] << "Icon name for action " << action
-                              << " is `" << xpm_name << "'" << endl;
-       
-       string fullname = LibFileSearch("images", xpm_name, "xpm");
-
-       if (!fullname.empty()) {
-               lyxerr[Debug::TOOLBAR] << "Full icon name is `" 
-                                      << fullname << "'" << endl;
-               fl_set_pixmapbutton_file(obj, fullname.c_str());
-               return;
-       }
-
-       if (act == LFUN_INSERT_MATH && !arg.empty()) {
-               lyxerr[Debug::TOOLBAR] << "Using mathed-provided icon" << endl;
-               char const ** pixmap = get_pixmap_from_symbol(arg.c_str(),
-                                                       buttonwidth,
-                                                       height);
-               fl_set_pixmapbutton_data(obj, const_cast<char **>(pixmap));
-               return;
-       }
-       
-       lyxerr << "Unable to find icon `" << xpm_name << "'" << endl;
-       fullname = LibFileSearch("images", "unknown", "xpm");
-       if (!fullname.empty()) {
-               lyxerr[Debug::TOOLBAR] << "Using default `unknown' icon" 
-                                      << endl;
-               fl_set_pixmapbutton_file(obj, fullname.c_str());
-       }
-}
-
-void Toolbar::set(bool doingmain)
-{
-       // we shouldn't set if we have not cleaned
-       if (!cleaned) return;
-       
-       FL_OBJECT * obj;
-       
-       if (!doingmain) {
-               fl_freeze_form(owner->getForm());
-               fl_addto_form(owner->getForm());
-       }
-
-#if FL_REVISION < 89
-       // add the time if it don't exist
-       if (bubble_timer == 0)
-               bubble_timer = fl_add_timer(FL_HIDDEN_TIMER,
-                                           xpos, ypos, 0, 0, "Timer");
-#endif
-       
-       ToolbarList::iterator item = toollist.begin();
-       for (; item != toollist.end(); ++item) {
-               switch(item->action){
-               case TOOL_SEPARATOR:
-                       xpos += sepspace;
-                       break;
-               case TOOL_LAYOUTS:
-                       xpos += standardspacing;
-                       if (!combox)
-                               combox = new Combox(FL_COMBOX_DROPLIST);
-                       combox->add(xpos, ypos, 135, height, 400);
-                       combox->setcallback(LayoutsCB);
-                       combox->resize(FL_RESIZE_ALL);
-                       combox->gravity(NorthWestGravity, NorthWestGravity);
-                       xpos += 135;
-                       break;
-               default:
-                       xpos += standardspacing;
-                       item->icon = obj = 
-                               fl_add_pixmapbutton(FL_NORMAL_BUTTON,
-                                                   xpos, ypos,
-                                                   buttonwidth,
-                                                   height, "");
-                       fl_set_object_resize(obj, FL_RESIZE_ALL);
-                       fl_set_object_gravity(obj,
-                                             NorthWestGravity,
-                                             NorthWestGravity);
-                       fl_set_object_callback(obj, C_Toolbar_ToolbarCB,
-                                              static_cast<long>(item->action));
-                       // Remove the blue feedback rectangle
-                       fl_set_pixmapbutton_focus_outline(obj, 0);
-
-                       // Set the tooltip
-#if FL_REVISION >= 89
-                       string help = lyxaction.helpText(item->action);
-                       fl_set_object_helper(obj, help.c_str());        
-#else
-                       fl_set_object_posthandler(obj, C_Toolbar_BubblePost);
-#endif
-
-                       // The toolbar that this object belongs too.
-                       obj->u_vdata = this;
-
-                       setPixmap(obj, item->action, buttonwidth, height);
-                       // we must remember to update the positions
-                       xpos += buttonwidth;
-                       // ypos is constant
-                       /* Here will come a check to see if the new
-                        * pos is within the bounds of the main frame,
-                        * and perhaps wrap the toolbar if not.
-                        */
-                       break;
-               }
-       }
-
-       if (!doingmain) {
-               fl_end_form();
-               fl_unfreeze_form(owner->getForm());
-               // Should be safe to do this here.
-               owner->updateLayoutChoice();
-       }
-
-       // set the state of the icons
-       //update();
-
-       cleaned = false;
-}
-
-
-void Toolbar::add(int action, bool doclean)
-{
-       if (doclean && !cleaned) clean();
-
-       // this is what we do if we want to add to an existing
-       // toolbar.
-       if (!doclean && owner) {
-               // first "hide" the toolbar buttons. This is not a real hide
-               // actually it deletes and frees the button altogether.
-               lyxerr << "Toolbar::add: \"hide\" the toolbar buttons." 
-                      << endl;
-
-               lightReset();
-               
-               fl_freeze_form(owner->getForm());
-
-               ToolbarList::iterator p = toollist.begin();
-               for (; p != toollist.end(); ++p) {
-                       p->clean();
-               }
-
-               if (combox) {
-                       delete combox;
-                       combox = 0;
-               }
-               fl_unfreeze_form(owner->getForm());
-               cleaned = true; // this is not completely true, but OK anyway
-       }
-       
-       // there exist some special actions not part of
-       // kb_action: SEPARATOR, LAYOUTS
-
-       toolbarItem newItem;
-       newItem.action = action;
-       toollist.push_back(newItem);
-}
-
-
-void Toolbar::clean()
-{
-       //reset(); // I do not understand what this reset() is, anyway
-
-       //now delete all the objects..
-       if (owner)
-               fl_freeze_form(owner->getForm());
-
-       // G++ vector does not have clear defined
-       //toollist.clear();
-       toollist.erase(toollist.begin(), toollist.end());
-
-       lyxerr[Debug::TOOLBAR] << "Combox: " << combox << endl;
-       if (combox) {
-               delete combox;
-               combox = 0;
-       }
-
-       if (owner)
-               fl_unfreeze_form(owner->getForm());
-       lyxerr[Debug::TOOLBAR] << "toolbar cleaned" << endl;
-       cleaned = true;
-}
-
-
-void Toolbar::push(int nth)
-{
-       lyxerr[Debug::TOOLBAR] << "Toolbar::push: trying to trigger no `"
-                              << nth << '\'' << endl;
-       
-       if (nth <= 0 || nth >= int(toollist.size())) {
-               // item nth not found...
-               LyXBell();
-               return;
-       }
-
-       fl_trigger_object(toollist[nth - 1].icon);
-}
-
-
-void Toolbar::add(string const & func, bool doclean)
-{
-       int tf = lyxaction.LookupFunc(func);
-
-       if (tf == -1) {
-               lyxerr << "Toolbar::add: no LyX command called`"
-                      << func << "'exists!" << endl; 
-       } else {
-               add(tf, doclean);
-       }
-}
-
-
-void Toolbar::reset() 
-{
-       //toollist = 0; // what is this supposed to do?
-       cleaned = false;
-       lightReset();
-}
-
-//  void Toolbar::lightReset()
-//  {
-//     standardspacing = 2; // the usual space between items
-//     sepspace = 6; // extra space
-//     xpos = sxpos - standardspacing;
-//     ypos = sypos;
-//     buttonwidth = 30; // the standard button width
-//     height = 30; // the height of all items in the toolbar
-//  }
diff --git a/src/toolbar.h b/src/toolbar.h
deleted file mode 100644 (file)
index f766333..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-// -*- C++ -*-
-/* This file is part of
- * ======================================================
- * 
- *           LyX, The Document Processor
- *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 The LyX Team.
- *
- *           This file is Copyright 1996-2000
- *           Lars Gullik Bjønnes
- *
- * ====================================================== */
-
-#ifndef TOOLBAR_H
-#define TOOLBAR_H
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include <vector>
-#include FORMS_H_LOCATION
-#include "commandtags.h"
-#include "combox.h"
-
-class LyXView;
-
-/** The LyX toolbar class
-  This class {\em is} the LyX toolbar, and is not likely to be enhanced
-  further until we begin the move to Qt. We will probably have to make our
-  own QToolBar, at least until Troll Tech makes theirs.
-  */
-class Toolbar {
-public:
-       ///
-       Toolbar(LyXView * o, int x, int y);
-
-       ///
-       ~Toolbar() {
-               clean();
-       }
-       
-       ///
-       int get_toolbar_func(string const & func);
-       
-        /// The special toolbar actions
-       enum  TOOLBARITEMS {
-               /// adds space between buttons in the toolbar
-               TOOL_SEPARATOR = -1,
-               /// a special combox insead of a button
-               TOOL_LAYOUTS = -2,
-               /// begin a new line of button (not working)
-               TOOL_NEWLINE = -3
-       };
-
-       ///
-       Combox * combox;
-
-       /// (re)sets the toolbar
-       void set(bool doingmain = false);
-
-       /** this is to be the entry point to the toolbar
-         frame, where you can change the toolbar realtime. */
-       void edit();
-       /// add a new button to the toolbar.
-       void add(int , bool doclean = true);
-       /// name of func instead of kb_action
-       void add(string const & , bool doclean = true);
-       /// invokes the n'th icon in the toolbar
-       void push(int);
-       /// activates the toolbar
-        void activate();
-       /// deactivates the toolbar
-        void deactivate();
-       /// update the state of the icons
-       void update();
-       ///
-       static void ToolbarCB(FL_OBJECT *, long);
-
-#if FL_REVISION < 89
-       ///
-       static void BubbleTimerCB(FL_OBJECT *, long);
-       ///
-       static int BubblePost(FL_OBJECT * ob, int event,
-                             FL_Coord mx, FL_Coord my, int key, void * xev);
-#endif
-
-private:
-       ///
-       struct toolbarItem
-       {
-               ///
-               int action;
-               ///
-               FL_OBJECT * icon;
-               ///
-               toolbarItem();
-               ///
-               void clean();
-               ///
-               ~toolbarItem();
-               ///
-               toolbarItem & operator=(toolbarItem const & ti);
-       };
-
-       /// typedef to simplify things
-       typedef std::vector<toolbarItem> ToolbarList;
-       /// The list containing all the buttons
-       ToolbarList toollist;
-       ///
-       LyXView * owner;
-#if FL_REVISION < 89
-       ///
-       FL_OBJECT * bubble_timer;
-#endif
-       /// Starting position
-       int sxpos, sypos;
-       ///
-       int xpos;
-       ///
-       int ypos;
-       ///
-       int buttonwidth;
-       ///
-       int height;
-       ///
-       int standardspacing;
-       ///
-       int sepspace;
-       ///
-       bool cleaned;
-
-       ///
-       char const ** getPixmap(kb_action, string const & arg = string());
-       /// removes all toolbar buttons from the toolbar.
-       void clean();
-
-       /** more...
-        */
-       void reset();
-
-       /** more...
-        */
-       void lightReset() {
-               standardspacing = 2; // the usual space between items
-               sepspace = 6; // extra space
-               xpos = sxpos - standardspacing;
-               ypos = sypos;
-               buttonwidth = 30; // the standard button width
-               height = 30; // the height of all items in the toolbar
-       }
-};
-#endif
index 8f7562376d4d2c18a3e3081760aa70f0bce0271e..eff168456998a071e60e1199d47ef70c8a00833c 100644 (file)
@@ -1,3 +1,19 @@
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include <config.h>
 
 #include "tracer.h"
index 9521e5104d4a3ccd92a28183309e7669f6de9754..a467efb56896ca22d8831d741dc1f94f0128bb55 100644 (file)
@@ -1,7 +1,21 @@
 // -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ * 
+ *           LyX, The Document Processor
+ *        
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
 #ifndef TRACER_H
 #define TRACER_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include "debug.h"
 #include "LString.h"