File: properties_dlg.cpp

package info (click to toggle)
c-munipack 2.1.39-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,888 kB
  • sloc: ansic: 200,762; cpp: 106,129; lex: 9,035; yacc: 4,916; sh: 4,074; fortran: 2,613; xml: 2,105; python: 1,182; makefile: 546; perl: 104
file content (247 lines) | stat: -rw-r--r-- 7,957 bytes parent folder | download | duplicates (2)
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
/**************************************************************

properties_dlg.cpp (C-Munipack project)
The "Properties" dialogs
Copyright (C) 2012 David Motl, dmotl@volny.cz

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

**************************************************************/

#include <stdio.h>
#include <windows.h>

#include "properties_dlg.h"
#include "mv_image.h"
#include "mv_chart.h"
#include "mv_graph.h"
#include "main.h"
#include "resource.h"

// Constructor
CFileProperties::CFileProperties(const TCCD_Interface *parent):m_FileName(NULL), 
	m_DirPath(NULL), m_pParent(parent)
{
	HDC hdc = CreateCompatibleDC(0);
	m_hTitleFont = CreateFont(-MulDiv(9, GetDeviceCaps(hdc, LOGPIXELSY), 72), 
		0, 0, 0, FW_BOLD, 0, TRUE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Microsoft Sans Serif");
	DeleteDC(hdc);

	if (parent && parent->FilePath()) {
		const char *filepath = parent->FilePath();
		const char *aux = strrchr(filepath, '\\');
		if (aux) {
			size_t len = strlen(aux+1);
			m_FileName = (char*)malloc(len+1);
			if (m_FileName)
				strcpy_s(m_FileName, len+1, aux+1);
			len = (aux-filepath);
			m_DirPath = (char*)malloc(len+1);
			if (m_DirPath) {
				strncpy_s(m_DirPath, len+1, filepath, len);
				m_DirPath[len] = '\0';
			}
		}
	}
}

// Destructor
CFileProperties::~CFileProperties()
{
	DeleteObject(m_hTitleFont);
	free(m_FileName);
	free(m_DirPath);
}

// Initialize the dialog
BOOL CFileProperties::OnInitDialog(void)
{
	SendDlgItemMessage(m_hWnd, IDC_FILE_SECTION, WM_SETFONT, (WPARAM)m_hTitleFont, 0); 
	SetDlgItemText(m_hWnd, IDC_FILE, m_FileName);
	SetDlgItemText(m_hWnd, IDC_PATH, m_DirPath);
	return TRUE;
}

// Command handler
BOOL CFileProperties::OnCommand(int iCtrlId, int iCode)
{
	if (iCtrlId == IDOK) {
		EndDialog(m_hWnd, IDOK);
		return TRUE;
	}
	return FALSE;
}

// Constructor
CImageProperties::CImageProperties(const TCCD_Image *parent):CFileProperties(parent)
{
}

// Resource id 
int CImageProperties::ResourceId(void)
{
	return IDD_IMAGE_PROPERTIES;
}

// Dialog initialization
BOOL CImageProperties::OnInitDialog(void)
{
	char buf[256];

	CFileProperties::OnInitDialog();
	SendDlgItemMessage(m_hWnd, IDC_FRAME_SECTION, WM_SETFONT, (WPARAM)m_hTitleFont, 0); 
	if (m_pParent) {
		const TCCD_Image *parent = (TCCD_Image*)m_pParent;
		SetDlgItemText(m_hWnd, IDC_FORMAT, parent->FormatName());
		if (parent->JulianDate()>0) {
			const CmpackDateTime *dt = parent->DateTime();
			sprintf_s(buf, "%04d-%02d-%02d %d:%02d:%02d.%03d", dt->date.year, dt->date.month, dt->date.day,
				dt->time.hour, dt->time.minute, dt->time.second, dt->time.milisecond);
			SetDlgItemText(m_hWnd, IDC_DATE, buf);
			sprintf_s(buf, "%.7lf", parent->JulianDate());
			SetDlgItemText(m_hWnd, IDC_JD, buf);
		} else {
			SetDlgItemText(m_hWnd, IDC_DATE, "Not available");
			SetDlgItemText(m_hWnd, IDC_JD, "Not available");
		}
		if (parent->Exposure()>0) {
			sprintf_s(buf, "%.3lf seconds", parent->Exposure());
			SetDlgItemText(m_hWnd, IDC_EXPOSURE, buf);
		} else
			SetDlgItemText(m_hWnd, IDC_EXPOSURE, "Not available");
		if (parent->CCDTemperature()>-999 && parent->CCDTemperature()<999) {
			sprintf_s(buf, "%.2lf \xB0""C", parent->CCDTemperature());
			SetDlgItemText(m_hWnd, IDC_CCDTEMP, buf);
		} else
			SetDlgItemText(m_hWnd, IDC_CCDTEMP, "Not available");
		if (parent->Filter())
			SetDlgItemText(m_hWnd, IDC_FILTER, parent->Filter());
		else
			SetDlgItemText(m_hWnd, IDC_FILTER, "Not available");
		if (parent->Object())
			SetDlgItemText(m_hWnd, IDC_OBJECT, parent->Object());
		else
			SetDlgItemText(m_hWnd, IDC_OBJECT, "Not available");
		if (parent->Observer())
			SetDlgItemText(m_hWnd, IDC_OBSERVER, parent->Observer());
		else
			SetDlgItemText(m_hWnd, IDC_OBSERVER, "Not available");
		if (parent->AvgFrames()>0) {
			sprintf_s(buf, "%d", parent->AvgFrames());
			SetDlgItemText(m_hWnd, IDC_FRAMES_AVG, buf);
		} else
			SetDlgItemText(m_hWnd, IDC_FRAMES_AVG, "Not available");
		if (parent->SumFrames()>0) {
			sprintf_s(buf, "%d", parent->SumFrames());
			SetDlgItemText(m_hWnd, IDC_FRAMES_SUM, buf);
		} else
			SetDlgItemText(m_hWnd, IDC_FRAMES_SUM, "Not available");
		if (parent->ImageWidth()>0 && parent->ImageHeigt()>0) {
			sprintf_s(buf, "%d x %d pixels", parent->ImageWidth(), parent->ImageHeigt());
			SetDlgItemText(m_hWnd, IDC_IMG_SIZE, buf);
		} else
			SetDlgItemText(m_hWnd, IDC_IMG_SIZE, "Not available");
	}
	return TRUE;
}

// Constructor
CChartProperties::CChartProperties(const TCCD_Chart *parent):CFileProperties(parent)
{
}

// Resource id 
int CChartProperties::ResourceId(void)
{
	return IDD_CHART_PROPERTIES;
}

// Dialog initialization
BOOL CChartProperties::OnInitDialog(void)
{
	char buf[256];

	CFileProperties::OnInitDialog();
	SendDlgItemMessage(m_hWnd, IDC_FRAME_SECTION, WM_SETFONT, (WPARAM)m_hTitleFont, 0); 
	if (m_pParent) {
		const TCCD_Chart *parent = (TCCD_Chart*)m_pParent;
		SetDlgItemText(m_hWnd, IDC_FORMAT, parent->FormatName());
		if (parent->JulianDate()>0) {
			const CmpackDateTime *dt = parent->DateTime();
			sprintf_s(buf, "%04d-%02d-%02d %d:%02d:%02d.%03d", dt->date.year, dt->date.month, dt->date.day,
				dt->time.hour, dt->time.minute, dt->time.second, dt->time.milisecond);
			SetDlgItemText(m_hWnd, IDC_DATE, buf);
			sprintf_s(buf, "%.7lf", parent->JulianDate());
			SetDlgItemText(m_hWnd, IDC_JD, buf);
		} else {
			SetDlgItemText(m_hWnd, IDC_DATE, "Not available");
			SetDlgItemText(m_hWnd, IDC_JD, "Not available");
		}
		if (parent->Exposure()>0) {
			sprintf_s(buf, "%.3lf seconds", parent->Exposure());
			SetDlgItemText(m_hWnd, IDC_EXPOSURE, buf);
		} else
			SetDlgItemText(m_hWnd, IDC_EXPOSURE, "Not available");
		if (parent->Filter())
			SetDlgItemText(m_hWnd, IDC_FILTER, parent->Filter());
		else
			SetDlgItemText(m_hWnd, IDC_FILTER, "Not available");
		if (parent->Object())
			SetDlgItemText(m_hWnd, IDC_OBJECT, parent->Object());
		else
			SetDlgItemText(m_hWnd, IDC_OBJECT, "Not available");
		if (parent->Observer())
			SetDlgItemText(m_hWnd, IDC_OBSERVER, parent->Observer());
		else
			SetDlgItemText(m_hWnd, IDC_OBSERVER, "Not available");
		sprintf_s(buf, "%d", parent->Stars());
		SetDlgItemText(m_hWnd, IDC_STARS, buf);
	}
	return TRUE;
}

// Constructor
CTableProperties::CTableProperties(const TCCD_Graph *parent):CFileProperties(parent)
{
	m_Type = parent->TableType();
}

// Resource id 
int CTableProperties::ResourceId(void)
{
	if (m_Type == CMPACK_TABLE_LCURVE_DIFF || m_Type == CMPACK_TABLE_LCURVE_INST)
		return IDD_LCURVE_PROPERTIES;
	else
		return IDD_TABLE_PROPERTIES;
}

// Dialog initialization
BOOL CTableProperties::OnInitDialog(void)
{
	//char buf[256];

	CFileProperties::OnInitDialog();
	SendDlgItemMessage(m_hWnd, IDC_LCURVE_SECTION, WM_SETFONT, (WPARAM)m_hTitleFont, 0); 
	if (m_pParent) {
		const TCCD_Graph *parent = (TCCD_Graph*)m_pParent;
		SetDlgItemText(m_hWnd, IDC_FORMAT, parent->FormatName());
		if (parent->Filter())
			SetDlgItemText(m_hWnd, IDC_FILTER, parent->Filter());
		else
			SetDlgItemText(m_hWnd, IDC_FILTER, "Not available");
	}
	return TRUE;
}