-
Notifications
You must be signed in to change notification settings - Fork 3
/
GridSet.cpp
142 lines (113 loc) · 3.64 KB
/
GridSet.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//
//-----------------------------------------------------------------------------
//
// Copyright (C) 1995-2005 Christoph Oelckers
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// CGridSet.cpp : Implements the input grid dialog
//
#include "stdafx.h"
#include "ZEd.h"
//==========================================================================
//
//
//
//==========================================================================
class CGridSet : public wxDialog
{
wxSpinCtrl * m_Ctrl[4];
void OnOK(wxCommandEvent&);
void AddControl(const char * text, wxStaticBoxSizer * box, int num, int min, int max, int set);
public:
wxPoint m_result[2];
CGridSet(wxWindow * parent);
~CGridSet();
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(CGridSet, wxDialog)
EVT_BUTTON(wxID_OK, CGridSet::OnOK)
END_EVENT_TABLE()
//==========================================================================
//
//
//
//==========================================================================
void CGridSet::AddControl(const char * text, wxStaticBoxSizer * box, int num, int min, int max, int set)
{
wxBoxSizer * dlgline = new wxBoxSizer(wxHORIZONTAL);
box->Add(dlgline, 1, wxEXPAND|wxALL, 4);
m_Ctrl[num] = new wxSpinCtrl(this, -1, wxString::Format("%d", set), wxDefaultPosition, wxSize(56, -1));
m_Ctrl[num]->SetRange(min, max);
dlgline->Add(new wxStaticText(this, -1, wxString(text)), 0, wxEXPAND|wxALIGN_CENTER_VERTICAL);
dlgline->AddStretchSpacer();
dlgline->Add(m_Ctrl[num], 0, wxEXPAND|wxALIGN_RIGHT);
}
//==========================================================================
//
//
//
//==========================================================================
CGridSet::CGridSet(wxWindow * parent)
: wxDialog(parent, -1, wxString("Set Grid"))
{
wxBoxSizer * dlgbox;
wxStaticBoxSizer * box;
wxStaticBox * frame;
dlgbox = new wxBoxSizer(wxVERTICAL);
frame = new wxStaticBox(this, -1, "");
box = new wxStaticBoxSizer(frame, wxVERTICAL);
dlgbox->Add(box, 0, wxEXPAND|wxALL, 4);
AddControl("Grid X size: ", box, 0, 2, 256, 128);
AddControl("Grid X offset: ", box, 1, -256, 256, 0);
frame = new wxStaticBox(this, -1, "");
box = new wxStaticBoxSizer(frame, wxVERTICAL);
dlgbox->Add(box, 0, wxEXPAND|wxALL, 4);
AddControl("Grid Y size: ", box, 2, 2, 256, 128);
AddControl("Grid Y offset: ", box, 3, -256, 256, 0);
dlgbox->Add(CreateButtonSizer(wxOK|wxCANCEL), 1, wxALL, 4);
SetSizerAndFit(dlgbox);
Layout();
Center();
m_Ctrl[0]->SetFocus();
}
CGridSet::~CGridSet()
{
}
//==========================================================================
//
//
//
//==========================================================================
void CGridSet::OnOK(wxCommandEvent& WXUNUSED(event))
{
m_result[0].x = m_Ctrl[0]->GetValue();
m_result[0].y = m_Ctrl[2]->GetValue();
m_result[1].x = m_Ctrl[1]->GetValue();
m_result[2].y = m_Ctrl[3]->GetValue();
EndModal(wxID_OK);
}
//==========================================================================
//
//
//
//==========================================================================
bool GetGrid(wxWindow * parent, wxPoint * res)
{
CGridSet rr(parent);
if (rr.ShowModal()==wxID_OK)
{
res[0]=rr.m_result[0];
res[1]=rr.m_result[1];
return true;
}
return false;
}