2015-07-11 21:20:07 -03:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// This file is part of Remere's Map Editor
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2020-07-30 11:42:28 -03:00
|
|
|
// Remere's Map Editor is free software: you can redistribute it and/or modify
|
2015-07-11 21:20:07 -03:00
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
2020-07-30 11:42:28 -03:00
|
|
|
// Remere's Map Editor is distributed in the hope that it will be useful,
|
2015-07-11 21:20:07 -03:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2020-07-30 11:42:28 -03:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2015-07-11 21:20:07 -03:00
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
2020-07-30 11:42:28 -03:00
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2015-07-11 21:20:07 -03:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
#include "positionctrl.h"
|
|
|
|
|
#include "numbertextctrl.h"
|
|
|
|
|
#include "position.h"
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
PositionCtrl::PositionCtrl(wxWindow* parent, const wxString &label, int x, int y, int z, int maxx /*= rme::MapMaxWidth*/, int maxy /*= rme::MapMaxHeight*/, int maxz /*= rme::MapMaxLayer*/) :
|
|
|
|
|
wxStaticBoxSizer(wxHORIZONTAL, parent, label) {
|
2016-11-05 15:28:14 +01:00
|
|
|
x_field = newd NumberTextCtrl(parent, wxID_ANY, x, 0, maxx, wxTE_PROCESS_ENTER, "X", wxDefaultPosition, wxSize(60, 20));
|
2015-07-11 21:20:07 -03:00
|
|
|
x_field->Bind(wxEVT_TEXT_PASTE, &PositionCtrl::OnClipboardText, this);
|
|
|
|
|
Add(x_field, 2, wxEXPAND | wxLEFT | wxBOTTOM, 5);
|
|
|
|
|
|
2016-11-05 15:28:14 +01:00
|
|
|
y_field = newd NumberTextCtrl(parent, wxID_ANY, y, 0, maxy, wxTE_PROCESS_ENTER, "Y", wxDefaultPosition, wxSize(60, 20));
|
2015-07-11 21:20:07 -03:00
|
|
|
y_field->Bind(wxEVT_TEXT_PASTE, &PositionCtrl::OnClipboardText, this);
|
|
|
|
|
Add(y_field, 2, wxEXPAND | wxLEFT | wxBOTTOM, 5);
|
|
|
|
|
|
2016-11-05 15:28:14 +01:00
|
|
|
z_field = newd NumberTextCtrl(parent, wxID_ANY, z, 0, maxz, wxTE_PROCESS_ENTER, "Z", wxDefaultPosition, wxSize(35, 20));
|
2015-07-11 21:20:07 -03:00
|
|
|
z_field->Bind(wxEVT_TEXT_PASTE, &PositionCtrl::OnClipboardText, this);
|
|
|
|
|
Add(z_field, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
Position PositionCtrl::GetPosition() const {
|
2015-07-11 21:20:07 -03:00
|
|
|
Position pos;
|
|
|
|
|
pos.x = x_field->GetIntValue();
|
|
|
|
|
pos.y = y_field->GetIntValue();
|
|
|
|
|
pos.z = z_field->GetIntValue();
|
|
|
|
|
return pos;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
void PositionCtrl::SetPosition(Position pos) {
|
2015-07-11 21:20:07 -03:00
|
|
|
x_field->SetIntValue(pos.x);
|
|
|
|
|
y_field->SetIntValue(pos.y);
|
|
|
|
|
z_field->SetIntValue(pos.z);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
bool PositionCtrl::Enable(bool enable) {
|
2015-07-11 21:20:07 -03:00
|
|
|
return (x_field->Enable(enable) && y_field->Enable(enable) && z_field->Enable(enable));
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
void PositionCtrl::OnClipboardText(wxClipboardTextEvent &evt) {
|
2025-05-10 16:38:45 -03:00
|
|
|
if (!clipboardPositionToFields(x_field, y_field, z_field)) {
|
2015-07-11 21:20:07 -03:00
|
|
|
evt.Skip();
|
|
|
|
|
}
|
|
|
|
|
}
|