2010-01-31 03:36:02 +03:00
|
|
|
/*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2015-03-13 17:32:06 +03:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* This is The win32 API about dialog implementation.
|
|
|
|
*/
|
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2012-08-11 01:22:59 +04:00
|
|
|
#include "utils/config.h"
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
2016-04-28 00:41:59 +03:00
|
|
|
#include "utils/log.h"
|
2010-01-31 03:36:02 +03:00
|
|
|
#include "utils/utils.h"
|
|
|
|
#include "utils/messages.h"
|
2014-10-13 18:08:16 +04:00
|
|
|
#include "desktop/version.h"
|
2010-01-31 03:36:02 +03:00
|
|
|
|
2016-04-28 00:41:59 +03:00
|
|
|
#include "windows/gui.h"
|
2015-03-13 17:32:06 +03:00
|
|
|
#include "windows/window.h"
|
2010-01-31 03:36:02 +03:00
|
|
|
#include "windows/about.h"
|
|
|
|
#include "windows/resourceid.h"
|
|
|
|
|
2011-03-25 03:14:34 +03:00
|
|
|
#include "windbg.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the about dialog text fields
|
|
|
|
*/
|
|
|
|
static BOOL init_about_dialog(HWND hwnd)
|
2010-01-31 03:36:02 +03:00
|
|
|
{
|
2011-03-25 03:14:34 +03:00
|
|
|
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) {
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("Setting font object");
|
2011-03-25 03:14:34 +03:00
|
|
|
SendMessage(dlg_itm, WM_SETFONT, (WPARAM)hFont, 0);
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
2011-03-25 03:14:34 +03:00
|
|
|
|
|
|
|
snprintf(ver_str, sizeof(ver_str), "%s %s",
|
|
|
|
messages_get("NetSurf"), netsurf_version);
|
2010-01-31 03:36:02 +03:00
|
|
|
|
2011-03-25 03:14:34 +03:00
|
|
|
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) {
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("Destroyed font object");
|
2011-03-25 03:14:34 +03:00
|
|
|
DeleteObject(hFont);
|
|
|
|
}
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
2011-03-25 03:14:34 +03:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
case WM_COMMAND:
|
|
|
|
switch(LOWORD(wparam)) {
|
|
|
|
case IDOK:
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("OK clicked");
|
2010-01-31 03:36:02 +03:00
|
|
|
EndDialog(hwnd, IDOK);
|
|
|
|
break;
|
2011-03-25 03:14:34 +03:00
|
|
|
|
|
|
|
case IDCANCEL:
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("Cancel clicked");
|
2011-03-25 03:14:34 +03:00
|
|
|
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;
|
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
|
|
|
break;
|
2011-03-25 03:14:34 +03:00
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
case WM_CREATE:
|
|
|
|
return TRUE;
|
2011-03-25 03:14:34 +03:00
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
return destroy_about_dialog(hwnd);
|
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
2011-03-25 03:14:34 +03:00
|
|
|
return FALSE;
|
2010-01-31 03:36:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsws_about_dialog_init(HINSTANCE hinst, HWND parent)
|
|
|
|
{
|
2011-03-07 02:27:09 +03:00
|
|
|
int ret = DialogBox(hinst, MAKEINTRESOURCE(IDD_DLG_ABOUT), parent,
|
2010-01-31 03:36:02 +03:00
|
|
|
nsws_about_event_callback);
|
|
|
|
if (ret == -1) {
|
2016-04-28 00:41:59 +03:00
|
|
|
win32_warning(messages_get("NoMemory"), 0);
|
2010-01-31 03:36:02 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|