dsrc isn't necessary for this repo
[client-tools.git] / src / external / 3rd / application / DXTex / dialogs.cpp
blob443edde88169202e95d461b5aa2bac1aaf8c3bf6
1 // Dialogs.cpp : implementation file
2 //
4 #include "stdafx.h"
5 #include "dxtex.h"
6 #include "dialogs.h"
8 #ifdef _DEBUG
9 #define new DEBUG_NEW
10 #undef THIS_FILE
11 static char THIS_FILE[] = __FILE__;
12 #endif
14 struct FMTINFO
16 D3DFORMAT fmt;
17 UINT idsFmtDesc;
20 const FMTINFO fmtInfoArray[] =
22 D3DFMT_A8R8G8B8, IDS_FMTDESC_A8R8G8B8,
23 D3DFMT_A1R5G5B5, IDS_FMTDESC_A1R5G5B5,
24 D3DFMT_A4R4G4B4, IDS_FMTDESC_A4R4G4B4,
25 D3DFMT_R8G8B8, IDS_FMTDESC_R8G8B8,
26 D3DFMT_R5G6B5, IDS_FMTDESC_R5G6B5,
27 D3DFMT_A2R10G10B10, IDS_FMTDESC_A2R10G10B10,
28 D3DFMT_X8R8G8B8, IDS_FMTDESC_X8R8G8B8,
29 D3DFMT_X1R5G5B5, IDS_FMTDESC_X1R5G5B5,
30 D3DFMT_R3G3B2, IDS_FMTDESC_R3G3B2,
31 D3DFMT_A8R3G3B2, IDS_FMTDESC_A8R3G3B2,
32 D3DFMT_X4R4G4B4, IDS_FMTDESC_X4R4G4B4,
33 D3DFMT_A16B16G16R16, IDS_FMTDESC_A16B16G16R16,
34 D3DFMT_DXT1, IDS_FMTDESC_DXT1,
35 D3DFMT_DXT2, IDS_FMTDESC_DXT2,
36 D3DFMT_DXT3, IDS_FMTDESC_DXT3,
37 D3DFMT_DXT4, IDS_FMTDESC_DXT4,
38 D3DFMT_DXT5, IDS_FMTDESC_DXT5,
40 const int fmtInfoArraySize = sizeof(fmtInfoArray) / sizeof(fmtInfoArray[0]);
42 /////////////////////////////////////////////////////////////////////////////
43 // CNewTextureDlg dialog
46 CNewTextureDlg::CNewTextureDlg(CWnd* pParent /*=NULL*/)
47 : CDialog(CNewTextureDlg::IDD, pParent)
49 //{{AFX_DATA_INIT(CNewTextureDlg)
50 m_iTexType = 0;
51 m_dwWidth = 256;
52 m_dwHeight = 256;
53 m_dwDepth = 8;
54 m_iFmt = 0;
55 m_strFmtDesc = _T("");
56 m_numMips = 1;
57 //}}AFX_DATA_INIT
61 void CNewTextureDlg::DoDataExchange(CDataExchange* pDX)
63 CDialog::DoDataExchange(pDX);
64 //{{AFX_DATA_MAP(CNewTextureDlg)
65 DDX_Radio(pDX, IDC_TEXTURE, m_iTexType);
66 DDX_Text(pDX, IDC_WIDTH, m_dwWidth);
67 DDV_MinMaxInt(pDX, m_dwWidth, 1, 1024);
68 DDX_Text(pDX, IDC_HEIGHT, m_dwHeight);
69 DDV_MinMaxInt(pDX, m_dwHeight, 1, 1024);
70 DDX_Text(pDX, IDC_DEPTH, m_dwDepth);
71 DDV_MinMaxInt(pDX, m_dwDepth, 2, 1024);
72 DDX_Radio(pDX, IDC_A8R8G8B8, m_iFmt);
73 DDX_Text(pDX, IDC_FMTDESC, m_strFmtDesc);
74 DDX_Text(pDX, IDC_MIPCOUNT, m_numMips);
75 DDV_MinMaxInt(pDX, m_numMips, 1, 20);
76 //}}AFX_DATA_MAP
80 BEGIN_MESSAGE_MAP(CNewTextureDlg, CDialog)
81 //{{AFX_MSG_MAP(CNewTextureDlg)
82 ON_BN_CLICKED(IDC_TEXTURE, OnChangeTextureType)
83 ON_BN_CLICKED(IDC_A8R8G8B8, OnChangeFormat)
84 ON_BN_CLICKED(IDC_VOLUMETEXTURE, OnChangeTextureType)
85 ON_BN_CLICKED(IDC_CUBEMAP, OnChangeTextureType)
86 ON_BN_CLICKED(IDC_A4R4G4B4, OnChangeFormat)
87 ON_BN_CLICKED(IDC_A1R5G5B5, OnChangeFormat)
88 ON_BN_CLICKED(IDC_R5G6B5, OnChangeFormat)
89 ON_BN_CLICKED(IDC_R8G8B8, OnChangeFormat)
90 ON_BN_CLICKED(IDC_X8R8G8B8, OnChangeFormat)
91 ON_BN_CLICKED(IDC_X1R5G5B5, OnChangeFormat)
92 ON_BN_CLICKED(IDC_R3G3B2, OnChangeFormat)
93 ON_BN_CLICKED(IDC_A8R3G3B2, OnChangeFormat)
94 ON_BN_CLICKED(IDC_X4R4G4B4, OnChangeFormat)
95 ON_BN_CLICKED(IDC_DXT1, OnChangeFormat)
96 ON_BN_CLICKED(IDC_DXT2, OnChangeFormat)
97 ON_BN_CLICKED(IDC_DXT3, OnChangeFormat)
98 ON_BN_CLICKED(IDC_DXT4, OnChangeFormat)
99 ON_BN_CLICKED(IDC_DXT5, OnChangeFormat)
100 ON_BN_CLICKED(IDC_A2R10G10B10, OnChangeFormat)
101 ON_BN_CLICKED(IDC_A16B16G16R16, OnChangeFormat)
102 //}}AFX_MSG_MAP
103 END_MESSAGE_MAP()
105 /////////////////////////////////////////////////////////////////////////////
106 // CNewTextureDlg message handlers
108 BOOL CNewTextureDlg::OnInitDialog()
110 CDialog::OnInitDialog();
112 OnChangeTextureType();
113 OnChangeFormat();
115 return TRUE; // return TRUE unless you set the focus to a control
116 // EXCEPTION: OCX Property Pages should return FALSE
120 void CNewTextureDlg::OnChangeTextureType()
122 UpdateData(TRUE);
124 if (m_iTexType == 2)
126 // Volume Tex
127 GetDlgItem(IDC_VOLUMEDEPTHLABEL)->EnableWindow(TRUE);
128 GetDlgItem(IDC_DEPTH)->EnableWindow(TRUE);
130 else
132 // Normal or Cube Tex
133 GetDlgItem(IDC_VOLUMEDEPTHLABEL)->EnableWindow(FALSE);
134 GetDlgItem(IDC_DEPTH)->EnableWindow(FALSE);
136 UpdateData(FALSE);
137 OnChangeFormat();
142 void CNewTextureDlg::OnChangeFormat()
144 UpdateData(TRUE);
145 m_fmt = fmtInfoArray[m_iFmt].fmt;
146 m_strFmtDesc.LoadString(fmtInfoArray[m_iFmt].idsFmtDesc);
147 UpdateData(FALSE);
150 void CNewTextureDlg::OnOK()
152 UpdateData(TRUE);
154 // TODO: Need to do lots of validation of width/height/depth/mipcount here
156 if (m_iTexType != 2)
157 m_dwDepth = 0;
159 m_fmt = fmtInfoArray[m_iFmt].fmt;
161 CDialog::OnOK();
164 /////////////////////////////////////////////////////////////////////////////
165 // CCubeMapDlg dialog
168 CCubeMapDlg::CCubeMapDlg(CWnd* pParent /*=NULL*/)
169 : CDialog(CCubeMapDlg::IDD, pParent)
171 //{{AFX_DATA_INIT(CCubeMapDlg)
172 m_iFace = 0;
173 //}}AFX_DATA_INIT
177 void CCubeMapDlg::DoDataExchange(CDataExchange* pDX)
179 CDialog::DoDataExchange(pDX);
180 //{{AFX_DATA_MAP(CCubeMapDlg)
181 DDX_Radio(pDX, IDC_POSX, m_iFace);
182 //}}AFX_DATA_MAP
186 BEGIN_MESSAGE_MAP(CCubeMapDlg, CDialog)
187 //{{AFX_MSG_MAP(CCubeMapDlg)
188 // NOTE: the ClassWizard will add message map macros here
189 //}}AFX_MSG_MAP
190 END_MESSAGE_MAP()
193 /////////////////////////////////////////////////////////////////////////////
194 // CVolumeMapDlg dialog
197 CVolumeMapDlg::CVolumeMapDlg(CWnd* pParent /*=NULL*/)
198 : CDialog(CVolumeMapDlg::IDD, pParent)
200 //{{AFX_DATA_INIT(CVolumeMapDlg)
201 m_powLayers = 0;
202 //}}AFX_DATA_INIT
206 void CVolumeMapDlg::DoDataExchange(CDataExchange* pDX)
208 CDialog::DoDataExchange(pDX);
209 //{{AFX_DATA_MAP(CVolumeMapDlg)
210 DDX_Radio(pDX, IDC_RADIO2, m_powLayers);
211 //}}AFX_DATA_MAP
215 BEGIN_MESSAGE_MAP(CVolumeMapDlg, CDialog)
216 //{{AFX_MSG_MAP(CVolumeMapDlg)
217 // NOTE: the ClassWizard will add message map macros here
218 //}}AFX_MSG_MAP
219 END_MESSAGE_MAP()
221 /////////////////////////////////////////////////////////////////////////////
222 // CVolumeMapDlg message handlers
225 /////////////////////////////////////////////////////////////////////////////
226 // CChangeFmtDlg dialog
229 CChangeFmtDlg::CChangeFmtDlg(CWnd* pParent /*=NULL*/)
230 : CDialog(CChangeFmtDlg::IDD, pParent)
232 //{{AFX_DATA_INIT(CChangeFmtDlg)
233 m_iFmt = -1;
234 m_strFmtDesc = _T("");
235 //}}AFX_DATA_INIT
239 void CChangeFmtDlg::DoDataExchange(CDataExchange* pDX)
241 CDialog::DoDataExchange(pDX);
242 //{{AFX_DATA_MAP(CChangeFmtDlg)
243 DDX_Radio(pDX, IDC_A8R8G8B8, m_iFmt);
244 DDX_Text(pDX, IDC_FMTDESC, m_strFmtDesc);
245 //}}AFX_DATA_MAP
247 GetDlgItem( IDOK )->EnableWindow( m_iFmt != m_iFmtInitial );
251 BEGIN_MESSAGE_MAP(CChangeFmtDlg, CDialog)
252 //{{AFX_MSG_MAP(CChangeFmtDlg)
253 ON_BN_CLICKED(IDC_A1R5G5B5, OnChangeFmt)
254 ON_BN_CLICKED(IDC_A4R4G4B4, OnChangeFmt)
255 ON_BN_CLICKED(IDC_A8R8G8B8, OnChangeFmt)
256 ON_BN_CLICKED(IDC_R5G6B5, OnChangeFmt)
257 ON_BN_CLICKED(IDC_R8G8B8, OnChangeFmt)
258 ON_BN_CLICKED(IDC_X8R8G8B8, OnChangeFmt)
259 ON_BN_CLICKED(IDC_X1R5G5B5, OnChangeFmt)
260 ON_BN_CLICKED(IDC_R3G3B2, OnChangeFmt)
261 ON_BN_CLICKED(IDC_A8R3G3B2, OnChangeFmt)
262 ON_BN_CLICKED(IDC_X4R4G4B4, OnChangeFmt)
263 ON_BN_CLICKED(IDC_DXT1, OnChangeFmt)
264 ON_BN_CLICKED(IDC_DXT2, OnChangeFmt)
265 ON_BN_CLICKED(IDC_DXT3, OnChangeFmt)
266 ON_BN_CLICKED(IDC_DXT4, OnChangeFmt)
267 ON_BN_CLICKED(IDC_DXT5, OnChangeFmt)
268 ON_BN_CLICKED(IDC_A2R10G10B10, OnChangeFmt)
269 ON_BN_CLICKED(IDC_A16B16G16R16, OnChangeFmt)
270 //}}AFX_MSG_MAP
271 END_MESSAGE_MAP()
273 /////////////////////////////////////////////////////////////////////////////
274 // CChangeFmtDlg message handlers
276 BOOL CChangeFmtDlg::OnInitDialog()
278 CDialog::OnInitDialog();
280 for( m_iFmt = 0; m_iFmt < fmtInfoArraySize; m_iFmt++ )
282 if( m_fmt == fmtInfoArray[m_iFmt].fmt )
283 break;
286 m_iFmtInitial = m_iFmt;
288 UpdateFmtDesc();
290 UpdateData(FALSE);
292 return TRUE; // return TRUE unless you set the focus to a control
293 // EXCEPTION: OCX Property Pages should return FALSE
296 void CChangeFmtDlg::OnChangeFmt()
298 UpdateData(TRUE);
299 UpdateFmtDesc();
302 void CChangeFmtDlg::UpdateFmtDesc()
304 m_fmt = fmtInfoArray[m_iFmt].fmt;
305 m_strFmtDesc.LoadString(fmtInfoArray[m_iFmt].idsFmtDesc);
306 UpdateData(FALSE);
309 /////////////////////////////////////////////////////////////////////////////
310 // CResizeDialog dialog
313 CResizeDialog::CResizeDialog(CWnd* pParent /*=NULL*/)
314 : CDialog(CResizeDialog::IDD, pParent)
316 //{{AFX_DATA_INIT(CResizeDialog)
317 m_newHeight = 0;
318 m_newWidth = 0;
319 m_oldHeight = _T("");
320 m_oldWidth = _T("");
321 //}}AFX_DATA_INIT
325 void CResizeDialog::DoDataExchange(CDataExchange* pDX)
327 CDialog::DoDataExchange(pDX);
328 //{{AFX_DATA_MAP(CResizeDialog)
329 DDX_Text(pDX, IDC_NEWHEIGHT, m_newHeight);
330 DDV_MinMaxUInt(pDX, m_newHeight, 1, 4096);
331 DDX_Text(pDX, IDC_NEWWIDTH, m_newWidth);
332 DDV_MinMaxUInt(pDX, m_newWidth, 1, 4096);
333 DDX_Text(pDX, IDC_OLDHEIGHT, m_oldHeight);
334 DDX_Text(pDX, IDC_OLDWIDTH, m_oldWidth);
335 //}}AFX_DATA_MAP
339 BEGIN_MESSAGE_MAP(CResizeDialog, CDialog)
340 //{{AFX_MSG_MAP(CResizeDialog)
341 //}}AFX_MSG_MAP
342 END_MESSAGE_MAP()
344 /////////////////////////////////////////////////////////////////////////////
345 // CSpecularPowerDialog dialog
347 CSpecularPowerDialog::CSpecularPowerDialog(CWnd* pParent /*=NULL*/)
348 : CDialog(CSpecularPowerDialog::IDD, pParent)
350 //{{AFX_DATA_INIT(CSpecularPowerDialog)
351 m_specularPower = _T("");
352 //}}AFX_DATA_INIT
356 void CSpecularPowerDialog::DoDataExchange(CDataExchange* pDX)
358 CDialog::DoDataExchange(pDX);
359 //{{AFX_DATA_MAP(CSpecularPowerDialog)
360 DDX_Text(pDX, IDC_SPECULARPOWER, m_specularPower);
361 //}}AFX_DATA_MAP
365 BEGIN_MESSAGE_MAP(CSpecularPowerDialog, CDialog)
366 //{{AFX_MSG_MAP(CSpecularPowerDialog)
367 //}}AFX_MSG_MAP
368 END_MESSAGE_MAP()