Index: base/applications/fontview/display.c =================================================================== --- base/applications/fontview/display.c (revision 55287) +++ base/applications/fontview/display.c (working copy) @@ -224,7 +224,7 @@ /* Create data structure */ pData = malloc(sizeof(DISPLAYDATA)); ZeroMemory(pData, sizeof(DISPLAYDATA)); - + /* Set the window's GWLP_USERDATA to our data structure */ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pData); @@ -377,6 +377,91 @@ return 0; } +LRESULT +Display_OnPrint(HWND hwnd) +{ + PRINTDLG pfont; + TEXTMETRIC tm; + int copies, currentPage; + int numlines, yPos; + + + /* Clears the memory before using it */ + ZeroMemory(&pfont, sizeof(pfont)); + + pfont.lStructSize = sizeof(pfont); + pfont.hwndOwner = hwnd; + pfont.hDevMode = NULL; + pfont.hDevNames = NULL; + pfont.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC; + pfont.nCopies = 1; + pfont.nFromPage = 0xFFFF; + pfont.nToPage = 0xFFFF; + pfont.nMinPage = 1; + pfont.nMaxPage = 0xFFFF; + + if(PrintDlg(&pfont)) + { + DOCINFO docinfo; + + docinfo.cbSize = sizeof(DOCINFO); + docinfo.lpszDocName = "Printing Font"; + docinfo.lpszOutput = NULL; + docinfo.lpszDatatype = NULL; + docinfo.fwType = 0; + + /* We start printing */ + StartDoc(pfont.hDC, &docinfo); + + /* Grabs the text metrics for the printer */ + GetTextMetrics(pfont.hDC, &tm); + + /* Find the amount of lines needed per page */ + numlines = GetDeviceCaps(pfont.hDC, VERTRES); + numlines = numlines / (tm.tmHeight + tm.tmExternalLeading); + + /* Start out with 0 for the y position for the text */ + yPos = 0; + + /* Used to determine the current page number */ + currentPage = 0; + + /* Used when printing for more than one copy */ + for(copies = 0; copies < pfont.nCopies; copies++) + { + /* Now we actually print out the information */ + TextOutW(pfont.hDC, 10, yPos, L"Font:", 5); + yPos = yPos + tm.tmHeight + tm.tmExternalLeading; + + /* TODO: Add in text for test information */ + + /* Switch to the next page */ + currentPage++; + + /* If we've reached the end of the page, then start a new page */ + if(numlines == currentPage) + { + EndPage(pfont.hDC); + currentPage = 0; + yPos = 0; + StartPage(pfont.hDC); + } + } + + /* Closes the page since there is nothing else to print */ + EndPage(pfont.hDC); + + /* The printing is now over */ + EndDoc(pfont.hDC); + + DeleteDC(pfont.hDC); + } else { + return -1; + } + + return 0; +} + LRESULT CALLBACK DisplayProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { Index: base/applications/fontview/display.h =================================================================== --- base/applications/fontview/display.h (revision 55287) +++ base/applications/fontview/display.h (working copy) @@ -13,3 +13,4 @@ /* Public function */ BOOL Display_InitClass(HINSTANCE hInstance); +LRESULT Display_OnPrint(HWND hwnd); \ No newline at end of file Index: base/applications/fontview/fontview.c =================================================================== --- base/applications/fontview/fontview.c (revision 55287) +++ base/applications/fontview/fontview.c (working copy) @@ -92,21 +92,55 @@ WNDCLASSEXW wincl; HINSTANCE hDLL; PGFRI GetFontResourceInfoW; + LPCWSTR fileName; g_hInstance = hThisInstance; - + /* Get unicode command line */ argv = CommandLineToArgvW(GetCommandLineW(), &argc); if (argc < 2) { - ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_BADCMD, argv[1]); - return -1; + OPENFILENAMEW fontOpen; + WCHAR szFileName[MAX_PATH] = L""; + HLOCAL dialogTitle = NULL; + + /* Gets the title for the dialog box ready */ + FormatString(FORMAT_MESSAGE_ALLOCATE_BUFFER, + NULL, IDS_OPEN, 0, (LPWSTR)&dialogTitle, 0, NULL); + + /* Clears out any values of fontOpen before we use it */ + ZeroMemory(&fontOpen, sizeof(fontOpen)); + + /* Sets up the open dialog box */ + fontOpen.lStructSize = sizeof(fontOpen); + fontOpen.hwndOwner = hMainWnd; + fontOpen.lpstrFilter = L"TrueType Font (*.ttf)\0*.ttf\0" + L"All Files (*.*)\0*.*\0"; + fontOpen.lpstrFile = szFileName; + fontOpen.lpstrTitle = dialogTitle; + fontOpen.nMaxFile = MAX_PATH; + fontOpen.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; + fontOpen.lpstrDefExt = L"ttf"; + + /* Opens up the Open File dialog box in order to chose a font file. */ + if(GetOpenFileNameW(&fontOpen)) + { + fileName = fontOpen.lpstrFile; + } else { + /* If the user decides to close out of the open dialog effectively + exiting the program altogether */ + return 0; + } } - - /* Try to add the font resource */ - if (!AddFontResourceW(argv[1])) + else { - ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]); + /* Try to add the font resource from command line */ + fileName = argv[1]; + } + + if (!AddFontResourceW(fileName)) + { + ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, fileName); return -1; } @@ -116,16 +150,16 @@ /* Get the font name */ dwSize = sizeof(g_ExtLogFontW.elfFullName); - if (!GetFontResourceInfoW(argv[1], &dwSize, g_ExtLogFontW.elfFullName, 1)) + if (!GetFontResourceInfoW(fileName, &dwSize, g_ExtLogFontW.elfFullName, 1)) { - ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]); + ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, fileName); return -1; } dwSize = sizeof(LOGFONTW); - if (!GetFontResourceInfoW(argv[1], &dwSize, &g_ExtLogFontW.elfLogFont, 2)) + if (!GetFontResourceInfoW(fileName, &dwSize, &g_ExtLogFontW.elfLogFont, 2)) { - ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]); + ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, fileName); return -1; } @@ -290,13 +324,13 @@ { case WM_CREATE: return MainWnd_OnCreate(hwnd); - + break; case WM_PAINT: return MainWnd_OnPaint(hwnd); - + break; case WM_SIZE: return MainWnd_OnSize(hwnd); - + break; case WM_COMMAND: switch(LOWORD(wParam)) { @@ -305,7 +339,7 @@ break; case IDC_PRINT: - MessageBox(hwnd, TEXT("This function is unimplemented"), TEXT("Unimplemented"), MB_OK); + return Display_OnPrint(hwnd); break; } break; @@ -316,6 +350,7 @@ default: /* for messages that we don't deal with */ return DefWindowProcW(hwnd, message, wParam, lParam); + break; } return 0; Index: base/applications/fontview/fontview.rbuild =================================================================== --- base/applications/fontview/fontview.rbuild (revision 55287) +++ base/applications/fontview/fontview.rbuild (working copy) @@ -3,6 +3,7 @@ . gdi32 + comdlg32 user32 shell32 fontview.c Index: base/applications/fontview/lang/bg-BG.rc =================================================================== --- base/applications/fontview/lang/bg-BG.rc (revision 55287) +++ base/applications/fontview/lang/bg-BG.rc (working copy) @@ -5,6 +5,7 @@ IDS_QUIT, "Изход" IDS_PRINT, "Печат" IDS_STRING, "Абвгд ежзий клмно прсту фхцчш щъьюя. 1234567890" + IDS_OPEN, "Open Font..." IDS_ERROR, "Грешка" IDS_ERROR_NOMEM, "Няма достатъчно място за завършване на действието." IDS_ERROR_NOFONT, "%1 не е редовен шрифтов файл." Index: base/applications/fontview/lang/de-DE.rc =================================================================== --- base/applications/fontview/lang/de-DE.rc (revision 55287) +++ base/applications/fontview/lang/de-DE.rc (working copy) @@ -5,6 +5,7 @@ IDS_QUIT, "Fertig" IDS_PRINT, "Drucken" IDS_STRING, "Franz jagt im komplett verwahrlosten Taxi quer durch Bayern. 1234567890" + IDS_OPEN, "Open Font..." IDS_ERROR, "Fehler" IDS_ERROR_NOMEM, "Es steht nicht genügend Speicher zur Verfügung." IDS_ERROR_NOFONT, "Die angegebene Datei %1 ist keine gültige Schriftartendatei." Index: base/applications/fontview/lang/en-US.rc =================================================================== --- base/applications/fontview/lang/en-US.rc (revision 55287) +++ base/applications/fontview/lang/en-US.rc (working copy) @@ -5,6 +5,7 @@ IDS_QUIT, "Quit" IDS_PRINT, "Print" IDS_STRING, "Jackdaws love my big sphinx of quartz. 1234567890" + IDS_OPEN, "Open Font..." IDS_ERROR, "Error" IDS_ERROR_NOMEM, "There's not enough memory to complete the operation." IDS_ERROR_NOFONT, "The file %1 is not a valid font file." Index: base/applications/fontview/lang/es-ES.rc =================================================================== --- base/applications/fontview/lang/es-ES.rc (revision 55287) +++ base/applications/fontview/lang/es-ES.rc (working copy) @@ -9,6 +9,7 @@ IDS_QUIT, "Cerrar" IDS_PRINT, "Imprimir" IDS_STRING, "Haz el amor y no la guerra. 1234567890" + IDS_OPEN, "Open Font..." IDS_ERROR, "Error" IDS_ERROR_NOMEM, "No hay memoria suficiente para completar la operación." IDS_ERROR_NOFONT, "El archivo %1 no es un archivo válido de fuente." Index: base/applications/fontview/lang/fr-FR.rc =================================================================== --- base/applications/fontview/lang/fr-FR.rc (revision 55287) +++ base/applications/fontview/lang/fr-FR.rc (working copy) @@ -5,6 +5,7 @@ IDS_QUIT, "Quitter" IDS_PRINT, "Imprimer" IDS_STRING, "Voix ambiguë d'un cśur qui au zéphyr préfčre les jattes de kiwis. 1234567890" + IDS_OPEN, "Open Font..." IDS_ERROR, "Erreur" IDS_ERROR_NOMEM, "Mémoire insuffisante pour terminer l'opération." IDS_ERROR_NOFONT, "Le fichier %1 n'est pas un fichier police valide." Index: base/applications/fontview/lang/lt-LT.rc =================================================================== --- base/applications/fontview/lang/lt-LT.rc (revision 55287) +++ base/applications/fontview/lang/lt-LT.rc (working copy) @@ -7,6 +7,7 @@ IDS_QUIT, "Baigti" IDS_PRINT, "Spausdinti" IDS_STRING, "ABCDEFGHIYJKLMNOPQRSTUVWXZ ąčęėįšųūž 1234567890" + IDS_OPEN, "Open Font..." IDS_ERROR, "Klaida" IDS_ERROR_NOMEM, "Užduočiai užbaigti, nepakanka atminties." IDS_ERROR_NOFONT, "%1 nėra teisinga šrifto byla." Index: base/applications/fontview/lang/no-NO.rc =================================================================== --- base/applications/fontview/lang/no-NO.rc (revision 55287) +++ base/applications/fontview/lang/no-NO.rc (working copy) @@ -5,6 +5,7 @@ IDS_QUIT, "Avslutt" IDS_PRINT, "Skriv" IDS_STRING, "Jackdaws love my big sphinx of quartz. 1234567890" + IDS_OPEN, "Open Font..." IDS_ERROR, "Feil" IDS_ERROR_NOMEM, "Det er ikke nok minne for å fullføre oppgaven." IDS_ERROR_NOFONT, "Filen %1 er ikke et gyldig skriftfil." Index: base/applications/fontview/lang/pl-PL.rc =================================================================== --- base/applications/fontview/lang/pl-PL.rc (revision 55287) +++ base/applications/fontview/lang/pl-PL.rc (working copy) @@ -13,6 +13,7 @@ IDS_QUIT, "Wyjście" IDS_PRINT, "Drukuj" IDS_STRING, "Zażółć gęślą Jaźń żółwiątkiem. 1234567890. !@#$%^&*()_+=-/?" + IDS_OPEN, "Open Font..." IDS_ERROR, "Błąd" IDS_ERROR_NOMEM, "Brakuje pamięci do ukończenia tej operacji." IDS_ERROR_NOFONT, "Plik %1 nie jest poprawnym plikiem czcionki." Index: base/applications/fontview/lang/pt-BR.rc =================================================================== --- base/applications/fontview/lang/pt-BR.rc (revision 55287) +++ base/applications/fontview/lang/pt-BR.rc (working copy) @@ -7,6 +7,7 @@ IDS_QUIT, "Fechar" IDS_PRINT, "Imprimir" IDS_STRING, "Jackdaws ama minha grande esfinge de quartzo. 1234567890" + IDS_OPEN, "Open Font..." IDS_ERROR, "Erro" IDS_ERROR_NOMEM, "Não há memória suficiente para completar a operação." IDS_ERROR_NOFONT, "O arquivo %1 não é um arquivo de fonte válida." Index: base/applications/fontview/lang/ro-RO.rc =================================================================== --- base/applications/fontview/lang/ro-RO.rc (revision 55287) +++ base/applications/fontview/lang/ro-RO.rc (working copy) @@ -6,6 +6,7 @@ IDS_QUIT, "Ieșire" IDS_PRINT, "Imprimare" IDS_STRING, "Turubinele eoliene generează câțiva MJ (câțiva kW•h) în exces, acoperind și necesarul familiei. QY 1234567890" + IDS_OPEN, "Open Font..." IDS_ERROR, "Eroare" IDS_ERROR_NOMEM, "Nu e destulă memorie pentru a încheia operația." IDS_ERROR_NOFONT, "Fișierul „%1” este un fișier font deteriorat." Index: base/applications/fontview/lang/ru-RU.rc =================================================================== --- base/applications/fontview/lang/ru-RU.rc (revision 55287) +++ base/applications/fontview/lang/ru-RU.rc (working copy) @@ -7,6 +7,7 @@ IDS_QUIT, "Выход" IDS_PRINT, "Печать" IDS_STRING, "В чащах юга жил бы цитрус? Да, но фальшивый экземпляр! 1234567890" + IDS_OPEN, "Open Font..." IDS_ERROR, "Ошибка" IDS_ERROR_NOMEM, "Недостаточно памяти, чтобы завершить операцию." IDS_ERROR_NOFONT, "%1 не является корректным файлом шрифта." Index: base/applications/fontview/lang/sk-SK.rc =================================================================== --- base/applications/fontview/lang/sk-SK.rc (revision 55287) +++ base/applications/fontview/lang/sk-SK.rc (working copy) @@ -10,6 +10,7 @@ IDS_QUIT, "Hotovo" IDS_PRINT, "Tlačiť" IDS_STRING, "Kŕdeľ ďatľov učí koňa žrať kôru. 1234567890" + IDS_OPEN, "Open Font..." IDS_ERROR, "Chyba" IDS_ERROR_NOMEM, "Na vykonanie tejto operácie nie je dostatok voľnej pamäte." IDS_ERROR_NOFONT, "Požadovaný súbor %1 nie je platným súborom písiem." Index: base/applications/fontview/lang/sv-SE.rc =================================================================== --- base/applications/fontview/lang/sv-SE.rc (revision 55287) +++ base/applications/fontview/lang/sv-SE.rc (working copy) @@ -12,6 +12,7 @@ IDS_QUIT, "Avsluta" IDS_PRINT, "Skriv ut" IDS_STRING, "Jackdaws love my big sphinx of quartz. 1234567890" + IDS_OPEN, "Open Font..." IDS_ERROR, "Fel" IDS_ERROR_NOMEM, "Det er inte nog minne för att slutföre operationen." IDS_ERROR_NOFONT, "Filen %1 är inte en giltig typsnittsfil." Index: base/applications/fontview/lang/uk-UA.rc =================================================================== --- base/applications/fontview/lang/uk-UA.rc (revision 55287) +++ base/applications/fontview/lang/uk-UA.rc (working copy) @@ -13,6 +13,7 @@ IDS_QUIT, "Вихід" IDS_PRINT, "Друк" IDS_STRING, "Чуєш їх, доцю, га? Кумедна ж ти, прощайся без ґольфів! 1234567890" + IDS_OPEN, "Open Font..." IDS_ERROR, "Помилка" IDS_ERROR_NOMEM, "Недостатньо пам'яті для завершення операції." IDS_ERROR_NOFONT, "Файл %1 не є коректним файлом шрифту." Index: base/applications/fontview/lang/zh-CN.rc =================================================================== --- base/applications/fontview/lang/zh-CN.rc (revision 55287) +++ base/applications/fontview/lang/zh-CN.rc (working copy) @@ -13,6 +13,7 @@ IDS_QUIT, "结束" IDS_PRINT, "列印" IDS_STRING, "ReactOS 给所有人一个自由的操作系统!1234567890" + IDS_OPEN, "Open Font..." IDS_ERROR, "错误" IDS_ERROR_NOMEM, "没有足够的内存来完成操作。" IDS_ERROR_NOFONT, "%1不是一个有效的字体档案。" Index: base/applications/fontview/lang/zh-TW.rc =================================================================== --- base/applications/fontview/lang/zh-TW.rc (revision 55287) +++ base/applications/fontview/lang/zh-TW.rc (working copy) @@ -13,6 +13,7 @@ IDS_QUIT, "結束" IDS_PRINT, "列印" IDS_STRING, "ReactOS 給所有人一個自由的操作系統! 1234567890" + IDS_OPEN, "Open Font..." IDS_ERROR, "錯誤" IDS_ERROR_NOMEM, "沒有足夠的記憶體來完成操作。" IDS_ERROR_NOFONT, "%1 不是一個有效的字體檔案。" Index: base/applications/fontview/resource.h =================================================================== --- base/applications/fontview/resource.h (revision 55287) +++ base/applications/fontview/resource.h (working copy) @@ -8,6 +8,7 @@ #define IDS_QUIT 500 #define IDS_PRINT 501 #define IDS_STRING 502 +#define IDS_OPEN 503 #define IDS_CHARSLOWER 700 #define IDS_CHARSUPPER 701