| @@ -47,14 +47,6 @@ BEGIN_JUCE_NAMESPACE | |||
| #include "../../../src/juce_appframework/events/juce_Timer.h" | |||
| #include "../../../src/juce_core/misc/juce_PlatformUtilities.h" | |||
| static struct _LogicalCpuInfo | |||
| { | |||
| bool htSupported; | |||
| bool htAvailable; | |||
| int numPackages; | |||
| int numLogicalPerPackage; | |||
| uint32 physicalAffinityMask; | |||
| } logicalCpuInfo; | |||
| //============================================================================== | |||
| static juce_noinline unsigned int getCPUIDWord (int* familyModel, int* extFeatures) throw() | |||
| @@ -82,110 +74,6 @@ static juce_noinline unsigned int getCPUIDWord (int* familyModel, int* extFeatur | |||
| return cpu; | |||
| } | |||
| void juce_initLogicalCpuInfo() throw() | |||
| { | |||
| int familyModelWord, extFeaturesWord; | |||
| int featuresWord = getCPUIDWord (&familyModelWord, &extFeaturesWord); | |||
| logicalCpuInfo.htSupported = false; | |||
| logicalCpuInfo.htAvailable = false; | |||
| logicalCpuInfo.numLogicalPerPackage = 1; | |||
| logicalCpuInfo.numPackages = 0; | |||
| logicalCpuInfo.physicalAffinityMask = 0; | |||
| #if SUPPORT_AFFINITIES | |||
| cpu_set_t processAffinity; | |||
| /* | |||
| N.B. If this line causes a compile error, then you've probably not got the latest | |||
| version of glibc installed. | |||
| If you don't want to update your copy of glibc and don't care about cpu affinities, | |||
| then you can just disable all this stuff by removing the SUPPORT_AFFINITIES macro | |||
| from the linuxincludes.h file. | |||
| */ | |||
| if (sched_getaffinity (getpid(), | |||
| sizeof (cpu_set_t), | |||
| &processAffinity) != sizeof (cpu_set_t)) | |||
| { | |||
| return; | |||
| } | |||
| // Checks: CPUID supported, model >= Pentium 4, Hyperthreading bit set, logical CPUs per package > 1 | |||
| if (featuresWord == 0 | |||
| || ((familyModelWord >> 8) & 0xf) < 15 | |||
| || (featuresWord & (1 << 28)) == 0 | |||
| || ((extFeaturesWord >> 16) & 0xff) < 2) | |||
| { | |||
| for (int i = 0; i < 64; ++i) | |||
| if (CPU_ISSET (i, &processAffinity)) | |||
| logicalCpuInfo.physicalAffinityMask |= (1 << i); | |||
| return; | |||
| } | |||
| logicalCpuInfo.htSupported = true; | |||
| logicalCpuInfo.numLogicalPerPackage = (extFeaturesWord >> 16) & 0xff; | |||
| cpu_set_t affinityMask; | |||
| cpu_set_t physAff; | |||
| CPU_ZERO (&physAff); | |||
| unsigned char i = 1; | |||
| unsigned char physIdMask = 0xFF; | |||
| unsigned char physIdShift = 0; | |||
| //unsigned char apicId, logId, physId; | |||
| while (i < logicalCpuInfo.numLogicalPerPackage) | |||
| { | |||
| i *= 2; | |||
| physIdMask <<= 1; | |||
| physIdShift++; | |||
| } | |||
| CPU_SET (0, &affinityMask); | |||
| logicalCpuInfo.numPackages = 0; | |||
| //xxx revisit this at some point.. | |||
| /* while ((affinityMask != 0) && (affinityMask <= processAffinity)) | |||
| { | |||
| int ret; | |||
| if (! sched_setaffinity (getpid(), sizeof (cpu_set_t), &affinityMask)) | |||
| { | |||
| sched_yield(); // schedule onto correct CPU | |||
| featuresWord = getCPUIDWord(&familyModelWord, &extFeaturesWord); | |||
| apicId = (unsigned char)(extFeaturesWord >> 24); | |||
| logId = (unsigned char)(apicId & ~physIdMask); | |||
| physId = (unsigned char)(apicId >> physIdShift); | |||
| if (logId != 0) | |||
| logicalCpuInfo.htAvailable = true; | |||
| if ((((int)logId) % logicalCpuInfo.numLogicalPerPackage) == 0) | |||
| { | |||
| // This is a physical CPU | |||
| physAff |= affinityMask; | |||
| logicalCpuInfo.numPackages++; | |||
| } | |||
| } | |||
| affinityMask = affinityMask << 1; | |||
| } | |||
| sched_setaffinity (getpid(), sizeof(unsigned long), &processAffinity); | |||
| */ | |||
| logicalCpuInfo.physicalAffinityMask = 0; | |||
| for (int i = 0; i < 64; ++i) | |||
| if (CPU_ISSET (i, &physAff)) | |||
| logicalCpuInfo.physicalAffinityMask |= (1 << i); | |||
| #endif | |||
| } | |||
| //============================================================================== | |||
| void Logger::outputDebugString (const String& text) throw() | |||
| { | |||
| @@ -280,11 +168,6 @@ int SystemStats::getCpuSpeedInMegaherz() throw() | |||
| return (int) (speed.getFloatValue() + 0.5f); | |||
| } | |||
| bool SystemStats::hasHyperThreading() throw() | |||
| { | |||
| return logicalCpuInfo.htAvailable; | |||
| } | |||
| int SystemStats::getMemorySizeInMegabytes() throw() | |||
| { | |||
| struct sysinfo sysi; | |||
| @@ -360,34 +243,13 @@ int SystemStats::getPageSize() throw() | |||
| return systemPageSize; | |||
| } | |||
| int SystemStats::getNumPhysicalCpus() throw() | |||
| { | |||
| if (logicalCpuInfo.numPackages) | |||
| return logicalCpuInfo.numPackages; | |||
| return getNumLogicalCpus(); | |||
| } | |||
| int SystemStats::getNumLogicalCpus() throw() | |||
| int SystemStats::getNumCpus() throw() | |||
| { | |||
| const int lastCpu = getCpuInfo ("processor", true).getIntValue(); | |||
| return lastCpu + 1; | |||
| } | |||
| uint32 SystemStats::getPhysicalAffinityMask() throw() | |||
| { | |||
| #if SUPPORT_AFFINITIES | |||
| return logicalCpuInfo.physicalAffinityMask; | |||
| #else | |||
| /* affinities aren't supported because either the appropriate header files weren't found, | |||
| or the SUPPORT_AFFINITIES macro was turned off in linuxheaders.h | |||
| */ | |||
| jassertfalse | |||
| return 0; | |||
| #endif | |||
| } | |||
| //============================================================================== | |||
| void SystemStats::initialiseStats() throw() | |||
| @@ -396,8 +258,6 @@ void SystemStats::initialiseStats() throw() | |||
| Process::lowerPrivilege(); | |||
| String s (SystemStats::getJUCEVersion()); | |||
| juce_initLogicalCpuInfo(); | |||
| } | |||
| void PlatformUtilities::fpuReset() | |||
| @@ -167,7 +167,7 @@ void Thread::yield() throw() | |||
| sched_yield(); | |||
| } | |||
| void Thread::sleep (int millisecs) throw() | |||
| void JUCE_CALLTYPE Thread::sleep (int millisecs) throw() | |||
| { | |||
| struct timespec time; | |||
| time.tv_sec = millisecs / 1000; | |||
| @@ -83,7 +83,6 @@ struct CPUFlags | |||
| bool hasSSE : 1; | |||
| bool hasSSE2 : 1; | |||
| bool has3DNow : 1; | |||
| bool hasHT : 1; | |||
| }; | |||
| static CPUFlags cpuFlags; | |||
| @@ -145,7 +144,6 @@ void SystemStats::initialiseStats() throw() | |||
| cpuFlags.hasSSE = ((features & (1 << 25)) != 0); | |||
| cpuFlags.hasSSE2 = ((features & (1 << 26)) != 0); | |||
| cpuFlags.has3DNow = ((extFeatures & (1 << 31)) != 0); | |||
| cpuFlags.hasHT = ((features & (1 << 28)) != 0); | |||
| } | |||
| #endif | |||
| @@ -201,15 +199,6 @@ bool SystemStats::has3DNow() throw() | |||
| #endif | |||
| } | |||
| bool SystemStats::hasHyperThreading() throw() | |||
| { | |||
| #if JUCE_INTEL | |||
| return cpuFlags.hasHT; | |||
| #else | |||
| return false; | |||
| #endif | |||
| } | |||
| const String SystemStats::getCpuVendor() throw() | |||
| { | |||
| #if JUCE_INTEL | |||
| @@ -226,22 +215,11 @@ int SystemStats::getCpuSpeedInMegaherz() throw() | |||
| return GetCPUSpeed(); | |||
| } | |||
| int SystemStats::getNumPhysicalCpus() throw() | |||
| int SystemStats::getNumCpus() throw() | |||
| { | |||
| return MPProcessors(); | |||
| } | |||
| int SystemStats::getNumLogicalCpus() throw() | |||
| { | |||
| return getNumPhysicalCpus(); | |||
| } | |||
| uint32 SystemStats::getPhysicalAffinityMask() throw() | |||
| { | |||
| jassertfalse | |||
| return 0; | |||
| } | |||
| //============================================================================== | |||
| static int64 juce_getMicroseconds() throw() | |||
| { | |||
| @@ -213,7 +213,7 @@ void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) throw() | |||
| jassertfalse | |||
| } | |||
| void Thread::sleep (int millisecs) throw() | |||
| void JUCE_CALLTYPE Thread::sleep (int millisecs) throw() | |||
| { | |||
| struct timespec time; | |||
| time.tv_sec = millisecs / 1000; | |||
| @@ -567,7 +567,7 @@ static const File juce_getSpecialFolderPath (int type) throw() | |||
| return File::nonexistent; | |||
| } | |||
| const File File::getSpecialLocation (const SpecialLocationType type) | |||
| const File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType type) | |||
| { | |||
| switch (type) | |||
| { | |||
| @@ -63,6 +63,11 @@ BEGIN_JUCE_NAMESPACE | |||
| #include "../../../src/juce_core/basics/juce_SystemStats.h" | |||
| extern void juce_updateMultiMonitorInfo() throw(); | |||
| extern void juce_initialiseThreadEvents() throw(); | |||
| #if JUCE_ENABLE_WIN98_COMPATIBILITY | |||
| extern void juce_initialiseUnicodeFileFunctions() throw(); | |||
| #endif | |||
| //============================================================================== | |||
| @@ -83,16 +88,8 @@ void Logger::outputDebugPrintf (const tchar* format, ...) throw() | |||
| //============================================================================== | |||
| static int64 hiResTicksPerSecond; | |||
| static double hiResTicksScaleFactor; | |||
| static SYSTEM_INFO systemInfo; | |||
| static struct _LogicalCpuInfo | |||
| { | |||
| bool htSupported; | |||
| bool htAvailable; | |||
| int numPackages; | |||
| int numLogicalPerPackage; | |||
| unsigned long physicalAffinityMask; | |||
| } logicalCpuInfo; | |||
| static SYSTEM_INFO systemInfo; | |||
| //============================================================================== | |||
| @@ -103,7 +100,7 @@ static struct _LogicalCpuInfo | |||
| #pragma intrinsic (__cpuid) | |||
| #pragma intrinsic (__rdtsc) | |||
| static unsigned int getCPUIDWord (int* familyModel = 0, int* extFeatures = 0) throw() | |||
| /*static unsigned int getCPUIDWord (int* familyModel = 0, int* extFeatures = 0) throw() | |||
| { | |||
| int info [4]; | |||
| __cpuid (info, 1); | |||
| @@ -115,7 +112,7 @@ static unsigned int getCPUIDWord (int* familyModel = 0, int* extFeatures = 0) th | |||
| *extFeatures = info[1]; | |||
| return info[3]; | |||
| } | |||
| }*/ | |||
| const String SystemStats::getCpuVendor() throw() | |||
| { | |||
| @@ -135,7 +132,7 @@ const String SystemStats::getCpuVendor() throw() | |||
| //============================================================================== | |||
| // CPU info functions using old fashioned inline asm... | |||
| static juce_noinline unsigned int getCPUIDWord (int* familyModel = 0, int* extFeatures = 0) | |||
| /*static juce_noinline unsigned int getCPUIDWord (int* familyModel = 0, int* extFeatures = 0) | |||
| { | |||
| unsigned int cpu = 0; | |||
| unsigned int ext = 0; | |||
| @@ -177,7 +174,7 @@ static juce_noinline unsigned int getCPUIDWord (int* familyModel = 0, int* extFe | |||
| *extFeatures = ext; | |||
| return cpu; | |||
| } | |||
| }*/ | |||
| static void juce_getCpuVendor (char* const v) | |||
| { | |||
| @@ -223,117 +220,36 @@ const String SystemStats::getCpuVendor() throw() | |||
| } | |||
| #endif | |||
| static void initLogicalCpuInfo() throw() | |||
| { | |||
| int familyModelWord, extFeaturesWord; | |||
| int featuresWord = getCPUIDWord (&familyModelWord, &extFeaturesWord); | |||
| HANDLE hCurrentProcessHandle = GetCurrentProcess(); | |||
| logicalCpuInfo.htSupported = false; | |||
| logicalCpuInfo.htAvailable = false; | |||
| logicalCpuInfo.numLogicalPerPackage = 1; | |||
| logicalCpuInfo.numPackages = 0; | |||
| logicalCpuInfo.physicalAffinityMask = 0; | |||
| DWORD_PTR processAffinity, systemAffinity; | |||
| if (! GetProcessAffinityMask (hCurrentProcessHandle, &processAffinity, &systemAffinity)) | |||
| return; | |||
| // Checks: CPUID supported, model >= Pentium 4, Hyperthreading bit set, logical CPUs per package > 1 | |||
| if (featuresWord == 0 | |||
| || ((familyModelWord >> 8) & 0xf) < 15 | |||
| || (featuresWord & (1 << 28)) == 0 | |||
| || ((extFeaturesWord >> 16) & 0xff) < 2) | |||
| { | |||
| logicalCpuInfo.physicalAffinityMask = static_cast <unsigned long> (processAffinity); | |||
| return; | |||
| } | |||
| logicalCpuInfo.htSupported = true; | |||
| logicalCpuInfo.numLogicalPerPackage = (extFeaturesWord >> 16) & 0xff; | |||
| unsigned int affinityMask; | |||
| unsigned int physAff = 0; | |||
| unsigned char i = 1; | |||
| unsigned char physIdMask = 0xFF; | |||
| unsigned char physIdShift = 0; | |||
| unsigned char apicId; | |||
| unsigned char logId; | |||
| unsigned char physId; | |||
| while (i < logicalCpuInfo.numLogicalPerPackage) | |||
| { | |||
| i *= 2; | |||
| physIdMask <<= 1; | |||
| physIdShift++; | |||
| } | |||
| affinityMask = 1; | |||
| logicalCpuInfo.numPackages = 0; | |||
| while ((affinityMask != 0) && (affinityMask <= processAffinity)) | |||
| { | |||
| if (SetProcessAffinityMask (hCurrentProcessHandle, affinityMask)) | |||
| { | |||
| Sleep(0); // schedule onto correct CPU | |||
| featuresWord = getCPUIDWord (&familyModelWord, &extFeaturesWord); | |||
| apicId = (unsigned char) (extFeaturesWord >> 24); | |||
| logId = (unsigned char) (apicId & ~physIdMask); | |||
| physId = (unsigned char) (apicId >> physIdShift); | |||
| if (logId != 0) | |||
| logicalCpuInfo.htAvailable = true; | |||
| if ((((int) logId) % logicalCpuInfo.numLogicalPerPackage) == 0) | |||
| { | |||
| // This is a physical CPU | |||
| physAff |= affinityMask; | |||
| logicalCpuInfo.numPackages++; | |||
| } | |||
| } | |||
| affinityMask = affinityMask << 1; | |||
| } | |||
| logicalCpuInfo.physicalAffinityMask = physAff; | |||
| SetProcessAffinityMask(hCurrentProcessHandle, processAffinity); | |||
| } | |||
| //============================================================================== | |||
| void juce_initialiseThreadEvents() throw(); | |||
| #if JUCE_ENABLE_WIN98_COMPATIBILITY | |||
| void juce_initialiseUnicodeFileFunctions() throw(); | |||
| #endif | |||
| static struct JuceCpuProps | |||
| struct CPUFlags | |||
| { | |||
| bool hasMMX : 1, hasSSE : 1, hasSSE2 : 1, has3DNow : 1; | |||
| } juce_CpuProps; | |||
| bool hasMMX : 1; | |||
| bool hasSSE : 1; | |||
| bool hasSSE2 : 1; | |||
| bool has3DNow : 1; | |||
| }; | |||
| static CPUFlags cpuFlags; | |||
| bool SystemStats::hasMMX() throw() | |||
| { | |||
| return juce_CpuProps.hasMMX; | |||
| return cpuFlags.hasMMX; | |||
| } | |||
| bool SystemStats::hasSSE() throw() | |||
| { | |||
| return juce_CpuProps.hasSSE; | |||
| return cpuFlags.hasSSE; | |||
| } | |||
| bool SystemStats::hasSSE2() throw() | |||
| { | |||
| return juce_CpuProps.hasSSE2; | |||
| return cpuFlags.hasSSE2; | |||
| } | |||
| bool SystemStats::has3DNow() throw() | |||
| { | |||
| return juce_CpuProps.has3DNow; | |||
| return cpuFlags.has3DNow; | |||
| } | |||
| void SystemStats::initialiseStats() throw() | |||
| @@ -344,13 +260,13 @@ void SystemStats::initialiseStats() throw() | |||
| juce_initialiseThreadEvents(); | |||
| juce_CpuProps.hasMMX = IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE) != 0; | |||
| juce_CpuProps.hasSSE = IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE) != 0; | |||
| juce_CpuProps.hasSSE2 = IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE) != 0; | |||
| cpuFlags.hasMMX = IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE) != 0; | |||
| cpuFlags.hasSSE = IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE) != 0; | |||
| cpuFlags.hasSSE2 = IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE) != 0; | |||
| #ifdef PF_AMD3D_INSTRUCTIONS_AVAILABLE | |||
| juce_CpuProps.has3DNow = IsProcessorFeaturePresent (PF_AMD3D_INSTRUCTIONS_AVAILABLE) != 0; | |||
| cpuFlags.has3DNow = IsProcessorFeaturePresent (PF_AMD3D_INSTRUCTIONS_AVAILABLE) != 0; | |||
| #else | |||
| juce_CpuProps.has3DNow = IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE) != 0; | |||
| cpuFlags.has3DNow = IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE) != 0; | |||
| #endif | |||
| LARGE_INTEGER f; | |||
| @@ -361,7 +277,6 @@ void SystemStats::initialiseStats() throw() | |||
| String s (SystemStats::getJUCEVersion()); | |||
| GetSystemInfo (&systemInfo); | |||
| initLogicalCpuInfo(); | |||
| #ifdef JUCE_DEBUG | |||
| const MMRESULT res = timeBeginPeriod (1); | |||
| @@ -445,29 +360,11 @@ int SystemStats::getMemorySizeInMegabytes() throw() | |||
| return (int) (mem.dwTotalPhys / (1024 * 1024)) + 1; | |||
| } | |||
| bool SystemStats::hasHyperThreading() throw() | |||
| { | |||
| return logicalCpuInfo.htAvailable; | |||
| } | |||
| int SystemStats::getNumPhysicalCpus() throw() | |||
| { | |||
| if (logicalCpuInfo.numPackages) | |||
| return logicalCpuInfo.numPackages; | |||
| return getNumLogicalCpus(); | |||
| } | |||
| int SystemStats::getNumLogicalCpus() throw() | |||
| int SystemStats::getNumCpus() throw() | |||
| { | |||
| return systemInfo.dwNumberOfProcessors; | |||
| } | |||
| uint32 SystemStats::getPhysicalAffinityMask() throw() | |||
| { | |||
| return logicalCpuInfo.physicalAffinityMask; | |||
| } | |||
| //============================================================================== | |||
| uint32 juce_millisecondsSinceStartup() throw() | |||
| { | |||
| @@ -225,7 +225,7 @@ void Thread::yield() throw() | |||
| Sleep (0); | |||
| } | |||
| void Thread::sleep (const int millisecs) throw() | |||
| void JUCE_CALLTYPE Thread::sleep (const int millisecs) throw() | |||
| { | |||
| if (millisecs >= 10) | |||
| { | |||
| @@ -124,13 +124,11 @@ private: | |||
| << T("\nOperating system: ") << SystemStats::getOperatingSystemName() | |||
| << T("\nCPU vendor: ") << SystemStats::getCpuVendor() | |||
| << T("\nCPU speed: ") << SystemStats::getCpuSpeedInMegaherz() << T("MHz\n") | |||
| << T("\nNumber of physical CPUs: ") << SystemStats::getNumPhysicalCpus() | |||
| << T("\nNumber of logical CPUs: ") << SystemStats::getNumLogicalCpus() | |||
| << T("\nNumber of CPUs: ") << SystemStats::getNumCpus() | |||
| << T("\nCPU has MMX: ") << (SystemStats::hasMMX() ? T("yes") : T("no")) | |||
| << T("\nCPU has SSE: ") << (SystemStats::hasSSE() ? T("yes") : T("no")) | |||
| << T("\nCPU has SSE2: ") << (SystemStats::hasSSE2() ? T("yes") : T("no")) | |||
| << T("\nCPU has 3DNOW: ") << (SystemStats::has3DNow() ? T("yes") : T("no")) | |||
| << T("\nCPU has hyperthreading: ") << (SystemStats::hasHyperThreading() ? T("yes") : T("no")) | |||
| << T("\nMemory size: ") << SystemStats::getMemorySizeInMegabytes() << T("MB\n"); | |||
| int64 macAddresses[8]; | |||
| @@ -1169,7 +1169,7 @@ private: | |||
| public: | |||
| TabMoveProperty (TabbedComponent* comp, JucerDocument& document_, | |||
| const int tabIndex_, const int totalNumTabs_) | |||
| : ButtonPropertyComponent (T("add tab"), false), | |||
| : ButtonPropertyComponent (T("move tab"), false), | |||
| component (comp), | |||
| document (document_), | |||
| tabIndex (tabIndex_), | |||
| @@ -429,30 +429,25 @@ void* Component::getWindowHandle() const throw() | |||
| } | |||
| //============================================================================== | |||
| void Component::addToDesktop (int desktopWindowStyleFlags, void* nativeWindowToAttachTo) | |||
| void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo) | |||
| { | |||
| // if component methods are being called from threads other than the message | |||
| // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
| checkMessageManagerIsLocked | |||
| if (! isOpaque()) | |||
| desktopWindowStyleFlags |= juce_windowIsSemiTransparentFlag; | |||
| styleWanted |= juce_windowIsSemiTransparentFlag; | |||
| int currentStyleFlags = 0; | |||
| ComponentBoundsConstrainer* currentConstainer = 0; | |||
| if (isOnDesktop()) | |||
| { | |||
| const ComponentPeer* const peer = getPeer(); | |||
| // don't use getPeer(), so that we only get the peer that's specifically | |||
| // for this comp, and not for one of its parents. | |||
| ComponentPeer* peer = ComponentPeer::getPeerFor (this); | |||
| if (peer != 0) | |||
| { | |||
| currentStyleFlags = peer->getStyleFlags(); | |||
| currentConstainer = peer->getConstrainer(); | |||
| } | |||
| } | |||
| if (peer != 0) | |||
| currentStyleFlags = peer->getStyleFlags(); | |||
| if ((! isOnDesktop()) || desktopWindowStyleFlags != currentStyleFlags) | |||
| if (styleWanted != currentStyleFlags || ! flags.hasHeavyweightPeerFlag) | |||
| { | |||
| const ComponentDeletionWatcher deletionChecker (this); | |||
| @@ -467,14 +462,16 @@ void Component::addToDesktop (int desktopWindowStyleFlags, void* nativeWindowToA | |||
| int x = 0, y = 0; | |||
| relativePositionToGlobal (x, y); | |||
| ComponentPeer* peer = getPeer(); | |||
| bool wasFullscreen = false; | |||
| bool wasMinimised = false; | |||
| ComponentBoundsConstrainer* currentConstainer = 0; | |||
| if (peer != 0) | |||
| { | |||
| wasFullscreen = peer->isFullScreen(); | |||
| wasMinimised = peer->isMinimised(); | |||
| currentConstainer = peer->getConstrainer(); | |||
| removeFromDesktop(); | |||
| } | |||
| @@ -485,7 +482,7 @@ void Component::addToDesktop (int desktopWindowStyleFlags, void* nativeWindowToA | |||
| { | |||
| flags.hasHeavyweightPeerFlag = true; | |||
| peer = createNewPeer (desktopWindowStyleFlags, nativeWindowToAttachTo); | |||
| peer = createNewPeer (styleWanted, nativeWindowToAttachTo); | |||
| Desktop::getInstance().addDesktopComponent (this); | |||
| @@ -518,7 +515,7 @@ void Component::removeFromDesktop() | |||
| // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
| checkMessageManagerIsLocked | |||
| if (isOnDesktop()) | |||
| if (flags.hasHeavyweightPeerFlag) | |||
| { | |||
| ComponentPeer* const peer = ComponentPeer::getPeerFor (this); | |||
| @@ -559,9 +556,9 @@ void Component::setOpaque (const bool shouldBeOpaque) throw() | |||
| { | |||
| flags.opaqueFlag = shouldBeOpaque; | |||
| if (isOnDesktop()) | |||
| if (flags.hasHeavyweightPeerFlag) | |||
| { | |||
| const ComponentPeer* const peer = getPeer(); | |||
| const ComponentPeer* const peer = ComponentPeer::getPeerFor (this); | |||
| if (peer != 0) | |||
| { | |||
| @@ -880,7 +877,7 @@ void Component::setBounds (int x, int y, int w, int h) | |||
| // send a fake mouse move to trigger enter/exit messages if needed.. | |||
| sendFakeMouseMove(); | |||
| if (! isOnDesktop()) | |||
| if (! flags.hasHeavyweightPeerFlag) | |||
| repaintParent(); | |||
| } | |||
| @@ -888,7 +885,7 @@ void Component::setBounds (int x, int y, int w, int h) | |||
| if (wasResized) | |||
| repaint(); | |||
| else if (! isOnDesktop()) | |||
| else if (! flags.hasHeavyweightPeerFlag) | |||
| repaintParent(); | |||
| if (flags.hasHeavyweightPeerFlag) | |||
| @@ -1859,9 +1856,17 @@ void Component::sendLookAndFeelChange() | |||
| } | |||
| } | |||
| static const String getColourPropertyName (const int colourId) throw() | |||
| { | |||
| String s; | |||
| s.preallocateStorage (18); | |||
| s << T("jcclr_") << colourId; | |||
| return s; | |||
| } | |||
| const Colour Component::findColour (const int colourId, const bool inheritFromParent) const throw() | |||
| { | |||
| const String customColour (getComponentProperty (T("jucecol_") + String::toHexString (colourId), | |||
| const String customColour (getComponentProperty (getColourPropertyName (colourId), | |||
| inheritFromParent, | |||
| String::empty)); | |||
| @@ -1873,7 +1878,7 @@ const Colour Component::findColour (const int colourId, const bool inheritFromPa | |||
| bool Component::isColourSpecified (const int colourId) const throw() | |||
| { | |||
| return getComponentProperty (T("jucecol_") + String::toHexString (colourId), | |||
| return getComponentProperty (getColourPropertyName (colourId), | |||
| false, | |||
| String::empty).isNotEmpty(); | |||
| } | |||
| @@ -1882,14 +1887,14 @@ void Component::removeColour (const int colourId) | |||
| { | |||
| if (isColourSpecified (colourId)) | |||
| { | |||
| removeComponentProperty (T("jucecol_") + String::toHexString (colourId)); | |||
| removeComponentProperty (getColourPropertyName (colourId)); | |||
| colourChanged(); | |||
| } | |||
| } | |||
| void Component::setColour (const int colourId, const Colour& colour) | |||
| { | |||
| const String colourName (T("jucecol_") + String::toHexString (colourId)); | |||
| const String colourName (getColourPropertyName (colourId)); | |||
| const String customColour (getComponentProperty (colourName, false, String::empty)); | |||
| if (customColour.isEmpty() || Colour (customColour.getIntValue()) != colour) | |||
| @@ -1908,7 +1913,7 @@ void Component::copyAllExplicitColoursTo (Component& target) const throw() | |||
| for (int i = 0; i < keys.size(); ++i) | |||
| { | |||
| if (keys[i].startsWith (T("jucecol_"))) | |||
| if (keys[i].startsWith (T("jcclr_"))) | |||
| { | |||
| target.setComponentProperty (keys[i], | |||
| props.getAllValues() [i]); | |||
| @@ -156,12 +156,12 @@ DropShadower::~DropShadower() | |||
| void DropShadower::deleteShadowWindows() | |||
| { | |||
| int i; | |||
| for (i = numShadows; --i >= 0;) | |||
| delete shadowWindows[i]; | |||
| if (numShadows > 0) | |||
| { | |||
| int i; | |||
| for (i = numShadows; --i >= 0;) | |||
| delete shadowWindows[i]; | |||
| for (i = 12; --i >= 0;) | |||
| delete shadowImageSections[i]; | |||
| @@ -305,22 +305,22 @@ void DropShadower::updateShadows() | |||
| } | |||
| const int x = owner->getX(); | |||
| const int y = owner->getY(); | |||
| const int y = owner->getY() - shadowEdge; | |||
| const int w = owner->getWidth(); | |||
| const int h = owner->getHeight(); | |||
| const int h = owner->getHeight() + shadowEdge + shadowEdge; | |||
| shadowWindows[0]->setBounds (x - shadowEdge, | |||
| y - shadowEdge, | |||
| y, | |||
| shadowEdge, | |||
| h + shadowEdge + shadowEdge); | |||
| h); | |||
| shadowWindows[1]->setBounds (x + w, | |||
| y - shadowEdge, | |||
| y, | |||
| shadowEdge, | |||
| h + shadowEdge + shadowEdge); | |||
| h); | |||
| shadowWindows[2]->setBounds (x, | |||
| y - shadowEdge, | |||
| y, | |||
| w, | |||
| shadowEdge); | |||
| @@ -341,7 +341,7 @@ void DropShadower::setShadowImage (Image* const src, | |||
| const int w, | |||
| const int h, | |||
| const int sx, | |||
| const int sy) | |||
| const int sy) throw() | |||
| { | |||
| shadowImageSections[num] = new Image (Image::ARGB, w, h, true); | |||
| @@ -101,7 +101,7 @@ private: | |||
| void setShadowImage (Image* const src, | |||
| const int num, | |||
| const int w, const int h, | |||
| const int sx, const int sy); | |||
| const int sx, const int sy) throw(); | |||
| void bringShadowWindowsToFront(); | |||
| void deleteShadowWindows(); | |||
| @@ -57,9 +57,11 @@ ResizableWindow::ResizableWindow (const String& name, | |||
| { | |||
| setBackgroundColour (backgroundColour_); | |||
| const Rectangle mainMonArea (Desktop::getInstance().getMainMonitorArea()); | |||
| defaultConstrainer.setSizeLimits (200, 200, | |||
| Desktop::getInstance().getMainMonitorArea().getWidth(), | |||
| Desktop::getInstance().getMainMonitorArea().getHeight()); | |||
| mainMonArea.getWidth(), | |||
| mainMonArea.getHeight()); | |||
| defaultConstrainer.setMinimumOnscreenAmounts (0x10000, 16, 24, 16); | |||
| @@ -101,13 +103,10 @@ void ResizableWindow::setContentComponent (Component* const newContentComponent, | |||
| if (contentComponent != newContentComponent) | |||
| { | |||
| if (contentComponent != 0) | |||
| { | |||
| if (deleteOldOne) | |||
| delete contentComponent; | |||
| else | |||
| removeChildComponent (contentComponent); | |||
| } | |||
| if (deleteOldOne) | |||
| delete contentComponent; | |||
| else | |||
| removeChildComponent (contentComponent); | |||
| contentComponent = newContentComponent; | |||
| @@ -269,18 +268,22 @@ void ResizableWindow::setResizeLimits (const int newMinimumWidth, | |||
| void ResizableWindow::setConstrainer (ComponentBoundsConstrainer* newConstrainer) | |||
| { | |||
| constrainer = newConstrainer; | |||
| if (constrainer != newConstrainer) | |||
| { | |||
| constrainer = newConstrainer; | |||
| const bool shouldBeResizable = resizableCorner != 0 || resizableBorder != 0; | |||
| const bool useBottomRightCornerResizer = resizableCorner != 0; | |||
| const bool useBottomRightCornerResizer = resizableCorner != 0; | |||
| const bool shouldBeResizable = useBottomRightCornerResizer || resizableBorder != 0; | |||
| deleteAndZero (resizableCorner); | |||
| deleteAndZero (resizableBorder); | |||
| deleteAndZero (resizableCorner); | |||
| deleteAndZero (resizableBorder); | |||
| setResizable (shouldBeResizable, useBottomRightCornerResizer); | |||
| setResizable (shouldBeResizable, useBottomRightCornerResizer); | |||
| if (getPeer() != 0) | |||
| getPeer()->setConstrainer (newConstrainer); | |||
| ComponentPeer* const peer = getPeer(); | |||
| if (peer != 0) | |||
| peer->setConstrainer (newConstrainer); | |||
| } | |||
| } | |||
| void ResizableWindow::setBoundsConstrained (int x, int y, int w, int h) | |||
| @@ -326,8 +329,9 @@ void ResizableWindow::lookAndFeelChanged() | |||
| { | |||
| Component::addToDesktop (getDesktopWindowStyleFlags()); | |||
| if (getPeer() != 0) | |||
| getPeer()->setConstrainer (constrainer); | |||
| ComponentPeer* const peer = getPeer(); | |||
| if (peer != 0) | |||
| peer->setConstrainer (constrainer); | |||
| } | |||
| } | |||
| @@ -394,21 +398,21 @@ void ResizableWindow::setFullScreen (const bool shouldBeFullScreen) | |||
| bool ResizableWindow::isMinimised() const | |||
| { | |||
| ComponentPeer* const nw = getPeer(); | |||
| ComponentPeer* const peer = getPeer(); | |||
| return (nw != 0) && nw->isMinimised(); | |||
| return (peer != 0) && peer->isMinimised(); | |||
| } | |||
| void ResizableWindow::setMinimised (const bool shouldMinimise) | |||
| { | |||
| if (shouldMinimise != isMinimised()) | |||
| { | |||
| ComponentPeer* const nw = getPeer(); | |||
| ComponentPeer* const peer = getPeer(); | |||
| if (nw != 0) | |||
| if (peer != 0) | |||
| { | |||
| updateLastPos(); | |||
| nw->setMinimised (shouldMinimise); | |||
| peer->setMinimised (shouldMinimise); | |||
| } | |||
| else | |||
| { | |||
| @@ -441,7 +445,7 @@ const String ResizableWindow::getWindowStateAsString() | |||
| String s; | |||
| if (isFullScreen()) | |||
| s << T("fs "); | |||
| s << "fs "; | |||
| s << lastNonFullScreenPos.getX() << T(' ') | |||
| << lastNonFullScreenPos.getY() << T(' ') | |||
| @@ -464,10 +468,10 @@ bool ResizableWindow::restoreWindowStateFromString (const String& s) | |||
| if (tokens.size() != 4 + n) | |||
| return false; | |||
| Rectangle r (tokens[n].getIntValue(), | |||
| tokens[n + 1].getIntValue(), | |||
| tokens[n + 2].getIntValue(), | |||
| tokens[n + 3].getIntValue()); | |||
| const Rectangle r (tokens[n].getIntValue(), | |||
| tokens[n + 1].getIntValue(), | |||
| tokens[n + 2].getIntValue(), | |||
| tokens[n + 3].getIntValue()); | |||
| if (r.isEmpty()) | |||
| return false; | |||
| @@ -51,10 +51,10 @@ static const Graphics::ResamplingQuality defaultQuality = Graphics::mediumResamp | |||
| && (int) x <= MAXIMUM_COORD \ | |||
| && (int) y >= MINIMUM_COORD \ | |||
| && (int) y <= MAXIMUM_COORD \ | |||
| && (int) w >= 0 \ | |||
| && (int) w < MAXIMUM_COORD \ | |||
| && (int) h >= 0 \ | |||
| && (int) h < MAXIMUM_COORD); | |||
| && (int) w >= MINIMUM_COORD \ | |||
| && (int) w <= MAXIMUM_COORD \ | |||
| && (int) h >= MINIMUM_COORD \ | |||
| && (int) h <= MAXIMUM_COORD); | |||
| //============================================================================== | |||
| @@ -115,31 +115,9 @@ public: | |||
| /** Checks whether AMD 3DNOW instructions are available. */ | |||
| static bool has3DNow() throw(); | |||
| /** True if the chip has hyperthreading. | |||
| Probably only uber-geeks will care less about this. | |||
| */ | |||
| static bool hasHyperThreading() throw(); | |||
| /** Checks whether there are multiple processors in the box. | |||
| @see getNumLogicalCpus | |||
| */ | |||
| static int getNumPhysicalCpus() throw(); | |||
| /** Counts the number of logical processors. | |||
| May give a different result to getNumPhysicalCpus()... | |||
| */ | |||
| static int getNumLogicalCpus() throw(); | |||
| /** Returns a bitmask for the physical processors. | |||
| This mask shows which of the logical processors are actually physical. | |||
| @see Thread::setAffinityMask | |||
| /** Returns the number of CPUs. | |||
| */ | |||
| static uint32 getPhysicalAffinityMask() throw(); | |||
| static int getNumCpus() throw(); | |||
| /** Returns a clock-cycle tick counter, if available. | |||
| @@ -241,7 +241,7 @@ int64 Time::secondsToHighResolutionTicks (const double seconds) throw() | |||
| //============================================================================== | |||
| const Time Time::getCurrentTime() throw() | |||
| const Time JUCE_CALLTYPE Time::getCurrentTime() throw() | |||
| { | |||
| return Time (currentTimeMillis()); | |||
| } | |||
| @@ -103,7 +103,7 @@ public: | |||
| @see currentTimeMillis | |||
| */ | |||
| static const Time getCurrentTime() throw(); | |||
| static const Time JUCE_CALLTYPE getCurrentTime() throw(); | |||
| /** Returns the time as a number of milliseconds. | |||
| @@ -767,7 +767,7 @@ public: | |||
| @see SpecialLocationType | |||
| */ | |||
| static const File getSpecialLocation (const SpecialLocationType type); | |||
| static const File JUCE_CALLTYPE getSpecialLocation (const SpecialLocationType type); | |||
| //============================================================================== | |||
| /** Returns a temporary file in the system's temp directory. | |||
| @@ -769,13 +769,17 @@ const String String::operator+ (const tchar characterToAppend) const throw() | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (const char* const string1, | |||
| const String& string2) throw() | |||
| { | |||
| return String (string1) + string2; | |||
| String s (string1); | |||
| s += string2; | |||
| return s; | |||
| } | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (const juce_wchar* const string1, | |||
| const String& string2) throw() | |||
| { | |||
| return String (string1) + string2; | |||
| String s (string1); | |||
| s += string2; | |||
| return s; | |||
| } | |||
| //============================================================================== | |||
| @@ -192,10 +192,10 @@ public: | |||
| //============================================================================== | |||
| // this can be called from any thread that needs to pause.. | |||
| static void sleep (int milliseconds) throw(); | |||
| static void JUCE_CALLTYPE sleep (int milliseconds) throw(); | |||
| /** Yields the calling thread's current time-slot. */ | |||
| static void yield() throw(); | |||
| static void JUCE_CALLTYPE yield() throw(); | |||
| //============================================================================== | |||
| /** Makes the thread wait for a notification. | |||