+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,
* 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.
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
\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"
\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"
#\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 ########################################################
--- /dev/null
+# 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
+
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
#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;
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 &);
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();
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();
{ 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"),
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 },
-// -*- C++ -*-
/* This file is part of
* ======================================================
*
#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()
LyXView::~LyXView()
{
+#ifdef NEW_MENUBAR
+ delete menubar;
+#else
delete menus;
+#endif
delete toolbar;
delete bufferview;
delete minibuffer;
return toolbar;
}
+void LyXView::setLayout(int layout)
+{
+ toolbar->setLayout(layout);
+}
LyXFunc * LyXView::getLyXFunc() 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
//
// 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);
invalidateLayoutChoice();
updateLayoutChoice();
UpdateDocumentClassChoice();
+#ifdef NEW_MENUBAR
+ updateMenubar();
+#endif
// Start autosave timer
if (lyxrc.autosave) {
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;
}
}
#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;
/// 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;
Toolbar * toolbar;
///
MiniBuffer * minibuffer;
+#ifdef NEW_MENUBAR
+ ///
+ Menubar * menubar;
+#else
///
Menus * menus;
+#endif
///
Intl * intl;
///
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
LyXView.C \
LyXView.h \
Makefile.in \
+ MenuBackend.C \
+ MenuBackend.h \
Painter.C \
Painter.h \
PainterBase.C \
texrow.h \
text.C \
text2.C \
- toolbar.C \
- toolbar.h \
tracer.C \
tracer.h \
trans.C \
--- /dev/null
+/* 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();
+}
--- /dev/null
+/* 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 */
+/* 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>
#ifndef SPACING_H
#define SPACING_H
+#ifdef __GNUG__
+#pragma interface
+#endif
+
#include <iosfwd>
#include "LString.h"
+/* 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
// -*- 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
+/* 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()
{
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);
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;
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);
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:
}
}
lex.popTable();
+ lex.next();
}
// -*- 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"
///
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;
///
Defaults defaults;
};
-#endif
+//The global instance
+extern ToolbarDefaults toolbardefaults;
+#endif
#include <config.h>
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
#include <stdlib.h>
#include "bmtable.h"
#include XPM_H_LOCATION
#ifndef BMTABLE_H
#define BMTABLE_H
+#ifdef __GNUG__
+#pragma interface
+#endif
+
#include FORMS_H_LOCATION
#if defined(__cplusplus)
int j;
int ltype = 0;
int ltype_depth = 0;
- int * actcell = 0;
+ int actcell = 0;
int actpos = 0;
#ifndef NEW_TABULAR
int h;
+/* 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"
// -*- 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;
LFUN_TEX,
LFUN_FOOTMELT,
LFUN_MARGINMELT,
+ LFUN_SWITCHBUFFER,
LFUN_EMPH,
LFUN_BOLD,
LFUN_ROMAN,
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
+/* 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"
// -*- 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"
{ 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"},
// -*- 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"
///
KEY = (1 << 2), // 4
///
- TOOLBAR = (1 << 3), // 8
+ GUI = (1 << 3), // 8
///
PARSER = (1 << 4), // 16
///
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 |
#include <config.h>
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
#include "encoding.h"
Uchar tab_iso8859_1[256] = {
#ifndef ENCODING_H
#define ENCODING_H
+#ifdef __GNUG__
+#pragma interface
+#endif
+
#include "LString.h"
#include "lyxrc.h"
+/* 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"
// -*- 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"
+/* 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"
#ifndef LIASON_H
#define LIASON_H
+#ifdef __GNUG__
+#pragma interface
+#endif
+
class PrinterParams;
class Buffer;
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
--- /dev/null
+/* 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);
+}
--- /dev/null
+// -*- 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
--- /dev/null
+/* 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);
+ }
+}
+
+
--- /dev/null
+// -*- 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
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
--- /dev/null
+/* 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);
+
+}
--- /dev/null
+// -*- 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
--- /dev/null
+/* 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;
+}
--- /dev/null
+// -*- 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
#include FORMS_H_LOCATION
#include "insetbib.h"
-#include "combox.h"
#include "buffer.h"
#include "debug.h"
#include "lyx_gui_misc.h"
#include "CutAndPaste.h"
#include "font.h"
#include "minibuffer.h"
-#include "toolbar.h"
#include "LColor.h"
#include "support/textutils.h"
#include "support/LAssert.h"
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);
}
}
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());
}
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);
}
}
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);
}
}
+/* 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"
// -*- 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"
#include <config.h>
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
#include <cerrno>
#include "lyx_gui_misc.h"
#include "BufferView.h"
#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 */
#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;
}
}
-
-
// Initialization of LyX (reads lyxrc and more)
lyxerr[Debug::INIT] << "Initializing LyX::init..." << endl;
init(argc, argv, gui);
if (!lyxrc.hasBindFile)
lyxrc.ReadBindFile();
+ // Read menus
+ ReadUIFile(lyxrc.ui_file);
// Bind the X dead keys to the corresponding LyX functions if
// necessary.
}
+// 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)
{
#ifndef LYX_MAIN_H
#define LYX_MAIN_H
+#ifdef __GNUG__
+#pragma interface
+#endif
+
#include <csignal>
#include "LString.h"
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[]);
//@}
-/*
- 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}
// -*- 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)
#include <config.h>
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
#include "lyxcursor.h"
#ifndef LYXCURSOR_H
#define LYXCURSOR_H
+#ifdef __GNUG__
+#pragma interface
+#endif
+
#include "lyxparagraph.h"
struct Row;
#pragma implementation
#endif
+#include "version.h"
#include "lyxlookup.h"
#include "kbmap.h"
#include "lyxfunc.h"
#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"
#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;
// no
setErrorMessage(N_("Document is read-only"));
flag |= LyXFunc::Disabled;
+ return flag;
}
} else {
// no
}
}
- 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";
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;
}
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:
{
// --- buffers ----------------------------------------
+ case LFUN_SWITCHBUFFER:
+ owner->view()->buffer(bufferlist.getBuffer(argument));
+ break;
+
+
case LFUN_FILE_INSERT:
{
MenuInsertLyXFile(argument);
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();
}
break;
case LFUN_DROP_LAYOUTS_CHOICE:
- owner->getToolbar()->combox->Show();
+ owner->getToolbar()->openLayoutList();
break;
case LFUN_LANGUAGE:
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:
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);
case LFUN_ADD_TO_TOOLBAR:
{
- if (lyxerr.debugging(Debug::TOOLBAR)) {
+ if (lyxerr.debugging(Debug::GUI)) {
lyxerr << "LFUN_ADD_TO_TOOLBAR:"
"argument = `" << argument << '\'' << endl;
}
//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);
-// 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>
*
* ====================================================== */
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
#include <config.h>
#ifdef HAVE_XOPENIM
#endif
#include <clocale>
+#include "lyxlookup.h"
#include "debug.h"
#include "lyxrc.h"
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
enum LyXRCTags {
- RC_BEGINTOOLBAR = 1,
- RC_FONT_ENCODING,
+ RC_FONT_ENCODING = 1,
RC_PRINTER,
RC_PRINT_COMMAND,
RC_PRINTEVENPAGEFLAG,
RC_SERVERPIPE,
RC_INPUT,
RC_BINDFILE,
+ RC_UIFILE,
RC_KBMAP,
RC_KBMAP_PRIMARY,
RC_KBMAP_SECONDARY,
{ "\\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 },
{ "\\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 },
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");
}
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:
// 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)
#pragma interface
#endif
-#include "ToolbarDefaults.h"
#include "bufferparams.h"
/// This contains the runtime configuration of LyX
///
int ReadBindFile(string const & name = "cua");
///
- ToolbarDefaults toolbardefaults;
- ///
string bind_file;
///
+ string ui_file;
+ ///
string printer;
///
string print_command;
#include <config.h>
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
#include "lyxrow.h"
#ifndef LYXROW_H
#define LYXROW_H
+#ifdef __GNUG__
+#pragma interface
+#endif
+
#include "lyxparagraph.h"
///
#include <config.h>
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
#include <unistd.h>
#include <fcntl.h>
#include <cstdlib>
// -*- 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;
#include <config.h>
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
//#include "DebugStream.h"
#include "debug.h"
#ifndef DEBUGSTREAM_H
#define DEBUGSTREAM_H
+#ifdef __GNUG__
+#pragma interface
+#endif
+
#include "LOstream.h"
#ifdef TEST_DEBUGSTREAM
#include <config.h>
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
#include <sys/types.h>
#include <sys/stat.h>
#include <cerrno>
#ifndef FILE_INFO_H
#define FILE_INFO_H
+#ifdef __GNUG__
+#pragma interface
+#endif
+
#include <ctime>
#include <unistd.h>
#include <config.h>
#endif
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
#include "LSubstring.h"
LRegex.h \
LSubstring.C \
LSubstring.h \
+ StrPool.C \
+ StrPool.h \
abort.C \
block.h \
chdir.C \
--- /dev/null
+// -*- 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;
+}
+
--- /dev/null
+// -*- 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
+/* 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>
}
}
+///
+char lowercase(char c)
+{
+ return tolower(c);
+}
+///
+char uppercase(char c)
+{
+ return toupper(c);
+}
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);
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);
#ifndef LSTRINGS_H
#define LSTRINGS_H
+#ifdef __GNUG__
+#pragma interface
+#endif
+
#include <cstring>
#include <cctype>
///
double strToDbl(string const & str);
+///
+char lowercase(char c);
+
+///
+char uppercase(char c);
+
///
string lowercase(string const &);
+/* 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"
// -*- 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
+/* 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
// -*- 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
///
+++ /dev/null
-/* 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
-// }
+++ /dev/null
-// -*- 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
+/* 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"
// -*- 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"