From e2156acbd09ac4637365fb7beda3797993030c38 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Fri, 17 Sep 2010 14:30:52 +0100 Subject: [PATCH] win32 openGL tweaks. Fixes for a couple of File methods. New "cpp + header" file creation option for the new jucer. --- .../Source/Project/jucer_NewFileWizard.cpp | 55 +++++++++++++++---- .../Source/Project/jucer_NewFileWizard.h | 2 +- juce_amalgamated.cpp | 24 +++----- src/io/files/juce_File.cpp | 6 +- .../windows/juce_win32_OpenGLComponent.cpp | 18 ++---- 5 files changed, 62 insertions(+), 43 deletions(-) diff --git a/extras/Jucer (experimental)/Source/Project/jucer_NewFileWizard.cpp b/extras/Jucer (experimental)/Source/Project/jucer_NewFileWizard.cpp index 0a4e9637ec..ab01391699 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_NewFileWizard.cpp +++ b/extras/Jucer (experimental)/Source/Project/jucer_NewFileWizard.cpp @@ -49,15 +49,22 @@ public: void createNewFile (Project::Item parent) { - File newFile = askUserToChooseNewFile ("SourceCode.cpp", "*.cpp", parent); + const File newFile (askUserToChooseNewFile ("SourceCode.cpp", "*.cpp", parent)); if (newFile != File::nonexistent) + create (parent, newFile); + } + + static bool create (Project::Item parent, const File& newFile) + { + if (fillInNewCppFileTemplate (newFile, parent, "jucer_NewCppFileTemplate_cpp")) { - if (fillInNewCppFileTemplate (newFile, parent, "jucer_NewCppFileTemplate_cpp")) - parent.addFile (newFile, 0); - else - showFailedToWriteMessage (newFile); + parent.addFile (newFile, 0); + return true; } + + showFailedToWriteMessage (newFile); + return false; } }; @@ -72,18 +79,45 @@ public: void createNewFile (Project::Item parent) { - File newFile = askUserToChooseNewFile ("SourceCode.h", "*.h", parent); + const File newFile (askUserToChooseNewFile ("SourceCode.h", "*.h", parent)); if (newFile != File::nonexistent) + create (parent, newFile); + } + + static bool create (Project::Item parent, const File& newFile) + { + if (fillInNewCppFileTemplate (newFile, parent, "jucer_NewCppFileTemplate_h")) { - if (fillInNewCppFileTemplate (newFile, parent, "jucer_NewCppFileTemplate_h")) - parent.addFile (newFile, 0); - else - showFailedToWriteMessage (newFile); + parent.addFile (newFile, 0); + return true; } + + showFailedToWriteMessage (newFile); + return false; } }; +//============================================================================== +class NewCppAndHeaderFileWizard : public NewFileWizard::Type +{ +public: + NewCppAndHeaderFileWizard() {} + ~NewCppAndHeaderFileWizard() {} + + const String getName() { return "CPP & Header File"; } + + void createNewFile (Project::Item parent) + { + const File newFile (askUserToChooseNewFile ("SourceCode.h", "*.h;*.cpp", parent)); + + if (newFile != File::nonexistent) + { + if (NewHeaderFileWizard::create (parent, newFile.withFileExtension ("h"))) + NewCppFileWizard::create (parent, newFile.withFileExtension ("cpp")); + } + } +}; //============================================================================== void NewFileWizard::Type::showFailedToWriteMessage (const File& file) @@ -113,6 +147,7 @@ NewFileWizard::NewFileWizard() { registerWizard (new NewCppFileWizard()); registerWizard (new NewHeaderFileWizard()); + registerWizard (new NewCppAndHeaderFileWizard()); } NewFileWizard::~NewFileWizard() diff --git a/extras/Jucer (experimental)/Source/Project/jucer_NewFileWizard.h b/extras/Jucer (experimental)/Source/Project/jucer_NewFileWizard.h index df15ed8760..70aa031ffa 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_NewFileWizard.h +++ b/extras/Jucer (experimental)/Source/Project/jucer_NewFileWizard.h @@ -56,7 +56,7 @@ public: const File askUserToChooseNewFile (const String& suggestedFilename, const String& wildcard, const Project::Item& projectGroupToAddTo); - void showFailedToWriteMessage (const File& file); + static void showFailedToWriteMessage (const File& file); }; //============================================================================== diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 4b3cb0fa65..5429dd25a7 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -7483,7 +7483,7 @@ int File::findChildFiles (Array& results, int File::getNumberOfChildFiles (const int whatToLookFor, const String& wildCardPattern) const { - DirectoryIterator di (*this, false, "*", whatToLookFor); + DirectoryIterator di (*this, false, wildCardPattern, whatToLookFor); int total = 0; while (di.next()) @@ -7924,7 +7924,7 @@ public: expect (tempFile.exists()); expect (tempFile.getSize() == 10); - expect (std::abs ((int64) (tempFile.getLastModificationTime().toMilliseconds() - Time::getCurrentTime().toMilliseconds())) < 3000); + expect (std::abs ((int) (tempFile.getLastModificationTime().toMilliseconds() - Time::getCurrentTime().toMilliseconds())) < 3000); expect (tempFile.loadFileAsString() == "0123456789"); expect (! demoFolder.containsSubDirectories()); @@ -7945,7 +7945,7 @@ public: Time t (Time::getCurrentTime()); tempFile.setLastModificationTime (t); Time t2 = tempFile.getLastModificationTime(); - expect (std::abs ((int64) (t2.toMilliseconds() - t.toMilliseconds())) <= 1000); + expect (std::abs ((int) (t2.toMilliseconds() - t.toMilliseconds())) <= 1000); { MemoryBlock mb; @@ -246329,22 +246329,14 @@ private: void createNativeWindow() { - nativeWindow = new Win32ComponentPeer (component, 0, 0); + Win32ComponentPeer* topLevelPeer = dynamic_cast (component->getTopLevelComponent()->getPeer()); + + nativeWindow = new Win32ComponentPeer (component, ComponentPeer::windowIgnoresMouseClicks, + topLevelPeer == 0 ? 0 : (HWND) topLevelPeer->getNativeHandle()); nativeWindow->dontRepaint = true; nativeWindow->setVisible (true); - HWND hwnd = (HWND) nativeWindow->getNativeHandle(); - - Win32ComponentPeer* const peer = dynamic_cast (component->getTopLevelComponent()->getPeer()); - - if (peer != 0) - { - SetParent (hwnd, (HWND) peer->getNativeHandle()); - juce_setWindowStyleBit (hwnd, GWL_STYLE, WS_CHILD, true); - juce_setWindowStyleBit (hwnd, GWL_STYLE, WS_POPUP, false); - } - - dc = GetDC (hwnd); + dc = GetDC ((HWND) nativeWindow->getNativeHandle()); } bool fillInPixelFormatDetails (const int pixelFormatIndex, diff --git a/src/io/files/juce_File.cpp b/src/io/files/juce_File.cpp index b5607b3ccf..76f0b0c3f5 100644 --- a/src/io/files/juce_File.cpp +++ b/src/io/files/juce_File.cpp @@ -551,7 +551,7 @@ int File::findChildFiles (Array& results, int File::getNumberOfChildFiles (const int whatToLookFor, const String& wildCardPattern) const { - DirectoryIterator di (*this, false, "*", whatToLookFor); + DirectoryIterator di (*this, false, wildCardPattern, whatToLookFor); int total = 0; while (di.next()) @@ -1003,7 +1003,7 @@ public: expect (tempFile.exists()); expect (tempFile.getSize() == 10); - expect (std::abs ((int64) (tempFile.getLastModificationTime().toMilliseconds() - Time::getCurrentTime().toMilliseconds())) < 3000); + expect (std::abs ((int) (tempFile.getLastModificationTime().toMilliseconds() - Time::getCurrentTime().toMilliseconds())) < 3000); expect (tempFile.loadFileAsString() == "0123456789"); expect (! demoFolder.containsSubDirectories()); @@ -1024,7 +1024,7 @@ public: Time t (Time::getCurrentTime()); tempFile.setLastModificationTime (t); Time t2 = tempFile.getLastModificationTime(); - expect (std::abs ((int64) (t2.toMilliseconds() - t.toMilliseconds())) <= 1000); + expect (std::abs ((int) (t2.toMilliseconds() - t.toMilliseconds())) <= 1000); { MemoryBlock mb; diff --git a/src/native/windows/juce_win32_OpenGLComponent.cpp b/src/native/windows/juce_win32_OpenGLComponent.cpp index ab2d3a46d7..ab3979819b 100644 --- a/src/native/windows/juce_win32_OpenGLComponent.cpp +++ b/src/native/windows/juce_win32_OpenGLComponent.cpp @@ -391,22 +391,14 @@ private: //============================================================================== void createNativeWindow() { - nativeWindow = new Win32ComponentPeer (component, 0, 0); + Win32ComponentPeer* topLevelPeer = dynamic_cast (component->getTopLevelComponent()->getPeer()); + + nativeWindow = new Win32ComponentPeer (component, ComponentPeer::windowIgnoresMouseClicks, + topLevelPeer == 0 ? 0 : (HWND) topLevelPeer->getNativeHandle()); nativeWindow->dontRepaint = true; nativeWindow->setVisible (true); - HWND hwnd = (HWND) nativeWindow->getNativeHandle(); - - Win32ComponentPeer* const peer = dynamic_cast (component->getTopLevelComponent()->getPeer()); - - if (peer != 0) - { - SetParent (hwnd, (HWND) peer->getNativeHandle()); - juce_setWindowStyleBit (hwnd, GWL_STYLE, WS_CHILD, true); - juce_setWindowStyleBit (hwnd, GWL_STYLE, WS_POPUP, false); - } - - dc = GetDC (hwnd); + dc = GetDC ((HWND) nativeWindow->getNativeHandle()); } bool fillInPixelFormatDetails (const int pixelFormatIndex,