4 * Copyright 1998,99 Marcel Baur <mbaur@g26.ethz.ch>
5 * To be distributed under the Wine License
32 static LRESULT
DIALOG_PAGESETUP_DlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
);
36 int AlertIDS(UINT ids_message
, UINT ids_caption
, WORD type
) {
38 * Given some ids strings, this acts as a language-aware wrapper for
41 CHAR szMessage
[MAX_STRING_LEN
];
42 CHAR szCaption
[MAX_STRING_LEN
];
44 LoadString(Globals
.hInstance
, ids_message
, szMessage
, sizeof(szMessage
));
45 LoadString(Globals
.hInstance
, ids_caption
, szCaption
, sizeof(szCaption
));
47 return (MessageBox(Globals
.hMainWnd
, szMessage
, szCaption
, type
));
50 void AlertFileNotFound(LPSTR szFileName
) {
53 CHAR szMessage
[MAX_STRING_LEN
];
54 CHAR szRessource
[MAX_STRING_LEN
];
56 /* Load and format szMessage */
57 LoadString(Globals
.hInstance
, IDS_NOTFOUND
, szRessource
, sizeof(szRessource
));
58 wvsprintf(szMessage
, szRessource
, szFileName
);
61 LoadString(Globals
.hInstance
, IDS_ERROR
, szRessource
, sizeof(szRessource
));
63 /* Display Modal Dialog */
64 nResult
= MessageBox(Globals
.hMainWnd
, szMessage
, szRessource
, MB_ICONEXCLAMATION
);
68 int AlertFileNotSaved(LPSTR szFileName
) {
71 CHAR szMessage
[MAX_STRING_LEN
];
72 CHAR szRessource
[MAX_STRING_LEN
];
74 /* Load and format Message */
76 LoadString(Globals
.hInstance
, IDS_NOTSAVED
, szRessource
, sizeof(szRessource
));
77 wvsprintf(szMessage
, szRessource
, szFileName
);
81 LoadString(Globals
.hInstance
, IDS_ERROR
, szRessource
, sizeof(szRessource
));
84 nResult
= MessageBox(Globals
.hMainWnd
, szMessage
, szRessource
, MB_ICONEXCLAMATION
+ MB_YESNOCANCEL
);
89 VOID
AlertOutOfMemory(void) {
92 nResult
= AlertIDS(IDS_OUT_OF_MEMORY
, IDS_ERROR
, MB_ICONEXCLAMATION
);
97 BOOL
ExistFile(LPCSTR szFilename
) {
99 * Returns: TRUE - if "szFileName" exists
100 * FALSE - if it does not
102 WIN32_FIND_DATA entry
;
105 hFile
= FindFirstFile(szFilename
, &entry
);
107 return (hFile
!=INVALID_HANDLE_VALUE
);
110 VOID
DoSaveFile(VOID
) {
112 /* FIXME: Really Save the file */
113 /* ... (Globals.szFileName); */
117 BOOL
DoCloseFile(void) {
118 /* Return value: TRUE - User agreed to close (both save/don't save) */
119 /* FALSE - User cancelled close by selecting "Cancel" */
123 if (strlen(Globals
.szFileName
)>0) {
124 /* prompt user to save changes */
125 nResult
= AlertFileNotSaved(Globals
.szFileName
);
127 case IDYES
: DoSaveFile();
132 case IDCANCEL
: return(FALSE
);
135 default: return(FALSE
);
140 /* Forget file name */
141 lstrcpy(Globals
.szFileName
, "");
142 LANGUAGE_UpdateWindowCaption();
147 void DoOpenFile(LPCSTR szFileName
) {
152 /* Close any files and prompt to save changes */
154 GetFileTitle(szFileName
, Globals
.szFileName
, sizeof(Globals
.szFileName
));
155 LANGUAGE_UpdateWindowCaption();
156 hFile
= _lopen(szFileName
, OF_READ
);
157 nResult
= _lread(hFile
, Globals
.Buffer
, sizeof(Globals
.Buffer
));
160 /* FIXME: Append time/date if first line contains LOGPREFIX */
161 /* (Globals.Buffer, ) */
166 VOID
DIALOG_FileNew(VOID
)
168 /* Close any files and promt to save changes */
174 VOID
DIALOG_FileOpen(VOID
)
176 OPENFILENAME openfilename
;
177 CHAR szPath
[MAX_PATHNAME_LEN
];
178 CHAR szDir
[MAX_PATHNAME_LEN
];
179 CHAR szzFilter
[2 * MAX_STRING_LEN
+ 100];
180 CHAR szDefaultExt
[4];
183 lstrcpy(szDefaultExt
, "txt");
185 LoadString(Globals
.hInstance
, IDS_TEXT_FILES_TXT
, p
, MAX_STRING_LEN
);
189 LoadString(Globals
.hInstance
, IDS_ALL_FILES
, p
, MAX_STRING_LEN
);
195 GetCurrentDirectory(sizeof(szDir
), szDir
);
196 lstrcpy(szPath
,"*.txt");
198 openfilename
.lStructSize
= sizeof(OPENFILENAME
);
199 openfilename
.hwndOwner
= Globals
.hMainWnd
;
200 openfilename
.hInstance
= Globals
.hInstance
;
201 openfilename
.lpstrFilter
= szzFilter
;
202 openfilename
.lpstrCustomFilter
= 0;
203 openfilename
.nMaxCustFilter
= 0;
204 openfilename
.nFilterIndex
= 0;
205 openfilename
.lpstrFile
= szPath
;
206 openfilename
.nMaxFile
= sizeof(szPath
);
207 openfilename
.lpstrFileTitle
= 0;
208 openfilename
.nMaxFileTitle
= 0;
209 openfilename
.lpstrInitialDir
= szDir
;
210 openfilename
.lpstrTitle
= 0;
211 openfilename
.Flags
= OFN_FILEMUSTEXIST
+ OFN_PATHMUSTEXIST
;
212 openfilename
.nFileOffset
= 0;
213 openfilename
.nFileExtension
= 0;
214 openfilename
.lpstrDefExt
= szDefaultExt
;
215 openfilename
.lCustData
= 0;
216 openfilename
.lpfnHook
= 0;
217 openfilename
.lpTemplateName
= 0;
219 if (GetOpenFileName(&openfilename
)) {
221 if (ExistFile(openfilename
.lpstrFile
))
222 DoOpenFile(openfilename
.lpstrFile
);
224 AlertFileNotFound(openfilename
.lpstrFile
);
229 VOID
DIALOG_FileSave(VOID
)
231 /* FIXME: Save File */
236 VOID
DIALOG_FileSaveAs(VOID
)
239 CHAR szPath
[MAX_PATHNAME_LEN
];
240 CHAR szDir
[MAX_PATHNAME_LEN
];
241 CHAR szDefaultExt
[4];
242 CHAR szzFilter
[2 * MAX_STRING_LEN
+ 100];
246 lstrcpy(szDefaultExt
, "txt");
248 LoadString(Globals
.hInstance
, IDS_TEXT_FILES_TXT
, p
, MAX_STRING_LEN
);
252 LoadString(Globals
.hInstance
, IDS_ALL_FILES
, p
, MAX_STRING_LEN
);
258 lstrcpy(szPath
,"*.*");
260 GetCurrentDirectory(sizeof(szDir
), szDir
);
262 saveas
.lStructSize
= sizeof(OPENFILENAME
);
263 saveas
.hwndOwner
= Globals
.hMainWnd
;
264 saveas
.hInstance
= Globals
.hInstance
;
265 saveas
.lpstrFilter
= szzFilter
;
266 saveas
.lpstrCustomFilter
= 0;
267 saveas
.nMaxCustFilter
= 0;
268 saveas
.nFilterIndex
= 0;
269 saveas
.lpstrFile
= szPath
;
270 saveas
.nMaxFile
= sizeof(szPath
);
271 saveas
.lpstrFileTitle
= 0;
272 saveas
.nMaxFileTitle
= 0;
273 saveas
.lpstrInitialDir
= szDir
;
274 saveas
.lpstrTitle
= 0;
275 saveas
.Flags
= OFN_PATHMUSTEXIST
+ OFN_OVERWRITEPROMPT
+ OFN_HIDEREADONLY
;
276 saveas
.nFileOffset
= 0;
277 saveas
.nFileExtension
= 0;
278 saveas
.lpstrDefExt
= szDefaultExt
;
279 saveas
.lCustData
= 0;
281 saveas
.lpTemplateName
= 0;
283 if (GetSaveFileName(&saveas
)) {
284 lstrcpy(Globals
.szFileName
, saveas
.lpstrFile
);
285 LANGUAGE_UpdateWindowCaption();
290 VOID
DIALOG_FilePrint(VOID
)
299 CHAR szDocumentName
[MAX_STRING_LEN
]; /* Name of document */
300 CHAR szPrinterName
[MAX_STRING_LEN
]; /* Name of the printer */
301 CHAR szDeviceName
[MAX_STRING_LEN
]; /* Name of the printer device */
302 CHAR szOutput
[MAX_STRING_LEN
]; /* in which file/device to print */
304 /* LPDEVMODE hDevMode; */
305 /* LPDEVNAMES hDevNames; */
307 /* hDevMode = GlobalAlloc(GMEM_MOVEABLE + GMEM_ZEROINIT, sizeof(DEVMODE)); */
308 /* hDevNames = GlobalAlloc(GMEM_MOVEABLE + GMEM_ZEROINIT, sizeof(DEVNAMES)); */
310 /* Get Current Settings */
312 printer
.lStructSize
= sizeof(PRINTDLG
);
313 printer
.hwndOwner
= Globals
.hMainWnd
;
314 printer
.hInstance
= Globals
.hInstance
;
316 /* Let PrintDlg create a DEVMODE structure */
317 printer
.hDevMode
= 0;
318 printer
.hDevNames
= 0;
320 printer
.Flags
= PD_RETURNDEFAULT
;
321 printer
.nFromPage
= 0;
323 printer
.nMinPage
= 0;
324 printer
.nMaxPage
= 0;
326 printer
.lCustData
= 0;
327 printer
.lpfnPrintHook
= 0;
328 printer
.lpfnSetupHook
= 0;
329 printer
.lpPrintTemplateName
= 0;
330 printer
.lpSetupTemplateName
= 0;
331 printer
.hPrintTemplate
= 0;
332 printer
.hSetupTemplate
= 0;
334 nResult
= PrintDlg(&printer
);
336 /* hContext = CreateDC(, szDeviceName, "TEST.TXT", 0); */
338 /* Congratulations to those Microsoft Engineers responsable */
339 /* for the following pointer acrobatics */
341 assert(printer
.hDevNames
!=0);
343 nBase
= (LONG
)(printer
.hDevNames
);
345 nOffset
= (WORD
)((LPDEVNAMES
) printer
.hDevNames
)->wDriverOffset
;
346 lstrcpy(szPrinterName
, (LPCSTR
) (nBase
+ nOffset
));
348 nOffset
= (WORD
)((LPDEVNAMES
) printer
.hDevNames
)->wDeviceOffset
;
349 lstrcpy(szDeviceName
, (LPCSTR
) (nBase
+ nOffset
));
351 nOffset
= (WORD
)((LPDEVNAMES
) printer
.hDevNames
)->wOutputOffset
;
352 lstrcpy(szOutput
, (LPCSTR
) (nBase
+ nOffset
));
354 MessageBox(Globals
.hMainWnd
, szPrinterName
, "Printer Name", MB_ICONEXCLAMATION
);
355 MessageBox(Globals
.hMainWnd
, szDeviceName
, "Device Name", MB_ICONEXCLAMATION
);
356 MessageBox(Globals
.hMainWnd
, szOutput
, "Output", MB_ICONEXCLAMATION
);
358 /* Set some default flags */
360 bFlags
= PD_RETURNDC
+ PD_SHOWHELP
;
363 /* Remove "Print Selection" if there is no selection */
364 bFlags
= bFlags
+ PD_NOSELECTION
;
367 printer
.Flags
= bFlags
;
369 printer.nFromPage = 0;
371 printer.nMinPage = 0;
372 printer.nMaxPage = 0;
375 /* Let commdlg manage copy settings */
376 printer
.nCopies
= (WORD
)PD_USEDEVMODECOPIES
;
378 if (PrintDlg(&printer
)) {
380 /* initialize DOCINFO */
381 di
.cbSize
= sizeof(DOCINFO
);
382 lstrcpy((LPSTR
)di
.lpszDocName
, szDocumentName
);
383 lstrcpy((LPSTR
)di
.lpszOutput
, szOutput
);
385 hContext
= printer
.hDC
;
387 assert( (int) hContext
!=PD_RETURNDC
);
389 SetMapMode(hContext
, MM_LOMETRIC
);
390 /* SetViewPortExExt(hContext, 10, 10, 0); */
391 SetBkMode(hContext
, OPAQUE
);
393 nResult
= TextOut(hContext
, 0, 0, " ", 1);
394 assert(nResult
!= 0);
396 nResult
= StartDoc(hContext
, &di
);
397 assert(nResult
!= SP_ERROR
);
399 nResult
= StartPage(hContext
);
402 /* FIXME: actually print */
404 nResult
= EndPage(hContext
);
408 MessageBox(Globals
.hMainWnd
, "Generic Error", "Print Engine Error", MB_ICONEXCLAMATION
);
411 MessageBox(Globals
.hMainWnd
, "The print job was aborted.", "Print Engine Error", MB_ICONEXCLAMATION
);
414 MessageBox(Globals
.hMainWnd
, "The print job was aborted using the Print Manager ", "Print Engine Error", MB_ICONEXCLAMATION
);
417 MessageBox(Globals
.hMainWnd
, "Out of disk space", "Print Engine Error", MB_ICONEXCLAMATION
);
423 MessageBox(Globals
.hMainWnd
, "Default", "Print", MB_ICONEXCLAMATION
);
425 nResult
= EndDoc(hContext
);
427 nResult
= DeleteDC(hContext
);
431 /* GlobalFree(hDevNames); */
432 /* GlobalFree(hDevMode); */
435 VOID
DIALOG_FilePageSetup(VOID
)
440 VOID
DIALOG_FilePrinterSetup(VOID
)
444 printer
.lStructSize
= sizeof(PRINTDLG
);
445 printer
.hwndOwner
= Globals
.hMainWnd
;
446 printer
.hInstance
= Globals
.hInstance
;
447 printer
.hDevMode
= 0;
448 printer
.hDevNames
= 0;
450 printer
.Flags
= PD_PRINTSETUP
;
451 printer
.nFromPage
= 0;
453 printer
.nMinPage
= 0;
454 printer
.nMaxPage
= 0;
456 printer
.lCustData
= 0;
457 printer
.lpfnPrintHook
= 0;
458 printer
.lpfnSetupHook
= 0;
459 printer
.lpPrintTemplateName
= 0;
460 printer
.lpSetupTemplateName
= 0;
461 printer
.hPrintTemplate
= 0;
462 printer
.hSetupTemplate
= 0;
464 if (PrintDlg(&printer
)) {
470 VOID
DIALOG_FileExit(VOID
)
477 VOID
DIALOG_EditUndo(VOID
)
479 MessageBox(Globals
.hMainWnd
, "Undo", "Debug", MB_ICONEXCLAMATION
);
483 VOID
DIALOG_EditCut(VOID
)
487 hMem
= GlobalAlloc(GMEM_ZEROINIT
, 99);
489 OpenClipboard(Globals
.hMainWnd
);
492 /* FIXME: Get text */
493 lstrcpy((CHAR
*)hMem
, "Hello World");
495 SetClipboardData(CF_TEXT
, hMem
);
501 VOID
DIALOG_EditCopy(VOID
)
505 hMem
= GlobalAlloc(GMEM_ZEROINIT
, 99);
507 OpenClipboard(Globals
.hMainWnd
);
510 /* FIXME: Get text */
511 lstrcpy((CHAR
*)hMem
, "Hello World");
513 SetClipboardData(CF_TEXT
, hMem
);
519 VOID
DIALOG_EditPaste(VOID
)
523 if (IsClipboardFormatAvailable(CF_TEXT
)) {
524 OpenClipboard(Globals
.hMainWnd
);
525 hClipText
= GetClipboardData(CF_TEXT
);
527 MessageBox(Globals
.hMainWnd
, (CHAR
*)hClipText
, "PASTE", MB_ICONEXCLAMATION
);
531 VOID
DIALOG_EditDelete(VOID
)
536 VOID
DIALOG_EditSelectAll(VOID
)
541 VOID
DIALOG_EditTimeDate(VOID
)
544 LPSYSTEMTIME lpst
= &st
;
545 CHAR szDate
[MAX_STRING_LEN
];
549 GetDateFormat(LOCALE_USER_DEFAULT
, LOCALE_SLONGDATE
, lpst
, NULL
, date
, MAX_STRING_LEN
);
550 GetTimeFormat(LOCALE_USER_DEFAULT
, LOCALE_STIMEFORMAT
, lpst
, NULL
, date
, MAX_STRING_LEN
);
554 VOID
DIALOG_EditWrap(VOID
)
556 Globals
.bWrapLongLines
= !Globals
.bWrapLongLines
;
557 CheckMenuItem(Globals
.hEditMenu
, NP_EDIT_WRAP
, MF_BYCOMMAND
|
558 (Globals
.bWrapLongLines
? MF_CHECKED
: MF_UNCHECKED
));
561 VOID
DIALOG_Search(VOID
)
563 Globals
.find
.lStructSize
= sizeof(Globals
.find
);
564 Globals
.find
.hwndOwner
= Globals
.hMainWnd
;
565 Globals
.find
.hInstance
= Globals
.hInstance
;
566 Globals
.find
.lpstrFindWhat
= (CHAR
*) &Globals
.szFindText
;
567 Globals
.find
.wFindWhatLen
= sizeof(Globals
.szFindText
);
568 Globals
.find
.lpstrReplaceWith
= 0;
569 Globals
.find
.wReplaceWithLen
= 0;
570 Globals
.find
.Flags
= FR_DOWN
;
571 Globals
.find
.lCustData
= 0;
572 Globals
.find
.lpfnHook
= 0;
573 Globals
.find
.lpTemplateName
= 0;
575 /* We only need to create the modal FindReplace dialog which will */
576 /* notify us of incoming events using hMainWnd Window Messages */
578 Globals
.hFindReplaceDlg
= FindText(&Globals
.find
);
579 assert(Globals
.hFindReplaceDlg
!=0);
582 VOID
DIALOG_SearchNext(VOID
)
587 VOID
DIALOG_HelpContents(VOID
)
589 WinHelp(Globals
.hMainWnd
, HELPFILE
, HELP_INDEX
, 0);
592 VOID
DIALOG_HelpSearch(VOID
)
597 VOID
DIALOG_HelpHelp(VOID
)
599 WinHelp(Globals
.hMainWnd
, HELPFILE
, HELP_HELPONHELP
, 0);
602 VOID
DIALOG_HelpLicense(VOID
)
604 WineLicense(Globals
.hMainWnd
, Globals
.lpszLanguage
);
607 VOID
DIALOG_HelpNoWarranty(VOID
)
609 WineWarranty(Globals
.hMainWnd
, Globals
.lpszLanguage
);
612 VOID
DIALOG_HelpAboutWine(VOID
)
614 CHAR szNotepad
[MAX_STRING_LEN
];
616 LoadString(Globals
.hInstance
, IDS_NOTEPAD
, szNotepad
, sizeof(szNotepad
));
617 ShellAbout(Globals
.hMainWnd
, szNotepad
, "Notepad\n" WINE_RELEASE_INFO
, 0);
620 /***********************************************************************
625 VOID
DIALOG_PageSetup(VOID
)
629 lpfnDlg
= MakeProcInstance(DIALOG_PAGESETUP_DlgProc
, Globals
.hInstance
);
630 DialogBox(Globals
.hInstance
, STRING_PAGESETUP_Xx
, Globals
.hMainWnd
, (DLGPROC
)lpfnDlg
);
631 FreeProcInstance(lpfnDlg
);
635 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
637 * DIALOG_PAGESETUP_DlgProc
640 static LRESULT
DIALOG_PAGESETUP_DlgProc(HWND hDlg
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
649 /* save user input and close dialog */
650 GetDlgItemText(hDlg
, NP_PAGESETUP_HEAD
, Globals
.szHeader
, sizeof(Globals
.szHeader
));
651 GetDlgItemText(hDlg
, NP_PAGESETUP_TAIL
, Globals
.szFooter
, sizeof(Globals
.szFooter
));
652 GetDlgItemText(hDlg
, NP_PAGESETUP_TOP
, Globals
.szMarginTop
, sizeof(Globals
.szMarginTop
));
653 GetDlgItemText(hDlg
, NP_PAGESETUP_BOTTOM
, Globals
.szMarginBottom
, sizeof(Globals
.szMarginBottom
));
654 GetDlgItemText(hDlg
, NP_PAGESETUP_LEFT
, Globals
.szMarginLeft
, sizeof(Globals
.szMarginLeft
));
655 GetDlgItemText(hDlg
, NP_PAGESETUP_RIGHT
, Globals
.szMarginRight
, sizeof(Globals
.szMarginRight
));
656 EndDialog(hDlg
, IDOK
);
660 /* discard user input and close dialog */
661 EndDialog(hDlg
, IDCANCEL
);
665 /* FIXME: Bring this to work */
666 MessageBox(Globals
.hMainWnd
, "Sorry, no help available", "Help", MB_ICONEXCLAMATION
);
672 /* fetch last user input prior to display dialog */
673 SetDlgItemText(hDlg
, NP_PAGESETUP_HEAD
, Globals
.szHeader
);
674 SetDlgItemText(hDlg
, NP_PAGESETUP_TAIL
, Globals
.szFooter
);
675 SetDlgItemText(hDlg
, NP_PAGESETUP_TOP
, Globals
.szMarginTop
);
676 SetDlgItemText(hDlg
, NP_PAGESETUP_BOTTOM
, Globals
.szMarginBottom
);
677 SetDlgItemText(hDlg
, NP_PAGESETUP_LEFT
, Globals
.szMarginLeft
);
678 SetDlgItemText(hDlg
, NP_PAGESETUP_RIGHT
, Globals
.szMarginRight
);