4 * Copyright 1997,98 Marcel Baur <mbaur@g26.ethz.ch>
5 * To be distributed under the Wine License
20 void LIBWINE_Register_Da();
21 void LIBWINE_Register_De();
22 void LIBWINE_Register_En();
23 void LIBWINE_Register_Sw();
26 NOTEPAD_GLOBALS Globals
;
28 /***********************************************************************
32 * All handling of main menu events
35 int NOTEPAD_MenuCommand (WPARAM wParam
)
38 case NP_FILE_NEW
: DIALOG_FileNew(); break;
39 case NP_FILE_OPEN
: DIALOG_FileOpen(); break;
40 case NP_FILE_SAVE
: DIALOG_FileSave(); break;
41 case NP_FILE_SAVEAS
: DIALOG_FileSaveAs(); break;
42 case NP_FILE_PRINT
: DIALOG_FilePrint(); break;
43 case NP_FILE_PAGESETUP
: DIALOG_FilePageSetup(); break;
44 case NP_FILE_PRINTSETUP
: DIALOG_FilePrinterSetup();break;
45 case NP_FILE_EXIT
: DIALOG_FileExit(); break;
47 case NP_EDIT_UNDO
: DIALOG_EditUndo(); break;
48 case NP_EDIT_CUT
: DIALOG_EditCut(); break;
49 case NP_EDIT_COPY
: DIALOG_EditCopy(); break;
50 case NP_EDIT_PASTE
: DIALOG_EditPaste(); break;
51 case NP_EDIT_DELETE
: DIALOG_EditDelete(); break;
52 case NP_EDIT_SELECTALL
: DIALOG_EditSelectAll(); break;
53 case NP_EDIT_TIMEDATE
: DIALOG_EditTimeDate();break;
54 case NP_EDIT_WRAP
: DIALOG_EditWrap(); break;
56 case NP_SEARCH_SEARCH
: DIALOG_Search(); break;
57 case NP_SEARCH_NEXT
: DIALOG_SearchNext(); break;
59 case NP_HELP_CONTENTS
: DIALOG_HelpContents(); break;
60 case NP_HELP_SEARCH
: DIALOG_HelpSearch(); break;
61 case NP_HELP_ON_HELP
: DIALOG_HelpHelp(); break;
62 case NP_HELP_LICENSE
: DIALOG_HelpLicense(); break;
63 case NP_HELP_NO_WARRANTY
: DIALOG_HelpNoWarranty(); break;
64 case NP_HELP_ABOUT_WINE
: DIALOG_HelpAboutWine(); break;
68 LANGUAGE_DefaultHandle(wParam
);
75 /***********************************************************************
80 LRESULT
NOTEPAD_WndProc (HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
83 CHAR szFileName
[MAX_STRING_LEN
];
85 lstrcpy(szFileName
, "");
93 BeginPaint(hWnd
, &ps
);
98 NOTEPAD_MenuCommand(wParam
);
106 DragQueryFile(wParam
, 0, szFileName
, sizeof(szFileName
));
107 printf("file %s to be opened by drag and drop !\n", szFileName
);
113 return DefWindowProc (hWnd
, msg
, wParam
, lParam
);
120 /***********************************************************************
125 int PASCAL
WinMain (HANDLE hInstance
, HANDLE prev
, LPSTR cmdline
, int show
)
129 char className
[] = "NPClass"; /* To make sure className >= 0x10000 */
130 char winName
[] = "Notepad";
132 #if defined(WINELIB) && !defined(HAVE_WINE_CONSTRUCTOR)
133 /* Register resources */
134 LIBWINE_Register_Da();
135 LIBWINE_Register_De();
136 LIBWINE_Register_En();
137 LIBWINE_Register_Sw();
140 /* Select Language */
146 Globals
.lpszIniFile
= "notepad.ini";
147 Globals
.lpszIcoFile
= "notepad.ico";
149 Globals
.hInstance
= hInstance
;
150 Globals
.hMainIcon
= ExtractIcon(Globals
.hInstance
,
151 Globals
.lpszIcoFile
, 0);
152 if (!Globals
.hMainIcon
) Globals
.hMainIcon
=
153 LoadIcon(0, MAKEINTRESOURCE(DEFAULTICON
));
155 lstrcpy(Globals
.szFindText
, "");
156 lstrcpy(Globals
.szFileName
, "");
157 lstrcpy(Globals
.szMarginTop
, "25 mm");
158 lstrcpy(Globals
.szMarginBottom
, "25 mm");
159 lstrcpy(Globals
.szMarginLeft
, "20 mm");
160 lstrcpy(Globals
.szMarginRight
, "20 mm");
161 lstrcpy(Globals
.szHeader
, "&n");
162 lstrcpy(Globals
.szFooter
, "Page &s");
165 class.style
= CS_HREDRAW
| CS_VREDRAW
;
166 class.lpfnWndProc
= NOTEPAD_WndProc
;
167 class.cbClsExtra
= 0;
168 class.cbWndExtra
= 0;
169 class.hInstance
= Globals
.hInstance
;
170 class.hIcon
= LoadIcon (0, IDI_APPLICATION
);
171 class.hCursor
= LoadCursor (0, IDC_ARROW
);
172 class.hbrBackground
= GetStockObject (WHITE_BRUSH
);
173 class.lpszMenuName
= 0;
174 class.lpszClassName
= className
;
177 if (!RegisterClass (&class))
180 Globals
.hMainWnd
= CreateWindow (className
, winName
, WS_OVERLAPPEDWINDOW
,
181 CW_USEDEFAULT
, 0, CW_USEDEFAULT
, 0, 0,
182 LoadMenu(Globals
.hInstance
, STRING_MENU_Xx
),
183 Globals
.hInstance
, 0);
185 LANGUAGE_SelectByName(Globals
.lpszLanguage
);
187 SetMenu(Globals
.hMainWnd
, Globals
.hMainMenu
);
189 ShowWindow (Globals
.hMainWnd
, show
);
190 UpdateWindow (Globals
.hMainWnd
);
192 // now handle command line
194 while (*cmdline
&& (*cmdline
== ' ' || *cmdline
== '-'))
200 if (*cmdline
++ == ' ') continue;
203 if (option
) cmdline
++;
204 while (*cmdline
&& *cmdline
== ' ') cmdline
++;
209 case 'P': printf("Print file: ");
210 // Not yet able to print a file
215 DragAcceptFiles(Globals
.hMainWnd
, TRUE
);
217 // now enter mesage loop
219 while (GetMessage (&msg
, 0, 0, 0)) {
220 TranslateMessage (&msg
);
221 DispatchMessage (&msg
);
226 /* Local Variables: */
227 /* c-file-style: "GNU" */