diff --git a/ChangeLog b/ChangeLog index 57d9010fad..fcd3a91d96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ +2003-12-15 Ronald Florence + * README.MacOSX: updated for 1.4.0cvs + 2003-11-18 Angus Leeming * autogen.sh: accept autoconf 2.58 as a supported version. diff --git a/README.MacOSX b/README.MacOSX index cc7fa4dd18..9693e48ae8 100644 --- a/README.MacOSX +++ b/README.MacOSX @@ -1,56 +1,46 @@ - Building LyX on Aqua + Building LyX/Mac Ronald Florence + LyX/Mac is built from the LyX source, the GPL-licensed Trolltech + Qt/Mac library, and a custom application bundle. Qt-3.2.3 and + later versions align the button labels in the Math Panel better + under MacOS-10.3, but present other problems. Qt-3.1.2 as patched + here is fully functional. - Make sure you have installed the MacOSX development tools. The - procedure described here builds LyX-1.3.3 linked with a static Qt - library and installs the LyX and Start-LyX applications. + You will need the MacOSX development tools. The procedure + described here builds LyX linked with a static Qt library. If you + are using the tcsh shell, change the "export VAR=value" statements + to "setenv VAR value". - Download the GPL-licensed MacOSX Qt 3.1.2 library source code from - ftp://ftp.lyx.org/pub/lyx/contrib/qt-mac-free-3.1.2.sit. Untar the - .tar.gz file in a convenient directory in /usr/local/src or - /usr/local. Then open a terminal, cd to the Qt source directory, - apply the patch development/MacOSX/qt.patch, and: + 1. Download the GPL-licensed Qt/Mac library source code from + , untar in + a convenient directory, cd to the top of the Qt source hierarcy, + and: - % setenv QTDIR `pwd` - % sudo gcc_select 2 - % ./configure -static - % make - % sudo gcc_select 3 + export QTDIR=`pwd` + patch -p0 < LYX-SOURCE-DIRECTORY/development/MacOSX/qt.patch + sudo gcc_select 3.3 + ./configure -static [for Panther, use "./configure -static -lresolv"] + make + + 2. Using the same terminal session, cd to the top of the LyX + source hierarchy, and: - To avoid this compiler-changing procedure in the future, you might - want to write Apple to urge that they fix bug ID #3162425 so the - default gcc-3.1 compiler can be used to compile LyX-1.3.x on MacOSX. + export LDFLAGS="-framework Carbon -framework OpenGL -framework AGL -framework QuickTime -lz" + ./configure --with-frontend=qt --without-x --datadir=/Applications/LyX.app/Contents/Resources --bindir=/Applications/LyX.app/Contents/MacOS --mandir=/Applications/LyX.app/Contents/Resources/man + make + cp -R development/MacOSX/LyX.app /Applications + make install + rm /Applications/LyX.app/Contents/Resources/LyX/images/lyx.xpm - Using the same terminal session you used to build the Qt libraries - (or if you start a new terminal, set the QTDIR environment variable - as above), cd to the top of the LyX source hierarchy. Then: - - % setenv CXX g++2 - % setenv LDFLAGS "-framework Carbon -framework OpenGL -framework AGL -framew -ork QuickTime -lz" - % ./configure --with-frontend=qt --without-x --datadir=/Applications/LyX.app -/Contents/Resources --bindir=/Applications/LyX.app/Contents/MacOS --mandir=/App -lications/LyX.app/Contents/Resources/man - % make - - Download the LyX Framework at - http://www.18james.com/code/LyX.tar.gz and run the installer. Then - in the terminal where you built LyX: - - % make install - % rm /Applications/LyX.app/Contents/Resources/LyX/images/lyx.xpm For information on configuring LyX/Mac, please see the howto at - http://www.18james.com/lyx_on_aqua.html . The binary installation - of LyX on Aqua sets the PATH in ~/.MacOS/environment.plist, - installs the LyX math fonts, configures LyX to use the reLyX and - noweb2lyx commands in the application package and to use system - defaults for viewers, sets up the lyxpipe for Start-LyX, and - optionally installs latex-preview; you will need to do this - configuration manually if you build LyX/Mac yourself. + . The binary installation + of LyX/Mac installs LaTeX fonts and packages, and provides + additional functionality including inverse DVI search with some + DVI-previewers. The information on this page is believed to be accurate, has been used successfully on many systems and sites, and has benefited from diff --git a/lib/ChangeLog b/lib/ChangeLog index c1947d899f..3048a66567 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2003-12-15 Ronald Florence + + * reLyX/reLyX.in: search for library in + "$dir/../Resources/LyX/reLyX" for LyX/Mac + 2004-01-07 Jean-Marc Lasgouttes * layouts/siamltex.layout: fix layout name for Definition diff --git a/lib/reLyX/reLyX.in b/lib/reLyX/reLyX.in index 264b6e176d..44a526de44 100644 --- a/lib/reLyX/reLyX.in +++ b/lib/reLyX/reLyX.in @@ -44,7 +44,9 @@ push @maybe_dir, "$dir/$srcdir"; if (exists $ENV{LYX_DIR_14x}) { push @maybe_dir, "$ENV{LYX_DIR_14x}/reLyX"}; # case 4: e.g., reLyX in /opt/bin, $mainscript in /opt/share/lyx/reLyX push @maybe_dir, "$dir/../share/$lyxname/reLyX"; # case 4 -# case 5: configure figured out where $mainscript is +# case 5: LyX/Mac -- reLyX is in a MacOS X application bundle +push @maybe_dir, "$dir/../Resources/LyX/reLyX"; # case 5 +# case 6: configure figured out where $mainscript is push @maybe_dir, "$lyxdir/reLyX"; # Decide which one is the real directory, based on the existence of diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 0f19da702c..472872f955 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,12 @@ +2003-12-15 Ronald Florence + + * qfont_loader.C: fixed headers to compile w/o X11 + + * QWorkArea.C (checkAppleEventForMissingParams) + (handleOpenDocuments): add support for OpenDocuments apple event + + * lyx_gui.C (macEventFilter): handle apple events + 2004-01-05 Angus Leeming * FileDialog_private.C (c-tor): invoke convert_brace_glob to convert diff --git a/src/frontends/qt2/QWorkArea.C b/src/frontends/qt2/QWorkArea.C index 5d70abb779..d987ea63ab 100644 --- a/src/frontends/qt2/QWorkArea.C +++ b/src/frontends/qt2/QWorkArea.C @@ -28,9 +28,16 @@ #include #endif +#ifdef Q_WS_MACX +#include +#endif + using std::endl; using std::string; +namespace { +QWorkArea const * wa_ptr = 0; +} QWorkArea::QWorkArea(int, int, int, int) : WorkArea(), QWidget(qApp->mainWidget()), painter_(*this) @@ -51,6 +58,9 @@ QWorkArea::QWorkArea(int, int, int, int) vl->addWidget(content_, 5); vl->addWidget(scrollbar_, 0); +#ifdef Q_WS_MACX + wa_ptr = this; +#endif show(); } @@ -75,10 +85,6 @@ void QWorkArea::setScrollbarParams(int h, int pos, int line_h) scrollbar_->setPageStep(height()); } -namespace { -QWorkArea const * wa_ptr = 0; -} - #ifdef Q_WS_X11 bool lyxX11EventFilter(XEvent * xev) { @@ -98,6 +104,72 @@ bool lyxX11EventFilter(XEvent * xev) } #endif +#ifdef Q_WS_MACX +namespace{ +OSErr checkAppleEventForMissingParams(const AppleEvent& theAppleEvent) + { + DescType returnedType; + Size actualSize; + OSErr err = AEGetAttributePtr(&theAppleEvent, keyMissedKeywordAttr, + typeWildCard, &returnedType, nil, 0, + &actualSize); + switch (err) { + case errAEDescNotFound: + return noErr; + case noErr: + return errAEEventNotHandled; + default: + return err; + } + } +} + +pascal OSErr handleOpenDocuments(const AppleEvent* inEvent, + AppleEvent* /*reply*/, long /*refCon*/) +{ + QString s_arg; + AEDescList documentList; + OSErr err = AEGetParamDesc(inEvent, keyDirectObject, typeAEList, + &documentList); + if (err != noErr) + return err; + + err = checkAppleEventForMissingParams(*inEvent); + if (err == noErr) { + long documentCount; + err = AECountItems(&documentList, &documentCount); + for (long documentIndex = 1; + err == noErr && documentIndex <= documentCount; + documentIndex++) { + DescType returnedType; + Size actualSize; + AEKeyword keyword; + FSRef ref; + char qstr_buf[1024]; + err = AESizeOfNthItem(&documentList, documentIndex, + &returnedType, &actualSize); + if (err == noErr) { + err = AEGetNthPtr(&documentList, documentIndex, + typeFSRef, &keyword, + &returnedType, (Ptr)&ref, + sizeof(FSRef), &actualSize); + if (err == noErr) { + FSRefMakePath(&ref, (UInt8*)qstr_buf, + 1024); + s_arg=QString::fromUtf8(qstr_buf); + wa_ptr->dispatch( + FuncRequest(LFUN_FILE_OPEN, + fromqstr(s_arg))); + break; + } + } + } // for ... + } + AEDisposeDesc(&documentList); + return err; +} +#endif // Q_WS_MACX + void QWorkArea::haveSelection(bool own) const { wa_ptr = this; diff --git a/src/frontends/qt2/lyx_gui.C b/src/frontends/qt2/lyx_gui.C index d93936aea6..4b95e12f15 100644 --- a/src/frontends/qt2/lyx_gui.C +++ b/src/frontends/qt2/lyx_gui.C @@ -43,6 +43,10 @@ #include "socket_callback.h" #include "lcolorcache.h" +#ifdef Q_WS_MACX +#include +#endif + #include #include @@ -86,6 +90,12 @@ extern void initEncodings(); extern bool lyxX11EventFilter(XEvent * xev); #endif +#ifdef Q_WS_MACX +extern bool macEventFilter(EventRef event); +extern pascal OSErr +handleOpenDocuments(const AppleEvent* inEvent, AppleEvent* /*reply*/, + long /*refCon*/); +#endif class LQApplication : public QApplication { @@ -95,17 +105,42 @@ public: #ifdef Q_WS_X11 bool x11EventFilter (XEvent * ev) { return lyxX11EventFilter(ev); } #endif +#ifdef Q_WS_MACX + bool macEventFilter(EventRef event); +#endif }; LQApplication::LQApplication(int & argc, char ** argv) : QApplication(argc, argv) -{} +{ +#ifdef Q_WS_MACX + AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, + NewAEEventHandlerUPP(handleOpenDocuments), + 0, false); +#endif +} LQApplication::~LQApplication() {} + +#ifdef Q_WS_MACX +bool LQApplication::macEventFilter(EventRef event) +{ + if (GetEventClass(event) == kEventClassAppleEvent) { + EventRecord eventrec; + ConvertEventRefToEventRecord(event, &eventrec); + AEProcessAppleEvent(&eventrec); + + return false; + } + return false; +} +#endif + + namespace lyx_gui { bool use_gui = true; diff --git a/src/frontends/qt2/qfont_loader.C b/src/frontends/qt2/qfont_loader.C index 3686d9dd0e..8fb2f8bc75 100644 --- a/src/frontends/qt2/qfont_loader.C +++ b/src/frontends/qt2/qfont_loader.C @@ -26,10 +26,10 @@ #ifdef Q_WS_X11 #include #include -#include "support/systemcall.h" -#include "support/filetools.h" #include #endif +#include "support/systemcall.h" +#include "support/filetools.h" using lyx::support::contains; using lyx::support::LibFileSearch; diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index e3661b92d2..f41ca6e5c3 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,6 @@ +2003-12-15 Ronald Florence + + * math_symbolinset.C: fixed "ugly" patch for Qt/Mac fonts. 2003-12-15 André Pönitz diff --git a/src/mathed/math_symbolinset.C b/src/mathed/math_symbolinset.C index b7cb9d8c40..6657899b3f 100644 --- a/src/mathed/math_symbolinset.C +++ b/src/mathed/math_symbolinset.C @@ -65,10 +65,10 @@ void MathSymbolInset::metrics(MetricsInfo & mi, Dimension & dim) const // correct height for broken cmex and wasy font #if defined(__APPLE__) && defined(__GNUC__) if (sym_->inset == "cmex") { - h_ = 4 * dim_.des / 5; - dim_.asc += 0*h_; - dim_.des -= h_; - h_ = dim_.asc; + h_ = 4 * dim.des / 5; + dim.asc += 0*h_; + dim.des -= h_; + h_ = dim.asc; } else if (sym_->inset == "wasy") { h_ = 4 * dim.des / 5; dim.asc += h_; diff --git a/src/support/ChangeLog b/src/support/ChangeLog index 80f539b16e..ba5e14a142 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,10 @@ +2003-12-14 Ronald Florence + + * tostr.[hC]: added tostr(long unsigned int i). + + * path_defines.C.in: determine system directory and set PATH for + relocatable LyX/Mac bundle. + 2004-01-06 Angus Leeming * globbing.C (glob): compilation fix for cygwin. diff --git a/src/support/path_defines.C.in b/src/support/path_defines.C.in index 7d46a8576d..b746ec7387 100644 --- a/src/support/path_defines.C.in +++ b/src/support/path_defines.C.in @@ -23,6 +23,7 @@ #include "filetools.h" #include "lstrings.h" #include "os.h" +#include "lyxlib.h" using std::string; using std::endl; @@ -166,10 +167,11 @@ bool setLyxPaths() // 1) -sysdir command line parameter // 2) LYX_DIR_14x environment variable // 3) Maybe /TOP_SRCDIR/lib - // 4) /../share// - // 4a) repeat 4 after following the Symlink if /../Resources// [for LyX/Mac] + // 5) /../share// + // 5a) repeat 4 after following the Symlink if is a symbolic link. - // 5) hardcoded lyx_dir + // 6) hardcoded lyx_dir // The directory is checked for the presence of the file // "chkconfig.ltx", and if that is present, the directory // is accepted as the system directory. @@ -187,6 +189,10 @@ bool setLyxPaths() searchpath += lyxdir + ';'; } + // Path of binary/../Resources/ + searchpath += NormalizePath(AddPath(binpath, "../Resources/") + + OnlyFilename(binname)) + ';'; + string fullbinpath = binpath; FileInfo file(fullbinname, true); if (file.isLink()) { @@ -281,6 +287,24 @@ bool setLyxPaths() lyxerr[Debug::INIT] << "System directory: '" << system_lyxdir_ << '\'' << endl; + // + // Set PATH for LyX/Mac + // LyX/Mac is a relocatable application bundle; here we add to + // the PATH so it can find binaries like reLyX inside its own + // application bundle, and also append PATH elements that it + // needs to run latex, previewers, etc. + // + + if (system_lyxdir_ == NormalizePath(AddPath(binpath, "../Resources/") + + OnlyFilename(binname))) { + const string newpath = GetEnv("PATH") + ":" + binpath + + ":/sw/bin:/usr/local/bin" + + ":/usr/local/teTeX/bin/powerpc-apple-darwin-current"; + lyx::support::putenv("PATH", newpath); + lyxerr[Debug::INIT] << "Running from LyX/Mac bundle. " + "Setting PATH to: " << GetEnv("PATH") << endl; + } + // // Determine user lyx-dir // diff --git a/src/support/tostr.C b/src/support/tostr.C index 6803d94b9e..da5b7aaa8d 100644 --- a/src/support/tostr.C +++ b/src/support/tostr.C @@ -58,3 +58,11 @@ string const tostr(string const & s) { return s; } + + +string const tostr(long unsigned int i) +{ + ostringstream os; + os << i; + return os.str(); +} diff --git a/src/support/tostr.h b/src/support/tostr.h index a6a9543fb1..2e362d9199 100644 --- a/src/support/tostr.h +++ b/src/support/tostr.h @@ -29,5 +29,7 @@ std::string const tostr(long int); std::string const tostr(double); /// std::string const tostr(std::string const & s); +/// +std::string const tostr(long unsigned int); #endif