DOSFS_ToDosFCBFormat: fail if extension longer than 3 characters.
[wine/gsoc-2012-control.git] / programs / progman / group.c
blob7b3dc0e46de9eb2b143742a0a302c05cac6b2d78
1 /*
2 * Program Manager
4 * Copyright 1996 Ulrich Schmid
5 */
7 #include <stdio.h>
8 #include <string.h>
9 #include "windows.h"
10 #include "windowsx.h"
11 #include "progman.h"
13 /***********************************************************************
15 * GROUP_GroupWndProc
18 static LRESULT GROUP_GroupWndProc (HWND hWnd, UINT msg,
19 WPARAM wParam, LPARAM lParam)
21 #if 0
22 printf("G %4.4x %4.4x\n", msg, wParam);
23 #endif
24 switch (msg)
26 case WM_SYSCOMMAND:
27 if (wParam == SC_CLOSE) wParam = SC_MINIMIZE;
28 break;
30 case WM_CHILDACTIVATE:
31 case WM_NCLBUTTONDOWN:
32 Globals.hActiveGroup = (HLOCAL) GetWindowLong(hWnd, 0);
33 EnableMenuItem(Globals.hFileMenu, PM_MOVE , MF_GRAYED);
34 EnableMenuItem(Globals.hFileMenu, PM_COPY , MF_GRAYED);
35 break;
37 return(DefMDIChildProc(hWnd, msg, wParam, lParam));
40 /***********************************************************************
42 * GROUP_RegisterGroupWinClass
45 ATOM GROUP_RegisterGroupWinClass()
47 WNDCLASS class;
49 class.style = CS_HREDRAW | CS_VREDRAW;
50 class.lpfnWndProc = GROUP_GroupWndProc;
51 class.cbClsExtra = 0;
52 class.cbWndExtra = sizeof(LONG);
53 class.hInstance = Globals.hInstance;
54 class.hIcon = LoadIcon (0, MAKEINTRESOURCE(OIC_WINEICON));
55 class.hCursor = LoadCursor (0, IDC_ARROW);
56 class.hbrBackground = GetStockObject (WHITE_BRUSH);
57 class.lpszMenuName = 0;
58 class.lpszClassName = STRING_GROUP_WIN_CLASS_NAME;
60 return RegisterClass(&class);
63 /***********************************************************************
65 * GROUP_NewGroup
68 VOID GROUP_NewGroup()
70 CHAR szName[MAX_PATHNAME_LEN] = "";
71 CHAR szFile[MAX_PATHNAME_LEN] = "";
72 OFSTRUCT dummy;
74 if (!DIALOG_GroupAttributes(szName, szFile, MAX_PATHNAME_LEN)) return;
76 if (OpenFile(szFile, &dummy, OF_EXIST) == HFILE_ERROR)
78 /* File doesn't exist */
79 HLOCAL hGroup =
80 GROUP_AddGroup(szName, szFile, SW_SHOWNORMAL,
81 DEF_GROUP_WIN_XPOS, DEF_GROUP_WIN_YPOS,
82 DEF_GROUP_WIN_WIDTH, DEF_GROUP_WIN_HEIGHT, 0, 0,
83 FALSE, FALSE, FALSE);
84 if (!hGroup) return;
85 GRPFILE_WriteGroupFile(hGroup);
87 else /* File exist */
88 GRPFILE_ReadGroupFile(szFile);
90 /* FIXME Update progman.ini */
93 /***********************************************************************
95 * GROUP_AddGroup
98 HLOCAL GROUP_AddGroup(LPCSTR lpszName, LPCSTR lpszGrpFile, INT nCmdShow,
99 INT x, INT y, INT width, INT height,
100 INT iconx, INT icony,
101 BOOL bFileNameModified, BOOL bOverwriteFileOk,
102 /* FIXME shouldn't be necessary */
103 BOOL bSuppressShowWindow)
105 GROUP *group, *prior;
106 MDICREATESTRUCT cs;
107 INT seqnum;
108 HLOCAL hPrior, *p;
109 HLOCAL hGroup = LocalAlloc(LMEM_FIXED, sizeof(GROUP));
110 HLOCAL hName = LocalAlloc(LMEM_FIXED, 1 + lstrlen(lpszName));
111 HLOCAL hGrpFile = LocalAlloc(LMEM_FIXED, 1 + lstrlen(lpszGrpFile));
112 if (!hGroup || !hName || !hGrpFile)
114 MAIN_MessageBoxIDS(IDS_OUT_OF_MEMORY, IDS_ERROR, MB_OK);
115 if (hGroup) LocalFree(hGroup);
116 if (hName) LocalFree(hName);
117 if (hGrpFile) LocalFree(hGrpFile);
118 return(0);
120 hmemcpy16(LocalLock(hName), lpszName, 1 + lstrlen(lpszName));
121 hmemcpy16(LocalLock(hGrpFile), lpszGrpFile, 1 + lstrlen(lpszGrpFile));
123 Globals.hActiveGroup = hGroup;
125 seqnum = 1;
126 hPrior = 0;
127 p = &Globals.hGroups;
128 while (*p)
130 hPrior = *p;
131 prior = LocalLock(hPrior);
132 p = &prior->hNext;
133 if (prior->seqnum >= seqnum)
134 seqnum = prior->seqnum + 1;
136 *p = hGroup;
138 group = LocalLock(hGroup);
139 group->hPrior = hPrior;
140 group->hNext = 0;
141 group->hName = hName;
142 group->hGrpFile = hGrpFile;
143 group->bFileNameModified = bFileNameModified;
144 group->bOverwriteFileOk = bOverwriteFileOk;
145 group->seqnum = seqnum;
146 group->nCmdShow = nCmdShow;
147 group->x = x;
148 group->y = y;
149 group->width = width;
150 group->height = height;
151 group->iconx = iconx;
152 group->icony = icony;
153 group->hPrograms = 0;
154 group->hActiveProgram = 0;
156 cs.szClass = STRING_GROUP_WIN_CLASS_NAME;
157 cs.szTitle = (LPSTR)lpszName;
158 cs.hOwner = 0;
159 cs.x = x;
160 cs.y = y;
161 cs.cx = width;
162 cs.cy = height;
163 cs.style = 0;
164 cs.lParam = 0;
166 group->hWnd = (HWND)SendMessage(Globals.hMDIWnd, WM_MDICREATE, 0, (LPARAM)&cs);
168 SetWindowLong(group->hWnd, 0, (LONG) hGroup);
170 #if 1
171 if (!bSuppressShowWindow) /* FIXME shouldn't be necessary */
172 #endif
174 ShowWindow (group->hWnd, nCmdShow);
175 UpdateWindow (group->hWnd);
178 return(hGroup);
181 /***********************************************************************
183 * GROUP_ModifyGroup
186 VOID GROUP_ModifyGroup(HLOCAL hGroup)
188 GROUP *group = LocalLock(hGroup);
189 CHAR szName[MAX_PATHNAME_LEN];
190 CHAR szFile[MAX_PATHNAME_LEN];
191 lstrcpyn(szName, LocalLock(group->hName), MAX_PATHNAME_LEN);
192 lstrcpyn(szFile, LocalLock(group->hGrpFile), MAX_PATHNAME_LEN);
194 if (!DIALOG_GroupAttributes(szName, szFile, MAX_PATHNAME_LEN)) return;
196 if (strcmp(szFile, LocalLock(group->hGrpFile)))
197 group->bOverwriteFileOk = FALSE;
199 MAIN_ReplaceString(&group->hName, szName);
200 MAIN_ReplaceString(&group->hGrpFile, szFile);
202 GRPFILE_WriteGroupFile(hGroup);
204 /* FIXME Delete old GrpFile if GrpFile changed */
206 /* FIXME Update progman.ini */
208 SetWindowText(group->hWnd, szName);
211 /***********************************************************************
213 * GROUP_ShowGroupWindow
216 /* FIXME shouldn't be necessary */
217 VOID GROUP_ShowGroupWindow(HLOCAL hGroup)
219 GROUP *group = LocalLock(hGroup);
220 ShowWindow (group->hWnd, group->nCmdShow);
221 UpdateWindow (group->hWnd);
224 /***********************************************************************
226 * GROUP_DeleteGroup
229 VOID GROUP_DeleteGroup(HLOCAL hGroup)
231 GROUP *group = LocalLock(hGroup);
233 Globals.hActiveGroup = 0;
235 if (group->hPrior)
236 ((GROUP*)LocalLock(group->hPrior))->hNext = group->hNext;
237 else Globals.hGroups = group->hNext;
239 if (group->hNext)
240 ((GROUP*)LocalLock(group->hNext))->hPrior = group->hPrior;
242 while (group->hPrograms)
243 PROGRAM_DeleteProgram(group->hPrograms, FALSE);
245 /* FIXME Update progman.ini */
247 SendMessage(Globals.hMDIWnd, WM_MDIDESTROY, (WPARAM)group->hWnd, 0);
249 LocalFree(group->hName);
250 LocalFree(group->hGrpFile);
251 LocalFree(hGroup);
254 /***********************************************************************
256 * GROUP_FirstGroup
259 HLOCAL GROUP_FirstGroup()
261 return(Globals.hGroups);
264 /***********************************************************************
266 * GROUP_NextGroup
269 HLOCAL GROUP_NextGroup(HLOCAL hGroup)
271 GROUP *group;
272 if (!hGroup) return(0);
273 group = LocalLock(hGroup);
274 return(group->hNext);
277 /***********************************************************************
279 * GROUP_ActiveGroup
282 HLOCAL GROUP_ActiveGroup()
284 return(Globals.hActiveGroup);
287 /***********************************************************************
289 * GROUP_GroupWnd
292 HWND GROUP_GroupWnd(HLOCAL hGroup)
294 GROUP *group;
295 if (!hGroup) return(0);
296 group = LocalLock(hGroup);
297 return(group->hWnd);
300 /***********************************************************************
302 * GROUP_GroupName
305 LPCSTR GROUP_GroupName(HLOCAL hGroup)
307 GROUP *group;
308 if (!hGroup) return(0);
309 group = LocalLock(hGroup);
310 return(LocalLock(group->hName));
313 /* Local Variables: */
314 /* c-file-style: "GNU" */
315 /* End: */