2 * $Logfile: /Freespace2/code/FRED2/Grid.cpp $
7 * Grid dialog box created by Mike. Probably will never be used again.
10 * Revision 1.1 2002/05/03 03:28:08 root
14 * 2 10/07/98 6:28p Dave
15 * Initial checkin. Renamed all relevant stuff to be Fred2 instead of
16 * Fred. Globalized mission and campaign file extensions. Removed Silent
17 * Threat specific code.
19 * 1 10/07/98 3:01p Dave
21 * 1 10/07/98 3:00p Dave
23 * 5 6/18/97 11:36p Lawrance
24 * move grid rendering code to MissionGrid.cpp
26 * 4 2/17/97 5:28p Hoffoss
27 * Checked RCS headers, added them were missing, changing description to
28 * something better, etc where needed.
44 static char THIS_FILE[] = __FILE__;
47 extern int double_fine_gridlines;
49 /////////////////////////////////////////////////////////////////////////////
52 // Modeless constructor, MK
53 CGrid::CGrid(CView* pView)
59 CGrid::CGrid(CWnd* pParent /*=NULL*/)
60 : CDialog(CGrid::IDD, pParent)
62 //{{AFX_DATA_INIT(CGrid)
71 void CGrid::DoDataExchange(CDataExchange* pDX)
73 CDialog::DoDataExchange(pDX);
74 //{{AFX_DATA_MAP(CGrid)
75 DDX_Text(pDX, IDC_GRID_SIZE, m_GridSize);
76 DDV_MinMaxUInt(pDX, m_GridSize, 2, 20);
81 BEGIN_MESSAGE_MAP(CGrid, CDialog)
82 //{{AFX_MSG_MAP(CGrid)
83 ON_BN_CLICKED(IDC_GRID_XY_PLANE, OnGridXyPlane)
84 ON_BN_CLICKED(IDC_GRID_XZ_PLANE, OnGridXzPlane)
85 ON_BN_CLICKED(IDC_GRID_YZ_PLANE, OnGridYzPlane)
93 /////////////////////////////////////////////////////////////////////////////
94 // CGrid message handlers
96 extern grid *The_grid;
98 void GridOrient(vector *forward, vector *right)
104 if (The_grid != NULL){
105 center = The_grid->center;
106 nrows = The_grid->nrows;
107 ncols = The_grid->ncols;
108 square_size = The_grid->square_size;
110 vm_vec_make(¢er, 0.0f, 0.0f, 0.0f);
116 The_grid = create_grid(The_grid, forward,
122 physics_init(&The_grid->physics);
125 void CGrid::OnGridXyPlane()
127 vector forward, right;
129 vm_vec_make(&forward, 0.0f, 1.0f, 0.0f);
130 vm_vec_make(&right, 1.0f, 0.0f, 0.0f);
132 GridOrient(&forward, &right);
135 void CGrid::OnGridXzPlane()
137 vector forward, right;
139 vm_vec_make(&forward, 0.0f, 0.0f, 1.0f);
140 vm_vec_make(&right, 1.0f, 0.0f, 0.0f);
142 GridOrient(&forward, &right);
145 void CGrid::OnGridYzPlane()
147 vector forward, right;
149 vm_vec_make(&forward, 0.0f, 1.0f, 0.0f);
150 vm_vec_make(&right, 0.0f, 0.0f, 1.0f);
152 GridOrient(&forward, &right);
155 BOOL CGrid::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
157 return CDialog::Create(IDD, pParentWnd);
162 return CDialog::Create(CGrid::IDD);
166 void CGrid::OnClose()
171 void CGrid::OnDestroy()
175 CDialog::OnDestroy();
179 void CGrid::OnKillFocus(CWnd* pNewWnd)
181 CDialog::OnKillFocus(pNewWnd);
187 BOOL CGrid::DestroyWindow()
189 // TODO: Add your specialized code here and/or call the base class
193 return CDialog::DestroyWindow();
196 BOOL CGrid::OnInitDialog()
198 CDialog::OnInitDialog();
200 CSpinButtonCtrl* pSpin = (CSpinButtonCtrl*) GetDlgItem(IDC_SPIN_GRID_SIZE);
201 pSpin->SetRange(2, 20);
202 if ((m_GridSize < 2) || (m_GridSize > 20))
203 m_GridSize = The_grid->ncols/5;
204 pSpin->SetPos(m_GridSize);
206 return TRUE; // return TRUE unless you set the focus to a control
207 // EXCEPTION: OCX Property Pages should return FALSE
210 void CGrid::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
214 CSpinButtonCtrl* pSpin = (CSpinButtonCtrl*) GetDlgItem(IDC_SPIN_GRID_SIZE);
215 strValue.Format("%i", pSpin->GetPos());
216 pSpin->GetBuddy()->SetWindowText(strValue);
218 The_grid->nrows = pSpin->GetPos()*5;
219 The_grid->ncols = The_grid->nrows;
221 modify_grid(The_grid);
223 CDialog::OnVScroll(nSBCode, nPos, pScrollBar);