GUI-indep toolbar and menus mostly work !

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@913 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2000-07-24 13:53:19 +00:00
parent 69c9c901ac
commit 4b2a999762
84 changed files with 2608 additions and 341 deletions

View File

@ -1,3 +1,79 @@
2000-07-24 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/buffer.C (writeFileAscii): Define actcell as an int instead
of int*.
2000-07-23 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* Lot of files: add pragma interface/implementation.
* src/lyx_main.C (ReadUFile): new method. Read the UI file.
* lib/ui/default.ui: new file (ans new directory). Contains the
default menu and toolbar.
* src/lyxrc.[Ch]: new variable ui_file. Move toolbardefaults to
global space. Toolbars are now read (as menus) in ui files.
* src/debug.C: change Debug::TOOLBAR to Debug::GUI.
* src/lyxfunc.C (getStatus): do not exit immediately if a command
is disabled because the document is read-only. We want to have the
toggle state of the function anyway.
(getStatus): add code for LFUN_VC* functions (mimicking what is
done in old-style menus)
* src/lyxfunc.C (Dispatch): news functions LFUN_SWITCHBUFFER,
LFUN_HELP_CREDITS, LFUN_HELP_VERSION, LFUN_HELP_OPEN.
* src/LyXView.[Ch]: add code for the NEW_MENUBAR define.
* src/BufferView_pimpl.C: ditto.
* src/lyxfunc.C: ditto.
* src/LyXView.h: add a define NEW_MENUBAR (commented out by
default). This replaces old-style menus by new ones.
* src/MenuBackend.[Ch]: new classes MenuBackend, Menu and
MenuItem. Contain the data structure of a menu.
* src/insets/insettext.C: use LyXView::setLayout instead of
accessing directly the toolbar combox.
* src/lyxfunc.C (Dispatch): ditto.
* src/LyXView.C (setLayout): new method, which just calls
Toolbar::setLayout().
(updateLayoutChoice): move part of this method in Toolbar.
* src/toolbar.[Ch]: removed.
* src/frontend/xforms/Toolbar_pimpl.[Ch]: new files. The xforms
implementation the toolbar.
* src/frontend/Toolbar.[Ch]: new files. The abstract interface of
the toolbar. It might make sense to merge it with ToolbarDefaults
later.
(setLayout): new function.
(updateLayoutList): ditto.
(openLayoutList): ditto.
* src/frontend/xforms/Toolbar_pimpl.[Ch]: new files. Contain the
xforms implementation of the toolbar.
(get_toolbar_func): comment out, since I do not
know what it is good for.
* src/ToolbarDefaults.h: Add the ItemType enum.
* src/support/StrPool.[Ch]: new class. Acts as a reference holder
for a list of allocated C strings. Used in Menubar xforms
implementation to avoid memory leaks.
* src/support/lstrings.[Ch] (uppercase): new version taking and
returning a char.
(lowercase): ditto.
* lib/bind/xemacs.bind: remove bogus binding for lyx-quit.
* lib/bind/emacs.bind: ditto.
2000-07-21 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/toolbar.h: include commandtags.h instead of lyxfunc.h,
@ -23,7 +99,7 @@
* src/paragraph.C (SimpleTeXOnePar): NEW_INSETS: move some #ifdef
to correct place.
* src/buffer.C (parseSingleLyXformat2Token: NEW_INSETS: fix the
* src/buffer.C (parseSingleLyXformat2Token): NEW_INSETS: fix the
planemet in reading of old style floats, fix the \end_deeper
problem when reading old style floats.

View File

@ -17,17 +17,19 @@ LAYOUT = layouts/*.layout layouts/*.inc
LYXSCRIPTS = scripts/*
TEMPL = templates/*.lyx
TEXSUPPORT = tex/*.cls
UI = ui/*.ui
LIBINSTFILES = $(BIND) $(CLIPART) $(DOCINST) $(EXAMPLES) $(IMAGES) $(KBD) \
$(LAYOUT) $(TEMPL) $(TEXSUPPORT) $(LYXSCRIPTS)
$(LAYOUT) $(TEMPL) $(TEXSUPPORT) $(UI) $(LYXSCRIPTS)
LIBDISTFILES = $(BIND) $(CLIPART) $(DOCDIST) $(EXAMPLES) $(IMAGES) $(KBD) \
$(LAYOUT) $(TEMPL) $(TEXSUPPORT) $(LYXSCRIPTS)
$(LAYOUT) $(TEMPL) $(UI) $(TEXSUPPORT) $(LYXSCRIPTS)
pkgdata_DATA = lyxrc.example CREDITS chkconfig.ltx lyxrc.defaults \
textclass.lst packages.lst external_templates
LYXLIBDIRS = bind clipart doc examples images kbd layouts scripts templates tex
LYXLIBDIRS = bind clipart doc examples images kbd layouts scripts \
templates tex ui
EXTRA_DIST = CREDITS chkconfig.ltx configure.cmd lyxrc.example \
external_templates $(LYXLIBDIRS) build-listerrors

View File

@ -71,7 +71,6 @@
\bind "C-x a" "buffer-auto-save"
#\bind "C-x b" "buffer-previous"
\bind "C-x c" "lyx-quit"
\bind "C-x d" "buffer-new"
\bind "C-x g" "buffer-view-ps"
\bind "C-x k" "buffer-close"

View File

@ -74,7 +74,6 @@
\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 d" "buffer-new"
\bind "C-x g" "buffer-view-ps"
\bind "C-x k" "buffer-close"

View File

@ -267,56 +267,12 @@
#\set_color mathlines yellow
#
# TOOLBAR SECTION ########################################################
# UI 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
# 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 ########################################################

285
lib/ui/default.ui Normal file
View File

@ -0,0 +1,285 @@
# This is the default LyX user interface definition file. The syntax
# should be straightforward enough. The menubar "main_nobuffer" (if it
# exists) is used when there is no buffer open; otherwise, the menubar
# "main" is used.
Menuset
Menubar "main"
Submenu "File|F" "file"
Submenu "Edit|E" "edit"
Submenu "Layout|L" "layout"
Submenu "Insert|I" "insert"
Submenu "Math|M" "math"
Submenu "Options|O" "options"
Submenu "Documents|D" "documents"
Submenu "Help|H" "help"
End
Menubar "main_nobuffer"
Submenu "File|F" "file_nobuffer"
Submenu "Options|O" "options"
Submenu "Help|H" "help"
End
Menu "file"
Item "New...|N" "buffer-new"
Item "New from template|t" "buffer-new-template"
Item "Open...|O" "buffer-open"
Separator
Item "Close|C" "buffer-close"
Item "Save|S" "buffer-write"
Item "Save As|A" "buffer-write-as"
Item "Revert to saved|R" "buffer-reload"
Separator
Item "View dvi|d" "buffer-view"
Item "View Postscript|w" "buffer-view-ps"
Item "Update dvi|v" "buffer-typeset"
Item "Update Postscript|u" "buffer-typeset-ps"
Item "Build program|B" "build-program"
Separator
Item "Print...|P" "buffer-print"
Item "Fax...|F" "buffer-fax"
Submenu "Import|I" "import"
Submenu "Export|E" "export"
Separator
Item "Exit|x" "lyx-quit"
Separator
Lastfiles
End
Menu "file_nobuffer"
Item "New...|N" "buffer-new"
Item "New from template|t" "buffer-new-template"
Item "Open...|O" "buffer-open"
Separator
Submenu "Import|I" "import"
Separator
Item "Exit|x" "lyx-quit"
Separator
Lastfiles
End
Menu "import"
Item "LaTeX|L" "buffer-import latex"
Item "Ascii text as lines|A" "buffer-import ascii"
Item "Ascii text as paragraphs|p" "buffer-import ascii"
Item "Noweb|N" "buffer-import noweb"
End
Menu "export"
Item "LaTeX|L" "buffer-export latex"
Item "DVI|D" "buffer-export dvi"
Item "Postscript|P" "buffer-export postscript"
Item "Ascii|A" "buffer-export ascii"
Item "Custom...|C" "buffer-export custom"
End
Menu "edit"
Item "Undo|U" "undo"
Item "Redo|R" "redo"
Separator
Item "Cut|C" "cut"
Item "Copy|o" "copy"
Item "Paste|P" "paste"
Separator
Item "Find & Replace...|F" "find-replace"
Item "Go to Error|E" "error-next"
Item "Go to Note|N" "note-next"
Submenu "Floats & Insets|I" "floats"
Submenu "Table" "table"
Item "Spellchecker...|S" "spellchecker"
Item "Check TeX|h" "buffer-chktex"
Item "Table of Contents|b" "toc-view"
Separator
Submenu "Version control" "vc"
Separator
Item "View LaTeX log file|w" "latex-view-log"
Separator
Item "Paste primary selection as Lines|L" "primary-selection-paste"
Item "Paste primary selection as Paragraphs|g" "primary-selection-paste paragraph"
End
Menu "floats"
End
Menu "table"
End
Menu "vc"
Item "Register|R" "vc-register"
Item "Check In Changes|I" "vc-check-in"
Item "Check Out for Edit|O" "vc-check-out"
Item "Revert to last version|l" "vc-revert"
Item "Undo last check in|U" "vc-undo-last"
Item "Show History|H" "vc-history"
End
Menu "layout"
Item "Character...|C" "layout-character"
Item "Paragraph...|P" "layout-paragraph"
Item "Paper...|a" "layout-paper"
Item "Document...|D" "layout-document"
Item "Table...|T" "layout-table"
Item "Quotes...|Q" "layout-quotes"
Separator
Item "Emphasize Style|E" "font-emph"
Item "Noun Style|N" "font-noun"
Item "Bold Style|B" "font-bold"
Item "TeX Style|x" "tex-mode"
Item "Change environment depth|v" "depth-increment"
Item "LaTeX preamble|a" "layout-preamble"
Item "Start of Appendix|x" "appendix"
Separator
Item "Save layout as default|S" "layout-save-default"
End
Menu "insert"
Item "Figure...|F" "figure-insert"
Item "Table...|T" "table-insert"
Separator
Item "Include File...|I" "buffer-child-insert"
Submenu "Import ascii file|a" "insert_ascii"
Item "Insert LyX file|X" "file-insert"
Separator
Item "Footnote|F" "footnote-insert"
Item "Marginnote|M" "marginpar-insert"
Submenu "Floats|a" "floats"
Separator
Submenu "Lists & TOC|T" "insert_toc"
Separator
Submenu "Special character|S" "insert_special"
Separator
Item "Note...|N" "note-insert"
Item "Label...|L" "label-insert"
Item "Cross reference...|r" "reference-insert"
Item "Citation reference...|i" "citation-insert"
Item "Index entry...|d" "index-insert"
Item "Index entry of last word|w" "index-insert-last"
Item "URL...|U" "url-insert"
End
Menu "insert_ascii"
Item "As lines|l" "file-insert-ascii lines"
Item "As paragraphs|p" "file-insert-ascii paragraphs"
End
Menu "insert_floats"
Item "Figure float|F" "buffer-float-insert figure"
Item "Table float|T" "buffer-float-insert table"
Item "Wide figure float|W" "buffer-float-insert wide-fig"
Item "Wide table float|d" "buffer-float-insert wide-tab"
Separator
Item "Algorithm float|A" "buffer-float-insert algorithm"
End
Menu "insert_toc"
Item "Table of Contents|C" "toc-view"
Item "List of Figures|F" "lof-insert"
Item "List of Tables|T" "lot-insert"
Item "List of Algorithms|A" "loa-insert"
Item "Index List|I" "index-print"
Item "BibTeX reference|B" "bibtex-insert"
End
Menu "insert_special"
Item "HFill|H" "hfill-insert"
Item "Hyphenation point|p" "hyphenation-point-insert"
Item "Protected blank|b" "protected-space-insert"
Item "Linebreak|L" "break-line"
Item "Ellipsis|i" "dots-insert"
Item "End of sentence|E" "end-of-sentence-period-insert"
Item "Ordinary Quote|Q" "quote-insert"
End
Menu "math"
Item "Fraction|F" "math-insert frac"
Item "Square root|S" "math-insert sqrt"
Item "Exponent|E" "math-insert ^"
Item "Index|x" "math-insert -"
Item "Sum|u" "math-insert sum"
Item "Integral|I" "math-insert int"
Separator
Item "Math mode|M" "math-mode"
Item "Display|D" "math-display"
Separator
Item "Math Panel...|P" "math-panel"
End
Menu "options"
Item "Screen Fonts...|F" "screen-options"
Item "Spellchecker Options...|S" "spellchecker-options"
Item "Keyboard...|K" "keyboard-options"
Separator
Item "Reconfigure|R" "reconfigure"
Item "Preferences|P" "options-preferences"
End
Menu "documents"
Documents
End
Menu "help"
Item "Introduction|I" "help-open Intro"
Item "Tutorial|T" "help-open Tutorial"
Item "User's Guide|U" "help-open UserGuide"
Item "Extended Features|x" "help-open Extended"
Item "Customization|C" "help-open Customization"
Item "Reference Manual|R" "help-open Reference"
Item "FAQ|F" "help-open FAQ"
Item "Table of contents|a" "help-open TOC"
Item "Known Bugs|K" "help-open BUGS"
Item "LaTeX Configuration|L" "help-open LaTeXConfig"
Separator
Item "Copyright and Warranty...|o" "help-copyright"
Item "Credits...|e" "help-credits"
Item "Version...|V" "help-version"
End
End
# Setup your favorite Toolbar here:
# Only three commands are allowed inside the begin_toolbar and end_toolbar
# directives:
# Icon "<action> [<parameter>]" adds an icon to the toolbar performing
# "<action> <parameter>"
# Examples:
# Icon "font-size small"
# Icon set-emph
#
# Layouts adds the layouts combo-box to the toolbar
#
# Separator adds some spacing to the toolbar
#
# The icons are found in the lib/image direcory under the name
# action.xpm or action_parameter.xpm.
#
# All other lyx commands will get a "unknown" icon.
#
# This is the default toolbar:
Toolbar
Layouts
Icon "buffer-open"
Icon "buffer-write"
Icon "buffer-print"
Separator
Icon "cut"
Icon "copy"
Icon "paste"
Separator
Icon "font-emph"
Icon "font-noun"
Icon "font-free"
Separator
Icon "footnote-insert"
Icon "marginpar-insert"
Icon "depth-next"
Separator
Icon "tex-mode"
Icon "math-mode"
Separator
Icon "figure-insert"
Icon "table-insert"
End

View File

@ -35,6 +35,7 @@ src/frontends/xforms/FormPrint.C
src/frontends/xforms/form_print.C
src/frontends/xforms/FormTabular.C
src/frontends/xforms/form_tabular.C
src/frontends/xforms/Menubar_pimpl.C
src/gettext.h
src/insets/figinset.C
src/insets/form_graphics.C

View File

@ -21,12 +21,14 @@
#include "TextCache.h"
#include "bufferlist.h"
#include "insets/insetbib.h"
#include "menus.h"
#include "lyx_gui_misc.h"
#include "lyxrc.h"
#include "intl.h"
#include "support/LAssert.h"
#include "frontends/Dialogs.h"
#ifndef NEW_MENUBAR
# include "menus.h"
#endif
#ifdef SIGC_CXX_NAMESPACES
using SigC::slot;
@ -44,6 +46,7 @@ bool selection_possible = false;
extern BufferList bufferlist;
extern char ascii_type;
extern "C" void TimerCB(FL_OBJECT *, long);
extern void sigchldhandler(pid_t pid, int * status);
extern int bibitemMaxWidth(BufferView *, LyXFont const &);
@ -130,7 +133,6 @@ void BufferView::Pimpl::buffer(Buffer * b)
if (buffer_) {
lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
buffer_->addUser(bv_);
owner_->getMenus()->showMenus();
// If we don't have a text object for this, we make one
if (bv_->text == 0) {
resizeCurrentBuffer();
@ -139,12 +141,21 @@ void BufferView::Pimpl::buffer(Buffer * b)
updateScrollbar();
}
bv_->text->first = screen_->TopCursorVisible(bv_->text);
#ifdef NEW_MENUBAR
owner_->updateMenubar();
#else
owner_->getMenus()->showMenus();
#endif
redraw();
owner_->getDialogs()->updateBufferDependent();
bv_->insetWakeup();
} else {
lyxerr[Debug::INFO] << " No Buffer!" << endl;
#ifdef NEW_MENUBAR
owner_->updateMenubar();
#else
owner_->getMenus()->hideMenus();
#endif
updateScrollbar();
workarea_->redraw();

View File

@ -139,6 +139,8 @@ void LyXAction::init()
{ LFUN_MENUPRINT, "buffer-print", N_("Print"), ReadOnly },
{ LFUN_MENURELOAD, "buffer-reload",
N_("Revert to saved"), ReadOnly },
{ LFUN_SWITCHBUFFER, "buffer-switch",
N_("Switch to an open document"), ReadOnly },
{ LFUN_READ_ONLY_TOGGLE, "buffer-toggle-read-only",
N_("Toggle read-only"), ReadOnly },
{ LFUN_RUNLATEX, "buffer-typeset", N_("Update DVI"),
@ -226,6 +228,13 @@ void LyXAction::init()
N_("Insert horizontal fill"), Noop },
{ LFUN_HELP_COPYRIGHT, "help-copyright",
N_("Display copyright information"), NoBuffer },
{ LFUN_HELP_CREDITS, "help-credits",
N_("Show the list of people who helped writing LyX"),
NoBuffer},
{ LFUN_HELP_OPEN, "help-open", N_("Open a Help file"),
NoBuffer|Argument},
{ LFUN_HELP_VERSION, "help-version",
N_("Show the actual LyX version"), NoBuffer},
{ LFUN_HTMLURL, "html-insert", "", Noop },
{ LFUN_HYPHENATION, "hyphenation-point-insert",
N_("Insert hyphenation point"), Noop },

View File

@ -1,4 +1,3 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
@ -21,7 +20,6 @@
#include "LyXView.h"
#include "lyx_main.h"
#include "lyxlookup.h"
#include "toolbar.h"
#include "minibuffer.h"
#include "lyxfunc.h"
#include "debug.h"
@ -32,8 +30,15 @@
#include "layout.h"
#include "lyxtext.h"
#include "buffer.h"
#include "menus.h"
#include "frontends/Dialogs.h"
#include "frontends/Toolbar.h"
#ifdef NEW_MENUBAR
# include "frontends/Menubar.h"
# include "MenuBackend.h"
#else
# include "menus.h"
#endif
#include "ToolbarDefaults.h"
#include "lyx_gui_misc.h" // [update,Close]AllBufferRelatedDialogs
#include "bufferview_funcs.h" // CurrentState()
@ -77,7 +82,11 @@ LyXView::LyXView(int width, int height)
LyXView::~LyXView()
{
#ifdef NEW_MENUBAR
delete menubar;
#else
delete menus;
#endif
delete toolbar;
delete bufferview;
delete minibuffer;
@ -119,6 +128,10 @@ Toolbar * LyXView::getToolbar() const
return toolbar;
}
void LyXView::setLayout(int layout)
{
toolbar->setLayout(layout);
}
LyXFunc * LyXView::getLyXFunc() const
{
@ -132,10 +145,28 @@ MiniBuffer * LyXView::getMiniBuffer() const
}
#ifdef NEW_MENUBAR
Menubar * LyXView::getMenubar() const
{
return menubar;
}
void LyXView::updateMenubar()
{
if ((!view() || !view()->buffer())
&& menubackend.hasMenu("main_nobuffer"))
menubar->set("main_nobuffer");
else
menubar->set("main");
}
#else
Menus * LyXView::getMenus() const
{
return menus;
}
#endif
Intl * LyXView::getIntl() const
@ -212,14 +243,17 @@ void LyXView::create_form_form_main(int width, int height)
//
// THE MENUBAR
//
#ifdef NEW_MENUBAR
menubar = new Menubar(this, menubackend);
#else
menus = new Menus(this, air);
#endif
//
// TOOLBAR
//
toolbar = new Toolbar(this, air, 30 + air + bw);
toolbar = new Toolbar(this, air, 30 + air + bw, toolbardefaults);
// Setup the toolbar
toolbar->set(true);
@ -284,6 +318,9 @@ void LyXView::init()
invalidateLayoutChoice();
updateLayoutChoice();
UpdateDocumentClassChoice();
#ifdef NEW_MENUBAR
updateMenubar();
#endif
// Start autosave timer
if (lyxrc.autosave) {
@ -307,41 +344,28 @@ void LyXView::invalidateLayoutChoice()
void LyXView::updateLayoutChoice()
{
// Update the layout display
if (!toolbar->combox) return;
// This has a side-effect that the layouts are not showed when no
// document is loaded.
if (bufferview == 0 || bufferview->buffer() == 0) {
toolbar->combox->clear();
toolbar->combox->Redraw();
if (!view() || !view()->buffer()) {
toolbar->clearLayoutList();
return;
}
// If textclass is different, we need to update the list
if (toolbar->combox->empty() ||
(last_textclass != int(buffer()->params.textclass))) {
toolbar->combox->clear();
LyXTextClass const & tc =
textclasslist.TextClass(buffer()->params.textclass);
for (LyXTextClass::const_iterator cit = tc.begin();
cit != tc.end(); ++cit) {
if ((*cit).obsoleted_by().empty())
toolbar->combox->addline((*cit).name().c_str());
else
toolbar->combox->addline(("@N" + (*cit).name()).c_str());
}
// Update the layout display
if (last_textclass != int(buffer()->params.textclass)) {
toolbar->updateLayoutList(true);
last_textclass = int(buffer()->params.textclass);
current_layout = 0;
}
// we need to do this.
toolbar->combox->Redraw();
} else
toolbar->updateLayoutList(false);
LyXTextClass::size_type layout =
bufferview->text->cursor.par()->GetLayout();
if (layout != current_layout){
toolbar->combox->select(layout + 1);
toolbar->setLayout(layout);
current_layout = layout;
}
}

View File

@ -20,12 +20,20 @@
#include "Timeout.h"
// uncomment this line to try out the new menus
//#define NEW_MENUBAR
class LyXFunc;
class Toolbar;
class MiniBuffer;
class Intl;
class Buffer;
#ifdef NEW_MENUBAR
class Menubar;
#else
class Menus;
#endif
class BufferView;
class Dialogs;
@ -71,15 +79,25 @@ public:
/// return a pointer to the toolbar
Toolbar * getToolbar() const;
/// sets the layout in the toolbar layout combox
void setLayout(int layout);
/// return a pointer to the lyxfunc
LyXFunc * getLyXFunc() const;
/// return a pointer to the minibuffer
MiniBuffer * getMiniBuffer() const;
#ifdef NEW_MENUBAR
///
Menubar * getMenubar() const;
///
void updateMenubar();
#else
///
Menus * getMenus() const;
#endif
///
Intl * getIntl() const;
@ -105,8 +123,13 @@ private:
Toolbar * toolbar;
///
MiniBuffer * minibuffer;
#ifdef NEW_MENUBAR
///
Menubar * menubar;
#else
///
Menus * menus;
#endif
///
Intl * intl;
///

View File

@ -3,9 +3,13 @@ SUBDIRS = mathed insets support frontends
DISTCLEANFILES= *.orig *.rej *~ *.bak core libintl.h config.h
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in $(srcdir)/config.h.in
bin_PROGRAMS = lyx
## libfrontends is given twice on the link line because it needs stuff
## from FRONTEND_GUILIB and inversely. If you do not like it, feel
## free to provide another solution... Maybe signals would solve that
## magically, but I do not understand them much (JMarc)
lyx_DEPENDENCIES = mathed/libmathed.la insets/libinsets.la \
support/libsupport.la @FRONTEND_GUILIB@ frontends/libfrontends.la \
@INCLUDED_SIGC@
frontends/libfrontends.la @FRONTEND_GUILIB@ \
frontends/libfrontends.la support/libsupport.la @INCLUDED_SIGC@
lyx_LDADD = $(lyx_DEPENDENCIES) @INTLLIBS@ $(LYX_LIBS) $(SIGC_LIBS) \
@FRONTEND_LDFLAGS@ @FRONTEND_LIBS@
EXTRA_DIST = config.h.in stamp-h.in cheaders
@ -56,6 +60,8 @@ lyx_SOURCES = \
LyXView.C \
LyXView.h \
Makefile.in \
MenuBackend.C \
MenuBackend.h \
Painter.C \
Painter.h \
PainterBase.C \
@ -208,8 +214,6 @@ lyx_SOURCES = \
texrow.h \
text.C \
text2.C \
toolbar.C \
toolbar.h \
tracer.C \
tracer.h \
trans.C \

273
src/MenuBackend.C Normal file
View File

@ -0,0 +1,273 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
*
* ====================================================== */
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "MenuBackend.h"
#include "lyxlex.h"
#include "LyXAction.h"
#include "debug.h"
extern LyXAction lyxaction;
using std::endl;
// This is the global menu definition
MenuBackend menubackend;
MenuItem::MenuItem(MenuItem const & m)
: kind_(m.kind_), label_(m.label_), action_(m.action_), submenu_(m.submenu_)
{}
MenuItem::MenuItem(Kind kind, string const & label, string const & command)
: kind_(kind), label_(label)
{
switch(kind) {
case Separator:
case Documents:
case Lastfiles:
break;
case Command:
action_ = lyxaction.LookupFunc(command);
if (action_ == LFUN_UNKNOWN_ACTION) {
lyxerr << "MenuItem(): LyX command `"
<< command << "' does not exist." << endl;
}
break;
case Submenu:
submenu_ = command;
break;
}
}
void Menu::add(MenuItem const & i)
{
items_.push_back(i);
}
void Menu::read(LyXLex & lex)
{
enum Menutags {
md_item = 1,
md_documents,
md_endmenu,
md_lastfiles,
md_submenu,
md_separator,
md_last
};
struct keyword_item menutags[md_last-1] = {
{ "documents", md_documents },
{ "end", md_endmenu },
{ "item", md_item },
{ "lastfiles", md_lastfiles },
{ "separator", md_separator },
{ "submenu", md_submenu }
};
lex.pushTable(menutags, md_last - 1);
if (lyxerr.debugging(Debug::PARSER))
lex.printTable(lyxerr);
string mlabel, mname;
bool quit = false;
while (lex.IsOK() && !quit) {
switch(lex.lex()) {
case md_item: {
lex.next();
string name = lex.GetString();
lex.next();
string command = lex.GetString();
add(MenuItem(MenuItem::Command, name, command));
break;
}
case md_separator:
add(MenuItem(MenuItem::Separator));
break;
case md_lastfiles:
add(MenuItem(MenuItem::Lastfiles));
break;
case md_documents:
add(MenuItem(MenuItem::Documents));
break;
case md_submenu: {
lex.next();
mlabel = lex.GetString();
lex.next();
mname = lex.GetString();
add(MenuItem(MenuItem::Submenu, mlabel, mname));
break;
}
case md_endmenu:
quit = true;
break;
default:
lex.printError("menubar::read: "
"Unknown menu tag: `$$Token'");
break;
}
}
lex.popTable();
}
void MenuBackend::read(LyXLex & lex)
{
enum Menutags {
md_menu = 1,
md_menubar,
md_endmenuset,
md_last
};
struct keyword_item menutags[md_last-1] = {
{ "end", md_endmenuset },
{ "menu", md_menu },
{ "menubar", md_menubar }
};
//consistency check
if (compare_no_case(lex.GetString(), "menuset"))
lyxerr << "Menubackend::read: ERROR wrong token:`"
<< lex.GetString() << '\'' << endl;
lex.pushTable(menutags, md_last - 1);
if (lyxerr.debugging(Debug::PARSER))
lex.printTable(lyxerr);
string mlabel, mname;
bool quit = false;
while (lex.IsOK() && !quit) {
switch(lex.lex()) {
case md_menu: {
lex.next();
string name = lex.GetString();
Menu menu(name, false);
menu.read(lex);
add(menu);
break;
}
case md_menubar: {
lex.next();
string name = lex.GetString();
Menu menubar(name, true);
menubar.read(lex);
add(menubar);
break;
}
case md_endmenuset:
quit = true;
break;
default:
lex.printError("menubackend::read: "
"Unknown menu tag: `$$Token'");
break;
}
}
lex.popTable();
}
void MenuBackend::defaults()
{
if (menulist_.size() > 0)
menulist_.clear();
lyxerr[Debug::GUI] << "MenuBackend::defaults: using default values"
<< endl;
Menu file("file");
file.add(MenuItem(MenuItem::Command,
"New...|N", "buffer-new"));
file.add(MenuItem(MenuItem::Command,
"Open...|O", "buffer-open"));
file.add(MenuItem(MenuItem::Submenu,
"Import|I", "import"));
file.add(MenuItem(MenuItem::Command,
"Quit|Q", "lyx-quit"));
file.add(MenuItem(MenuItem::Separator));
file.add(MenuItem(MenuItem::Lastfiles));
add(file);
Menu import("import");
import.add(MenuItem(MenuItem::Command,
"LaTeX...|L", "buffer-import latex"));
import.add(MenuItem(MenuItem::Command,
"LinuxDoc...|L", "buffer-import linuxdoc"));
add(import);
Menu edit("edit");
edit.add(MenuItem(MenuItem::Command,
"Cut", "cut"));
edit.add(MenuItem(MenuItem::Command,
"Copy", "copy"));
edit.add(MenuItem(MenuItem::Command,
"Paste", "paste"));
edit.add(MenuItem(MenuItem::Command,
"Emphasize", "font-emph"));
add(edit);
Menu documents("documents");
documents.add(MenuItem(MenuItem::Documents));
add(documents);
Menu main("main", true);
main.add(MenuItem(MenuItem::Submenu, "File|F", "file"));
main.add(MenuItem(MenuItem::Submenu, "Edit|E", "edit"));
main.add(MenuItem(MenuItem::Submenu,
"Documents|D", "documents"));
add(main);
Menu main_nobuffer("main_nobuffer", true);
main_nobuffer.add(MenuItem(MenuItem::Submenu,
"File|F", "file"));
add(main_nobuffer);
if (lyxerr.debugging(Debug::GUI)) {
for(const_iterator cit = begin();
cit != end() ; ++cit)
lyxerr << "Menu name: " << cit->name()
<< ", Menubar: " << cit->menubar()
<< endl;
}
}
void MenuBackend::add(Menu const &menu)
{
menulist_.push_back(menu);
}
bool MenuBackend::hasMenu(string const &name) const
{
for (const_iterator cit = begin(); cit != end(); ++cit) {
if ((*cit).name() == name)
return true;
}
return false;
}
Menu const & MenuBackend::getMenu(string const &name) const
{
for (const_iterator cit = begin(); cit != end(); ++cit) {
if ((*cit).name() == name)
return (*cit);
}
Assert(false); // we actually require the name to exist.
return menulist_.front();
}

138
src/MenuBackend.h Normal file
View File

@ -0,0 +1,138 @@
/* This file is part of -*- C++ -*-
* ======================================================
*
* LyX, The Document Processor
*
* Copyright (C) 1995 Matthias Ettrich
* Copyright (C) 1995-1999 The LyX Team.
*
* This file is Copyright 1999
* Jean-Marc Lasgouttes
*
*======================================================*/
#ifndef MENUBACKEND_H
#define MENUBACKEND_H
#ifdef __GNUG__
#pragma interface
#endif
#include "LString.h"
#include "support/LAssert.h"
#include <vector>
class LyXLex;
class MenuItem;
class MenuItem {
public:
// The type of elements that can be in a menu
enum Kind {
Command,
Submenu,
Separator,
Lastfiles, // This is the list of last opened file,
// typically for the File menu.
Documents // This is the list of opened Documents,
// typically for the Documents menu.
};
// Create a copy of a given MenuItem
MenuItem(MenuItem const &);
// Create a Command type MenuItem
MenuItem(Kind kind_, string const & label_ = string(),
string const & command_ = string());
//
~MenuItem() {}
// The label of a given menuitem
string const & label() const { return label_; }
// The kind of entry
Kind kind() const { return kind_; }
// the action (if relevant)
int action() const { return action_; }
// the description of the submenu (if relevant)
string const & submenu() const { return submenu_; }
private:
Kind kind_;
string label_;
int action_;
string submenu_;
MenuItem() {}
};
class Menu {
public:
//
typedef std::vector<MenuItem> ItemList;
//
typedef ItemList::const_iterator const_iterator;
//
explicit Menu(string const & name, bool mb = false)
: menubar_(mb), name_(name) {}
//
void add(MenuItem const &);
//
void read(LyXLex &);
//
bool menubar() const { return menubar_; }
//
string const & name() const { return name_; }
//
bool empty() const { return items_.empty(); }
///
const_iterator begin() const {
return items_.begin();
}
///
const_iterator end() const {
return items_.end();
}
private:
///
ItemList items_;
///
bool menubar_;
///
string name_;
///
};
class MenuBackend {
public:
///
typedef std::vector<Menu> MenuList;
///
typedef MenuList::const_iterator const_iterator;
///
void read(LyXLex &);
/// Set default values for menu structure.
void defaults();
///
void add(Menu const &);
///
bool hasMenu (string const &) const;
///
Menu const & getMenu (string const &) const;
//
bool empty() const { return menulist_.empty(); }
///
const_iterator begin() const {
return menulist_.begin();
}
///
const_iterator end() const {
return menulist_.end();
}
private:
///
MenuList menulist_;
};
extern MenuBackend menubackend;
#endif /* MENUBACKEND_H */

View File

@ -1,5 +1,18 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#ifdef HAVE_SSTREAM
#include <sstream>

View File

@ -12,6 +12,10 @@
#ifndef SPACING_H
#define SPACING_H
#ifdef __GNUG__
#pragma interface
#endif
#include <iosfwd>
#include "LString.h"

View File

@ -1,3 +1,17 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include FORMS_H_LOCATION

View File

@ -1,7 +1,21 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#ifndef TIMEOUT_H
#define TIMEOUT_H
#ifdef __GNUG__
#pragma interface
#endif
#include <sigc++/signal_system.h>
#ifdef SIGC_CXX_NAMESPACES

View File

@ -1,15 +1,30 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
*
* ====================================================== */
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "ToolbarDefaults.h"
#include "LyXAction.h"
#include "toolbar.h"
#include "lyxlex.h"
#include "debug.h"
#include "lyxlex.h"
using std::endl;
extern LyXAction lyxaction;
ToolbarDefaults toolbardefaults;
ToolbarDefaults::ToolbarDefaults()
{
@ -22,34 +37,33 @@ void ToolbarDefaults::add(int action)
defaults.push_back(action);
}
void ToolbarDefaults::init()
{
add(Toolbar::TOOL_LAYOUTS);
add(LAYOUTS);
add(LFUN_MENUOPEN);
//add(LFUN_CLOSEBUFFER);
add(LFUN_MENUWRITE);
add(LFUN_MENUPRINT);
add(Toolbar::TOOL_SEPARATOR);
add(SEPARATOR);
add(LFUN_CUT);
add(LFUN_COPY);
add(LFUN_PASTE);
add(Toolbar::TOOL_SEPARATOR);
add(SEPARATOR);
add(LFUN_EMPH);
add(LFUN_NOUN);
add(LFUN_FREE);
add(Toolbar::TOOL_SEPARATOR);
add(SEPARATOR);
add(LFUN_FOOTMELT);
add(LFUN_MARGINMELT);
add(LFUN_DEPTH);
add(Toolbar::TOOL_SEPARATOR);
add(SEPARATOR);
add(LFUN_TEX);
add(LFUN_MATH_MODE);
add(Toolbar::TOOL_SEPARATOR);
add(SEPARATOR);
add(LFUN_FIGURE);
add(LFUN_TABLE);
@ -68,18 +82,18 @@ enum _tooltags {
struct keyword_item toolTags[TO_LAST - 1] = {
{ "\\add", TO_ADD },
{ "\\end_toolbar", TO_ENDTOOLBAR },
{ "\\layouts", TO_LAYOUTS },
{ "\\newline", TO_NEWLINE },
{ "\\separator", TO_SEPARATOR }
{ "end", TO_ENDTOOLBAR },
{ "icon", TO_ADD },
{ "layouts", TO_LAYOUTS },
{ "newline", TO_NEWLINE },
{ "separator", TO_SEPARATOR }
};
void ToolbarDefaults::read(LyXLex & lex)
{
//consistency check
if (lex.GetString() != "\\begin_toolbar")
if (compare_no_case(lex.GetString(), "toolbar"))
lyxerr << "Toolbar::read: ERROR wrong token:`"
<< lex.GetString() << '\'' << endl;
@ -95,14 +109,14 @@ void ToolbarDefaults::read(LyXLex & lex)
while (lex.IsOK() && !quit) {
lyxerr[Debug::TOOLBAR] << "Toolbar::read: current lex text: `"
lyxerr[Debug::GUI] << "Toolbar::read: current lex text: `"
<< lex.GetString() << '\'' << endl;
switch(lex.lex()) {
case TO_ADD:
if (lex.EatLine()) {
if (lex.next()) {
func = lex.GetString();
lyxerr[Debug::TOOLBAR]
lyxerr[Debug::GUI]
<< "Toolbar::read TO_ADD func: `"
<< func << "'" << endl;
add(func);
@ -110,15 +124,15 @@ void ToolbarDefaults::read(LyXLex & lex)
break;
case TO_SEPARATOR:
add(Toolbar::TOOL_SEPARATOR);
add(SEPARATOR);
break;
case TO_LAYOUTS:
add(Toolbar::TOOL_LAYOUTS);
add(LAYOUTS);
break;
case TO_NEWLINE:
add(Toolbar::TOOL_NEWLINE);
add(NEWLINE);
break;
case TO_ENDTOOLBAR:
@ -133,6 +147,7 @@ void ToolbarDefaults::read(LyXLex & lex)
}
}
lex.popTable();
lex.next();
}

View File

@ -1,8 +1,23 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
*
* ====================================================== */
#ifndef TOOLBARDEFAULTS_H
#define TOOLBARDEFAULTS_H
#ifdef __GNUG__
#pragma interface
#endif
#include <vector>
#include "LString.h"
@ -12,6 +27,16 @@ class LyXLex;
///
class ToolbarDefaults {
public:
/// The special toolbar actions
enum ItemType {
/// adds space between buttons in the toolbar
SEPARATOR=-3,
/// a special combox insead of a button
LAYOUTS=-2,
/// begin a new line of button (not working)
NEWLINE=-1
};
///
typedef std::vector<int> Defaults;
///
@ -49,7 +74,9 @@ private:
Defaults defaults;
};
//The global instance
extern ToolbarDefaults toolbardefaults;
#endif

View File

@ -15,6 +15,10 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <stdlib.h>
#include "bmtable.h"
#include XPM_H_LOCATION

View File

@ -16,6 +16,10 @@
#ifndef BMTABLE_H
#define BMTABLE_H
#ifdef __GNUG__
#pragma interface
#endif
#include FORMS_H_LOCATION
#if defined(__cplusplus)

View File

@ -1292,7 +1292,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
int j;
int ltype = 0;
int ltype_depth = 0;
int * actcell = 0;
int actcell = 0;
int actpos = 0;
#ifndef NEW_TABULAR
int h;

View File

@ -1,5 +1,19 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "bufferview_funcs.h"
#include "LyXView.h"
#include "BufferView.h"

View File

@ -1,7 +1,21 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#ifndef BUFFERVIEW_FUNCS_H
#define BUFFERVIEW_FUNCS_H
#ifdef __GNUG__
#pragma interface
#endif
#include "LString.h"
class BufferView;

View File

@ -52,6 +52,7 @@ enum kb_action {
LFUN_TEX,
LFUN_FOOTMELT,
LFUN_MARGINMELT,
LFUN_SWITCHBUFFER,
LFUN_EMPH,
LFUN_BOLD,
LFUN_ROMAN,
@ -242,6 +243,9 @@ enum kb_action {
LFUN_SEQUENCE, // Andre' 991111
LFUN_SAVEPREFERENCES, // Lgb 991127
LFUN_HELP_COPYRIGHT, // ARRae 20000129
LFUN_HELP_CREDITS, // ARRae 981017
LFUN_HELP_OPEN, // Jug 990627
LFUN_HELP_VERSION, // Jug 990627
LFUN_DATE_INSERT, // jdblair 20000131
LFUN_LANGUAGE, // Dekel 20000203
LFUN_INSET_TEXT, // Jug 20000214

View File

@ -1,3 +1,18 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
*
* ====================================================== */
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "counters.h"

View File

@ -1,8 +1,23 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
*
* ====================================================== */
#ifndef COUNTERS_H
#define COUTNERS_H
#ifdef __GNUG__
#pragma interface
#endif
#include <map>
#include <sigc++/signal_system.h>
#include "LString.h"

View File

@ -31,7 +31,7 @@ static error_item errorTags[] = {
{ Debug::INFO, "info", "General information"},
{ Debug::INIT, "init", "Program initialisation"},
{ Debug::KEY, "key", "Keyboard events handling"},
{ Debug::TOOLBAR, "toolbar", "Toolbar handling"},
{ Debug::GUI, "gui", "GUI handling"},
{ Debug::PARSER, "parser", "Lyxlex grammer parser"},
{ Debug::LYXRC, "lyxrc", "Configuration files reading"},
{ Debug::KBMAP, "kbmap", "Custom keyboard definition"},

View File

@ -1,8 +1,21 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#ifndef LYXDEBUG_H
#define LYXDEBUG_H
#ifdef __GNUG__
#pragma interface
#endif
#include <iosfwd>
#include "LString.h"
@ -24,7 +37,7 @@ struct Debug {
///
KEY = (1 << 2), // 4
///
TOOLBAR = (1 << 3), // 8
GUI = (1 << 3), // 8
///
PARSER = (1 << 4), // 16
///
@ -55,7 +68,7 @@ struct Debug {
INSETS = (1 << 17)
};
///
static const type ANY = type(INFO | INIT | KEY | TOOLBAR |
static const type ANY = type(INFO | INIT | KEY | GUI |
PARSER | LYXRC | KBMAP | LATEX |
MATHED | FONT | TCLASS | LYXVC |
LYXSERVER | ROFF | ACTION | LYXLEX |

View File

@ -10,6 +10,10 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "encoding.h"
Uchar tab_iso8859_1[256] = {

View File

@ -12,6 +12,10 @@
#ifndef ENCODING_H
#define ENCODING_H
#ifdef __GNUG__
#pragma interface
#endif
#include "LString.h"
#include "lyxrc.h"

View File

@ -1,5 +1,19 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <cctype>
#include "font.h"

View File

@ -1,7 +1,21 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#ifndef FONT_H
#define FONT_H
#ifdef __GNUG__
#pragma interface
#endif
#include <X11/Xlib.h>
#include "LString.h"

View File

@ -1,6 +1,19 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#include <config.h>
//#include "config.h"
#ifdef __GNUG__
#pragma implementation
#endif
#include "Liason.h"
#include "BufferView.h"
#include "buffer.h"

View File

@ -26,6 +26,10 @@
#ifndef LIASON_H
#define LIASON_H
#ifdef __GNUG__
#pragma interface
#endif
class PrinterParams;
class Buffer;

View File

@ -3,12 +3,16 @@ DISTCLEANFILES= *.orig *.rej *~ *.bak core
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
SUBDIRS = @FRONTEND@
ETAGS_ARGS = --lang=c++
INCLUDES = -I${srcdir}/../
INCLUDES = -I${srcdir}/.. -I${srcdir}/@FRONTEND@
LIBS =
noinst_LTLIBRARIES = libfrontends.la
libfrontends_la_SOURCES=\
Dialogs.h \
DialogBase.h \
Liason.C \
Liason.h
Liason.h \
Menubar.C \
Menubar.h \
Toolbar.C \
Toolbar.h

46
src/frontends/Menubar.C Normal file
View File

@ -0,0 +1,46 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* This file is Copyright 2000 Jean-Marc Lasgouttes
*
* ====================================================== */
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "Menubar.h"
#include "Menubar_pimpl.h"
using std::endl;
Menubar::Menubar(LyXView * o, MenuBackend const &md)
{
pimpl_ = new Pimpl(o, md);
}
Menubar::~Menubar()
{
delete pimpl_;
}
void Menubar::set(string const & name)
{
pimpl_->set(name);
}
void Menubar::openByName(string const & name)
{
pimpl_->openByName(name);
}

48
src/frontends/Menubar.h Normal file
View File

@ -0,0 +1,48 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* This file is Copyright 1996-2000
* Lars Gullik Bjønnes
*
* ====================================================== */
#ifndef MENUBAR_H
#define MENUBAR_H
#ifdef __GNUG__
#pragma interface
#endif
#include "LString.h"
class LyXView;
class MenuBackend;
/** The LyX GUI independent menubar class
The GUI interface is implemented in the corresponding Menubar_pimpl class.
*/
class Menubar {
public:
///
Menubar(LyXView * o, MenuBackend const &);
///
~Menubar();
///
void set(string const &);
/// Opens a top-level submenu given its name
void openByName(string const &);
//I disable this temporarily until I find a nice way to make it work
//with compaq cxx.
//private:
struct Pimpl;
friend struct Pimpl;
Pimpl * pimpl_;
};
#endif

114
src/frontends/Toolbar.C Normal file
View File

@ -0,0 +1,114 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* This file is Copyright 1996-1998
* Lars Gullik Bjønnes
*
* ====================================================== */
// Added pseudo-action handling, asierra 180296
#include <config.h>
#ifdef __GNUG__
#pragma implementation "Toolbar.h"
#endif
#include "Toolbar.h"
#include "Toolbar_pimpl.h"
#include "debug.h"
#include "LyXAction.h"
using std::endl;
extern LyXAction lyxaction;
Toolbar::Toolbar(LyXView * o, int x, int y, ToolbarDefaults const &tbd)
{
pimpl_ = new Pimpl(o, x, y);
pimpl_->reset();
// extracts the toolbar actions from tbd
for (ToolbarDefaults::const_iterator cit = tbd.begin();
cit != tbd.end(); ++cit) {
pimpl_->add((*cit));
lyxerr[Debug::GUI] << "tool action: "
<< (*cit) << endl;
}
}
Toolbar::~Toolbar()
{
delete pimpl_;
}
void Toolbar::set(bool doingmain)
{
pimpl_->set(doingmain);
}
void Toolbar::activate()
{
pimpl_->activate();
}
void Toolbar::deactivate()
{
pimpl_->deactivate();
}
void Toolbar::update()
{
pimpl_->update();
}
void Toolbar::setLayout(int layout) {
pimpl_->setLayout(layout);
}
void Toolbar::updateLayoutList(bool force) {
pimpl_->updateLayoutList(force);
}
void Toolbar::openLayoutList() {
pimpl_->openLayoutList();
}
void Toolbar::clearLayoutList()
{
pimpl_->clearLayoutList();
}
void Toolbar::push(int nth)
{
pimpl_->push(nth);}
void Toolbar::add(string const & func, bool doclean)
{
int tf = lyxaction.LookupFunc(func);
if (tf == -1) {
lyxerr << "Toolbar::add: no LyX command called`"
<< func << "'exists!" << endl;
} else {
pimpl_->add(tf, doclean);
}
}

70
src/frontends/Toolbar.h Normal file
View File

@ -0,0 +1,70 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* This file is Copyright 1996-2000
* Lars Gullik Bjønnes
*
* ====================================================== */
#ifndef TOOLBAR_H
#define TOOLBAR_H
#ifdef __GNUG__
#pragma interface
#endif
#include "LString.h"
class LyXView;
class ToolbarDefaults;
/** The LyX GUI independent toolbar class
The GUI interface is implemented in the corresponding Toolbar_pimpl class.
*/
class Toolbar {
public:
///
Toolbar(LyXView * o, int x, int y, ToolbarDefaults const &);
///
~Toolbar();
/// (re)sets the toolbar
void set(bool doingmain = false);
/** this is to be the entry point to the toolbar
frame, where you can change the toolbar realtime. */
void edit();
/// add a new button to the toolbar.
void add(int , bool doclean = true);
/// name of func instead of kb_action
void add(string const & , bool doclean = true);
/// invokes the n'th icon in the toolbar
void push(int);
/// activates the toolbar
void activate();
/// deactivates the toolbar
void deactivate();
/// update the state of the icons
void update();
/// update the layout combox
void setLayout(int layout);
/// Populate the layout combox; re-do everything if force is true.
void updateLayoutList(bool force);
/// Drop down the layout list
void openLayoutList();
/// Erase the layout list
void clearLayoutList();
private:
struct Pimpl;
friend struct Toolbar::Pimpl;
Pimpl * pimpl_;
};
#endif

View File

@ -31,6 +31,10 @@ libxforms_la_SOURCES = \
FormTabular.h \
form_tabular.C \
form_tabular.h \
Toolbar_pimpl.C \
Toolbar_pimpl.h \
Menubar_pimpl.C \
Menubar_pimpl.h \
input_validators.h \
input_validators.c \
xform_macros.h

View File

@ -0,0 +1,463 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright (C) 1999 The LyX Team.
*
*======================================================*/
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include <algorithm>
#include <cctype>
#include "support/lstrings.h"
#include "support/filetools.h"
#include "support/StrPool.h"
#include "support/LAssert.h"
#include "debug.h"
#include "LyXAction.h"
#include "lyxfunc.h"
#include "kbmap.h"
#include "bufferlist.h"
#include "lastfiles.h"
#include "LyXView.h"
#include "lyx_gui_misc.h"
#include "MenuBackend.h"
#include "Menubar_pimpl.h"
using std::endl;
extern kb_keymap * toplevel_keymap;
extern LyXAction lyxaction;
extern BufferList bufferlist;
extern LastFiles * lastfiles;
// Some constants
const int MENU_LABEL_SIZE = FL_NORMAL_SIZE;
const int mheight = 30;
const int mbheight= 22;
// where to place the menubar?
const int yloc = (mheight - mbheight)/2; //air + bw;
const int mbadd = 20; // menu button add (to width)
// Some space between buttons on the menubar
const int air = 2;
char const * menu_tabstop = "aa";
char const * default_tabstop = "aaaaaaaa";
//Defined later.
extern "C"
void C_Menubar_Pimpl_MenuCallback(FL_OBJECT * ob, long button);
Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mb)
: frame_(0), owner_(view), menubackend_(&mb)
{
// Should we do something here?
}
Menubar::Pimpl::~Pimpl()
{
// Should we do something here?
}
void Menubar::Pimpl::set(string const & menu_name)
{
lyxerr[Debug::GUI] << "Entering Menubar::Pimpl::set "
<< "for menu `" << menu_name << "'" << endl;
if (menu_name == current_menu) {
lyxerr[Debug::GUI] << "Nothing to do." << endl;
return;
}
// If the backend has not been initialized yet, we use a
// default instead.
if (menubackend_->empty()) {
lyxerr << "Menubar::Pimpl::set: menubackend is empty! "
"using default values." << endl;
MenuBackend * mb = new MenuBackend();
mb->defaults();
menubackend_ = mb;
}
if (!menubackend_->hasMenu(menu_name)){
lyxerr << "ERROR:set: Unknown menu `" << menu_name
<< "'" << endl;
return;
}
Menu menu = menubackend_->getMenu(menu_name);
if (!menu.menubar()) {
lyxerr << "Only a menubar-type object can go in a "
"toplevel menu" << endl;
return;
}
current_menu = menu_name;
FL_FORM * form = owner_->getForm();
int moffset = 0;
bool form_was_open, form_was_frozen;
if (fl_current_form == form)
form_was_open = true;
else if (fl_current_form == 0) {
form_was_open = false;
fl_addto_form(form);
}
else {
lyxerr << "Something is wrong: unknown form "
<< fl_current_form << " is already open"
<< "(main form is " << form << ")" << endl;
return;
}
if (form->frozen)
form_was_frozen = true;
else {
form_was_frozen = false;
fl_freeze_form(form);
}
// Delete old buttons if there are some.
for(ButtonList::const_iterator cit = buttonlist_.begin();
cit != buttonlist_.end(); ++cit) {
if ((*cit)->obj_) {
fl_delete_object((*cit)->obj_);
fl_free_object((*cit)->obj_);
}
delete (*cit);
}
buttonlist_.clear();
// Create menu frame if there is non yet.
if (!frame_) {
frame_ = fl_add_frame(FL_UP_FRAME, 0, 0, form->w, mheight, "");
fl_set_object_resize(frame_, FL_RESIZE_ALL);
fl_set_object_gravity(frame_, NorthWestGravity,
NorthEastGravity);
}
for (Menu::const_iterator i = menu.begin();
i != menu.end(); ++i) {
FL_OBJECT * obj;
if (i->kind() != MenuItem::Submenu) {
lyxerr << "ERROR: Menubar::Pimpl::Pimpl:"
" only submenus can appear in a menubar";
break;
}
char const * label = idex(i->label().c_str());
char const * shortcut = scex(i->label().c_str());
int width = fl_get_string_width(FL_NORMAL_STYLE,
MENU_LABEL_SIZE,
label,
strlen(label));
obj = fl_add_button(FL_TOUCH_BUTTON,
air + moffset, yloc,
width + mbadd,
mbheight,
label);
fl_set_object_boxtype(obj, FL_FLAT_BOX);
fl_set_object_color(obj, FL_MCOL, FL_MCOL);
fl_set_object_lsize(obj, MENU_LABEL_SIZE);
fl_set_object_lstyle(obj, FL_NORMAL_STYLE);
fl_set_object_resize(obj, FL_RESIZE_ALL);
fl_set_object_gravity(obj, NorthWestGravity,
NorthWestGravity);
moffset += obj->w + air;
fl_set_object_shortcut(obj, shortcut, 1);
fl_set_object_callback(obj, C_Menubar_Pimpl_MenuCallback, 1);
ItemInfo * iteminfo = new ItemInfo(this,
new MenuItem(*i), obj);
buttonlist_.push_back(iteminfo);
obj->u_vdata = iteminfo;
// lyxerr << "MenuCallback: ItemInfo address=" << iteminfo
// << " Val=(pimpl_=" << iteminfo->pimpl_
// << ", item_=" << iteminfo->item_
// << ", obj_=" << iteminfo->obj_ << ")" <<endl;
}
if (!form_was_frozen) {
fl_unfreeze_form(form);
}
if (!form_was_open)
fl_end_form();
lyxerr[Debug::GUI] << "Menubar set." << endl;
}
void Menubar::Pimpl::openByName(string const & name)
{
for(ButtonList::const_iterator cit = buttonlist_.begin();
cit != buttonlist_.end(); ++cit) {
if ((*cit)->item_->submenu() == name) {
MenuCallback((*cit)->obj_, 1);
return;
}
}
lyxerr << "Menubar::Pimpl::openByName: menu "
<< name << " not found" << endl;
}
void Menubar::Pimpl::add_lastfiles(int menu, string const & extra_label,
std::vector<int> & /*smn*/,
StrPool & strpool)
{
int ii = 1;
for (LastFiles::const_iterator cit = lastfiles->begin();
cit != lastfiles->end() && ii < 10; ++cit, ++ii) {
int action =
lyxaction.getPseudoAction(LFUN_FILE_OPEN, (*cit));
string label = tostr(ii) + ". "
+ MakeDisplayPath((*cit),30)
+ "%x" + tostr(action);
if ((cit + 1) == lastfiles->end())
label += extra_label;
string shortcut = tostr(ii) + "#" + tostr(ii);
lyxerr[Debug::GUI] << "shortcut is " << shortcut <<
endl;
int n = fl_addtopup(menu, strpool.add(label));
fl_setpup_shortcut(menu, n, strpool.add(shortcut));
}
}
void Menubar::Pimpl::add_documents(int menu, string const & extra_label,
std::vector<int> & /*smn*/,
StrPool & strpool)
{
std::vector<string> names = bufferlist.getFileNames();
if (names.empty()) {
fl_addtopup(menu,_("No Documents Open!%i"));
return;
}
for (std::vector<string>::const_iterator cit = names.begin();
cit != names.end() ; ++cit) {
int action =
lyxaction.getPseudoAction(LFUN_SWITCHBUFFER, *cit);
string label = MakeDisplayPath(*cit, 30)
+ "%x" + tostr(action);
if ((cit + 1) == names.end())
label += extra_label;
fl_addtopup(menu, strpool.add(label));
}
}
int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
string const & menu_name,
std::vector<int> & smn, StrPool & strpool)
{
if (!menubackend_->hasMenu(menu_name)){
lyxerr << "ERROR:create_submenu: Unknown menu `"
<< menu_name << "'" << endl;
return -1;
}
Menu md = menubackend_->getMenu(menu_name);
int menu = fl_newpup(win);
fl_setpup_softedge(menu, true);
fl_setpup_bw(menu, -1);
lyxerr[Debug::GUI] << "Adding menu " << menu
<< " in deletion list" << endl;
smn.push_back(menu);
// Compute the size of the largest label (because xforms is
// not able to support shortcuts correctly...)
int max_width = 0, max_tabs = 0;
int tab_width = fl_get_string_width(FL_NORMAL_STYLE, MENU_LABEL_SIZE,
menu_tabstop, strlen(menu_tabstop));
for (Menu::const_iterator i = md.begin(); i != md.end(); ++i) {
MenuItem item = (*i);
if (item.kind() == MenuItem::Command) {
string label = idex(item.label().c_str());
int width = fl_get_string_width(FL_NORMAL_STYLE,
MENU_LABEL_SIZE,
label.c_str(),
label.length());
if (width > max_width)
max_width = width;
}
}
max_tabs = (max_width + 5)/tab_width + 1;
lyxerr[Debug::GUI] << "tab_width=" << tab_width
<< ", max_width=" << max_width
<< ", max_tabs=" << max_tabs << endl;
for (Menu::const_iterator i = md.begin(); i != md.end(); ++i) {
MenuItem item = (*i);
// Is there a separator after this item?
string extra_label;
if ((i+1) != md.end()
&& (i+1)->kind() == MenuItem::Separator)
extra_label = "%l";
switch(item.kind()) {
case MenuItem::Command: {
LyXFunc::func_status flag =
view->getLyXFunc()->getStatus(item.action());
// Get the keys bound to this action, but keep only the
// first one later
string accel = toplevel_keymap->findbinding(item.action());
lyxerr[Debug::GUI] << "Command: "
<< lyxaction.getActionName(item.action())
<< " Binding " << accel << endl;
// Build the menu label from all the info
string label = idex(item.label().c_str());
if (!accel.empty()) {
// Try to be clever and add enough
// tabs to align shortcuts.
int width =
fl_get_string_width(FL_NORMAL_STYLE,
MENU_LABEL_SIZE,
label.c_str(),
label.length());
int nb = max_tabs - width/tab_width;
lyxerr[Debug::GUI] << "label=" << label
<< ", tabs=" << nb
<< endl;
if (nb > 0)
label += string(nb, '\t');
label += accel.substr(1,accel.find(']') - 1);
}
label += "%x" + tostr(item.action()) + extra_label;
// Modify the entry using the function status
string pupmode;
if (flag & (LyXFunc::Disabled | LyXFunc::Unknown))
pupmode += "%i";
if (flag & LyXFunc::ToggleOn)
pupmode += "%B";
if (flag & LyXFunc::ToggleOff)
pupmode += "%b";
label += pupmode;
// Finally the menu shortcut
string shortcut = scex(item.label().c_str());
if (!shortcut.empty()) {
string xfshortcut;
xfshortcut += uppercase(shortcut[0]);
xfshortcut += '#';
xfshortcut += uppercase(shortcut[0]);
xfshortcut += lowercase(shortcut[0]);
xfshortcut += '#';
xfshortcut += lowercase(shortcut[0]);
lyxerr[Debug::GUI] << "shortcut is "
<< xfshortcut << endl;
label += "%h";
fl_addtopup(menu, strpool.add(label),
strpool.add(xfshortcut));
} else
fl_addtopup(menu, strpool.add(label));
break;
}
case MenuItem::Submenu: {
int submenu = create_submenu(win, view,
item.submenu(),
smn, strpool);
if (submenu == -1)
return -1;
string label = idex(item.label().c_str());
label += extra_label + "%m";
string shortcut = scex(item.label().c_str());
int n = fl_addtopup(menu, strpool.add(label), submenu);
fl_setpup_shortcut(menu, n, strpool.add(shortcut));
break;
}
case MenuItem::Separator:
// already done, and if it was the first one,
// we just ignore it.
break;
case MenuItem::Documents:
add_documents(menu, extra_label, smn, strpool);
break;
case MenuItem::Lastfiles:
add_lastfiles(menu, extra_label, smn, strpool);
break;
}
}
return menu;
}
extern "C"
void C_Menubar_Pimpl_MenuCallback(FL_OBJECT * ob, long button)
{
Menubar::Pimpl::MenuCallback(ob, button);
}
void Menubar::Pimpl::MenuCallback(FL_OBJECT * ob, long button)
{
ItemInfo * iteminfo = static_cast<ItemInfo *>(ob->u_vdata);
// lyxerr << "MenuCallback: ItemInfo address=" << iteminfo
// << "Val=(pimpl_=" << iteminfo->pimpl_
// << ", item_=" << iteminfo->item_
// << ", obj_=" << iteminfo->obj_ << ")" <<endl;
LyXView * view = iteminfo->pimpl_->owner_;
MenuItem const * item = iteminfo->item_;
if (button == 1) {
// set the pseudo menu-button
fl_set_object_boxtype(ob, FL_DOWN_BOX);
fl_set_button(ob, 0);
fl_redraw_object(ob);
}
// Paranoia check
Assert(item->kind() == MenuItem::Submenu);
// set tabstop length
fl_set_tabstop(menu_tabstop);
std::vector<int> submenus;
StrPool strpool;
int menu = iteminfo->pimpl_->
create_submenu(FL_ObjWin(ob), view,
item->submenu(),
submenus, strpool);
if (menu != -1) {
// place popup
fl_setpup_position(view->getForm()->x + ob->x,
view->getForm()->y + ob->y + ob->h + 10);
int choice = fl_dopup(menu);
if (button == 1) {
// set the pseudo menu-button back
fl_set_object_boxtype(ob, FL_FLAT_BOX);
fl_redraw_object(ob);
}
if (choice >= 1) {
view->getLyXFunc()->Dispatch(choice);
}
}
else
lyxerr << "Error in MenuCallback" << endl;
std::for_each(submenus.begin(), submenus.end(), fl_freepup);
// restore tabstop length
fl_set_tabstop(default_tabstop);
}

View File

@ -0,0 +1,90 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* This file is Copyright 1996-2000
* Lars Gullik Bjønnes
*
* ====================================================== */
#ifndef MENUBAR_PIMPL_H
#define MENUBAR_PIMPL_H
#ifdef __GNUG__
#pragma interface
#endif
#include <vector>
#include "LString.h"
#include "frontends/Menubar.h"
#include FORMS_H_LOCATION
class LyXView;
class MenuBackend;
class MenuItem;
class StrPool;
#include "debug.h"
/** The LyX GUI independent menubar class
The GUI interface is implemented in the corresponding Menubar_pimpl class.
*/
struct Menubar::Pimpl {
public:
///
Pimpl(LyXView *, MenuBackend const &);
///
~Pimpl();
///
void set(string const &);
/// Opens a top-level submenu given its name
void openByName(string const &);
///
static void MenuCallback(FL_OBJECT *, long);
/// Add to "menu" the list of last opened files
/// (add "extra_label" to the last entry)
void add_lastfiles(int menu, string const & extra_label,
std::vector<int> & smn, StrPool & strpool);
/// Add to "menu" the list of opened documents
/// (add "extra_label" to the last entry)
void add_documents(int menu, string const & extra_label,
std::vector<int> & smn, StrPool & strpool);
///
int create_submenu(Window win, LyXView * view,
string const & menuname,
std::vector<int> & smn, StrPool & strpool);
private:
///
FL_OBJECT * frame_;
///
LyXView * owner_;
///
MenuBackend const * menubackend_;
///
string current_menu;
///
struct ItemInfo {
///
ItemInfo(Menubar::Pimpl * p, MenuItem const * i,
FL_OBJECT * o)
: pimpl_(p), item_(i), obj_(o) {}
///
Menubar::Pimpl * pimpl_;
///
MenuItem const * item_;
///
FL_OBJECT * obj_;
};
///
typedef std::vector<ItemInfo *> ButtonList;
///
ButtonList buttonlist_;
};
#endif

View File

@ -16,22 +16,17 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation "toolbar.h"
#pragma implementation
#endif
#include "lyx_main.h"
#include "lyx_gui_misc.h"
#include "lyx.h"
#include "toolbar.h"
#include "Toolbar_pimpl.h"
#include "lyxfunc.h"
#include "lyxlex.h"
#include "debug.h"
#include "combox.h"
#include "LyXView.h"
#include "BufferView.h"
#include "buffer.h"
#include "LyXAction.h"
#include "support/lstrings.h"
#include "support/filetools.h"
#include "lyxrc.h"
using std::endl;
@ -40,16 +35,24 @@ 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::toolbarItem::toolbarItem()
{
Toolbar::Pimpl::toolbarItem::toolbarItem() {
action = LFUN_NOACTION;
icon = 0;
}
void Toolbar::toolbarItem::clean()
{
Toolbar::Pimpl::toolbarItem::~toolbarItem() {
clean();
}
void Toolbar::Pimpl::toolbarItem::clean() {
if (icon) {
fl_delete_object(icon);
fl_free_object(icon);
@ -58,16 +61,9 @@ void Toolbar::toolbarItem::clean()
}
Toolbar::toolbarItem::~toolbarItem()
{
clean();
}
Toolbar::toolbarItem &
Toolbar::toolbarItem::operator=(Toolbar::toolbarItem const & ti)
{
// do we have to check icon and IsBitmap too?
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
@ -75,29 +71,21 @@ Toolbar::toolbarItem::operator=(Toolbar::toolbarItem const & ti)
}
Toolbar::Toolbar(LyXView * o, int x, int y)
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
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)
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
@ -111,26 +99,27 @@ void Toolbar::BubbleTimerCB(FL_OBJECT *, long data)
extern "C" void C_Toolbar_BubbleTimerCB(FL_OBJECT * ob, long data)
{
Toolbar::BubbleTimerCB(ob, data);
BubbleTimerCB(ob, data);
}
// post_handler for bubble-help (Matthias)
int Toolbar::BubblePost(FL_OBJECT *ob, int event,
static
int BubblePost(FL_OBJECT *ob, int event,
FL_Coord /*mx*/, FL_Coord /*my*/,
int /*key*/, void */*xev*/)
{
Toolbar * t = reinterpret_cast<Toolbar*>(ob->u_vdata);
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(t->bubble_timer,
fl_set_object_callback(bubble_timer,
C_Toolbar_BubbleTimerCB,
reinterpret_cast<long>(ob));
fl_set_timer(t->bubble_timer, 1);
fl_set_timer(bubble_timer, 1);
}
else if(event != FL_MOTION){
fl_set_timer(t->bubble_timer, 0);
fl_set_timer(bubble_timer, 0);
fl_hide_oneliner();
}
return 0;
@ -141,12 +130,12 @@ 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);
return BubblePost(ob, event, 0, 0, key, xev);
}
#endif
void Toolbar::activate()
void Toolbar::Pimpl::activate()
{
ToolbarList::const_iterator p = toollist.begin();
for (; p != toollist.end(); ++p) {
@ -157,7 +146,7 @@ void Toolbar::activate()
}
void Toolbar::deactivate()
void Toolbar::Pimpl::deactivate()
{
ToolbarList::const_iterator p = toollist.begin();
for (; p != toollist.end(); ++p) {
@ -167,7 +156,7 @@ void Toolbar::deactivate()
}
}
void Toolbar::update()
void Toolbar::Pimpl::update()
{
ToolbarList::const_iterator p = toollist.begin();
for (; p != toollist.end(); ++p) {
@ -199,22 +188,67 @@ void Toolbar::update()
}
void Toolbar::ToolbarCB(FL_OBJECT * ob, long ac)
{
Toolbar * t = static_cast<Toolbar*>(ob->u_vdata);
void Toolbar::Pimpl::setLayout(int layout) {
if (combox)
combox->select(layout+1);
}
string res = t->owner->getLyXFunc()->Dispatch(int(ac));
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::TOOLBAR] << res << endl;
lyxerr[Debug::GUI] << res << endl;
}
extern "C" void C_Toolbar_ToolbarCB(FL_OBJECT * ob, long data)
{
Toolbar::ToolbarCB(ob, 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());
@ -227,6 +261,8 @@ int Toolbar::get_toolbar_func(string const & func)
}
return action;
}
#endif
static
void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) {
@ -234,8 +270,6 @@ void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) {
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, ' ','_');
@ -245,20 +279,17 @@ void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) {
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 `"
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::TOOLBAR] << "Using mathed-provided icon" << endl;
lyxerr[Debug::GUI] << "Using mathed-provided icon" << endl;
char const ** pixmap = get_pixmap_from_symbol(arg.c_str(),
buttonwidth,
height);
@ -269,13 +300,13 @@ void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) {
lyxerr << "Unable to find icon `" << xpm_name << "'" << endl;
fullname = LibFileSearch("images", "unknown", "xpm");
if (!fullname.empty()) {
lyxerr[Debug::TOOLBAR] << "Using default `unknown' icon"
lyxerr[Debug::GUI] << "Using default `unknown' icon"
<< endl;
fl_set_pixmapbutton_file(obj, fullname.c_str());
}
}
void Toolbar::set(bool doingmain)
void Toolbar::Pimpl::set(bool doingmain)
{
// we shouldn't set if we have not cleaned
if (!cleaned) return;
@ -297,10 +328,13 @@ void Toolbar::set(bool doingmain)
ToolbarList::iterator item = toollist.begin();
for (; item != toollist.end(); ++item) {
switch(item->action){
case TOOL_SEPARATOR:
case ToolbarDefaults::SEPARATOR:
xpos += sepspace;
break;
case TOOL_LAYOUTS:
case ToolbarDefaults::NEWLINE:
// Not supported yet.
break;
case ToolbarDefaults::LAYOUTS:
xpos += standardspacing;
if (!combox)
combox = new Combox(FL_COMBOX_DROPLIST);
@ -332,10 +366,11 @@ void Toolbar::set(bool doingmain)
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 toolbar that this object belongs too.
obj->u_vdata = this;
// The view that this object belongs to.
obj->u_vdata = owner;
setPixmap(obj, item->action, buttonwidth, height);
// we must remember to update the positions
@ -363,7 +398,7 @@ void Toolbar::set(bool doingmain)
}
void Toolbar::add(int action, bool doclean)
void Toolbar::Pimpl::add(int action, bool doclean)
{
if (doclean && !cleaned) clean();
@ -401,7 +436,7 @@ void Toolbar::add(int action, bool doclean)
}
void Toolbar::clean()
void Toolbar::Pimpl::clean()
{
//reset(); // I do not understand what this reset() is, anyway
@ -413,7 +448,7 @@ void Toolbar::clean()
//toollist.clear();
toollist.erase(toollist.begin(), toollist.end());
lyxerr[Debug::TOOLBAR] << "Combox: " << combox << endl;
lyxerr[Debug::GUI] << "Combox: " << combox << endl;
if (combox) {
delete combox;
combox = 0;
@ -421,19 +456,18 @@ void Toolbar::clean()
if (owner)
fl_unfreeze_form(owner->getForm());
lyxerr[Debug::TOOLBAR] << "toolbar cleaned" << endl;
lyxerr[Debug::GUI] << "toolbar cleaned" << endl;
cleaned = true;
}
void Toolbar::push(int nth)
void Toolbar::Pimpl::push(int nth)
{
lyxerr[Debug::TOOLBAR] << "Toolbar::push: trying to trigger no `"
lyxerr[Debug::GUI] << "Toolbar::push: trying to trigger no `"
<< nth << '\'' << endl;
if (nth <= 0 || nth >= int(toollist.size())) {
// item nth not found...
LyXBell();
return;
}
@ -441,32 +475,14 @@ void Toolbar::push(int 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 {
add(tf, doclean);
}
}
void Toolbar::reset()
void Toolbar::Pimpl::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
// }
void Toolbar::Pimpl::lightReset() {
xpos = sxpos - standardspacing;
ypos = sypos;
}

View File

@ -11,8 +11,10 @@
*
* ====================================================== */
#ifndef TOOLBAR_H
#define TOOLBAR_H
#ifndef TOOLBAR_PIMPL_H
#define TOOLBAR_PIMPL_H
#include "frontends/Toolbar.h"
#ifdef __GNUG__
#pragma interface
@ -22,39 +24,24 @@
#include FORMS_H_LOCATION
#include "commandtags.h"
#include "combox.h"
#include "ToolbarDefaults.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.
/** The LyX xforms toolbar class
*/
class Toolbar {
struct Toolbar::Pimpl {
public:
///
Toolbar(LyXView * o, int x, int y);
Pimpl(LyXView * o, int x, int y);
///
~Toolbar() {
~Pimpl() {
clean();
}
#if 0
///
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;
#endif
/// (re)sets the toolbar
void set(bool doingmain = false);
@ -64,8 +51,6 @@ public:
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
@ -74,18 +59,16 @@ public:
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
/// 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();
private:
///
struct toolbarItem
{
@ -113,6 +96,8 @@ private:
///
FL_OBJECT * bubble_timer;
#endif
///
Combox * combox;
/// Starting position
int sxpos, sypos;
///
@ -120,18 +105,8 @@ private:
///
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();
@ -141,13 +116,6 @@ private:
/** 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
}
void lightReset();
};
#endif

View File

@ -9,7 +9,6 @@
#include FORMS_H_LOCATION
#include "insetbib.h"
#include "combox.h"
#include "buffer.h"
#include "debug.h"
#include "lyx_gui_misc.h"

View File

@ -38,7 +38,6 @@
#include "CutAndPaste.h"
#include "font.h"
#include "minibuffer.h"
#include "toolbar.h"
#include "LColor.h"
#include "support/textutils.h"
#include "support/LAssert.h"
@ -420,7 +419,7 @@ void InsetText::UpdateLocal(BufferView * bv, UpdateCodes what, bool mark_dirty)
TEXT(bv)->selection)
bv->updateInset(this, mark_dirty);
if (old_par != cpar(bv)) {
bv->owner()->getToolbar()->combox->select(cpar(bv)->GetLayout()+1);
bv->owner()->setLayout(cpar(bv)->GetLayout());
old_par = cpar(bv);
}
}
@ -467,11 +466,10 @@ void InsetText::InsetUnlock(BufferView * bv)
TEXT(bv)->selection = 0;
UpdateLocal(bv, CLEAR_FRAME, false);
if (owner())
bv->owner()->getToolbar()->combox->
select(owner()->getLyXText(bv)->cursor.par()->GetLayout()+1);
bv->owner()->setLayout(owner()->getLyXText(bv)
->cursor.par()->GetLayout());
else
bv->owner()->getToolbar()->combox->select(bv->text->cursor.par()->
GetLayout()+1);
bv->owner()->setLayout(bv->text->cursor.par()->GetLayout());
}
@ -594,7 +592,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
y+TEXT(bv)->first+insetAscent);
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR, false);
bv->owner()->getToolbar()->combox->select(cpar(bv)->GetLayout()+1);
bv->owner()->setLayout(cpar(bv)->GetLayout());
old_par = cpar(bv);
}
}
@ -866,7 +864,7 @@ InsetText::LocalDispatch(BufferView * bv,
if (cur_layout != layout.second) {
cur_layout = layout.second;
TEXT(bv)->SetLayout(bv, layout.second);
bv->owner()->getToolbar()->combox->select(cpar(bv)->GetLayout()+1);
bv->owner()->setLayout(cpar(bv)->GetLayout());
UpdateLocal(bv, CURSOR_PAR, true);
}
}

View File

@ -1,6 +1,19 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "language.h"
#include "gettext.h"
#include "encoding.h"

View File

@ -1,7 +1,21 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#ifndef LANGUAGE_H
#define LANGUAGE_H
#ifdef __GNUG__
#pragma interface
#endif
#include <map>
#include "LString.h"

View File

@ -11,6 +11,10 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <cerrno>
#include "lyx_gui_misc.h"
#include "BufferView.h"

View File

@ -14,6 +14,10 @@
#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 */

View File

@ -13,6 +13,10 @@
#include <cstdlib>
#include <csignal>
#ifdef __GNUG__
#pragma implementation
#endif
#include "version.h"
#include "lyx_main.h"
#include "lyx_gui.h"
@ -31,6 +35,11 @@
#include "layout.h"
#include "gettext.h"
#include "kbmap.h"
#ifdef NEW_MENUBAR
# include "MenuBackend.h"
#endif
#include "ToolbarDefaults.h"
#include "lyxlex.h"
using std::endl;
@ -89,8 +98,6 @@ LyX::LyX(int * argc, char * argv[])
}
}
// Initialization of LyX (reads lyxrc and more)
lyxerr[Debug::INIT] << "Initializing LyX::init..." << endl;
init(argc, argv, gui);
@ -403,6 +410,8 @@ void LyX::init(int */*argc*/, char **argv, bool gui)
if (!lyxrc.hasBindFile)
lyxrc.ReadBindFile();
// Read menus
ReadUIFile(lyxrc.ui_file);
// Bind the X dead keys to the corresponding LyX functions if
// necessary.
@ -575,6 +584,65 @@ void LyX::ReadRcFile(string const & name)
}
// Read the ui file `name'
void LyX::ReadUIFile(string const & name)
{
enum Uitags {
ui_menuset = 1,
ui_toolbar,
ui_last
};
struct keyword_item uitags[ui_last-1] = {
{ "menuset", ui_menuset },
{ "toolbar", ui_toolbar }
};
lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
string ui_path = LibFileSearch("ui", name, "ui");
if (ui_path.empty()) {
lyxerr[Debug::INIT] << "Could not find " << name << endl;
return;
}
lyxerr[Debug::INIT] << "Found " << name
<< " in " << ui_path << endl;
LyXLex lex(uitags, ui_last - 1);
lex.setFile(ui_path);
if (lyxerr.debugging(Debug::PARSER))
lex.printTable(lyxerr);
while (lex.IsOK()) {
switch(lex.lex()) {
case ui_menuset:
#ifdef NEW_MENUBAR
menubackend.read(lex);
break;
#else
// Skip any menu definition and fall over to toolbar.
// This is a hack, but it is supposed to go away...
do {
lex.next();
if (!lex.IsOK()) return;
}
while (lex.lex() != ui_toolbar);
#endif
case ui_toolbar:
toolbardefaults.read(lex);
break;
default:
lex.printError("LyX::ReadUFile: "
"Unknown menu tag: `$$Token'");
break;
}
}
}
// Set debugging level and report result to user
void setDebuggingLevel(string const & dbgLevel)
{

View File

@ -15,6 +15,10 @@
#ifndef LYX_MAIN_H
#define LYX_MAIN_H
#ifdef __GNUG__
#pragma interface
#endif
#include <csignal>
#include "LString.h"
@ -83,6 +87,8 @@ private:
void queryUserLyXDir(bool explicit_userdir);
///
void ReadRcFile(string const & name);
/// Read the ui file `name'
void ReadUIFile(string const & name);
///
bool easyParse(int * argc, char * argv[]);
//@}

View File

@ -1,16 +1,19 @@
/*
This file is part of
======================================================
LyX, The Document Processor
Copyright 1995 Matthias Ettrich
Copyright 1995-2000 The LyX Team.
======================================================
*/
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "lyx_sty.h"
//\NeedsTeXFormat{LaTeX2e}

View File

@ -1,19 +1,21 @@
// -*- C++ -*-
/*
This file is part of
======================================================
LyX, The Document Processor
Copyright 1995 Matthias Ettrich
copyright 1995-2000 The LyX Team.
======================================================
*/
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#ifndef LYX_STY_H
#define LYX_STY_H
#ifdef __GNUG__
#pragma interface
#endif
#include "LString.h"
// This seems to be fixed now (JMarc)

View File

@ -10,6 +10,10 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "lyxcursor.h"

View File

@ -12,6 +12,10 @@
#ifndef LYXCURSOR_H
#define LYXCURSOR_H
#ifdef __GNUG__
#pragma interface
#endif
#include "lyxparagraph.h"
struct Row;

View File

@ -28,6 +28,7 @@ using std::istringstream;
#pragma implementation
#endif
#include "version.h"
#include "lyxlookup.h"
#include "kbmap.h"
#include "lyxfunc.h"
@ -64,7 +65,6 @@ using std::istringstream;
#include "insets/insettheorem.h"
#include "insets/insetcaption.h"
#include "mathed/formulamacro.h"
#include "toolbar.h"
#include "spellchecker.h" // RVDK_PATCH_5
#include "minibuffer.h"
#include "vspace.h"
@ -86,9 +86,14 @@ using std::istringstream;
#include "layout.h"
#include "WorkArea.h"
#include "lyxfr1.h"
#include "menus.h"
#include "bufferview_funcs.h"
#include "frontends/Dialogs.h"
#include "frontends/Toolbar.h"
#ifdef NEW_MENUBAR
#include "frontends/Menubar.h"
#else
#include "menus.h"
#endif
#include "FloatList.h"
using std::pair;
@ -343,6 +348,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
// no
setErrorMessage(N_("Document is read-only"));
flag |= LyXFunc::Disabled;
return flag;
}
} else {
// no
@ -352,9 +358,6 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
}
}
if (flag & LyXFunc::Disabled)
return flag;
// I would really like to avoid having this switch and rather try to
// encode this in the function itself.
static bool noLaTeX = lyxrc.latex_command == "none";
@ -409,6 +412,20 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
disable = ! owner->view()->text->cursor.par()->table;
break;
#endif
case LFUN_VC_REGISTER:
disable = buf->lyxvc.inUse();
break;
case LFUN_VC_CHECKIN:
disable = !buf->lyxvc.inUse() || buf->isReadonly();
break;
case LFUN_VC_CHECKOUT:
disable = !buf->lyxvc.inUse() || !buf->isReadonly();
break;
case LFUN_VC_REVERT:
case LFUN_VC_UNDO:
case LFUN_VC_HISTORY:
disable = !buf->lyxvc.inUse();
break;
default:
break;
}
@ -1046,6 +1063,42 @@ string LyXFunc::Dispatch(int ac,
owner->getDialogs()->showCopyright();
break;
case LFUN_HELP_CREDITS:
owner->getDialogs()->showCredits();
break;
case LFUN_HELP_OPEN: {
string arg = argument;
if (arg.empty()) {
setErrorMessage(N_("Missing argument"));
break;
}
ProhibitInput(owner->view());
string fname = i18nLibFileSearch("doc", arg, "lyx");
if (fname.empty()) {
lyxerr << "LyX: unable to find documentation file `"
<< arg << "'. Bad installation?" << endl;
AllowInput(owner->view());
break;
}
owner->getMiniBuffer()->Set(_("Opening help file"),
MakeDisplayPath(fname),"...");
owner->view()->buffer(bufferlist.loadLyXFile(fname,false));
AllowInput(owner->view());
break;
}
case LFUN_HELP_VERSION:
ProhibitInput(owner->view());
fl_show_message((string(_("LyX Version ")) + LYX_VERSION
+ _(" of ") + LYX_RELEASE).c_str(),
(_("Library directory: ")
+ MakeDisplayPath(system_lyxdir)).c_str(),
(_("User directory: ")
+ MakeDisplayPath(user_lyxdir)).c_str());
AllowInput(owner->view());
break;
// --- version control -------------------------------
case LFUN_VC_REGISTER:
{
@ -1090,6 +1143,11 @@ string LyXFunc::Dispatch(int ac,
// --- buffers ----------------------------------------
case LFUN_SWITCHBUFFER:
owner->view()->buffer(bufferlist.getBuffer(argument));
break;
case LFUN_FILE_INSERT:
{
MenuInsertLyXFile(argument);
@ -1174,10 +1232,7 @@ string LyXFunc::Dispatch(int ac,
owner->view()->update(BufferView::SELECT|BufferView::FITCUR);
owner->view()->text->
SetLayout(owner->view(), layout.second);
owner->getToolbar()->combox->
select(owner->view()->
text->cursor.par()->
GetLayout() + 1);
owner->setLayout(layout.second);
owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
owner->view()->setState();
}
@ -1221,7 +1276,7 @@ string LyXFunc::Dispatch(int ac,
break;
case LFUN_DROP_LAYOUTS_CHOICE:
owner->getToolbar()->combox->Show();
owner->getToolbar()->openLayoutList();
break;
case LFUN_LANGUAGE:
@ -1348,7 +1403,11 @@ string LyXFunc::Dispatch(int ac,
break;
case LFUN_MENU_OPEN_BY_NAME:
#ifdef NEW_MENUBAR
owner->getMenubar()->openByName(argument);
#else
owner->getMenus()->openByName(argument);
#endif
break; // RVDK_PATCH_5
case LFUN_SPELLCHECK:
@ -2290,15 +2349,7 @@ string LyXFunc::Dispatch(int ac,
case LFUN_PUSH_TOOLBAR:
{
int nth = strToInt(argument);
if (lyxerr.debugging(Debug::TOOLBAR)) {
lyxerr << "LFUN_PUSH_TOOLBAR: argument = `"
<< argument << "'\n"
<< "LFUN_PUSH_TOOLBAR: nth = `"
<< nth << "'" << endl;
}
if (nth <= 0) {
LyXBell();
setErrorMessage(N_("Push-toolbar needs argument > 0"));
} else {
owner->getToolbar()->push(nth);
@ -2308,7 +2359,7 @@ string LyXFunc::Dispatch(int ac,
case LFUN_ADD_TO_TOOLBAR:
{
if (lyxerr.debugging(Debug::TOOLBAR)) {
if (lyxerr.debugging(Debug::GUI)) {
lyxerr << "LFUN_ADD_TO_TOOLBAR:"
"argument = `" << argument << '\'' << endl;
}
@ -2316,7 +2367,6 @@ string LyXFunc::Dispatch(int ac,
//lyxerr <<string("Argument: ") + argument);
//lyxerr <<string("Tmp : ") + tmp);
if (tmp.empty()) {
LyXBell();
setErrorMessage(N_("Usage: toolbar-add-to <LyX command>"));
} else {
owner->getToolbar()->add(argument, false);

View File

@ -1,8 +1,15 @@
// Generalized simple lexical analizer.
// It can be used for simple syntax parsers, like lyxrc,
// texclass and others to come. [asierra30/03/96]
//
// Copyright 1996 Lyx Team.
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1996-2000 The LyX Team.
*
* Generalized simple lexical analizer.
* It can be used for simple syntax parsers, like lyxrc,
* texclass and others to come. [asierra30/03/96]
*
* ====================================================== */
#include <config.h>

View File

@ -8,6 +8,10 @@
*
* ====================================================== */
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#ifdef HAVE_XOPENIM
@ -22,6 +26,7 @@
#endif
#include <clocale>
#include "lyxlookup.h"
#include "debug.h"
#include "lyxrc.h"

View File

@ -13,6 +13,10 @@
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

View File

@ -47,8 +47,7 @@ extern kb_keymap * toplevel_keymap;
enum LyXRCTags {
RC_BEGINTOOLBAR = 1,
RC_FONT_ENCODING,
RC_FONT_ENCODING = 1,
RC_PRINTER,
RC_PRINT_COMMAND,
RC_PRINTEVENPAGEFLAG,
@ -98,6 +97,7 @@ enum LyXRCTags {
RC_SERVERPIPE,
RC_INPUT,
RC_BINDFILE,
RC_UIFILE,
RC_KBMAP,
RC_KBMAP_PRIMARY,
RC_KBMAP_SECONDARY,
@ -169,7 +169,6 @@ keyword_item lyxrcTags[] = {
{ "\\auto_region_delete", RC_AUTOREGIONDELETE },
{ "\\autosave", RC_AUTOSAVE },
{ "\\backupdir_path", RC_BACKUPDIR_PATH },
{ "\\begin_toolbar", RC_BEGINTOOLBAR },
{ "\\bind", RC_BIND },
{ "\\bind_file", RC_BINDFILE },
{ "\\build_command", RC_BUILD_COMMAND },
@ -257,6 +256,7 @@ keyword_item lyxrcTags[] = {
{ "\\spell_command", RC_SPELL_COMMAND },
{ "\\tempdir_path", RC_TEMPDIRPATH },
{ "\\template_path", RC_TEMPLATEPATH },
{ "\\ui_file", RC_UIFILE },
{ "\\use_alt_language", RC_USE_ALT_LANG },
{ "\\use_escape_chars", RC_USE_ESC_CHARS },
{ "\\use_gui", RC_USE_GUI },
@ -282,6 +282,7 @@ LyXRC::LyXRC()
void LyXRC::setDefaults() {
ui_file = "default";
// Get printer from the environment. If fail, use default "",
// assuming that everything is set up correctly.
printer = GetEnv("PRINTER");
@ -460,10 +461,10 @@ int LyXRC::read(string const & filename)
}
break;
case RC_BEGINTOOLBAR:
// this toolbar should be changed to be a completely
// non gui toolbar. (Lgb)
toolbardefaults.read(lexrc);
case RC_UIFILE:
if (lexrc.next()) {
ui_file = lexrc.GetString();
}
break;
case RC_KBMAP:
@ -1145,8 +1146,8 @@ void LyXRC::output(ostream & os) const
// bindings is not written to the preferences file.
case RC_BINDFILE:
// bind files are not done here.
case RC_BEGINTOOLBAR:
// Toolbar is not written here (yet).
case RC_UIFILE:
os << "\\ui_file \"" << ui_file << "\"\n";
//case RC_SET_COLOR:
// color bindings not written to preference file.
// And we want to be warned about that. (Lgb)

View File

@ -16,7 +16,6 @@
#pragma interface
#endif
#include "ToolbarDefaults.h"
#include "bufferparams.h"
/// This contains the runtime configuration of LyX
@ -38,10 +37,10 @@ public:
///
int ReadBindFile(string const & name = "cua");
///
ToolbarDefaults toolbardefaults;
///
string bind_file;
///
string ui_file;
///
string printer;
///
string print_command;

View File

@ -10,6 +10,10 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "lyxrow.h"

View File

@ -12,6 +12,10 @@
#ifndef LYXROW_H
#define LYXROW_H
#ifdef __GNUG__
#pragma interface
#endif
#include "lyxparagraph.h"
///

View File

@ -12,6 +12,10 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <unistd.h>
#include <fcntl.h>
#include <cstdlib>

View File

@ -1,7 +1,21 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#ifndef SPELLCHECKER_H
#define SPELLCHECKER_H
#ifdef __GNUG__
#pragma interface
#endif
/* These functions are defined in lyx_cb.C */
class BufferView;

View File

@ -9,6 +9,10 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
//#include "DebugStream.h"
#include "debug.h"

View File

@ -12,6 +12,10 @@
#ifndef DEBUGSTREAM_H
#define DEBUGSTREAM_H
#ifdef __GNUG__
#pragma interface
#endif
#include "LOstream.h"
#ifdef TEST_DEBUGSTREAM

View File

@ -11,6 +11,10 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <cerrno>

View File

@ -12,6 +12,10 @@
#ifndef FILE_INFO_H
#define FILE_INFO_H
#ifdef __GNUG__
#pragma interface
#endif
#include <ctime>
#include <unistd.h>

View File

@ -12,6 +12,10 @@
#include <config.h>
#endif
#ifdef __GNUG__
#pragma implementation
#endif
#include "LSubstring.h"

View File

@ -28,6 +28,8 @@ libsupport_la_SOURCES = \
LRegex.h \
LSubstring.C \
LSubstring.h \
StrPool.C \
StrPool.h \
abort.C \
block.h \
chdir.C \

35
src/support/StrPool.C Normal file
View File

@ -0,0 +1,35 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 Jean-Marc Lasgouttes
*
* ======================================================*/
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "StrPool.h"
StrPool::~StrPool()
{
for (Pool::const_iterator cit = pool_.begin() ;
cit != pool_.end() ; ++cit) {
delete[] (*cit);
}
}
char const * StrPool::add(string const & str)
{
int s = str.length();
char * buf = new char [s + 1];
str.copy(buf, s);
buf[s] = '\0';
pool_.push_back(buf);
return buf;
}

34
src/support/StrPool.h Normal file
View File

@ -0,0 +1,34 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 Jean-Marc Lasgouttes
*
* ======================================================*/
#ifndef STRPOOL_H
#define STRPOOL_H
#ifdef __GNUG__
#pragma interface
#endif
#include "LString.h"
#include <vector>
class StrPool {
public:
// delete all the strings that have been allocated by add()
~StrPool();
// Make a copy of the string, and remember it in the pool
char const * add(string const & str);
private:
typedef std::vector<char const *> Pool;
Pool pool_;
};
#endif

View File

@ -1,5 +1,19 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <algorithm>
#include <cctype>
@ -141,7 +155,17 @@ double strToDbl(string const & str)
}
}
///
char lowercase(char c)
{
return tolower(c);
}
///
char uppercase(char c)
{
return toupper(c);
}
string lowercase(string const & a)
{
@ -150,7 +174,7 @@ string lowercase(string const & a)
string::iterator result = tmp.begin();
for (string::iterator first = tmp.begin();
first != tmp.end(); ++first, ++result) {
*result = tolower(*first);
*result = lowercase(*first);
}
//#else
// transform(tmp.begin(), tmp.end(), tmp.begin(), tolower);
@ -166,7 +190,7 @@ string uppercase(string const & a)
string::iterator result = tmp.begin();
for (string::iterator first = tmp.begin();
first != tmp.end(); ++first, ++result) {
*result = toupper(*first);
*result = uppercase(*first);
}
//#else
// transform(tmp.begin(), tmp.end(), tmp.begin(), toupper);

View File

@ -8,6 +8,10 @@
#ifndef LSTRINGS_H
#define LSTRINGS_H
#ifdef __GNUG__
#pragma interface
#endif
#include <cstring>
#include <cctype>
@ -54,6 +58,12 @@ bool isStrDbl(string const & str);
///
double strToDbl(string const & str);
///
char lowercase(char c);
///
char uppercase(char c);
///
string lowercase(string const &);

View File

@ -1,5 +1,19 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <cstdlib>
#include "tex-accent.h"
#include "commandtags.h"

View File

@ -1,8 +1,21 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#ifndef TEX_ACCENT
#define TEX_ACCENT
#ifdef __GNUG__
#pragma interface
#endif
#include "commandtags.h"
/* the names used by TeX and XWindows for deadkeys/accents are not the same

View File

@ -1,4 +1,19 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "tex-strings.h"
// this file should perhaps be split into even smaller parts

View File

@ -1,8 +1,21 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#ifndef TEX_STRINGS
#define TEX_STRINGS
#ifdef __GNUG__
#pragma interface
#endif
// this file should perhaps be split into even smaler parts
///

View File

@ -1,3 +1,19 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "tracer.h"

View File

@ -1,7 +1,21 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#ifndef TRACER_H
#define TRACER_H
#ifdef __GNUG__
#pragma interface
#endif
#include "debug.h"
#include "LString.h"