diff --git a/build/win32/platform_specific_code/juce_win32_DirectSound.cpp b/build/win32/platform_specific_code/juce_win32_DirectSound.cpp index 2ee8852ca0..dec1590c91 100644 --- a/build/win32/platform_specific_code/juce_win32_DirectSound.cpp +++ b/build/win32/platform_specific_code/juce_win32_DirectSound.cpp @@ -255,11 +255,6 @@ DSOUND_FUNCTION (DirectSoundCaptureCreate, (const GUID*, IDirectSoundCapture**, DSOUND_FUNCTION (DirectSoundEnumerateW, (LPDSENUMCALLBACKW, LPVOID)) DSOUND_FUNCTION (DirectSoundCaptureEnumerateW, (LPDSENUMCALLBACKW, LPVOID)) -#if JUCE_ENABLE_WIN98_COMPATIBILITY - DSOUND_FUNCTION (DirectSoundEnumerateA, (LPDSENUMCALLBACKA, LPVOID)) - DSOUND_FUNCTION (DirectSoundCaptureEnumerateA, (LPDSENUMCALLBACKA, LPVOID)) -#endif - static void initialiseDSoundFunctions() { if (dsDirectSoundCreate == 0) @@ -270,11 +265,6 @@ static void initialiseDSoundFunctions() DSOUND_FUNCTION_LOAD (DirectSoundCaptureCreate) DSOUND_FUNCTION_LOAD (DirectSoundEnumerateW) DSOUND_FUNCTION_LOAD (DirectSoundCaptureEnumerateW) - -#if JUCE_ENABLE_WIN98_COMPATIBILITY - DSOUND_FUNCTION_LOAD (DirectSoundEnumerateA) - DSOUND_FUNCTION_LOAD (DirectSoundCaptureEnumerateA) -#endif } } @@ -1460,13 +1450,6 @@ public: dsDirectSoundEnumerateW (outputEnumProcW, this); dsDirectSoundCaptureEnumerateW (inputEnumProcW, this); } -#if JUCE_ENABLE_WIN98_COMPATIBILITY - else if (dsDirectSoundEnumerateA != 0) - { - dsDirectSoundEnumerateA (outputEnumProcA, this); - dsDirectSoundCaptureEnumerateA (inputEnumProcA, this); - } -#endif } const StringArray getDeviceNames (const bool preferInputNames) const diff --git a/build/win32/platform_specific_code/juce_win32_FileChooser.cpp b/build/win32/platform_specific_code/juce_win32_FileChooser.cpp index ff660a8fa7..131f8102a1 100644 --- a/build/win32/platform_specific_code/juce_win32_FileChooser.cpp +++ b/build/win32/platform_specific_code/juce_win32_FileChooser.cpp @@ -49,33 +49,6 @@ BEGIN_JUCE_NAMESPACE #pragma warning (pop) #endif -//============================================================================== -#if JUCE_ENABLE_WIN98_COMPATIBILITY - UNICODE_FUNCTION (SHBrowseForFolderW, LPITEMIDLIST, (LPBROWSEINFOW)) - UNICODE_FUNCTION (SHGetPathFromIDListW, BOOL, (LPCITEMIDLIST, LPWSTR)) - UNICODE_FUNCTION (GetSaveFileNameW, BOOL, (LPOPENFILENAMEW)) - UNICODE_FUNCTION (GetOpenFileNameW, BOOL, (LPOPENFILENAMEW)) - - static void juce_initialiseUnicodeFileBrowserFunctions() - { - static bool initialised = false; - - if (! initialised) - { - initialised = true; - - HMODULE h = LoadLibraryA ("shell32.dll"); - UNICODE_FUNCTION_LOAD (SHBrowseForFolderW) - UNICODE_FUNCTION_LOAD (SHGetPathFromIDListW) - - h = LoadLibraryA ("comdlg32.dll"); - UNICODE_FUNCTION_LOAD (GetSaveFileNameW) - UNICODE_FUNCTION_LOAD (GetOpenFileNameW) - } - } -#endif - - //============================================================================== static const void* defaultDirPath = 0; static String returnedString; // need this to get non-existent pathnames from the directory chooser @@ -98,13 +71,7 @@ static int CALLBACK browseCallbackProc (HWND hWnd, UINT msg, LPARAM lParam, LPAR { if (msg == BFFM_INITIALIZED) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - SendMessage (hWnd, (wSHBrowseForFolderW != 0) ? BFFM_SETSELECTIONW - : BFFM_SETSELECTIONA, - TRUE, (LPARAM) defaultDirPath); -#else SendMessage (hWnd, BFFM_SETSELECTIONW, TRUE, (LPARAM) defaultDirPath); -#endif } else if (msg == BFFM_VALIDATEFAILEDW) { @@ -162,16 +129,7 @@ static UINT_PTR CALLBACK openCallback (HWND hdlg, UINT uiMsg, WPARAM /*wParam*/, path[0] = 0; CommDlg_OpenSave_GetFilePath (GetParent (hdlg), (LPARAM) &path, MAX_PATH); -#if JUCE_ENABLE_WIN98_COMPATIBILITY - String fn; - - if (wGetOpenFileNameW != 0) - fn = (const WCHAR*) path; - else - fn = path; -#else const String fn ((const WCHAR*) path); -#endif comp->selectedFileChanged (File (fn)); } @@ -216,10 +174,6 @@ void FileChooser::showPlatformDialog (OwnedArray& results, bool selectMultipleFiles, FilePreviewComponent* extraInfoComponent) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - juce_initialiseUnicodeFileBrowserFunctions(); -#endif - const int numCharsAvailable = 32768; MemoryBlock filenameSpace ((numCharsAvailable + 1) * sizeof (WCHAR), true); WCHAR* const fname = (WCHAR*) filenameSpace.getData(); @@ -250,14 +204,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, } else { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wSHBrowseForFolderW != 0) - currentFileOrDirectory.getFileName().copyToBuffer (fname, numCharsAvailable); - else - currentFileOrDirectory.getFileName().copyToBuffer ((char*) fname, numCharsAvailable); -#else currentFileOrDirectory.getFileName().copyToBuffer (fname, numCharsAvailable); -#endif initialDir = currentFileOrDirectory.getParentDirectory().getFullPathName(); } @@ -273,60 +220,10 @@ void FileChooser::showPlatformDialog (OwnedArray& results, LPITEMIDLIST list = 0; filenameSpace.fillWith (0); -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wSHBrowseForFolderW != 0) - { - BROWSEINFOW bi; - zerostruct (bi); - - bi.hwndOwner = (HWND) w.getWindowHandle(); - bi.pszDisplayName = fname; - bi.lpszTitle = title; - bi.lpfn = browseCallbackProc; -#ifdef BIF_USENEWUI - bi.ulFlags = BIF_USENEWUI | BIF_VALIDATE; -#else - bi.ulFlags = 0x50; -#endif - defaultDirPath = (const WCHAR*) initialDir; - - list = wSHBrowseForFolderW (&bi); - - if (! wSHGetPathFromIDListW (list, fname)) - { - fname[0] = 0; - returnedString = String::empty; - } - } - else { BROWSEINFO bi; zerostruct (bi); - bi.hwndOwner = (HWND) w.getWindowHandle(); - bi.pszDisplayName = (TCHAR*) fname; - bi.lpszTitle = title; - bi.lpfn = browseCallbackProc; -#ifdef BIF_USENEWUI - bi.ulFlags = BIF_USENEWUI | BIF_VALIDATE; -#else - bi.ulFlags = 0x50; -#endif - defaultDirPath = (const char*) initialDir; - - list = SHBrowseForFolder (&bi); - - if (! SHGetPathFromIDList (list, (char*) fname)) - { - fname[0] = 0; - returnedString = String::empty; - } - } -#else - { - BROWSEINFOW bi; - zerostruct (bi); - bi.hwndOwner = (HWND) w.getWindowHandle(); bi.pszDisplayName = fname; bi.lpszTitle = title; @@ -338,7 +235,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, #endif defaultDirPath = (const WCHAR*) initialDir; - list = SHBrowseForFolderW (&bi); + list = SHBrowseForFolder (&bi); if (! SHGetPathFromIDListW (list, fname)) { @@ -346,7 +243,6 @@ void FileChooser::showPlatformDialog (OwnedArray& results, returnedString = String::empty; } } -#endif LPMALLOC al; if (list != 0 && SUCCEEDED (SHGetMalloc (&al))) @@ -356,16 +252,7 @@ void FileChooser::showPlatformDialog (OwnedArray& results, if (returnedString.isNotEmpty()) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - String stringFName; - - if (wSHBrowseForFolderW != 0) - stringFName = fname; - else - stringFName = (char*) fname; -#else const String stringFName (fname); -#endif results.add (new File (File (stringFName).getSiblingFile (returnedString))); returnedString = String::empty; @@ -396,8 +283,6 @@ void FileChooser::showPlatformDialog (OwnedArray& results, currentExtraFileWin->enterModalState(); } -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wGetSaveFileNameW != 0) { WCHAR filters [1024]; zeromem (filters, sizeof (filters)); @@ -422,49 +307,6 @@ void FileChooser::showPlatformDialog (OwnedArray& results, of.lpstrTitle = title; of.Flags = flags; - if (extraInfoComponent != 0) - of.lpfnHook = &openCallback; - - if (isSaveDialogue) - { - if (! wGetSaveFileNameW (&of)) - fname[0] = 0; - else - fnameIdx = of.nFileOffset; - } - else - { - if (! wGetOpenFileNameW (&of)) - fname[0] = 0; - else - fnameIdx = of.nFileOffset; - } - } - else - { - TCHAR filters [1024]; - zeromem (filters, sizeof (filters)); - filter.copyToBuffer (filters, 1024); - filter.copyToBuffer (filters + filter.length() + 1, - 1022 - filter.length()); - - OPENFILENAME of; - zerostruct (of); - -#ifdef OPENFILENAME_SIZE_VERSION_400 - of.lStructSize = OPENFILENAME_SIZE_VERSION_400; -#else - of.lStructSize = sizeof (of); -#endif - of.hwndOwner = (HWND) w.getWindowHandle(); - of.lpstrFilter = filters; - of.nFilterIndex = 1; - of.lpstrFile = (TCHAR*) fname; - of.nMaxFile = numCharsAvailable; - of.lpstrInitialDir = initialDir; - of.lpstrTitle = title; - of.Flags = flags; - if (extraInfoComponent != 0) of.lpfnHook = &openCallback; @@ -483,50 +325,6 @@ void FileChooser::showPlatformDialog (OwnedArray& results, fnameIdx = of.nFileOffset; } } -#else - { - WCHAR filters [1024]; - zeromem (filters, sizeof (filters)); - filter.copyToBuffer (filters, 1024); - filter.copyToBuffer (filters + filter.length() + 1, - 1022 - filter.length()); - - OPENFILENAMEW of; - zerostruct (of); - -#ifdef OPENFILENAME_SIZE_VERSION_400W - of.lStructSize = OPENFILENAME_SIZE_VERSION_400W; -#else - of.lStructSize = sizeof (of); -#endif - of.hwndOwner = (HWND) w.getWindowHandle(); - of.lpstrFilter = filters; - of.nFilterIndex = 1; - of.lpstrFile = fname; - of.nMaxFile = numCharsAvailable; - of.lpstrInitialDir = initialDir; - of.lpstrTitle = title; - of.Flags = flags; - - if (extraInfoComponent != 0) - of.lpfnHook = &openCallback; - - if (isSaveDialogue) - { - if (! GetSaveFileNameW (&of)) - fname[0] = 0; - else - fnameIdx = of.nFileOffset; - } - else - { - if (! GetOpenFileNameW (&of)) - fname[0] = 0; - else - fnameIdx = of.nFileOffset; - } - } -#endif } } #if JUCE_CATCH_UNHANDLED_EXCEPTIONS @@ -538,51 +336,23 @@ void FileChooser::showPlatformDialog (OwnedArray& results, deleteAndZero (currentExtraFileWin); -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wGetSaveFileNameW != 0) - { -#endif - const WCHAR* const files = fname; + const WCHAR* const files = fname; - if (selectMultipleFiles && fnameIdx > 0 && files [fnameIdx - 1] == 0) - { - const WCHAR* filename = files + fnameIdx; + if (selectMultipleFiles && fnameIdx > 0 && files [fnameIdx - 1] == 0) + { + const WCHAR* filename = files + fnameIdx; - while (*filename != 0) - { - const String filepath (String (files) + T("\\") + String (filename)); - results.add (new File (filepath)); - filename += CharacterFunctions::length (filename) + 1; - } - } - else if (files[0] != 0) + while (*filename != 0) { - results.add (new File (files)); + const String filepath (String (files) + T("\\") + String (filename)); + results.add (new File (filepath)); + filename += CharacterFunctions::length (filename) + 1; } - -#if JUCE_ENABLE_WIN98_COMPATIBILITY } - else + else if (files[0] != 0) { - const char* const files = (const char*) fname; - - if (selectMultipleFiles && fnameIdx > 0 && files [fnameIdx - 1] == 0) - { - const char* filename = files + fnameIdx; - - while (*filename != 0) - { - const String filepath (String (files) + T("\\") + String (filename)); - results.add (new File (filepath)); - filename += CharacterFunctions::length (filename) + 1; - } - } - else if (files[0] != 0) - { - results.add (new File (files)); - } + results.add (new File (files)); } -#endif } END_JUCE_NAMESPACE diff --git a/build/win32/platform_specific_code/juce_win32_Files.cpp b/build/win32/platform_specific_code/juce_win32_Files.cpp index 5bc03db03e..1a79dc75b9 100644 --- a/build/win32/platform_specific_code/juce_win32_Files.cpp +++ b/build/win32/platform_specific_code/juce_win32_Files.cpp @@ -69,57 +69,6 @@ BEGIN_JUCE_NAMESPACE const tchar File::separator = T('\\'); const tchar* File::separatorString = T("\\"); -//============================================================================== -#if JUCE_ENABLE_WIN98_COMPATIBILITY -UNICODE_FUNCTION (GetFileAttributesW, DWORD, (LPCWSTR)) -UNICODE_FUNCTION (GetFileAttributesExW, BOOL, (LPCWSTR, GET_FILEEX_INFO_LEVELS, LPVOID)) -UNICODE_FUNCTION (SetFileAttributesW, BOOL, (LPCWSTR, DWORD)) -UNICODE_FUNCTION (RemoveDirectoryW, BOOL, (LPCWSTR)) -UNICODE_FUNCTION (DeleteFileW, BOOL, (LPCWSTR)) -UNICODE_FUNCTION (MoveFileW, BOOL, (LPCWSTR, LPCWSTR)) -UNICODE_FUNCTION (CopyFileW, BOOL, (LPCWSTR, LPCWSTR, BOOL)) -UNICODE_FUNCTION (CreateDirectoryW, BOOL, (LPCWSTR, LPSECURITY_ATTRIBUTES)) -UNICODE_FUNCTION (CreateFileW, HANDLE, (LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE)) -UNICODE_FUNCTION (CreateNamedPipeW, HANDLE, (LPCWSTR, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPSECURITY_ATTRIBUTES)) -UNICODE_FUNCTION (GetTempPathW, DWORD, (DWORD, LPCWSTR)) -UNICODE_FUNCTION (SHGetSpecialFolderPathW, BOOL, (HWND, LPCWSTR, int, BOOL)) -UNICODE_FUNCTION (GetModuleFileNameW, DWORD, (HMODULE, LPCWSTR, DWORD)) -UNICODE_FUNCTION (GetCurrentDirectoryW, DWORD, (DWORD, LPCWSTR)) -UNICODE_FUNCTION (SetCurrentDirectoryW, BOOL, (LPCWSTR)) -UNICODE_FUNCTION (FindFirstFileW, HANDLE, (LPCWSTR, LPWIN32_FIND_DATAW)) -UNICODE_FUNCTION (FindNextFileW, BOOL, (HANDLE, LPWIN32_FIND_DATAW)) - -void juce_initialiseUnicodeFileFunctions() throw() -{ - static_jassert (CSIDL_MYMUSIC == 0x000d); - static_jassert (CSIDL_MYVIDEO == 0x000e); - - if ((SystemStats::getOperatingSystemType() & SystemStats::WindowsNT) != 0) - { - HMODULE h = GetModuleHandleA ("kernel32.dll"); - - UNICODE_FUNCTION_LOAD (GetFileAttributesW) - UNICODE_FUNCTION_LOAD (GetFileAttributesExW) - UNICODE_FUNCTION_LOAD (SetFileAttributesW) - UNICODE_FUNCTION_LOAD (RemoveDirectoryW) - UNICODE_FUNCTION_LOAD (DeleteFileW) - UNICODE_FUNCTION_LOAD (MoveFileW) - UNICODE_FUNCTION_LOAD (CopyFileW) - UNICODE_FUNCTION_LOAD (CreateDirectoryW) - UNICODE_FUNCTION_LOAD (CreateFileW) - UNICODE_FUNCTION_LOAD (CreateNamedPipeW) - UNICODE_FUNCTION_LOAD (GetTempPathW) - UNICODE_FUNCTION_LOAD (GetModuleFileNameW) - UNICODE_FUNCTION_LOAD (GetCurrentDirectoryW) - UNICODE_FUNCTION_LOAD (SetCurrentDirectoryW) - UNICODE_FUNCTION_LOAD (FindFirstFileW) - UNICODE_FUNCTION_LOAD (FindNextFileW) - - h = LoadLibraryA ("shell32.dll"); - UNICODE_FUNCTION_LOAD (SHGetSpecialFolderPathW) - } -} -#endif //============================================================================== bool juce_fileExists (const String& fileName, @@ -128,12 +77,7 @@ bool juce_fileExists (const String& fileName, if (fileName.isEmpty()) return false; -#if JUCE_ENABLE_WIN98_COMPATIBILITY - const DWORD attr = (wGetFileAttributesW != 0) ? wGetFileAttributesW (fileName) - : GetFileAttributes (fileName); -#else - const DWORD attr = GetFileAttributesW (fileName); -#endif + const DWORD attr = GetFileAttributes (fileName); return dontCountDirectories ? ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0) : (attr != 0xffffffff); @@ -141,12 +85,7 @@ bool juce_fileExists (const String& fileName, bool juce_isDirectory (const String& fileName) throw() { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - const DWORD attr = (wGetFileAttributesW != 0) ? wGetFileAttributesW (fileName) - : GetFileAttributes (fileName); -#else - const DWORD attr = GetFileAttributesW (fileName); -#endif + const DWORD attr = GetFileAttributes (fileName); return (attr != 0xffffffff) && ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0); @@ -154,12 +93,7 @@ bool juce_isDirectory (const String& fileName) throw() bool juce_canWriteToFile (const String& fileName) throw() { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - const DWORD attr = (wGetFileAttributesW != 0) ? wGetFileAttributesW (fileName) - : GetFileAttributes (fileName); -#else - const DWORD attr = GetFileAttributesW (fileName); -#endif + const DWORD attr = GetFileAttributes (fileName); return ((attr & FILE_ATTRIBUTE_READONLY) == 0); } @@ -167,12 +101,7 @@ bool juce_canWriteToFile (const String& fileName) throw() bool juce_setFileReadOnly (const String& fileName, bool isReadOnly) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - DWORD attr = (wGetFileAttributesW != 0) ? wGetFileAttributesW (fileName) - : GetFileAttributes (fileName); -#else - DWORD attr = GetFileAttributesW (fileName); -#endif + DWORD attr = GetFileAttributes (fileName); if (attr == 0xffffffff) return false; @@ -185,66 +114,33 @@ bool juce_setFileReadOnly (const String& fileName, else attr &= ~FILE_ATTRIBUTE_READONLY; -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wSetFileAttributesW != 0) - return wSetFileAttributesW (fileName, attr) != FALSE; - return SetFileAttributes (fileName, attr) != FALSE; -#else - return SetFileAttributesW (fileName, attr) != FALSE; -#endif } //============================================================================== bool juce_deleteFile (const String& fileName) throw() { -#if JUCE_ENABLE_WIN98_COMPATIBILITY if (juce_isDirectory (fileName)) - return (wRemoveDirectoryW != 0) ? wRemoveDirectoryW (fileName) != 0 - : RemoveDirectory (fileName) != 0; - else - return (wDeleteFileW != 0) ? wDeleteFileW (fileName) != 0 - : DeleteFile (fileName) != 0; -#else - if (juce_isDirectory (fileName)) - return RemoveDirectoryW (fileName) != 0; + return RemoveDirectory (fileName) != 0; - return DeleteFileW (fileName) != 0; -#endif + return DeleteFile (fileName) != 0; } bool juce_moveFile (const String& source, const String& dest) throw() { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - return (wMoveFileW != 0) ? wMoveFileW (source, dest) != 0 - : MoveFile (source, dest) != 0; -#else - return MoveFileW (source, dest) != 0; -#endif + return MoveFile (source, dest) != 0; } bool juce_copyFile (const String& source, const String& dest) throw() { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - return (wCopyFileW != 0) ? wCopyFileW (source, dest, false) != 0 - : CopyFile (source, dest, false) != 0; -#else - return CopyFileW (source, dest, false) != 0; -#endif + return CopyFile (source, dest, false) != 0; } void juce_createDirectory (const String& fileName) throw() { if (! juce_fileExists (fileName, true)) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wCreateDirectoryW != 0) - wCreateDirectoryW (fileName, 0); - else - CreateDirectory (fileName, 0); -#else - CreateDirectoryW (fileName, 0); -#endif + CreateDirectory (fileName, 0); } } @@ -256,17 +152,8 @@ void* juce_fileOpen (const String& fileName, bool forWriting) throw() if (forWriting) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wCreateFileW != 0) - h = wCreateFileW (fileName, GENERIC_WRITE, FILE_SHARE_READ, 0, - OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); - else - h = CreateFile (fileName, GENERIC_WRITE, FILE_SHARE_READ, 0, - OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); -#else - h = CreateFileW (fileName, GENERIC_WRITE, FILE_SHARE_READ, 0, - OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); -#endif + h = CreateFile (fileName, GENERIC_WRITE, FILE_SHARE_READ, 0, + OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if (h != INVALID_HANDLE_VALUE) SetFilePointer (h, 0, 0, FILE_END); @@ -275,17 +162,8 @@ void* juce_fileOpen (const String& fileName, bool forWriting) throw() } else { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wCreateFileW != 0) - h = wCreateFileW (fileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, 0); - else - h = CreateFile (fileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, 0); -#else - h = CreateFileW (fileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, 0); -#endif + h = CreateFile (fileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, 0); if (h == INVALID_HANDLE_VALUE) h = 0; @@ -350,12 +228,7 @@ int64 juce_getFileSize (const String& fileName) throw() { WIN32_FILE_ATTRIBUTE_DATA attributes; -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wGetFileAttributesExW != 0 ? wGetFileAttributesExW (fileName, GetFileExInfoStandard, &attributes) - : GetFileAttributesEx (fileName, GetFileExInfoStandard, &attributes)) -#else - if (GetFileAttributesExW (fileName, GetFileExInfoStandard, &attributes)) -#endif + if (GetFileAttributesEx (fileName, GetFileExInfoStandard, &attributes)) { return (((int64) attributes.nFileSizeHigh) << 32) | attributes.nFileSizeLow; @@ -394,12 +267,7 @@ void juce_getFileTimes (const String& fileName, WIN32_FILE_ATTRIBUTE_DATA attributes; -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wGetFileAttributesExW != 0 ? wGetFileAttributesExW (fileName, GetFileExInfoStandard, &attributes) - : GetFileAttributesEx (fileName, GetFileExInfoStandard, &attributes)) -#else - if (GetFileAttributesExW (fileName, GetFileExInfoStandard, &attributes)) -#endif + if (GetFileAttributesEx (fileName, GetFileExInfoStandard, &attributes)) { modificationTime = fileTimeToTime (&attributes.ftLastWriteTime); creationTime = fileTimeToTime (&attributes.ftCreationTime); @@ -559,27 +427,10 @@ bool File::isOnRemovableDrive() const throw() static const File juce_getSpecialFolderPath (int type) throw() { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wSHGetSpecialFolderPathW != 0) - { - WCHAR path [MAX_PATH_CHARS]; - - if (wSHGetSpecialFolderPathW (0, path, type, 0)) - return File (String (path)); - } - else - { - TCHAR path [MAX_PATH_CHARS]; - - if (SHGetSpecialFolderPath (0, path, type, 0)) - return File (String (path)); - } -#else WCHAR path [MAX_PATH_CHARS]; - if (SHGetSpecialFolderPathW (0, path, type, 0)) + if (SHGetSpecialFolderPath (0, path, type, 0)) return File (String (path)); -#endif return File::nonexistent; } @@ -620,56 +471,22 @@ const File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType typ break; case tempDirectory: -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wGetTempPathW != 0) { WCHAR dest [2048]; dest[0] = 0; - wGetTempPathW (2048, dest); - return File (String (dest)); - } - else - { - TCHAR dest [2048]; - dest[0] = 0; GetTempPath (2048, dest); return File (String (dest)); } -#else - { - WCHAR dest [2048]; - dest[0] = 0; - GetTempPathW (2048, dest); - return File (String (dest)); - } -#endif case currentExecutableFile: case currentApplicationFile: { HINSTANCE moduleHandle = (HINSTANCE) PlatformUtilities::getCurrentModuleInstanceHandle(); -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wGetModuleFileNameW != 0) - { - WCHAR dest [MAX_PATH_CHARS]; - dest[0] = 0; - wGetModuleFileNameW (moduleHandle, dest, MAX_PATH_CHARS); - return File (String (dest)); - } - else - { - TCHAR dest [MAX_PATH_CHARS]; - dest[0] = 0; - GetModuleFileName (moduleHandle, dest, MAX_PATH_CHARS); - return File (String (dest)); - } -#else WCHAR dest [MAX_PATH_CHARS]; dest[0] = 0; - GetModuleFileNameW (moduleHandle, dest, MAX_PATH_CHARS); + GetModuleFileName (moduleHandle, dest, MAX_PATH_CHARS); return File (String (dest)); -#endif } break; @@ -690,37 +507,15 @@ void juce_setCurrentExecutableFileName (const String&) throw() //============================================================================== const File File::getCurrentWorkingDirectory() throw() { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wGetCurrentDirectoryW != 0) - { - WCHAR dest [MAX_PATH_CHARS]; - dest[0] = 0; - wGetCurrentDirectoryW (MAX_PATH_CHARS, dest); - return File (String (dest)); - } - else - { - TCHAR dest [MAX_PATH_CHARS]; - dest[0] = 0; - GetCurrentDirectory (MAX_PATH_CHARS, dest); - return File (String (dest)); - } -#else WCHAR dest [MAX_PATH_CHARS]; dest[0] = 0; - GetCurrentDirectoryW (MAX_PATH_CHARS, dest); + GetCurrentDirectory (MAX_PATH_CHARS, dest); return File (String (dest)); -#endif } bool File::setAsCurrentWorkingDirectory() const throw() { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - return (wSetCurrentDirectoryW != 0) ? wSetCurrentDirectoryW (getFullPathName()) != FALSE - : SetCurrentDirectory (getFullPathName()) != FALSE; -#else - return SetCurrentDirectoryW (getFullPathName()) != FALSE; -#endif + return SetCurrentDirectory (getFullPathName()) != FALSE; } //============================================================================== @@ -763,39 +558,15 @@ void* juce_findFileStart (const String& directory, const String& wildCard, Strin wc += wildCard; -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wFindFirstFileW != 0) - { - WIN32_FIND_DATAW findData; - HANDLE h = wFindFirstFileW (wc, &findData); - - if (h != INVALID_HANDLE_VALUE) - { - getFindFileInfo (findData, firstResult, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly); - return h; - } - } - else - { - WIN32_FIND_DATA findData; - HANDLE h = FindFirstFile (wc, &findData); - - if (h != INVALID_HANDLE_VALUE) - { - getFindFileInfo (findData, firstResult, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly); - return h; - } - } -#else - WIN32_FIND_DATAW findData; - HANDLE h = FindFirstFileW (wc, &findData); + WIN32_FIND_DATA findData; + HANDLE h = FindFirstFile (wc, &findData); if (h != INVALID_HANDLE_VALUE) { - getFindFileInfo (findData, firstResult, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly); + getFindFileInfo (findData, firstResult, isDir, isHidden, fileSize, + modTime, creationTime, isReadOnly); return h; } -#endif firstResult = String::empty; return 0; @@ -805,36 +576,14 @@ bool juce_findFileNext (void* handle, String& resultFile, bool* isDir, bool* isHidden, int64* fileSize, Time* modTime, Time* creationTime, bool* isReadOnly) throw() { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wFindNextFileW != 0) - { - WIN32_FIND_DATAW findData; - - if (handle != 0 && wFindNextFileW ((HANDLE) handle, &findData) != 0) - { - getFindFileInfo (findData, resultFile, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly); - return true; - } - } - else - { - WIN32_FIND_DATA findData; - - if (handle != 0 && FindNextFile ((HANDLE) handle, &findData) != 0) - { - getFindFileInfo (findData, resultFile, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly); - return true; - } - } -#else - WIN32_FIND_DATAW findData; + WIN32_FIND_DATA findData; - if (handle != 0 && FindNextFileW ((HANDLE) handle, &findData) != 0) + if (handle != 0 && FindNextFile ((HANDLE) handle, &findData) != 0) { - getFindFileInfo (findData, resultFile, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly); + getFindFileInfo (findData, resultFile, isDir, isHidden, fileSize, + modTime, creationTime, isReadOnly); return true; } -#endif resultFile = String::empty; return false; @@ -956,31 +705,13 @@ bool NamedPipe::openInternal (const String& pipeName, const bool createPipe) if (createPipe) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wCreateNamedPipeW != 0) - intern->pipeH = wCreateNamedPipeW (file, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, 0, - 1, 64, 64, 0, NULL); - else - intern->pipeH = CreateNamedPipe (file, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, 0, - 1, 64, 64, 0, NULL); -#else - intern->pipeH = CreateNamedPipeW (file, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, 0, - 1, 64, 64, 0, NULL); -#endif + intern->pipeH = CreateNamedPipe (file, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, 0, + 1, 64, 64, 0, NULL); } else { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wCreateFileW != 0) - intern->pipeH = wCreateFileW (file, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, 0); - else - intern->pipeH = CreateFile (file, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, 0); -#else - intern->pipeH = CreateFileW (file, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, - FILE_FLAG_OVERLAPPED, 0); -#endif + intern->pipeH = CreateFile (file, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, + FILE_FLAG_OVERLAPPED, 0); } if (intern->pipeH != INVALID_HANDLE_VALUE) diff --git a/build/win32/platform_specific_code/juce_win32_Fonts.cpp b/build/win32/platform_specific_code/juce_win32_Fonts.cpp index eed240c0ef..7c201903c8 100644 --- a/build/win32/platform_specific_code/juce_win32_Fonts.cpp +++ b/build/win32/platform_specific_code/juce_win32_Fonts.cpp @@ -42,55 +42,6 @@ BEGIN_JUCE_NAMESPACE //============================================================================== -#if JUCE_ENABLE_WIN98_COMPATIBILITY - UNICODE_FUNCTION (GetGlyphOutlineW, DWORD, (HDC, UINT, UINT, LPGLYPHMETRICS, DWORD, LPVOID, CONST MAT2*)) - UNICODE_FUNCTION (GetTextMetricsW, BOOL, (HDC, LPTEXTMETRICW)) - UNICODE_FUNCTION (GetKerningPairsW, DWORD, (HDC, DWORD, LPKERNINGPAIR)) - UNICODE_FUNCTION (EnumFontFamiliesExW, int, (HDC, LPLOGFONTW, FONTENUMPROCW, LPARAM, DWORD)) - UNICODE_FUNCTION (CreateFontIndirectW, HFONT, (CONST LOGFONTW *)); - UNICODE_FUNCTION (GetGlyphIndicesW, DWORD, (HDC, LPCWSTR, int, LPWORD, DWORD)); - - static void juce_initialiseUnicodeFileFontFunctions() - { - static bool initialised = false; - - if (! initialised) - { - initialised = true; - - if ((SystemStats::getOperatingSystemType() & SystemStats::WindowsNT) != 0) - { - HMODULE h = LoadLibraryA ("gdi32.dll"); - UNICODE_FUNCTION_LOAD (GetGlyphOutlineW) - UNICODE_FUNCTION_LOAD (GetTextMetricsW) - UNICODE_FUNCTION_LOAD (GetKerningPairsW) - UNICODE_FUNCTION_LOAD (EnumFontFamiliesExW) - UNICODE_FUNCTION_LOAD (CreateFontIndirectW) - UNICODE_FUNCTION_LOAD (GetGlyphIndicesW) - } - } - } -#endif - - -//============================================================================== -#if JUCE_ENABLE_WIN98_COMPATIBILITY -static int CALLBACK fontEnum2 (ENUMLOGFONTEX* lpelfe, - NEWTEXTMETRICEX*, - int type, - LPARAM lParam) -{ - if (lpelfe != 0 && type == TRUETYPE_FONTTYPE) - { - const String fontName (lpelfe->elfLogFont.lfFaceName); - - ((StringArray*) lParam)->addIfNotAlreadyThere (fontName.removeCharacters (T("@"))); - } - - return 1; -} -#endif - static int CALLBACK wfontEnum2 (ENUMLOGFONTEXW* lpelfe, NEWTEXTMETRICEXW*, int type, @@ -106,39 +57,6 @@ static int CALLBACK wfontEnum2 (ENUMLOGFONTEXW* lpelfe, return 1; } -#if JUCE_ENABLE_WIN98_COMPATIBILITY -static int CALLBACK fontEnum1 (ENUMLOGFONTEX* lpelfe, - NEWTEXTMETRICEX*, - int type, - LPARAM lParam) -{ - if (lpelfe != 0 - && ((type & (DEVICE_FONTTYPE | RASTER_FONTTYPE)) == 0)) - { - LOGFONT lf; - zerostruct (lf); - - lf.lfWeight = FW_DONTCARE; - lf.lfOutPrecision = OUT_TT_ONLY_PRECIS; - lf.lfQuality = DEFAULT_QUALITY; - lf.lfCharSet = DEFAULT_CHARSET; - lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf.lfPitchAndFamily = FF_DONTCARE; - - const String fontName (lpelfe->elfLogFont.lfFaceName); - fontName.copyToBuffer (lf.lfFaceName, LF_FACESIZE - 1); - - HDC dc = CreateCompatibleDC (0); - EnumFontFamiliesEx (dc, &lf, - (FONTENUMPROC) &fontEnum2, - lParam, 0); - DeleteDC (dc); - } - - return 1; -} -#endif - static int CALLBACK wfontEnum1 (ENUMLOGFONTEXW* lpelfe, NEWTEXTMETRICEXW*, int type, @@ -161,15 +79,9 @@ static int CALLBACK wfontEnum1 (ENUMLOGFONTEXW* lpelfe, fontName.copyToBuffer (lf.lfFaceName, LF_FACESIZE - 1); HDC dc = CreateCompatibleDC (0); -#if JUCE_ENABLE_WIN98_COMPATIBILITY - wEnumFontFamiliesExW (dc, &lf, - (FONTENUMPROCW) &wfontEnum2, - lParam, 0); -#else - EnumFontFamiliesExW (dc, &lf, - (FONTENUMPROCW) &wfontEnum2, - lParam, 0); -#endif + EnumFontFamiliesEx (dc, &lf, + (FONTENUMPROCW) &wfontEnum2, + lParam, 0); DeleteDC (dc); } @@ -181,8 +93,6 @@ const StringArray Font::findAllTypefaceNames() throw() StringArray results; HDC dc = CreateCompatibleDC (0); -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wEnumFontFamiliesExW != 0) { LOGFONTW lf; zerostruct (lf); @@ -195,45 +105,10 @@ const StringArray Font::findAllTypefaceNames() throw() lf.lfPitchAndFamily = FF_DONTCARE; lf.lfFaceName[0] = 0; - wEnumFontFamiliesExW (dc, &lf, - (FONTENUMPROCW) &wfontEnum1, - (LPARAM) &results, 0); - } - else - { - LOGFONT lf; - zerostruct (lf); - - lf.lfWeight = FW_DONTCARE; - lf.lfOutPrecision = OUT_TT_ONLY_PRECIS; - lf.lfQuality = DEFAULT_QUALITY; - lf.lfCharSet = DEFAULT_CHARSET; - lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf.lfPitchAndFamily = FF_DONTCARE; - lf.lfFaceName[0] = 0; - EnumFontFamiliesEx (dc, &lf, - (FONTENUMPROC) &fontEnum1, + (FONTENUMPROCW) &wfontEnum1, (LPARAM) &results, 0); } -#else - { - LOGFONTW lf; - zerostruct (lf); - - lf.lfWeight = FW_DONTCARE; - lf.lfOutPrecision = OUT_TT_ONLY_PRECIS; - lf.lfQuality = DEFAULT_QUALITY; - lf.lfCharSet = DEFAULT_CHARSET; - lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf.lfPitchAndFamily = FF_DONTCARE; - lf.lfFaceName[0] = 0; - - EnumFontFamiliesExW (dc, &lf, - (FONTENUMPROCW) &wfontEnum1, - (LPARAM) &results, 0); - } -#endif DeleteDC (dc); @@ -287,9 +162,6 @@ public: italic (false), size (0) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - juce_initialiseUnicodeFileFontFunctions(); -#endif } ~FontDCHolder() throw() @@ -334,44 +206,6 @@ public: SetMapperFlags (dc, 0); SetMapMode (dc, MM_TEXT); -#if JUCE_ENABLE_WIN98_COMPATIBILITY - LOGFONT lf; - LOGFONTW lfw; - HFONT standardSizedFont = 0; - - if (wCreateFontIndirectW != 0) - { - zerostruct (lfw); - - lfw.lfCharSet = DEFAULT_CHARSET; - lfw.lfClipPrecision = CLIP_DEFAULT_PRECIS; - lfw.lfOutPrecision = OUT_OUTLINE_PRECIS; - lfw.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - lfw.lfQuality = PROOF_QUALITY; - lfw.lfItalic = (BYTE) (italic ? TRUE : FALSE); - lfw.lfWeight = bold ? FW_BOLD : FW_NORMAL; - fontName.copyToBuffer (lfw.lfFaceName, LF_FACESIZE - 1); - - lfw.lfHeight = size > 0 ? size : -256; - standardSizedFont = wCreateFontIndirectW (&lfw); - } - else - { - zerostruct (lf); - - lf.lfCharSet = DEFAULT_CHARSET; - lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf.lfOutPrecision = OUT_OUTLINE_PRECIS; - lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - lf.lfQuality = PROOF_QUALITY; - lf.lfItalic = (BYTE) (italic ? TRUE : FALSE); - lf.lfWeight = bold ? FW_BOLD : FW_NORMAL; - fontName.copyToBuffer (lf.lfFaceName, LF_FACESIZE - 1); - - lf.lfHeight = size > 0 ? size : -256; - standardSizedFont = CreateFontIndirect (&lf); - } -#else LOGFONTW lfw; zerostruct (lfw); @@ -385,8 +219,7 @@ public: fontName.copyToBuffer (lfw.lfFaceName, LF_FACESIZE - 1); lfw.lfHeight = size > 0 ? size : -256; - HFONT standardSizedFont = CreateFontIndirectW (&lfw); -#endif + HFONT standardSizedFont = CreateFontIndirect (&lfw); if (standardSizedFont != 0) { @@ -399,21 +232,8 @@ public: OUTLINETEXTMETRIC otm; if (GetOutlineTextMetrics (dc, sizeof (otm), &otm) != 0) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wCreateFontIndirectW != 0) - { - lfw.lfHeight = -(int) otm.otmEMSquare; - fontH = wCreateFontIndirectW (&lfw); - } - else - { - lf.lfHeight = -(int) otm.otmEMSquare; - fontH = CreateFontIndirect (&lf); - } -#else lfw.lfHeight = -(int) otm.otmEMSquare; - fontH = CreateFontIndirectW (&lfw); -#endif + fontH = CreateFontIndirect (&lfw); SelectObject (dc, fontH); DeleteObject (standardSizedFont); @@ -439,24 +259,9 @@ public: { if (kps == 0) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wGetKerningPairsW != 0) - { - numKPs = wGetKerningPairsW (dc, 0, 0); - kps = (KERNINGPAIR*) juce_calloc (sizeof (KERNINGPAIR) * numKPs); - wGetKerningPairsW (dc, numKPs, kps); - } - else - { - numKPs = GetKerningPairs (dc, 0, 0); - kps = (KERNINGPAIR*) juce_calloc (sizeof (KERNINGPAIR) * numKPs); - GetKerningPairs (dc, numKPs, kps); - } -#else - numKPs = GetKerningPairsW (dc, 0, 0); + numKPs = GetKerningPairs (dc, 0, 0); kps = (KERNINGPAIR*) juce_calloc (sizeof (KERNINGPAIR) * numKPs); - GetKerningPairsW (dc, numKPs, kps); -#endif + GetKerningPairs (dc, numKPs, kps); } numKPs_ = numKPs; @@ -479,50 +284,21 @@ static bool addGlyphToTypeface (HDC dc, float height; BOOL ok = false; -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wGetGlyphIndicesW != 0) { - const WCHAR charToTest[] = { (WCHAR)character, 0 }; + const WCHAR charToTest[] = { (WCHAR) character, 0 }; WORD index = 0; - if (wGetGlyphIndicesW (dc, charToTest, 1, &index, GGI_MARK_NONEXISTING_GLYPHS) != GDI_ERROR + if (GetGlyphIndices (dc, charToTest, 1, &index, GGI_MARK_NONEXISTING_GLYPHS) != GDI_ERROR && index == 0xffff) { return false; } } - if (wGetTextMetricsW != 0) - { - TEXTMETRICW tm; - ok = wGetTextMetricsW (dc, &tm); - - height = (float) tm.tmHeight; - } - else - { - TEXTMETRIC tm; - ok = GetTextMetrics (dc, &tm); - - height = (float) tm.tmHeight; - } -#else - { - const WCHAR charToTest[] = { (WCHAR)character, 0 }; - WORD index = 0; - - if (GetGlyphIndicesW (dc, charToTest, 1, &index, GGI_MARK_NONEXISTING_GLYPHS) != GDI_ERROR - && index == 0xffff) - { - return false; - } - } - - TEXTMETRICW tm; - ok = GetTextMetricsW (dc, &tm); + TEXTMETRIC tm; + ok = GetTextMetrics (dc, &tm); height = (float) tm.tmHeight; -#endif if (! ok) { @@ -534,35 +310,15 @@ static bool addGlyphToTypeface (HDC dc, const float scaleY = -1.0f / height; static const MAT2 identityMatrix = { { 0, 1 }, { 0, 0 }, { 0, 0 }, { 0, 1 } }; - int bufSize; - -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wGetGlyphOutlineW != 0) - bufSize = wGetGlyphOutlineW (dc, character, GGO_NATIVE, - &gm, 0, 0, &identityMatrix); - else - bufSize = GetGlyphOutline (dc, character, GGO_NATIVE, - &gm, 0, 0, &identityMatrix); -#else - bufSize = GetGlyphOutlineW (dc, character, GGO_NATIVE, - &gm, 0, 0, &identityMatrix); -#endif + const int bufSize = GetGlyphOutline (dc, character, GGO_NATIVE, + &gm, 0, 0, &identityMatrix); if (bufSize > 0) { char* const data = (char*) juce_malloc (bufSize); -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wGetGlyphOutlineW != 0) - wGetGlyphOutlineW (dc, character, GGO_NATIVE, &gm, - bufSize, data, &identityMatrix); - else - GetGlyphOutline (dc, character, GGO_NATIVE, &gm, - bufSize, data, &identityMatrix); -#else - GetGlyphOutlineW (dc, character, GGO_NATIVE, &gm, - bufSize, data, &identityMatrix); -#endif + GetGlyphOutline (dc, character, GGO_NATIVE, &gm, + bufSize, data, &identityMatrix); const TTPOLYGONHEADER* pheader = (TTPOLYGONHEADER*) data; @@ -717,20 +473,6 @@ void Typeface::initialiseTypefaceCharacteristics (const String& fontName, float height; int firstChar, lastChar; -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wGetTextMetricsW != 0) - { - TEXTMETRICW tm; - wGetTextMetricsW (dc, &tm); - - height = (float) tm.tmHeight; - firstChar = tm.tmFirstChar; - lastChar = tm.tmLastChar; - - setAscent (tm.tmAscent / height); - setDefaultCharacter (tm.tmDefaultChar); - } - else { TEXTMETRIC tm; GetTextMetrics (dc, &tm); @@ -742,19 +484,6 @@ void Typeface::initialiseTypefaceCharacteristics (const String& fontName, setAscent (tm.tmAscent / height); setDefaultCharacter (tm.tmDefaultChar); } -#else - { - TEXTMETRICW tm; - GetTextMetricsW (dc, &tm); - - height = (float) tm.tmHeight; - firstChar = tm.tmFirstChar; - lastChar = tm.tmLastChar; - - setAscent (tm.tmAscent / height); - setDefaultCharacter (tm.tmDefaultChar); - } -#endif setName (fontName); setBold (bold); diff --git a/build/win32/platform_specific_code/juce_win32_Midi.cpp b/build/win32/platform_specific_code/juce_win32_Midi.cpp index 2bf957cfa7..103deedb41 100644 --- a/build/win32/platform_specific_code/juce_win32_Midi.cpp +++ b/build/win32/platform_specific_code/juce_win32_Midi.cpp @@ -331,10 +331,10 @@ const StringArray MidiInput::getDevices() for (int i = 0; i < num; ++i) { - MIDIINCAPSW mc; + MIDIINCAPS mc; zerostruct (mc); - if (midiInGetDevCapsW (i, &mc, sizeof (mc)) == MMSYSERR_NOERROR) + if (midiInGetDevCaps (i, &mc, sizeof (mc)) == MMSYSERR_NOERROR) s.add (String (mc.szPname, sizeof (mc.szPname))); } @@ -359,10 +359,10 @@ MidiInput* MidiInput::openDevice (const int index, MidiInputCallback* const call for (int i = 0; i < num; ++i) { - MIDIINCAPSW mc; + MIDIINCAPS mc; zerostruct (mc); - if (midiInGetDevCapsW (i, &mc, sizeof (mc)) == MMSYSERR_NOERROR) + if (midiInGetDevCaps (i, &mc, sizeof (mc)) == MMSYSERR_NOERROR) { if (index == n) { @@ -444,10 +444,10 @@ const StringArray MidiOutput::getDevices() for (int i = 0; i < num; ++i) { - MIDIOUTCAPSW mc; + MIDIOUTCAPS mc; zerostruct (mc); - if (midiOutGetDevCapsW (i, &mc, sizeof (mc)) == MMSYSERR_NOERROR) + if (midiOutGetDevCaps (i, &mc, sizeof (mc)) == MMSYSERR_NOERROR) s.add (String (mc.szPname, sizeof (mc.szPname))); } @@ -461,10 +461,10 @@ int MidiOutput::getDefaultDeviceIndex() for (int i = 0; i < num; ++i) { - MIDIOUTCAPSW mc; + MIDIOUTCAPS mc; zerostruct (mc); - if (midiOutGetDevCapsW (i, &mc, sizeof (mc)) == MMSYSERR_NOERROR) + if (midiOutGetDevCaps (i, &mc, sizeof (mc)) == MMSYSERR_NOERROR) { if ((mc.wTechnology & MOD_MAPPER) != 0) return n; @@ -484,10 +484,10 @@ MidiOutput* MidiOutput::openDevice (int index) for (i = 0; i < num; ++i) { - MIDIOUTCAPSW mc; + MIDIOUTCAPS mc; zerostruct (mc); - if (midiOutGetDevCapsW (i, &mc, sizeof (mc)) == MMSYSERR_NOERROR) + if (midiOutGetDevCaps (i, &mc, sizeof (mc)) == MMSYSERR_NOERROR) { // use the microsoft sw synth as a default - best not to allow deviceId // to be MIDI_MAPPER, or else device sharing breaks diff --git a/build/win32/platform_specific_code/juce_win32_Misc.cpp b/build/win32/platform_specific_code/juce_win32_Misc.cpp index 4ce5de1037..a43c485366 100644 --- a/build/win32/platform_specific_code/juce_win32_Misc.cpp +++ b/build/win32/platform_specific_code/juce_win32_Misc.cpp @@ -45,15 +45,9 @@ bool AlertWindow::showNativeDialogBox (const String& title, const String& bodyText, bool isOkCancel) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY return MessageBox (0, bodyText, title, (isOkCancel) ? MB_OKCANCEL : MB_OK) == IDOK; -#else - return MessageBoxW (0, bodyText, title, - (isOkCancel) ? MB_OKCANCEL - : MB_OK) == IDOK; -#endif } //============================================================================== diff --git a/build/win32/platform_specific_code/juce_win32_PlatformUtils.cpp b/build/win32/platform_specific_code/juce_win32_PlatformUtils.cpp index 0552c272ef..e6242f9602 100644 --- a/build/win32/platform_specific_code/juce_win32_PlatformUtils.cpp +++ b/build/win32/platform_specific_code/juce_win32_PlatformUtils.cpp @@ -47,46 +47,12 @@ BEGIN_JUCE_NAMESPACE #pragma warning (pop) #endif -//============================================================================== -#if JUCE_ENABLE_WIN98_COMPATIBILITY -UNICODE_FUNCTION (RegCreateKeyExW, LONG, (HKEY, LPCWSTR, DWORD, LPWSTR, DWORD, REGSAM, LPSECURITY_ATTRIBUTES, PHKEY, LPDWORD)) -UNICODE_FUNCTION (RegOpenKeyExW, LONG, (HKEY, LPCWSTR, DWORD, REGSAM, PHKEY)) -UNICODE_FUNCTION (RegQueryValueExW, LONG, (HKEY, LPCWSTR, LPDWORD, LPDWORD, LPBYTE, LPDWORD)) -UNICODE_FUNCTION (RegSetValueExW, LONG, (HKEY, LPCWSTR, DWORD, DWORD, const BYTE*, DWORD)) -UNICODE_FUNCTION (RegDeleteValueW, LONG, (HKEY, LPCWSTR)) -UNICODE_FUNCTION (RegDeleteKeyW, LONG, (HKEY, LPCWSTR)) - -static void juce_initialiseUnicodeRegistryFunctions() throw() -{ - static bool initialised = false; - - if (! initialised) - { - initialised = true; - - if ((SystemStats::getOperatingSystemType() & SystemStats::WindowsNT) != 0) - { - HMODULE h = LoadLibraryA ("Advapi32.dll"); - UNICODE_FUNCTION_LOAD (RegCreateKeyExW) - UNICODE_FUNCTION_LOAD (RegOpenKeyExW) - UNICODE_FUNCTION_LOAD (RegQueryValueExW) - UNICODE_FUNCTION_LOAD (RegSetValueExW) - UNICODE_FUNCTION_LOAD (RegDeleteValueW) - UNICODE_FUNCTION_LOAD (RegDeleteKeyW) - } - } -} -#endif //============================================================================== static HKEY findKeyForPath (String name, const bool createForWriting, String& valueName) throw() { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - juce_initialiseUnicodeRegistryFunctions(); -#endif - HKEY rootKey = 0; if (name.startsWithIgnoreCase (T("HKEY_CURRENT_USER\\"))) @@ -109,42 +75,14 @@ static HKEY findKeyForPath (String name, if (createForWriting) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wRegCreateKeyExW != 0) - { - if (wRegCreateKeyExW (rootKey, name, 0, L"", REG_OPTION_NON_VOLATILE, - (KEY_WRITE | KEY_QUERY_VALUE), 0, &key, &result) == ERROR_SUCCESS) - return key; - } - else - { - if (RegCreateKeyEx (rootKey, name, 0, _T(""), REG_OPTION_NON_VOLATILE, - (KEY_WRITE | KEY_QUERY_VALUE), 0, &key, &result) == ERROR_SUCCESS) - return key; - } -#else - if (RegCreateKeyExW (rootKey, name, 0, L"", REG_OPTION_NON_VOLATILE, - (KEY_WRITE | KEY_QUERY_VALUE), 0, &key, &result) == ERROR_SUCCESS) + if (RegCreateKeyEx (rootKey, name, 0, L"", REG_OPTION_NON_VOLATILE, + (KEY_WRITE | KEY_QUERY_VALUE), 0, &key, &result) == ERROR_SUCCESS) return key; -#endif } else { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wRegOpenKeyExW != 0) - { - if (wRegOpenKeyExW (rootKey, name, 0, KEY_READ, &key) == ERROR_SUCCESS) - return key; - } - else - { - if (RegOpenKeyEx (rootKey, name, 0, KEY_READ, &key) == ERROR_SUCCESS) - return key; - } -#else - if (RegOpenKeyExW (rootKey, name, 0, KEY_READ, &key) == ERROR_SUCCESS) + if (RegOpenKeyEx (rootKey, name, 0, KEY_READ, &key) == ERROR_SUCCESS) return key; -#endif } } @@ -159,39 +97,14 @@ const String PlatformUtilities::getRegistryValue (const String& regValuePath, if (k != 0) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wRegQueryValueExW != 0) - { - WCHAR buffer [2048]; - unsigned long bufferSize = sizeof (buffer); - DWORD type = REG_SZ; - - if (wRegQueryValueExW (k, valueName, 0, &type, (LPBYTE) buffer, &bufferSize) == ERROR_SUCCESS) - s = buffer; - else - s = defaultValue; - } - else - { - TCHAR buffer [2048]; - unsigned long bufferSize = sizeof (buffer); - DWORD type = REG_SZ; - - if (RegQueryValueEx (k, valueName, 0, &type, (LPBYTE) buffer, &bufferSize) == ERROR_SUCCESS) - s = buffer; - else - s = defaultValue; - } -#else WCHAR buffer [2048]; unsigned long bufferSize = sizeof (buffer); DWORD type = REG_SZ; - if (RegQueryValueExW (k, valueName, 0, &type, (LPBYTE) buffer, &bufferSize) == ERROR_SUCCESS) + if (RegQueryValueEx (k, valueName, 0, &type, (LPBYTE) buffer, &bufferSize) == ERROR_SUCCESS) s = buffer; else s = defaultValue; -#endif RegCloseKey (k); } @@ -207,20 +120,9 @@ void PlatformUtilities::setRegistryValue (const String& regValuePath, if (k != 0) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wRegSetValueExW != 0) - wRegSetValueExW (k, valueName, 0, REG_SZ, - (const BYTE*) (const WCHAR*) value, - sizeof (WCHAR) * (value.length() + 1)); - else - RegSetValueEx (k, valueName, 0, REG_SZ, - (const BYTE*) (const TCHAR*) value, - sizeof (TCHAR) * (value.length() + 1)); -#else - RegSetValueExW (k, valueName, 0, REG_SZ, - (const BYTE*) (const WCHAR*) value, - sizeof (WCHAR) * (value.length() + 1)); -#endif + RegSetValueEx (k, valueName, 0, REG_SZ, + (const BYTE*) (const WCHAR*) value, + sizeof (WCHAR) * (value.length() + 1)); RegCloseKey (k); } @@ -238,21 +140,8 @@ bool PlatformUtilities::registryValueExists (const String& regValuePath) unsigned long bufferSize = sizeof (buffer); DWORD type = 0; -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wRegQueryValueExW != 0) - { - if (wRegQueryValueExW (k, valueName, 0, &type, buffer, &bufferSize) == ERROR_SUCCESS) - exists = true; - } - else - { - if (RegQueryValueEx (k, valueName, 0, &type, buffer, &bufferSize) == ERROR_SUCCESS) - exists = true; - } -#else - if (RegQueryValueExW (k, valueName, 0, &type, buffer, &bufferSize) == ERROR_SUCCESS) + if (RegQueryValueEx (k, valueName, 0, &type, buffer, &bufferSize) == ERROR_SUCCESS) exists = true; -#endif RegCloseKey (k); } @@ -267,15 +156,7 @@ void PlatformUtilities::deleteRegistryValue (const String& regValuePath) if (k != 0) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wRegDeleteValueW != 0) - wRegDeleteValueW (k, valueName); - else - RegDeleteValue (k, valueName); -#else - RegDeleteValueW (k, valueName); -#endif - + RegDeleteValue (k, valueName); RegCloseKey (k); } } @@ -287,15 +168,7 @@ void PlatformUtilities::deleteRegistryKey (const String& regKeyPath) if (k != 0) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wRegDeleteKeyW != 0) - wRegDeleteKeyW (k, valueName); - else - RegDeleteKey (k, valueName); -#else - RegDeleteKeyW (k, valueName); -#endif - + RegDeleteKey (k, valueName); RegCloseKey (k); } } diff --git a/build/win32/platform_specific_code/juce_win32_SystemStats.cpp b/build/win32/platform_specific_code/juce_win32_SystemStats.cpp index 8c41592d7e..8e4374544e 100644 --- a/build/win32/platform_specific_code/juce_win32_SystemStats.cpp +++ b/build/win32/platform_specific_code/juce_win32_SystemStats.cpp @@ -69,10 +69,6 @@ BEGIN_JUCE_NAMESPACE extern void juce_updateMultiMonitorInfo() throw(); extern void juce_initialiseThreadEvents() throw(); -#if JUCE_ENABLE_WIN98_COMPATIBILITY - extern void juce_initialiseUnicodeFileFunctions() throw(); -#endif - //============================================================================== void Logger::outputDebugString (const String& text) throw() @@ -256,10 +252,6 @@ bool SystemStats::has3DNow() throw() void SystemStats::initialiseStats() throw() { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - juce_initialiseUnicodeFileFunctions(); -#endif - juce_initialiseThreadEvents(); cpuFlags.hasMMX = IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE) != 0; @@ -359,7 +351,7 @@ bool SystemStats::isOperatingSystem64Bit() throw() #else typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); - LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress (GetModuleHandle ("kernel32"), "IsWow64Process"); + LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress (GetModuleHandle (L"kernel32"), "IsWow64Process"); BOOL isWow64 = FALSE; diff --git a/build/win32/platform_specific_code/juce_win32_Windowing.cpp b/build/win32/platform_specific_code/juce_win32_Windowing.cpp index bb086992b6..997f5092b6 100644 --- a/build/win32/platform_specific_code/juce_win32_Windowing.cpp +++ b/build/win32/platform_specific_code/juce_win32_Windowing.cpp @@ -134,48 +134,8 @@ bool Desktop::canUseSemiTransparentWindows() throw() } //============================================================================== -#if JUCE_ENABLE_WIN98_COMPATIBILITY - UNICODE_FUNCTION (SetWindowTextW, BOOL, (HWND, LPCWSTR)) - UNICODE_FUNCTION (DragQueryFileW, UINT, (HDROP, UINT, LPWSTR, UINT)) - UNICODE_FUNCTION (MapVirtualKeyW, UINT, (UINT, UINT)) - UNICODE_FUNCTION (ToUnicode, int, (UINT, UINT, const PBYTE, LPWSTR, int, UINT)) - UNICODE_FUNCTION (RegisterClassExW, ATOM, (CONST WNDCLASSEXW*)) - UNICODE_FUNCTION (CreateWindowExW, HWND, (DWORD, LPCWSTR, LPCWSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID)) - UNICODE_FUNCTION (DefWindowProcW, LRESULT, (HWND, UINT, WPARAM, LPARAM)) - - void juce_initialiseUnicodeWindowFunctions() - { - static bool initialised = false; - - if (! initialised) - { - initialised = true; - - if ((SystemStats::getOperatingSystemType() & SystemStats::WindowsNT) != 0) - { - HMODULE h = LoadLibraryA ("user32.dll"); - UNICODE_FUNCTION_LOAD (SetWindowTextW) - UNICODE_FUNCTION_LOAD (MapVirtualKeyW) - UNICODE_FUNCTION_LOAD (ToUnicode) - UNICODE_FUNCTION_LOAD (RegisterClassExW) - UNICODE_FUNCTION_LOAD (CreateWindowExW) - UNICODE_FUNCTION_LOAD (DefWindowProcW) - - if (wDefWindowProcW == 0) - wDefWindowProcW = & DefWindowProcA; - - h = LoadLibraryA ("shell32.dll"); - UNICODE_FUNCTION_LOAD (DragQueryFileW) - } - } - } - - #undef DefWindowProc - #define DefWindowProc wDefWindowProcW -#else - #undef DefWindowProc - #define DefWindowProc DefWindowProcW -#endif +#undef DefWindowProc +#define DefWindowProc DefWindowProcW //============================================================================== const int extendedKeyModifier = 0x10000; @@ -529,10 +489,6 @@ public: taskBarIcon (0), dropTarget (0) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - juce_initialiseUnicodeWindowFunctions(); -#endif - MessageManager::getInstance() ->callFunctionOnMessageThread (&createWindowCallback, (void*) this); @@ -592,14 +548,7 @@ public: void setTitle (const String& title) { -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wSetWindowTextW != 0) - wSetWindowTextW (hwnd, title); - else - SetWindowText (hwnd, title); -#else - SetWindowTextW (hwnd, title); -#endif + SetWindowText (hwnd, title); } void setPosition (int x, int y) @@ -762,7 +711,7 @@ public: if (hasTitleBar()) ShowWindow (hwnd, SW_SHOWMAXIMIZED); else - SendMessage (hwnd, WM_SETTINGCHANGE, 0, 0); + SendMessageW (hwnd, WM_SETTINGCHANGE, 0, 0); } if (! deletionChecker.hasBeenDeleted()) @@ -1024,47 +973,7 @@ private: GetModuleFileName (moduleHandle, moduleFile, 1024); WORD iconNum = 0; - #if JUCE_ENABLE_WIN98_COMPATIBILITY - if (wRegisterClassExW != 0) - { - WNDCLASSEXW wcex; - wcex.cbSize = sizeof (wcex); - wcex.style = CS_OWNDC; - wcex.lpfnWndProc = (WNDPROC) windowProc; - wcex.lpszClassName = windowClassName; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 32; - wcex.hInstance = moduleHandle; - wcex.hIcon = ExtractAssociatedIcon (moduleHandle, moduleFile, &iconNum); - iconNum = 1; - wcex.hIconSm = ExtractAssociatedIcon (moduleHandle, moduleFile, &iconNum); - wcex.hCursor = 0; - wcex.hbrBackground = 0; - wcex.lpszMenuName = 0; - - wRegisterClassExW (&wcex); - } - else - { - WNDCLASSEX wcex; - wcex.cbSize = sizeof (wcex); - wcex.style = CS_OWNDC; - wcex.lpfnWndProc = (WNDPROC) windowProc; - wcex.lpszClassName = windowClassName; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 32; - wcex.hInstance = moduleHandle; - wcex.hIcon = ExtractAssociatedIcon (moduleHandle, moduleFile, &iconNum); - iconNum = 1; - wcex.hIconSm = ExtractAssociatedIcon (moduleHandle, moduleFile, &iconNum); - wcex.hCursor = 0; - wcex.hbrBackground = 0; - wcex.lpszMenuName = 0; - - RegisterClassEx (&wcex); - } - #else - WNDCLASSEXW wcex; + WNDCLASSEX wcex; wcex.cbSize = sizeof (wcex); wcex.style = CS_OWNDC; wcex.lpfnWndProc = (WNDPROC) windowProc; @@ -1079,8 +988,7 @@ private: wcex.hbrBackground = 0; wcex.lpszMenuName = 0; - RegisterClassExW (&wcex); - #endif + RegisterClassEx (&wcex); } ~WindowClassHolder() @@ -1149,16 +1057,7 @@ private: && Desktop::canUseSemiTransparentWindows()) exstyle |= WS_EX_LAYERED; -#if JUCE_ENABLE_WIN98_COMPATIBILITY - const WindowClassHolder* const windowClassHolder = WindowClassHolder::getInstance(); - - if (wCreateWindowExW != 0) - hwnd = wCreateWindowExW (exstyle, windowClassHolder->windowClassName, L"", type, 0, 0, 0, 0, 0, 0, 0, 0); - else - hwnd = CreateWindowEx (exstyle, windowClassHolder->windowClassName, _T(""), type, 0, 0, 0, 0, 0, 0, 0, 0); -#else - hwnd = CreateWindowExW (exstyle, WindowClassHolder::getInstance()->windowClassName, L"", type, 0, 0, 0, 0, 0, 0, 0, 0); -#endif + hwnd = CreateWindowEx (exstyle, WindowClassHolder::getInstance()->windowClassName, L"", type, 0, 0, 0, 0, 0, 0, 0, 0); if (hwnd != 0) { @@ -1684,13 +1583,7 @@ private: // if there isn't a WM_CHAR or WM_DEADCHAR message pending, we need to // manually generate the key-press event that matches this key-down. -#if JUCE_ENABLE_WIN98_COMPATIBILITY - const UINT keyChar = wMapVirtualKeyW != 0 ? wMapVirtualKeyW (key, 2) - : MapVirtualKey (key, 2); -#else - const UINT keyChar = MapVirtualKeyW (key, 2); -#endif - + const UINT keyChar = MapVirtualKey (key, 2); used = handleKeyPress ((int) LOWORD (keyChar), 0) || used; } } @@ -1732,49 +1625,8 @@ private: else { // convert the scan code to an unmodified character code.. -#if JUCE_ENABLE_WIN98_COMPATIBILITY - const UINT virtualKey = wMapVirtualKeyW != 0 ? wMapVirtualKeyW (virtualScanCode, 1) - : MapVirtualKey (virtualScanCode, 1); - - UINT keyChar = wMapVirtualKeyW != 0 ? wMapVirtualKeyW (virtualKey, 2) - : MapVirtualKey (virtualKey, 2); - - if (wToUnicode != 0) - { - BYTE keyState[256]; - GetKeyboardState (keyState); - WCHAR unicodeChar[32]; - const DWORD converted = wToUnicode (virtualKey, virtualScanCode, keyState, - unicodeChar, 32, 0); - if (converted > 0) - { - // ahem.. can't actually remember why this section of code was originall here, - // so if you see this assertion, please let me know what you were doing at - // the time! - jassert (textChar == unicodeChar[0]); - // textChar = unicodeChar[0]; - } - } -#else - const UINT virtualKey = MapVirtualKeyW (virtualScanCode, 1); - UINT keyChar = MapVirtualKeyW (virtualKey, 2); - - { - BYTE keyState[256]; - GetKeyboardState (keyState); - WCHAR unicodeChar[32]; - const DWORD converted = ToUnicode (virtualKey, virtualScanCode, keyState, - unicodeChar, 32, 0); - if (converted > 0) - { - // ahem.. can't actually remember why this section of code was originall here, - // so if you see this assertion, please let me know what you were doing at - // the time! - jassert (textChar == unicodeChar[0]); -// textChar = unicodeChar[0]; - } - } -#endif + const UINT virtualKey = MapVirtualKey (virtualScanCode, 1); + UINT keyChar = MapVirtualKey (virtualKey, 2); keyChar = LOWORD (keyChar); @@ -3067,34 +2919,6 @@ static HDROP createHDrop (const StringArray& fileNames) throw() LPDROPFILES pDropFiles = (LPDROPFILES) GlobalLock (hDrop); pDropFiles->pFiles = sizeof (DROPFILES); -#if JUCE_ENABLE_WIN98_COMPATIBILITY - pDropFiles->fWide = (SystemStats::getOperatingSystemType() & SystemStats::WindowsNT) != 0; - - if (pDropFiles->fWide) - { - WCHAR* fname = (WCHAR*) (((char*) pDropFiles) + sizeof (DROPFILES)); - - for (int i = 0; i < fileNames.size(); ++i) - { - fileNames[i].copyToBuffer (fname, 2048); - fname += fileNames[i].length() + 1; - } - - *fname = 0; - } - else - { - char* fname = ((char*) pDropFiles) + sizeof (DROPFILES); - - for (int i = 0; i < fileNames.size(); ++i) - { - fileNames[i].copyToBuffer (fname, 2048); - fname += fileNames[i].length() + 1; - } - - *fname = 0; - } -#else pDropFiles->fWide = true; WCHAR* fname = (WCHAR*) (((char*) pDropFiles) + sizeof (DROPFILES)); @@ -3106,7 +2930,6 @@ static HDROP createHDrop (const StringArray& fileNames) throw() } *fname = 0; -#endif GlobalUnlock (hDrop); } @@ -3149,20 +2972,8 @@ bool DragAndDropContainer::performExternalDragDropOfText (const String& text) medium.hGlobal = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, (numChars + 2) * sizeof (WCHAR)); char* d = (char*) GlobalLock (medium.hGlobal); -#if JUCE_ENABLE_WIN98_COMPATIBILITY - if ((SystemStats::getOperatingSystemType() & SystemStats::WindowsNT) != 0) - { - text.copyToBuffer ((WCHAR*) d, numChars + 1); - format.cfFormat = CF_UNICODETEXT; - } - else - { - text.copyToBuffer (d, numChars + 1); - } -#else text.copyToBuffer ((WCHAR*) d, numChars + 1); format.cfFormat = CF_UNICODETEXT; -#endif GlobalUnlock (medium.hGlobal); @@ -4033,12 +3844,20 @@ static LRESULT CALLBACK activeXHookWndProc (HWND hwnd, UINT message, WPARAM wPar case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: + case WM_LBUTTONDBLCLK: + case WM_MBUTTONDBLCLK: + case WM_RBUTTONDBLCLK: if (ax->isShowing()) { ComponentPeer* const peer = ax->getPeer(); if (peer != 0) + { offerActiveXMouseEventToPeer (peer, hwnd, message, lParam); + + if (! ax->areMouseEventsAllowed()) + return 0; + } } break; @@ -4055,7 +3874,8 @@ static LRESULT CALLBACK activeXHookWndProc (HWND hwnd, UINT message, WPARAM wPar ActiveXControlComponent::ActiveXControlComponent() : originalWndProc (0), - control (0) + control (0), + mouseEventsAllowed (true) { activeXComps.add (this); } @@ -4169,5 +3989,10 @@ void ActiveXControlComponent::setControlVisible (const bool shouldBeVisible) con ShowWindow (hwnd, shouldBeVisible ? SW_SHOWNA : SW_HIDE); } +void ActiveXControlComponent::setMouseEventsAllowed (const bool eventsCanReachControl) +{ + mouseEventsAllowed = eventsCanReachControl; +} + END_JUCE_NAMESPACE diff --git a/build/win32/platform_specific_code/win32_headers.h b/build/win32/platform_specific_code/win32_headers.h index f5ef3c668d..2b29bbef0b 100644 --- a/build/win32/platform_specific_code/win32_headers.h +++ b/build/win32/platform_specific_code/win32_headers.h @@ -48,6 +48,9 @@ #define _WIN32_WINNT 0x0500 #endif +#define _UNICODE 1 +#define UNICODE 1 + #include #include #include @@ -61,22 +64,4 @@ #pragma warning (pop) #endif -//============================================================================== -#ifndef JUCE_ENABLE_WIN98_COMPATIBILITY - #define JUCE_ENABLE_WIN98_COMPATIBILITY 1 -#endif - -// helpers for dynamically loading unicode functions.. - -#if JUCE_ENABLE_WIN98_COMPATIBILITY - #define UNICODE_FUNCTION(functionName, returnType, params) \ - typedef returnType (WINAPI *type##functionName) params; \ - static type##functionName w##functionName = 0; - - #define UNICODE_FUNCTION_LOAD(functionName) \ - w##functionName = (type##functionName) GetProcAddress (h, #functionName); \ - jassert (w##functionName != 0); -#endif - - #endif // __WIN32_HEADERS_JUCEHEADER__ diff --git a/docs/JUCE changelist.txt b/docs/JUCE changelist.txt index e56dcf41e4..20cc7e8e1c 100644 --- a/docs/JUCE changelist.txt +++ b/docs/JUCE changelist.txt @@ -28,6 +28,7 @@ Changelist for version 1.46 - fixed InterprocessLock on mac/linux so that it can't get stuck when an app quits unexpectedly - added an option to splash screens to close themselves when the mouse is clicked - change to ProgressBar to allow custom text and bars that are just spinning without a known progress position. This also meant a change to the params for LookAndFeel::drawProgressBar +- ditched win98 non-unicode support (presumably nobody will miss that!) ============================================================================== Changelist for version 1.45 diff --git a/extras/audio plugins/demo/build/AudioUnit/Info-JuceAU.plist b/extras/audio plugins/demo/build/AudioUnit/Info-JuceAU.plist index e26db49912..c0cc15ff3f 100644 --- a/extras/audio plugins/demo/build/AudioUnit/Info-JuceAU.plist +++ b/extras/audio plugins/demo/build/AudioUnit/Info-JuceAU.plist @@ -5,7 +5,7 @@ CFBundleDevelopmentRegion English CFBundleExecutable - + DemoJuceAudioUnit CFBundleGetInfoString CFBundleIconFile diff --git a/extras/audio plugins/demo/build/AudioUnit/JuceDemoAU.xcodeproj/project.pbxproj b/extras/audio plugins/demo/build/AudioUnit/JuceDemoAU.xcodeproj/project.pbxproj index f6cbd51085..92e04c7c73 100644 --- a/extras/audio plugins/demo/build/AudioUnit/JuceDemoAU.xcodeproj/project.pbxproj +++ b/extras/audio plugins/demo/build/AudioUnit/JuceDemoAU.xcodeproj/project.pbxproj @@ -32,7 +32,6 @@ 84581F990D917FC700AE1A4C /* AUScopeElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 84581F8C0D917FC700AE1A4C /* AUScopeElement.h */; }; 84581F9A0D917FC700AE1A4C /* ComponentBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84581F8D0D917FC700AE1A4C /* ComponentBase.cpp */; }; 84581F9B0D917FC700AE1A4C /* ComponentBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 84581F8E0D917FC700AE1A4C /* ComponentBase.h */; }; - 845FAE5F0A5C0A6A008C94D8 /* juce.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 845FAE5E0A5C0A6A008C94D8 /* juce.xcconfig */; }; 845FAEE10A5C2696008C94D8 /* QuickTime.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 845FAEE00A5C2696008C94D8 /* QuickTime.framework */; }; 84B4CDD10C7DD23B0083122F /* MusicDeviceBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B4CDCF0C7DD23B0083122F /* MusicDeviceBase.cpp */; }; 84B4CDD20C7DD23B0083122F /* MusicDeviceBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 84B4CDD00C7DD23B0083122F /* MusicDeviceBase.h */; }; @@ -48,7 +47,6 @@ 84EB400C090A4A2C008FAC1B /* juce_AudioUnitWrapper.r in Rez */ = {isa = PBXBuildFile; fileRef = 84EB400A090A4A2C008FAC1B /* juce_AudioUnitWrapper.r */; }; 84EB4042090A4F5A008FAC1B /* CAVectorUnit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4E5DC280898301D00589A5A /* CAVectorUnit.cpp */; }; 84EB404E090A5116008FAC1B /* JucePluginCharacteristics.h in Headers */ = {isa = PBXBuildFile; fileRef = 84EB404D090A5116008FAC1B /* JucePluginCharacteristics.h */; }; - 84F0521E090674BB00AEC8DB /* Info-JuceAU.plist in Resources */ = {isa = PBXBuildFile; fileRef = 84F05215090674BB00AEC8DB /* Info-JuceAU.plist */; }; 84F0548F090687F600AEC8DB /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84F0548E090687F600AEC8DB /* CoreAudio.framework */; }; 84F054E80906C8DD00AEC8DB /* AUMIDIBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84F054E40906C8DD00AEC8DB /* AUMIDIBase.cpp */; }; 84F054E90906C8DD00AEC8DB /* AUMIDIBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 84F054E50906C8DD00AEC8DB /* AUMIDIBase.h */; }; @@ -454,8 +452,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 84F0521E090674BB00AEC8DB /* Info-JuceAU.plist in Resources */, - 845FAE5F0A5C0A6A008C94D8 /* juce.xcconfig in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/juce_appframework/gui/components/special/juce_ActiveXControlComponent.h b/src/juce_appframework/gui/components/special/juce_ActiveXControlComponent.h index 6cd82ce3fe..b432a927ea 100644 --- a/src/juce_appframework/gui/components/special/juce_ActiveXControlComponent.h +++ b/src/juce_appframework/gui/components/special/juce_ActiveXControlComponent.h @@ -105,6 +105,13 @@ public: */ void* queryInterface (const void* iid) const; + /** Set this to false to stop mouse events being allowed through to the control. + */ + void setMouseEventsAllowed (const bool eventsCanReachControl); + + /** Returns true if mouse events are allowed to get through to the control. + */ + bool areMouseEventsAllowed() const throw() { return mouseEventsAllowed; } //============================================================================== /** @internal */ @@ -117,6 +124,7 @@ public: private: friend class ActiveXControlData; void* control; + bool mouseEventsAllowed; ActiveXControlComponent (const ActiveXControlComponent&); const ActiveXControlComponent& operator= (const ActiveXControlComponent&); diff --git a/src/juce_appframework/gui/components/special/juce_QuickTimeMovieComponent.cpp b/src/juce_appframework/gui/components/special/juce_QuickTimeMovieComponent.cpp index 881102f53f..e905ead4a3 100644 --- a/src/juce_appframework/gui/components/special/juce_QuickTimeMovieComponent.cpp +++ b/src/juce_appframework/gui/components/special/juce_QuickTimeMovieComponent.cpp @@ -1,1089 +1,1089 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. - - JUCE is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. - - ============================================================================== -*/ - -#include "../../../../../juce_Config.h" - -#if JUCE_QUICKTIME - -#ifdef _MSC_VER - #pragma warning (disable: 4514) -#endif - -#ifdef _WIN32 - #include - - #ifdef _MSC_VER - #pragma warning (push) - #pragma warning (disable : 4100) - #endif - +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +#include "../../../../../juce_Config.h" + +#if JUCE_QUICKTIME + +#ifdef _MSC_VER + #pragma warning (disable: 4514) +#endif + +#ifdef _WIN32 + #include + + #ifdef _MSC_VER + #pragma warning (push) + #pragma warning (disable : 4100) + #endif + /* If you've got an include error here, you probably need to install the QuickTime SDK and add its header directory to your include path. Alternatively, if you don't need any QuickTime services, just turn off the JUC_QUICKTIME flag in juce_Config.h */ - #include - #include - #include - #include - #include - - #ifdef _MSC_VER - #pragma warning (pop) - #endif - - // If you've got QuickTime 7 installed, then these COM objects should be found in - // the "\Program Files\Quicktime" directory. You'll need to add this directory to - // your include search path to make these import statements work. - #import - #import - - using namespace QTOLibrary; - using namespace QTOControlLib; -#else - #include - #include - #include - #include -#endif - -#include "../../../../juce_core/basics/juce_StandardHeader.h" - -BEGIN_JUCE_NAMESPACE - -#include "juce_QuickTimeMovieComponent.h" -#include "../../../../juce_core/io/files/juce_FileInputStream.h" - -bool juce_OpenQuickTimeMovieFromStream (InputStream* input, Movie& movie, Handle& dataHandle); - - -//============================================================================== -struct QTMovieCompInternal -{ - QTMovieCompInternal() - : dataHandle (0) - { -#if JUCE_MAC - movie = 0; - controller = 0; -#endif - } - - ~QTMovieCompInternal() - { - clearHandle(); - } - -#if JUCE_MAC - Movie movie; - MovieController controller; -#else - IQTControlPtr qtControlInternal; - IQTMoviePtr qtMovieInternal; -#endif - - Handle dataHandle; - - void clearHandle() - { - if (dataHandle != 0) - { - DisposeHandle (dataHandle); - dataHandle = 0; - } - } -}; - -#if JUCE_WIN32 - -#define qtControl (((QTMovieCompInternal*) internal)->qtControlInternal) -#define qtMovie (((QTMovieCompInternal*) internal)->qtMovieInternal) - -//============================================================================== -QuickTimeMovieComponent::QuickTimeMovieComponent() - : movieLoaded (false), - controllerVisible (true) -{ - internal = new QTMovieCompInternal(); -} - -QuickTimeMovieComponent::~QuickTimeMovieComponent() -{ - closeMovie(); - qtControl = 0; - - deleteControl(); - - delete internal; - internal = 0; -} - -//============================================================================== -void QuickTimeMovieComponent::createControlIfNeeded() -{ - if (isShowing() && ! isControlCreated()) - { - const IID qtIID = __uuidof (QTControl); - - if (createControl (&qtIID)) - { - const IID qtInterfaceIID = __uuidof (IQTControl); - qtControl = (IQTControl*) queryInterface (&qtInterfaceIID); - - if (qtControl != 0) - { - qtControl->Release(); // it has one ref too many at this point - - qtControl->QuickTimeInitialize(); - qtControl->PutSizing (qtMovieFitsControl); - - if (movieFile != File::nonexistent) - loadMovie (movieFile, controllerVisible); - } - } - } -} - -bool QuickTimeMovieComponent::isControlCreated() const -{ - return isControlOpen(); -} - -bool QuickTimeMovieComponent::loadMovie (InputStream* movieStream, - const bool isControllerVisible) -{ - movieFile = File::nonexistent; - movieLoaded = false; - qtMovie = 0; - controllerVisible = isControllerVisible; - createControlIfNeeded(); - - if (isControlCreated()) - { - if (qtControl != 0) - { - qtControl->Put_MovieHandle (0); - ((QTMovieCompInternal*) internal)->clearHandle(); - - Movie movie; - if (juce_OpenQuickTimeMovieFromStream (movieStream, movie, ((QTMovieCompInternal*) internal)->dataHandle)) - { - qtControl->Put_MovieHandle ((long) (pointer_sized_int) movie); - - qtMovie = qtControl->GetMovie(); - - if (qtMovie != 0) - qtMovie->PutMovieControllerType (isControllerVisible ? qtMovieControllerTypeStandard - : qtMovieControllerTypeNone); - } - - if (movie == 0) - ((QTMovieCompInternal*) internal)->clearHandle(); - } - - movieLoaded = (qtMovie != 0); - } - else - { - // You're trying to open a movie when the control hasn't yet been created, probably because - // you've not yet added this component to a Window and made the whole component hierarchy visible. - jassertfalse - } - - delete movieStream; - return movieLoaded; -} - -void QuickTimeMovieComponent::closeMovie() -{ - stop(); - movieFile = File::nonexistent; - movieLoaded = false; - qtMovie = 0; - - if (qtControl != 0) - qtControl->Put_MovieHandle (0); - //qtControl->PutURL (L""); - - ((QTMovieCompInternal*) internal)->clearHandle(); -} - -const File QuickTimeMovieComponent::getCurrentMovieFile() const -{ - return movieFile; -} - -bool QuickTimeMovieComponent::isMovieOpen() const -{ - return movieLoaded; -} - -double QuickTimeMovieComponent::getMovieDuration() const -{ - if (qtMovie != 0) - return qtMovie->GetDuration() / (double) qtMovie->GetTimeScale(); - - return 0.0; -} - -void QuickTimeMovieComponent::getMovieNormalSize (int& width, int& height) const -{ - if (qtMovie != 0) - { - struct QTRECT r = qtMovie->GetNaturalRect(); - - width = r.right - r.left; - height = r.bottom - r.top; - } - else - { - width = height = 0; - } -} - -void QuickTimeMovieComponent::play() -{ - if (qtMovie != 0) - qtMovie->Play(); -} - -void QuickTimeMovieComponent::stop() -{ - if (qtMovie != 0) - qtMovie->Stop(); -} - -bool QuickTimeMovieComponent::isPlaying() const -{ - return qtMovie != 0 && qtMovie->GetRate() != 0.0f; -} - -void QuickTimeMovieComponent::setPosition (const double seconds) -{ - if (qtMovie != 0) - qtMovie->PutTime ((long) (seconds * qtMovie->GetTimeScale())); -} - -double QuickTimeMovieComponent::getPosition() const -{ - if (qtMovie != 0) - return qtMovie->GetTime() / (double) qtMovie->GetTimeScale(); - - return 0.0; -} - -void QuickTimeMovieComponent::setSpeed (const float newSpeed) -{ - if (qtMovie != 0) - qtMovie->PutRate (newSpeed); -} - -void QuickTimeMovieComponent::setMovieVolume (const float newVolume) -{ - if (qtMovie != 0) - qtMovie->PutAudioVolume (newVolume); -} - -float QuickTimeMovieComponent::getMovieVolume() const -{ - if (qtMovie != 0) - return qtMovie->GetAudioVolume(); - - return 0.0f; -} - -void QuickTimeMovieComponent::setLooping (const bool shouldLoop) -{ - if (qtMovie != 0) - qtMovie->PutLoop (shouldLoop); -} - -bool QuickTimeMovieComponent::isLooping() const -{ - return qtMovie != 0 && qtMovie->GetLoop(); -} - -bool QuickTimeMovieComponent::isControllerVisible() const -{ - return controllerVisible; -} - -void QuickTimeMovieComponent::parentHierarchyChanged() -{ - createControlIfNeeded(); - QTWinBaseClass::parentHierarchyChanged(); -} - -void QuickTimeMovieComponent::visibilityChanged() -{ - createControlIfNeeded(); - QTWinBaseClass::visibilityChanged(); -} - -void QuickTimeMovieComponent::paint (Graphics& g) -{ - if (! isControlCreated()) - g.fillAll (Colours::black); -} - -#endif - -//============================================================================== -#if JUCE_MAC - -#include "../../../../juce_core/misc/juce_PlatformUtilities.h" -#include "../../../events/juce_MessageManager.h" -#include "../../graphics/geometry/juce_RectangleList.h" - -static bool isQTAvailable = false; -static bool hasLoadedQT = false; -static VoidArray activeQTWindows (2); - -struct MacClickEventData -{ - ::Point where; - long when; - long modifiers; -}; - -void OfferMouseClickToQuickTime (WindowRef window, - ::Point where, long when, long modifiers, - Component* topLevelComp) -{ - if (hasLoadedQT) - { - for (int i = activeQTWindows.size(); --i >= 0;) - { - QuickTimeMovieComponent* const qtw = (QuickTimeMovieComponent*) activeQTWindows[i]; - - if (qtw->isVisible() && topLevelComp->isParentOf (qtw)) - { - MacClickEventData data; - data.where = where; - data.when = when; - data.modifiers = modifiers; - - qtw->handleMCEvent (&data); - } - } - } -} - -//============================================================================== -QuickTimeMovieComponent::QuickTimeMovieComponent() - : internal (new QTMovieCompInternal()), - associatedWindow (0), - controllerVisible (false), - controllerAssignedToWindow (false), - reentrant (false) -{ - if (! hasLoadedQT) - { - hasLoadedQT = true; - isQTAvailable = EnterMovies() == noErr; - } - - setOpaque (true); - setVisible (true); - - activeQTWindows.add (this); -} - -QuickTimeMovieComponent::~QuickTimeMovieComponent() -{ - closeMovie(); - - activeQTWindows.removeValue ((void*) this); - - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - delete id; - - if (activeQTWindows.size() == 0 && isQTAvailable) - { - isQTAvailable = false; - hasLoadedQT = false; - - ExitMovies(); - } -} - -bool QuickTimeMovieComponent::loadMovie (InputStream* movieStream, - const bool controllerVisible_) -{ - if (! isQTAvailable) - return false; - - closeMovie(); - movieFile = File::nonexistent; - - if (getPeer() == 0) - { - // To open a movie, this component must be visible inside a functioning window, so that - // the QT control can be assigned to the window. - jassertfalse - return false; - } - - controllerVisible = controllerVisible_; - - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - GrafPtr savedPort; - GetPort (&savedPort); - bool result = false; - - if (juce_OpenQuickTimeMovieFromStream (movieStream, id->movie, id->dataHandle)) - { - id->controller = 0; - - void* window = getWindowHandle(); - - if (window != associatedWindow && window != 0) - associatedWindow = window; - - assignMovieToWindow(); - - SetMovieActive (id->movie, true); - SetMovieProgressProc (id->movie, (MovieProgressUPP) -1, 0); - - startTimer (1000 / 50); // this needs to be quite a high frequency for smooth playback - result = true; - - repaint(); - } - - MacSetPort (savedPort); - - return result; -} - -void QuickTimeMovieComponent::closeMovie() -{ - stop(); - - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - if (id->controller != 0) - { - DisposeMovieController (id->controller); - id->controller = 0; - } - - if (id->movie != 0) - { - DisposeMovie (id->movie); - id->movie = 0; - } - - id->clearHandle(); - - stopTimer(); - movieFile = File::nonexistent; -} - -bool QuickTimeMovieComponent::isMovieOpen() const -{ - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - return id->movie != 0 && id->controller != 0; -} - -const File QuickTimeMovieComponent::getCurrentMovieFile() const -{ - return movieFile; -} - -static GrafPtr getPortForWindow (void* window) -{ - if (window == 0) - return 0; - - return (GrafPtr) GetWindowPort ((WindowRef) window); -} - -void QuickTimeMovieComponent::assignMovieToWindow() -{ - if (reentrant) - return; - - reentrant = true; - - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - if (id->controller != 0) - { - DisposeMovieController (id->controller); - id->controller = 0; - } - - controllerAssignedToWindow = false; - - void* window = getWindowHandle(); - GrafPtr port = getPortForWindow (window); - - if (port != 0) - { - GrafPtr savedPort; - GetPort (&savedPort); - - SetMovieGWorld (id->movie, (CGrafPtr) port, 0); - MacSetPort (port); - - Rect r; - r.top = 0; - r.left = 0; - r.right = (short) jmax (1, getWidth()); - r.bottom = (short) jmax (1, getHeight()); - SetMovieBox (id->movie, &r); - - // create the movie controller - id->controller = NewMovieController (id->movie, &r, - controllerVisible ? mcTopLeftMovie - : mcNotVisible); - - if (id->controller != 0) - { - MCEnableEditing (id->controller, true); - - MCDoAction (id->controller, mcActionSetUseBadge, (void*) false); - MCDoAction (id->controller, mcActionSetLoopIsPalindrome, (void*) false); - setLooping (looping); - - MCDoAction (id->controller, mcActionSetFlags, - (void*) (pointer_sized_int) (mcFlagSuppressMovieFrame | (controllerVisible ? 0 : (mcFlagSuppressStepButtons | mcFlagSuppressSpeakerButton)))); - - MCSetControllerBoundsRect (id->controller, &r); - - controllerAssignedToWindow = true; - - resized(); - } - - MacSetPort (savedPort); - } - else - { - SetMovieGWorld (id->movie, 0, 0); - } - - reentrant = false; -} - -void QuickTimeMovieComponent::play() -{ - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - if (id->movie != 0) - StartMovie (id->movie); -} - -void QuickTimeMovieComponent::stop() -{ - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - if (id->movie != 0) - StopMovie (id->movie); -} - -bool QuickTimeMovieComponent::isPlaying() const -{ - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - return id->movie != 0 && GetMovieRate (id->movie) != 0; -} - -void QuickTimeMovieComponent::setPosition (const double seconds) -{ - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - if (id->controller != 0) - { - TimeRecord time; - time.base = GetMovieTimeBase (id->movie); - time.scale = 100000; - const uint64 t = (uint64) (100000.0 * seconds); - time.value.lo = (UInt32) (t & 0xffffffff); - time.value.hi = (UInt32) (t >> 32); - - SetMovieTime (id->movie, &time); - timerCallback(); // to call MCIdle - } - else - { - jassertfalse // no movie is open, so can't set the position. - } -} - -double QuickTimeMovieComponent::getPosition() const -{ - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - if (id->movie != 0) - { - TimeRecord time; - GetMovieTime (id->movie, &time); - - return ((int64) (((uint64) time.value.hi << 32) | (uint64) time.value.lo)) - / (double) time.scale; - } - - return 0.0; -} - -void QuickTimeMovieComponent::setSpeed (const float newSpeed) -{ - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - if (id->movie != 0) - SetMovieRate (id->movie, (Fixed) (newSpeed * (Fixed) 0x00010000L)); -} - -double QuickTimeMovieComponent::getMovieDuration() const -{ - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - if (id->movie != 0) - return GetMovieDuration (id->movie) / (double) GetMovieTimeScale (id->movie); - - return 0.0; -} - -void QuickTimeMovieComponent::setLooping (const bool shouldLoop) -{ - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - looping = shouldLoop; - - if (id->controller != 0) - MCDoAction (id->controller, mcActionSetLooping, (void*) shouldLoop); -} - -bool QuickTimeMovieComponent::isLooping() const -{ - return looping; -} - -void QuickTimeMovieComponent::setMovieVolume (const float newVolume) -{ - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - if (id->movie != 0) - SetMovieVolume (id->movie, jlimit ((short) 0, (short) 0x100, (short) (newVolume * 0x0100))); -} - -float QuickTimeMovieComponent::getMovieVolume() const -{ - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - if (id->movie != 0) - return jmax (0.0f, GetMovieVolume (id->movie) / (float) 0x0100); - - return 0.0f; -} - -void QuickTimeMovieComponent::getMovieNormalSize (int& width, int& height) const -{ - width = 0; - height = 0; - - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - if (id->movie != 0) - { - Rect r; - GetMovieNaturalBoundsRect (id->movie, &r); - width = r.right - r.left; - height = r.bottom - r.top; - } -} - -void QuickTimeMovieComponent::paint (Graphics& g) -{ - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - if (id->movie == 0 || id->controller == 0) - { - g.fillAll (Colours::black); - return; - } - - GrafPtr savedPort; - GetPort (&savedPort); - - MacSetPort (getPortForWindow (getWindowHandle())); - MCDraw (id->controller, (WindowRef) getWindowHandle()); - - MacSetPort (savedPort); - - ComponentPeer* const peer = getPeer(); - - if (peer != 0) - { - peer->addMaskedRegion (getScreenX() - peer->getScreenX(), - getScreenY() - peer->getScreenY(), - getWidth(), getHeight()); - } - - timerCallback(); -} - -static const Rectangle getMoviePos (Component* const c) -{ - return Rectangle (c->getScreenX() - c->getTopLevelComponent()->getScreenX(), - c->getScreenY() - c->getTopLevelComponent()->getScreenY(), - jmax (1, c->getWidth()), - jmax (1, c->getHeight())); -} - -void QuickTimeMovieComponent::moved() -{ - resized(); -} - -void QuickTimeMovieComponent::resized() -{ - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - if (id->controller != 0 && isShowing()) - { - checkWindowAssociation(); - - GrafPtr port = getPortForWindow (getWindowHandle()); - - if (port != 0) - { - GrafPtr savedPort; - GetPort (&savedPort); - - SetMovieGWorld (id->movie, (CGrafPtr) port, 0); - MacSetPort (port); - - lastPositionApplied = getMoviePos (this); - - Rect r; - r.left = (short) lastPositionApplied.getX(); - r.top = (short) lastPositionApplied.getY(); - r.right = (short) lastPositionApplied.getRight(); - r.bottom = (short) lastPositionApplied.getBottom(); - - if (MCGetVisible (id->controller)) - MCSetControllerBoundsRect (id->controller, &r); - else - SetMovieBox (id->movie, &r); - - if (! isPlaying()) - timerCallback(); - - MacSetPort (savedPort); - - repaint(); - } - } -} - -void QuickTimeMovieComponent::visibilityChanged() -{ - checkWindowAssociation(); - QTWinBaseClass::visibilityChanged(); -} - -void QuickTimeMovieComponent::timerCallback() -{ - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - if (id->controller != 0) - { - if (isTimerRunning()) - startTimer (getTimerInterval()); - - MCIdle (id->controller); - - if (lastPositionApplied != getMoviePos (this)) - resized(); - } -} - -void QuickTimeMovieComponent::checkWindowAssociation() -{ - void* const window = getWindowHandle(); - - if (window != associatedWindow - || (window != 0 && ! controllerAssignedToWindow)) - { - associatedWindow = window; - assignMovieToWindow(); - } -} - -void QuickTimeMovieComponent::parentHierarchyChanged() -{ - checkWindowAssociation(); -} - -void QuickTimeMovieComponent::handleMCEvent (void* ev) -{ - QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; - - if (id->controller != 0 && isShowing()) - { - MacClickEventData* data = (MacClickEventData*) ev; - - data->where.h -= getTopLevelComponent()->getScreenX(); - data->where.v -= getTopLevelComponent()->getScreenY(); - - Boolean b = false; - MCPtInController (id->controller, data->where, &b); - - if (b) - { - const int oldTimeBeforeWaitCursor = MessageManager::getInstance()->getTimeBeforeShowingWaitCursor(); - MessageManager::getInstance()->setTimeBeforeShowingWaitCursor (0); - - MCClick (id->controller, - (WindowRef) getWindowHandle(), - data->where, - data->when, - data->modifiers); - - MessageManager::getInstance()->setTimeBeforeShowingWaitCursor (oldTimeBeforeWaitCursor); - } - } -} - -#endif - -//============================================================================== -// (methods common to both platforms..) - -static Handle createHandleDataRef (Handle dataHandle, const char* fileName) -{ - Handle dataRef = 0; - OSStatus err = PtrToHand (&dataHandle, &dataRef, sizeof (Handle)); - if (err == noErr) - { - Str255 suffix; -#if JUCE_WIN32 - strcpy_s ((char*) suffix, 128, fileName); -#else - strcpy ((char*) suffix, fileName); -#endif - StringPtr name = suffix; - err = PtrAndHand (name, dataRef, name[0] + 1); - - if (err == noErr) - { - long atoms[3]; - atoms[0] = EndianU32_NtoB (3 * sizeof (long)); - atoms[1] = EndianU32_NtoB (kDataRefExtensionMacOSFileType); - atoms[2] = EndianU32_NtoB (MovieFileType); - - err = PtrAndHand (atoms, dataRef, 3 * sizeof (long)); - - if (err == noErr) - return dataRef; - } - - DisposeHandle (dataRef); - } - - return 0; -} - -static CFStringRef juceStringToCFString (const String& s) -{ - const int len = s.length(); - const juce_wchar* const t = (const juce_wchar*) s; - - UniChar* temp = (UniChar*) juce_malloc (sizeof (UniChar) * len + 4); - - for (int i = 0; i <= len; ++i) - temp[i] = t[i]; - - CFStringRef result = CFStringCreateWithCharacters (kCFAllocatorDefault, temp, len); - juce_free (temp); - - return result; -} - -static bool openMovie (QTNewMoviePropertyElement* props, int prop, Movie& movie) -{ - Boolean trueBool = true; - props[prop].propClass = kQTPropertyClass_MovieInstantiation; - props[prop].propID = kQTMovieInstantiationPropertyID_DontResolveDataRefs; - props[prop].propValueSize = sizeof (trueBool); - props[prop].propValueAddress = &trueBool; - ++prop; - - props[prop].propClass = kQTPropertyClass_MovieInstantiation; - props[prop].propID = kQTMovieInstantiationPropertyID_AsyncOK; - props[prop].propValueSize = sizeof (trueBool); - props[prop].propValueAddress = &trueBool; - ++prop; - - Boolean isActive = true; - props[prop].propClass = kQTPropertyClass_NewMovieProperty; - props[prop].propID = kQTNewMoviePropertyID_Active; - props[prop].propValueSize = sizeof (isActive); - props[prop].propValueAddress = &isActive; - ++prop; - -#if JUCE_MAC - SetPort (0); -#else - MacSetPort (0); -#endif - - jassert (prop <= 5); - OSStatus err = NewMovieFromProperties (prop, props, 0, 0, &movie); - - return err == noErr; -} - -bool juce_OpenQuickTimeMovieFromStream (InputStream* input, Movie& movie, Handle& dataHandle) -{ - if (input == 0) - return false; - - dataHandle = 0; - bool ok = false; - - QTNewMoviePropertyElement props[5]; - zeromem (props, sizeof (props)); - int prop = 0; - - DataReferenceRecord dr; - props[prop].propClass = kQTPropertyClass_DataLocation; - props[prop].propID = kQTDataLocationPropertyID_DataReference; - props[prop].propValueSize = sizeof (dr); - props[prop].propValueAddress = (void*) &dr; - ++prop; - - FileInputStream* const fin = dynamic_cast (input); - - if (fin != 0) - { - CFStringRef filePath = juceStringToCFString (fin->getFile().getFullPathName()); - - QTNewDataReferenceFromFullPathCFString (filePath, (QTPathStyle) kQTNativeDefaultPathStyle, 0, - &dr.dataRef, &dr.dataRefType); - - - ok = openMovie (props, prop, movie); - - DisposeHandle (dr.dataRef); - CFRelease (filePath); - } - else - { - // sanity-check because this currently needs to load the whole stream into memory.. - jassert (input->getTotalLength() < 50 * 1024 * 1024); - - dataHandle = NewHandle ((Size) input->getTotalLength()); - HLock (dataHandle); - // read the entire stream into memory - this is a pain, but can't get it to work - // properly using a custom callback to supply the data. - input->read (*dataHandle, (int) input->getTotalLength()); - HUnlock (dataHandle); - - // different types to get QT to try. (We should really be a bit smarter here by - // working out in advance which one the stream contains, rather than just trying - // each one) - const char* const suffixesToTry[] = { "\04.mov", "\04.mp3", - "\04.avi", "\04.m4a" }; - - for (int i = 0; i < numElementsInArray (suffixesToTry) && ! ok; ++i) - { - /* // this fails for some bizarre reason - it can be bodged to work with - // movies, but can't seem to do it for other file types.. - QTNewMovieUserProcRecord procInfo; - procInfo.getMovieUserProc = NewGetMovieUPP (readMovieStreamProc); - procInfo.getMovieUserProcRefcon = this; - procInfo.defaultDataRef.dataRef = dataRef; - procInfo.defaultDataRef.dataRefType = HandleDataHandlerSubType; - - props[prop].propClass = kQTPropertyClass_DataLocation; - props[prop].propID = kQTDataLocationPropertyID_MovieUserProc; - props[prop].propValueSize = sizeof (procInfo); - props[prop].propValueAddress = (void*) &procInfo; - ++prop; */ - - dr.dataRef = createHandleDataRef (dataHandle, suffixesToTry [i]); - dr.dataRefType = HandleDataHandlerSubType; - ok = openMovie (props, prop, movie); - - DisposeHandle (dr.dataRef); - } - } - - return ok; -} - -bool QuickTimeMovieComponent::loadMovie (const File& movieFile_, - const bool isControllerVisible) -{ - const bool ok = loadMovie ((InputStream*) movieFile_.createInputStream(), isControllerVisible); - movieFile = movieFile_; - return ok; -} - -void QuickTimeMovieComponent::goToStart() -{ - setPosition (0.0); -} - -void QuickTimeMovieComponent::setBoundsWithCorrectAspectRatio (const Rectangle& spaceToFitWithin, - const RectanglePlacement& placement) -{ - int normalWidth, normalHeight; - getMovieNormalSize (normalWidth, normalHeight); - - if (normalWidth > 0 && normalHeight > 0 && ! spaceToFitWithin.isEmpty()) - { - double x = 0.0, y = 0.0, w = normalWidth, h = normalHeight; - - placement.applyTo (x, y, w, h, - spaceToFitWithin.getX(), spaceToFitWithin.getY(), - spaceToFitWithin.getWidth(), spaceToFitWithin.getHeight()); - - if (w > 0 && h > 0) - { - setBounds (roundDoubleToInt (x), roundDoubleToInt (y), - roundDoubleToInt (w), roundDoubleToInt (h)); - } - } - else - { - setBounds (spaceToFitWithin); - } -} - - -END_JUCE_NAMESPACE - -#endif + #include + #include + #include + #include + #include + + #ifdef _MSC_VER + #pragma warning (pop) + #endif + + // If you've got QuickTime 7 installed, then these COM objects should be found in + // the "\Program Files\Quicktime" directory. You'll need to add this directory to + // your include search path to make these import statements work. + #import + #import + + using namespace QTOLibrary; + using namespace QTOControlLib; +#else + #include + #include + #include + #include +#endif + +#include "../../../../juce_core/basics/juce_StandardHeader.h" + +BEGIN_JUCE_NAMESPACE + +#include "juce_QuickTimeMovieComponent.h" +#include "../../../../juce_core/io/files/juce_FileInputStream.h" + +bool juce_OpenQuickTimeMovieFromStream (InputStream* input, Movie& movie, Handle& dataHandle); + + +//============================================================================== +struct QTMovieCompInternal +{ + QTMovieCompInternal() + : dataHandle (0) + { +#if JUCE_MAC + movie = 0; + controller = 0; +#endif + } + + ~QTMovieCompInternal() + { + clearHandle(); + } + +#if JUCE_MAC + Movie movie; + MovieController controller; +#else + IQTControlPtr qtControlInternal; + IQTMoviePtr qtMovieInternal; +#endif + + Handle dataHandle; + + void clearHandle() + { + if (dataHandle != 0) + { + DisposeHandle (dataHandle); + dataHandle = 0; + } + } +}; + +#if JUCE_WIN32 + +#define qtControl (((QTMovieCompInternal*) internal)->qtControlInternal) +#define qtMovie (((QTMovieCompInternal*) internal)->qtMovieInternal) + +//============================================================================== +QuickTimeMovieComponent::QuickTimeMovieComponent() + : movieLoaded (false), + controllerVisible (true) +{ + internal = new QTMovieCompInternal(); + setMouseEventsAllowed (false); +} + +QuickTimeMovieComponent::~QuickTimeMovieComponent() +{ + closeMovie(); + qtControl = 0; + + deleteControl(); + + delete internal; + internal = 0; +} + +//============================================================================== +void QuickTimeMovieComponent::createControlIfNeeded() +{ + if (isShowing() && ! isControlCreated()) + { + const IID qtIID = __uuidof (QTControl); + + if (createControl (&qtIID)) + { + const IID qtInterfaceIID = __uuidof (IQTControl); + qtControl = (IQTControl*) queryInterface (&qtInterfaceIID); + + if (qtControl != 0) + { + qtControl->Release(); // it has one ref too many at this point + + qtControl->QuickTimeInitialize(); + qtControl->PutSizing (qtMovieFitsControl); + + if (movieFile != File::nonexistent) + loadMovie (movieFile, controllerVisible); + } + } + } +} + +bool QuickTimeMovieComponent::isControlCreated() const +{ + return isControlOpen(); +} + +bool QuickTimeMovieComponent::loadMovie (InputStream* movieStream, + const bool isControllerVisible) +{ + movieFile = File::nonexistent; + movieLoaded = false; + qtMovie = 0; + controllerVisible = isControllerVisible; + createControlIfNeeded(); + + if (isControlCreated()) + { + if (qtControl != 0) + { + qtControl->Put_MovieHandle (0); + ((QTMovieCompInternal*) internal)->clearHandle(); + + Movie movie; + if (juce_OpenQuickTimeMovieFromStream (movieStream, movie, ((QTMovieCompInternal*) internal)->dataHandle)) + { + qtControl->Put_MovieHandle ((long) (pointer_sized_int) movie); + + qtMovie = qtControl->GetMovie(); + + if (qtMovie != 0) + qtMovie->PutMovieControllerType (isControllerVisible ? qtMovieControllerTypeStandard + : qtMovieControllerTypeNone); + } + + if (movie == 0) + ((QTMovieCompInternal*) internal)->clearHandle(); + } + + movieLoaded = (qtMovie != 0); + } + else + { + // You're trying to open a movie when the control hasn't yet been created, probably because + // you've not yet added this component to a Window and made the whole component hierarchy visible. + jassertfalse + } + + delete movieStream; + return movieLoaded; +} + +void QuickTimeMovieComponent::closeMovie() +{ + stop(); + movieFile = File::nonexistent; + movieLoaded = false; + qtMovie = 0; + + if (qtControl != 0) + qtControl->Put_MovieHandle (0); + + ((QTMovieCompInternal*) internal)->clearHandle(); +} + +const File QuickTimeMovieComponent::getCurrentMovieFile() const +{ + return movieFile; +} + +bool QuickTimeMovieComponent::isMovieOpen() const +{ + return movieLoaded; +} + +double QuickTimeMovieComponent::getMovieDuration() const +{ + if (qtMovie != 0) + return qtMovie->GetDuration() / (double) qtMovie->GetTimeScale(); + + return 0.0; +} + +void QuickTimeMovieComponent::getMovieNormalSize (int& width, int& height) const +{ + if (qtMovie != 0) + { + struct QTRECT r = qtMovie->GetNaturalRect(); + + width = r.right - r.left; + height = r.bottom - r.top; + } + else + { + width = height = 0; + } +} + +void QuickTimeMovieComponent::play() +{ + if (qtMovie != 0) + qtMovie->Play(); +} + +void QuickTimeMovieComponent::stop() +{ + if (qtMovie != 0) + qtMovie->Stop(); +} + +bool QuickTimeMovieComponent::isPlaying() const +{ + return qtMovie != 0 && qtMovie->GetRate() != 0.0f; +} + +void QuickTimeMovieComponent::setPosition (const double seconds) +{ + if (qtMovie != 0) + qtMovie->PutTime ((long) (seconds * qtMovie->GetTimeScale())); +} + +double QuickTimeMovieComponent::getPosition() const +{ + if (qtMovie != 0) + return qtMovie->GetTime() / (double) qtMovie->GetTimeScale(); + + return 0.0; +} + +void QuickTimeMovieComponent::setSpeed (const float newSpeed) +{ + if (qtMovie != 0) + qtMovie->PutRate (newSpeed); +} + +void QuickTimeMovieComponent::setMovieVolume (const float newVolume) +{ + if (qtMovie != 0) + qtMovie->PutAudioVolume (newVolume); +} + +float QuickTimeMovieComponent::getMovieVolume() const +{ + if (qtMovie != 0) + return qtMovie->GetAudioVolume(); + + return 0.0f; +} + +void QuickTimeMovieComponent::setLooping (const bool shouldLoop) +{ + if (qtMovie != 0) + qtMovie->PutLoop (shouldLoop); +} + +bool QuickTimeMovieComponent::isLooping() const +{ + return qtMovie != 0 && qtMovie->GetLoop(); +} + +bool QuickTimeMovieComponent::isControllerVisible() const +{ + return controllerVisible; +} + +void QuickTimeMovieComponent::parentHierarchyChanged() +{ + createControlIfNeeded(); + QTWinBaseClass::parentHierarchyChanged(); +} + +void QuickTimeMovieComponent::visibilityChanged() +{ + createControlIfNeeded(); + QTWinBaseClass::visibilityChanged(); +} + +void QuickTimeMovieComponent::paint (Graphics& g) +{ + if (! isControlCreated()) + g.fillAll (Colours::black); +} + +#endif + +//============================================================================== +#if JUCE_MAC + +#include "../../../../juce_core/misc/juce_PlatformUtilities.h" +#include "../../../events/juce_MessageManager.h" +#include "../../graphics/geometry/juce_RectangleList.h" + +static bool isQTAvailable = false; +static bool hasLoadedQT = false; +static VoidArray activeQTWindows (2); + +struct MacClickEventData +{ + ::Point where; + long when; + long modifiers; +}; + +void OfferMouseClickToQuickTime (WindowRef window, + ::Point where, long when, long modifiers, + Component* topLevelComp) +{ + if (hasLoadedQT) + { + for (int i = activeQTWindows.size(); --i >= 0;) + { + QuickTimeMovieComponent* const qtw = (QuickTimeMovieComponent*) activeQTWindows[i]; + + if (qtw->isVisible() && topLevelComp->isParentOf (qtw)) + { + MacClickEventData data; + data.where = where; + data.when = when; + data.modifiers = modifiers; + + qtw->handleMCEvent (&data); + } + } + } +} + +//============================================================================== +QuickTimeMovieComponent::QuickTimeMovieComponent() + : internal (new QTMovieCompInternal()), + associatedWindow (0), + controllerVisible (false), + controllerAssignedToWindow (false), + reentrant (false) +{ + if (! hasLoadedQT) + { + hasLoadedQT = true; + isQTAvailable = EnterMovies() == noErr; + } + + setOpaque (true); + setVisible (true); + + activeQTWindows.add (this); +} + +QuickTimeMovieComponent::~QuickTimeMovieComponent() +{ + closeMovie(); + + activeQTWindows.removeValue ((void*) this); + + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + delete id; + + if (activeQTWindows.size() == 0 && isQTAvailable) + { + isQTAvailable = false; + hasLoadedQT = false; + + ExitMovies(); + } +} + +bool QuickTimeMovieComponent::loadMovie (InputStream* movieStream, + const bool controllerVisible_) +{ + if (! isQTAvailable) + return false; + + closeMovie(); + movieFile = File::nonexistent; + + if (getPeer() == 0) + { + // To open a movie, this component must be visible inside a functioning window, so that + // the QT control can be assigned to the window. + jassertfalse + return false; + } + + controllerVisible = controllerVisible_; + + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + GrafPtr savedPort; + GetPort (&savedPort); + bool result = false; + + if (juce_OpenQuickTimeMovieFromStream (movieStream, id->movie, id->dataHandle)) + { + id->controller = 0; + + void* window = getWindowHandle(); + + if (window != associatedWindow && window != 0) + associatedWindow = window; + + assignMovieToWindow(); + + SetMovieActive (id->movie, true); + SetMovieProgressProc (id->movie, (MovieProgressUPP) -1, 0); + + startTimer (1000 / 50); // this needs to be quite a high frequency for smooth playback + result = true; + + repaint(); + } + + MacSetPort (savedPort); + + return result; +} + +void QuickTimeMovieComponent::closeMovie() +{ + stop(); + + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + if (id->controller != 0) + { + DisposeMovieController (id->controller); + id->controller = 0; + } + + if (id->movie != 0) + { + DisposeMovie (id->movie); + id->movie = 0; + } + + id->clearHandle(); + + stopTimer(); + movieFile = File::nonexistent; +} + +bool QuickTimeMovieComponent::isMovieOpen() const +{ + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + return id->movie != 0 && id->controller != 0; +} + +const File QuickTimeMovieComponent::getCurrentMovieFile() const +{ + return movieFile; +} + +static GrafPtr getPortForWindow (void* window) +{ + if (window == 0) + return 0; + + return (GrafPtr) GetWindowPort ((WindowRef) window); +} + +void QuickTimeMovieComponent::assignMovieToWindow() +{ + if (reentrant) + return; + + reentrant = true; + + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + if (id->controller != 0) + { + DisposeMovieController (id->controller); + id->controller = 0; + } + + controllerAssignedToWindow = false; + + void* window = getWindowHandle(); + GrafPtr port = getPortForWindow (window); + + if (port != 0) + { + GrafPtr savedPort; + GetPort (&savedPort); + + SetMovieGWorld (id->movie, (CGrafPtr) port, 0); + MacSetPort (port); + + Rect r; + r.top = 0; + r.left = 0; + r.right = (short) jmax (1, getWidth()); + r.bottom = (short) jmax (1, getHeight()); + SetMovieBox (id->movie, &r); + + // create the movie controller + id->controller = NewMovieController (id->movie, &r, + controllerVisible ? mcTopLeftMovie + : mcNotVisible); + + if (id->controller != 0) + { + MCEnableEditing (id->controller, true); + + MCDoAction (id->controller, mcActionSetUseBadge, (void*) false); + MCDoAction (id->controller, mcActionSetLoopIsPalindrome, (void*) false); + setLooping (looping); + + MCDoAction (id->controller, mcActionSetFlags, + (void*) (pointer_sized_int) (mcFlagSuppressMovieFrame | (controllerVisible ? 0 : (mcFlagSuppressStepButtons | mcFlagSuppressSpeakerButton)))); + + MCSetControllerBoundsRect (id->controller, &r); + + controllerAssignedToWindow = true; + + resized(); + } + + MacSetPort (savedPort); + } + else + { + SetMovieGWorld (id->movie, 0, 0); + } + + reentrant = false; +} + +void QuickTimeMovieComponent::play() +{ + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + if (id->movie != 0) + StartMovie (id->movie); +} + +void QuickTimeMovieComponent::stop() +{ + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + if (id->movie != 0) + StopMovie (id->movie); +} + +bool QuickTimeMovieComponent::isPlaying() const +{ + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + return id->movie != 0 && GetMovieRate (id->movie) != 0; +} + +void QuickTimeMovieComponent::setPosition (const double seconds) +{ + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + if (id->controller != 0) + { + TimeRecord time; + time.base = GetMovieTimeBase (id->movie); + time.scale = 100000; + const uint64 t = (uint64) (100000.0 * seconds); + time.value.lo = (UInt32) (t & 0xffffffff); + time.value.hi = (UInt32) (t >> 32); + + SetMovieTime (id->movie, &time); + timerCallback(); // to call MCIdle + } + else + { + jassertfalse // no movie is open, so can't set the position. + } +} + +double QuickTimeMovieComponent::getPosition() const +{ + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + if (id->movie != 0) + { + TimeRecord time; + GetMovieTime (id->movie, &time); + + return ((int64) (((uint64) time.value.hi << 32) | (uint64) time.value.lo)) + / (double) time.scale; + } + + return 0.0; +} + +void QuickTimeMovieComponent::setSpeed (const float newSpeed) +{ + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + if (id->movie != 0) + SetMovieRate (id->movie, (Fixed) (newSpeed * (Fixed) 0x00010000L)); +} + +double QuickTimeMovieComponent::getMovieDuration() const +{ + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + if (id->movie != 0) + return GetMovieDuration (id->movie) / (double) GetMovieTimeScale (id->movie); + + return 0.0; +} + +void QuickTimeMovieComponent::setLooping (const bool shouldLoop) +{ + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + looping = shouldLoop; + + if (id->controller != 0) + MCDoAction (id->controller, mcActionSetLooping, (void*) shouldLoop); +} + +bool QuickTimeMovieComponent::isLooping() const +{ + return looping; +} + +void QuickTimeMovieComponent::setMovieVolume (const float newVolume) +{ + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + if (id->movie != 0) + SetMovieVolume (id->movie, jlimit ((short) 0, (short) 0x100, (short) (newVolume * 0x0100))); +} + +float QuickTimeMovieComponent::getMovieVolume() const +{ + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + if (id->movie != 0) + return jmax (0.0f, GetMovieVolume (id->movie) / (float) 0x0100); + + return 0.0f; +} + +void QuickTimeMovieComponent::getMovieNormalSize (int& width, int& height) const +{ + width = 0; + height = 0; + + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + if (id->movie != 0) + { + Rect r; + GetMovieNaturalBoundsRect (id->movie, &r); + width = r.right - r.left; + height = r.bottom - r.top; + } +} + +void QuickTimeMovieComponent::paint (Graphics& g) +{ + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + if (id->movie == 0 || id->controller == 0) + { + g.fillAll (Colours::black); + return; + } + + GrafPtr savedPort; + GetPort (&savedPort); + + MacSetPort (getPortForWindow (getWindowHandle())); + MCDraw (id->controller, (WindowRef) getWindowHandle()); + + MacSetPort (savedPort); + + ComponentPeer* const peer = getPeer(); + + if (peer != 0) + { + peer->addMaskedRegion (getScreenX() - peer->getScreenX(), + getScreenY() - peer->getScreenY(), + getWidth(), getHeight()); + } + + timerCallback(); +} + +static const Rectangle getMoviePos (Component* const c) +{ + return Rectangle (c->getScreenX() - c->getTopLevelComponent()->getScreenX(), + c->getScreenY() - c->getTopLevelComponent()->getScreenY(), + jmax (1, c->getWidth()), + jmax (1, c->getHeight())); +} + +void QuickTimeMovieComponent::moved() +{ + resized(); +} + +void QuickTimeMovieComponent::resized() +{ + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + if (id->controller != 0 && isShowing()) + { + checkWindowAssociation(); + + GrafPtr port = getPortForWindow (getWindowHandle()); + + if (port != 0) + { + GrafPtr savedPort; + GetPort (&savedPort); + + SetMovieGWorld (id->movie, (CGrafPtr) port, 0); + MacSetPort (port); + + lastPositionApplied = getMoviePos (this); + + Rect r; + r.left = (short) lastPositionApplied.getX(); + r.top = (short) lastPositionApplied.getY(); + r.right = (short) lastPositionApplied.getRight(); + r.bottom = (short) lastPositionApplied.getBottom(); + + if (MCGetVisible (id->controller)) + MCSetControllerBoundsRect (id->controller, &r); + else + SetMovieBox (id->movie, &r); + + if (! isPlaying()) + timerCallback(); + + MacSetPort (savedPort); + + repaint(); + } + } +} + +void QuickTimeMovieComponent::visibilityChanged() +{ + checkWindowAssociation(); + QTWinBaseClass::visibilityChanged(); +} + +void QuickTimeMovieComponent::timerCallback() +{ + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + if (id->controller != 0) + { + if (isTimerRunning()) + startTimer (getTimerInterval()); + + MCIdle (id->controller); + + if (lastPositionApplied != getMoviePos (this)) + resized(); + } +} + +void QuickTimeMovieComponent::checkWindowAssociation() +{ + void* const window = getWindowHandle(); + + if (window != associatedWindow + || (window != 0 && ! controllerAssignedToWindow)) + { + associatedWindow = window; + assignMovieToWindow(); + } +} + +void QuickTimeMovieComponent::parentHierarchyChanged() +{ + checkWindowAssociation(); +} + +void QuickTimeMovieComponent::handleMCEvent (void* ev) +{ + QTMovieCompInternal* const id = (QTMovieCompInternal*) internal; + + if (id->controller != 0 && isShowing()) + { + MacClickEventData* data = (MacClickEventData*) ev; + + data->where.h -= getTopLevelComponent()->getScreenX(); + data->where.v -= getTopLevelComponent()->getScreenY(); + + Boolean b = false; + MCPtInController (id->controller, data->where, &b); + + if (b) + { + const int oldTimeBeforeWaitCursor = MessageManager::getInstance()->getTimeBeforeShowingWaitCursor(); + MessageManager::getInstance()->setTimeBeforeShowingWaitCursor (0); + + MCClick (id->controller, + (WindowRef) getWindowHandle(), + data->where, + data->when, + data->modifiers); + + MessageManager::getInstance()->setTimeBeforeShowingWaitCursor (oldTimeBeforeWaitCursor); + } + } +} + +#endif + +//============================================================================== +// (methods common to both platforms..) + +static Handle createHandleDataRef (Handle dataHandle, const char* fileName) +{ + Handle dataRef = 0; + OSStatus err = PtrToHand (&dataHandle, &dataRef, sizeof (Handle)); + if (err == noErr) + { + Str255 suffix; +#if JUCE_WIN32 + strcpy_s ((char*) suffix, 128, fileName); +#else + strcpy ((char*) suffix, fileName); +#endif + StringPtr name = suffix; + err = PtrAndHand (name, dataRef, name[0] + 1); + + if (err == noErr) + { + long atoms[3]; + atoms[0] = EndianU32_NtoB (3 * sizeof (long)); + atoms[1] = EndianU32_NtoB (kDataRefExtensionMacOSFileType); + atoms[2] = EndianU32_NtoB (MovieFileType); + + err = PtrAndHand (atoms, dataRef, 3 * sizeof (long)); + + if (err == noErr) + return dataRef; + } + + DisposeHandle (dataRef); + } + + return 0; +} + +static CFStringRef juceStringToCFString (const String& s) +{ + const int len = s.length(); + const juce_wchar* const t = (const juce_wchar*) s; + + UniChar* temp = (UniChar*) juce_malloc (sizeof (UniChar) * len + 4); + + for (int i = 0; i <= len; ++i) + temp[i] = t[i]; + + CFStringRef result = CFStringCreateWithCharacters (kCFAllocatorDefault, temp, len); + juce_free (temp); + + return result; +} + +static bool openMovie (QTNewMoviePropertyElement* props, int prop, Movie& movie) +{ + Boolean trueBool = true; + props[prop].propClass = kQTPropertyClass_MovieInstantiation; + props[prop].propID = kQTMovieInstantiationPropertyID_DontResolveDataRefs; + props[prop].propValueSize = sizeof (trueBool); + props[prop].propValueAddress = &trueBool; + ++prop; + + props[prop].propClass = kQTPropertyClass_MovieInstantiation; + props[prop].propID = kQTMovieInstantiationPropertyID_AsyncOK; + props[prop].propValueSize = sizeof (trueBool); + props[prop].propValueAddress = &trueBool; + ++prop; + + Boolean isActive = true; + props[prop].propClass = kQTPropertyClass_NewMovieProperty; + props[prop].propID = kQTNewMoviePropertyID_Active; + props[prop].propValueSize = sizeof (isActive); + props[prop].propValueAddress = &isActive; + ++prop; + +#if JUCE_MAC + SetPort (0); +#else + MacSetPort (0); +#endif + + jassert (prop <= 5); + OSStatus err = NewMovieFromProperties (prop, props, 0, 0, &movie); + + return err == noErr; +} + +bool juce_OpenQuickTimeMovieFromStream (InputStream* input, Movie& movie, Handle& dataHandle) +{ + if (input == 0) + return false; + + dataHandle = 0; + bool ok = false; + + QTNewMoviePropertyElement props[5]; + zeromem (props, sizeof (props)); + int prop = 0; + + DataReferenceRecord dr; + props[prop].propClass = kQTPropertyClass_DataLocation; + props[prop].propID = kQTDataLocationPropertyID_DataReference; + props[prop].propValueSize = sizeof (dr); + props[prop].propValueAddress = (void*) &dr; + ++prop; + + FileInputStream* const fin = dynamic_cast (input); + + if (fin != 0) + { + CFStringRef filePath = juceStringToCFString (fin->getFile().getFullPathName()); + + QTNewDataReferenceFromFullPathCFString (filePath, (QTPathStyle) kQTNativeDefaultPathStyle, 0, + &dr.dataRef, &dr.dataRefType); + + + ok = openMovie (props, prop, movie); + + DisposeHandle (dr.dataRef); + CFRelease (filePath); + } + else + { + // sanity-check because this currently needs to load the whole stream into memory.. + jassert (input->getTotalLength() < 50 * 1024 * 1024); + + dataHandle = NewHandle ((Size) input->getTotalLength()); + HLock (dataHandle); + // read the entire stream into memory - this is a pain, but can't get it to work + // properly using a custom callback to supply the data. + input->read (*dataHandle, (int) input->getTotalLength()); + HUnlock (dataHandle); + + // different types to get QT to try. (We should really be a bit smarter here by + // working out in advance which one the stream contains, rather than just trying + // each one) + const char* const suffixesToTry[] = { "\04.mov", "\04.mp3", + "\04.avi", "\04.m4a" }; + + for (int i = 0; i < numElementsInArray (suffixesToTry) && ! ok; ++i) + { + /* // this fails for some bizarre reason - it can be bodged to work with + // movies, but can't seem to do it for other file types.. + QTNewMovieUserProcRecord procInfo; + procInfo.getMovieUserProc = NewGetMovieUPP (readMovieStreamProc); + procInfo.getMovieUserProcRefcon = this; + procInfo.defaultDataRef.dataRef = dataRef; + procInfo.defaultDataRef.dataRefType = HandleDataHandlerSubType; + + props[prop].propClass = kQTPropertyClass_DataLocation; + props[prop].propID = kQTDataLocationPropertyID_MovieUserProc; + props[prop].propValueSize = sizeof (procInfo); + props[prop].propValueAddress = (void*) &procInfo; + ++prop; */ + + dr.dataRef = createHandleDataRef (dataHandle, suffixesToTry [i]); + dr.dataRefType = HandleDataHandlerSubType; + ok = openMovie (props, prop, movie); + + DisposeHandle (dr.dataRef); + } + } + + return ok; +} + +bool QuickTimeMovieComponent::loadMovie (const File& movieFile_, + const bool isControllerVisible) +{ + const bool ok = loadMovie ((InputStream*) movieFile_.createInputStream(), isControllerVisible); + movieFile = movieFile_; + return ok; +} + +void QuickTimeMovieComponent::goToStart() +{ + setPosition (0.0); +} + +void QuickTimeMovieComponent::setBoundsWithCorrectAspectRatio (const Rectangle& spaceToFitWithin, + const RectanglePlacement& placement) +{ + int normalWidth, normalHeight; + getMovieNormalSize (normalWidth, normalHeight); + + if (normalWidth > 0 && normalHeight > 0 && ! spaceToFitWithin.isEmpty()) + { + double x = 0.0, y = 0.0, w = normalWidth, h = normalHeight; + + placement.applyTo (x, y, w, h, + spaceToFitWithin.getX(), spaceToFitWithin.getY(), + spaceToFitWithin.getWidth(), spaceToFitWithin.getHeight()); + + if (w > 0 && h > 0) + { + setBounds (roundDoubleToInt (x), roundDoubleToInt (y), + roundDoubleToInt (w), roundDoubleToInt (h)); + } + } + else + { + setBounds (spaceToFitWithin); + } +} + + +END_JUCE_NAMESPACE + +#endif diff --git a/src/juce_core/basics/juce_StandardHeader.h b/src/juce_core/basics/juce_StandardHeader.h index c3233f0abc..6e4e9bab7d 100644 --- a/src/juce_core/basics/juce_StandardHeader.h +++ b/src/juce_core/basics/juce_StandardHeader.h @@ -38,7 +38,7 @@ See also SystemStats::getJUCEVersion() for a string version. */ #define JUCE_MAJOR_VERSION 1 -#define JUCE_MINOR_VERSION 45 +#define JUCE_MINOR_VERSION 46 /** Current Juce version number.