Skip to content

Commit e2dfab0

Browse files
committed
[charmap]
- Carlo Bramini: implement a skeleton for the charmap advanced view, Italian translation included - German translation added by myself See issue reactos#6065 for more details. svn path=/trunk/; revision=51537
1 parent 2b77604 commit e2dfab0

26 files changed

+708
-219
lines changed

reactos/base/applications/charmap/charmap.c

Lines changed: 251 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,17 @@
1111

1212
#define ID_ABOUT 0x1
1313

14+
typedef struct {
15+
BOOL IsAdvancedView;
16+
} SETTINGS;
17+
1418
HINSTANCE hInstance;
19+
HWND hCharmapDlg;
20+
HWND hAdvancedDlg;
21+
HWND hStatusWnd;
22+
HICON hSmIcon;
23+
HICON hBgIcon;
24+
SETTINGS Settings;
1525

1626
/* Font-enumeration callback */
1727
static
@@ -226,76 +236,91 @@ AddCharToSelection(HWND hDlg, WCHAR ch)
226236
}
227237

228238

239+
static
240+
void
241+
UpdateSettings(HWND hDlg)
242+
{
243+
if (hDlg == hCharmapDlg)
244+
{
245+
Settings.IsAdvancedView =
246+
SendDlgItemMessage(hDlg, IDC_CHECK_ADVANCED, BM_GETCHECK, 0, 0);
247+
}
248+
249+
if (hDlg == hAdvancedDlg)
250+
{
251+
}
252+
}
253+
254+
static
255+
void
256+
ChangeView(HWND hWnd)
257+
{
258+
RECT rcCharmap;
259+
RECT rcAdvanced;
260+
RECT rcPanelExt;
261+
RECT rcPanelInt;
262+
RECT rcStatus;
263+
UINT DeX, DeY;
264+
UINT xPos, yPos;
265+
UINT Width, Height;
266+
UINT DeskTopWidth, DeskTopHeight;
267+
268+
GetClientRect(hCharmapDlg, &rcCharmap);
269+
GetClientRect(hAdvancedDlg, &rcAdvanced);
270+
GetWindowRect(hWnd, &rcPanelExt);
271+
GetClientRect(hWnd, &rcPanelInt);
272+
GetClientRect(hStatusWnd, &rcStatus);
273+
274+
DeskTopWidth = GetSystemMetrics(SM_CXFULLSCREEN);
275+
DeskTopHeight = GetSystemMetrics(SM_CYFULLSCREEN);
276+
277+
DeX = (rcPanelExt.right - rcPanelExt.left) - rcPanelInt.right;
278+
DeY = (rcPanelExt.bottom - rcPanelExt.top) - rcPanelInt.bottom;
279+
280+
MoveWindow(hCharmapDlg, 0, 0, rcCharmap.right, rcCharmap.bottom, FALSE);
281+
MoveWindow(hAdvancedDlg, 0, rcCharmap.bottom, rcAdvanced.right, rcAdvanced.bottom, FALSE);
282+
283+
ShowWindow(hAdvancedDlg, (Settings.IsAdvancedView) ? SW_SHOW : SW_HIDE);
284+
285+
xPos = rcPanelExt.left;
286+
yPos = rcPanelExt.top;
287+
288+
Width = DeX + rcCharmap.right;
289+
Height = DeY + rcCharmap.bottom + rcStatus.bottom;
290+
291+
if (Settings.IsAdvancedView)
292+
Height += rcAdvanced.bottom;
293+
294+
if ((xPos + Width) > DeskTopWidth)
295+
xPos += DeskTopWidth - (xPos + Width);
296+
297+
if ((yPos + Height) > DeskTopHeight)
298+
yPos += DeskTopHeight - (yPos + Height);
299+
300+
MoveWindow(hWnd,
301+
xPos, yPos,
302+
Width, Height,
303+
TRUE);
304+
}
305+
229306
static
230307
INT_PTR
231308
CALLBACK
232-
DlgProc(HWND hDlg,
233-
UINT Message,
234-
WPARAM wParam,
235-
LPARAM lParam)
309+
CharMapDlgProc(HWND hDlg,
310+
UINT Message,
311+
WPARAM wParam,
312+
LPARAM lParam)
236313
{
237-
static HICON hSmIcon;
238-
static HICON hBgIcon;
239-
LPWSTR lpAboutText = NULL;
240-
241314
switch(Message)
242315
{
243316
case WM_INITDIALOG:
244317
{
245-
HMENU hSysMenu;
246318
DWORD evMask;
247319

248-
hSmIcon = LoadImageW(hInstance,
249-
MAKEINTRESOURCEW(IDI_ICON),
250-
IMAGE_ICON,
251-
16,
252-
16,
253-
0);
254-
if (hSmIcon)
255-
{
256-
SendMessageW(hDlg,
257-
WM_SETICON,
258-
ICON_SMALL,
259-
(LPARAM)hSmIcon);
260-
}
261-
262-
hBgIcon = LoadImageW(hInstance,
263-
MAKEINTRESOURCEW(IDI_ICON),
264-
IMAGE_ICON,
265-
32,
266-
32,
267-
0);
268-
if (hBgIcon)
269-
{
270-
SendMessageW(hDlg,
271-
WM_SETICON,
272-
ICON_BIG,
273-
(LPARAM)hBgIcon);
274-
}
275-
276320
FillFontStyleComboList(GetDlgItem(hDlg,
277321
IDC_FONTCOMBO));
278322

279323
ChangeMapFont(hDlg);
280-
hSysMenu = GetSystemMenu(hDlg,
281-
FALSE);
282-
if (hSysMenu != NULL)
283-
{
284-
if (LoadStringW(hInstance,
285-
IDS_ABOUT,
286-
lpAboutText,
287-
0))
288-
{
289-
AppendMenuW(hSysMenu,
290-
MF_SEPARATOR,
291-
0,
292-
NULL);
293-
AppendMenuW(hSysMenu,
294-
MF_STRING,
295-
ID_ABOUT,
296-
lpAboutText);
297-
}
298-
}
299324

300325
// Configure Richedi control for sending notification changes.
301326
evMask = SendDlgItemMessage(hDlg, IDC_TEXTBOX, EM_GETEVENTMASK, 0, 0);
@@ -344,43 +369,177 @@ DlgProc(HWND hDlg,
344369
CopyCharacters(hDlg);
345370
break;
346371

347-
case IDOK:
348-
if (hSmIcon)
349-
DestroyIcon(hSmIcon);
350-
if (hBgIcon)
351-
DestroyIcon(hBgIcon);
352-
EndDialog(hDlg, 0);
372+
case IDC_CHECK_ADVANCED:
373+
UpdateSettings(hDlg);
374+
ChangeView(GetParent(hDlg));
353375
break;
354376
}
355377
}
356378
break;
357379

358-
case WM_SYSCOMMAND:
380+
default:
381+
break;
382+
}
383+
384+
return FALSE;
385+
}
386+
387+
static
388+
INT_PTR
389+
CALLBACK
390+
AdvancedDlgProc(HWND hDlg,
391+
UINT Message,
392+
WPARAM wParam,
393+
LPARAM lParam)
394+
{
395+
switch(Message)
396+
{
397+
case WM_INITDIALOG:
398+
return TRUE;
399+
400+
default:
401+
return FALSE;
402+
}
403+
404+
return FALSE;
405+
}
406+
407+
static int
408+
OnCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
409+
{
410+
HMENU hSysMenu;
411+
WCHAR lpAboutText[256];
412+
413+
hCharmapDlg = CreateDialog(hInstance,
414+
MAKEINTRESOURCE(IDD_CHARMAP),
415+
hWnd,
416+
CharMapDlgProc);
417+
418+
hAdvancedDlg = CreateDialog(hInstance,
419+
MAKEINTRESOURCE(IDD_ADVANCED),
420+
hWnd,
421+
AdvancedDlgProc);
422+
423+
hStatusWnd = CreateWindow(STATUSCLASSNAME,
424+
NULL,
425+
WS_CHILD | WS_VISIBLE,
426+
0, 0, 0, 0,
427+
hWnd,
428+
(HMENU)IDD_STATUSBAR,
429+
hInstance,
430+
NULL);
431+
432+
// Set the status bar for multiple parts output
433+
SendMessage(hStatusWnd, SB_SIMPLE, (WPARAM)FALSE, (LPARAM)0);
434+
435+
ChangeView(hWnd);
436+
437+
hSysMenu = GetSystemMenu(hWnd, FALSE);
438+
439+
if (hSysMenu != NULL)
440+
{
441+
if (LoadStringW(hInstance, IDS_ABOUT, lpAboutText, SIZEOF(lpAboutText)))
359442
{
360-
switch(wParam)
361-
{
362-
case ID_ABOUT:
363-
ShowAboutDlg(hDlg);
364-
break;
365-
}
443+
AppendMenuW(hSysMenu, MF_SEPARATOR, 0, NULL);
444+
AppendMenuW(hSysMenu, MF_STRING, ID_ABOUT, lpAboutText);
366445
}
446+
}
447+
448+
return 0;
449+
}
450+
451+
static LRESULT CALLBACK
452+
PanelWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
453+
{
454+
switch (msg) {
455+
case WM_CREATE:
456+
return OnCreate(hWnd, wParam, lParam);
457+
458+
case WM_CLOSE:
459+
DestroyWindow(hWnd);
460+
return 0;
461+
462+
case WM_SIZE:
463+
SendMessage(hStatusWnd, msg, wParam, lParam);
367464
break;
368465

369-
case WM_CLOSE:
370-
if (hSmIcon)
371-
DestroyIcon(hSmIcon);
372-
if (hBgIcon)
373-
DestroyIcon(hBgIcon);
374-
EndDialog(hDlg, 0);
466+
case WM_DESTROY:
467+
PostQuitMessage(0);
468+
return 0;
469+
470+
case WM_SYSCOMMAND:
471+
switch(wParam) {
472+
case ID_ABOUT:
473+
ShowAboutDlg(hWnd);
375474
break;
475+
}
476+
break;
376477

377-
default:
378-
return FALSE;
379478
}
380479

381-
return FALSE;
480+
return DefWindowProc(hWnd, msg, wParam, lParam);
382481
}
383482

483+
static HWND
484+
InitInstance(HINSTANCE hInst)
485+
{
486+
WCHAR szClass[] = L"CharMap";
487+
WCHAR szTitle[256];
488+
WNDCLASSEXW wc;
489+
HWND hWnd;
490+
491+
LoadStringW(hInst, IDS_TITLE, szTitle, SIZEOF(szTitle));
492+
493+
hSmIcon = LoadImage(hInstance,
494+
MAKEINTRESOURCE(IDI_ICON),
495+
IMAGE_ICON,
496+
16,
497+
16,
498+
0);
499+
500+
hBgIcon = LoadImage(hInstance,
501+
MAKEINTRESOURCE(IDI_ICON),
502+
IMAGE_ICON,
503+
32,
504+
32,
505+
0);
506+
507+
// Create workspace
508+
ZeroMemory(&wc, sizeof(wc));
509+
510+
wc.cbSize = sizeof(wc);
511+
wc.lpfnWndProc = PanelWndProc;
512+
wc.hInstance = hInst;
513+
wc.hIcon = hBgIcon;
514+
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
515+
wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
516+
wc.lpszMenuName = NULL;
517+
wc.lpszClassName = szClass;
518+
wc.hIconSm = hSmIcon;
519+
520+
RegisterClassExW(&wc);
521+
522+
hWnd = CreateWindowW(
523+
szClass,
524+
szTitle,
525+
WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
526+
CW_USEDEFAULT,
527+
CW_USEDEFAULT,
528+
CW_USEDEFAULT,
529+
CW_USEDEFAULT,
530+
NULL,
531+
NULL,
532+
hInst,
533+
NULL);
534+
535+
if (hWnd != NULL)
536+
{
537+
ShowWindow(hWnd, SW_SHOW);
538+
UpdateWindow(hWnd);
539+
}
540+
541+
return hWnd;
542+
}
384543

385544
INT
386545
WINAPI
@@ -392,6 +551,7 @@ wWinMain(HINSTANCE hInst,
392551
INITCOMMONCONTROLSEX iccx;
393552
INT Ret = 1;
394553
HMODULE hRichEd20;
554+
MSG Msg;
395555

396556
hInstance = hInst;
397557

@@ -405,10 +565,19 @@ wWinMain(HINSTANCE hInst,
405565

406566
if (hRichEd20 != NULL)
407567
{
408-
Ret = DialogBoxW(hInstance,
409-
MAKEINTRESOURCEW(IDD_CHARMAP),
410-
NULL,
411-
DlgProc) >= 0;
568+
InitInstance(hInst);
569+
570+
for (;;)
571+
{
572+
if (GetMessage(&Msg, NULL, 0, 0) <= 0)
573+
{
574+
Ret = Msg.wParam;
575+
break;
576+
}
577+
578+
TranslateMessage(&Msg);
579+
DispatchMessage(&Msg);
580+
}
412581

413582
FreeLibrary(hRichEd20);
414583
}

0 commit comments

Comments
 (0)