LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL
-MAINMENU MENU DISCARDABLE
+IDM_MAINMENU MENU DISCARDABLE
BEGIN
POPUP "&Datei"
BEGIN
"which will cause all formatting to be lost. " \
"Are you sure that you wish to do this?"
STRING_INVALID_NUMBER, "Invalid number format"
+ STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported"
END
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
-MAINMENU MENU DISCARDABLE
+IDM_MAINMENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
"which will cause all formatting to be lost. " \
"Are you sure that you wish to do this?"
STRING_INVALID_NUMBER, "Invalid number format"
+ STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported"
END
/*
- * Copyright 2006 by Jonathan Ernst
+ * Copyright 2006-2007 by Jonathan Ernst
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
-MAINMENU MENU DISCARDABLE
+IDM_MAINMENU MENU DISCARDABLE
BEGIN
POPUP "&Fichier"
BEGIN
MENUITEM "&Enregistrer\tCtrl+S", ID_FILE_SAVE
MENUITEM "Enregistrer &sous...", ID_FILE_SAVEAS
MENUITEM SEPARATOR
- MENUITEM "&Print . . .\tCtrl+P", ID_PRINT
- MENUITEM "Print previe&w . . .", ID_PREVIEW
- MENUITEM "Page setup . . .", ID_PRINTSETUP
+ MENUITEM "&Imprimer...\tCtrl+P", ID_PRINT
+ MENUITEM "A&perçu avant impression...", ID_PREVIEW
+ MENUITEM "&Mise en page...", ID_PRINTSETUP
MENUITEM SEPARATOR
MENUITEM "&Quitter", ID_FILE_EXIT
END
POPUP "É&dition"
BEGIN
MENUITEM "&Annuler\tCtrl+Z", ID_EDIT_UNDO
- MENUITEM "Ré&péter\tCtrl+Y", ID_EDIT_REDO
+ MENUITEM "&Rétablir\tCtrl+Y", ID_EDIT_REDO
MENUITEM SEPARATOR
MENUITEM "&Couper\tCtrl+X", ID_EDIT_CUT
MENUITEM "Co&pier\tCtrl+C", ID_EDIT_COPY
MENUITEM "&Effacer\tDel", ID_EDIT_CLEAR
MENUITEM "&Sélectionner tout\tCtrl+A", ID_EDIT_SELECTALL
MENUITEM SEPARATOR
- MENUITEM "&Find . . .\tCrtl+F", ID_FIND
- MENUITEM "Find &next\tF3", ID_FIND_NEXT
- MENUITEM "&Replace . . .\tCtrl+H", ID_REPLACE
+ MENUITEM "&Rechercher...\tCrtl+F", ID_FIND
+ MENUITEM "Rechercher le &suivant\tF3", ID_FIND_NEXT
+ MENUITEM "&Remplacer...\tCtrl+H", ID_REPLACE
MENUITEM SEPARATOR
MENUITEM "Lecture-&seule", ID_EDIT_READONLY
MENUITEM "&Modifié", ID_EDIT_MODIFIED
MENUITEM "&Barre de format", ID_TOGGLE_FORMATBAR
MENUITEM "&Barre d'état", ID_TOGGLE_STATUSBAR
MENUITEM SEPARATOR
- MENUITEM "&Options . . .", ID_VIEWPROPERTIES
+ MENUITEM "&Options...", ID_VIEWPROPERTIES
END
- POPUP "&Insert"
+ POPUP "&Insertion"
BEGIN
- MENUITEM "&Date and time . . .", ID_DATETIME
+ MENUITEM "&Date et heure...", ID_DATETIME
END
POPUP "Forma&t"
BEGIN
- MENUITEM "&Font . . .", ID_FONTSETTINGS
- MENUITEM "&Bullet points" ID_BULLET
- MENUITEM "&Paragraph . . ." ID_PARAFORMAT
- MENUITEM "&Tabs . . ." ID_TABSTOPS
+ MENUITEM "&Polive...", ID_FONTSETTINGS
+ MENUITEM "&Puces" ID_BULLET
+ MENUITEM "&Paragraphe..." ID_PARAFORMAT
+ MENUITEM "&Tabulations..." ID_TABSTOPS
POPUP "&Fond"
BEGIN
MENUITEM "&Système\tCtrl+1", ID_BACK_1
MENUITEM "&Jaunasse\tCtrl+2", ID_BACK_2
END
END
- POPUP "&Help"
+ POPUP "Aid&e"
BEGIN
- MENUITEM "&About Wine Wordpad" ID_ABOUT
+ MENUITEM "À &propos du Wordpad de Wine" ID_ABOUT
END
END
MENUITEM "Co&pier", ID_EDIT_COPY
MENUITEM "C&oller", ID_EDIT_PASTE
MENUITEM SEPARATOR
- MENUITEM "&Bullet points" ID_BULLET
- MENUITEM "&Paragraph . . ." ID_PARAFORMAT
+ MENUITEM "&Puces" ID_BULLET
+ MENUITEM "&Paragraphe" ID_PARAFORMAT
END
END
IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
-CAPTION "Date and time"
+CAPTION "Date et heure"
FONT 10, "MS Sans Serif"
BEGIN
LTEXT "Available formats",0,3,2,100,15
IDD_NEWFILE DIALOG DISCARDABLE 30, 20, 140, 80
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
-CAPTION "New"
+CAPTION "Nouveau"
FONT 10, "MS Sans Serif"
BEGIN
- LTEXT "New document type",0,3,2,100,15
+ LTEXT "Nouveau type de document",0,3,2,100,15
LISTBOX IDC_NEWFILE,3,12,90,65,LBS_NOINTEGRALHEIGHT
PUSHBUTTON "&OK",IDOK,97,12,40,12
- PUSHBUTTON "&Cancel",IDCANCEL,97,26,40,12
+ PUSHBUTTON "&Annuler",IDCANCEL,97,26,40,12
END
IDD_PARAFORMAT DIALOG DISCARDABLE 30, 20, 200, 110
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
-Caption "Paragraph format"
+Caption "Format de paragraphe"
FONT 8, "MS Shell Dlg"
BEGIN
GROUPBOX "Indentation", 0, 10, 10, 120, 68
LTEXT "Alignment", 0, 15, 87, 40, 13
COMBOBOX IDC_PARA_ALIGN, 55, 85, 60, 13, CBS_DROPDOWNLIST
PUSHBUTTON "&OK", IDOK, 137, 15, 50, 15
- PUSHBUTTON "&Cancel", IDCANCEL, 137, 33, 50, 15
+ PUSHBUTTON "&Annuler", IDCANCEL, 137, 33, 50, 15
END
IDD_TABSTOPS DIALOG DISCARDABLE 30, 20, 200, 110
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
-Caption "Tabs"
+Caption "Tabulations"
FONT 8, "MS SHell DLg"
BEGIN
- GROUPBOX "Tab stops", 0, 10, 10, 120, 90
+ GROUPBOX "Arrêts de tabulation", 0, 10, 10, 120, 90
COMBOBOX IDC_TABSTOPS, 20, 20, 100, 60, CBS_SIMPLE | CBS_SORT
- DEFPUSHBUTTON "&Add", ID_TAB_ADD, 20, 80, 45, 15
- PUSHBUTTON "&Remove", ID_TAB_DEL, 72, 80, 45, 15
+ DEFPUSHBUTTON "&Ajouter", ID_TAB_ADD, 20, 80, 45, 15
+ PUSHBUTTON "&Supprimer", ID_TAB_DEL, 72, 80, 45, 15
PUSHBUTTON "&OK", IDOK, 137, 15, 50, 15
- PUSHBUTTON "&Cancel", IDCANCEL, 137, 33, 50, 15
- PUSHBUTTON "Remove al&l", ID_TAB_EMPTY, 137, 51, 50, 15
+ PUSHBUTTON "&Annuler", IDCANCEL, 137, 33, 50, 15
+ PUSHBUTTON "Supprimer &tous", ID_TAB_EMPTY, 137, 51, 50, 15
END
IDD_FORMATOPTS DIALOG DISCARDABLE 0, 0, 280, 110
GROUPBOX "Line wrapping", 0, 10, 10, 130, 85
RADIOBUTTON "Wrap text by the &window border", IDC_PAGEFMT_WW, 18, 25, 117, 15
RADIOBUTTON "Wrap text by the &margin", IDC_PAGEFMT_WM, 18, 45, 117, 15
- GROUPBOX "Toolbars", 0, 150, 10, 120, 85
- CHECKBOX "&Toolbar", IDC_PAGEFMT_TB, 160, 20, 80, 15
- CHECKBOX "&Formatbar", IDC_PAGEFMT_FB, 160, 38, 80, 15
- CHECKBOX "&Statusbar", IDC_PAGEFMT_SB, 160, 56, 80, 15
+ GROUPBOX "Barres d'outils", 0, 150, 10, 120, 85
+ CHECKBOX "&Barre d'outils", IDC_PAGEFMT_TB, 160, 20, 80, 15
+ CHECKBOX "Barre de &format", IDC_PAGEFMT_FB, 160, 38, 80, 15
+ CHECKBOX "Barre de &statut", IDC_PAGEFMT_SB, 160, 56, 80, 15
LTEXT "", IDC_PAGEFMT_ID, 0,0,0,0
END
STRINGTABLE DISCARDABLE
BEGIN
- STRING_RICHTEXT_FILES_RTF, "Rich text format (*.rtf)"
- STRING_TEXT_FILES_TXT, "Text documents (*.txt)"
- STRING_TEXT_FILES_UNICODE_TXT, "Unicode text document (*.txt)"
- STRING_ALL_FILES, "All documents (*.*)"
+ STRING_RICHTEXT_FILES_RTF, "Documents texte riche (*.rtf)"
+ STRING_TEXT_FILES_TXT, "Documents texte (*.txt)"
+ STRING_TEXT_FILES_UNICODE_TXT, "Documents texte unicode (*.txt)"
+ STRING_ALL_FILES, "Tous les documents (*.*)"
END
STRINGTABLE DISCARDABLE
BEGIN
- STRING_ALIGN_LEFT, "Left"
- STRING_ALIGN_RIGHT, "Right"
- STRING_ALIGN_CENTER, "Center"
+ STRING_ALIGN_LEFT, "Gauche"
+ STRING_ALIGN_RIGHT, "Droite"
+ STRING_ALIGN_CENTER, "Centrer"
END
STRINGTABLE DISCARDABLE
BEGIN
- STRING_NEWFILE_RICHTEXT, "Rich text document"
- STRING_NEWFILE_TXT, "Text document"
- STRING_NEWFILE_TXT_UNICODE, "Unicode text document"
+ STRING_NEWFILE_RICHTEXT, "Document texte riche"
+ STRING_NEWFILE_TXT, "Document texte"
+ STRING_NEWFILE_TXT_UNICODE, "Document texte unicode"
END
STRINGTABLE DISCARDABLE
BEGIN
- STRING_PRINTER_FILES_PRN, "Printer files (*.PRN)"
+ STRING_PRINTER_FILES_PRN, "Fichiers d'impression (*.PRN)"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_VIEWPROPS_TITLE, "Options"
- STRING_VIEWPROPS_TEXT, "Text"
- STRING_VIEWPROPS_RICHTEXT, "Rich text"
+ STRING_VIEWPROPS_TEXT, "Texte"
+ STRING_VIEWPROPS_RICHTEXT, "Texte riche"
END
STRINGTABLE DISCARDABLE
BEGIN
- STRING_PREVIEW_PRINT, "Print"
- STRING_PREVIEW_NEXTPAGE, "Next page"
- STRING_PREVIEW_PREVPAGE, "Previous page"
- STRING_PREVIEW_CLOSE, "Close"
+ STRING_PREVIEW_PRINT, "Imprimer"
+ STRING_PREVIEW_NEXTPAGE, "Page suivante"
+ STRING_PREVIEW_PREVPAGE, "Page précédente"
+ STRING_PREVIEW_CLOSE, "Fermer"
END
STRINGTABLE DISCARDABLE
STRINGTABLE DISCARDABLE
BEGIN
STRING_DEFAULT_FILENAME, "Document"
- STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
- STRING_SEARCH_FINISHED, "Finished searching the document."
- STRING_LOAD_RICHED_FAILED, "Failed to load the RichEdit library."
- STRING_SAVE_LOSEFORMATTING, "You have chosen to save in plain text format, " \
- "which will cause all formatting to be lost. " \
- "Are you sure that you wish to do this?"
- STRING_INVALID_NUMBER, "Invalid number format"
+ STRING_PROMPT_SAVE_CHANGES, "Enregistrer les modifications de « %s » ?"
+ STRING_SEARCH_FINISHED, "Recherche terminée dans le document."
+ STRING_LOAD_RICHED_FAILED, "Impossible de charger la bibliothèque RichEdit."
+ STRING_SAVE_LOSEFORMATTING, "Vous avez choisi d'enregistrer en texte simple, " \
+ "ce qui causera la perte de tout formattage. " \
+ "Voulez-vous vraiment continuer ?"
+ STRING_INVALID_NUMBER, "Format de nombre invalide"
+ STRING_OLE_STORAGE_NOT_SUPPORTED, "Les documents conteneur OLE ne sont pas supportés"
END
LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT
-MAINMENU MENU DISCARDABLE
+IDM_MAINMENU MENU DISCARDABLE
BEGIN
POPUP "&Fájl"
BEGIN
"which will cause all formatting to be lost. " \
"Are you sure that you wish to do this?"
STRING_INVALID_NUMBER, "Invalid number format"
+ STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported"
END
LANGUAGE LANG_KOREAN, SUBLANG_NEUTRAL
-MAINMENU MENU DISCARDABLE
+
+IDM_MAINMENU MENU DISCARDABLE
BEGIN
POPUP "ÆÄÀÏ(&F)"
BEGIN
POPUP "Çü½Ä(&O)"
BEGIN
MENUITEM "±Û²Ã(&F) . . .", ID_FONTSETTINGS
- MENUITEM " °Á¶ Á¡(&U)" ID_BULLET
+ MENUITEM "°Á¶ Á¡(&U)" ID_BULLET
MENUITEM "´Ü¶ô(&P) . . ." ID_PARAFORMAT
MENUITEM "ÅÇ(&T) . . ." ID_TABSTOPS
POPUP "¹è°æ(&B)"
IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "³¯Â¥¿Í ½Ã°£"
-FONT 10, "MS Sans Serif"
+FONT 10, "MS Shell Dlg"
BEGIN
LTEXT "°¡´ÉÇÑ Çü½Ä",0,3,2,100,15
LISTBOX IDC_DATETIME,3,12,80,65,LBS_NOINTEGRALHEIGHT
IDD_NEWFILE DIALOG DISCARDABLE 30, 20, 140, 80
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "»õ ¹®¼"
-FONT 10, "MS Sans Serif"
+FONT 10, "MS Shell Dlg"
BEGIN
LTEXT "»õ ¹®¼ Çü½Ä",0,3,2,100,15
LISTBOX IDC_NEWFILE,3,12,90,65,LBS_NOINTEGRALHEIGHT
IDD_TABSTOPS DIALOG DISCARDABLE 30, 20, 200, 110
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
Caption "ÅÇ"
-FONT 8, "MS SHell DLg"
+FONT 8, "MS Shell Dlg"
BEGIN
GROUPBOX "ÅÇ Á¤Áö", 0, 10, 10, 120, 90
COMBOBOX IDC_TABSTOPS, 20, 20, 100, 60, CBS_SIMPLE | CBS_SORT
"ÀÌ°ÍÀº Ư¼öÇÑ ²Ù¹ÒÀ» ¾ø¿¤ °ÍÀÔ´Ï´Ù. " \
"´ç½ÅÀº Á¤¸»·Î ÀúÀåÇϱ⸦ ¿øÇմϱî?"
STRING_INVALID_NUMBER, "¿Ã¹Ù¸£Áö ¾ÊÀº ¼ö Çü½Ä"
+ STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE ÀúÀå ¹®¼´Â Áö¿øµÇÁö ¾Ê½À´Ï´Ù"
END
LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL
-MAINMENU MENU DISCARDABLE
+IDM_MAINMENU MENU DISCARDABLE
BEGIN
POPUP "&Bestand"
BEGIN
"which will cause all formatting to be lost. " \
"Are you sure that you wish to do this?"
STRING_INVALID_NUMBER, "Invalid number format"
+ STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported"
END
LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL
-MAINMENU MENU DISCARDABLE
+IDM_MAINMENU MENU DISCARDABLE
BEGIN
POPUP "&Fil"
BEGIN
"vil føre til at all formatering går tapt. Er du " \
"sikker på at du vil fortsette?"
STRING_INVALID_NUMBER, "Ugyldig tallformat"
+ STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported"
END
LANGUAGE LANG_POLISH, SUBLANG_DEFAULT
-MAINMENU MENU DISCARDABLE
+IDM_MAINMENU MENU DISCARDABLE
BEGIN
POPUP "&Plik"
BEGIN
"which will cause all formatting to be lost. " \
"Are you sure that you wish to do this?"
STRING_INVALID_NUMBER, "Invalid number format"
+ STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported"
END
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
-MAINMENU MENU DISCARDABLE
+IDM_MAINMENU MENU DISCARDABLE
BEGIN
POPUP "&Ôàéë"
BEGIN
MENUITEM "&Ñîõðàíèòü\tCtrl+S", ID_FILE_SAVE
MENUITEM "Ñîõðàíèòü &êàê...", ID_FILE_SAVEAS
MENUITEM SEPARATOR
- MENUITEM "&Print . . .\tCtrl+P", ID_PRINT
- MENUITEM "Print previe&w . . .", ID_PREVIEW
- MENUITEM "Pag&e setup . . .", ID_PRINTSETUP
+ MENUITEM "&Ïå÷àòü . . .\tCtrl+P", ID_PRINT
+ MENUITEM "Ïðåä&âàðèòåëüíûé ïðîñìîòð . . .", ID_PREVIEW
+ MENUITEM "&Ìàêåò ñòðàíèöû . . .", ID_PRINTSETUP
MENUITEM SEPARATOR
MENUITEM "Â&ûõîä", ID_FILE_EXIT
END
MENUITEM SEPARATOR
MENUITEM "&Âûðåçàòü\tCtrl+X", ID_EDIT_CUT
MENUITEM "&Êîïèðîâàòü\tCtrl+C", ID_EDIT_COPY
- MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE
+ MENUITEM "&Âñòàâèòü\tCtrl+V", ID_EDIT_PASTE
MENUITEM SEPARATOR
- MENUITEM "&Find . . .\tCrtl+F", ID_FIND
- MENUITEM "Find &next\tF3", ID_FIND_NEXT
- MENUITEM "&Replace . . .\tCtrl+H", ID_REPLACE
+ MENUITEM "&Íàéòè . . .\tCrtl+F", ID_FIND
+ MENUITEM "Íà&éòè äàëåå\tF3", ID_FIND_NEXT
+ MENUITEM "&Çàìåíèòü . . .\tCtrl+H", ID_REPLACE
MENUITEM SEPARATOR
MENUITEM "&Òîëüêî äëÿ ÷òåíèÿ", ID_EDIT_READONLY
MENUITEM "&Èçìåíåí", ID_EDIT_MODIFIED
END
POPUP "&View"
BEGIN
- MENUITEM "&Toolbar", ID_TOGGLE_TOOLBAR
- MENUITEM "&Formatbar", ID_TOGGLE_FORMATBAR
- MENUITEM "&Statusbar", ID_TOGGLE_STATUSBAR
+ MENUITEM "Ïàíåëü &èíñòðóìåíòîâ", ID_TOGGLE_TOOLBAR
+ MENUITEM "Ï&àíåëü ôîðìàòèðîâàíèÿ", ID_TOGGLE_FORMATBAR
+ MENUITEM "&Ñòðîêà ñîñòîÿíèÿ", ID_TOGGLE_STATUSBAR
MENUITEM SEPARATOR
- MENUITEM "&Options . . .", ID_VIEWPROPERTIES
+ MENUITEM "&Ïàðàìåòðû . . .", ID_VIEWPROPERTIES
END
- POPUP "&Insert"
+ POPUP "Âñò&àâêà"
BEGIN
- MENUITEM "&Date and time . . .", ID_DATETIME
+ MENUITEM "&Äàòà è âðåìÿ . . .", ID_DATETIME
END
POPUP "Ôîð&ìàò"
BEGIN
- MENUITEM "&Font . . .", ID_FONTSETTINGS
- MENUITEM "B&ullet points" ID_BULLET
- MENUITEM "&Paragraph . . ." ID_PARAFORMAT
- MENUITEM "&Tabs . . ." ID_TABSTOPS
+ MENUITEM "&Øðèôò . . .", ID_FONTSETTINGS
+ MENUITEM "&Ìàðêåð" ID_BULLET
+ MENUITEM "&Àáçàö . . ." ID_PARAFORMAT
+ MENUITEM "&Òàáóëÿöèÿ . . ." ID_TABSTOPS
POPUP "&Ôîí"
BEGIN
MENUITEM "&Ñèñòåìíûé\tCtrl+1", ID_BACK_1
MENUITEM "&Æåëòîâàòûé PostThat\tCtrl+2", ID_BACK_2
END
END
- POPUP "&Help"
+ POPUP "&Ñïðàâêà"
BEGIN
- MENUITEM "&About Wine Wordpad" ID_ABOUT
+ MENUITEM "&Î Wine Wordpad" ID_ABOUT
END
END
BEGIN
MENUITEM "&Âûðåçàòü\tCtrl+X", ID_EDIT_CUT
MENUITEM "&Êîïèðîâàòü\tCtrl+C", ID_EDIT_COPY
- MENUITEM "&Paste", ID_EDIT_PASTE
+ MENUITEM "Âñò&àâèòü", ID_EDIT_PASTE
MENUITEM SEPARATOR
- MENUITEM "&Bullet points" ID_BULLET
- MENUITEM "&Paragraph . . ." ID_PARAFORMAT
+ MENUITEM "&Ìàðêåð" ID_BULLET
+ MENUITEM "&Àáçàö . . ." ID_PARAFORMAT
END
END
IDD_DATETIME DIALOG DISCARDABLE 30, 20, 130, 80
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
-CAPTION "Date and time"
+CAPTION "Äàòà è âðåìÿ"
FONT 10, "MS Sans Serif"
BEGIN
- LTEXT "Available formats",0,3,2,100,15
+ LTEXT "Äîñòóïíûå ôîðìàòû",0,3,2,100,15
LISTBOX IDC_DATETIME,3,12,80,65,LBS_NOINTEGRALHEIGHT
- PUSHBUTTON "&OK",IDOK,87,12,40,12
- PUSHBUTTON "&Cancel",IDCANCEL,87,26,40,12
+ PUSHBUTTON "&ÎÊ",IDOK,87,12,40,12
+ PUSHBUTTON "Î&òìåíà",IDCANCEL,87,26,40,12
END
IDD_NEWFILE DIALOG DISCARDABLE 30, 20, 140, 80
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
-CAPTION "New"
+CAPTION "Íîâûé äîêóìåíò"
FONT 10, "MS Sans Serif"
BEGIN
- LTEXT "New document type",0,3,2,100,15
+ LTEXT "Òèï ñîçäàâàåìîãî äîêóìåíòà",0,3,2,100,15
LISTBOX IDC_NEWFILE,3,12,90,65,LBS_NOINTEGRALHEIGHT
- PUSHBUTTON "&OK",IDOK,97,12,40,12
- PUSHBUTTON "&Cancel",IDCANCEL,97,26,40,12
+ PUSHBUTTON "&ÎÊ",IDOK,97,12,40,12
+ PUSHBUTTON "Î&òìåíà",IDCANCEL,97,26,40,12
END
IDD_PARAFORMAT DIALOG DISCARDABLE 30, 20, 200, 110
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
-Caption "Paragraph format"
+Caption "Àáçàö"
FONT 8, "MS Shell Dlg"
BEGIN
- GROUPBOX "Indentation", 0, 10, 10, 120, 68
- LTEXT "Left", 0, 15, 22, 40, 13
+ GROUPBOX "Îòñòóï", 0, 10, 10, 120, 68
+ LTEXT "Ñëåâà", 0, 15, 22, 40, 13
EDITTEXT IDC_PARA_LEFT, 55, 20, 60, 13
- LTEXT "Right", 0, 15, 40, 40, 13
+ LTEXT "Ñïðàâà", 0, 15, 40, 40, 13
EDITTEXT IDC_PARA_RIGHT, 55, 38, 60, 13
- LTEXT "First line", 0, 15, 58, 40, 13
+ LTEXT "Ïåðâàÿ ñòðîêà", 0, 15, 58, 40, 13
EDITTEXT IDC_PARA_FIRST, 55, 56, 60, 13
- LTEXT "Alignment", 0, 15, 87, 40, 13
+ LTEXT "Âûðàâíèâàíèå", 0, 15, 87, 40, 13
COMBOBOX IDC_PARA_ALIGN, 55, 85, 60, 13, CBS_DROPDOWNLIST
- PUSHBUTTON "&OK", IDOK, 137, 15, 50, 15
- PUSHBUTTON "&Cancel", IDCANCEL, 137, 33, 50, 15
+ PUSHBUTTON "&ÎÊ", IDOK, 137, 15, 50, 15
+ PUSHBUTTON "Î&òìåíà", IDCANCEL, 137, 33, 50, 15
END
IDD_TABSTOPS DIALOG DISCARDABLE 30, 20, 200, 110
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
-Caption "Tabs"
+Caption "Òàáóëÿöèÿ"
FONT 8, "MS SHell DLg"
BEGIN
- GROUPBOX "Tab stops", 0, 10, 10, 120, 90
+ GROUPBOX "Ïîçèöèè òàáóëÿöèè", 0, 10, 10, 120, 90
COMBOBOX IDC_TABSTOPS, 20, 20, 100, 60, CBS_SIMPLE | CBS_SORT
- DEFPUSHBUTTON "&Add", ID_TAB_ADD, 20, 80, 45, 15
- PUSHBUTTON "&Remove", ID_TAB_DEL, 72, 80, 45, 15
- PUSHBUTTON "&OK", IDOK, 137, 15, 50, 15
- PUSHBUTTON "&Cancel", IDCANCEL, 137, 33, 50, 15
- PUSHBUTTON "Remove al&l", ID_TAB_EMPTY, 137, 51, 50, 15
+ DEFPUSHBUTTON "&Óñòàíîâèòü", ID_TAB_ADD, 20, 80, 45, 15
+ PUSHBUTTON "Î&÷èñòèòü", ID_TAB_DEL, 72, 80, 45, 15
+ PUSHBUTTON "&ÎÊ", IDOK, 137, 15, 50, 15
+ PUSHBUTTON "Î&òìåíà", IDCANCEL, 137, 33, 50, 15
+ PUSHBUTTON "Î÷èñòèòü &âñå", ID_TAB_EMPTY, 137, 51, 50, 15
END
IDD_FORMATOPTS DIALOG DISCARDABLE 0, 0, 280, 110
Caption ""
FONT 8, "MS Shell Dlg"
BEGIN
- GROUPBOX "Line wrapping", 0, 10, 10, 130, 85
- RADIOBUTTON "Wrap text by the &window border", IDC_PAGEFMT_WW, 18, 25, 117, 15
- RADIOBUTTON "Wrap text by the &margin", IDC_PAGEFMT_WM, 18, 45, 117, 15
- GROUPBOX "Toolbars", 0, 150, 10, 120, 85
- CHECKBOX "&Toolbar", IDC_PAGEFMT_TB, 160, 20, 80, 15
- CHECKBOX "&Formatbar", IDC_PAGEFMT_FB, 160, 38, 80, 15
- CHECKBOX "&Statusbar", IDC_PAGEFMT_SB, 160, 56, 80, 15
+ GROUPBOX "Ïåðåíîñ ïî ñëîâàì", 0, 10, 10, 130, 85
+ RADIOBUTTON "Â ãðàíèöàõ &îêíà", IDC_PAGEFMT_WW, 18, 25, 117, 15
+ RADIOBUTTON "Â ãðàíèöàõ &ïîëåé", IDC_PAGEFMT_WM, 18, 45, 117, 15
+ GROUPBOX "Ïàíåëè", 0, 150, 10, 120, 85
+ CHECKBOX "&Èíñòðóìåíòîâ", IDC_PAGEFMT_TB, 160, 20, 80, 15
+ CHECKBOX "&Ôîðìàòèðîâàíèÿ", IDC_PAGEFMT_FB, 160, 38, 80, 15
+ CHECKBOX "&Ñòðîêà ñîñòîÿíèÿ", IDC_PAGEFMT_SB, 160, 56, 80, 15
LTEXT "", IDC_PAGEFMT_ID, 0,0,0,0
END
STRINGTABLE DISCARDABLE
BEGIN
- STRING_RICHTEXT_FILES_RTF, "Rich text format (*.rtf)"
- STRING_TEXT_FILES_TXT, "Text documents (*.txt)"
- STRING_TEXT_FILES_UNICODE_TXT, "Unicode text document (*.txt)"
- STRING_ALL_FILES, "All documents (*.*)"
+ STRING_RICHTEXT_FILES_RTF, "Ôàéëû RTF (*.rtf)"
+ STRING_TEXT_FILES_TXT, "Òåêñòîâûå äîêóìåíòû (*.txt)"
+ STRING_TEXT_FILES_UNICODE_TXT, "Äîêóìåíòû Unicode (*.txt)"
+ STRING_ALL_FILES, "Âñå äîêóìíòû (*.*)"
END
STRINGTABLE DISCARDABLE
BEGIN
- STRING_ALIGN_LEFT, "Left"
- STRING_ALIGN_RIGHT, "Right"
- STRING_ALIGN_CENTER, "Center"
+ STRING_ALIGN_LEFT, "Ïî ëåâîìó êðàþ"
+ STRING_ALIGN_RIGHT, "Ïî ïðàâîìó êðàþ"
+ STRING_ALIGN_CENTER, "Ïî öåíòðó"
END
STRINGTABLE DISCARDABLE
BEGIN
- STRING_NEWFILE_RICHTEXT, "Rich text document"
- STRING_NEWFILE_TXT, "Text document"
- STRING_NEWFILE_TXT_UNICODE, "Unicode text document"
+ STRING_NEWFILE_RICHTEXT, "Ôàéë RTF"
+ STRING_NEWFILE_TXT, "Òåêñòîâûé äîêóìåíò"
+ STRING_NEWFILE_TXT_UNICODE, "Äîêóìåíò â ôîðìàòå Unicode"
END
STRINGTABLE DISCARDABLE
BEGIN
- STRING_PRINTER_FILES_PRN, "Printer files (*.PRN)"
+ STRING_PRINTER_FILES_PRN, "Ôàéëû ïðèíòåðà (*.PRN)"
END
STRINGTABLE DISCARDABLE
BEGIN
- STRING_VIEWPROPS_TITLE, "Options"
- STRING_VIEWPROPS_TEXT, "Text"
- STRING_VIEWPROPS_RICHTEXT, "Rich text"
+ STRING_VIEWPROPS_TITLE, "Íàñòðîéêè"
+ STRING_VIEWPROPS_TEXT, "Òåêñò"
+ STRING_VIEWPROPS_RICHTEXT, "Ôàéë RTF"
END
STRINGTABLE DISCARDABLE
BEGIN
- STRING_PREVIEW_PRINT, "Print"
- STRING_PREVIEW_NEXTPAGE, "Next page"
- STRING_PREVIEW_PREVPAGE, "Previous page"
- STRING_PREVIEW_CLOSE, "Close"
+ STRING_PREVIEW_PRINT, "Ïå÷àòü"
+ STRING_PREVIEW_NEXTPAGE, "Ñëåäóþùàÿ ñòðàíèöà"
+ STRING_PREVIEW_PREVPAGE, "Ïðåäûäóùàÿ ñòðàíèöà"
+ STRING_PREVIEW_CLOSE, "Çàêðûòü"
END
STRINGTABLE DISCARDABLE
BEGIN
- STRING_UNITS_CM, "cm"
+ STRING_UNITS_CM, "ñì"
END
STRINGTABLE DISCARDABLE
BEGIN
STRING_DEFAULT_FILENAME, "Document"
- STRING_PROMPT_SAVE_CHANGES, "Save changes to '%s'?"
- STRING_SEARCH_FINISHED, "Finished searching the document."
- STRING_LOAD_RICHED_FAILED, "Failed to load the RichEdit library."
- STRING_SAVE_LOSEFORMATTING, "You have chosen to save in plain text format, " \
- "which will cause all formatting to be lost. " \
- "Are you sure that you wish to do this?"
- STRING_INVALID_NUMBER, "Invalid number format"
+ STRING_PROMPT_SAVE_CHANGES, "Ñîõðàíèòü èçìåíåíèÿ â '%s'?"
+ STRING_SEARCH_FINISHED, "Ïîèñê â äîêóìåíòå çàâåðøåí."
+ STRING_LOAD_RICHED_FAILED, "Îøèáêà çàãðóçêè áèáëèîòåêè RichEdit."
+ STRING_SAVE_LOSEFORMATTING, "Ñîõðàíåíèå äîêóìåíòà â âèäå íåôîðìàòèðîâàííîãî òåêñòà, " \
+ "ïðèâåäåò ê ïîòåðå ôîðìàòèðîâàíèÿ. Ïîäòâåðæäàåòå âûïîëíåíèå" \
+ "ýòîé îïåðàöèè?"
+ STRING_INVALID_NUMBER, "Íåïðàâèëüíûé ÷èñëîâîé ôîðìàò"
+ STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage äîêóìåíòû íå ïîääåðæèâàþòñÿ"
END
LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT
-MAINMENU MENU DISCARDABLE
+IDM_MAINMENU MENU DISCARDABLE
BEGIN
POPUP "&Dosya"
BEGIN
"which will cause all formatting to be lost. " \
"Are you sure that you wish to do this?"
STRING_INVALID_NUMBER, "Invalid number format"
+ STRING_OLE_STORAGE_NOT_SUPPORTED, "OLE storage documents are not supported"
END
--- /dev/null
+/*
+ * Wordpad implementation - Printing and print preview functions
+ *
+ * Copyright 2007 by Alexander N. Sørnes <alex@thehandofagony.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <windows.h>
+#include <richedit.h>
+#include <commctrl.h>
+
+#include "wordpad.h"
+
+typedef struct _previewinfo
+{
+ int page;
+ int pages;
+ HDC hdc;
+ HDC hdcSized;
+ RECT window;
+ LPWSTR wszFileName;
+} previewinfo, *ppreviewinfo;
+
+static HGLOBAL devMode;
+static HGLOBAL devNames;
+
+static RECT margins;
+static previewinfo preview;
+
+static const WCHAR var_pagemargin[] = {'P','a','g','e','M','a','r','g','i','n',0};
+
+static LPWSTR get_print_file_filter(HWND hMainWnd)
+{
+ static WCHAR wszPrintFilter[MAX_STRING_LEN*2+6+4+1];
+ const WCHAR files_prn[] = {'*','.','P','R','N',0};
+ const WCHAR files_all[] = {'*','.','*','\0'};
+ LPWSTR p;
+ HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hMainWnd, GWLP_HINSTANCE);
+
+ 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;
+
+ return wszPrintFilter;
+}
+
+void registry_set_pagemargins(HKEY hKey)
+{
+ RegSetValueExW(hKey, var_pagemargin, 0, REG_BINARY, (LPBYTE)&margins, sizeof(RECT));
+}
+
+void registry_read_pagemargins(HKEY hKey)
+{
+ DWORD size = sizeof(RECT);
+
+ if(!hKey || RegQueryValueExW(hKey, var_pagemargin, 0, NULL, (LPBYTE)&margins,
+ &size) != ERROR_SUCCESS || size != sizeof(RECT))
+ {
+ margins.top = 1417;
+ margins.bottom = 1417;
+ margins.left = 1757;
+ margins.right = 1757;
+ }
+}
+
+static void AddTextButton(HWND hRebarWnd, int string, int command, int id)
+{
+ REBARBANDINFOW rb;
+ HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hRebarWnd, GWLP_HINSTANCE);
+ WCHAR text[MAX_STRING_LEN];
+ HWND hButton;
+
+ LoadStringW(hInstance, string, text, MAX_STRING_LEN);
+ hButton = CreateWindowW(WC_BUTTONW, text,
+ WS_VISIBLE | WS_CHILD, 5, 5, 100, 15,
+ hRebarWnd, (HMENU)command, hInstance, NULL);
+
+ rb.cbSize = sizeof(rb);
+ rb.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_ID;
+ rb.fStyle = RBBS_NOGRIPPER | RBBS_VARIABLEHEIGHT;
+ rb.hwndChild = hButton;
+ rb.cyChild = rb.cyMinChild = 22;
+ rb.cx = rb.cxMinChild = 90;
+ rb.cxIdeal = 100;
+ rb.wID = id;
+
+ SendMessageW(hRebarWnd, RB_INSERTBAND, -1, (LPARAM)&rb);
+}
+
+static HDC make_dc(void)
+{
+ if(devNames && devMode)
+ {
+ LPDEVNAMES dn = GlobalLock(devNames);
+ LPDEVMODEW dm = GlobalLock(devMode);
+ HDC ret;
+
+ ret = CreateDCW((LPWSTR)dn + dn->wDriverOffset,
+ (LPWSTR)dn + dn->wDeviceOffset, 0, dm);
+
+ GlobalUnlock(dn);
+ GlobalUnlock(dm);
+
+ return ret;
+ } else
+ {
+ return 0;
+ }
+}
+
+static LONG twips_to_centmm(int twips)
+{
+ return MulDiv(twips, 1000, 567);
+}
+
+LONG centmm_to_twips(int mm)
+{
+ return MulDiv(mm, 567, 1000);
+}
+
+static LONG twips_to_pixels(int twips, int dpi)
+{
+ float ret = ((float)twips / ((float)567 * 2.54)) * (float)dpi;
+ return (LONG)ret;
+}
+
+static LONG devunits_to_twips(int units, int dpi)
+{
+ float ret = ((float)units / (float)dpi) * (float)567 * 2.54;
+ return (LONG)ret;
+}
+
+
+static RECT get_print_rect(HDC hdc)
+{
+ RECT rc;
+ int width, height;
+
+ if(hdc)
+ {
+ int dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
+ int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
+ width = devunits_to_twips(GetDeviceCaps(hdc, PHYSICALWIDTH), dpiX);
+ height = devunits_to_twips(GetDeviceCaps(hdc, PHYSICALHEIGHT), dpiY);
+ } else
+ {
+ width = centmm_to_twips(18500);
+ height = centmm_to_twips(27000);
+ }
+
+ rc.left = margins.left;
+ rc.right = width - margins.right;
+ rc.top = margins.top;
+ rc.bottom = height - margins.bottom;
+
+ return rc;
+}
+
+void target_device(HWND hMainWnd, DWORD wordWrap)
+{
+ HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR);
+ HDC hdc = make_dc();
+ int width = 0;
+
+ if(wordWrap == ID_WORDWRAP_MARGIN)
+ {
+ RECT rc = get_print_rect(hdc);
+ width = rc.right;
+ }
+
+ if(!hdc)
+ {
+ HDC hMaindc = GetDC(hMainWnd);
+ hdc = CreateCompatibleDC(hMaindc);
+ ReleaseDC(hMainWnd, hMaindc);
+ }
+
+ SendMessageW(hEditorWnd, EM_SETTARGETDEVICE, (WPARAM)hdc, width);
+
+ DeleteDC(hdc);
+}
+
+static LPWSTR dialog_print_to_file(HWND hMainWnd)
+{
+ 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};
+ static LPWSTR file_filter;
+
+ if(!file_filter)
+ file_filter = get_print_file_filter(hMainWnd);
+
+ ZeroMemory(&ofn, sizeof(ofn));
+
+ ofn.lStructSize = sizeof(ofn);
+ ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
+ ofn.hwndOwner = hMainWnd;
+ ofn.lpstrFilter = file_filter;
+ ofn.lpstrFile = (LPWSTR)file;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.lpstrDefExt = (LPWSTR)defExt;
+
+ if(GetSaveFileNameW(&ofn))
+ return (LPWSTR)file;
+ else
+ return FALSE;
+}
+
+static int get_num_pages(HWND hEditorWnd, FORMATRANGE fr)
+{
+ int page = 0;
+
+ do
+ {
+ page++;
+ fr.chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE,
+ (LPARAM)&fr);
+ }
+ while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax);
+
+ return page;
+}
+
+static void char_from_pagenum(HWND hEditorWnd, FORMATRANGE *fr, int page)
+{
+ int i;
+
+ for(i = 1; i <= page; i++)
+ {
+ if(i == page)
+ break;
+
+ fr->chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)fr);
+ }
+}
+
+static void print(LPPRINTDLGW pd, LPWSTR wszFileName)
+{
+ FORMATRANGE fr;
+ DOCINFOW di;
+ HWND hEditorWnd = GetDlgItem(pd->hwndOwner, IDC_EDITOR);
+ int printedPages = 0;
+
+ fr.hdc = pd->hDC;
+ fr.hdcTarget = pd->hDC;
+
+ fr.rc = get_print_rect(fr.hdc);
+ fr.rcPage.left = 0;
+ fr.rcPage.right = fr.rc.right + margins.right;
+ fr.rcPage.top = 0;
+ fr.rcPage.bottom = fr.rc.bottom + margins.bottom;
+
+ ZeroMemory(&di, sizeof(di));
+ di.cbSize = sizeof(di);
+ di.lpszDocName = wszFileName;
+
+ if(pd->Flags & PD_PRINTTOFILE)
+ {
+ di.lpszOutput = dialog_print_to_file(pd->hwndOwner);
+ 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)>, 0);
+
+ if(pd->Flags & PD_PAGENUMS)
+ char_from_pagenum(hEditorWnd, &fr, pd->nToPage);
+ }
+
+ 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;
+
+ printedPages++;
+ if((pd->Flags & PD_PAGENUMS) && (printedPages > (pd->nToPage - pd->nFromPage)))
+ break;
+ }
+ while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax);
+
+ EndDoc(fr.hdc);
+ SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, 0);
+}
+
+void dialog_printsetup(HWND hMainWnd)
+{
+ PAGESETUPDLGW ps;
+
+ ZeroMemory(&ps, sizeof(ps));
+ ps.lStructSize = sizeof(ps);
+ ps.hwndOwner = hMainWnd;
+ ps.Flags = PSD_INHUNDREDTHSOFMILLIMETERS | PSD_MARGINS;
+ ps.rtMargin.left = twips_to_centmm(margins.left);
+ ps.rtMargin.right = twips_to_centmm(margins.right);
+ ps.rtMargin.top = twips_to_centmm(margins.top);
+ ps.rtMargin.bottom = twips_to_centmm(margins.bottom);
+ ps.hDevMode = devMode;
+ ps.hDevNames = devNames;
+
+ if(PageSetupDlgW(&ps))
+ {
+ margins.left = centmm_to_twips(ps.rtMargin.left);
+ margins.right = centmm_to_twips(ps.rtMargin.right);
+ margins.top = centmm_to_twips(ps.rtMargin.top);
+ margins.bottom = centmm_to_twips(ps.rtMargin.bottom);
+ devMode = ps.hDevMode;
+ devNames = ps.hDevNames;
+ }
+}
+
+void get_default_printer_opts(void)
+{
+ PRINTDLGW pd;
+ ZeroMemory(&pd, sizeof(pd));
+
+ ZeroMemory(&pd, sizeof(pd));
+ pd.lStructSize = sizeof(pd);
+ pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT;
+ pd.hDevMode = devMode;
+
+ PrintDlgW(&pd);
+
+ devMode = pd.hDevMode;
+ devNames = pd.hDevNames;
+}
+
+void print_quick(LPWSTR wszFileName)
+{
+ PRINTDLGW pd;
+
+ ZeroMemory(&pd, sizeof(pd));
+ pd.hDC = make_dc();
+
+ print(&pd, wszFileName);
+}
+
+void dialog_print(HWND hMainWnd, LPWSTR wszFileName)
+{
+ PRINTDLGW pd;
+ HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR);
+ 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;
+ pd.hDevMode = devMode;
+ pd.hDevNames = devNames;
+
+ SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&from, (LPARAM)&to);
+ if(from == to)
+ pd.Flags |= PD_NOSELECTION;
+
+ if(PrintDlgW(&pd))
+ {
+ devMode = pd.hDevMode;
+ devNames = pd.hDevNames;
+ print(&pd, wszFileName);
+ }
+}
+
+static void preview_bar_show(HWND hMainWnd, BOOL show)
+{
+ HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR);
+ int i;
+
+ if(show)
+ {
+ REBARBANDINFOW rb;
+ HWND hStatic;
+
+ AddTextButton(hReBar, STRING_PREVIEW_PRINT, ID_PRINT, BANDID_PREVIEW_BTN1);
+ AddTextButton(hReBar, STRING_PREVIEW_NEXTPAGE, ID_PREVIEW_NEXTPAGE, BANDID_PREVIEW_BTN2);
+ AddTextButton(hReBar, STRING_PREVIEW_PREVPAGE, ID_PREVIEW_PREVPAGE, BANDID_PREVIEW_BTN3);
+ AddTextButton(hReBar, STRING_PREVIEW_CLOSE, ID_FILE_EXIT, BANDID_PREVIEW_BTN4);
+
+ hStatic = CreateWindowW(WC_STATICW, NULL,
+ WS_VISIBLE | WS_CHILD, 0, 0, 0, 0,
+ hReBar, NULL, NULL, NULL);
+
+ rb.cbSize = sizeof(rb);
+ rb.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_ID;
+ rb.fStyle = RBBS_NOGRIPPER | RBBS_VARIABLEHEIGHT;
+ rb.hwndChild = hStatic;
+ rb.cyChild = rb.cyMinChild = 22;
+ rb.cx = rb.cxMinChild = 90;
+ rb.cxIdeal = 100;
+ rb.wID = BANDID_PREVIEW_BUFFER;
+
+ SendMessageW(hReBar, RB_INSERTBAND, -1, (LPARAM)&rb);
+ } else
+ {
+ for(i = 0; i <= PREVIEW_BUTTONS; i++)
+ SendMessageW(hReBar, RB_DELETEBAND, SendMessageW(hReBar, RB_IDTOINDEX, BANDID_PREVIEW_BTN1+i, 0), 0);
+ }
+}
+
+void init_preview(HWND hMainWnd, LPWSTR wszFileName)
+{
+ preview.page = 1;
+ preview.hdc = 0;
+ preview.wszFileName = wszFileName;
+ preview_bar_show(hMainWnd, TRUE);
+}
+
+void close_preview(HWND hMainWnd)
+{
+ preview.window.right = 0;
+ preview.window.bottom = 0;
+ preview.page = 0;
+ preview.pages = 0;
+
+ preview_bar_show(hMainWnd, FALSE);
+}
+
+BOOL preview_isactive(void)
+{
+ return preview.page != 0;
+}
+
+LRESULT print_preview(HWND hMainWnd)
+{
+ FORMATRANGE fr;
+ GETTEXTLENGTHEX gt;
+ HDC hdc;
+ RECT window, background;
+ HBITMAP hBitmapCapture, hBitmapScaled;
+ int bmWidth, bmHeight, bmNewWidth, bmNewHeight;
+ float ratioWidth, ratioHeight, ratio;
+ int xOffset, yOffset;
+ int barheight;
+ HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR);
+ PAINTSTRUCT ps;
+
+ hdc = BeginPaint(hMainWnd, &ps);
+ GetClientRect(hMainWnd, &window);
+
+ fr.hdcTarget = make_dc();
+ fr.rc = get_print_rect(fr.hdcTarget);
+ fr.rcPage.left = 0;
+ fr.rcPage.top = 0;
+ fr.rcPage.bottom = fr.rc.bottom + margins.bottom;
+ fr.rcPage.right = fr.rc.right + margins.right;
+
+ bmWidth = twips_to_pixels(fr.rcPage.right, GetDeviceCaps(hdc, LOGPIXELSX));
+ bmHeight = twips_to_pixels(fr.rcPage.bottom, GetDeviceCaps(hdc, LOGPIXELSY));
+
+ hBitmapCapture = CreateCompatibleBitmap(hdc, bmWidth, bmHeight);
+
+ if(!preview.hdc)
+ {
+ RECT paper;
+ HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR);
+
+ preview.hdc = CreateCompatibleDC(hdc);
+ fr.hdc = preview.hdc;
+ gt.flags = GTL_DEFAULT;
+ gt.codepage = 1200;
+ fr.chrg.cpMin = 0;
+ fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0);
+
+ paper.left = 0;
+ paper.right = bmWidth;
+ paper.top = 0;
+ paper.bottom = bmHeight;
+
+ if(!preview.pages)
+ preview.pages = get_num_pages(hEditorWnd, fr);
+
+ SelectObject(preview.hdc, hBitmapCapture);
+
+ char_from_pagenum(hEditorWnd, &fr, preview.page);
+
+ FillRect(preview.hdc, &paper, GetStockObject(WHITE_BRUSH));
+ SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)&fr);
+ SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, 0);
+
+ EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_PREVPAGE), preview.page > 1);
+ EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_NEXTPAGE), preview.page < preview.pages);
+ }
+
+ barheight = SendMessageW(hReBar, RB_GETBARHEIGHT, 0, 0);
+ ratioWidth = ((float)window.right - 20.0) / (float)bmHeight;
+ ratioHeight = ((float)window.bottom - 20.0 - (float)barheight) / (float)bmHeight;
+
+ if(ratioWidth > ratioHeight)
+ ratio = ratioHeight;
+ else
+ ratio = ratioWidth;
+
+ bmNewWidth = (int)((float)bmWidth * ratio);
+ bmNewHeight = (int)((float)bmHeight * ratio);
+ hBitmapScaled = CreateCompatibleBitmap(hdc, bmNewWidth, bmNewHeight);
+
+ xOffset = ((window.right - bmNewWidth) / 2);
+ yOffset = ((window.bottom - bmNewHeight + barheight) / 2);
+
+ if(window.right != preview.window.right || window.bottom != preview.window.bottom)
+ {
+ HPEN hPen;
+ int TopMargin = (int)((float)twips_to_pixels(fr.rc.top, GetDeviceCaps(hdc, LOGPIXELSX)) * ratio);
+ int BottomMargin = (int)((float)twips_to_pixels(fr.rc.bottom, GetDeviceCaps(hdc, LOGPIXELSX)) * ratio);
+ int LeftMargin = (int)((float)twips_to_pixels(fr.rc.left, GetDeviceCaps(hdc, LOGPIXELSY)) * ratio);
+ int RightMargin = (int)((float)twips_to_pixels(fr.rc.right, GetDeviceCaps(hdc, LOGPIXELSY)) * ratio);
+
+ DeleteDC(preview.hdcSized);
+ preview.hdcSized = CreateCompatibleDC(hdc);
+ SelectObject(preview.hdcSized, hBitmapScaled);
+
+ StretchBlt(preview.hdcSized, 0, 0, bmNewWidth, bmNewHeight, preview.hdc, 0, 0, bmWidth, bmHeight, SRCCOPY);
+
+ /* Draw margin lines */
+ hPen = CreatePen(PS_DOT, 1, RGB(0,0,0));
+ SelectObject(preview.hdcSized, hPen);
+
+ MoveToEx(preview.hdcSized, 0, TopMargin, NULL);
+ LineTo(preview.hdcSized, bmNewWidth, TopMargin);
+ MoveToEx(preview.hdcSized, 0, BottomMargin, NULL);
+ LineTo(preview.hdcSized, bmNewWidth, BottomMargin);
+
+ MoveToEx(preview.hdcSized, LeftMargin, 0, NULL);
+ LineTo(preview.hdcSized, LeftMargin, bmNewHeight);
+ MoveToEx(preview.hdcSized, RightMargin, 0, NULL);
+ LineTo(preview.hdcSized, RightMargin, bmNewHeight);
+ }
+
+ window.top = barheight;
+ FillRect(hdc, &window, GetStockObject(GRAY_BRUSH));
+
+ SelectObject(hdc, hBitmapScaled);
+
+ background.left = xOffset - 2;
+ background.right = xOffset + bmNewWidth + 2;
+ background.top = yOffset - 2;
+ background.bottom = yOffset + bmNewHeight + 2;
+
+ FillRect(hdc, &background, GetStockObject(BLACK_BRUSH));
+
+ BitBlt(hdc, xOffset, yOffset, bmNewWidth, bmNewHeight, preview.hdcSized, 0, 0, SRCCOPY);
+
+ DeleteDC(fr.hdcTarget);
+ preview.window = window;
+
+ EndPaint(hMainWnd, &ps);
+
+ return 0;
+}
+
+LRESULT preview_command(HWND hWnd, WPARAM wParam, LPARAM lParam)
+{
+ switch(LOWORD(wParam))
+ {
+ case ID_FILE_EXIT:
+ PostMessageW(hWnd, WM_CLOSE, 0, 0);
+ break;
+
+ case ID_PREVIEW_NEXTPAGE:
+ case ID_PREVIEW_PREVPAGE:
+ {
+ HWND hReBar = GetDlgItem(hWnd, IDC_REBAR);
+ RECT rc;
+
+ if(LOWORD(wParam) == ID_PREVIEW_NEXTPAGE)
+ preview.page++;
+ else
+ preview.page--;
+
+ preview.hdc = 0;
+ preview.window.right = 0;
+
+ GetClientRect(hWnd, &rc);
+ rc.top += SendMessageW(hReBar, RB_GETBARHEIGHT, 0, 0);
+ InvalidateRect(hWnd, &rc, TRUE);
+ }
+ break;
+
+ case ID_PRINT:
+ dialog_print(hWnd, preview.wszFileName);
+ SendMessageW(hWnd, WM_CLOSE, 0, 0);
+ break;
+ }
+
+ return 0;
+}
--- /dev/null
+/*
+ * Wordpad implementation - Registry functions
+ *
+ * Copyright 2007 by Alexander N. Sørnes <alex@thehandofagony.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <windows.h>
+#include <shlobj.h>
+#include <richedit.h>
+
+#include "wordpad.h"
+
+static const WCHAR key_recentfiles[] = {'R','e','c','e','n','t',' ','f','i','l','e',
+ ' ','l','i','s','t',0};
+static const WCHAR key_options[] = {'O','p','t','i','o','n','s',0};
+static const WCHAR key_rtf[] = {'R','T','F',0};
+static const WCHAR key_text[] = {'T','e','x','t',0};
+
+static const WCHAR var_file[] = {'F','i','l','e','%','d',0};
+static const WCHAR var_framerect[] = {'F','r','a','m','e','R','e','c','t',0};
+static const WCHAR var_barstate0[] = {'B','a','r','S','t','a','t','e','0',0};
+
+static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey)
+{
+ LONG ret;
+ static const WCHAR wszProgramKey[] = {'S','o','f','t','w','a','r','e','\\',
+ 'M','i','c','r','o','s','o','f','t','\\',
+ 'W','i','n','d','o','w','s','\\',
+ 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
+ 'A','p','p','l','e','t','s','\\',
+ 'W','o','r','d','p','a','d',0};
+ LPWSTR key = (LPWSTR)wszProgramKey;
+
+ if(subKey)
+ {
+ WCHAR backslash[] = {'\\',0};
+ key = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+ (lstrlenW(wszProgramKey)+lstrlenW(subKey)+lstrlenW(backslash)+1)
+ *sizeof(WCHAR));
+
+ if(!key)
+ return 1;
+
+ lstrcpyW(key, wszProgramKey);
+ lstrcatW(key, backslash);
+ lstrcatW(key, subKey);
+ }
+
+ if(action)
+ {
+ ret = RegCreateKeyExW(HKEY_CURRENT_USER, key, 0, NULL, REG_OPTION_NON_VOLATILE,
+ KEY_READ | KEY_WRITE, NULL, hKey, action);
+ } else
+ {
+ ret = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ | KEY_WRITE, hKey);
+ }
+
+ if(subKey)
+ HeapFree(GetProcessHeap(), 0, key);
+
+ return ret;
+}
+
+void registry_set_options(HWND hMainWnd)
+{
+ HKEY hKey;
+ DWORD action;
+
+ if(registry_get_handle(&hKey, &action, (LPWSTR)key_options) == ERROR_SUCCESS)
+ {
+ RECT rc;
+
+ GetWindowRect(hMainWnd, &rc);
+
+ RegSetValueExW(hKey, var_framerect, 0, REG_BINARY, (LPBYTE)&rc, sizeof(RECT));
+
+ registry_set_pagemargins(hKey);
+ }
+
+ RegCloseKey(hKey);
+}
+
+void registry_read_winrect(RECT* rc)
+{
+ HKEY hKey;
+ DWORD size = sizeof(RECT);
+
+ if(registry_get_handle(&hKey, 0, (LPWSTR)key_options) != ERROR_SUCCESS ||
+ RegQueryValueExW(hKey, var_framerect, 0, NULL, (LPBYTE)rc, &size) !=
+ ERROR_SUCCESS || size != sizeof(RECT))
+ {
+ rc->top = 0;
+ rc->left = 0;
+ rc->bottom = 300;
+ rc->right = 600;
+ }
+
+ RegCloseKey(hKey);
+}
+
+static void truncate_path(LPWSTR file, LPWSTR out, LPWSTR pos1, LPWSTR pos2)
+{
+ static const WCHAR dots[] = {'.','.','.',0};
+
+ *++pos1 = 0;
+
+ lstrcatW(out, file);
+ lstrcatW(out, dots);
+ lstrcatW(out, pos2);
+}
+
+static void format_filelist_filename(LPWSTR file, LPWSTR out)
+{
+ LPWSTR pos_basename;
+ LPWSTR truncpos1, truncpos2;
+ WCHAR myDocs[MAX_STRING_LEN];
+
+ SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, (LPWSTR)&myDocs);
+ pos_basename = file_basename(file);
+ truncpos1 = NULL;
+ truncpos2 = NULL;
+
+ *(pos_basename-1) = 0;
+ if(!lstrcmpiW(file, myDocs) || (lstrlenW(pos_basename) > FILELIST_ENTRY_LENGTH))
+ {
+ truncpos1 = pos_basename;
+ *(pos_basename-1) = '\\';
+ } else
+ {
+ LPWSTR pos;
+ BOOL morespace = FALSE;
+
+ *(pos_basename-1) = '\\';
+
+ for(pos = file; pos < pos_basename; pos++)
+ {
+ if(*pos == '\\' || *pos == '/')
+ {
+ if(truncpos1)
+ {
+ if((pos - file + lstrlenW(pos_basename)) > FILELIST_ENTRY_LENGTH)
+ break;
+
+ truncpos1 = pos;
+ morespace = TRUE;
+ break;
+ }
+
+ if((pos - file + lstrlenW(pos_basename)) > FILELIST_ENTRY_LENGTH)
+ break;
+
+ truncpos1 = pos;
+ }
+ }
+
+ if(morespace)
+ {
+ for(pos = pos_basename; pos >= truncpos1; pos--)
+ {
+ if(*pos == '\\' || *pos == '/')
+ {
+ if((truncpos1 - file + lstrlenW(pos_basename) + pos_basename - pos) > FILELIST_ENTRY_LENGTH)
+ break;
+
+ truncpos2 = pos;
+ }
+ }
+ }
+ }
+
+ if(truncpos1 == pos_basename)
+ lstrcatW(out, pos_basename);
+ else if(truncpos1 == truncpos2 || !truncpos2)
+ lstrcatW(out, file);
+ else
+ truncate_path(file, out, truncpos1, truncpos2 ? truncpos2 : (pos_basename-1));
+}
+
+void registry_read_filelist(HWND hMainWnd)
+{
+ HKEY hFileKey;
+
+ if(registry_get_handle(&hFileKey, 0, key_recentfiles) == ERROR_SUCCESS)
+ {
+ WCHAR itemText[MAX_PATH+3], buffer[MAX_PATH];
+ /* The menu item name is not the same as the file name, so we need to store
+ the file name here */
+ static WCHAR file1[MAX_PATH], file2[MAX_PATH], file3[MAX_PATH], file4[MAX_PATH];
+ WCHAR numFormat[] = {'&','%','d',' ',0};
+ LPWSTR pFile[] = {file1, file2, file3, file4};
+ DWORD pathSize = MAX_PATH*sizeof(WCHAR);
+ int i;
+ WCHAR key[6];
+ MENUITEMINFOW mi;
+ HMENU hMenu = GetMenu(hMainWnd);
+
+ mi.cbSize = sizeof(MENUITEMINFOW);
+ mi.fMask = MIIM_ID | MIIM_DATA | MIIM_STRING | MIIM_FTYPE;
+ mi.fType = MFT_STRING;
+ mi.dwTypeData = itemText;
+ mi.wID = ID_FILE_RECENT1;
+
+ RemoveMenu(hMenu, ID_FILE_RECENT_SEPARATOR, MF_BYCOMMAND);
+ for(i = 0; i < FILELIST_ENTRIES; i++)
+ {
+ wsprintfW(key, var_file, i+1);
+ RemoveMenu(hMenu, ID_FILE_RECENT1+i, MF_BYCOMMAND);
+ if(RegQueryValueExW(hFileKey, (LPWSTR)key, 0, NULL, (LPBYTE)pFile[i], &pathSize)
+ != ERROR_SUCCESS)
+ break;
+
+ mi.dwItemData = (DWORD)pFile[i];
+ wsprintfW(itemText, numFormat, i+1);
+
+ lstrcpyW(buffer, pFile[i]);
+
+ format_filelist_filename(buffer, itemText);
+
+ InsertMenuItemW(hMenu, ID_FILE_EXIT, FALSE, &mi);
+ mi.wID++;
+ pathSize = MAX_PATH*sizeof(WCHAR);
+ }
+ mi.fType = MFT_SEPARATOR;
+ mi.fMask = MIIM_FTYPE | MIIM_ID;
+ InsertMenuItemW(hMenu, ID_FILE_EXIT, FALSE, &mi);
+
+ RegCloseKey(hFileKey);
+ }
+}
+
+void registry_set_filelist(LPCWSTR newFile, HWND hMainWnd)
+{
+ HKEY hKey;
+ DWORD action;
+
+ if(registry_get_handle(&hKey, &action, key_recentfiles) == ERROR_SUCCESS)
+ {
+ LPCWSTR pFiles[FILELIST_ENTRIES];
+ int i;
+ HMENU hMenu = GetMenu(hMainWnd);
+ MENUITEMINFOW mi;
+ WCHAR buffer[6];
+
+ mi.cbSize = sizeof(MENUITEMINFOW);
+ mi.fMask = MIIM_DATA;
+
+ for(i = 0; i < FILELIST_ENTRIES; i++)
+ pFiles[i] = NULL;
+
+ for(i = 0; GetMenuItemInfoW(hMenu, ID_FILE_RECENT1+i, FALSE, &mi); i++)
+ pFiles[i] = (LPWSTR)mi.dwItemData;
+
+ if(lstrcmpiW(newFile, pFiles[0]))
+ {
+ for(i = 0; pFiles[i] && i < FILELIST_ENTRIES; i++)
+ {
+ if(!lstrcmpiW(pFiles[i], newFile))
+ {
+ int j;
+ for(j = 0; pFiles[j] && j < i; j++)
+ {
+ pFiles[i-j] = pFiles[i-j-1];
+ }
+ pFiles[0] = NULL;
+ break;
+ }
+ }
+
+ if(!pFiles[0])
+ {
+ pFiles[0] = newFile;
+ } else
+ {
+ for(i = 0; pFiles[i] && i < FILELIST_ENTRIES-1; i++)
+ pFiles[FILELIST_ENTRIES-1-i] = pFiles[FILELIST_ENTRIES-2-i];
+
+ pFiles[0] = newFile;
+ }
+
+ for(i = 0; pFiles[i] && i < FILELIST_ENTRIES; i++)
+ {
+ wsprintfW(buffer, var_file, i+1);
+ RegSetValueExW(hKey, (LPWSTR)&buffer, 0, REG_SZ, (LPBYTE)pFiles[i],
+ (lstrlenW(pFiles[i])+1)*sizeof(WCHAR));
+ }
+ }
+ }
+ RegCloseKey(hKey);
+ registry_read_filelist(hMainWnd);
+}
+
+int reg_formatindex(WPARAM format)
+{
+ return (format & SF_TEXT) ? 1 : 0;
+}
+
+void registry_read_options(void)
+{
+ HKEY hKey;
+
+ if(registry_get_handle(&hKey, 0, key_options) != ERROR_SUCCESS)
+ registry_read_pagemargins(NULL);
+ else
+ registry_read_pagemargins(hKey);
+
+ RegCloseKey(hKey);
+}
+
+static void registry_read_formatopts(int index, LPCWSTR key, DWORD barState[], DWORD wordWrap[])
+{
+ HKEY hKey;
+ DWORD action = 0;
+ BOOL fetched = FALSE;
+ barState[index] = 0;
+ wordWrap[index] = 0;
+
+ if(registry_get_handle(&hKey, &action, key) != ERROR_SUCCESS)
+ return;
+
+ if(action == REG_OPENED_EXISTING_KEY)
+ {
+ DWORD size = sizeof(DWORD);
+
+ if(RegQueryValueExW(hKey, var_barstate0, 0, NULL, (LPBYTE)&barState[index],
+ &size) == ERROR_SUCCESS)
+ fetched = TRUE;
+ }
+
+ if(!fetched)
+ barState[index] = (1 << BANDID_TOOLBAR) | (1 << BANDID_FORMATBAR) | (1 << BANDID_RULER) | (1 << BANDID_STATUSBAR);
+
+ if(index == reg_formatindex(SF_RTF))
+ wordWrap[index] = ID_WORDWRAP_WINDOW;
+ else if(index == reg_formatindex(SF_TEXT))
+ wordWrap[index] = ID_WORDWRAP_WINDOW; /* FIXME: should be ID_WORDWRAP_NONE once we support it */
+
+ RegCloseKey(hKey);
+}
+
+void registry_read_formatopts_all(DWORD barState[], DWORD wordWrap[])
+{
+ registry_read_formatopts(reg_formatindex(SF_RTF), key_rtf, barState, wordWrap);
+ registry_read_formatopts(reg_formatindex(SF_TEXT), key_text, barState, wordWrap);
+}
+
+static void registry_set_formatopts(int index, LPCWSTR key, DWORD barState[])
+{
+ HKEY hKey;
+ DWORD action = 0;
+
+ if(registry_get_handle(&hKey, &action, key) == ERROR_SUCCESS)
+ {
+ RegSetValueExW(hKey, var_barstate0, 0, REG_DWORD, (LPBYTE)&barState[index],
+ sizeof(DWORD));
+
+ RegCloseKey(hKey);
+ }
+}
+
+void registry_set_formatopts_all(DWORD barState[])
+{
+ registry_set_formatopts(reg_formatindex(SF_RTF), key_rtf, barState);
+ registry_set_formatopts(reg_formatindex(SF_TEXT), key_text, barState);
+}
#include <windef.h>
#include <winuser.h>
-#include "resource.h"
+#include "wordpad.h"
MAINACCELTABLE ACCELERATORS
BEGIN
"1", ID_BACK_1, VIRTKEY, CONTROL
"2", ID_BACK_2, VIRTKEY, CONTROL
- "L", ID_ALIGN_LEFT, VIRTKEY, CONTROL
- "E", ID_ALIGN_CENTER, VIRTKEY, CONTROL
- "R", ID_ALIGN_RIGHT, VIRTKEY, CONTROL
+ "L", ID_ALIGN_LEFT, VIRTKEY, CONTROL
+ "E", ID_ALIGN_CENTER, VIRTKEY, CONTROL
+ "R", ID_ALIGN_RIGHT, VIRTKEY, CONTROL
"F", ID_FIND, VIRTKEY, CONTROL
VK_F3, ID_FIND_NEXT, VIRTKEY
"H", ID_REPLACE, VIRTKEY, CONTROL
- "A", ID_EDIT_SELECTALL, VIRTKEY, CONTROL
- "X", ID_EDIT_CUT, VIRTKEY, CONTROL
- "C", ID_EDIT_COPY, VIRTKEY, CONTROL
- "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL
- "Y", ID_EDIT_REDO, VIRTKEY, CONTROL
- "B", ID_FORMAT_BOLD, VIRTKEY, CONTROL
- "I", ID_FORMAT_ITALIC, VIRTKEY, CONTROL
+ "A", ID_EDIT_SELECTALL, VIRTKEY, CONTROL
+ "X", ID_EDIT_CUT, VIRTKEY, CONTROL
+ "C", ID_EDIT_COPY, VIRTKEY, CONTROL
+ "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL
+ "Y", ID_EDIT_REDO, VIRTKEY, CONTROL
+ "B", ID_FORMAT_BOLD, VIRTKEY, CONTROL
+ "I", ID_FORMAT_ITALIC, VIRTKEY, CONTROL
"U", ID_FORMAT_UNDERLINE,VIRTKEY, CONTROL
- "N", ID_FILE_NEW, VIRTKEY, CONTROL
- "O", ID_FILE_OPEN, VIRTKEY, CONTROL
- "S", ID_FILE_SAVE, VIRTKEY, CONTROL
+ "N", ID_FILE_NEW, VIRTKEY, CONTROL
+ "O", ID_FILE_OPEN, VIRTKEY, CONTROL
+ "S", ID_FILE_SAVE, VIRTKEY, CONTROL
"P", ID_PRINT, VIRTKEY, CONTROL
END
#define WIN32_LEAN_AND_MEAN
//#define _WIN32_IE 0x0400
-#define MAX_STRING_LEN 255
-
#include <stdarg.h>
+#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <richedit.h>
#include <commctrl.h>
#include <commdlg.h>
-#include <shlobj.h>
#include <shellapi.h>
#include <math.h>
#include <errno.h>
-#include "resource.h"
+#include "wordpad.h"
#ifdef NONAMELESSUNION
# define U(x) (x).u
/* use LoadString */
static const WCHAR xszAppTitle[] = {'W','i','n','e',' ','W','o','r','d','p','a','d',0};
-static const WCHAR xszMainMenu[] = {'M','A','I','N','M','E','N','U',0};
static const WCHAR wszRichEditClass[] = {'R','I','C','H','E','D','I','T','2','0','W',0};
static const WCHAR wszMainWndClass[] = {'W','O','R','D','P','A','D','T','O','P',0};
static const WCHAR wszAppTitle[] = {'W','i','n','e',' ','W','o','r','d','p','a','d',0};
-static const WCHAR key_recentfiles[] = {'R','e','c','e','n','t',' ','f','i','l','e',
- ' ','l','i','s','t',0};
-static const WCHAR key_options[] = {'O','p','t','i','o','n','s',0};
-static const WCHAR key_rtf[] = {'R','T','F',0};
-static const WCHAR key_text[] = {'T','e','x','t',0};
-
-static const WCHAR var_file[] = {'F','i','l','e','%','d',0};
-static const WCHAR var_framerect[] = {'F','r','a','m','e','R','e','c','t',0};
-static const WCHAR var_barstate0[] = {'B','a','r','S','t','a','t','e','0',0};
-static const WCHAR var_pagemargin[] = {'P','a','g','e','M','a','r','g','i','n',0};
-
static const WCHAR stringFormat[] = {'%','2','d','\0'};
static HWND hMainWnd;
static UINT ID_FINDMSGSTRING;
+static DWORD wordWrap[2];
+static DWORD barState[2];
+static WPARAM fileFormat = SF_RTF;
+
+static WCHAR wszFileName[MAX_PATH];
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];
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);
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);
SendMessageW(hwndToolBar, TB_ADDBUTTONSW, 1, (LPARAM)&button);
}
-static void AddTextButton(HWND hWnd, int string, int command, int id)
-{
- REBARBANDINFOW rb;
- HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hMainWnd, GWLP_HINSTANCE);
- static const WCHAR button[] = {'B','U','T','T','O','N',0};
- WCHAR text[MAX_STRING_LEN];
- HWND hButton;
- RECT rc;
-
- LoadStringW(hInstance, string, text, MAX_STRING_LEN);
- hButton = CreateWindowW(button, text,
- WS_VISIBLE | WS_CHILD, 5, 5, 100, 15,
- hMainWnd, (HMENU)command, hInstance, NULL);
-
- rb.cbSize = sizeof(rb);
- rb.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_ID;
- rb.fStyle = RBBS_NOGRIPPER | RBBS_VARIABLEHEIGHT;
- rb.hwndChild = hButton;
- rb.cyChild = rb.cyMinChild = 22;
- rb.cx = rb.cxMinChild = 90;
- rb.cxIdeal = 100;
- rb.wID = id;
-
- rc.bottom = 22;
- rc.right = 90;
-
- SendMessageW(hWnd, RB_INSERTBAND, -1, (LPARAM)&rb);
- SetWindowPos(hButton, 0, 0, 0, 90, 22, SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
-}
-
static void AddSeparator(HWND hwndToolBar)
{
TBBUTTON button;
return 0;
}
-
-static LPWSTR file_basename(LPWSTR path)
+LPWSTR file_basename(LPWSTR path)
{
LPWSTR pos = path + lstrlenW(path);
return pos;
}
-static WCHAR wszFileName[MAX_PATH];
-static WPARAM fileFormat = SF_RTF;
-
static void set_caption(LPCWSTR wszNewFileName)
{
static const WCHAR wszSeparator[] = {' ','-',' '};
HeapFree(GetProcessHeap(), 0, wszCaption);
}
-static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey)
-{
- LONG ret;
- static const WCHAR wszProgramKey[] = {'S','o','f','t','w','a','r','e','\\',
- 'M','i','c','r','o','s','o','f','t','\\',
- 'W','i','n','d','o','w','s','\\',
- 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
- 'A','p','p','l','e','t','s','\\',
- 'W','o','r','d','p','a','d',0};
- LPWSTR key = (LPWSTR)wszProgramKey;
-
- if(subKey)
- {
- WCHAR backslash[] = {'\\',0};
- key = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
- (lstrlenW(wszProgramKey)+lstrlenW(subKey)+lstrlenW(backslash)+1)
- *sizeof(WCHAR));
-
- if(!key)
- return 1;
-
- lstrcpyW(key, wszProgramKey);
- lstrcatW(key, backslash);
- lstrcatW(key, subKey);
- }
-
- if(action)
- {
- ret = RegCreateKeyExW(HKEY_CURRENT_USER, key, 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_READ | KEY_WRITE, NULL, hKey, action);
- } else
- {
- ret = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ | KEY_WRITE, hKey);
- }
-
- if(subKey)
- HeapFree(GetProcessHeap(), 0, key);
-
- return ret;
-}
-
-static RECT margins;
-
-static void registry_set_options(void)
-{
- HKEY hKey;
- DWORD action;
-
- if(registry_get_handle(&hKey, &action, (LPWSTR)key_options) == ERROR_SUCCESS)
- {
- RECT rc;
-
- GetWindowRect(hMainWnd, &rc);
-
- RegSetValueExW(hKey, var_framerect, 0, REG_BINARY, (LPBYTE)&rc, sizeof(RECT));
-
- RegSetValueExW(hKey, var_pagemargin, 0, REG_BINARY, (LPBYTE)&margins, sizeof(RECT));
- }
-}
-
-static RECT registry_read_winrect(void)
-{
- HKEY hKey;
- RECT rc;
- DWORD size = sizeof(RECT);
-
- ZeroMemory(&rc, sizeof(RECT));
- if(registry_get_handle(&hKey, 0, (LPWSTR)key_options) != ERROR_SUCCESS ||
- RegQueryValueExW(hKey, var_framerect, 0, NULL, (LPBYTE)&rc, &size) !=
- ERROR_SUCCESS || size != sizeof(RECT))
- {
- rc.top = 0;
- rc.left = 0;
- rc.bottom = 300;
- rc.right = 600;
- }
-
- RegCloseKey(hKey);
- return rc;
-}
-
-static void truncate_path(LPWSTR file, LPWSTR out, LPWSTR pos1, LPWSTR pos2)
-{
- static const WCHAR dots[] = {'.','.','.',0};
-
- *++pos1 = 0;
-
- lstrcatW(out, file);
- lstrcatW(out, dots);
- lstrcatW(out, pos2);
-}
-
-static void format_filelist_filename(LPWSTR file, LPWSTR out)
-{
- LPWSTR pos_basename;
- LPWSTR truncpos1, truncpos2;
- WCHAR myDocs[MAX_STRING_LEN];
-
- SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, (LPWSTR)&myDocs);
- pos_basename = file_basename(file);
- truncpos1 = NULL;
- truncpos2 = NULL;
-
- *(pos_basename-1) = 0;
- if(!lstrcmpiW(file, myDocs) || (lstrlenW(pos_basename) > FILELIST_ENTRY_LENGTH))
- {
- truncpos1 = pos_basename;
- *(pos_basename-1) = '\\';
- } else
- {
- LPWSTR pos;
- BOOL morespace = FALSE;
-
- *(pos_basename-1) = '\\';
-
- for(pos = file; pos < pos_basename; pos++)
- {
- if(*pos == '\\' || *pos == '/')
- {
- if(truncpos1)
- {
- if((pos - file + lstrlenW(pos_basename)) > FILELIST_ENTRY_LENGTH)
- break;
-
- truncpos1 = pos;
- morespace = TRUE;
- break;
- }
-
- if((pos - file + lstrlenW(pos_basename)) > FILELIST_ENTRY_LENGTH)
- break;
-
- truncpos1 = pos;
- }
- }
-
- if(morespace)
- {
- for(pos = pos_basename; pos >= truncpos1; pos--)
- {
- if(*pos == '\\' || *pos == '/')
- {
- if((truncpos1 - file + lstrlenW(pos_basename) + pos_basename - pos) > FILELIST_ENTRY_LENGTH)
- break;
-
- truncpos2 = pos;
- }
- }
- }
- }
-
- if(truncpos1 == pos_basename)
- lstrcatW(out, pos_basename);
- else if(truncpos1 == truncpos2 || !truncpos2)
- lstrcatW(out, file);
- else
- truncate_path(file, out, truncpos1, truncpos2 ? truncpos2 : (pos_basename-1));
-}
-
-static void registry_read_filelist(HWND hMainWnd)
-{
- HKEY hFileKey;
-
- if(registry_get_handle(&hFileKey, 0, key_recentfiles) == ERROR_SUCCESS)
- {
- WCHAR itemText[MAX_PATH+3], buffer[MAX_PATH];
- /* The menu item name is not the same as the file name, so we need to store
- the file name here */
- static WCHAR file1[MAX_PATH], file2[MAX_PATH], file3[MAX_PATH], file4[MAX_PATH];
- WCHAR numFormat[] = {'&','%','d',' ',0};
- LPWSTR pFile[] = {file1, file2, file3, file4};
- DWORD pathSize = MAX_PATH*sizeof(WCHAR);
- int i;
- WCHAR key[6];
- MENUITEMINFOW mi;
- HMENU hMenu = GetMenu(hMainWnd);
-
- mi.cbSize = sizeof(MENUITEMINFOW);
- mi.fMask = MIIM_ID | MIIM_DATA | MIIM_STRING | MIIM_FTYPE;
- mi.fType = MFT_STRING;
- mi.dwTypeData = itemText;
- mi.wID = ID_FILE_RECENT1;
-
- RemoveMenu(hMenu, ID_FILE_RECENT_SEPARATOR, MF_BYCOMMAND);
- for(i = 0; i < FILELIST_ENTRIES; i++)
- {
- wsprintfW(key, var_file, i+1);
- RemoveMenu(hMenu, ID_FILE_RECENT1+i, MF_BYCOMMAND);
- if(RegQueryValueExW(hFileKey, (LPWSTR)key, 0, NULL, (LPBYTE)pFile[i], &pathSize)
- != ERROR_SUCCESS)
- break;
-
- mi.dwItemData = (DWORD)pFile[i];
- wsprintfW(itemText, numFormat, i+1);
-
- lstrcpyW(buffer, pFile[i]);
-
- format_filelist_filename(buffer, itemText);
-
- InsertMenuItemW(hMenu, ID_FILE_EXIT, FALSE, &mi);
- mi.wID++;
- pathSize = MAX_PATH*sizeof(WCHAR);
- }
- mi.fType = MFT_SEPARATOR;
- mi.fMask = MIIM_FTYPE | MIIM_ID;
- InsertMenuItemW(hMenu, ID_FILE_EXIT, FALSE, &mi);
-
- RegCloseKey(hFileKey);
- }
-}
-
-static void registry_set_filelist(LPCWSTR newFile)
-{
- HKEY hKey;
- DWORD action;
-
- if(registry_get_handle(&hKey, &action, key_recentfiles) == ERROR_SUCCESS)
- {
- LPCWSTR pFiles[FILELIST_ENTRIES];
- int i;
- HMENU hMenu = GetMenu(hMainWnd);
- MENUITEMINFOW mi;
- WCHAR buffer[6];
-
- mi.cbSize = sizeof(MENUITEMINFOW);
- mi.fMask = MIIM_DATA;
-
- for(i = 0; i < FILELIST_ENTRIES; i++)
- pFiles[i] = NULL;
-
- for(i = 0; GetMenuItemInfoW(hMenu, ID_FILE_RECENT1+i, FALSE, &mi); i++)
- pFiles[i] = (LPWSTR)mi.dwItemData;
-
- if(lstrcmpiW(newFile, pFiles[0]))
- {
- for(i = 0; pFiles[i] && i < FILELIST_ENTRIES; i++)
- {
- if(!lstrcmpiW(pFiles[i], newFile))
- {
- int j;
- for(j = 0; pFiles[j] && j < i; j++)
- {
- pFiles[i-j] = pFiles[i-j-1];
- }
- pFiles[0] = NULL;
- break;
- }
- }
-
- if(!pFiles[0])
- {
- pFiles[0] = newFile;
- } else
- {
- for(i = 0; pFiles[i] && i < FILELIST_ENTRIES-1; i++)
- pFiles[FILELIST_ENTRIES-1-i] = pFiles[FILELIST_ENTRIES-2-i];
-
- pFiles[0] = newFile;
- }
-
- for(i = 0; pFiles[i] && i < FILELIST_ENTRIES; i++)
- {
- wsprintfW(buffer, var_file, i+1);
- RegSetValueExW(hKey, (LPWSTR)&buffer, 0, REG_SZ, (LPBYTE)pFiles[i],
- (lstrlenW(pFiles[i])+1)*sizeof(WCHAR));
- }
- }
- }
- RegCloseKey(hKey);
- registry_read_filelist(hMainWnd);
-}
-
static BOOL validate_endptr(LPCSTR endptr, BOOL units)
{
if(!endptr || !*endptr)
SendMessageW(hEditorWnd, EM_SETPARAFORMAT, 0, (LPARAM)&pf);
}
-static int reg_formatindex(WPARAM format)
-{
- return (format & SF_TEXT) ? 1 : 0;
-}
-
static int fileformat_number(WPARAM format)
{
int number = 0;
cbItem.lParam = MAKELONG(fontType,fontHeight);
SendMessageW(hListWnd, CBEM_INSERTITEMW, 0, (LPARAM)&cbItem);
- HeapFree( GetProcessHeap(), 0, cbItem.pszText );
+ HeapFree( GetProcessHeap(), 0, cbItem.pszText );
}
static void dialog_choose_font(void)
(void) OnSize(hMainWnd, SIZE_RESTORED, MAKELONG(rect.bottom, rect.right));
}
-static DWORD barState[2];
-static DWORD wordWrap[2];
-
static BOOL is_bar_visible(int bandId)
{
return barState[reg_formatindex(fileFormat)] & (1 << bandId);
update_window();
}
-static HGLOBAL devMode;
-static HGLOBAL devNames;
-
-static HDC make_dc(void)
-{
- if(devNames && devMode)
- {
- LPDEVNAMES dn = GlobalLock(devNames);
- LPDEVMODEW dm = GlobalLock(devMode);
- HDC ret;
-
- ret = CreateDCW((LPWSTR)dn + dn->wDriverOffset,
- (LPWSTR)dn + dn->wDeviceOffset, 0, dm);
-
- GlobalUnlock(dn);
- GlobalUnlock(dm);
-
- return ret;
- } else
- {
- return 0;
- }
-}
-
-static LONG twips_to_pixels(int twips, int dpi)
-{
- float ret = ((float)twips / ((float)567 * 2.54)) * (float)dpi;
- return (LONG)ret;
-}
-
-static LONG devunits_to_twips(int units, int dpi)
-{
- float ret = ((float)units / (float)dpi) * (float)567 * 2.54;
- return (LONG)ret;
-}
-
-static LONG centmm_to_twips(int mm)
-{
- return MulDiv(mm, 567, 1000);
-}
-
-static LONG twips_to_centmm(int twips)
-{
- return MulDiv(twips, 1000, 567);
-}
-
-static RECT get_print_rect(HDC hdc)
-{
- RECT rc;
- int width, height;
-
- if(hdc)
- {
- int dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
- int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
- width = devunits_to_twips(GetDeviceCaps(hdc, PHYSICALWIDTH), dpiX);
- height = devunits_to_twips(GetDeviceCaps(hdc, PHYSICALHEIGHT), dpiY);
- } else
- {
- width = centmm_to_twips(18500);
- height = centmm_to_twips(27000);
- }
-
- rc.left = margins.left;
- rc.right = width - margins.right;
- rc.top = margins.top;
- rc.bottom = height - margins.bottom;
-
- return rc;
-}
-
-static void target_device(void)
+static void preview_exit(HWND hMainWnd)
{
- HDC hdc = make_dc();
- int width = 0;
- int index = reg_formatindex(fileFormat);
+ HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hMainWnd, GWLP_HINSTANCE);
+ HMENU hMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDM_MAINMENU));
+ HWND hEditorWnd = GetDlgItem(hMainWnd, IDC_EDITOR);
- if(wordWrap[index] == ID_WORDWRAP_MARGIN)
- {
- RECT rc = get_print_rect(hdc);
- width = rc.right;
- }
+ set_bar_states();
+ ShowWindow(hEditorWnd, TRUE);
- if(!hdc)
- {
- HDC hMaindc = GetDC(hMainWnd);
- hdc = CreateCompatibleDC(hMaindc);
- ReleaseDC(hMainWnd, hMaindc);
- }
+ close_preview(hMainWnd);
- SendMessageW(hEditorWnd, EM_SETTARGETDEVICE, (WPARAM)hdc, width);
+ SetMenu(hMainWnd, hMenu);
+ registry_read_filelist(hMainWnd);
- DeleteDC(hdc);
+ update_window();
}
static void set_fileformat(WPARAM format)
set_bar_states();
set_default_font();
- target_device();
+ target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]);
}
static void DoOpenFile(LPCWSTR szOpenFileName)
} else if(readOut >= 5)
{
static const char header[] = "{\\rtf";
+ static const BYTE STG_magic[] = { 0xd0,0xcf,0x11,0xe0 };
+
if(!memcmp(header, fileStart, 5))
format = SF_RTF;
+ else if (!memcmp(STG_magic, fileStart, sizeof(STG_magic)))
+ {
+ CloseHandle(hFile);
+ MessageBoxW(hMainWnd, MAKEINTRESOURCEW(STRING_OLE_STORAGE_NOT_SUPPORTED), wszAppTitle,
+ MB_OK | MB_ICONEXCLAMATION);
+ return;
+ }
}
es.dwCookie = (DWORD_PTR)hFile;
lstrcpyW(wszFileName, szOpenFileName);
SendMessageW(hEditorWnd, EM_SETMODIFY, FALSE, 0);
- registry_set_filelist(szOpenFileName);
+ registry_set_filelist(szOpenFileName, hMainWnd);
update_font_list();
}
}
}
-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 int get_num_pages(FORMATRANGE fr)
-{
- int page = 0;
-
- do
- {
- page++;
- fr.chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE,
- (LPARAM)&fr);
- }
- while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax);
-
- return page;
-}
-
-static void char_from_pagenum(FORMATRANGE *fr, int page)
-{
- int i;
-
- for(i = 1; i <= page; i++)
- {
- if(i == page)
- break;
-
- fr->chrg.cpMin = SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)fr);
- }
-}
-
-static void print(LPPRINTDLGW pd)
-{
- FORMATRANGE fr;
- DOCINFOW di;
- int printedPages = 0;
-
- fr.hdc = pd->hDC;
- fr.hdcTarget = pd->hDC;
-
- fr.rc = get_print_rect(fr.hdc);
- fr.rcPage.left = 0;
- fr.rcPage.right = fr.rc.right + margins.right;
- fr.rcPage.top = 0;
- fr.rcPage.bottom = fr.rc.bottom + margins.bottom;
-
- 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)>, 0);
-
- if(pd->Flags & PD_PAGENUMS)
- char_from_pagenum(&fr, pd->nToPage);
- }
-
- 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;
-
- printedPages++;
- if((pd->Flags & PD_PAGENUMS) && (printedPages > (pd->nToPage - pd->nFromPage)))
- break;
- }
- while(fr.chrg.cpMin && fr.chrg.cpMin < fr.chrg.cpMax);
-
- EndDoc(fr.hdc);
- SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, 0);
- target_device();
-}
-
-static void dialog_printsetup(void)
-{
- PAGESETUPDLGW ps;
-
- ZeroMemory(&ps, sizeof(ps));
- ps.lStructSize = sizeof(ps);
- ps.hwndOwner = hMainWnd;
- ps.Flags = PSD_INHUNDREDTHSOFMILLIMETERS | PSD_MARGINS;
- ps.rtMargin.left = twips_to_centmm(margins.left);
- ps.rtMargin.right = twips_to_centmm(margins.right);
- ps.rtMargin.top = twips_to_centmm(margins.top);
- ps.rtMargin.bottom = twips_to_centmm(margins.bottom);
- ps.hDevMode = devMode;
- ps.hDevNames = devNames;
-
- if(PageSetupDlgW(&ps))
- {
- margins.left = centmm_to_twips(ps.rtMargin.left);
- margins.right = centmm_to_twips(ps.rtMargin.right);
- margins.top = centmm_to_twips(ps.rtMargin.top);
- margins.bottom = centmm_to_twips(ps.rtMargin.bottom);
- devMode = ps.hDevMode;
- devNames = ps.hDevNames;
- target_device();
- }
-}
-
-static void get_default_printer_opts(void)
-{
- PRINTDLGW pd;
- ZeroMemory(&pd, sizeof(pd));
-
- ZeroMemory(&pd, sizeof(pd));
- pd.lStructSize = sizeof(pd);
- pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT;
- pd.hwndOwner = hMainWnd;
- pd.hDevMode = devMode;
-
- PrintDlgW(&pd);
-
- devMode = pd.hDevMode;
- devNames = pd.hDevNames;
-}
-
-static void print_quick(void)
-{
- PRINTDLGW pd;
-
- ZeroMemory(&pd, sizeof(pd));
- pd.hDC = make_dc();
-
- print(&pd);
-}
-
-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;
- pd.hDevMode = devMode;
- pd.hDevNames = devNames;
-
- SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&from, (LPARAM)&to);
- if(from == to)
- pd.Flags |= PD_NOSELECTION;
-
- if(PrintDlgW(&pd))
- {
- devMode = pd.hDevMode;
- devNames = pd.hDevNames;
- print(&pd);
- }
-}
-
-typedef struct _previewinfo
-{
- int page;
- int pages;
- HDC hdc;
- HDC hdcSized;
- RECT window;
-} previewinfo, *ppreviewinfo;
-
-static previewinfo preview;
-
-static void preview_bar_show(BOOL show)
-{
- HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR);
- int i;
-
- if(show)
- {
- REBARBANDINFOW rb;
-
- AddTextButton(hReBar, STRING_PREVIEW_PRINT, ID_PRINT, BANDID_PREVIEW_BTN1);
- AddTextButton(hReBar, STRING_PREVIEW_NEXTPAGE, ID_PREVIEW_NEXTPAGE, BANDID_PREVIEW_BTN2);
- AddTextButton(hReBar, STRING_PREVIEW_PREVPAGE, ID_PREVIEW_PREVPAGE, BANDID_PREVIEW_BTN3);
- AddTextButton(hReBar, STRING_PREVIEW_CLOSE, ID_FILE_EXIT, BANDID_PREVIEW_BTN4);
-
- rb.cbSize = sizeof(rb);
- rb.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_CHILD | RBBIM_IDEALSIZE | RBBIM_ID;
- rb.fStyle = RBBS_NOGRIPPER | RBBS_VARIABLEHEIGHT;
- rb.cyChild = rb.cyMinChild = 22;
- rb.cx = rb.cxMinChild = 90;
- rb.cxIdeal = 100;
- rb.wID = BANDID_PREVIEW_BUFFER;
-
- SendMessageW(hReBar, RB_INSERTBAND, -1, (LPARAM)&rb);
- } else
- {
- for(i = 0; i <= PREVIEW_BUTTONS; i++)
- SendMessageW(hReBar, RB_DELETEBAND, SendMessageW(hReBar, RB_IDTOINDEX, BANDID_PREVIEW_BTN1+i, 0), 0);
- }
-}
-
-static void preview_exit(void)
-{
- HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hMainWnd, GWLP_HINSTANCE);
- HMENU hMenu = LoadMenuW(hInstance, xszMainMenu);
-
- set_bar_states();
- preview.window.right = 0;
- preview.window.bottom = 0;
- preview.page = 0;
- preview.pages = 0;
- ShowWindow(hEditorWnd, TRUE);
-
- preview_bar_show(FALSE);
-
- SetMenu(hMainWnd, hMenu);
- registry_read_filelist(hMainWnd);
-
- update_window();
-}
-
-static LRESULT print_preview(void)
-{
- FORMATRANGE fr;
- GETTEXTLENGTHEX gt;
- HDC hdc;
- RECT window, background;
- HBITMAP hBitmapCapture, hBitmapScaled;
- int bmWidth, bmHeight, bmNewWidth, bmNewHeight;
- float ratioWidth, ratioHeight, ratio;
- int xOffset, yOffset;
- int barheight;
- HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR);
- PAINTSTRUCT ps;
-
- hdc = BeginPaint(hMainWnd, &ps);
- GetClientRect(hMainWnd, &window);
-
- fr.hdcTarget = make_dc();
- fr.rc = get_print_rect(fr.hdcTarget);
- fr.rcPage.left = 0;
- fr.rcPage.top = 0;
- fr.rcPage.bottom = fr.rc.bottom + margins.bottom;
- fr.rcPage.right = fr.rc.right + margins.right;
-
- bmWidth = twips_to_pixels(fr.rcPage.right, GetDeviceCaps(hdc, LOGPIXELSX));
- bmHeight = twips_to_pixels(fr.rcPage.bottom, GetDeviceCaps(hdc, LOGPIXELSY));
-
- hBitmapCapture = CreateCompatibleBitmap(hdc, bmWidth, bmHeight);
-
- if(!preview.hdc)
- {
- RECT paper;
-
- preview.hdc = CreateCompatibleDC(hdc);
- fr.hdc = preview.hdc;
- gt.flags = GTL_DEFAULT;
- gt.codepage = 1200;
- fr.chrg.cpMin = 0;
- fr.chrg.cpMax = SendMessageW(hEditorWnd, EM_GETTEXTLENGTHEX, (WPARAM)>, 0);
-
- paper.left = 0;
- paper.right = bmWidth;
- paper.top = 0;
- paper.bottom = bmHeight;
-
- if(!preview.pages)
- preview.pages = get_num_pages(fr);
-
- SelectObject(preview.hdc, hBitmapCapture);
-
- char_from_pagenum(&fr, preview.page);
-
- FillRect(preview.hdc, &paper, GetStockObject(WHITE_BRUSH));
- SendMessageW(hEditorWnd, EM_FORMATRANGE, TRUE, (LPARAM)&fr);
- SendMessageW(hEditorWnd, EM_FORMATRANGE, FALSE, 0);
-
- EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_PREVPAGE), preview.page > 1);
- EnableWindow(GetDlgItem(hReBar, ID_PREVIEW_NEXTPAGE), preview.page < preview.pages);
- }
-
- barheight = SendMessageW(hReBar, RB_GETBARHEIGHT, 0, 0);
- ratioWidth = ((float)window.right - 20.0) / (float)bmHeight;
- ratioHeight = ((float)window.bottom - 20.0 - (float)barheight) / (float)bmHeight;
-
- if(ratioWidth > ratioHeight)
- ratio = ratioHeight;
- else
- ratio = ratioWidth;
-
- bmNewWidth = (int)((float)bmWidth * ratio);
- bmNewHeight = (int)((float)bmHeight * ratio);
- hBitmapScaled = CreateCompatibleBitmap(hdc, bmNewWidth, bmNewHeight);
-
- xOffset = ((window.right - bmNewWidth) / 2);
- yOffset = ((window.bottom - bmNewHeight + barheight) / 2);
-
- if(window.right != preview.window.right || window.bottom != preview.window.bottom)
- {
- DeleteDC(preview.hdcSized),
- preview.hdcSized = CreateCompatibleDC(hdc);
- SelectObject(preview.hdcSized, hBitmapScaled);
-
- StretchBlt(preview.hdcSized, 0, 0, bmNewWidth, bmNewHeight, preview.hdc, 0, 0, bmWidth, bmHeight, SRCCOPY);
- }
-
- window.top = barheight;
- FillRect(hdc, &window, GetStockObject(GRAY_BRUSH));
-
- SelectObject(hdc, hBitmapScaled);
-
- background.left = xOffset - 2;
- background.right = xOffset + bmNewWidth + 2;
- background.top = yOffset - 2;
- background.bottom = yOffset + bmNewHeight + 2;
-
- FillRect(hdc, &background, GetStockObject(BLACK_BRUSH));
-
- BitBlt(hdc, xOffset, yOffset, bmNewWidth, bmNewHeight, preview.hdcSized, 0, 0, SRCCOPY);
-
- DeleteDC(fr.hdcTarget);
- preview.window = window;
-
- EndPaint(hMainWnd, &ps);
-
- return 0;
-}
-
-static LRESULT preview_command(HWND hWnd, WPARAM wParam, LPARAM lParam)
-{
- switch(LOWORD(wParam))
- {
- case ID_FILE_EXIT:
- PostMessageW(hMainWnd, WM_CLOSE, 0, 0);
- break;
-
- case ID_PREVIEW_NEXTPAGE:
- case ID_PREVIEW_PREVPAGE:
- {
- HWND hReBar = GetDlgItem(hMainWnd, IDC_REBAR);
- RECT rc;
-
- if(LOWORD(wParam) == ID_PREVIEW_NEXTPAGE)
- preview.page++;
- else
- preview.page--;
-
- preview.hdc = 0;
- preview.window.right = 0;
-
- GetClientRect(hMainWnd, &rc);
- rc.top += SendMessageW(hReBar, RB_GETBARHEIGHT, 0, 0);
- InvalidateRect(hMainWnd, &rc, TRUE);
- }
- break;
-
- case ID_PRINT:
- dialog_print();
- preview_exit();
- break;
- }
-
- return 0;
-}
-
-
static void dialog_about(void)
{
HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hMainWnd, GWLP_HINSTANCE);
U2(psh).nStartPage = 0;
PropertySheetW(&psh);
set_bar_states();
- target_device();
+ target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]);
}
static void HandleCommandLine(LPWSTR cmdline)
hFindWnd = FindTextW(fr);
}
-static void registry_read_options(void)
-{
- HKEY hKey;
- DWORD size = sizeof(RECT);
-
- if(registry_get_handle(&hKey, 0, key_options) != ERROR_SUCCESS ||
- RegQueryValueExW(hKey, var_pagemargin, 0, NULL, (LPBYTE)&margins,
- &size) != ERROR_SUCCESS || size != sizeof(RECT))
- {
- margins.top = 1417;
- margins.bottom = 1417;
- margins.left = 1757;
- margins.right = 1757;
- }
-
- RegCloseKey(hKey);
-}
-
-static void registry_read_formatopts(int index, LPCWSTR key)
-{
- HKEY hKey;
- DWORD action = 0;
- BOOL fetched = FALSE;
- barState[index] = 0;
- wordWrap[index] = 0;
-
- if(registry_get_handle(&hKey, &action, key) != ERROR_SUCCESS)
- return;
-
- if(action == REG_OPENED_EXISTING_KEY)
- {
- DWORD size = sizeof(DWORD);
-
- if(RegQueryValueExW(hKey, var_barstate0, 0, NULL, (LPBYTE)&barState[index],
- &size) == ERROR_SUCCESS)
- fetched = TRUE;
- }
-
- if(!fetched)
- barState[index] = (1 << BANDID_TOOLBAR) | (1 << BANDID_FORMATBAR) | (1 << BANDID_RULER) | (1 << BANDID_STATUSBAR);
-
- if(index == reg_formatindex(SF_RTF))
- wordWrap[index] = ID_WORDWRAP_WINDOW;
- else if(index == reg_formatindex(SF_TEXT))
- wordWrap[index] = ID_WORDWRAP_WINDOW; /* FIXME: should be ID_WORDWRAP_NONE once we support it */
-
- RegCloseKey(hKey);
-}
-
-static void registry_read_formatopts_all(void)
-{
- registry_read_formatopts(reg_formatindex(SF_RTF), key_rtf);
- registry_read_formatopts(reg_formatindex(SF_TEXT), key_text);
-}
-
-static void registry_set_formatopts(int index, LPCWSTR key)
-{
- HKEY hKey;
- DWORD action = 0;
-
- if(registry_get_handle(&hKey, &action, key) == ERROR_SUCCESS)
- {
- RegSetValueExW(hKey, var_barstate0, 0, REG_DWORD, (LPBYTE)&barState[index],
- sizeof(DWORD));
-
- RegCloseKey(hKey);
- }
-}
-
-static void registry_set_formatopts_all(void)
-{
- registry_set_formatopts(reg_formatindex(SF_RTF), key_rtf);
- registry_set_formatopts(reg_formatindex(SF_TEXT), key_text);
-}
-
static int current_units_to_twips(float number)
{
int twips = (int)(number * 567);
ID_FINDMSGSTRING = RegisterWindowMessageW(FINDMSGSTRINGW);
registry_read_filelist(hWnd);
- registry_read_formatopts_all();
+ registry_read_formatopts_all(barState, wordWrap);
registry_read_options();
DragAcceptFiles(hWnd, TRUE);
break;
case ID_PRINT:
- dialog_print();
+ dialog_print(hWnd, wszFileName);
+ target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]);
break;
case ID_PRINT_QUICK:
- print_quick();
+ print_quick(wszFileName);
+ target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]);
break;
case ID_PREVIEW:
set_bar_states();
barState[index] = tmp;
ShowWindow(hEditorWnd, FALSE);
- preview_bar_show(TRUE);
- preview.page = 1;
- preview.hdc = 0;
+ init_preview(hWnd, wszFileName);
+
SetMenu(hWnd, NULL);
InvalidateRect(0, 0, TRUE);
}
break;
case ID_PRINTSETUP:
- dialog_printsetup();
+ dialog_printsetup(hWnd);
+ target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]);
break;
case ID_FORMAT_BOLD:
return OnNotify( hWnd, wParam, lParam );
case WM_COMMAND:
- if(preview.page)
+ if(preview_isactive())
+ {
return preview_command( hWnd, wParam, lParam );
- else
- return OnCommand( hWnd, wParam, lParam );
+ }
+
+ return OnCommand( hWnd, wParam, lParam );
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_CLOSE:
- if(preview.page)
+ if(preview_isactive())
{
- preview_exit();
+ preview_exit(hWnd);
} else if(prompt_save_changes())
{
- registry_set_options();
- registry_set_formatopts_all();
+ registry_set_options(hMainWnd);
+ registry_set_formatopts_all(barState);
PostQuitMessage(0);
}
break;
}
break;
case WM_PAINT:
- if(preview.page)
- return print_preview();
+ if(preview_isactive())
+ return print_preview(hWnd);
else
return DefWindowProcW(hWnd, msg, wParam, lParam);
wc.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_WORDPAD));
wc.hCursor = LoadCursor(NULL, IDC_IBEAM);
wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
- wc.lpszMenuName = xszMainMenu;
+ wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MAINMENU);
wc.lpszClassName = wszMainWndClass;
RegisterClassW(&wc);
- rc = registry_read_winrect();
+ registry_read_winrect(&rc);
hMainWnd = CreateWindowExW(0, wszMainWndClass, wszAppTitle, WS_CLIPCHILDREN|WS_OVERLAPPEDWINDOW,
rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, NULL, NULL, hInstance, NULL);
ShowWindow(hMainWnd, SW_SHOWDEFAULT);
set_fileformat(SF_RTF);
hPopupMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDM_POPUP));
get_default_printer_opts();
- target_device();
+ target_device(hMainWnd, wordWrap[reg_formatindex(fileFormat)]);
HandleCommandLine(GetCommandLineW());
--- /dev/null
+/*
+ * Copyright 2004 by Krzysztof Foltman
+ * Copyright 2007 by Alexander N. Sørnes <alex@thehandofagony.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define MAX_STRING_LEN 255
+
+#define ID_FILE_EXIT 1000
+#define ID_FILE_OPEN 1001
+#define ID_FILE_SAVE 1002
+#define ID_FILE_NEW 1003
+#define ID_FILE_SAVEAS 1004
+
+#define ID_FILE_RECENT1 1005
+#define ID_FILE_RECENT2 1006
+#define ID_FILE_RECENT3 1007
+#define ID_FILE_RECENT4 1008
+#define ID_FILE_RECENT_SEPARATOR 1009
+
+#define ID_PRINT 1010
+#define ID_PREVIEW 1011
+#define ID_PRINTSETUP 1012
+#define ID_PRINT_QUICK 1013
+
+#define ID_FIND 1014
+#define ID_FIND_NEXT 1015
+#define ID_REPLACE 1016
+
+#define ID_PREVIEW_NEXTPAGE 1017
+#define ID_PREVIEW_PREVPAGE 1018
+
+#define ID_ALIGN_LEFT 1100
+#define ID_ALIGN_CENTER 1101
+#define ID_ALIGN_RIGHT 1102
+
+#define ID_BACK_1 1200
+#define ID_BACK_2 1201
+
+#define ID_EDIT_SELECTALL 1300
+#define ID_EDIT_SELECTIONINFO 1301
+#define ID_EDIT_READONLY 1302
+#define ID_EDIT_MODIFIED 1303
+#define ID_EDIT_CHARFORMAT 1304
+#define ID_EDIT_PARAFORMAT 1305
+#define ID_EDIT_DEFCHARFORMAT 1306
+#define ID_EDIT_UNDO 1307
+#define ID_EDIT_REDO 1308
+#define ID_EDIT_GETTEXT 1309
+#define ID_EDIT_COPY 1310
+#define ID_EDIT_CUT 1311
+#define ID_EDIT_PASTE 1312
+#define ID_EDIT_CLEAR 1313
+#define ID_BULLET 1314
+
+#define ID_FONTSETTINGS 1315
+
+#define ID_FORMAT_BOLD 1400
+#define ID_FORMAT_ITALIC 1401
+#define ID_FORMAT_UNDERLINE 1402
+
+#define ID_TOGGLE_TOOLBAR 1500
+#define ID_TOGGLE_FORMATBAR 1501
+#define ID_TOGGLE_STATUSBAR 1502
+
+#define PREVIEW_BUTTONS 4
+
+#define FILELIST_ENTRIES 4
+#define FILELIST_ENTRY_LENGTH 33
+
+#define BANDID_TOOLBAR 2
+#define BANDID_FORMATBAR 3
+#define BANDID_RULER 0
+#define BANDID_STATUSBAR 1
+#define BANDID_FONTLIST 4
+#define BANDID_SIZELIST 5
+
+#define BANDID_PREVIEW_BTN1 6
+#define BANDID_PREVIEW_BTN2 7
+#define BANDID_PREVIEW_BTN3 8
+#define BANDID_PREVIEW_BTN4 9
+#define BANDID_PREVIEW_BUFFER 10
+
+#define ID_WORDWRAP_NONE 0
+#define ID_WORDWRAP_WINDOW 1
+#define ID_WORDWRAP_MARGIN 2
+
+#define ID_NEWFILE_ABORT 100
+
+#define ID_TAB_ADD 100
+#define ID_TAB_DEL 101
+#define ID_TAB_EMPTY 102
+
+#define IDC_PAGEFMT_TB 100
+#define IDC_PAGEFMT_FB 101
+#define IDC_PAGEFMT_SB 102
+#define IDC_PAGEFMT_WW 103
+#define IDC_PAGEFMT_WM 104
+#define IDC_PAGEFMT_ID 105
+
+#define ID_DATETIME 1600
+#define ID_PARAFORMAT 1601
+#define ID_TABSTOPS 1602
+
+#define ID_ABOUT 1603
+#define ID_VIEWPROPERTIES 1604
+
+#define IDC_STATUSBAR 2000
+#define IDC_EDITOR 2001
+#define IDC_TOOLBAR 2002
+#define IDC_FORMATBAR 2003
+#define IDC_REBAR 2004
+#define IDC_COMBO 2005
+#define IDC_DATETIME 2006
+#define IDC_NEWFILE 2007
+#define IDC_PARA_LEFT 2008
+#define IDC_PARA_RIGHT 2009
+#define IDC_PARA_FIRST 2010
+#define IDC_PARA_ALIGN 2011
+#define IDC_TABSTOPS 2012
+#define IDC_FONTLIST 2013
+#define IDC_SIZELIST 2014
+
+#define IDD_DATETIME 2100
+#define IDD_NEWFILE 2101
+#define IDD_PARAFORMAT 2102
+#define IDD_TABSTOPS 2103
+#define IDD_FORMATOPTS 2104
+
+#define IDM_MAINMENU 2200
+#define IDM_POPUP 2201
+
+#define IDB_TOOLBAR 100
+#define IDB_FORMATBAR 101
+
+#define IDI_WORDPAD 102
+#define IDI_RTF 103
+#define IDI_WRI 104
+#define IDI_TXT 105
+
+#define STRING_ALL_FILES 1400
+#define STRING_TEXT_FILES_TXT 1401
+#define STRING_TEXT_FILES_UNICODE_TXT 1402
+#define STRING_RICHTEXT_FILES_RTF 1403
+
+#define STRING_NEWFILE_RICHTEXT 1404
+#define STRING_NEWFILE_TXT 1405
+#define STRING_NEWFILE_TXT_UNICODE 1406
+
+#define STRING_ALIGN_LEFT 1407
+#define STRING_ALIGN_RIGHT 1408
+#define STRING_ALIGN_CENTER 1409
+
+#define STRING_PRINTER_FILES_PRN 1410
+
+#define STRING_VIEWPROPS_TITLE 1411
+#define STRING_VIEWPROPS_TEXT 1412
+#define STRING_VIEWPROPS_RICHTEXT 1413
+
+#define STRING_PREVIEW_PRINT 1414
+#define STRING_PREVIEW_NEXTPAGE 1415
+#define STRING_PREVIEW_PREVPAGE 1416
+#define STRING_PREVIEW_CLOSE 1417
+
+#define STRING_UNITS_CM 1418
+
+#define STRING_DEFAULT_FILENAME 1700
+#define STRING_PROMPT_SAVE_CHANGES 1701
+#define STRING_SEARCH_FINISHED 1702
+#define STRING_LOAD_RICHED_FAILED 1703
+#define STRING_SAVE_LOSEFORMATTING 1704
+#define STRING_INVALID_NUMBER 1705
+#define STRING_OLE_STORAGE_NOT_SUPPORTED 1706
+
+LPWSTR file_basename(LPWSTR);
+
+void dialog_printsetup(HWND);
+void dialog_print(HWND, LPWSTR);
+void target_device(HWND, DWORD);
+void print_quick(LPWSTR);
+LRESULT preview_command(HWND, WPARAM, LPARAM);
+void init_preview(HWND, LPWSTR);
+void close_preview(HWND);
+BOOL preview_isactive(void);
+LRESULT print_preview(HWND);
+void get_default_printer_opts(void);
+void registry_set_pagemargins(HKEY);
+void registry_read_pagemargins(HKEY);
+
+int reg_formatindex(WPARAM);
+void registry_read_filelist(HWND);
+void registry_read_options(void);
+void registry_read_formatopts_all(DWORD[], DWORD[]);
+void registry_read_winrect(RECT*);
+void registry_set_filelist(LPCWSTR, HWND);
+void registry_set_formatopts_all(DWORD[]);
+void registry_set_options(HWND);
<library>shell32</library>
<library>comctl32</library>
<compilationunit name="unit.c">
+ <file>print.c</file>
+ <file>registry.c</file>
<file>wordpad.c</file>
</compilationunit>
<file>rsrc.rc</file>