]> git.lyx.org Git - features.git/commitdiff
make LyX/Mac compile and work better
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 7 Jan 2004 16:40:30 +0000 (16:40 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 7 Jan 2004 16:40:30 +0000 (16:40 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8321 a592a061-630c-0410-9148-cb99ea01b6c8

14 files changed:
ChangeLog
README.MacOSX
lib/ChangeLog
lib/reLyX/reLyX.in
src/frontends/qt2/ChangeLog
src/frontends/qt2/QWorkArea.C
src/frontends/qt2/lyx_gui.C
src/frontends/qt2/qfont_loader.C
src/mathed/ChangeLog
src/mathed/math_symbolinset.C
src/support/ChangeLog
src/support/path_defines.C.in
src/support/tostr.C
src/support/tostr.h

index 57d9010fad17bec1b0b2579758fb6b9e30084886..fcd3a91d966c0894b7adacf2b2a666bf5bb685a5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
+2003-12-15  Ronald Florence <ron@18james.com>
 
+       * README.MacOSX: updated for 1.4.0cvs
+       
 2003-11-18  Angus Leeming  <leeming@lyx.org>
 
        * autogen.sh: accept autoconf 2.58 as a supported version.
index cc7fa4dd18950adb5d957c5b7df1c9f614698c08..9693e48ae817dc071a77e0819bcca7589f454a9f 100644 (file)
@@ -1,56 +1,46 @@
 
-                        Building LyX on Aqua
+                          Building LyX/Mac
 
                  Ronald Florence <ron@18james.com>
 
+   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.
+
+   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".
+
+   1.  Download the GPL-licensed Qt/Mac library source code from
+   <ftp://ftp.lyx.org/pub/lyx/contrib/qt-mac-free-3.1.2.sit>, untar in
+   a convenient directory, cd to the top of the Qt source hierarcy,
+   and:
+
+     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:
+
+     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
 
-   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.
-
-   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:
-
-   % setenv QTDIR `pwd` 
-   % sudo gcc_select 2 
-   % ./configure -static 
-   % make 
-   % sudo gcc_select 3 
-
-   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.
-
-   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.
+   <http://www.18james.com/lyx_on_aqua.html>. 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
index c1947d899f35ee5af67c39e43b1ad86c45276794..3048a66567e66b9fa7875131499ed02e7c1370ae 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-15  Ronald Florence  <ron@18james.com>
+
+       * reLyX/reLyX.in: search for library in
+       "$dir/../Resources/LyX/reLyX" for LyX/Mac
+
 2004-01-07  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * layouts/siamltex.layout: fix layout name for Definition
index 264b6e176dde9263a750b7ad7135f4a85d221a23..44a526de44f2f0202dbd725e9688c00fcfb1c193 100644 (file)
@@ -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
index 0f19da702cb711e926f159896dd7951ed3756237..472872f95542c9bdf28110743d525aa6f773a1cb 100644 (file)
@@ -1,3 +1,12 @@
+2003-12-15  Ronald Florence <ron@18james.com>
+
+       * 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  <leeming@lyx.org>
 
        * FileDialog_private.C (c-tor): invoke convert_brace_glob to convert
index 5d70abb7795dd7275e6e3eefe23793135f2cad26..d987ea63abe0fbce4c19acb645febd965aa17d48 100644 (file)
 #include <X11/Xlib.h>
 #endif
 
+#ifdef Q_WS_MACX
+#include <Carbon/Carbon.h>
+#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;
index d93936aea69f998d764746bd665d3944f145cc33..4b95e12f151491a598036d6dc33bac92f1e46292 100644 (file)
 #include "socket_callback.h"
 #include "lcolorcache.h"
 
+#ifdef Q_WS_MACX
+#include <Carbon/Carbon.h>
+#endif
+
 #include <qapplication.h>
 #include <qpaintdevicemetrics.h>
 
@@ -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;
index 3686d9dd0ef40cc2cff1cb326de671dba19f59a1..8fb2f8bc75392ce618b11e7fd63fe56d2a333df5 100644 (file)
 #ifdef Q_WS_X11
 #include <qwidget.h>
 #include <X11/Xlib.h>
-#include "support/systemcall.h"
-#include "support/filetools.h"
 #include <algorithm>
 #endif
+#include "support/systemcall.h"
+#include "support/filetools.h"
 
 using lyx::support::contains;
 using lyx::support::LibFileSearch;
index e3661b92d2c5a6f0603e8dc680f23dc2aef84fbe..f41ca6e5c3b6453ee77fa8bf2a029fde6ea5918d 100644 (file)
@@ -1,3 +1,6 @@
+2003-12-15  Ronald Florence <ron@18james.com>
+
+       * math_symbolinset.C: fixed "ugly" patch for Qt/Mac fonts.
 
 2003-12-15  André Pönitz  <poenitz@gmx.net>
 
index b7cb9d8c40c81b470c582e1eabbc7170e0de1cf7..6657899b3f06c6fd5aaff51b3715bf9c9150a6f6 100644 (file)
@@ -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_;
index 80f539b16ebe6d898d6d97e5b110d3daa543d931..ba5e14a1425a4db55db3b82b539cefe03063ae9c 100644 (file)
@@ -1,3 +1,10 @@
+2003-12-14  Ronald Florence <ron@18james.com>
+
+       * 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  <leeming@lyx.org>
 
        * globbing.C (glob): compilation fix for cygwin.
index 7d46a8576d0b18a56f85c88246c6a789ee8c666d..b746ec738731280bd21345cdfb926e66c8d56793 100644 (file)
@@ -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 <path of binary>/TOP_SRCDIR/lib
-       // 4) <path of binary>/../share/<name of binary>/
-       // 4a) repeat 4 after following the Symlink if <path of
+       // 4) <path of binary>/../Resources/<name of binary>/  [for LyX/Mac]
+       // 5) <path of binary>/../share/<name of binary>/
+       // 5a) repeat 4 after following the Symlink if <path of
        //     binary> 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
        //
index 6803d94b9e50c54168827d22762e11517b2e016b..da5b7aaa8d98a0beada6ccb9722fccd569dc5c09 100644 (file)
@@ -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();
+}
index a6a9543fb1f2b8adf1d6ff72e77a722b3c3757dd..2e362d91999ab3957d23d8e91cf74f7f89df5c1b 100644 (file)
@@ -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