Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
GridProps.cpp
Go to the documentation of this file.
1
/* Project Magic 2.0
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: Magic.exe
6
FILE: GridProps.cpp
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Grid Properties Dialog implementation file
13
*/
14
15
16
#include "
stdafx.h
"
17
#include "
Magic.h
"
18
#include "
GridProps.h
"
19
#include "
Grid.h
"
20
21
#ifdef _DEBUG
22
#define new DEBUG_NEW
23
#undef THIS_FILE
24
static
char
THIS_FILE[] = __FILE__;
25
#endif
26
27
// +--------------------------------------------------------------------+
28
// GridProps dialog
29
// +--------------------------------------------------------------------+
30
31
GridProps::GridProps
(
Grid
* g, CWnd* pParent
/*=NULL*/
)
32
: CDialog(
GridProps
::IDD, pParent), grid(g)
33
{
34
//{{AFX_DATA_INIT(GridProps)
35
mGridShow
=
grid
->
IsShow
();
36
mGridSnap
=
grid
->
IsSnap
();
37
mReferencePlan
=
grid
->
GetReferencePlan
();
38
mReferenceFront
=
grid
->
GetReferenceFront
();
39
mReferenceSide
=
grid
->
GetReferenceSide
();
40
mGridSize
=
grid
->
GetSize
();
41
//}}AFX_DATA_INIT
42
}
43
44
static
const
char
* C(CString& str)
45
{
46
static
char
buf[512];
47
int
i;
48
for
(i = 0; i < str.GetLength(); i++)
49
buf[i] = (
char
) str.GetAt(i);
50
buf[i] = 0;
51
52
return
buf;
53
}
54
55
void
GridProps::DoDataExchange
(CDataExchange* pDX)
56
{
57
CDialog::DoDataExchange
(pDX);
58
//{{AFX_DATA_MAP(GridProps)
59
DDX_Check(pDX,
IDC_GRID_SHOW
,
mGridShow
);
60
DDX_Check(pDX,
IDC_GRID_SNAP
,
mGridSnap
);
61
DDX_Text(pDX,
IDC_REFERENCE_PLAN
,
mReferencePlan
);
62
DDX_Text(pDX,
IDC_REFERENCE_FRONT
,
mReferenceFront
);
63
DDX_Text(pDX,
IDC_REFERENCE_SIDE
,
mReferenceSide
);
64
DDX_Text(pDX,
IDC_GRID_SIZE
,
mGridSize
);
65
DDV_MinMaxInt(pDX,
mGridSize
, 1, 64);
66
//}}AFX_DATA_MAP
67
68
// if saving, write the values back to the grid
69
if
(pDX->m_bSaveAndValidate) {
70
grid
->
SetSnap
(
mGridSnap
?
true
:
false
);
71
grid
->
SetShow
(
mGridShow
?
true
:
false
);
72
grid
->
SetSize
(
mGridSize
);
73
74
grid
->
SetReferencePlan
(C(
mReferencePlan
));
75
grid
->
SetReferenceFront
(C(
mReferenceFront
));
76
grid
->
SetReferenceSide
(C(
mReferenceSide
));
77
}
78
}
79
80
81
BEGIN_MESSAGE_MAP(
GridProps
, CDialog)
82
//{{AFX_MSG_MAP(GridProps)
83
ON_BN_CLICKED(
IDC_FILE_PLAN
, OnFilePlan)
84
ON_BN_CLICKED(
IDC_FILE_FRONT
, OnFileFront)
85
ON_BN_CLICKED(
IDC_FILE_SIDE
, OnFileSide)
86
//}}AFX_MSG_MAP
87
END_MESSAGE_MAP()
88
89
// +--------------------------------------------------------------------+
90
91
static
void
OnImageFile(CString& strImageFile)
92
{
93
char
filename[512];
94
filename[0] =
'\0'
;
95
CFileDialog ofd(TRUE,
"pcx"
);
96
97
ofd.m_ofn.lpstrFilter =
"PCX Files\0*.pcx\0All Files\0*.*\0\0"
;
98
ofd.m_ofn.lpstrFile = filename;
99
ofd.m_ofn.nMaxFile =
sizeof
(filename);
100
101
if
(ofd.DoModal() != IDOK)
102
return
;
103
104
char
tex_name[512];
105
sprintf(tex_name,
"%s"
, ofd.GetFileName().GetBuffer(0));
106
107
strImageFile = tex_name;
108
}
109
110
void
GridProps::OnFilePlan
()
111
{
112
OnImageFile(
mReferencePlan
);
113
UpdateData(FALSE);
114
}
115
116
void
GridProps::OnFileFront
()
117
{
118
OnImageFile(
mReferenceFront
);
119
UpdateData(FALSE);
120
}
121
122
void
GridProps::OnFileSide
()
123
{
124
OnImageFile(
mReferenceSide
);
125
UpdateData(FALSE);
126
}
Magic2
GridProps.cpp
Generated on Thu May 31 2012 16:30:47 for Starshatter_Open by
1.8.1