Commit 4c3980da authored by Alexander Nicolaysen Sørnes's avatar Alexander Nicolaysen Sørnes Committed by Alexandre Julliard

wordpad: Add font dialog.

parent 58b09f02
...@@ -73,6 +73,7 @@ BEGIN ...@@ -73,6 +73,7 @@ BEGIN
END END
POPUP "F&ormat" POPUP "F&ormat"
BEGIN BEGIN
MENUITEM "&Font . . .", ID_FONTSETTINGS
MENUITEM "&Bullet points" ID_BULLET MENUITEM "&Bullet points" ID_BULLET
MENUITEM "&Paragraph . . ." ID_PARAFORMAT MENUITEM "&Paragraph . . ." ID_PARAFORMAT
MENUITEM "&Tabs . . ." ID_TABSTOPS MENUITEM "&Tabs . . ." ID_TABSTOPS
......
...@@ -73,6 +73,7 @@ BEGIN ...@@ -73,6 +73,7 @@ BEGIN
END END
POPUP "F&ormat" POPUP "F&ormat"
BEGIN BEGIN
MENUITEM "&Font . . .", ID_FONTSETTINGS
MENUITEM "&Bullet points" ID_BULLET MENUITEM "&Bullet points" ID_BULLET
MENUITEM "&Paragraph . . ." ID_PARAFORMAT MENUITEM "&Paragraph . . ." ID_PARAFORMAT
MENUITEM "&Tabs . . ." ID_TABSTOPS MENUITEM "&Tabs . . ." ID_TABSTOPS
......
...@@ -73,6 +73,7 @@ BEGIN ...@@ -73,6 +73,7 @@ BEGIN
END END
POPUP "Forma&t" POPUP "Forma&t"
BEGIN BEGIN
MENUITEM "&Font . . .", ID_FONTSETTINGS
MENUITEM "&Bullet points" ID_BULLET MENUITEM "&Bullet points" ID_BULLET
MENUITEM "&Paragraph . . ." ID_PARAFORMAT MENUITEM "&Paragraph . . ." ID_PARAFORMAT
MENUITEM "&Tabs . . ." ID_TABSTOPS MENUITEM "&Tabs . . ." ID_TABSTOPS
......
...@@ -73,6 +73,7 @@ BEGIN ...@@ -73,6 +73,7 @@ BEGIN
END END
POPUP "F&ormtum" POPUP "F&ormtum"
BEGIN BEGIN
MENUITEM "&Font . . .", ID_FONTSETTINGS
MENUITEM "&Bullet points" ID_BULLET MENUITEM "&Bullet points" ID_BULLET
MENUITEM "&Paragraph . . ." ID_PARAFORMAT MENUITEM "&Paragraph . . ." ID_PARAFORMAT
MENUITEM "&Tabs . . ." ID_TABSTOPS MENUITEM "&Tabs . . ." ID_TABSTOPS
......
...@@ -75,6 +75,7 @@ BEGIN ...@@ -75,6 +75,7 @@ BEGIN
POPUP "형식(&O)" POPUP "형식(&O)"
BEGIN BEGIN
MENUITEM " 강조 점(&U)" ID_BULLET MENUITEM " 강조 점(&U)" ID_BULLET
MENUITEM "&Font . . .", ID_FONTSETTINGS
MENUITEM "&Paragraph . . ." ID_PARAFORMAT MENUITEM "&Paragraph . . ." ID_PARAFORMAT
MENUITEM "&Tabs . . ." ID_TABSTOPS MENUITEM "&Tabs . . ." ID_TABSTOPS
POPUP "배경(&B)" POPUP "배경(&B)"
......
...@@ -73,6 +73,7 @@ BEGIN ...@@ -73,6 +73,7 @@ BEGIN
END END
POPUP "&Opmaak" POPUP "&Opmaak"
BEGIN BEGIN
MENUITEM "&Font . . .", ID_FONTSETTINGS
MENUITEM "&Bullet points" ID_BULLET MENUITEM "&Bullet points" ID_BULLET
MENUITEM "&Paragraph . . ." ID_PARAFORMAT MENUITEM "&Paragraph . . ." ID_PARAFORMAT
MENUITEM "&Tabs . . ." ID_TABSTOPS MENUITEM "&Tabs . . ." ID_TABSTOPS
......
...@@ -73,6 +73,7 @@ BEGIN ...@@ -73,6 +73,7 @@ BEGIN
END END
POPUP "F&ormat" POPUP "F&ormat"
BEGIN BEGIN
MENUITEM "&Skrift . . .", ID_FONTSETTINGS
MENUITEM "&Punktmerking" ID_BULLET MENUITEM "&Punktmerking" ID_BULLET
MENUITEM "&Avsnitt . . ." ID_PARAFORMAT MENUITEM "&Avsnitt . . ." ID_PARAFORMAT
MENUITEM "&Tabulatorer . . ." ID_TABSTOPS MENUITEM "&Tabulatorer . . ." ID_TABSTOPS
......
...@@ -74,6 +74,7 @@ BEGIN ...@@ -74,6 +74,7 @@ BEGIN
END END
POPUP "F&ormat" POPUP "F&ormat"
BEGIN BEGIN
MENUITEM "&Font . . .", ID_FONTSETTINGS
MENUITEM "&Bullet points" ID_BULLET MENUITEM "&Bullet points" ID_BULLET
MENUITEM "&Paragraph . . ." ID_PARAFORMAT MENUITEM "&Paragraph . . ." ID_PARAFORMAT
MENUITEM "Tab&s . . ." ID_TABSTOPS MENUITEM "Tab&s . . ." ID_TABSTOPS
......
...@@ -72,6 +72,7 @@ BEGIN ...@@ -72,6 +72,7 @@ BEGIN
END END
POPUP "&" POPUP "&"
BEGIN BEGIN
MENUITEM "&Font . . .", ID_FONTSETTINGS
MENUITEM "B&ullet points" ID_BULLET MENUITEM "B&ullet points" ID_BULLET
MENUITEM "&Paragraph . . ." ID_PARAFORMAT MENUITEM "&Paragraph . . ." ID_PARAFORMAT
MENUITEM "&Tabs . . ." ID_TABSTOPS MENUITEM "&Tabs . . ." ID_TABSTOPS
......
...@@ -76,6 +76,7 @@ BEGIN ...@@ -76,6 +76,7 @@ BEGIN
END END
POPUP "&Biim" POPUP "&Biim"
BEGIN BEGIN
MENUITEM "&Font . . .", ID_FONTSETTINGS
MENUITEM "&Bullet points" ID_BULLET MENUITEM "&Bullet points" ID_BULLET
MENUITEM "&Paragraph . . ." ID_PARAFORMAT MENUITEM "&Paragraph . . ." ID_PARAFORMAT
MENUITEM "&Tabs . . ." ID_TABSTOPS MENUITEM "&Tabs . . ." ID_TABSTOPS
......
...@@ -63,6 +63,8 @@ ...@@ -63,6 +63,8 @@
#define ID_EDIT_CLEAR 1313 #define ID_EDIT_CLEAR 1313
#define ID_BULLET 1314 #define ID_BULLET 1314
#define ID_FONTSETTINGS 1315
#define ID_FORMAT_BOLD 1400 #define ID_FORMAT_BOLD 1400
#define ID_FORMAT_ITALIC 1401 #define ID_FORMAT_ITALIC 1401
#define ID_FORMAT_UNDERLINE 1402 #define ID_FORMAT_UNDERLINE 1402
......
...@@ -719,6 +719,8 @@ static void set_font(LPCWSTR wszFaceName) ...@@ -719,6 +719,8 @@ static void set_font(LPCWSTR wszFaceName)
{ {
HWND hReBarWnd = GetDlgItem(hMainWnd, IDC_REBAR); HWND hReBarWnd = GetDlgItem(hMainWnd, IDC_REBAR);
HWND hSizeListWnd = GetDlgItem(hReBarWnd, IDC_SIZELIST); HWND hSizeListWnd = GetDlgItem(hReBarWnd, IDC_SIZELIST);
HWND hFontListWnd = GetDlgItem(hReBarWnd, IDC_FONTLIST);
HWND hFontListEditWnd = (HWND)SendMessageW(hFontListWnd, CBEM_GETEDITCONTROL, 0, 0);
CHARFORMAT2W fmt; CHARFORMAT2W fmt;
ZeroMemory(&fmt, sizeof(fmt)); ZeroMemory(&fmt, sizeof(fmt));
...@@ -731,6 +733,8 @@ static void set_font(LPCWSTR wszFaceName) ...@@ -731,6 +733,8 @@ static void set_font(LPCWSTR wszFaceName)
SendMessageW(hEditorWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt); SendMessageW(hEditorWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt);
populate_size_list(hSizeListWnd); populate_size_list(hSizeListWnd);
SendMessageW(hFontListEditWnd, WM_SETTEXT, 0, (LPARAM)(LPWSTR)wszFaceName);
} }
static void set_default_font(void) static void set_default_font(void)
...@@ -785,8 +789,48 @@ static void add_font(LPWSTR fontName, DWORD fontType, HWND hListWnd, NEWTEXTMETR ...@@ -785,8 +789,48 @@ static void add_font(LPWSTR fontName, DWORD fontType, HWND hListWnd, NEWTEXTMETR
SendMessageW(hListWnd, CBEM_INSERTITEMW, 0, (LPARAM)&cbItem); SendMessageW(hListWnd, CBEM_INSERTITEMW, 0, (LPARAM)&cbItem);
} }
static void dialog_choose_font(void)
{
CHOOSEFONTW cf;
LOGFONTW lf;
CHARFORMAT2W fmt;
HDC hDC = GetDC(hMainWnd);
ZeroMemory(&cf, sizeof(cf));
cf.lStructSize = sizeof(cf);
cf.hwndOwner = hMainWnd;
cf.lpLogFont = &lf;
cf.Flags = CF_SCREENFONTS | CF_NOSCRIPTSEL | CF_INITTOLOGFONTSTRUCT;
ZeroMemory(&fmt, sizeof(fmt));
fmt.cbSize = sizeof(fmt);
SendMessageW(hEditorWnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt);
lstrcpyW(cf.lpLogFont->lfFaceName, fmt.szFaceName);
cf.lpLogFont->lfItalic = (fmt.dwEffects & CFE_ITALIC) ? TRUE : FALSE;
cf.lpLogFont->lfWeight = (fmt.dwEffects & CFE_BOLD) ? FW_BOLD : FW_NORMAL;
cf.lpLogFont->lfHeight = -MulDiv(fmt.yHeight / 20, GetDeviceCaps(hDC, LOGPIXELSY), 72);
if(ChooseFontW(&cf))
{
ZeroMemory(&fmt, sizeof(fmt));
fmt.cbSize = sizeof(fmt);
fmt.dwMask = CFM_BOLD | CFM_ITALIC | CFM_SIZE;
fmt.yHeight = cf.iPointSize * 2;
if(cf.nFontType & BOLD_FONTTYPE)
fmt.dwEffects |= CFE_BOLD;
if(cf.nFontType & ITALIC_FONTTYPE)
fmt.dwEffects |= CFE_ITALIC;
SendMessageW(hEditorWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt);
set_font(cf.lpLogFont->lfFaceName);
}
}
int CALLBACK enum_font_proc(const LOGFONTW *lpelfe, const TEXTMETRICW *lpntme, int CALLBACK enum_font_proc(const LOGFONTW *lpelfe, const TEXTMETRICW *lpntme,
DWORD FontType, LPARAM lParam) DWORD FontType, LPARAM lParam)
{ {
HWND hListWnd = (HWND) lParam; HWND hListWnd = (HWND) lParam;
...@@ -2670,6 +2714,10 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) ...@@ -2670,6 +2714,10 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
handle_findmsg(&findreplace); handle_findmsg(&findreplace);
break; break;
case ID_FONTSETTINGS:
dialog_choose_font();
break;
case ID_PRINT: case ID_PRINT:
dialog_print(); dialog_print();
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment