2
* Copyright (c) 2005 Massachusetts Institute of Technology
4
* Permission is hereby granted, free of charge, to any person
5
* obtaining a copy of this software and associated documentation
6
* files (the "Software"), to deal in the Software without
7
* restriction, including without limitation the rights to use, copy,
8
* modify, merge, publish, distribute, sublicense, and/or sell copies
9
* of the Software, and to permit persons to whom the Software is
10
* furnished to do so, subject to the following conditions:
12
* The above copyright notice and this permission notice shall be
13
* included in all copies or substantial portions of the Software.
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
CRITICAL_SECTION cs_props;
39
InitializeCriticalSection(&cs_props);
44
DeleteCriticalSection(&cs_props);
47
KHMEXP khm_int32 KHMAPI
48
khui_ps_create_sheet(khui_property_sheet ** sheet)
50
khui_property_sheet * ps;
52
ps = PMALLOC(sizeof(*ps));
53
ZeroMemory(ps, sizeof(*ps));
55
ps->header.dwSize = sizeof(ps->header);
56
ps->header.dwFlags = PSH_MODELESS | PSH_PROPTITLE;
57
ps->status = KHUI_PS_STATUS_NONE;
61
return KHM_ERROR_SUCCESS;
64
KHMEXP khm_int32 KHMAPI
65
khui_ps_add_page(khui_property_sheet * sheet,
68
LPPROPSHEETPAGE ppage,
69
khui_property_page ** page)
71
khui_property_page * p;
73
p = PMALLOC(sizeof(*p));
74
ZeroMemory(p, sizeof(*p));
76
p->credtype = credtype;
80
EnterCriticalSection(&cs_props);
83
LeaveCriticalSection(&cs_props);
88
return KHM_ERROR_SUCCESS;
91
KHMEXP khm_int32 KHMAPI
92
khui_ps_find_page(khui_property_sheet * sheet,
94
khui_property_page ** page)
96
khui_property_page * p;
98
EnterCriticalSection(&cs_props);
102
if(p->credtype == credtype)
106
LeaveCriticalSection(&cs_props);
110
return KHM_ERROR_SUCCESS;
113
return KHM_ERROR_NOT_FOUND;
118
ps_order_func(const void *l, const void * r) {
119
khui_property_page * lp;
120
khui_property_page * rp;
122
lp = *(khui_property_page **)l;
123
rp = *(khui_property_page **)r;
125
if (lp->ordinal == rp->ordinal)
126
return lp->credtype - rp->credtype;
128
return lp->ordinal - rp->ordinal;
132
khui_ps_show_sheet(HWND parent, khui_property_sheet * s)
134
khui_property_page * p;
135
HPROPSHEETPAGE phpsp[KHUI_PS_MAX_PSP];
136
khui_property_page * ppgs[KHUI_PS_MAX_PSP];
141
EnterCriticalSection(&cs_props);
143
s->header.hwndParent = parent;
144
s->header.nPages = s->n_pages;
149
p->h_page = CreatePropertySheetPage(p->p_page);
158
assert(i == s->n_pages);
161
qsort(ppgs, s->n_pages, sizeof(ppgs[0]), ps_order_func);
163
for (i=0; i < s->n_pages; i++) {
164
phpsp[i] = ppgs[i]->h_page;
167
s->header.phpage = phpsp;
169
prv = PropertySheet(&s->header);
171
s->header.phpage = NULL;
177
/*TODO: better handling for this */
180
s->status = KHUI_PS_STATUS_RUNNING;
184
s->hwnd_page = PropSheet_GetCurrentPageHwnd(hw);
186
LeaveCriticalSection(&cs_props);
191
KHMEXP LRESULT KHMAPI
192
khui_ps_check_message(khui_property_sheet * sheet,
197
if(sheet->hwnd == NULL)
200
lr = PropSheet_IsDialogMessage(sheet->hwnd, pmsg);
202
sheet->hwnd_page = PropSheet_GetCurrentPageHwnd(sheet->hwnd);
203
if(sheet->hwnd_page == NULL &&
204
sheet->status == KHUI_PS_STATUS_RUNNING)
206
sheet->status = KHUI_PS_STATUS_DONE;
212
KHMEXP khm_int32 KHMAPI
213
khui_ps_destroy_sheet(khui_property_sheet * sheet)
215
khui_property_page * p;
217
EnterCriticalSection(&cs_props);
219
DestroyWindow(sheet->hwnd);
229
LeaveCriticalSection(&cs_props);
231
return KHM_ERROR_SUCCESS;