summaryrefslogtreecommitdiff
path: root/win/Povdlg.cpp
blob: e3c8a66b1ba903991e63ba61ffcf554a0abccf65 (plain)
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
// POVDlg.cpp : implementation file
//

#include "stdafx.h"
#include "leocad.h"
#include "POVDlg.h"
#include "tools.h"
#include "resource.hm"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPOVDlg dialog

const DWORD CPOVDlg::m_nHelpIDs[] =
{
	IDC_POVDLG_LGEO,	HIDC_POVDLG_LGEO,
	IDC_POVDLG_OUTPOV,	HIDC_POVDLG_OUTPOV,
	IDC_POVDLG_POVRAY,	HIDC_POVDLG_POVRAY,
	IDC_POVDLG_RENDER,	HIDC_POVDLG_RENDER,
    0,					0
};

CPOVDlg::CPOVDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPOVDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPOVDlg)
	m_bRender = FALSE;
	m_strPOV = _T("");
	m_strOut = _T("");
	m_strLGEO = _T("");
	//}}AFX_DATA_INIT
}

void CPOVDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPOVDlg)
	DDX_Check(pDX, IDC_POVDLG_RENDER, m_bRender);
	DDX_Text(pDX, IDC_POVDLG_POVRAY, m_strPOV);
	DDX_Text(pDX, IDC_POVDLG_OUTPOV, m_strOut);
	DDX_Text(pDX, IDC_POVDLG_LGEO, m_strLGEO);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CPOVDlg, CDialog)
	//{{AFX_MSG_MAP(CPOVDlg)
	ON_BN_CLICKED(IDC_POVDLG_POVBROWSE, OnPovbrowse)
	ON_BN_CLICKED(IDC_POVDLG_POVOUTBROWSE, OnPovoutbrowse)
	ON_BN_CLICKED(IDC_POVDLG_LGEOBROWSE, OnPovdlgLgeobrowse)
	ON_WM_CONTEXTMENU()
	ON_WM_HELPINFO()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPOVDlg message handlers

BOOL CPOVDlg::OnInitDialog() 
{
	m_bRender = theApp.GetProfileInt ("Settings", "POV Render", 1);
	m_strPOV = theApp.GetProfileString ("Settings", "POV-Ray", "");
	m_strLGEO = theApp.GetProfileString ("Settings", "LGEO", "");

	CDialog::OnInitDialog();
	
	return TRUE;
}

void CPOVDlg::OnOK() 
{
	UpdateData (TRUE);

	if (m_strOut.GetLength() == 0)
		return;

	if (m_strLGEO.GetLength() > 0)
		if (m_strLGEO[m_strLGEO.GetLength()-1] != '\\') 
			m_strLGEO += "\\";

	theApp.WriteProfileInt ("Settings", "POV Render", m_bRender);
	theApp.WriteProfileString ("Settings", "POV-Ray", m_strPOV);
	theApp.WriteProfileString ("Settings", "LGEO", m_strLGEO);

	CDialog::OnOK();
}

void CPOVDlg::OnPovbrowse() 
{
	CFileDialog dlg(TRUE, "*.exe", m_strPOV, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
		"Executable Files (*.exe)|*.exe|All Files (*.*)|*.*||", this);
	if (dlg.DoModal() == IDOK)
	{
		UpdateData (TRUE);
		m_strPOV = dlg.GetPathName();
		UpdateData (FALSE);
	}
}

void CPOVDlg::OnPovoutbrowse() 
{
	CFileDialog dlg(FALSE, "*.pov", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
		"POV-Ray Files (*.pov)|*.pov|All Files (*.*)|*.*||", AfxGetMainWnd());
	if (dlg.DoModal() == IDOK)
	{
		UpdateData (TRUE);
		m_strOut = dlg.GetPathName();
		UpdateData (FALSE);
	}
}

void CPOVDlg::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	::WinHelp(pWnd->m_hWnd, theApp.m_pszHelpFilePath, 
		HELP_CONTEXTMENU, (DWORD)(LPVOID)m_nHelpIDs);
}

BOOL CPOVDlg::OnHelpInfo(HELPINFO* pHelpInfo) 
{
	return ::WinHelp((HWND)pHelpInfo->hItemHandle, theApp.m_pszHelpFilePath, 
		HELP_WM_HELP, (DWORD)(LPVOID)m_nHelpIDs);
}

void CPOVDlg::OnPovdlgLgeobrowse() 
{
	CString str;
	if (FolderBrowse(&str, _T("Select LGEO folder"), GetSafeHwnd()))
	{
		UpdateData(TRUE);
		m_strLGEO = str;
		UpdateData(FALSE);
	}
}