2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/FRED2/Grid.cpp $
15 * Grid dialog box created by Mike. Probably will never be used again.
18 * Revision 1.3 2002/06/09 04:41:16 relnev
19 * added copyright header
21 * Revision 1.2 2002/05/07 03:16:44 theoddone33
22 * The Great Newline Fix
24 * Revision 1.1.1.1 2002/05/03 03:28:08 root
28 * 2 10/07/98 6:28p Dave
29 * Initial checkin. Renamed all relevant stuff to be Fred2 instead of
30 * Fred. Globalized mission and campaign file extensions. Removed Silent
31 * Threat specific code.
33 * 1 10/07/98 3:01p Dave
35 * 1 10/07/98 3:00p Dave
37 * 5 6/18/97 11:36p Lawrance
38 * move grid rendering code to MissionGrid.cpp
40 * 4 2/17/97 5:28p Hoffoss
41 * Checked RCS headers, added them were missing, changing description to
42 * something better, etc where needed.
58 static char THIS_FILE[] = __FILE__;
61 extern int double_fine_gridlines;
63 /////////////////////////////////////////////////////////////////////////////
66 // Modeless constructor, MK
67 CGrid::CGrid(CView* pView)
73 CGrid::CGrid(CWnd* pParent /*=NULL*/)
74 : CDialog(CGrid::IDD, pParent)
76 //{{AFX_DATA_INIT(CGrid)
85 void CGrid::DoDataExchange(CDataExchange* pDX)
87 CDialog::DoDataExchange(pDX);
88 //{{AFX_DATA_MAP(CGrid)
89 DDX_Text(pDX, IDC_GRID_SIZE, m_GridSize);
90 DDV_MinMaxUInt(pDX, m_GridSize, 2, 20);
95 BEGIN_MESSAGE_MAP(CGrid, CDialog)
96 //{{AFX_MSG_MAP(CGrid)
97 ON_BN_CLICKED(IDC_GRID_XY_PLANE, OnGridXyPlane)
98 ON_BN_CLICKED(IDC_GRID_XZ_PLANE, OnGridXzPlane)
99 ON_BN_CLICKED(IDC_GRID_YZ_PLANE, OnGridYzPlane)
107 /////////////////////////////////////////////////////////////////////////////
108 // CGrid message handlers
110 extern grid *The_grid;
112 void GridOrient(vector *forward, vector *right)
118 if (The_grid != NULL){
119 center = The_grid->center;
120 nrows = The_grid->nrows;
121 ncols = The_grid->ncols;
122 square_size = The_grid->square_size;
124 vm_vec_make(¢er, 0.0f, 0.0f, 0.0f);
130 The_grid = create_grid(The_grid, forward,
136 physics_init(&The_grid->physics);
139 void CGrid::OnGridXyPlane()
141 vector forward, right;
143 vm_vec_make(&forward, 0.0f, 1.0f, 0.0f);
144 vm_vec_make(&right, 1.0f, 0.0f, 0.0f);
146 GridOrient(&forward, &right);
149 void CGrid::OnGridXzPlane()
151 vector forward, right;
153 vm_vec_make(&forward, 0.0f, 0.0f, 1.0f);
154 vm_vec_make(&right, 1.0f, 0.0f, 0.0f);
156 GridOrient(&forward, &right);
159 void CGrid::OnGridYzPlane()
161 vector forward, right;
163 vm_vec_make(&forward, 0.0f, 1.0f, 0.0f);
164 vm_vec_make(&right, 0.0f, 0.0f, 1.0f);
166 GridOrient(&forward, &right);
169 BOOL CGrid::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
171 return CDialog::Create(IDD, pParentWnd);
176 return CDialog::Create(CGrid::IDD);
180 void CGrid::OnClose()
185 void CGrid::OnDestroy()
189 CDialog::OnDestroy();
193 void CGrid::OnKillFocus(CWnd* pNewWnd)
195 CDialog::OnKillFocus(pNewWnd);
201 BOOL CGrid::DestroyWindow()
203 // TODO: Add your specialized code here and/or call the base class
207 return CDialog::DestroyWindow();
210 BOOL CGrid::OnInitDialog()
212 CDialog::OnInitDialog();
214 CSpinButtonCtrl* pSpin = (CSpinButtonCtrl*) GetDlgItem(IDC_SPIN_GRID_SIZE);
215 pSpin->SetRange(2, 20);
216 if ((m_GridSize < 2) || (m_GridSize > 20))
217 m_GridSize = The_grid->ncols/5;
218 pSpin->SetPos(m_GridSize);
220 return TRUE; // return TRUE unless you set the focus to a control
221 // EXCEPTION: OCX Property Pages should return FALSE
224 void CGrid::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
228 CSpinButtonCtrl* pSpin = (CSpinButtonCtrl*) GetDlgItem(IDC_SPIN_GRID_SIZE);
229 strValue.Format("%i", pSpin->GetPos());
230 pSpin->GetBuddy()->SetWindowText(strValue);
232 The_grid->nrows = pSpin->GetPos()*5;
233 The_grid->ncols = The_grid->nrows;
235 modify_grid(The_grid);
237 CDialog::OnVScroll(nSBCode, nPos, pScrollBar);