bsnes/hiro/core/widget/source-edit.cpp

57 lines
1.2 KiB
C++

#if defined(Hiro_SourceEdit)
auto mSourceEdit::allocate() -> pObject* {
return new pSourceEdit(*this);
}
//
auto mSourceEdit::doChange() const -> void {
if(state.onChange) return state.onChange();
}
auto mSourceEdit::doMove() const -> void {
if(state.onMove) return state.onMove();
}
auto mSourceEdit::onChange(const function<void ()>& callback) -> type& {
state.onChange = callback;
return *this;
}
auto mSourceEdit::onMove(const function<void ()>& callback) -> type& {
state.onMove = callback;
return *this;
}
auto mSourceEdit::position() const -> unsigned {
return state.position;
}
auto mSourceEdit::setPosition(signed position) -> type& {
state.position = position;
signal(setPosition, position);
return *this;
}
auto mSourceEdit::setSelected(Position selected) -> type& {
if(selected.x() < 0) return *this;
if(selected.y() < 0) selected.setY(-1);
else if(selected.x() > selected.y()) return *this;
state.selected = selected;
signal(setSelected, selected);
return *this;
}
auto mSourceEdit::setText(const string& text) -> type& {
state.text = text;
signal(setText, text);
return *this;
}
auto mSourceEdit::text() const -> string {
return signal(text);
}
#endif