4 * Copyright 1996 Ulrich Schmid
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 /***********************************************************************
32 static LRESULT CALLBACK
GROUP_GroupWndProc(HWND hWnd
, UINT msg
,
33 WPARAM wParam
, LPARAM lParam
)
36 printf("G %4.4x %4.4x\n", msg
, wParam
);
41 if (wParam
== SC_CLOSE
) wParam
= SC_MINIMIZE
;
44 case WM_CHILDACTIVATE
:
45 case WM_NCLBUTTONDOWN
:
46 Globals
.hActiveGroup
= (HLOCAL
) GetWindowLong(hWnd
, 0);
47 EnableMenuItem(Globals
.hFileMenu
, PM_MOVE
, MF_GRAYED
);
48 EnableMenuItem(Globals
.hFileMenu
, PM_COPY
, MF_GRAYED
);
51 return(DefMDIChildProc(hWnd
, msg
, wParam
, lParam
));
54 /***********************************************************************
56 * GROUP_RegisterGroupWinClass
59 ATOM
GROUP_RegisterGroupWinClass()
63 class.style
= CS_HREDRAW
| CS_VREDRAW
;
64 class.lpfnWndProc
= GROUP_GroupWndProc
;
66 class.cbWndExtra
= sizeof(LONG
);
67 class.hInstance
= Globals
.hInstance
;
68 class.hIcon
= LoadIcon (0, IDI_WINLOGO
);
69 class.hCursor
= LoadCursor (0, IDC_ARROW
);
70 class.hbrBackground
= GetStockObject (WHITE_BRUSH
);
71 class.lpszMenuName
= 0;
72 class.lpszClassName
= STRING_GROUP_WIN_CLASS_NAME
;
74 return RegisterClass(&class);
77 /***********************************************************************
84 CHAR szName
[MAX_PATHNAME_LEN
] = "";
85 CHAR szFile
[MAX_PATHNAME_LEN
] = "";
88 if (!DIALOG_GroupAttributes(szName
, szFile
, MAX_PATHNAME_LEN
)) return;
90 if (OpenFile(szFile
, &dummy
, OF_EXIST
) == HFILE_ERROR
)
92 /* File doesn't exist */
94 GROUP_AddGroup(szName
, szFile
, SW_SHOWNORMAL
,
95 DEF_GROUP_WIN_XPOS
, DEF_GROUP_WIN_YPOS
,
96 DEF_GROUP_WIN_WIDTH
, DEF_GROUP_WIN_HEIGHT
, 0, 0,
99 GRPFILE_WriteGroupFile(hGroup
);
101 else /* File exist */
102 GRPFILE_ReadGroupFile(szFile
);
104 /* FIXME Update progman.ini */
107 /***********************************************************************
112 HLOCAL
GROUP_AddGroup(LPCSTR lpszName
, LPCSTR lpszGrpFile
, INT nCmdShow
,
113 INT x
, INT y
, INT width
, INT height
,
114 INT iconx
, INT icony
,
115 BOOL bFileNameModified
, BOOL bOverwriteFileOk
,
116 /* FIXME shouldn't be necessary */
117 BOOL bSuppressShowWindow
)
119 PROGGROUP
*group
, *prior
;
123 HLOCAL hGroup
= LocalAlloc(LMEM_FIXED
, sizeof(PROGGROUP
));
124 HLOCAL hName
= LocalAlloc(LMEM_FIXED
, 1 + lstrlen(lpszName
));
125 HLOCAL hGrpFile
= LocalAlloc(LMEM_FIXED
, 1 + lstrlen(lpszGrpFile
));
126 if (!hGroup
|| !hName
|| !hGrpFile
)
128 MAIN_MessageBoxIDS(IDS_OUT_OF_MEMORY
, IDS_ERROR
, MB_OK
);
129 if (hGroup
) LocalFree(hGroup
);
130 if (hName
) LocalFree(hName
);
131 if (hGrpFile
) LocalFree(hGrpFile
);
134 memcpy(LocalLock(hName
), lpszName
, 1 + lstrlen(lpszName
));
135 memcpy(LocalLock(hGrpFile
), lpszGrpFile
, 1 + lstrlen(lpszGrpFile
));
137 Globals
.hActiveGroup
= hGroup
;
141 p
= &Globals
.hGroups
;
145 prior
= LocalLock(hPrior
);
147 if (prior
->seqnum
>= seqnum
)
148 seqnum
= prior
->seqnum
+ 1;
152 group
= LocalLock(hGroup
);
153 group
->hPrior
= hPrior
;
155 group
->hName
= hName
;
156 group
->hGrpFile
= hGrpFile
;
157 group
->bFileNameModified
= bFileNameModified
;
158 group
->bOverwriteFileOk
= bOverwriteFileOk
;
159 group
->seqnum
= seqnum
;
160 group
->nCmdShow
= nCmdShow
;
163 group
->width
= width
;
164 group
->height
= height
;
165 group
->iconx
= iconx
;
166 group
->icony
= icony
;
167 group
->hPrograms
= 0;
168 group
->hActiveProgram
= 0;
170 cs
.szClass
= STRING_GROUP_WIN_CLASS_NAME
;
171 cs
.szTitle
= (LPSTR
)lpszName
;
180 group
->hWnd
= (HWND
)SendMessage(Globals
.hMDIWnd
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
182 SetWindowLong(group
->hWnd
, 0, (LONG
) hGroup
);
185 if (!bSuppressShowWindow
) /* FIXME shouldn't be necessary */
188 ShowWindow (group
->hWnd
, nCmdShow
);
189 UpdateWindow (group
->hWnd
);
195 /***********************************************************************
200 VOID
GROUP_ModifyGroup(HLOCAL hGroup
)
202 PROGGROUP
*group
= LocalLock(hGroup
);
203 CHAR szName
[MAX_PATHNAME_LEN
];
204 CHAR szFile
[MAX_PATHNAME_LEN
];
205 lstrcpyn(szName
, LocalLock(group
->hName
), MAX_PATHNAME_LEN
);
206 lstrcpyn(szFile
, LocalLock(group
->hGrpFile
), MAX_PATHNAME_LEN
);
208 if (!DIALOG_GroupAttributes(szName
, szFile
, MAX_PATHNAME_LEN
)) return;
210 if (strcmp(szFile
, LocalLock(group
->hGrpFile
)))
211 group
->bOverwriteFileOk
= FALSE
;
213 MAIN_ReplaceString(&group
->hName
, szName
);
214 MAIN_ReplaceString(&group
->hGrpFile
, szFile
);
216 GRPFILE_WriteGroupFile(hGroup
);
218 /* FIXME Delete old GrpFile if GrpFile changed */
220 /* FIXME Update progman.ini */
222 SetWindowText(group
->hWnd
, szName
);
225 /***********************************************************************
227 * GROUP_ShowGroupWindow
230 /* FIXME shouldn't be necessary */
231 VOID
GROUP_ShowGroupWindow(HLOCAL hGroup
)
233 PROGGROUP
*group
= LocalLock(hGroup
);
234 ShowWindow (group
->hWnd
, group
->nCmdShow
);
235 UpdateWindow (group
->hWnd
);
238 /***********************************************************************
243 VOID
GROUP_DeleteGroup(HLOCAL hGroup
)
245 PROGGROUP
*group
= LocalLock(hGroup
);
247 Globals
.hActiveGroup
= 0;
250 ((PROGGROUP
*)LocalLock(group
->hPrior
))->hNext
= group
->hNext
;
251 else Globals
.hGroups
= group
->hNext
;
254 ((PROGGROUP
*)LocalLock(group
->hNext
))->hPrior
= group
->hPrior
;
256 while (group
->hPrograms
)
257 PROGRAM_DeleteProgram(group
->hPrograms
, FALSE
);
259 /* FIXME Update progman.ini */
261 SendMessage(Globals
.hMDIWnd
, WM_MDIDESTROY
, (WPARAM
)group
->hWnd
, 0);
263 LocalFree(group
->hName
);
264 LocalFree(group
->hGrpFile
);
268 /***********************************************************************
273 HLOCAL
GROUP_FirstGroup()
275 return(Globals
.hGroups
);
278 /***********************************************************************
283 HLOCAL
GROUP_NextGroup(HLOCAL hGroup
)
286 if (!hGroup
) return(0);
287 group
= LocalLock(hGroup
);
288 return(group
->hNext
);
291 /***********************************************************************
296 HLOCAL
GROUP_ActiveGroup()
298 return(Globals
.hActiveGroup
);
301 /***********************************************************************
306 HWND
GROUP_GroupWnd(HLOCAL hGroup
)
309 if (!hGroup
) return(0);
310 group
= LocalLock(hGroup
);
314 /***********************************************************************
319 LPCSTR
GROUP_GroupName(HLOCAL hGroup
)
322 if (!hGroup
) return(0);
323 group
= LocalLock(hGroup
);
324 return(LocalLock(group
->hName
));
327 /* Local Variables: */
328 /* c-file-style: "GNU" */