]> git.lyx.org Git - features.git/commitdiff
Asger's obviously-correct Win32 changes.
authorAngus Leeming <leeming@lyx.org>
Mon, 31 Jan 2005 15:26:40 +0000 (15:26 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 31 Jan 2005 15:26:40 +0000 (15:26 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9556 a592a061-630c-0410-9148-cb99ea01b6c8

12 files changed:
src/ChangeLog
src/frontends/qt2/ChangeLog
src/frontends/qt2/QDialogView.h
src/frontends/qt2/QLPainter.C
src/frontends/qt2/lengthvalidator.h
src/lyxlex_pimpl.h
src/support/ChangeLog
src/support/chdir.C
src/support/getcwd.C
src/support/kill.C
src/support/mkdir.C
src/support/os_win32.h

index d13d25f9f522d783d5609752f677dd9bd3d902be..260b097364f50b30b0f0ab665d2e4b689b84c91b 100644 (file)
@@ -1,3 +1,7 @@
+2005-01-31  Asger Ottar Alstrup  <aalstrup@laerdal.dk>
+
+       * lyxlex_pimpl.h: #include <fstream>.
+
 2005-01-31  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * vc-backend.C (find_file): rewrite to use boost.filesystem
index 70a1e10e9eec64af02fc8d4292f355f5c99b574d..d454b6e5a0e2d0b09fa8e360bb48e88f42006964 100644 (file)
@@ -1,3 +1,12 @@
+2005-01-31  Asger Ottar Alstrup  <aalstrup@laerdal.dk>
+
+       * QDialogView.h (form): add cast for MSVC.
+
+       * QLPainter.C (smllCapsText, text): MSVC doesn't like the use
+       of operator[](i) here, so use at(i) instead.
+
+       * lengthvalidator.h: remove incorrect Q_EXPORT spec.
+
 2005-01-31  Angus Leeming  <leeming@lyx.org>
 
        * QGraphics.[Ch] (slotEdit): unused cruft, so removed.
index 8edd08c2705ec2de705b5d14b604300b99e38adb..cc1e92a10acee587d783b189025aada2e083690e 100644 (file)
@@ -13,6 +13,7 @@
 #define QDIALOGVIEW_H
 
 #include "Dialog.h"
+
 #include <boost/scoped_ptr.hpp>
 
 #include <qapplication.h>
@@ -110,7 +111,11 @@ QView<GUIDialog>::QView(Dialog & p, std::string const & t)
 template <class GUIDialog>
 QDialog * QView<GUIDialog>::form() const
 {
-       return dialog_.get();
+       /* Brain dead MSVC compiler wants to know the class hierarchy at the
+          definition site of the template, rather than the instantation point
+          to downcast correctly. So, rather than including all dialogs to 
+          provide that, we just cast it with the ugly hammer. */
+       return (QDialog *) dialog_.get();
 }
 
 
index 9f5b8a1031e96b105e20cced38b480a64ecd2ad8..958bd459feb2e1ec039f4d90bfe143a1964e54d8 100644 (file)
@@ -202,8 +202,9 @@ void QLPainter::smallCapsText(int x, int y,
        int tmpx = x;
        size_t ls = s.length();
        for (size_t i = 0; i < ls; ++i) {
-               QChar const c = s[i].upper();
-               if (c != s[i]) {
+               // Brain-dead MSVC wants at(i) rather than operator[]
+               QChar const c = s.at(i).upper();
+               if (c != s.at(i)) {
                        qp_->setFont(qsmallfont);
                        qp_->drawText(tmpx, y, c);
                        tmpx += qsmallfontm.width(c);
@@ -229,7 +230,8 @@ void QLPainter::text(int x, int y, char const * s, size_t ls,
 #if QT_VERSION >= 300
        str.setLength(ls);
        for (size_t i = 0; i < ls; ++i)
-               str[i] = QChar(encoding->ucs(s[i]));
+               // Brain-dead MSVC wants at(i) rather than operator[]
+               str.at(i) = QChar(encoding->ucs(s[i]));
        // HACK: QT3 refuses to show single compose characters
        if (ls == 1 && str[0].unicode() >= 0x05b0 && str[0].unicode() <= 0x05c2)
                str = ' ' + str;
index ea457211549860287f5f3228ccab3979852b629f..9f60b9869cd03797b80673e89d7d1d6602c5d717 100644 (file)
@@ -19,7 +19,7 @@
 class QWidget;
 
 
-class Q_EXPORT LengthValidator : public QValidator
+class LengthValidator : public QValidator
 {
        Q_OBJECT
 public:
index 797605dc08f0002405a9e57789ea7509c4282f66..79f4393acef51621bf74b71f86cf0513b947fc12 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <boost/utility.hpp>
 
+#include <fstream>
 #include <istream>
 #include <stack>
 #include <vector>
index 29bfff2cc3b89472ff3b40352a91e9f627007cee..85a02b2a86f7b914a2a44194fc7de26ac49fa0e9 100644 (file)
@@ -1,3 +1,12 @@
+2005-01-31  Asger Ottar Alstrup  <aalstrup@laerdal.dk>
+
+       * chdir.C (chdir):
+       * getcwd.C (l_getcwd):
+       * kill.C (kill):
+       * mkdir.C (mkdir): add Win32 specializations.
+
+       * os_win32.h: remove cruft.
+
 2005-01-31  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * Makefile.am (libsupport_la_SOURCES): remove rmdir.C 
index d9776e9c6e9572ae82226cc3cc2fea07983683fb..6425c860a2185ac16f623fc55e6f7178e49fb691 100644 (file)
 # include <unistd.h>
 #endif
 
+#ifdef _WIN32
+# include <windows.h>
+#endif
+
 int lyx::support::chdir(std::string const & name)
 {
-#ifndef __EMX__
-       return ::chdir(name.c_str());
-#else
+#ifdef __EMX__
        return ::_chdir2(name.c_str());
+#elif defined(_WIN32)
+       return SetCurrentDirectory(name.c_str()) != 0 ? 0 : -1;
+#else
+       return ::chdir(name.c_str());
 #endif
 }
index 47d67fa2743a86f1068c8cd9b5ac2f7f185b7171..f6600974066c355fcfccc4831d43081e20d6cca3 100644 (file)
 # include <unistd.h>
 #endif
 
+#ifdef _WIN32
+# include <windows.h>
+#endif
+
 using boost::scoped_array;
 
 using std::string;
@@ -29,10 +33,13 @@ namespace {
 inline
 char * l_getcwd(char * buffer, size_t size)
 {
-#ifndef __EMX__
-       return ::getcwd(buffer, size);
-#else
+#ifdef __EMX
        return ::_getcwd2(buffer, size);
+#elif defined(_WIN32)
+       GetCurrentDirectory(size, buffer);
+       return buffer;
+#else
+       return ::getcwd(buffer, size);
 #endif
 }
 
index 019c97949ddfa157d47bef6bd2fe3c12eaf4e8dc..3c23a96a9ec97336ce9426c6d52cf35e04521ff5 100644 (file)
 #include <sys/types.h>
 #include <csignal>
 
+#ifdef _WIN32
+#include "debug.h"
+#include "os.h"
+
+#include <windows.h>
+#include <errno.h>
+
+using std::endl;
+#endif //_WIN32
+
 int lyx::support::kill(int pid, int sig)
 {
+#ifdef _WIN32
+       if (pid == (int)GetCurrentProcessId()) {
+               return -(raise(sig));
+       } else {
+               HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
+               if (!hProcess) {
+                       lyxerr << "kill OpenProcess failed!" << endl;
+                       return -1;
+               } else {
+                       if (!TerminateProcess(hProcess, sig)){
+                               lyxerr << "kill process failed!" << endl;
+                               CloseHandle(hProcess);
+                               return -1;
+                       }
+               CloseHandle(hProcess);
+               }
+       }
+       return 0;
+
+#else
        return ::kill(pid, sig);
+#endif
 }
index c590880c30db4c8ea7082d042d588172c68ab0ae..e0be4fd8112605c4c2f0cb4633918c850f7255af 100644 (file)
@@ -18,6 +18,9 @@
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
+#ifdef _WIN32
+# include <Windows.h>
+#endif
 
 int lyx::support::mkdir(std::string const & pathname, unsigned long int mode)
 {
@@ -30,12 +33,12 @@ int lyx::support::mkdir(std::string const & pathname, unsigned long int mode)
        // POSIX
        return ::mkdir(pathname.c_str(), mode_t(mode));
 # endif
-#else
-# if HAVE__MKDIR
+#elif defined(_WIN32)
        // plain Windows 32
-       return ::_mkdir(pathname.c_str());
-# else
-#  error "Don't know how to create a directory on this system."
-# endif
+       return CreateDirectory(pathname.c_str(), 0) != 0 ? 0 : -1;
+#elif HAVE__MKDIR
+       return ::_mkdir(pathname.c_str());
+#else
+#   error "Don't know how to create a directory on this system."
 #endif
 }
index 7ee35d09eabd449493baf6390fff5583ff9eeab2..78ee2ee36b8507375fdf1a7f04439223a1c5fbd1 100644 (file)
@@ -65,16 +65,6 @@ extern "C" {
 #define O_NONBLOCK      0x4000
 inline int fcntl (int, int, ...) {return -1;}
 
-//signal.h
-#define SIGHUP 1
-#define SIGKILL 9
-
-//sys/time.h
-//struct timeval {
-//  long tv_sec;
-//  long tv_usec;
-//};
-
 //unistd.h
 inline int fork () {return -1;}
 #define pipe(a) _pipe(a,0,0)