winedbg: Add partial ARM disassembler.
[wine] / programs / winecfg / about.c
1 /*
2  * WineCfg about panel
3  *
4  * Copyright 2002 Jaco Greeff
5  * Copyright 2003 Dimitrie O. Paun
6  * Copyright 2003 Mike Hearn
7  * Copyright 2010 Joel Holdsworth
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22  *
23  */
24
25 #define COBJMACROS
26
27 #include "config.h"
28
29 #include <windows.h>
30 #include <commctrl.h>
31 #include <shellapi.h>
32
33 #include "resource.h"
34 #include "winecfg.h"
35
36
37 static HICON logo = NULL;
38 static HFONT titleFont = NULL;
39
40 INT_PTR CALLBACK
41 AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
42 {
43     HWND hWnd;
44     HDC hDC;
45     RECT rcClient, rcRect;
46     char *owner, *org;
47
48     switch (uMsg)
49     {
50     case WM_NOTIFY:
51         switch(((LPNMHDR)lParam)->code)
52         {
53         case PSN_APPLY:
54             /*save registration info to registry */
55             owner = get_text(hDlg, IDC_ABT_OWNER);
56             org   = get_text(hDlg, IDC_ABT_ORG);
57
58             set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
59                         "RegisteredOwner", owner ? owner : "");
60             set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
61                         "RegisteredOrganization", org ? org : "");
62             set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
63                         "RegisteredOwner", owner ? owner : "");
64             set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
65                         "RegisteredOrganization", org ? org : "");
66             apply();
67
68             HeapFree(GetProcessHeap(), 0, owner);
69             HeapFree(GetProcessHeap(), 0, org);
70             break;
71
72         case NM_CLICK:
73         case NM_RETURN:
74             if(wParam == IDC_ABT_WEB_LINK)
75                 ShellExecuteA(NULL, "open", PACKAGE_URL, NULL, NULL, SW_SHOW);
76             break;
77         }
78         break;
79
80     case WM_INITDIALOG:
81
82         hDC = GetDC(hDlg);
83
84         /* read owner and organization info from registry, load it into text box */
85         owner = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
86                             "RegisteredOwner", "");
87         org =   get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
88                             "RegisteredOrganization", "");
89
90         SetDlgItemTextA(hDlg, IDC_ABT_OWNER, owner);
91         SetDlgItemTextA(hDlg, IDC_ABT_ORG, org);
92
93         SendMessageW(GetParent(hDlg), PSM_UNCHANGED, 0, 0);
94
95         HeapFree(GetProcessHeap(), 0, owner);
96         HeapFree(GetProcessHeap(), 0, org);
97
98         /* prepare the panel */
99         hWnd = GetDlgItem(hDlg, IDC_ABT_PANEL);
100         if(hWnd)
101         {
102             GetClientRect(hDlg, &rcClient);
103             GetClientRect(hWnd, &rcRect);
104             MoveWindow(hWnd, 0, 0, rcClient.right, rcRect.bottom, FALSE);
105
106             logo = LoadImageW((HINSTANCE)GetWindowLongPtrW(hDlg, GWLP_HINSTANCE),
107                 MAKEINTRESOURCEW(IDI_LOGO), IMAGE_ICON, 0, 0, LR_SHARED);
108         }
109
110         /* prepare the title text */
111         hWnd = GetDlgItem(hDlg, IDC_ABT_TITLE_TEXT);
112         if(hWnd)
113         {
114             static const WCHAR tahomaW[] = {'T','a','h','o','m','a',0};
115             titleFont = CreateFontW(
116                 -MulDiv(24, GetDeviceCaps(hDC, LOGPIXELSY), 72),
117                 0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, 0, tahomaW);
118             SendMessageW(hWnd, WM_SETFONT, (WPARAM)titleFont, TRUE);
119             SetWindowTextA(hWnd, PACKAGE_NAME);
120         }
121         SetDlgItemTextA(hDlg, IDC_ABT_PANEL_TEXT, PACKAGE_VERSION);
122
123         /* prepare the web link */
124         SetDlgItemTextA(hDlg, IDC_ABT_WEB_LINK, "<a href=\"" PACKAGE_URL "\">" PACKAGE_URL "</a>");
125
126         ReleaseDC(hDlg, hDC);
127
128         break;
129
130     case WM_DESTROY:
131         if(logo)
132         {
133             DestroyIcon(logo);
134             logo = NULL;
135         }
136
137         if(titleFont)
138         {
139             DeleteObject(titleFont);
140             titleFont = NULL;
141         }
142
143         break;
144
145     case WM_COMMAND:
146         switch(HIWORD(wParam))
147         {
148         case EN_CHANGE:
149             /* enable apply button */
150             SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
151             break;
152         }
153         break;
154
155     case WM_DRAWITEM:
156         if(wParam == IDC_ABT_PANEL)
157         {
158             LPDRAWITEMSTRUCT pDIS = (LPDRAWITEMSTRUCT)lParam;
159             FillRect(pDIS->hDC, &pDIS->rcItem, (HBRUSH) (COLOR_WINDOW+1));
160             DrawIconEx(pDIS->hDC, 0, 0, logo, 0, 0, 0, 0, DI_IMAGE);
161             DrawEdge(pDIS->hDC, &pDIS->rcItem, EDGE_SUNKEN, BF_BOTTOM);
162         }
163         break;
164
165     case WM_CTLCOLORSTATIC:
166         switch(GetDlgCtrlID((HWND)lParam))
167         {
168         case IDC_ABT_TITLE_TEXT:
169             /* set the title to a wine color */
170             SetTextColor((HDC)wParam, 0x0000007F);
171         case IDC_ABT_PANEL_TEXT:
172         case IDC_ABT_LICENSE_TEXT:
173         case IDC_ABT_WEB_LINK:
174             return (INT_PTR)CreateSolidBrush(GetSysColor(COLOR_WINDOW));
175         }
176         break;
177     }
178
179     return FALSE;
180 }