Init.cpp

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 Chris Cannam.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #include <QApplication>
00017 #include <QFont>
00018 
00019 #include <iostream>
00020 
00021 #ifdef Q_WS_X11
00022 #include <X11/Xlib.h>
00023 #include <X11/Xutil.h>
00024 #include <X11/Xatom.h>
00025 #include <X11/SM/SMlib.h>
00026 
00027 static int handle_x11_error(Display *dpy, XErrorEvent *err)
00028 {
00029     char errstr[256];
00030     XGetErrorText(dpy, err->error_code, errstr, 256);
00031     if (err->error_code != BadWindow) {
00032         std::cerr << "Sonic Visualiser: X Error: "
00033                   << errstr << " " << int(err->error_code)
00034                   << "\nin major opcode:  "
00035                   << int(err->request_code) << std::endl;
00036     }
00037     return 0;
00038 }
00039 #endif
00040 
00041 #ifdef Q_WS_WIN32
00042 
00043 #include <fcntl.h>
00044 #include <windows.h>
00045 
00046 // Set default file open mode to binary
00047 //#undef _fmode
00048 //int _fmode = _O_BINARY;
00049 
00050 void redirectStderr()
00051 {
00052     HANDLE stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
00053     if (!stderrHandle) return;
00054 
00055     AllocConsole();
00056 
00057     CONSOLE_SCREEN_BUFFER_INFO info;
00058     GetConsoleScreenBufferInfo(stderrHandle, &info);
00059     info.dwSize.Y = 1000;
00060     SetConsoleScreenBufferSize(stderrHandle, info.dwSize);
00061 
00062     int h = _open_osfhandle((long)stderrHandle, _O_TEXT);
00063     if (h) {
00064         FILE *fd = _fdopen(h, "w");
00065         if (fd) {
00066             *stderr = *fd;
00067             setvbuf(stderr, NULL, _IONBF, 0);
00068         }
00069     }
00070 }
00071 
00072 #endif
00073 
00074 extern void svSystemSpecificInitialisation()
00075 {
00076 #ifdef Q_WS_X11
00077     XSetErrorHandler(handle_x11_error);
00078 #endif
00079 
00080 #ifdef Q_WS_WIN32
00081     redirectStderr();
00082 //    QFont fn = qApp->font();
00083 //    fn.setFamily("Tahoma");
00084 //    qApp->setFont(fn);
00085 #else
00086 #ifdef Q_WS_X11
00087 //    QFont fn = qApp->font();
00088 //    fn.setPointSize(fn.pointSize() + 2);
00089 //    qApp->setFont(fn);
00090 #endif
00091 #endif
00092 }
00093 
00094 
00095 

Generated on Wed Feb 20 15:45:26 2008 for SonicVisualiser by  doxygen 1.5.1