mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
whitespace clean-up
This commit is contained in:
parent
b7eb1587b5
commit
08d0621c07
22 changed files with 5916 additions and 5911 deletions
|
|
@ -1089,7 +1089,7 @@
|
|||
84E024E80E94028C003E41AF /* juce_mac_Network.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = juce_mac_Network.mm; sourceTree = "<group>"; };
|
||||
84E024E90E94028C003E41AF /* juce_mac_NSViewComponent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = juce_mac_NSViewComponent.mm; sourceTree = "<group>"; };
|
||||
84E024EA0E94028C003E41AF /* juce_mac_NSViewComponentPeer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 2; path = juce_mac_NSViewComponentPeer.mm; sourceTree = "<group>"; };
|
||||
84E024EB0E94028C003E41AF /* juce_mac_OpenGLComponent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = juce_mac_OpenGLComponent.mm; sourceTree = "<group>"; };
|
||||
84E024EB0E94028C003E41AF /* juce_mac_OpenGLComponent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 2; path = juce_mac_OpenGLComponent.mm; sourceTree = "<group>"; };
|
||||
84E024EC0E94028C003E41AF /* juce_mac_QuickTimeMovieComponent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = juce_mac_QuickTimeMovieComponent.mm; sourceTree = "<group>"; };
|
||||
84E024ED0E94028C003E41AF /* juce_mac_SystemStats.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = juce_mac_SystemStats.mm; sourceTree = "<group>"; };
|
||||
84E024EE0E94028C003E41AF /* juce_mac_Threads.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = juce_mac_Threads.mm; sourceTree = "<group>"; };
|
||||
|
|
@ -1177,7 +1177,7 @@
|
|||
84FED3C80CAA96DA00003997 /* juce_FileDragAndDropTarget.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = juce_FileDragAndDropTarget.h; sourceTree = "<group>"; };
|
||||
84FFAF290C6C8F2B009F6E72 /* juce_FileSearchPathListComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = juce_FileSearchPathListComponent.cpp; path = filebrowser/juce_FileSearchPathListComponent.cpp; sourceTree = "<group>"; };
|
||||
84FFAF2A0C6C8F2B009F6E72 /* juce_FileSearchPathListComponent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = juce_FileSearchPathListComponent.h; path = filebrowser/juce_FileSearchPathListComponent.h; sourceTree = "<group>"; };
|
||||
D2AAC046055464E500DB518D /* libjuce.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libjuce.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D2AAC046055464E500DB518D /* libjucedebug.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libjucedebug.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
|
@ -1216,7 +1216,7 @@
|
|||
1AB674ADFE9D54B511CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D2AAC046055464E500DB518D /* libjuce.a */,
|
||||
D2AAC046055464E500DB518D /* libjucedebug.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -2566,7 +2566,7 @@
|
|||
);
|
||||
name = Juce;
|
||||
productName = Juce;
|
||||
productReference = D2AAC046055464E500DB518D /* libjuce.a */;
|
||||
productReference = D2AAC046055464E500DB518D /* libjucedebug.a */;
|
||||
productType = "com.apple.product-type.library.static";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,341 +1,341 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
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.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
// (This file gets included by juce_mac_NativeCode.mm, rather than being
|
||||
// compiled on its own).
|
||||
#ifdef JUCE_INCLUDED_FILE
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class FontHelper
|
||||
{
|
||||
NSFont* font;
|
||||
|
||||
public:
|
||||
String name;
|
||||
bool isBold, isItalic;
|
||||
float fontSize, totalSize, ascent;
|
||||
int refCount;
|
||||
|
||||
FontHelper (const String& name_,
|
||||
const bool bold_,
|
||||
const bool italic_,
|
||||
const float size_)
|
||||
: font (0),
|
||||
name (name_),
|
||||
isBold (bold_),
|
||||
isItalic (italic_),
|
||||
fontSize (size_),
|
||||
refCount (1)
|
||||
{
|
||||
font = [NSFont fontWithName: juceStringToNS (name_) size: size_];
|
||||
|
||||
if (italic_)
|
||||
font = [[NSFontManager sharedFontManager] convertFont: font toHaveTrait: NSItalicFontMask];
|
||||
|
||||
if (bold_)
|
||||
font = [[NSFontManager sharedFontManager] convertFont: font toHaveTrait: NSBoldFontMask];
|
||||
|
||||
[font retain];
|
||||
|
||||
ascent = fabsf ([font ascender]);
|
||||
totalSize = ascent + fabsf ([font descender]);
|
||||
}
|
||||
|
||||
~FontHelper()
|
||||
{
|
||||
[font release];
|
||||
}
|
||||
|
||||
bool getPathAndKerning (const juce_wchar char1,
|
||||
const juce_wchar char2,
|
||||
Path* path,
|
||||
float& kerning,
|
||||
float* ascent,
|
||||
float* descent)
|
||||
{
|
||||
const ScopedAutoReleasePool pool;
|
||||
|
||||
if (font == 0
|
||||
|| ! [[font coveredCharacterSet] longCharacterIsMember: (UTF32Char) char1])
|
||||
return false;
|
||||
|
||||
String chars;
|
||||
chars << ' ' << char1 << char2;
|
||||
NSTextStorage* textStorage = [[[NSTextStorage alloc]
|
||||
initWithString: juceStringToNS (chars)
|
||||
attributes: [NSDictionary dictionaryWithObject: [NSNumber numberWithInt: 0]
|
||||
forKey: NSLigatureAttributeName]] autorelease];
|
||||
NSLayoutManager* layoutManager = [[[NSLayoutManager alloc] init] autorelease];
|
||||
NSTextContainer* textContainer = [[[NSTextContainer alloc] init] autorelease];
|
||||
[layoutManager addTextContainer: textContainer];
|
||||
[textStorage addLayoutManager: layoutManager];
|
||||
[textStorage setFont: font];
|
||||
|
||||
unsigned int glyphIndex = [layoutManager glyphRangeForCharacterRange: NSMakeRange (1, 1)
|
||||
actualCharacterRange: 0].location;
|
||||
NSPoint p1 = [layoutManager locationForGlyphAtIndex: glyphIndex];
|
||||
NSPoint p2 = [layoutManager locationForGlyphAtIndex: glyphIndex + 1];
|
||||
kerning = p2.x - p1.x;
|
||||
|
||||
if (ascent != 0)
|
||||
*ascent = this->ascent;
|
||||
|
||||
if (descent != 0)
|
||||
*descent = fabsf ([font descender]);
|
||||
|
||||
if (path != 0)
|
||||
{
|
||||
NSBezierPath* bez = [NSBezierPath bezierPath];
|
||||
[bez moveToPoint: NSMakePoint (0, 0)];
|
||||
[bez appendBezierPathWithGlyph: [layoutManager glyphAtIndex: glyphIndex]
|
||||
inFont: font];
|
||||
|
||||
for (int i = 0; i < [bez elementCount]; ++i)
|
||||
{
|
||||
NSPoint p[3];
|
||||
switch ([bez elementAtIndex: i associatedPoints: p])
|
||||
{
|
||||
case NSMoveToBezierPathElement:
|
||||
path->startNewSubPath (p[0].x, -p[0].y);
|
||||
break;
|
||||
case NSLineToBezierPathElement:
|
||||
path->lineTo (p[0].x, -p[0].y);
|
||||
break;
|
||||
case NSCurveToBezierPathElement:
|
||||
path->cubicTo (p[0].x, -p[0].y, p[1].x, -p[1].y, p[2].x, -p[2].y);
|
||||
break;
|
||||
case NSClosePathBezierPathElement:
|
||||
path->closeSubPath();
|
||||
break;
|
||||
default:
|
||||
jassertfalse
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return kerning != 0;
|
||||
}
|
||||
|
||||
juce_wchar getDefaultChar()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
class FontHelperCache : public Timer,
|
||||
public DeletedAtShutdown
|
||||
{
|
||||
VoidArray cache;
|
||||
|
||||
public:
|
||||
FontHelperCache()
|
||||
{
|
||||
}
|
||||
|
||||
~FontHelperCache()
|
||||
{
|
||||
for (int i = cache.size(); --i >= 0;)
|
||||
{
|
||||
FontHelper* const f = (FontHelper*) cache.getUnchecked(i);
|
||||
delete f;
|
||||
}
|
||||
|
||||
clearSingletonInstance();
|
||||
}
|
||||
|
||||
FontHelper* getFont (const String& name,
|
||||
const bool bold,
|
||||
const bool italic,
|
||||
const float size = 1024)
|
||||
{
|
||||
for (int i = cache.size(); --i >= 0;)
|
||||
{
|
||||
FontHelper* const f = (FontHelper*) cache.getUnchecked(i);
|
||||
|
||||
if (f->name == name
|
||||
&& f->isBold == bold
|
||||
&& f->isItalic == italic
|
||||
&& f->fontSize == size)
|
||||
{
|
||||
f->refCount++;
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
||||
FontHelper* const f = new FontHelper (name, bold, italic, size);
|
||||
cache.add (f);
|
||||
return f;
|
||||
}
|
||||
|
||||
void releaseFont (FontHelper* f)
|
||||
{
|
||||
for (int i = cache.size(); --i >= 0;)
|
||||
{
|
||||
FontHelper* const f2 = (FontHelper*) cache.getUnchecked(i);
|
||||
|
||||
if (f == f2)
|
||||
{
|
||||
f->refCount--;
|
||||
|
||||
if (f->refCount == 0)
|
||||
startTimer (5000);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void timerCallback()
|
||||
{
|
||||
stopTimer();
|
||||
|
||||
for (int i = cache.size(); --i >= 0;)
|
||||
{
|
||||
FontHelper* const f = (FontHelper*) cache.getUnchecked(i);
|
||||
|
||||
if (f->refCount == 0)
|
||||
{
|
||||
cache.remove (i);
|
||||
delete f;
|
||||
}
|
||||
}
|
||||
|
||||
if (cache.size() == 0)
|
||||
delete this;
|
||||
}
|
||||
|
||||
juce_DeclareSingleton_SingleThreaded_Minimal (FontHelperCache)
|
||||
};
|
||||
|
||||
juce_ImplementSingleton_SingleThreaded (FontHelperCache)
|
||||
|
||||
//==============================================================================
|
||||
void Typeface::initialiseTypefaceCharacteristics (const String& fontName,
|
||||
bool bold,
|
||||
bool italic,
|
||||
bool addAllGlyphsToFont) throw()
|
||||
{
|
||||
// This method is only safe to be called from the normal UI thread..
|
||||
jassert (MessageManager::getInstance()->isThisTheMessageThread());
|
||||
|
||||
FontHelper* const helper = FontHelperCache::getInstance()
|
||||
->getFont (fontName, bold, italic);
|
||||
|
||||
clear();
|
||||
setAscent (helper->ascent / helper->totalSize);
|
||||
setName (fontName);
|
||||
setDefaultCharacter (helper->getDefaultChar());
|
||||
setBold (bold);
|
||||
setItalic (italic);
|
||||
|
||||
if (addAllGlyphsToFont)
|
||||
{
|
||||
//xxx
|
||||
jassertfalse
|
||||
}
|
||||
|
||||
FontHelperCache::getInstance()->releaseFont (helper);
|
||||
}
|
||||
|
||||
bool Typeface::findAndAddSystemGlyph (juce_wchar character) throw()
|
||||
{
|
||||
// This method is only safe to be called from the normal UI thread..
|
||||
jassert (MessageManager::getInstance()->isThisTheMessageThread());
|
||||
|
||||
FontHelper* const helper = FontHelperCache::getInstance()
|
||||
->getFont (getName(), isBold(), isItalic());
|
||||
|
||||
Path path;
|
||||
float width;
|
||||
bool foundOne = false;
|
||||
|
||||
if (helper->getPathAndKerning (character, T('I'), &path, width, 0, 0))
|
||||
{
|
||||
path.applyTransform (AffineTransform::scale (1.0f / helper->totalSize,
|
||||
1.0f / helper->totalSize));
|
||||
|
||||
addGlyph (character, path, width / helper->totalSize);
|
||||
|
||||
for (int i = 0; i < glyphs.size(); ++i)
|
||||
{
|
||||
const TypefaceGlyphInfo* const g = (const TypefaceGlyphInfo*) glyphs.getUnchecked(i);
|
||||
|
||||
float kerning;
|
||||
if (helper->getPathAndKerning (character, g->getCharacter(), 0, kerning, 0, 0))
|
||||
{
|
||||
kerning = (kerning - width) / helper->totalSize;
|
||||
|
||||
if (kerning != 0)
|
||||
addKerningPair (character, g->getCharacter(), kerning);
|
||||
}
|
||||
|
||||
if (helper->getPathAndKerning (g->getCharacter(), character, 0, kerning, 0, 0))
|
||||
{
|
||||
kerning = kerning / helper->totalSize - g->width;
|
||||
|
||||
if (kerning != 0)
|
||||
addKerningPair (g->getCharacter(), character, kerning);
|
||||
}
|
||||
}
|
||||
|
||||
foundOne = true;
|
||||
}
|
||||
|
||||
FontHelperCache::getInstance()->releaseFont (helper);
|
||||
return foundOne;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
const StringArray Font::findAllTypefaceNames() throw()
|
||||
{
|
||||
StringArray names;
|
||||
|
||||
const ScopedAutoReleasePool pool;
|
||||
NSArray* fonts = [[NSFontManager sharedFontManager] availableFontFamilies];
|
||||
|
||||
for (int i = 0; i < [fonts count]; ++i)
|
||||
names.add (nsStringToJuce ((NSString*) [fonts objectAtIndex: i]));
|
||||
|
||||
names.sort (true);
|
||||
return names;
|
||||
}
|
||||
|
||||
void Typeface::getDefaultFontNames (String& defaultSans, String& defaultSerif, String& defaultFixed) throw()
|
||||
{
|
||||
defaultSans = "Lucida Grande";
|
||||
defaultSerif = "Times New Roman";
|
||||
defaultFixed = "Monaco";
|
||||
}
|
||||
|
||||
#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.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
// (This file gets included by juce_mac_NativeCode.mm, rather than being
|
||||
// compiled on its own).
|
||||
#ifdef JUCE_INCLUDED_FILE
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class FontHelper
|
||||
{
|
||||
NSFont* font;
|
||||
|
||||
public:
|
||||
String name;
|
||||
bool isBold, isItalic;
|
||||
float fontSize, totalSize, ascent;
|
||||
int refCount;
|
||||
|
||||
FontHelper (const String& name_,
|
||||
const bool bold_,
|
||||
const bool italic_,
|
||||
const float size_)
|
||||
: font (0),
|
||||
name (name_),
|
||||
isBold (bold_),
|
||||
isItalic (italic_),
|
||||
fontSize (size_),
|
||||
refCount (1)
|
||||
{
|
||||
font = [NSFont fontWithName: juceStringToNS (name_) size: size_];
|
||||
|
||||
if (italic_)
|
||||
font = [[NSFontManager sharedFontManager] convertFont: font toHaveTrait: NSItalicFontMask];
|
||||
|
||||
if (bold_)
|
||||
font = [[NSFontManager sharedFontManager] convertFont: font toHaveTrait: NSBoldFontMask];
|
||||
|
||||
[font retain];
|
||||
|
||||
ascent = fabsf ([font ascender]);
|
||||
totalSize = ascent + fabsf ([font descender]);
|
||||
}
|
||||
|
||||
~FontHelper()
|
||||
{
|
||||
[font release];
|
||||
}
|
||||
|
||||
bool getPathAndKerning (const juce_wchar char1,
|
||||
const juce_wchar char2,
|
||||
Path* path,
|
||||
float& kerning,
|
||||
float* ascent,
|
||||
float* descent)
|
||||
{
|
||||
const ScopedAutoReleasePool pool;
|
||||
|
||||
if (font == 0
|
||||
|| ! [[font coveredCharacterSet] longCharacterIsMember: (UTF32Char) char1])
|
||||
return false;
|
||||
|
||||
String chars;
|
||||
chars << ' ' << char1 << char2;
|
||||
NSTextStorage* textStorage = [[[NSTextStorage alloc]
|
||||
initWithString: juceStringToNS (chars)
|
||||
attributes: [NSDictionary dictionaryWithObject: [NSNumber numberWithInt: 0]
|
||||
forKey: NSLigatureAttributeName]] autorelease];
|
||||
NSLayoutManager* layoutManager = [[[NSLayoutManager alloc] init] autorelease];
|
||||
NSTextContainer* textContainer = [[[NSTextContainer alloc] init] autorelease];
|
||||
[layoutManager addTextContainer: textContainer];
|
||||
[textStorage addLayoutManager: layoutManager];
|
||||
[textStorage setFont: font];
|
||||
|
||||
unsigned int glyphIndex = [layoutManager glyphRangeForCharacterRange: NSMakeRange (1, 1)
|
||||
actualCharacterRange: 0].location;
|
||||
NSPoint p1 = [layoutManager locationForGlyphAtIndex: glyphIndex];
|
||||
NSPoint p2 = [layoutManager locationForGlyphAtIndex: glyphIndex + 1];
|
||||
kerning = p2.x - p1.x;
|
||||
|
||||
if (ascent != 0)
|
||||
*ascent = this->ascent;
|
||||
|
||||
if (descent != 0)
|
||||
*descent = fabsf ([font descender]);
|
||||
|
||||
if (path != 0)
|
||||
{
|
||||
NSBezierPath* bez = [NSBezierPath bezierPath];
|
||||
[bez moveToPoint: NSMakePoint (0, 0)];
|
||||
[bez appendBezierPathWithGlyph: [layoutManager glyphAtIndex: glyphIndex]
|
||||
inFont: font];
|
||||
|
||||
for (int i = 0; i < [bez elementCount]; ++i)
|
||||
{
|
||||
NSPoint p[3];
|
||||
switch ([bez elementAtIndex: i associatedPoints: p])
|
||||
{
|
||||
case NSMoveToBezierPathElement:
|
||||
path->startNewSubPath (p[0].x, -p[0].y);
|
||||
break;
|
||||
case NSLineToBezierPathElement:
|
||||
path->lineTo (p[0].x, -p[0].y);
|
||||
break;
|
||||
case NSCurveToBezierPathElement:
|
||||
path->cubicTo (p[0].x, -p[0].y, p[1].x, -p[1].y, p[2].x, -p[2].y);
|
||||
break;
|
||||
case NSClosePathBezierPathElement:
|
||||
path->closeSubPath();
|
||||
break;
|
||||
default:
|
||||
jassertfalse
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return kerning != 0;
|
||||
}
|
||||
|
||||
juce_wchar getDefaultChar()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
class FontHelperCache : public Timer,
|
||||
public DeletedAtShutdown
|
||||
{
|
||||
VoidArray cache;
|
||||
|
||||
public:
|
||||
FontHelperCache()
|
||||
{
|
||||
}
|
||||
|
||||
~FontHelperCache()
|
||||
{
|
||||
for (int i = cache.size(); --i >= 0;)
|
||||
{
|
||||
FontHelper* const f = (FontHelper*) cache.getUnchecked(i);
|
||||
delete f;
|
||||
}
|
||||
|
||||
clearSingletonInstance();
|
||||
}
|
||||
|
||||
FontHelper* getFont (const String& name,
|
||||
const bool bold,
|
||||
const bool italic,
|
||||
const float size = 1024)
|
||||
{
|
||||
for (int i = cache.size(); --i >= 0;)
|
||||
{
|
||||
FontHelper* const f = (FontHelper*) cache.getUnchecked(i);
|
||||
|
||||
if (f->name == name
|
||||
&& f->isBold == bold
|
||||
&& f->isItalic == italic
|
||||
&& f->fontSize == size)
|
||||
{
|
||||
f->refCount++;
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
||||
FontHelper* const f = new FontHelper (name, bold, italic, size);
|
||||
cache.add (f);
|
||||
return f;
|
||||
}
|
||||
|
||||
void releaseFont (FontHelper* f)
|
||||
{
|
||||
for (int i = cache.size(); --i >= 0;)
|
||||
{
|
||||
FontHelper* const f2 = (FontHelper*) cache.getUnchecked(i);
|
||||
|
||||
if (f == f2)
|
||||
{
|
||||
f->refCount--;
|
||||
|
||||
if (f->refCount == 0)
|
||||
startTimer (5000);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void timerCallback()
|
||||
{
|
||||
stopTimer();
|
||||
|
||||
for (int i = cache.size(); --i >= 0;)
|
||||
{
|
||||
FontHelper* const f = (FontHelper*) cache.getUnchecked(i);
|
||||
|
||||
if (f->refCount == 0)
|
||||
{
|
||||
cache.remove (i);
|
||||
delete f;
|
||||
}
|
||||
}
|
||||
|
||||
if (cache.size() == 0)
|
||||
delete this;
|
||||
}
|
||||
|
||||
juce_DeclareSingleton_SingleThreaded_Minimal (FontHelperCache)
|
||||
};
|
||||
|
||||
juce_ImplementSingleton_SingleThreaded (FontHelperCache)
|
||||
|
||||
//==============================================================================
|
||||
void Typeface::initialiseTypefaceCharacteristics (const String& fontName,
|
||||
bool bold,
|
||||
bool italic,
|
||||
bool addAllGlyphsToFont) throw()
|
||||
{
|
||||
// This method is only safe to be called from the normal UI thread..
|
||||
jassert (MessageManager::getInstance()->isThisTheMessageThread());
|
||||
|
||||
FontHelper* const helper = FontHelperCache::getInstance()
|
||||
->getFont (fontName, bold, italic);
|
||||
|
||||
clear();
|
||||
setAscent (helper->ascent / helper->totalSize);
|
||||
setName (fontName);
|
||||
setDefaultCharacter (helper->getDefaultChar());
|
||||
setBold (bold);
|
||||
setItalic (italic);
|
||||
|
||||
if (addAllGlyphsToFont)
|
||||
{
|
||||
//xxx
|
||||
jassertfalse
|
||||
}
|
||||
|
||||
FontHelperCache::getInstance()->releaseFont (helper);
|
||||
}
|
||||
|
||||
bool Typeface::findAndAddSystemGlyph (juce_wchar character) throw()
|
||||
{
|
||||
// This method is only safe to be called from the normal UI thread..
|
||||
jassert (MessageManager::getInstance()->isThisTheMessageThread());
|
||||
|
||||
FontHelper* const helper = FontHelperCache::getInstance()
|
||||
->getFont (getName(), isBold(), isItalic());
|
||||
|
||||
Path path;
|
||||
float width;
|
||||
bool foundOne = false;
|
||||
|
||||
if (helper->getPathAndKerning (character, T('I'), &path, width, 0, 0))
|
||||
{
|
||||
path.applyTransform (AffineTransform::scale (1.0f / helper->totalSize,
|
||||
1.0f / helper->totalSize));
|
||||
|
||||
addGlyph (character, path, width / helper->totalSize);
|
||||
|
||||
for (int i = 0; i < glyphs.size(); ++i)
|
||||
{
|
||||
const TypefaceGlyphInfo* const g = (const TypefaceGlyphInfo*) glyphs.getUnchecked(i);
|
||||
|
||||
float kerning;
|
||||
if (helper->getPathAndKerning (character, g->getCharacter(), 0, kerning, 0, 0))
|
||||
{
|
||||
kerning = (kerning - width) / helper->totalSize;
|
||||
|
||||
if (kerning != 0)
|
||||
addKerningPair (character, g->getCharacter(), kerning);
|
||||
}
|
||||
|
||||
if (helper->getPathAndKerning (g->getCharacter(), character, 0, kerning, 0, 0))
|
||||
{
|
||||
kerning = kerning / helper->totalSize - g->width;
|
||||
|
||||
if (kerning != 0)
|
||||
addKerningPair (g->getCharacter(), character, kerning);
|
||||
}
|
||||
}
|
||||
|
||||
foundOne = true;
|
||||
}
|
||||
|
||||
FontHelperCache::getInstance()->releaseFont (helper);
|
||||
return foundOne;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
const StringArray Font::findAllTypefaceNames() throw()
|
||||
{
|
||||
StringArray names;
|
||||
|
||||
const ScopedAutoReleasePool pool;
|
||||
NSArray* fonts = [[NSFontManager sharedFontManager] availableFontFamilies];
|
||||
|
||||
for (int i = 0; i < [fonts count]; ++i)
|
||||
names.add (nsStringToJuce ((NSString*) [fonts objectAtIndex: i]));
|
||||
|
||||
names.sort (true);
|
||||
return names;
|
||||
}
|
||||
|
||||
void Typeface::getDefaultFontNames (String& defaultSans, String& defaultSerif, String& defaultFixed) throw()
|
||||
{
|
||||
defaultSans = "Lucida Grande";
|
||||
defaultSerif = "Times New Roman";
|
||||
defaultFixed = "Monaco";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -246,4 +246,3 @@ void juce_updateMultiMonitorInfo (Array <Rectangle>& monitorCoords, const bool c
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,74 +1,74 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
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.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#ifndef __JUCE_MAC_NATIVEINCLUDES_JUCEHEADER__
|
||||
#define __JUCE_MAC_NATIVEINCLUDES_JUCEHEADER__
|
||||
|
||||
/*
|
||||
This file wraps together all the mac-specific code, so that
|
||||
we can include all the native headers just once, and compile all our
|
||||
platform-specific stuff in one big lump, keeping it out of the way of
|
||||
the rest of the codebase.
|
||||
*/
|
||||
|
||||
#include "../../../src/juce_core/basics/juce_StandardHeader.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <CoreAudio/HostTime.h>
|
||||
#import <CoreAudio/AudioHardware.h>
|
||||
#import <CoreMIDI/MIDIServices.h>
|
||||
#import <QTKit/QTKit.h>
|
||||
#import <WebKit/WebKit.h>
|
||||
#import <DiscRecording/DiscRecording.h>
|
||||
#import <IOKit/IOKitLib.h>
|
||||
#import <IOKit/IOCFPlugIn.h>
|
||||
#import <IOKit/hid/IOHIDLib.h>
|
||||
#import <IOKit/hid/IOHIDKeys.h>
|
||||
#import <IOKit/network/IOEthernetInterface.h>
|
||||
#import <IOKit/network/IONetworkInterface.h>
|
||||
#import <IOKit/network/IOEthernetController.h>
|
||||
#import <IOKit/pwr_mgt/IOPMLib.h>
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/dir.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <fnmatch.h>
|
||||
#include <utime.h>
|
||||
|
||||
#if MACOS_10_4_OR_EARLIER
|
||||
#include <GLUT/glut.h>
|
||||
typedef int NSInteger;
|
||||
typedef unsigned int NSUInteger;
|
||||
#endif
|
||||
|
||||
#endif // __JUCE_MAC_NATIVEINCLUDES_JUCEHEADER__
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
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.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#ifndef __JUCE_MAC_NATIVEINCLUDES_JUCEHEADER__
|
||||
#define __JUCE_MAC_NATIVEINCLUDES_JUCEHEADER__
|
||||
|
||||
/*
|
||||
This file wraps together all the mac-specific code, so that
|
||||
we can include all the native headers just once, and compile all our
|
||||
platform-specific stuff in one big lump, keeping it out of the way of
|
||||
the rest of the codebase.
|
||||
*/
|
||||
|
||||
#include "../../../src/juce_core/basics/juce_StandardHeader.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <CoreAudio/HostTime.h>
|
||||
#import <CoreAudio/AudioHardware.h>
|
||||
#import <CoreMIDI/MIDIServices.h>
|
||||
#import <QTKit/QTKit.h>
|
||||
#import <WebKit/WebKit.h>
|
||||
#import <DiscRecording/DiscRecording.h>
|
||||
#import <IOKit/IOKitLib.h>
|
||||
#import <IOKit/IOCFPlugIn.h>
|
||||
#import <IOKit/hid/IOHIDLib.h>
|
||||
#import <IOKit/hid/IOHIDKeys.h>
|
||||
#import <IOKit/network/IOEthernetInterface.h>
|
||||
#import <IOKit/network/IONetworkInterface.h>
|
||||
#import <IOKit/network/IOEthernetController.h>
|
||||
#import <IOKit/pwr_mgt/IOPMLib.h>
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/dir.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <fnmatch.h>
|
||||
#include <utime.h>
|
||||
|
||||
#if MACOS_10_4_OR_EARLIER
|
||||
#include <GLUT/glut.h>
|
||||
typedef int NSInteger;
|
||||
typedef unsigned int NSUInteger;
|
||||
#endif
|
||||
|
||||
#endif // __JUCE_MAC_NATIVEINCLUDES_JUCEHEADER__
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ END_JUCE_NAMESPACE
|
|||
//==============================================================================
|
||||
@interface ThreadSafeNSOpenGLView : NSOpenGLView
|
||||
{
|
||||
CriticalSection* contextLock;
|
||||
CriticalSection* contextLock;
|
||||
bool needsUpdate;
|
||||
}
|
||||
|
||||
|
|
@ -50,14 +50,14 @@ END_JUCE_NAMESPACE
|
|||
|
||||
@implementation ThreadSafeNSOpenGLView
|
||||
|
||||
- (id) initWithFrame: (NSRect) frameRect
|
||||
- (id) initWithFrame: (NSRect) frameRect
|
||||
pixelFormat: (NSOpenGLPixelFormat*) format
|
||||
{
|
||||
contextLock = new CriticalSection();
|
||||
self = [super initWithFrame: frameRect pixelFormat: format];
|
||||
|
||||
|
||||
if (self != nil)
|
||||
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||
selector: @selector (_surfaceNeedsUpdate:)
|
||||
name: NSViewGlobalFrameDidChangeNotification
|
||||
object: self];
|
||||
|
|
@ -74,7 +74,7 @@ END_JUCE_NAMESPACE
|
|||
- (bool) makeActive
|
||||
{
|
||||
const ScopedLock sl (*contextLock);
|
||||
|
||||
|
||||
if ([self openGLContext] == 0)
|
||||
return false;
|
||||
|
||||
|
|
@ -244,7 +244,7 @@ public:
|
|||
juce_UseDebuggingNewOperator
|
||||
|
||||
NSOpenGLContext* renderContext;
|
||||
ThreadSafeNSOpenGLView* view;
|
||||
ThreadSafeNSOpenGLView* view;
|
||||
|
||||
private:
|
||||
OpenGLPixelFormat pixelFormat;
|
||||
|
|
|
|||
|
|
@ -7999,3 +7999,4 @@ static const unsigned char temp17[] = {47,42,13,10,32,32,61,61,61,61,61,61,61,61
|
|||
111,109,109,97,110,100,77,97,110,97,103,101,114,41,13,10,123,13,10,32,32,32,32,114,101,116,117,114,110,32,110,101,119,32,87,105,100,103,101,116,
|
||||
115,68,101,109,111,32,40,99,111,109,109,97,110,100,77,97,110,97,103,101,114,41,59,13,10,125,13,10,0,0};
|
||||
const char* BinaryData::widgetsdemo_cpp = (const char*) temp17;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
844B0A9B0F52DC6000B2F1FD /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 844B0A9A0F52DC6000B2F1FD /* Carbon.framework */; };
|
||||
846929140A49DB9C00314975 /* juce.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 846929130A49DB9C00314975 /* juce.xcconfig */; };
|
||||
846C10D40DE33F4D00E8CCE8 /* juce_LibrarySource.mm in Sources */ = {isa = PBXBuildFile; fileRef = 846C10D30DE33F4D00E8CCE8 /* juce_LibrarySource.mm */; };
|
||||
846C10EA0DE33FA100E8CCE8 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 846C10DC0DE33FA100E8CCE8 /* ApplicationServices.framework */; };
|
||||
|
|
@ -60,6 +61,7 @@
|
|||
|
||||
/* Begin PBXFileReference section */
|
||||
0867D6ABFE840B52C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
844B0A9A0F52DC6000B2F1FD /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
|
||||
846929130A49DB9C00314975 /* juce.xcconfig */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xcconfig; name = juce.xcconfig; path = ../../../../build/macosx/juce.xcconfig; sourceTree = SOURCE_ROOT; };
|
||||
846C10D20DE33F4D00E8CCE8 /* juce_AppConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = juce_AppConfig.h; path = ../../src/juce_AppConfig.h; sourceTree = SOURCE_ROOT; };
|
||||
846C10D30DE33F4D00E8CCE8 /* juce_LibrarySource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = juce_LibrarySource.mm; path = ../../src/juce_LibrarySource.mm; sourceTree = SOURCE_ROOT; };
|
||||
|
|
@ -200,6 +202,7 @@
|
|||
846C10F60DE33FA100E8CCE8 /* WebKit.framework in Frameworks */,
|
||||
84E01DD90E910B7B003E41AF /* QTKit.framework in Frameworks */,
|
||||
84F8B68E0EB5FB290020D98D /* QuickTime.framework in Frameworks */,
|
||||
844B0A9B0F52DC6000B2F1FD /* Carbon.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
@ -258,6 +261,7 @@
|
|||
20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
844B0A9A0F52DC6000B2F1FD /* Carbon.framework */,
|
||||
846C10DC0DE33FA100E8CCE8 /* ApplicationServices.framework */,
|
||||
846C10DF0DE33FA100E8CCE8 /* Cocoa.framework */,
|
||||
846C10E10DE33FA100E8CCE8 /* CoreFoundation.framework */,
|
||||
|
|
|
|||
|
|
@ -911,3 +911,4 @@ static const unsigned char temp4[] = {137,80,78,71,13,10,26,10,0,0,0,13,73,72,68
|
|||
0,98,28,9,155,95,0,2,104,68,236,11,1,8,160,17,225,73,128,0,3,0,120,52,172,151,198,78,252,63,0,0,0,0,73,69,78,68,174,66,
|
||||
96,130,0,0};
|
||||
const char* BinaryData::prefs_misc_png = (const char*) temp4;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
#ifndef __JUCE_JUCE_APP_INCLUDES_INCLUDEFILES__
|
||||
#define __JUCE_JUCE_APP_INCLUDES_INCLUDEFILES__
|
||||
#ifndef __JUCE_APP_INCLUDES_JUCEHEADER__
|
||||
#define __JUCE_APP_INCLUDES_JUCEHEADER__
|
||||
|
||||
#ifndef __JUCE_APPLICATION_JUCEHEADER__
|
||||
#include "juce_appframework/application/juce_Application.h"
|
||||
|
|
@ -744,4 +744,4 @@
|
|||
#include "juce_appframework/documents/juce_UndoManager.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif // __JUCE_APP_INCLUDES_JUCEHEADER__
|
||||
|
|
|
|||
|
|
@ -1,242 +1,242 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
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_core/basics/juce_StandardHeader.h"
|
||||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
#include "juce_ImageButton.h"
|
||||
#include "../../graphics/imaging/juce_ImageCache.h"
|
||||
#include "../lookandfeel/juce_LookAndFeel.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
ImageButton::ImageButton (const String& text)
|
||||
: Button (text),
|
||||
scaleImageToFit (true),
|
||||
preserveProportions (true),
|
||||
alphaThreshold (0),
|
||||
imageX (0),
|
||||
imageY (0),
|
||||
imageW (0),
|
||||
imageH (0),
|
||||
normalImage (0),
|
||||
overImage (0),
|
||||
downImage (0)
|
||||
{
|
||||
}
|
||||
|
||||
ImageButton::~ImageButton()
|
||||
{
|
||||
deleteImages();
|
||||
}
|
||||
|
||||
void ImageButton::deleteImages()
|
||||
{
|
||||
if (normalImage != 0)
|
||||
{
|
||||
if (ImageCache::isImageInCache (normalImage))
|
||||
ImageCache::release (normalImage);
|
||||
else
|
||||
delete normalImage;
|
||||
}
|
||||
|
||||
if (overImage != 0)
|
||||
{
|
||||
if (ImageCache::isImageInCache (overImage))
|
||||
ImageCache::release (overImage);
|
||||
else
|
||||
delete overImage;
|
||||
}
|
||||
|
||||
if (downImage != 0)
|
||||
{
|
||||
if (ImageCache::isImageInCache (downImage))
|
||||
ImageCache::release (downImage);
|
||||
else
|
||||
delete downImage;
|
||||
}
|
||||
}
|
||||
|
||||
void ImageButton::setImages (const bool resizeButtonNowToFitThisImage,
|
||||
const bool rescaleImagesWhenButtonSizeChanges,
|
||||
const bool preserveImageProportions,
|
||||
Image* const normalImage_,
|
||||
const float imageOpacityWhenNormal,
|
||||
const Colour& overlayColourWhenNormal,
|
||||
Image* const overImage_,
|
||||
const float imageOpacityWhenOver,
|
||||
const Colour& overlayColourWhenOver,
|
||||
Image* const downImage_,
|
||||
const float imageOpacityWhenDown,
|
||||
const Colour& overlayColourWhenDown,
|
||||
const float hitTestAlphaThreshold)
|
||||
{
|
||||
deleteImages();
|
||||
|
||||
normalImage = normalImage_;
|
||||
overImage = overImage_;
|
||||
downImage = downImage_;
|
||||
|
||||
if (resizeButtonNowToFitThisImage && normalImage != 0)
|
||||
{
|
||||
imageW = normalImage->getWidth();
|
||||
imageH = normalImage->getHeight();
|
||||
|
||||
setSize (imageW, imageH);
|
||||
}
|
||||
|
||||
scaleImageToFit = rescaleImagesWhenButtonSizeChanges;
|
||||
preserveProportions = preserveImageProportions;
|
||||
|
||||
normalOpacity = imageOpacityWhenNormal;
|
||||
normalOverlay = overlayColourWhenNormal;
|
||||
overOpacity = imageOpacityWhenOver;
|
||||
overOverlay = overlayColourWhenOver;
|
||||
downOpacity = imageOpacityWhenDown;
|
||||
downOverlay = overlayColourWhenDown;
|
||||
|
||||
alphaThreshold = (unsigned char) jlimit (0, 0xff, roundFloatToInt (255.0f * hitTestAlphaThreshold));
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
Image* ImageButton::getCurrentImage() const
|
||||
{
|
||||
if (isDown() || getToggleState())
|
||||
return getDownImage();
|
||||
|
||||
if (isOver())
|
||||
return getOverImage();
|
||||
|
||||
return getNormalImage();
|
||||
}
|
||||
|
||||
Image* ImageButton::getNormalImage() const throw()
|
||||
{
|
||||
return normalImage;
|
||||
}
|
||||
|
||||
Image* ImageButton::getOverImage() const throw()
|
||||
{
|
||||
return (overImage != 0) ? overImage
|
||||
: normalImage;
|
||||
}
|
||||
|
||||
Image* ImageButton::getDownImage() const throw()
|
||||
{
|
||||
return (downImage != 0) ? downImage
|
||||
: getOverImage();
|
||||
}
|
||||
|
||||
void ImageButton::paintButton (Graphics& g,
|
||||
bool isMouseOverButton,
|
||||
bool isButtonDown)
|
||||
{
|
||||
if (! isEnabled())
|
||||
{
|
||||
isMouseOverButton = false;
|
||||
isButtonDown = false;
|
||||
}
|
||||
|
||||
Image* const im = getCurrentImage();
|
||||
|
||||
if (im != 0)
|
||||
{
|
||||
const int iw = im->getWidth();
|
||||
const int ih = im->getHeight();
|
||||
imageW = getWidth();
|
||||
imageH = getHeight();
|
||||
imageX = (imageW - iw) >> 1;
|
||||
imageY = (imageH - ih) >> 1;
|
||||
|
||||
if (scaleImageToFit)
|
||||
{
|
||||
if (preserveProportions)
|
||||
{
|
||||
int newW, newH;
|
||||
const float imRatio = ih / (float)iw;
|
||||
const float destRatio = imageH / (float)imageW;
|
||||
|
||||
if (imRatio > destRatio)
|
||||
{
|
||||
newW = roundFloatToInt (imageH / imRatio);
|
||||
newH = imageH;
|
||||
}
|
||||
else
|
||||
{
|
||||
newW = imageW;
|
||||
newH = roundFloatToInt (imageW * imRatio);
|
||||
}
|
||||
|
||||
imageX = (imageW - newW) / 2;
|
||||
imageY = (imageH - newH) / 2;
|
||||
imageW = newW;
|
||||
imageH = newH;
|
||||
}
|
||||
else
|
||||
{
|
||||
imageX = 0;
|
||||
imageY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (! scaleImageToFit)
|
||||
{
|
||||
imageW = iw;
|
||||
imageH = ih;
|
||||
}
|
||||
|
||||
getLookAndFeel().drawImageButton (g, im, imageX, imageY, imageW, imageH,
|
||||
isButtonDown ? downOverlay
|
||||
: (isMouseOverButton ? overOverlay
|
||||
: normalOverlay),
|
||||
isButtonDown ? downOpacity
|
||||
: (isMouseOverButton ? overOpacity
|
||||
: normalOpacity),
|
||||
*this);
|
||||
}
|
||||
}
|
||||
|
||||
bool ImageButton::hitTest (int x, int y)
|
||||
{
|
||||
if (alphaThreshold == 0)
|
||||
return true;
|
||||
|
||||
Image* const im = getCurrentImage();
|
||||
|
||||
return im == 0
|
||||
|| (imageW > 0 && imageH > 0
|
||||
&& alphaThreshold < im->getPixelAt (((x - imageX) * im->getWidth()) / imageW,
|
||||
((y - imageY) * im->getHeight()) / imageH).getAlpha());
|
||||
}
|
||||
|
||||
END_JUCE_NAMESPACE
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
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_core/basics/juce_StandardHeader.h"
|
||||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
#include "juce_ImageButton.h"
|
||||
#include "../../graphics/imaging/juce_ImageCache.h"
|
||||
#include "../lookandfeel/juce_LookAndFeel.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
ImageButton::ImageButton (const String& text)
|
||||
: Button (text),
|
||||
scaleImageToFit (true),
|
||||
preserveProportions (true),
|
||||
alphaThreshold (0),
|
||||
imageX (0),
|
||||
imageY (0),
|
||||
imageW (0),
|
||||
imageH (0),
|
||||
normalImage (0),
|
||||
overImage (0),
|
||||
downImage (0)
|
||||
{
|
||||
}
|
||||
|
||||
ImageButton::~ImageButton()
|
||||
{
|
||||
deleteImages();
|
||||
}
|
||||
|
||||
void ImageButton::deleteImages()
|
||||
{
|
||||
if (normalImage != 0)
|
||||
{
|
||||
if (ImageCache::isImageInCache (normalImage))
|
||||
ImageCache::release (normalImage);
|
||||
else
|
||||
delete normalImage;
|
||||
}
|
||||
|
||||
if (overImage != 0)
|
||||
{
|
||||
if (ImageCache::isImageInCache (overImage))
|
||||
ImageCache::release (overImage);
|
||||
else
|
||||
delete overImage;
|
||||
}
|
||||
|
||||
if (downImage != 0)
|
||||
{
|
||||
if (ImageCache::isImageInCache (downImage))
|
||||
ImageCache::release (downImage);
|
||||
else
|
||||
delete downImage;
|
||||
}
|
||||
}
|
||||
|
||||
void ImageButton::setImages (const bool resizeButtonNowToFitThisImage,
|
||||
const bool rescaleImagesWhenButtonSizeChanges,
|
||||
const bool preserveImageProportions,
|
||||
Image* const normalImage_,
|
||||
const float imageOpacityWhenNormal,
|
||||
const Colour& overlayColourWhenNormal,
|
||||
Image* const overImage_,
|
||||
const float imageOpacityWhenOver,
|
||||
const Colour& overlayColourWhenOver,
|
||||
Image* const downImage_,
|
||||
const float imageOpacityWhenDown,
|
||||
const Colour& overlayColourWhenDown,
|
||||
const float hitTestAlphaThreshold)
|
||||
{
|
||||
deleteImages();
|
||||
|
||||
normalImage = normalImage_;
|
||||
overImage = overImage_;
|
||||
downImage = downImage_;
|
||||
|
||||
if (resizeButtonNowToFitThisImage && normalImage != 0)
|
||||
{
|
||||
imageW = normalImage->getWidth();
|
||||
imageH = normalImage->getHeight();
|
||||
|
||||
setSize (imageW, imageH);
|
||||
}
|
||||
|
||||
scaleImageToFit = rescaleImagesWhenButtonSizeChanges;
|
||||
preserveProportions = preserveImageProportions;
|
||||
|
||||
normalOpacity = imageOpacityWhenNormal;
|
||||
normalOverlay = overlayColourWhenNormal;
|
||||
overOpacity = imageOpacityWhenOver;
|
||||
overOverlay = overlayColourWhenOver;
|
||||
downOpacity = imageOpacityWhenDown;
|
||||
downOverlay = overlayColourWhenDown;
|
||||
|
||||
alphaThreshold = (unsigned char) jlimit (0, 0xff, roundFloatToInt (255.0f * hitTestAlphaThreshold));
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
Image* ImageButton::getCurrentImage() const
|
||||
{
|
||||
if (isDown() || getToggleState())
|
||||
return getDownImage();
|
||||
|
||||
if (isOver())
|
||||
return getOverImage();
|
||||
|
||||
return getNormalImage();
|
||||
}
|
||||
|
||||
Image* ImageButton::getNormalImage() const throw()
|
||||
{
|
||||
return normalImage;
|
||||
}
|
||||
|
||||
Image* ImageButton::getOverImage() const throw()
|
||||
{
|
||||
return (overImage != 0) ? overImage
|
||||
: normalImage;
|
||||
}
|
||||
|
||||
Image* ImageButton::getDownImage() const throw()
|
||||
{
|
||||
return (downImage != 0) ? downImage
|
||||
: getOverImage();
|
||||
}
|
||||
|
||||
void ImageButton::paintButton (Graphics& g,
|
||||
bool isMouseOverButton,
|
||||
bool isButtonDown)
|
||||
{
|
||||
if (! isEnabled())
|
||||
{
|
||||
isMouseOverButton = false;
|
||||
isButtonDown = false;
|
||||
}
|
||||
|
||||
Image* const im = getCurrentImage();
|
||||
|
||||
if (im != 0)
|
||||
{
|
||||
const int iw = im->getWidth();
|
||||
const int ih = im->getHeight();
|
||||
imageW = getWidth();
|
||||
imageH = getHeight();
|
||||
imageX = (imageW - iw) >> 1;
|
||||
imageY = (imageH - ih) >> 1;
|
||||
|
||||
if (scaleImageToFit)
|
||||
{
|
||||
if (preserveProportions)
|
||||
{
|
||||
int newW, newH;
|
||||
const float imRatio = ih / (float)iw;
|
||||
const float destRatio = imageH / (float)imageW;
|
||||
|
||||
if (imRatio > destRatio)
|
||||
{
|
||||
newW = roundFloatToInt (imageH / imRatio);
|
||||
newH = imageH;
|
||||
}
|
||||
else
|
||||
{
|
||||
newW = imageW;
|
||||
newH = roundFloatToInt (imageW * imRatio);
|
||||
}
|
||||
|
||||
imageX = (imageW - newW) / 2;
|
||||
imageY = (imageH - newH) / 2;
|
||||
imageW = newW;
|
||||
imageH = newH;
|
||||
}
|
||||
else
|
||||
{
|
||||
imageX = 0;
|
||||
imageY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (! scaleImageToFit)
|
||||
{
|
||||
imageW = iw;
|
||||
imageH = ih;
|
||||
}
|
||||
|
||||
getLookAndFeel().drawImageButton (g, im, imageX, imageY, imageW, imageH,
|
||||
isButtonDown ? downOverlay
|
||||
: (isMouseOverButton ? overOverlay
|
||||
: normalOverlay),
|
||||
isButtonDown ? downOpacity
|
||||
: (isMouseOverButton ? overOpacity
|
||||
: normalOpacity),
|
||||
*this);
|
||||
}
|
||||
}
|
||||
|
||||
bool ImageButton::hitTest (int x, int y)
|
||||
{
|
||||
if (alphaThreshold == 0)
|
||||
return true;
|
||||
|
||||
Image* const im = getCurrentImage();
|
||||
|
||||
return im == 0
|
||||
|| (imageW > 0 && imageH > 0
|
||||
&& alphaThreshold < im->getPixelAt (((x - imageX) * im->getWidth()) / imageW,
|
||||
((y - imageY) * im->getHeight()) / imageH).getAlpha());
|
||||
}
|
||||
|
||||
END_JUCE_NAMESPACE
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1158,7 +1158,7 @@ void TreeViewItem::paintRecursively (Graphics& g, int width)
|
|||
g.saveState();
|
||||
g.setOrigin (indent, 0);
|
||||
|
||||
if (g.reduceClipRegion (drawsInLeftMargin ? -indent : 0, 0,
|
||||
if (g.reduceClipRegion (drawsInLeftMargin ? -indent : 0, 0,
|
||||
drawsInLeftMargin ? itemW + indent : itemW, itemHeight))
|
||||
paintItem (g, itemW, itemHeight);
|
||||
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ public:
|
|||
can draw all the way across to the left margin. Note that the
|
||||
context will still have its origin in the same place though, so
|
||||
the coordinates of anything to its left will be negative. It's
|
||||
mostly useful if you want to draw a wider bar behind the
|
||||
mostly useful if you want to draw a wider bar behind the
|
||||
highlighted item.
|
||||
*/
|
||||
void setDrawsInLeftMargin (bool canDrawInLeftMargin) throw();
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ public:
|
|||
allowed to pop up when the mouse moves onto them. If this is false, it'll try
|
||||
to hide as much on-screen paraphenalia as possible.
|
||||
*/
|
||||
void setKioskModeComponent (Component* componentToUse,
|
||||
void setKioskModeComponent (Component* componentToUse,
|
||||
const bool allowMenusAndBars = true);
|
||||
|
||||
/** Returns the component that is currently being used in kiosk-mode.
|
||||
|
|
|
|||
|
|
@ -189,9 +189,9 @@ void ComponentBoundsConstrainer::setBoundsForComponent (Component* const compone
|
|||
|
||||
void ComponentBoundsConstrainer::checkComponentBounds (Component* component)
|
||||
{
|
||||
setBoundsForComponent (component,
|
||||
setBoundsForComponent (component,
|
||||
component->getX(), component->getY(),
|
||||
component->getWidth(), component->getHeight(),
|
||||
component->getWidth(), component->getHeight(),
|
||||
false, false, false, false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ public:
|
|||
const bool isStretchingBottom,
|
||||
const bool isStretchingRight);
|
||||
|
||||
/** Performs a check on the current size of a component, and moves or resizes
|
||||
/** Performs a check on the current size of a component, and moves or resizes
|
||||
it if it fails the constraints.
|
||||
*/
|
||||
void checkComponentBounds (Component* component);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,158 +1,158 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
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 "../basics/juce_StandardHeader.h"
|
||||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_StringPairArray.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
StringPairArray::StringPairArray (const bool ignoreCase_) throw()
|
||||
: ignoreCase (ignoreCase_)
|
||||
{
|
||||
}
|
||||
|
||||
StringPairArray::StringPairArray (const StringPairArray& other) throw()
|
||||
: keys (other.keys),
|
||||
values (other.values),
|
||||
ignoreCase (other.ignoreCase)
|
||||
{
|
||||
}
|
||||
|
||||
StringPairArray::~StringPairArray() throw()
|
||||
{
|
||||
}
|
||||
|
||||
const StringPairArray& StringPairArray::operator= (const StringPairArray& other) throw()
|
||||
{
|
||||
keys = other.keys;
|
||||
values = other.values;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool StringPairArray::operator== (const StringPairArray& other) const throw()
|
||||
{
|
||||
for (int i = keys.size(); --i >= 0;)
|
||||
if (other [keys[i]] != values[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StringPairArray::operator!= (const StringPairArray& other) const throw()
|
||||
{
|
||||
return ! operator== (other);
|
||||
}
|
||||
|
||||
const String& StringPairArray::operator[] (const String& key) const throw()
|
||||
{
|
||||
return values [keys.indexOf (key, ignoreCase)];
|
||||
}
|
||||
|
||||
const String StringPairArray::getValue (const String& key, const String& defaultReturnValue) const
|
||||
{
|
||||
const int i = keys.indexOf (key, ignoreCase);
|
||||
|
||||
if (i >= 0)
|
||||
return values[i];
|
||||
|
||||
return defaultReturnValue;
|
||||
}
|
||||
|
||||
void StringPairArray::set (const String& key,
|
||||
const String& value) throw()
|
||||
{
|
||||
const int i = keys.indexOf (key, ignoreCase);
|
||||
|
||||
if (i >= 0)
|
||||
{
|
||||
values.set (i, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
keys.add (key);
|
||||
values.add (value);
|
||||
}
|
||||
}
|
||||
|
||||
void StringPairArray::addArray (const StringPairArray& other)
|
||||
{
|
||||
for (int i = 0; i < other.size(); ++i)
|
||||
set (other.keys[i], other.values[i]);
|
||||
}
|
||||
|
||||
void StringPairArray::clear() throw()
|
||||
{
|
||||
keys.clear();
|
||||
values.clear();
|
||||
}
|
||||
|
||||
void StringPairArray::remove (const String& key) throw()
|
||||
{
|
||||
remove (keys.indexOf (key, ignoreCase));
|
||||
}
|
||||
|
||||
void StringPairArray::remove (const int index) throw()
|
||||
{
|
||||
keys.remove (index);
|
||||
values.remove (index);
|
||||
}
|
||||
|
||||
void StringPairArray::setIgnoresCase (const bool shouldIgnoreCase) throw()
|
||||
{
|
||||
ignoreCase = shouldIgnoreCase;
|
||||
}
|
||||
|
||||
const String StringPairArray::getDescription() const
|
||||
{
|
||||
String s;
|
||||
|
||||
for (int i = 0; i < keys.size(); ++i)
|
||||
{
|
||||
s << keys[i] << T(" = ") << values[i];
|
||||
if (i < keys.size())
|
||||
s << T(", ");
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void StringPairArray::minimiseStorageOverheads() throw()
|
||||
{
|
||||
keys.minimiseStorageOverheads();
|
||||
values.minimiseStorageOverheads();
|
||||
}
|
||||
|
||||
END_JUCE_NAMESPACE
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
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 "../basics/juce_StandardHeader.h"
|
||||
|
||||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
|
||||
#include "juce_StringPairArray.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
StringPairArray::StringPairArray (const bool ignoreCase_) throw()
|
||||
: ignoreCase (ignoreCase_)
|
||||
{
|
||||
}
|
||||
|
||||
StringPairArray::StringPairArray (const StringPairArray& other) throw()
|
||||
: keys (other.keys),
|
||||
values (other.values),
|
||||
ignoreCase (other.ignoreCase)
|
||||
{
|
||||
}
|
||||
|
||||
StringPairArray::~StringPairArray() throw()
|
||||
{
|
||||
}
|
||||
|
||||
const StringPairArray& StringPairArray::operator= (const StringPairArray& other) throw()
|
||||
{
|
||||
keys = other.keys;
|
||||
values = other.values;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool StringPairArray::operator== (const StringPairArray& other) const throw()
|
||||
{
|
||||
for (int i = keys.size(); --i >= 0;)
|
||||
if (other [keys[i]] != values[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StringPairArray::operator!= (const StringPairArray& other) const throw()
|
||||
{
|
||||
return ! operator== (other);
|
||||
}
|
||||
|
||||
const String& StringPairArray::operator[] (const String& key) const throw()
|
||||
{
|
||||
return values [keys.indexOf (key, ignoreCase)];
|
||||
}
|
||||
|
||||
const String StringPairArray::getValue (const String& key, const String& defaultReturnValue) const
|
||||
{
|
||||
const int i = keys.indexOf (key, ignoreCase);
|
||||
|
||||
if (i >= 0)
|
||||
return values[i];
|
||||
|
||||
return defaultReturnValue;
|
||||
}
|
||||
|
||||
void StringPairArray::set (const String& key,
|
||||
const String& value) throw()
|
||||
{
|
||||
const int i = keys.indexOf (key, ignoreCase);
|
||||
|
||||
if (i >= 0)
|
||||
{
|
||||
values.set (i, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
keys.add (key);
|
||||
values.add (value);
|
||||
}
|
||||
}
|
||||
|
||||
void StringPairArray::addArray (const StringPairArray& other)
|
||||
{
|
||||
for (int i = 0; i < other.size(); ++i)
|
||||
set (other.keys[i], other.values[i]);
|
||||
}
|
||||
|
||||
void StringPairArray::clear() throw()
|
||||
{
|
||||
keys.clear();
|
||||
values.clear();
|
||||
}
|
||||
|
||||
void StringPairArray::remove (const String& key) throw()
|
||||
{
|
||||
remove (keys.indexOf (key, ignoreCase));
|
||||
}
|
||||
|
||||
void StringPairArray::remove (const int index) throw()
|
||||
{
|
||||
keys.remove (index);
|
||||
values.remove (index);
|
||||
}
|
||||
|
||||
void StringPairArray::setIgnoresCase (const bool shouldIgnoreCase) throw()
|
||||
{
|
||||
ignoreCase = shouldIgnoreCase;
|
||||
}
|
||||
|
||||
const String StringPairArray::getDescription() const
|
||||
{
|
||||
String s;
|
||||
|
||||
for (int i = 0; i < keys.size(); ++i)
|
||||
{
|
||||
s << keys[i] << T(" = ") << values[i];
|
||||
if (i < keys.size())
|
||||
s << T(", ");
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void StringPairArray::minimiseStorageOverheads() throw()
|
||||
{
|
||||
keys.minimiseStorageOverheads();
|
||||
values.minimiseStorageOverheads();
|
||||
}
|
||||
|
||||
END_JUCE_NAMESPACE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue