summaryrefslogtreecommitdiff
path: root/frontends/windows/about.c
blob: 2cd855b552a14323fa499f1ba7a1ed61b07c4083 (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
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin@dfgh.net>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf 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; version 2 of the License.
*
* NetSurf 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, see <http://www.gnu.org/licenses/>.
*/

/**
 * \file
 * This is The win32 API about dialog implementation.
 */

#include <stdio.h>

#include "utils/config.h"

#include <windows.h>

#include "utils/log.h"
#include "utils/messages.h"
#include "desktop/version.h"

#include "windows/gui.h"
#include "windows/window.h"
#include "windows/about.h"
#include "windows/resourceid.h"

#include "windbg.h"

/**
 * Initialize the about dialog text fields
 */
static BOOL init_about_dialog(HWND hwnd)
{
	char ver_str[128];
	HWND dlg_itm;
	HFONT hFont;

	dlg_itm = GetDlgItem(hwnd, IDC_ABOUT_VERSION);
	if (dlg_itm != NULL) {

		hFont=CreateFont (26, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial");
		if (hFont != NULL) {
			NSLOG(netsurf, INFO, "Setting font object");
			SendMessage(dlg_itm, WM_SETFONT, (WPARAM)hFont, 0);
		}

		snprintf(ver_str, sizeof(ver_str), "%s %s", 
			 messages_get("NetSurf"), netsurf_version); 
		
		SendMessage(dlg_itm, WM_SETTEXT, 0, (LPARAM)ver_str);
	}

	dlg_itm = GetDlgItem(hwnd, IDC_ABOUT_COPYRIGHT);
	if (dlg_itm != NULL) {
		snprintf(ver_str, sizeof(ver_str), "%s", 
			 messages_get("NetSurfCopyright")); 
		
		SendMessage(dlg_itm, WM_SETTEXT, 0, (LPARAM)ver_str);
	}

	return TRUE;
}

/**
 * destroy resources used to create about dialog
 */
static BOOL destroy_about_dialog(HWND hwnd)
{
	HWND dlg_itm;
	HFONT hFont;

	dlg_itm = GetDlgItem(hwnd, IDC_ABOUT_VERSION);
	if (dlg_itm != NULL) {
		hFont = (HFONT)SendMessage(dlg_itm, WM_GETFONT, 0, 0);
		if (hFont != NULL) {
			NSLOG(netsurf, INFO, "Destroyed font object");
			DeleteObject(hFont); 	
		}
	}
		
	return TRUE;

}

static BOOL CALLBACK 
nsws_about_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{

	LOG_WIN_MSG(hwnd, msg, wparam, lparam);

	switch(msg) {
	case WM_INITDIALOG: 
		return init_about_dialog(hwnd);

	case WM_COMMAND:
		switch(LOWORD(wparam)) {
		case IDOK:
			NSLOG(netsurf, INFO, "OK clicked");
			EndDialog(hwnd, IDOK);
			break;

		case IDCANCEL:
			NSLOG(netsurf, INFO, "Cancel clicked");
			EndDialog(hwnd, IDOK);
			break;

		case IDC_BTN_CREDITS: 
			nsws_window_go(hwnd, "about:credits");
			EndDialog(hwnd, IDOK);
			break;

		case IDC_BTN_LICENCE:
			nsws_window_go(hwnd, "about:licence");
			EndDialog(hwnd, IDOK);
			break;

		}
		break;

	case WM_CREATE:
		return TRUE;

	case WM_DESTROY:
		return destroy_about_dialog(hwnd);

	}
	return FALSE;
}

void nsws_about_dialog_init(HINSTANCE hinst, HWND parent)
{
	int ret = DialogBox(hinst, MAKEINTRESOURCE(IDD_DLG_ABOUT), parent,
			nsws_about_event_callback);
	if (ret == -1) {
		win32_warning(messages_get("NoMemory"), 0);
		return;
	}
}