1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-31 03:00:05 +00:00

Removed the (rather pointless) granularity value from the array objects. Converted a few macros into functions and other misc code clean-ups.

This commit is contained in:
Julian Storer 2010-01-13 18:58:40 +00:00
parent c368805559
commit 97035bb3a1
69 changed files with 218 additions and 369 deletions

View file

@ -36,10 +36,8 @@ BEGIN_JUCE_NAMESPACE
//==============================================================================
Button::Button (const String& name)
: Component (name),
shortcuts (2),
keySource (0),
text (name),
buttonListeners (2),
buttonPressTime (0),
lastTimeCallbackTime (0),
commandManagerToUse (0),

View file

@ -38,7 +38,6 @@ Label::Label (const String& componentName,
text (labelText),
font (15.0f),
justification (Justification::centredLeft),
listeners (2),
ownerComponent (0),
horizontalBorderSize (3),
verticalBorderSize (1),

View file

@ -91,7 +91,6 @@ private:
//==============================================================================
Slider::Slider (const String& name)
: Component (name),
listeners (2),
lastCurrentValue (0),
lastValueMin (0),
lastValueMax (0),

View file

@ -64,8 +64,7 @@ private:
//==============================================================================
TableHeaderComponent::TableHeaderComponent()
: listeners (2),
columnsChanged (false),
: columnsChanged (false),
columnsResized (false),
sortChanged (false),
menuActive (true),

View file

@ -79,17 +79,17 @@ public:
const Colour& colour_,
const tchar passwordCharacter)
: font (font_),
colour (colour_),
atoms (64)
colour (colour_)
{
initialiseAtoms (text, passwordCharacter);
}
UniformTextSection (const UniformTextSection& other)
: font (other.font),
colour (other.colour),
atoms (64)
colour (other.colour)
{
atoms.ensureStorageAllocated (other.atoms.size());
for (int i = 0; i < other.atoms.size(); ++i)
atoms.add (new TextAtom (*(const TextAtom*) other.atoms.getUnchecked(i)));
}
@ -141,6 +141,8 @@ public:
}
}
atoms.ensureStorageAllocated (atoms.size() + other.atoms.size() - i);
while (i < other.atoms.size())
{
atoms.add (other.getAtom(i));
@ -990,10 +992,8 @@ TextEditor::TextEditor (const String& name,
currentFont (14.0f),
totalNumChars (0),
caretPosition (0),
sections (8),
passwordCharacter (passwordCharacter_),
dragType (notDragging),
listeners (2)
dragType (notDragging)
{
setOpaque (true);

View file

@ -1086,7 +1086,6 @@ enum TreeViewOpenness
TreeViewItem::TreeViewItem()
: ownerView (0),
parentItem (0),
subItems (8),
y (0),
itemHeight (0),
totalHeight (0),

View file

@ -33,8 +33,7 @@ BEGIN_JUCE_NAMESPACE
//==============================================================================
DirectoryContentsDisplayComponent::DirectoryContentsDisplayComponent (DirectoryContentsList& listToShow)
: fileList (listToShow),
listeners (2)
: fileList (listToShow)
{
}

View file

@ -44,7 +44,6 @@ FileBrowserComponent::FileBrowserComponent (int flags_,
: FileFilter (String::empty),
fileFilter (fileFilter_),
flags (flags_),
listeners (2),
previewComp (previewComp_),
thread ("Juce FileBrowser")
{

View file

@ -46,8 +46,8 @@ BEGIN_JUCE_NAMESPACE
Component* Component::componentUnderMouse = 0;
Component* Component::currentlyFocusedComponent = 0;
static Array <Component*> modalComponentStack (4), modalComponentReturnValueKeys (4);
static Array <int> modalReturnValues (4);
static Array <Component*> modalComponentStack, modalComponentReturnValueKeys;
static Array <int> modalReturnValues;
static const int customCommandMessage = 0x7fff0001;
static const int exitModalStateMessage = 0x7fff0002;
@ -108,7 +108,6 @@ Component::Component() throw()
: parentComponent_ (0),
componentUID (++nextComponentUID),
numDeepMouseListeners (0),
childComponentList_ (16),
lookAndFeel_ (0),
effect_ (0),
bufferedImage_ (0),
@ -125,7 +124,6 @@ Component::Component (const String& name) throw()
parentComponent_ (0),
componentUID (++nextComponentUID),
numDeepMouseListeners (0),
childComponentList_ (16),
lookAndFeel_ (0),
effect_ (0),
bufferedImage_ (0),
@ -2163,7 +2161,7 @@ void Component::parentSizeChanged()
void Component::addComponentListener (ComponentListener* const newListener) throw()
{
if (componentListeners_ == 0)
componentListeners_ = new VoidArray (4);
componentListeners_ = new VoidArray();
componentListeners_->addIfNotAlreadyThere (newListener);
}
@ -2243,7 +2241,7 @@ void Component::addMouseListener (MouseListener* const newListener,
checkMessageManagerIsLocked
if (mouseListeners_ == 0)
mouseListeners_ = new VoidArray (4);
mouseListeners_ = new VoidArray();
if (! mouseListeners_->contains (newListener))
{
@ -3509,7 +3507,7 @@ const Rectangle Component::getParentMonitorArea() const throw()
void Component::addKeyListener (KeyListener* const newListener) throw()
{
if (keyListeners_ == 0)
keyListeners_ = new VoidArray (4);
keyListeners_ = new VoidArray();
keyListeners_->addIfNotAlreadyThere (newListener);
}

View file

@ -40,11 +40,7 @@ extern void juce_updateMultiMonitorInfo (Array <Rectangle>& monitorCoords,
static Desktop* juce_desktopInstance = 0;
Desktop::Desktop() throw()
: mouseListeners (2),
desktopComponents (4),
monitorCoordsClipped (2),
monitorCoordsUnclipped (2),
lastMouseX (0),
: lastMouseX (0),
lastMouseY (0),
kioskModeComponent (0)
{

View file

@ -34,7 +34,6 @@ BEGIN_JUCE_NAMESPACE
ComponentMovementWatcher::ComponentMovementWatcher (Component* const component_)
: component (component_),
lastPeer (0),
registeredParentComps (4),
reentrant (false)
{
jassert (component != 0); // can't use this with a null pointer..

View file

@ -98,8 +98,7 @@ ScrollBar::ScrollBar (const bool vertical_,
isDraggingThumb (false),
alwaysVisible (false),
upButton (0),
downButton (0),
listeners (2)
downButton (0)
{
setButtonVisibility (buttonsAreVisible);

View file

@ -1281,15 +1281,13 @@ private:
//==============================================================================
PopupMenu::PopupMenu()
: items (8),
lookAndFeel (0),
: lookAndFeel (0),
separatorPending (false)
{
}
PopupMenu::PopupMenu (const PopupMenu& other)
: items (8),
lookAndFeel (other.lookAndFeel),
: lookAndFeel (other.lookAndFeel),
separatorPending (false)
{
items.ensureStorageAllocated (other.items.size());

View file

@ -40,7 +40,7 @@ void juce_deleteMouseCursor (void* const cursorHandle, const bool isStandard) th
//==============================================================================
static CriticalSection activeCursorListLock;
static VoidArray activeCursors (2);
static VoidArray activeCursors;
//==============================================================================
class SharedMouseCursorInternal : public ReferenceCountedObject

View file

@ -674,6 +674,7 @@ private:
return y;
}
public:
//==============================================================================
class ChannelSelectorListBox : public ListBox,
public ListBoxModel
@ -930,6 +931,7 @@ private:
const ChannelSelectorListBox& operator= (const ChannelSelectorListBox&);
};
private:
ChannelSelectorListBox* inputChanList;
ChannelSelectorListBox* outputChanList;

View file

@ -95,8 +95,6 @@ MidiKeyboardComponent::MidiKeyboardComponent (MidiKeyboardState& state_,
canScroll (true),
mouseDragging (false),
useMousePositionForVelocity (true),
keyPresses (4),
keyPressNotes (16),
keyMappingOctave (6),
octaveNumForMiddleC (3)
{

View file

@ -53,7 +53,7 @@ extern bool juce_MouseHasMovedSignificantlySincePressed;
static const int fakeMouseMoveMessage = 0x7fff00ff;
static VoidArray heavyweightPeers (4);
static VoidArray heavyweightPeers;
//==============================================================================

View file

@ -45,8 +45,7 @@ class TopLevelWindowManager : public Timer,
public:
//==============================================================================
TopLevelWindowManager()
: windows (8),
currentActive (0)
: currentActive (0)
{
}

View file

@ -32,7 +32,6 @@ BEGIN_JUCE_NAMESPACE
//==============================================================================
ColourGradient::ColourGradient() throw()
: colours (4)
{
#ifdef JUCE_DEBUG
x1 = 987654.0f;
@ -50,8 +49,7 @@ ColourGradient::ColourGradient (const Colour& colour1,
y1 (y1_),
x2 (x2_),
y2 (y2_),
isRadial (isRadial_),
colours (4)
isRadial (isRadial_)
{
colours.add (0);
colours.add (colour1.getARGB());

View file

@ -35,20 +35,16 @@ BEGIN_JUCE_NAMESPACE
static const Graphics::ResamplingQuality defaultQuality = Graphics::mediumResamplingQuality;
//==============================================================================
#define MINIMUM_COORD -0x3fffffff
#define MAXIMUM_COORD 0x3fffffff
#undef ASSERT_COORDS_ARE_SENSIBLE_NUMBERS
#define ASSERT_COORDS_ARE_SENSIBLE_NUMBERS(x, y, w, h) \
jassert ((int) x >= MINIMUM_COORD \
&& (int) x <= MAXIMUM_COORD \
&& (int) y >= MINIMUM_COORD \
&& (int) y <= MAXIMUM_COORD \
&& (int) w >= MINIMUM_COORD \
&& (int) w <= MAXIMUM_COORD \
&& (int) h >= MINIMUM_COORD \
&& (int) h <= MAXIMUM_COORD);
template <typename Type>
static bool areCoordsSensibleNumbers (Type x, Type y, Type w, Type h)
{
const int maxVal = 0x3fffffff;
return (int) x >= -maxVal && (int) x <= maxVal
&& (int) y >= -maxVal && (int) y <= maxVal
&& (int) w >= -maxVal && (int) w <= maxVal
&& (int) h >= -maxVal && (int) h <= maxVal;
}
//==============================================================================
LowLevelGraphicsContext::LowLevelGraphicsContext()
@ -62,7 +58,7 @@ LowLevelGraphicsContext::~LowLevelGraphicsContext()
//==============================================================================
Graphics::Graphics (Image& imageToDrawOnto) throw()
: context (imageToDrawOnto.createLowLevelContext()),
ownsContext (true),
contextToDelete (context),
saveStatePending (false)
{
resetToDefaultState();
@ -70,7 +66,6 @@ Graphics::Graphics (Image& imageToDrawOnto) throw()
Graphics::Graphics (LowLevelGraphicsContext* const internalContext) throw()
: context (internalContext),
ownsContext (false),
saveStatePending (false)
{
resetToDefaultState();
@ -78,8 +73,6 @@ Graphics::Graphics (LowLevelGraphicsContext* const internalContext) throw()
Graphics::~Graphics() throw()
{
if (ownsContext)
delete context;
}
//==============================================================================
@ -325,7 +318,7 @@ void Graphics::fillRect (int x,
int height) const throw()
{
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
jassert (areCoordsSensibleNumbers (x, y, width, height));
context->fillRect (Rectangle (x, y, width, height), false);
}
@ -341,7 +334,7 @@ void Graphics::fillRect (const float x,
const float height) const throw()
{
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
jassert (areCoordsSensibleNumbers (x, y, width, height));
Path p;
p.addRectangle (x, y, width, height);
@ -397,7 +390,7 @@ void Graphics::drawRect (const int x,
const int lineThickness) const throw()
{
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
jassert (areCoordsSensibleNumbers (x, y, width, height));
context->fillRect (Rectangle (x, y, width, lineThickness), false);
context->fillRect (Rectangle (x, y + lineThickness, lineThickness, height - lineThickness * 2), false);
@ -412,7 +405,7 @@ void Graphics::drawRect (const float x,
const float lineThickness) const throw()
{
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
jassert (areCoordsSensibleNumbers (x, y, width, height));
Path p;
p.addRectangle (x, y, width, lineThickness);
@ -441,7 +434,7 @@ void Graphics::drawBevel (const int x,
const bool sharpEdgeOnOutside) const throw()
{
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
jassert (areCoordsSensibleNumbers (x, y, width, height));
if (clipRegionIntersects (x, y, width, height))
{
@ -476,7 +469,7 @@ void Graphics::fillEllipse (const float x,
const float height) const throw()
{
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
jassert (areCoordsSensibleNumbers (x, y, width, height));
Path p;
p.addEllipse (x, y, width, height);
@ -490,7 +483,7 @@ void Graphics::drawEllipse (const float x,
const float lineThickness) const throw()
{
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
jassert (areCoordsSensibleNumbers (x, y, width, height));
Path p;
p.addEllipse (x, y, width, height);
@ -504,7 +497,7 @@ void Graphics::fillRoundedRectangle (const float x,
const float cornerSize) const throw()
{
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
jassert (areCoordsSensibleNumbers (x, y, width, height));
Path p;
p.addRoundedRectangle (x, y, width, height, cornerSize);
@ -529,7 +522,7 @@ void Graphics::drawRoundedRectangle (const float x,
const float lineThickness) const throw()
{
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (x, y, width, height);
jassert (areCoordsSensibleNumbers (x, y, width, height));
Path p;
p.addRoundedRectangle (x, y, width, height, cornerSize);
@ -723,7 +716,7 @@ void Graphics::drawImageWithin (const Image* const imageToDraw,
const bool fillAlphaChannelWithCurrentBrush) const throw()
{
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (destX, destY, destW, destH);
jassert (areCoordsSensibleNumbers (destX, destY, destW, destH));
if (imageToDraw != 0)
{
@ -757,8 +750,8 @@ void Graphics::drawImage (const Image* const imageToDraw,
const bool fillAlphaChannelWithCurrentBrush) const throw()
{
// passing in a silly number can cause maths problems in rendering!
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (dx, dy, dw, dh);
ASSERT_COORDS_ARE_SENSIBLE_NUMBERS (sx, sy, sw, sh);
jassert (areCoordsSensibleNumbers (dx, dy, dw, dh));
jassert (areCoordsSensibleNumbers (sx, sy, sw, sh));
if (context->clipRegionIntersects (Rectangle (dx, dy, dw, dh)))
{

View file

@ -717,7 +717,7 @@ public:
private:
//==============================================================================
LowLevelGraphicsContext* const context;
const bool ownsContext;
ScopedPointer <LowLevelGraphicsContext> contextToDelete;
bool saveStatePending;
void saveStateIfPending() throw();

View file

@ -443,10 +443,9 @@ void LowLevelGraphicsPostScriptRenderer::writeImage (const Image& im,
pixel = Colours::transparentWhite;
}
char colourString [16];
sprintf (colourString, "%x%x%x", pixel.getRed(), pixel.getGreen(), pixel.getBlue());
const uint8 pixelValues[3] = { pixel.getRed(), pixel.getGreen(), pixel.getBlue() };
out << (const char*) colourString;
out << String::toHexString (pixelValues, 3, 0);
charsOnLine += 3;
if (charsOnLine > 100)

View file

@ -1341,10 +1341,10 @@ private:
//==============================================================================
LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (Image& image_)
: image (image_),
stateStack (20)
: image (image_)
{
currentState = new LLGCSavedState (image_.getBounds(), 0, 0, Font(), FillType(), Graphics::mediumResamplingQuality);
currentState = new LLGCSavedState (image_.getBounds(), 0, 0, Font(),
FillType(), Graphics::mediumResamplingQuality);
}
LowLevelGraphicsSoftwareRenderer::~LowLevelGraphicsSoftwareRenderer()

View file

@ -341,8 +341,7 @@ class TypefaceCache : public DeletedAtShutdown
{
public:
TypefaceCache (int numToCache = 10) throw()
: counter (1),
faces (2)
: counter (1)
{
while (--numToCache >= 0)
faces.add (new CachedFace());

View file

@ -109,8 +109,8 @@ void PositionedGlyph::moveBy (const float deltaX,
//==============================================================================
GlyphArrangement::GlyphArrangement()
: glyphs (128)
{
glyphs.ensureStorageAllocated (128);
}
GlyphArrangement::GlyphArrangement (const GlyphArrangement& other)

View file

@ -93,22 +93,21 @@ public:
//==============================================================================
TextLayout::TextLayout() throw()
: tokens (64),
totalLines (0)
: totalLines (0)
{
tokens.ensureStorageAllocated (64);
}
TextLayout::TextLayout (const String& text,
const Font& font) throw()
: tokens (64),
totalLines (0)
: totalLines (0)
{
tokens.ensureStorageAllocated (64);
appendText (text, font);
}
TextLayout::TextLayout (const TextLayout& other) throw()
: tokens (64),
totalLines (0)
: totalLines (0)
{
*this = other;
}

View file

@ -49,8 +49,7 @@ static const int defaultGranularity = 32;
//==============================================================================
Path::Path() throw()
: data (defaultGranularity),
numElements (0),
: numElements (0),
pathXMin (0),
pathXMax (0),
pathYMin (0),
@ -64,8 +63,7 @@ Path::~Path() throw()
}
Path::Path (const Path& other) throw()
: data (defaultGranularity),
numElements (other.numElements),
: numElements (other.numElements),
pathXMin (other.pathXMin),
pathXMax (other.pathXMax),
pathYMin (other.pathYMin),

View file

@ -32,9 +32,9 @@
namespace jpeglibNamespace
{
#if JUCE_INCLUDE_JPEGLIB_CODE
#if JUCE_MINGW
typedef unsigned char boolean;
#endif
#if JUCE_MINGW
typedef unsigned char boolean;
#endif
extern "C"
{
#define JPEG_INTERNALS

View file

@ -49,7 +49,6 @@ static int cacheTimeout = 5000;
ImageCache::ImageCache()
: images (4)
{
}