Release 981025.
[wine/gsoc-2012-control.git] / programs / notepad / main.c
blob735b4da7e3f9b606b72c38f8cb0003a2e546fd14
1 /*
2 * Notepad
4 * Copyright 1997,98 Marcel Baur <mbaur@g26.ethz.ch>
5 * To be distributed under the Wine License
6 */
8 #include <stdio.h>
9 #include "windows.h"
10 #include "shell.h"
11 #include "main.h"
12 #include "license.h"
13 #include "dialog.h"
14 #include "language.h"
16 #ifdef WINELIB
17 #include "options.h"
18 #include "resource.h"
19 #include "shell.h"
20 void LIBWINE_Register_Da();
21 void LIBWINE_Register_De();
22 void LIBWINE_Register_En();
23 void LIBWINE_Register_Sw();
24 #endif
26 NOTEPAD_GLOBALS Globals;
28 /***********************************************************************
30 * NOTEPAD_MenuCommand
32 * All handling of main menu events
35 int NOTEPAD_MenuCommand (WPARAM wParam)
37 switch (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;
66 // Handle languages
67 default:
68 LANGUAGE_DefaultHandle(wParam);
70 return 0;
75 /***********************************************************************
77 * NOTEPAD_WndProc
80 LRESULT NOTEPAD_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
82 PAINTSTRUCT ps;
83 CHAR szFileName[MAX_STRING_LEN];
85 lstrcpy(szFileName, "");
87 switch (msg) {
89 case WM_CREATE:
90 break;
92 case WM_PAINT:
93 BeginPaint(hWnd, &ps);
94 EndPaint(hWnd, &ps);
95 break;
97 case WM_COMMAND:
98 NOTEPAD_MenuCommand(wParam);
99 break;
101 case WM_DESTROY:
102 PostQuitMessage (0);
103 break;
105 case WM_DROPFILES:
106 DragQueryFile(wParam, 0, szFileName, sizeof(szFileName));
107 printf("file %s to be opened by drag and drop !\n", szFileName);
108 DragFinish(wParam);
109 break;
112 default:
113 return DefWindowProc (hWnd, msg, wParam, lParam);
115 return 0l;
120 /***********************************************************************
122 * WinMain
125 int PASCAL WinMain (HANDLE hInstance, HANDLE prev, LPSTR cmdline, int show)
127 MSG msg;
128 WNDCLASS class;
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();
138 #endif
140 /* Select Language */
141 LANGUAGE_Init();
144 /* Setup Globals */
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");
164 if (!prev){
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))
178 return FALSE;
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 == '-'))
197 CHAR option;
198 // LPCSTR topic_id;
200 if (*cmdline++ == ' ') continue;
202 option = *cmdline;
203 if (option) cmdline++;
204 while (*cmdline && *cmdline == ' ') cmdline++;
206 switch(option)
208 case 'p':
209 case 'P': printf("Print file: ");
210 // Not yet able to print a file
211 break;
215 DragAcceptFiles(Globals.hMainWnd, TRUE);
217 // now enter mesage loop
219 while (GetMessage (&msg, 0, 0, 0)) {
220 TranslateMessage (&msg);
221 DispatchMessage (&msg);
223 return 0;
226 /* Local Variables: */
227 /* c-file-style: "GNU" */
228 /* End: */