1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-19 09:01:15 +02:00

Remove wxArrays of pointers

This commit is contained in:
Paul Licameli
2018-02-02 15:39:19 -05:00
parent 8be1e8fdad
commit 3b32d39b54
15 changed files with 132 additions and 143 deletions

View File

@@ -95,7 +95,7 @@ enum {
class ToolBarArrangement
{
public:
ExpandingToolBarArray childArray;
std::vector<ExpandingToolBar*> childArray;
std::vector<wxRect> rectArray;
std::vector<int> rowArray;
};
@@ -864,7 +864,7 @@ void ToolBarArea::ContractRow(int rowIndex)
int i;
int x = 0;
for(i=0; i<(int)mChildArray.GetCount(); i++)
for(i = 0; i < (int)mChildArray.size(); i++)
if (mRowArray[i] == rowIndex) {
wxPoint childPos = mChildArray[i]->GetPosition();
wxSize childMin = mChildArray[i]->GetMinSize();
@@ -890,7 +890,7 @@ bool ToolBarArea::ExpandRow(int rowIndex)
int expandableCount = 0;
int toolbarCount = 0;
for(i=0; i<(int)mChildArray.GetCount(); i++)
for(i = 0; i < (int)mChildArray.size(); i++)
if (mRowArray[i] == rowIndex) {
ExpandingToolBar *child = mChildArray[i];
wxSize childMin = child->GetMinSize();
@@ -914,7 +914,7 @@ bool ToolBarArea::ExpandRow(int rowIndex)
j = 0;
x = 0;
for(i=0; i<(int)mChildArray.GetCount(); i++)
for(i = 0; i < (int)mChildArray.size(); i++)
if (mRowArray[i] == rowIndex) {
ExpandingToolBar *child = mChildArray[i];
wxPoint childPos = child->GetPosition();
@@ -1017,10 +1017,10 @@ bool ToolBarArea::Layout()
int i;
for(i=0; i<(int)mChildArray.GetCount(); i++)
for(i = 0; i < (int)mChildArray.size(); i++)
mRowArray[i] = -1;
for(i=0; i<(int)mChildArray.GetCount(); i++)
for(i = 0; i < (int)mChildArray.size(); i++)
LayoutOne(i);
Refresh(true);
@@ -1036,13 +1036,13 @@ void ToolBarArea::AdjustLayout()
int row = -1;
int i, j;
for(i=0; i<(int)mChildArray.GetCount(); i++) {
for(i = 0; i < (int)mChildArray.size(); i++) {
if (mRowArray[i] > row) {
row = mRowArray[i];
bool success = ExpandRow(row);
if (!success) {
// Re-layout all toolbars from this row on
for(j=i; j<(int)mChildArray.GetCount(); j++)
for(j = i; j < (int)mChildArray.size(); j++)
LayoutOne(j);
return;
}
@@ -1067,7 +1067,7 @@ void ToolBarArea::Fit(bool horizontal, bool vertical)
minSize.y = 0;
maxSize.x = 9999;
maxSize.y = 0;
for(i=0; i<(int)mChildArray.GetCount(); i++) {
for(i = 0; i < (int)mChildArray.size(); i++) {
wxPoint childPos = mChildArray[i]->GetPosition();
wxSize childSize = mChildArray[i]->GetSize();
@@ -1147,15 +1147,15 @@ void ToolBarArea::CollapseAll(bool now)
{
int i;
for(i=0; i<(int)mChildArray.GetCount(); i++)
for(i = 0; i < (int)mChildArray.size(); i++)
mChildArray[i]->Collapse(now);
}
void ToolBarArea::AddChild(ExpandingToolBar *child)
{
mChildArray.Add(child);
mChildArray.push_back(child);
mRowArray.push_back(-1); // unknown row
LayoutOne(mChildArray.GetCount()-1);
LayoutOne(mChildArray.size() - 1);
Fit(false, true);
}
@@ -1163,17 +1163,17 @@ void ToolBarArea::RemoveChild(ExpandingToolBar *child)
{
int i, j;
for(i=0; i<(int)mChildArray.GetCount(); i++) {
for(i = 0; i < (int)mChildArray.size(); i++) {
if (mChildArray[i] == child) {
child->Hide();
mChildArray.RemoveAt(i);
mChildArray.erase(mChildArray.begin() + i);
mRowArray.erase(mRowArray.begin() + i);
for(j=i; j<(int)mChildArray.GetCount(); j++)
for(j = i; j < (int)mChildArray.size(); j++)
mRowArray[j] = -1;
for(j=i; j<(int)mChildArray.GetCount(); j++)
for(j = i; j < (int)mChildArray.size(); j++)
LayoutOne(j);
Fit(false, true);
@@ -1189,7 +1189,7 @@ std::unique_ptr<ToolBarArrangement> ToolBarArea::SaveArrangement()
arrangement->childArray = mChildArray;
arrangement->rowArray = mRowArray;
for(i=0; i<(int)mChildArray.GetCount(); i++)
for(i = 0; i < (int)mChildArray.size(); i++)
arrangement->rectArray.push_back(mChildArray[i]->GetRect());
return arrangement;
@@ -1202,7 +1202,7 @@ void ToolBarArea::RestoreArrangement(std::unique_ptr<ToolBarArrangement>&& arran
mChildArray = arrangement->childArray;
mRowArray = arrangement->rowArray;
for(i=0; i<(int)mChildArray.GetCount(); i++) {
for(i = 0; i < (int)mChildArray.size(); i++) {
mChildArray[i]->SetSize(arrangement->rectArray[i]);
mChildArray[i]->Show();
}
@@ -1218,7 +1218,7 @@ std::vector<wxRect> ToolBarArea::GetDropTargets()
mDropTargetIndices.clear();
mDropTargetRows.clear();
int numChildren = (int)mChildArray.GetCount();
int numChildren = (int)mChildArray.size();
int i;
int row = -1;
@@ -1257,17 +1257,17 @@ void ToolBarArea::MoveChild(ExpandingToolBar *toolBar, wxRect dropTarget)
int newIndex = mDropTargetIndices[i];
int newRow = mDropTargetRows[i];
mChildArray.Insert(toolBar, newIndex);
mChildArray.insert(mChildArray.begin() + newIndex, toolBar);
mRowArray.insert(mRowArray.begin() + newIndex, newRow);
for(j=newIndex+1; j<(int)mChildArray.GetCount(); j++)
for(j = newIndex+1; j < (int)mChildArray.size(); j++)
mRowArray[j] = -1;
ContractRow(newRow);
mChildArray[newIndex]->Show();
for(j=newIndex; j<(int)mChildArray.GetCount(); j++)
for(j = newIndex; j < (int)mChildArray.size(); j++)
LayoutOne(j);
Fit(false, true);

View File

@@ -40,7 +40,6 @@ class ToolBarGrabber;
class ToolBarArrangement;
using WindowHash = std::unordered_map<void*, int>;
WX_DEFINE_ARRAY(ExpandingToolBar *, ExpandingToolBarArray);
class ExpandingToolBarEvtHandler;
@@ -239,7 +238,7 @@ class ToolBarArea final : public wxPanelWrapper
void AdjustLayout();
void Fit(bool horizontal, bool vertical);
ExpandingToolBarArray mChildArray;
std::vector<ExpandingToolBar*> mChildArray;
std::vector<int> mRowArray;
wxSize mLastLayoutSize;
bool mInOnSize;