Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5532 Some refactoring and rearrangement, surface flags can be modifi…
…ed now
- Loading branch information
1 parent
1fb9fed
commit 7b4c12e
Showing
11 changed files
with
499 additions
and
383 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#pragma once | ||
|
||
namespace ui | ||
{ | ||
|
||
template<typename Source> | ||
class CheckBoxBinding : | ||
public TwoWayBinding<Source, bool> | ||
{ | ||
public: | ||
using BaseBinding = TwoWayBinding<Source, bool>; | ||
|
||
private: | ||
wxCheckBox* _checkbox; | ||
|
||
public: | ||
CheckBoxBinding(wxCheckBox* checkbox, | ||
const typename BaseBinding::LoadFunc& loadFunc, | ||
const typename BaseBinding::UpdateFunc& saveFunc) : | ||
CheckBoxBinding(checkbox, loadFunc, saveFunc, BaseBinding::PostUpdateFunc()) | ||
{} | ||
|
||
CheckBoxBinding(wxCheckBox* checkbox, | ||
const typename BaseBinding::LoadFunc& loadFunc, | ||
const typename BaseBinding::UpdateFunc& saveFunc, | ||
const typename BaseBinding::PostUpdateFunc& postChangeNotify) : | ||
CheckBoxBinding(checkbox, loadFunc, saveFunc, postChangeNotify, std::bind(&BaseBinding::UseSourceAsTarget, this)) | ||
{} | ||
|
||
CheckBoxBinding(wxCheckBox* checkbox, | ||
const typename BaseBinding::LoadFunc& loadFunc, | ||
const typename BaseBinding::UpdateFunc& saveFunc, | ||
const typename BaseBinding::PostUpdateFunc& postChangeNotify, | ||
const typename BaseBinding::AcquireTargetFunc& acquireSaveTarget) : | ||
BaseBinding(loadFunc, saveFunc, postChangeNotify, acquireSaveTarget), | ||
_checkbox(checkbox) | ||
{ | ||
if (BaseBinding::_updateValue) | ||
{ | ||
_checkbox->Bind(wxEVT_CHECKBOX, &CheckBoxBinding::onValueChanged, this); | ||
} | ||
} | ||
|
||
virtual ~CheckBoxBinding() | ||
{ | ||
if (BaseBinding::_updateValue) | ||
{ | ||
_checkbox->Unbind(wxEVT_CHECKBOX, &CheckBoxBinding::onValueChanged, this); | ||
} | ||
} | ||
|
||
protected: | ||
void setValueOnControl(const bool& value) override | ||
{ | ||
_checkbox->SetValue(value); | ||
} | ||
|
||
void onValueChanged(wxCommandEvent& ev) | ||
{ | ||
BaseBinding::updateValueOnTarget(_checkbox->GetValue()); | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.