| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "ShuttleGui.h" |
| 4 |
|
| 5 |
template <typename ReturnType, typename... Args> class ScopedSizer |
| 6 |
{ |
| 7 |
public: |
| 8 |
ScopedSizer( |
| 9 |
ShuttleGui& s, ReturnType (ShuttleGui::*startFunc)(Args...), |
| 10 |
void (ShuttleGui::*endFunc)(), Args... args) |
| 11 |
: mShuttleGui(s) |
| 12 |
, mStartFunction(startFunc) |
| 13 |
, mEndFunction(endFunc) |
| 14 |
{ |
| 15 |
(mShuttleGui.*mStartFunction)(std::forward<Args>(args)...); |
| 16 |
} |
| 17 |
|
| 18 |
~ScopedSizer() |
| 19 |
{ |
| 20 |
(mShuttleGui.*mEndFunction)(); |
| 21 |
} |
| 22 |
|
| 23 |
private: |
| 24 |
ShuttleGui& mShuttleGui; |
| 25 |
ReturnType (ShuttleGui::*mStartFunction)(Args...); |
| 26 |
void (ShuttleGui::*mEndFunction)(); |
| 27 |
}; |
| 28 |
|
| 29 |
class ScopedHorizontalLay : public ScopedSizer<void, int, int> |
| 30 |
{ |
| 31 |
public: |
| 32 |
ScopedHorizontalLay( |
| 33 |
ShuttleGui& s, int PositionFlags = wxALIGN_CENTRE, int iProp = 1) |
| 34 |
: ScopedSizer<void, int, int>( |
| 35 |
s, &ShuttleGui::StartHorizontalLay, &ShuttleGui::EndHorizontalLay, |
| 36 |
PositionFlags, iProp) |
| 37 |
{ |
| 38 |
} |
| 39 |
}; |
| 40 |
|
| 41 |
class ScopedInvisiblePanel : public ScopedSizer<wxPanel*, int> |
| 42 |
{ |
| 43 |
public: |
| 44 |
ScopedInvisiblePanel(ShuttleGui& s, int border = 0) |
| 45 |
: ScopedSizer<wxPanel*, int>( |
| 46 |
s, &ShuttleGui::StartInvisiblePanel, &ShuttleGui::EndInvisiblePanel, |
| 47 |
border) |
| 48 |
{ |
| 49 |
} |
| 50 |
}; |
| 51 |
|
| 52 |
class ScopedVerticalLay : public ScopedSizer<void, int> |
| 53 |
{ |
| 54 |
public: |
| 55 |
ScopedVerticalLay(ShuttleGui& s, int iProp = 1) |
| 56 |
: ScopedSizer<void, int>( |
| 57 |
s, &ShuttleGui::StartVerticalLay, &ShuttleGui::EndVerticalLay, |
| 58 |
iProp) |
| 59 |
{ |
| 60 |
} |
| 61 |
}; |
| 62 |
|
| 63 |
class ScopedStatic : |
| 64 |
public ScopedSizer<wxStaticBox*, const TranslatableString&, int> |
| 65 |
{ |
| 66 |
public: |
| 67 |
ScopedStatic(ShuttleGui& s, const TranslatableString& label, int iProp = 0) |
| 68 |
: ScopedSizer<wxStaticBox*, const TranslatableString&, int>( |
| 69 |
s, &ShuttleGui::StartStatic, &ShuttleGui::EndStatic, label, iProp) |
| 70 |
{ |
| 71 |
} |
| 72 |
}; |