Commit 61876c72 authored by Alexander Nicolaysen Sørnes's avatar Alexander Nicolaysen Sørnes Committed by Alexandre Julliard

wordpad: Add initial printing support.

parent 695a94f1
......@@ -27,6 +27,8 @@ BEGIN
MENUITEM "&Speichern\tCtrl+S", ID_FILE_SAVE
MENUITEM "Speichern &unter...", ID_FILE_SAVEAS
MENUITEM SEPARATOR
MENUITEM "&Print . . .\tCtrl+P", ID_PRINT
MENUITEM SEPARATOR
MENUITEM "&Beenden", ID_FILE_EXIT
END
POPUP "&Bearbeiten"
......@@ -156,7 +158,12 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
STRING_PRINTER_FILES_PRN, "Printer files (*.PRN)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
END
STRINGTABLE DISCARDABLE
......
......@@ -27,6 +27,8 @@ BEGIN
MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE
MENUITEM "Save &as . . .", ID_FILE_SAVEAS
MENUITEM SEPARATOR
MENUITEM "&Print . . .\tCtrl+P", ID_PRINT
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_FILE_EXIT
END
POPUP "&Edit"
......@@ -157,7 +159,12 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
STRING_PRINTER_FILES_PRN, "Printer files (*.PRN)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
END
STRINGTABLE DISCARDABLE
......
......@@ -27,6 +27,8 @@ BEGIN
MENUITEM "&Enregistrer\tCtrl+S", ID_FILE_SAVE
MENUITEM "Enregistrer &sous...", ID_FILE_SAVEAS
MENUITEM SEPARATOR
MENUITEM "&Print . . .\tCtrl+P", ID_PRINT
MENUITEM SEPARATOR
MENUITEM "&Quitter", ID_FILE_EXIT
END
POPUP "&dition"
......@@ -156,7 +158,12 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
STRING_PRINTER_FILES_PRN, "Printer files (*.PRN)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
END
STRINGTABLE DISCARDABLE
......
......@@ -27,6 +27,8 @@ BEGIN
MENUITEM "M&ents\tCtrl+S", ID_FILE_SAVE
MENUITEM "Ments m&sknt...", ID_FILE_SAVEAS
MENUITEM SEPARATOR
MENUITEM "&Print . . .\tCtrl+P", ID_PRINT
MENUITEM SEPARATOR
MENUITEM "&Kilps", ID_FILE_EXIT
END
POPUP "Sz&erkeszts"
......@@ -156,7 +158,12 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
STRING_PRINTER_FILES_PRN, "Printer files (*.PRN)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
END
STRINGTABLE DISCARDABLE
......
......@@ -28,6 +28,8 @@ BEGIN
MENUITEM "저장(&S)\tCtrl+S", ID_FILE_SAVE
MENUITEM "다른 이름으로 저장(&A)...", ID_FILE_SAVEAS
MENUITEM SEPARATOR
MENUITEM "&Print . . .\tCtrl+P", ID_PRINT
MENUITEM SEPARATOR
MENUITEM "나가기(&X)", ID_FILE_EXIT
END
POPUP "편집(&E)"
......@@ -143,14 +145,19 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
STRING_ALIGN_LEFT, "Left"
STRING_ALIGN_RIGHT, "Right"
STRING_ALIGN_CENTER, "Center"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_ALIGN_LEFT, "Left"
STRING_ALIGN_RIGHT, "Right"
STRING_ALIGN_CENTER, "Center"
STRING_PRINTER_FILES_PRN, "Printer files (*.PRN)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
END
STRINGTABLE DISCARDABLE
......
......@@ -27,6 +27,8 @@ BEGIN
MENUITEM "O&pslaan\tCtrl+S", ID_FILE_SAVE
MENUITEM "Ops&laan als...", ID_FILE_SAVEAS
MENUITEM SEPARATOR
MENUITEM "&Print . . .\tCtrl+P", ID_PRINT
MENUITEM SEPARATOR
MENUITEM "&Afsluiten", ID_FILE_EXIT
END
POPUP "Be&werken"
......@@ -156,7 +158,12 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
STRING_PRINTER_FILES_PRN, "Printer files (*.PRN)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
END
STRINGTABLE DISCARDABLE
......
......@@ -27,6 +27,8 @@ BEGIN
MENUITEM "&Lagre\tCtrl+S", ID_FILE_SAVE
MENUITEM "Lagre &som . . .", ID_FILE_SAVEAS
MENUITEM SEPARATOR
MENUITEM "&Skriv ut . . .\tCtrl+P", ID_PRINT
MENUITEM SEPARATOR
MENUITEM "&Avslutt", ID_FILE_EXIT
END
POPUP "R&ediger"
......@@ -156,6 +158,11 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_PRINTER_FILES_PRN, "Skriverfiler (*.PRN)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
END
......
......@@ -28,6 +28,8 @@ BEGIN
MENUITEM "&Zapisz\tCtrl+S", ID_FILE_SAVE
MENUITEM "Z&apisz jako...", ID_FILE_SAVEAS
MENUITEM SEPARATOR
MENUITEM "&Print . . .\tCtrl+P", ID_PRINT
MENUITEM SEPARATOR
MENUITEM "Za&kocz", ID_FILE_EXIT
END
POPUP "&Edycja"
......@@ -157,7 +159,12 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
STRING_PRINTER_FILES_PRN, "Printer files (*.PRN)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
END
STRINGTABLE DISCARDABLE
......
......@@ -27,6 +27,8 @@ BEGIN
MENUITEM "&\tCtrl+S", ID_FILE_SAVE
MENUITEM " &...", ID_FILE_SAVEAS
MENUITEM SEPARATOR
MENUITEM "&Print . . .\tCtrl+P", ID_PRINT
MENUITEM SEPARATOR
MENUITEM "&", ID_FILE_EXIT
END
POPUP "&"
......@@ -154,7 +156,12 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
STRING_PRINTER_FILES_PRN, "Printer files (*.PRN)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
END
STRINGTABLE DISCARDABLE
......
......@@ -29,6 +29,8 @@ BEGIN
MENUITEM "&Kaydet\tCtrl+S", ID_FILE_SAVE
MENUITEM "&Farkl Kaydet...", ID_FILE_SAVEAS
MENUITEM SEPARATOR
MENUITEM "&Print . . .\tCtrl+P", ID_PRINT
MENUITEM SEPARATOR
MENUITEM "&k", ID_FILE_EXIT
END
POPUP "&Dzen"
......@@ -158,7 +160,12 @@ END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
STRING_PRINTER_FILES_PRN, "Printer files (*.PRN)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_UNITS_CM, "cm"
END
STRINGTABLE DISCARDABLE
......
......@@ -120,7 +120,9 @@
#define STRING_ALIGN_RIGHT 1408
#define STRING_ALIGN_CENTER 1409
#define STRING_UNITS_CM 1410
#define STRING_PRINTER_FILES_PRN 1410
#define STRING_UNITS_CM 1411
#define STRING_DEFAULT_FILENAME 1700
#define STRING_PROMPT_SAVE_CHANGES 1701
......
......@@ -41,6 +41,7 @@ BEGIN
"N", ID_FILE_NEW, VIRTKEY, CONTROL
"O", ID_FILE_OPEN, VIRTKEY, CONTROL
"S", ID_FILE_SAVE, VIRTKEY, CONTROL
"P", ID_PRINT, VIRTKEY, CONTROL
END
/* BINRES toolbar.bmp */
......
......@@ -68,6 +68,7 @@ static UINT ID_FINDMSGSTRING;
static WCHAR wszFilter[MAX_STRING_LEN*4+6*3+5];
static WCHAR wszDefaultFileName[MAX_STRING_LEN];
static WCHAR wszSaveChanges[MAX_STRING_LEN];
static WCHAR wszPrintFilter[MAX_STRING_LEN*2+6+4+1];
static WCHAR units_cmW[MAX_STRING_LEN];
static char units_cmA[MAX_STRING_LEN];
......@@ -81,6 +82,7 @@ static void DoLoadStrings(void)
static const WCHAR files_rtf[] = {'*','.','r','t','f','\0'};
static const WCHAR files_txt[] = {'*','.','t','x','t','\0'};
static const WCHAR files_all[] = {'*','.','*','\0'};
static const WCHAR files_prn[] = {'*','.','P','R','N',0};
HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hMainWnd, GWLP_HINSTANCE);
LoadStringW(hInstance, STRING_RICHTEXT_FILES_RTF, p, MAX_STRING_LEN);
......@@ -101,6 +103,17 @@ static void DoLoadStrings(void)
p += lstrlenW(p) + 1;
*p = '\0';
p = wszPrintFilter;
LoadStringW(hInstance, STRING_PRINTER_FILES_PRN, p, MAX_STRING_LEN);
p += lstrlenW(p) + 1;
lstrcpyW(p, files_prn);
p += lstrlenW(p) + 1;
LoadStringW(hInstance, STRING_ALL_FILES, p, MAX_STRING_LEN);
p += lstrlenW(p) + 1;
lstrcpyW(p, files_all);
p += lstrlenW(p) + 1;
*p = 0;
p = wszDefaultFileName;
LoadStringW(hInstance, STRING_DEFAULT_FILENAME, p, MAX_STRING_LEN);
......@@ -874,6 +887,118 @@ static void DialogOpenFile(void)
}
}
static LPWSTR dialog_print_to_file(void)
{
OPENFILENAMEW ofn;
static WCHAR file[MAX_PATH] = {'O','U','T','P','U','T','.','P','R','N',0};
static const WCHAR defExt[] = {'P','R','N',0};
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
ofn.hwndOwner = hMainWnd;
ofn.lpstrFilter = (LPWSTR)wszPrintFilter;
ofn.lpstrFile = (LPWSTR)file;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = (LPWSTR)defExt;
if(GetSaveFileNameW(&ofn))
return (LPWSTR)file;
else
return FALSE;
}
static LONG devunits_to_twips(int units, int dpi)
{
float ret = ((float)units / (float)dpi) * (float)567 * 2.54;
return (LONG)ret;
}
static void print(LPPRINTDLGW pd)
{
FORMATRANGE fr;
DOCINFOW di;
int dpiY, dpiX, width, height;
fr.hdc = pd->hDC;
fr.hdcTarget = pd->hDC;
dpiY = GetDeviceCaps(fr.hdc, LOGPIXELSY);
dpiX = GetDeviceCaps(fr.hdc, LOGPIXELSX);
width = devunits_to_twips(GetDeviceCaps(fr.hdc, PHYSICALWIDTH), dpiX);
height = devunits_to_twips(GetDeviceCaps(fr.hdc, PHYSICALHEIGHT), dpiY);
fr.rc.left = devunits_to_twips(GetDeviceCaps(fr.hdc, PHYSICALOFFSETX), dpiX);
fr.rc.right = width - (fr.rc.left * 2);
fr.rc.top = devunits_to_twips(GetDeviceCaps(fr.hdc, PHYSICALOFFSETY), dpiY);
fr.rc.bottom = height - (fr.rc.top * 2);
fr.rcPage.left = 0;
fr.rcPage.right = width;
fr.rcPage.top = 0;
fr.rcPage.bottom = height;
ZeroMemory(&di, sizeof(di));
di.cbSize = sizeof(di);
di.lpszDocName = (LPWSTR)wszFileName;
if(pd->Flags & PD_PRINTTOFILE)
{
di.lpszOutput = dialog_print_to_file();
if(!di.lpszOutput)
return;
}
if(pd->Flags & PD_SELECTION)
{
SendMessageW(hEditorWnd, EM_EXGETSEL, 0, (LPARAM)&fr.chrg);
} else
{
GETTEXTLENGTHEX gt;
gt.flags = GTL_DEFAULT;
gt.codepage = 1200;
fr.chrg.cpMin = 0;
fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)&gt, 0);
}
StartDocW(fr.hdc, &di);
do
{
if(StartPage(fr.hdc) <= 0)
break;
fr.chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)&fr);
if(EndPage(fr.hdc) <= 0)
break;
}
while(fr.chrg.cpMin < fr.chrg.cpMax);
EndDoc(fr.hdc);
SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, 0);
}
static void dialog_print(void)
{
PRINTDLGW pd;
int from = 0;
int to = 0;
ZeroMemory(&pd, sizeof(pd));
pd.lStructSize = sizeof(pd);
pd.hwndOwner = hMainWnd;
pd.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE;
pd.nMinPage = 1;
pd.nMaxPage = 1;
SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&from, (LPARAM)&to);
if(from == to)
pd.Flags |= PD_NOSELECTION;
if(PrintDlgW(&pd))
print(&pd);
}
static void HandleCommandLine(LPWSTR cmdline)
{
WCHAR delimiter;
......@@ -1698,6 +1823,9 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
break;
case ID_PRINT:
dialog_print();
break;
case ID_PREVIEW:
{
static const WCHAR wszNotImplemented[] = {'N','o','t',' ',
......
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