Browse Source

Minor clean-ups.

tags/2021-05-28
jules 10 years ago
parent
commit
c17a72e5b1
3 changed files with 70 additions and 70 deletions
  1. +54
    -54
      extras/Introjucer/Source/ComponentEditor/components/jucer_TabbedComponentHandler.h
  2. +13
    -13
      modules/juce_core/memory/juce_HeapBlock.h
  3. +3
    -3
      modules/juce_gui_basics/windows/juce_ComponentPeer.cpp

+ 54
- 54
extras/Introjucer/Source/ComponentEditor/components/jucer_TabbedComponentHandler.h View File

@@ -42,7 +42,7 @@ public:
XmlElement* createXmlFor (Component* comp, const ComponentLayout* layout)
{
TabbedComponent* const t = dynamic_cast <TabbedComponent*> (comp);
TabbedComponent* const t = dynamic_cast<TabbedComponent*> (comp);
XmlElement* const e = ComponentTypeHandler::createXmlFor (comp, layout);
if (t->getOrientation() == TabbedButtonBar::TabsAtTop) e->setAttribute ("orientation", "top");
@@ -64,7 +64,7 @@ public:
if (! ComponentTypeHandler::restoreFromXml (xml, comp, layout))
return false;
TabbedComponent* const t = dynamic_cast <TabbedComponent*> (comp);
TabbedComponent* const t = dynamic_cast<TabbedComponent*> (comp);
if (xml.getStringAttribute ("orientation") == "top") t->setOrientation (TabbedButtonBar::TabsAtTop);
else if (xml.getStringAttribute ("orientation") == "bottom") t->setOrientation (TabbedButtonBar::TabsAtBottom);
@@ -92,7 +92,7 @@ public:
{
ComponentTypeHandler::getEditableProperties (component, doc, props);
TabbedComponent* const t = dynamic_cast <TabbedComponent*> (component);
TabbedComponent* const t = dynamic_cast<TabbedComponent*> (component);
props.add (new TabOrientationProperty (t, doc));
props.add (new TabDepthProperty (t, doc));
@@ -110,11 +110,11 @@ public:
{
ComponentTypeHandler::addPropertiesToPropertyPanel (comp, doc, panel);
TabbedComponent* const t = dynamic_cast <TabbedComponent*> (comp);
TabbedComponent* const t = dynamic_cast<TabbedComponent*> (comp);
for (int i = 0; i < t->getNumTabs(); ++i)
{
Array <PropertyComponent*> properties;
Array<PropertyComponent*> properties;
properties.add (new TabNameProperty (t, doc, i));
properties.add (new TabColourProperty (t, doc, i));
@@ -136,7 +136,7 @@ public:
String getCreationParameters (GeneratedCode&, Component* comp)
{
TabbedComponent* const t = dynamic_cast <TabbedComponent*> (comp);
TabbedComponent* const t = dynamic_cast<TabbedComponent*> (comp);
switch (t->getOrientation())
{
@@ -152,7 +152,7 @@ public:
void fillInCreationCode (GeneratedCode& code, Component* component, const String& memberVariableName)
{
TabbedComponent* const t = dynamic_cast <TabbedComponent*> (component);
TabbedComponent* const t = dynamic_cast<TabbedComponent*> (component);
ComponentTypeHandler::fillInCreationCode (code, component, memberVariableName);
@@ -223,7 +223,7 @@ public:
xml->setAttribute ("name", tc->getTabNames() [tabIndex]);
xml->setAttribute ("colour", tc->getTabBackgroundColour (tabIndex).toString());
if (TabDemoContentComp* const tdc = dynamic_cast <TabDemoContentComp*> (tc->getTabContentComponent (tabIndex)))
if (TabDemoContentComp* const tdc = dynamic_cast<TabDemoContentComp*> (tc->getTabContentComponent (tabIndex)))
{
xml->setAttribute ("useJucerComp", tdc->isUsingJucerComp);
xml->setAttribute ("contentClassName", tdc->contentClassName);
@@ -239,11 +239,11 @@ public:
tc->setTabName (tabIndex, xml.getStringAttribute ("name", "Tab"));
tc->setTabBackgroundColour (tabIndex, Colour::fromString (xml.getStringAttribute ("colour", Colours::lightgrey.toString())));
if (TabDemoContentComp* const tdc = dynamic_cast <TabDemoContentComp*> (tc->getTabContentComponent (tabIndex)))
if (TabDemoContentComp* const tdc = dynamic_cast<TabDemoContentComp*> (tc->getTabContentComponent (tabIndex)))
{
tdc->isUsingJucerComp = xml.getBoolAttribute ("useJucerComp", false);
tdc->contentClassName = xml.getStringAttribute ("contentClassName");
tdc->constructorParams = xml.getStringAttribute ("constructorParams");
tdc->isUsingJucerComp = xml.getBoolAttribute ("useJucerComp", false);
tdc->contentClassName = xml.getStringAttribute ("contentClassName");
tdc->constructorParams = xml.getStringAttribute ("constructorParams");
tdc->jucerComponentFile = xml.getStringAttribute ("jucerComponentFile");
tdc->updateContent();
@@ -253,7 +253,7 @@ public:
//==============================================================================
static bool isTabUsingJucerComp (TabbedComponent* tc, int tabIndex)
{
TabDemoContentComp* const tdc = dynamic_cast <TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
TabDemoContentComp* const tdc = dynamic_cast<TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
jassert (tdc != nullptr);
return tdc != 0 && tdc->isUsingJucerComp;
@@ -261,7 +261,7 @@ public:
static void setTabUsingJucerComp (TabbedComponent* tc, int tabIndex, const bool b)
{
TabDemoContentComp* const tdc = dynamic_cast <TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
TabDemoContentComp* const tdc = dynamic_cast<TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
jassert (tdc != nullptr);
if (tdc != nullptr)
@@ -273,7 +273,7 @@ public:
static String getTabClassName (TabbedComponent* tc, int tabIndex)
{
TabDemoContentComp* const tdc = dynamic_cast <TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
TabDemoContentComp* const tdc = dynamic_cast<TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
jassert (tdc != nullptr);
return tdc != 0 ? tdc->contentClassName : String::empty;
@@ -281,7 +281,7 @@ public:
static void setTabClassName (TabbedComponent* tc, int tabIndex, const String& newName)
{
TabDemoContentComp* const tdc = dynamic_cast <TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
TabDemoContentComp* const tdc = dynamic_cast<TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
jassert (tdc != nullptr);
if (tdc != nullptr)
@@ -293,7 +293,7 @@ public:
static String getTabConstructorParams (TabbedComponent* tc, int tabIndex)
{
TabDemoContentComp* const tdc = dynamic_cast <TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
TabDemoContentComp* const tdc = dynamic_cast<TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
jassert (tdc != nullptr);
return tdc != 0 ? tdc->constructorParams : String::empty;
@@ -301,7 +301,7 @@ public:
static void setTabConstructorParams (TabbedComponent* tc, int tabIndex, const String& newParams)
{
TabDemoContentComp* const tdc = dynamic_cast <TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
TabDemoContentComp* const tdc = dynamic_cast<TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
jassert (tdc != nullptr);
if (tdc != nullptr)
@@ -313,7 +313,7 @@ public:
static String getTabJucerFile (TabbedComponent* tc, int tabIndex)
{
TabDemoContentComp* const tdc = dynamic_cast <TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
TabDemoContentComp* const tdc = dynamic_cast<TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
jassert (tdc != nullptr);
return tdc != 0 ? tdc->jucerComponentFile : String::empty;
@@ -321,7 +321,7 @@ public:
static void setTabJucerFile (TabbedComponent* tc, int tabIndex, const String& newFile)
{
TabDemoContentComp* const tdc = dynamic_cast <TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
TabDemoContentComp* const tdc = dynamic_cast<TabDemoContentComp*> (tc->getTabContentComponent (tabIndex));
jassert (tdc != nullptr);
if (tdc != nullptr)
@@ -396,11 +396,11 @@ private:
};
//==============================================================================
class TabOrientationProperty : public ComponentChoiceProperty <TabbedComponent>
class TabOrientationProperty : public ComponentChoiceProperty<TabbedComponent>
{
public:
TabOrientationProperty (TabbedComponent* comp, JucerDocument& doc)
: ComponentChoiceProperty <TabbedComponent> ("tab position", comp, doc)
: ComponentChoiceProperty<TabbedComponent> ("tab position", comp, doc)
{
choices.add ("Tabs at top");
choices.add ("Tabs at bottom");
@@ -434,11 +434,11 @@ private:
}
private:
class TabOrienationChangeAction : public ComponentUndoableAction <TabbedComponent>
class TabOrienationChangeAction : public ComponentUndoableAction<TabbedComponent>
{
public:
TabOrienationChangeAction (TabbedComponent* const comp, ComponentLayout& l, const TabbedButtonBar::Orientation newState_)
: ComponentUndoableAction <TabbedComponent> (comp, l),
: ComponentUndoableAction<TabbedComponent> (comp, l),
newState (newState_)
{
oldState = comp->getOrientation();
@@ -465,11 +465,11 @@ private:
};
//==============================================================================
class TabInitialTabProperty : public ComponentChoiceProperty <TabbedComponent>
class TabInitialTabProperty : public ComponentChoiceProperty<TabbedComponent>
{
public:
TabInitialTabProperty (TabbedComponent* comp, JucerDocument& doc)
: ComponentChoiceProperty <TabbedComponent> ("initial tab", comp, doc)
: ComponentChoiceProperty<TabbedComponent> ("initial tab", comp, doc)
{
for (int i = 0; i < comp->getNumTabs(); ++i)
choices.add ("Tab " + String (i) + ": \"" + comp->getTabNames() [i] + "\"");
@@ -487,11 +487,11 @@ private:
}
private:
class InitialTabChangeAction : public ComponentUndoableAction <TabbedComponent>
class InitialTabChangeAction : public ComponentUndoableAction<TabbedComponent>
{
public:
InitialTabChangeAction (TabbedComponent* const comp, ComponentLayout& l, const int newValue_)
: ComponentUndoableAction <TabbedComponent> (comp, l),
: ComponentUndoableAction<TabbedComponent> (comp, l),
newValue (newValue_)
{
oldValue = comp->getCurrentTabIndex();
@@ -558,11 +558,11 @@ private:
JucerDocument& document;
private:
class TabDepthChangeAction : public ComponentUndoableAction <TabbedComponent>
class TabDepthChangeAction : public ComponentUndoableAction<TabbedComponent>
{
public:
TabDepthChangeAction (TabbedComponent* const comp, ComponentLayout& l, const int newState_)
: ComponentUndoableAction <TabbedComponent> (comp, l),
: ComponentUndoableAction<TabbedComponent> (comp, l),
newState (newState_)
{
oldState = comp->getTabBarDepth();
@@ -614,7 +614,7 @@ private:
JucerDocument& document;
private:
class AddTabAction : public ComponentUndoableAction <TabbedComponent>
class AddTabAction : public ComponentUndoableAction<TabbedComponent>
{
public:
AddTabAction (TabbedComponent* const comp, ComponentLayout& l)
@@ -680,7 +680,7 @@ private:
JucerDocument& document;
private:
class RemoveTabAction : public ComponentUndoableAction <TabbedComponent>
class RemoveTabAction : public ComponentUndoableAction<TabbedComponent>
{
public:
RemoveTabAction (TabbedComponent* const comp, ComponentLayout& l, int indexToRemove_)
@@ -717,11 +717,11 @@ private:
};
//==============================================================================
class TabNameProperty : public ComponentTextProperty <TabbedComponent>
class TabNameProperty : public ComponentTextProperty<TabbedComponent>
{
public:
TabNameProperty (TabbedComponent* comp, JucerDocument& doc, const int tabIndex_)
: ComponentTextProperty <TabbedComponent> ("name", 200, false, comp, doc),
: ComponentTextProperty<TabbedComponent> ("name", 200, false, comp, doc),
tabIndex (tabIndex_)
{
}
@@ -740,11 +740,11 @@ private:
private:
int tabIndex;
class TabNameChangeAction : public ComponentUndoableAction <TabbedComponent>
class TabNameChangeAction : public ComponentUndoableAction<TabbedComponent>
{
public:
TabNameChangeAction (TabbedComponent* const comp, ComponentLayout& l, const int tabIndex_, const String& newValue_)
: ComponentUndoableAction <TabbedComponent> (comp, l),
: ComponentUndoableAction<TabbedComponent> (comp, l),
tabIndex (tabIndex_),
newValue (newValue_)
{
@@ -817,12 +817,12 @@ private:
JucerDocument& document;
int tabIndex;
class TabColourChangeAction : public ComponentUndoableAction <TabbedComponent>
class TabColourChangeAction : public ComponentUndoableAction<TabbedComponent>
{
public:
TabColourChangeAction (TabbedComponent* comp, ComponentLayout& l,
int tabIndex_, Colour newValue_)
: ComponentUndoableAction <TabbedComponent> (comp, l),
: ComponentUndoableAction<TabbedComponent> (comp, l),
tabIndex (tabIndex_),
newValue (newValue_)
{
@@ -852,11 +852,11 @@ private:
};
//==============================================================================
class TabContentTypeProperty : public ComponentChoiceProperty <TabbedComponent>
class TabContentTypeProperty : public ComponentChoiceProperty<TabbedComponent>
{
public:
TabContentTypeProperty (TabbedComponent* comp, JucerDocument& doc, const int tabIndex_)
: ComponentChoiceProperty <TabbedComponent> ("content type", comp, doc),
: ComponentChoiceProperty<TabbedComponent> ("content type", comp, doc),
tabIndex (tabIndex_)
{
choices.add ("Jucer content component");
@@ -877,11 +877,11 @@ private:
private:
int tabIndex;
class TabContentTypeChangeAction : public ComponentUndoableAction <TabbedComponent>
class TabContentTypeChangeAction : public ComponentUndoableAction<TabbedComponent>
{
public:
TabContentTypeChangeAction (TabbedComponent* const comp, ComponentLayout& l, const int tabIndex_, const bool newValue_)
: ComponentUndoableAction <TabbedComponent> (comp, l),
: ComponentUndoableAction<TabbedComponent> (comp, l),
tabIndex (tabIndex_),
newValue (newValue_)
{
@@ -952,11 +952,11 @@ private:
JucerDocument& document;
int tabIndex;
class JucerCompFileChangeAction : public ComponentUndoableAction <TabbedComponent>
class JucerCompFileChangeAction : public ComponentUndoableAction<TabbedComponent>
{
public:
JucerCompFileChangeAction (TabbedComponent* const comp, ComponentLayout& l, const int tabIndex_, const String& newState_)
: ComponentUndoableAction <TabbedComponent> (comp, l),
: ComponentUndoableAction<TabbedComponent> (comp, l),
tabIndex (tabIndex_),
newState (newState_)
{
@@ -985,11 +985,11 @@ private:
};
//==============================================================================
class TabContentClassProperty : public ComponentTextProperty <TabbedComponent>
class TabContentClassProperty : public ComponentTextProperty<TabbedComponent>
{
public:
TabContentClassProperty (TabbedComponent* comp, JucerDocument& doc, const int tabIndex_)
: ComponentTextProperty <TabbedComponent> ("content class", 256, false, comp, doc),
: ComponentTextProperty<TabbedComponent> ("content class", 256, false, comp, doc),
tabIndex (tabIndex_)
{
}
@@ -1008,11 +1008,11 @@ private:
private:
int tabIndex;
class TabClassNameChangeAction : public ComponentUndoableAction <TabbedComponent>
class TabClassNameChangeAction : public ComponentUndoableAction<TabbedComponent>
{
public:
TabClassNameChangeAction (TabbedComponent* const comp, ComponentLayout& l, const int tabIndex_, const String& newValue_)
: ComponentUndoableAction <TabbedComponent> (comp, l),
: ComponentUndoableAction<TabbedComponent> (comp, l),
tabIndex (tabIndex_),
newValue (newValue_)
{
@@ -1043,11 +1043,11 @@ private:
};
//==============================================================================
class TabContentConstructorParamsProperty : public ComponentTextProperty <TabbedComponent>
class TabContentConstructorParamsProperty : public ComponentTextProperty<TabbedComponent>
{
public:
TabContentConstructorParamsProperty (TabbedComponent* comp, JucerDocument& doc, const int tabIndex_)
: ComponentTextProperty <TabbedComponent> ("constructor params", 512, false, comp, doc),
: ComponentTextProperty<TabbedComponent> ("constructor params", 512, false, comp, doc),
tabIndex (tabIndex_)
{
}
@@ -1066,11 +1066,11 @@ private:
private:
int tabIndex;
class TabConstructorParamChangeAction : public ComponentUndoableAction <TabbedComponent>
class TabConstructorParamChangeAction : public ComponentUndoableAction<TabbedComponent>
{
public:
TabConstructorParamChangeAction (TabbedComponent* const comp, ComponentLayout& l, const int tabIndex_, const String& newValue_)
: ComponentUndoableAction <TabbedComponent> (comp, l),
: ComponentUndoableAction<TabbedComponent> (comp, l),
tabIndex (tabIndex_),
newValue (newValue_)
{
@@ -1138,12 +1138,12 @@ private:
const int tabIndex, totalNumTabs;
private:
class MoveTabAction : public ComponentUndoableAction <TabbedComponent>
class MoveTabAction : public ComponentUndoableAction<TabbedComponent>
{
public:
MoveTabAction (TabbedComponent* const comp, ComponentLayout& l,
const int oldIndex_, const int newIndex_)
: ComponentUndoableAction <TabbedComponent> (comp, l),
: ComponentUndoableAction<TabbedComponent> (comp, l),
oldIndex (oldIndex_),
newIndex (newIndex_)
{


+ 13
- 13
modules/juce_core/memory/juce_HeapBlock.h View File

@@ -36,7 +36,7 @@ namespace HeapBlockHelper
struct ThrowOnFail { static void check (void*) {} };
template<>
struct ThrowOnFail <true> { static void check (void* data) { if (data == nullptr) throw std::bad_alloc(); } };
struct ThrowOnFail<true> { static void check (void* data) { if (data == nullptr) throw std::bad_alloc(); } };
}
#endif
@@ -67,7 +67,7 @@ namespace HeapBlockHelper
..you could just write this:
@code
HeapBlock <int> temp (1024);
HeapBlock<int> temp (1024);
memcpy (temp, xyz, 1024 * sizeof (int));
temp.calloc (2048);
temp[0] = 1234;
@@ -109,7 +109,7 @@ public:
other constructor that takes an InitialisationState parameter.
*/
explicit HeapBlock (const size_t numElements)
: data (static_cast <ElementType*> (std::malloc (numElements * sizeof (ElementType))))
: data (static_cast<ElementType*> (std::malloc (numElements * sizeof (ElementType))))
{
throwOnAllocationFailure();
}
@@ -120,7 +120,7 @@ public:
or left uninitialised.
*/
HeapBlock (const size_t numElements, const bool initialiseToZero)
: data (static_cast <ElementType*> (initialiseToZero
: data (static_cast<ElementType*> (initialiseToZero
? std::calloc (numElements, sizeof (ElementType))
: std::malloc (numElements * sizeof (ElementType))))
{
@@ -166,13 +166,13 @@ public:
This may be a null pointer if the data hasn't yet been allocated, or if it has been
freed by calling the free() method.
*/
inline operator void*() const noexcept { return static_cast <void*> (data); }
inline operator void*() const noexcept { return static_cast<void*> (data); }
/** Returns a void pointer to the allocated data.
This may be a null pointer if the data hasn't yet been allocated, or if it has been
freed by calling the free() method.
*/
inline operator const void*() const noexcept { return static_cast <const void*> (data); }
inline operator const void*() const noexcept { return static_cast<const void*> (data); }
/** Lets you use indirect calls to the first element in the array.
Obviously this will cause problems if the array hasn't been initialised, because it'll
@@ -220,7 +220,7 @@ public:
void malloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
{
std::free (data);
data = static_cast <ElementType*> (std::malloc (newNumElements * elementSize));
data = static_cast<ElementType*> (std::malloc (newNumElements * elementSize));
throwOnAllocationFailure();
}
@@ -230,7 +230,7 @@ public:
void calloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
{
std::free (data);
data = static_cast <ElementType*> (std::calloc (newNumElements, elementSize));
data = static_cast<ElementType*> (std::calloc (newNumElements, elementSize));
throwOnAllocationFailure();
}
@@ -241,7 +241,7 @@ public:
void allocate (const size_t newNumElements, bool initialiseToZero)
{
std::free (data);
data = static_cast <ElementType*> (initialiseToZero
data = static_cast<ElementType*> (initialiseToZero
? std::calloc (newNumElements, sizeof (ElementType))
: std::malloc (newNumElements * sizeof (ElementType)));
throwOnAllocationFailure();
@@ -254,15 +254,15 @@ public:
*/
void realloc (const size_t newNumElements, const size_t elementSize = sizeof (ElementType))
{
data = static_cast <ElementType*> (data == nullptr ? std::malloc (newNumElements * elementSize)
: std::realloc (data, newNumElements * elementSize));
data = static_cast<ElementType*> (data == nullptr ? std::malloc (newNumElements * elementSize)
: std::realloc (data, newNumElements * elementSize));
throwOnAllocationFailure();
}
/** Frees any currently-allocated data.
This will free the data and reset this object to be a null pointer.
*/
void free()
void free() noexcept
{
std::free (data);
data = nullptr;
@@ -272,7 +272,7 @@ public:
The two objects simply exchange their data pointers.
*/
template <bool otherBlockThrows>
void swapWith (HeapBlock <ElementType, otherBlockThrows>& other) noexcept
void swapWith (HeapBlock<ElementType, otherBlockThrows>& other) noexcept
{
std::swap (data, other.data);
}


+ 3
- 3
modules/juce_gui_basics/windows/juce_ComponentPeer.cpp View File

@@ -187,7 +187,7 @@ bool ComponentPeer::handleKeyPress (const int keyCode, const juce_wchar textChar
{
const WeakReference<Component> deletionChecker (target);
if (const Array <KeyListener*>* const keyListeners = target->keyListeners)
if (const Array<KeyListener*>* const keyListeners = target->keyListeners)
{
for (int i = keyListeners->size(); --i >= 0;)
{
@@ -238,7 +238,7 @@ bool ComponentPeer::handleKeyUpOrDown (const bool isKeyDown)
if (keyWasUsed || deletionChecker == nullptr)
break;
if (const Array <KeyListener*>* const keyListeners = target->keyListeners)
if (const Array<KeyListener*>* const keyListeners = target->keyListeners)
{
for (int i = keyListeners->size(); --i >= 0;)
{
@@ -276,7 +276,7 @@ TextInputTarget* ComponentPeer::findCurrentTextInputTarget()
Component* const c = Component::getCurrentlyFocusedComponent();
if (c == &component || component.isParentOf (c))
if (TextInputTarget* const ti = dynamic_cast <TextInputTarget*> (c))
if (TextInputTarget* const ti = dynamic_cast<TextInputTarget*> (c))
if (ti->isTextInputActive())
return ti;


Loading…
Cancel
Save