Sync to Wine-20050725:
Vitaliy Margolen <wine-patch(a)kievinfo.com>
- Send CDDS_ITEMPOSTERASE | CDDS_PREPAINT notify.
Felix Nawothnig <felix.nawothnig(a)t-online.de>
- Move DPA and DSA functions out of comctl32undoc.c as they are
documented by now.
- Fix some DPA functions so they pass the new tests.
- Don't invalidate the whole propsheet when the page is switched.
Dimi Paun <dimi(a)lattica.com>
- Silence uninitialized warnings.
Robert Shearman <rob(a)codeweavers.com>
- Call SetBkMode with the correct value from the NMTBCUSTOMDRAW
structure.
- Don't fill the NMTBCUSTOMDRAW structure in again for
CDDS_POSTPAINT.
- Remove redundant bBtnTransprnt value.
- Height is now calculated based on the number of rows, not on the
bounding rect.
- Only call CalcToolbar in AutoSize if it has TBSTYLE_WRAPABLE or
TBSTYLE_EX_UNDOC1 set.
- Remove a bad test in SetButtonWidth that fixes a regression from the
above change in IE.
- Remove unnecessary nHeight data.
- Remove duplicated code in Size by calling AutoSize.
- Remove unnecessary bAutoSize value because SetWindowPos doesn't
generate WM_SIZE when there is nothing to do on both Windows and
Wine.
- TBSTATE_INDETERMINATE only takes effect if the button is enabled,
otherwise it should just appear like any other disabled button.
- Native autosizes on inserting/adding buttons, so we should too.
- The IsValidImageList test is not needed because if it isn't a valid
image list we will have set the bitmap width and height to 1 and it
does the wrong thing when no buttons are present.
- The calculated button height should include the text height when no
buttons are present.
- Handle CopyImage and other functions failing by not adding the icon
and notifying the caller.
Thomas Weidenmueller <wine-patches(a)reactsoft.com>
- Support PSH_WIZARDHASFINISH in wizards.
- Correct tab order of the wizard buttons.
- Support PSM_IDTOINDEX.
Aric Stewart <aric(a)codeweavers.com>
- When adding an image copy the full previous buffer.
- Implement replacing an icon with one from a resource.
Kevin Koltzau <kevin(a)plop.org>
- Forward some header notifications to parent of listview.
Frank Richter <frank.richter(a)gmail.com>
- Enabled "tab" dialog texture for property sheet pages.
- Add theming support for header controls.
- Use theming for the ListView non-client area.
- Let property sheets update the cached system colors upon receiving
WM_SYSCOLORCHANGE.
- Add theming for the up/down control.
Modified: trunk/reactos/lib/comctl32/comctl32.xml
Modified: trunk/reactos/lib/comctl32/comctl32undoc.c
Modified: trunk/reactos/lib/comctl32/comctl_Cn.rc
Modified: trunk/reactos/lib/comctl32/comctl_Cs.rc
Modified: trunk/reactos/lib/comctl32/comctl_De.rc
Modified: trunk/reactos/lib/comctl32/comctl_En.rc
Modified: trunk/reactos/lib/comctl32/comctl_Es.rc
Modified: trunk/reactos/lib/comctl32/comctl_Fr.rc
Modified: trunk/reactos/lib/comctl32/comctl_It.rc
Modified: trunk/reactos/lib/comctl32/comctl_Ja.rc
Modified: trunk/reactos/lib/comctl32/comctl_Ko.rc
Modified: trunk/reactos/lib/comctl32/comctl_Nl.rc
Modified: trunk/reactos/lib/comctl32/comctl_Pl.rc
Modified: trunk/reactos/lib/comctl32/comctl_Pt.rc
Modified: trunk/reactos/lib/comctl32/comctl_Ru.rc
Modified: trunk/reactos/lib/comctl32/comctl_Si.rc
Modified: trunk/reactos/lib/comctl32/comctl_Sv.rc
Modified: trunk/reactos/lib/comctl32/comctl_Th.rc
Modified: trunk/reactos/lib/comctl32/comctl_Uk.rc
Added: trunk/reactos/lib/comctl32/dpa.c
Added: trunk/reactos/lib/comctl32/dsa.c
Modified: trunk/reactos/lib/comctl32/header.c
Modified: trunk/reactos/lib/comctl32/imagelist.c
Modified: trunk/reactos/lib/comctl32/listview.c
Modified: trunk/reactos/lib/comctl32/propsheet.c
Modified: trunk/reactos/lib/comctl32/toolbar.c
Modified: trunk/reactos/lib/comctl32/updown.c
_____
Modified: trunk/reactos/lib/comctl32/comctl32.xml
--- trunk/reactos/lib/comctl32/comctl32.xml 2005-08-12 13:46:36 UTC
(rev 17325)
+++ trunk/reactos/lib/comctl32/comctl32.xml 2005-08-12 16:31:56 UTC
(rev 17326)
@@ -13,13 +13,16 @@
<library>advapi32</library>
<library>gdi32</library>
<library>user32</library>
+ <library>uxtheme</library>
<library>winmm</library>
<file>animate.c</file>
<file>comboex.c</file>
<file>comctl32undoc.c</file>
<file>commctrl.c</file>
<file>datetime.c</file>
+ <file>dpa.c</file>
<file>draglist.c</file>
+ <file>dsa.c</file>
<file>flatsb.c</file>
<file>header.c</file>
<file>hotkey.c</file>
_____
Modified: trunk/reactos/lib/comctl32/comctl32undoc.c
--- trunk/reactos/lib/comctl32/comctl32undoc.c 2005-08-12 13:46:36 UTC
(rev 17325)
+++ trunk/reactos/lib/comctl32/comctl32undoc.c 2005-08-12 16:31:56 UTC
(rev 17326)
@@ -55,314 +55,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(commctrl);
-struct _DSA
-{
- INT nItemCount;
- LPVOID pData;
- INT nMaxCount;
- INT nItemSize;
- INT nGrow;
-};
-
-struct _DPA
-{
- INT nItemCount;
- LPVOID *ptrs;
- HANDLE hHeap;
- INT nGrow;
- INT nMaxCount;
-};
-
-typedef struct _STREAMDATA
-{
- DWORD dwSize;
- DWORD dwData2;
- DWORD dwItems;
-} STREAMDATA, *PSTREAMDATA;
-
-typedef struct _LOADDATA
-{
- INT nCount;
- PVOID ptr;
-} LOADDATA, *LPLOADDATA;
-
-typedef HRESULT (CALLBACK *DPALOADPROC)(LPLOADDATA,IStream*,LPARAM);
-
static const WCHAR strMRUList[] = {
'M','R','U','L','i','s','t',0 };
/***********************************************************************
***
- * DPA_LoadStream [COMCTL32.9]
- *
- * Loads a dynamic pointer array from a stream
- *
- * PARAMS
- * phDpa [O] pointer to a handle to a dynamic pointer array
- * loadProc [I] pointer to a callback function
- * pStream [I] pointer to a stream
- * lParam [I] application specific value
- *
- * RETURNS
- * Success: TRUE
- * Failure: FALSE
- *
- * NOTES
- * No more information available yet!
- */
-HRESULT WINAPI DPA_LoadStream (HDPA *phDpa, DPALOADPROC loadProc,
- IStream *pStream, LPARAM lParam)
-{
- HRESULT errCode;
- LARGE_INTEGER position;
- ULARGE_INTEGER newPosition;
- STREAMDATA streamData;
- LOADDATA loadData;
- ULONG ulRead;
- HDPA hDpa;
- PVOID *ptr;
-
- FIXME ("phDpa=%p loadProc=%p pStream=%p lParam=%lx\n",
- phDpa, loadProc, pStream, lParam);
-
- if (!phDpa || !loadProc || !pStream)
- return E_INVALIDARG;
-
- *phDpa = (HDPA)NULL;
-
- position.QuadPart = 0;
-
- /*
- * Zero out our streamData
- */
- memset(&streamData,0,sizeof(STREAMDATA));
-
- errCode = IStream_Seek (pStream, position, STREAM_SEEK_CUR,
&newPosition);
- if (errCode != S_OK)
- return errCode;
-
- errCode = IStream_Read (pStream, &streamData, sizeof(STREAMDATA),
&ulRead);
- if (errCode != S_OK)
- return errCode;
-
- FIXME ("dwSize=%lu dwData2=%lu dwItems=%lu\n",
- streamData.dwSize, streamData.dwData2, streamData.dwItems);
-
- if ( ulRead < sizeof(STREAMDATA) ||
- lParam < sizeof(STREAMDATA) ||
- streamData.dwSize < sizeof(STREAMDATA) ||
- streamData.dwData2 < 1) {
- errCode = E_FAIL;
- }
-
- if (streamData.dwItems > (UINT_MAX / 2 / sizeof(VOID*))) /*
536870911 */
- return E_OUTOFMEMORY;
-
- /* create the dpa */
- hDpa = DPA_Create (streamData.dwItems);
- if (!hDpa)
- return E_OUTOFMEMORY;
-
- if (!DPA_Grow (hDpa, streamData.dwItems))
- return E_OUTOFMEMORY;
-
- /* load data from the stream into the dpa */
- ptr = hDpa->ptrs;
- for (loadData.nCount = 0; loadData.nCount < streamData.dwItems;
loadData.nCount++) {
- errCode = (loadProc)(&loadData, pStream, lParam);
- if (errCode != S_OK) {
- errCode = S_FALSE;
- break;
- }
-
- *ptr = loadData.ptr;
- ptr++;
- }
-
- /* set the number of items */
- hDpa->nItemCount = loadData.nCount;
-
- /* store the handle to the dpa */
- *phDpa = hDpa;
- FIXME ("new hDpa=%p, errorcode=%lx\n", hDpa, errCode);
-
- return errCode;
-}
-
-
-/**********************************************************************
****
- * DPA_SaveStream [COMCTL32.10]
- *
- * Saves a dynamic pointer array to a stream
- *
- * PARAMS
- * hDpa [I] handle to a dynamic pointer array
- * loadProc [I] pointer to a callback function
- * pStream [I] pointer to a stream
- * lParam [I] application specific value
- *
- * RETURNS
- * Success: TRUE
- * Failure: FALSE
- *
- * NOTES
- * No more information available yet!
- */
-HRESULT WINAPI DPA_SaveStream (const HDPA hDpa, DPALOADPROC loadProc,
- IStream *pStream, LPARAM lParam)
-{
-
- FIXME ("hDpa=%p loadProc=%p pStream=%p lParam=%lx\n",
- hDpa, loadProc, pStream, lParam);
-
- return E_FAIL;
-}
-
-
-/**********************************************************************
****
- * DPA_Merge [COMCTL32.11]
- *
- * Merge two dynamic pointers arrays.
- *
- * PARAMS
- * hdpa1 [I] handle to a dynamic pointer array
- * hdpa2 [I] handle to a dynamic pointer array
- * dwFlags [I] flags
- * pfnCompare [I] pointer to sort function
- * pfnMerge [I] pointer to merge function
- * lParam [I] application specific value
- *
- * RETURNS
- * Success: TRUE
- * Failure: FALSE
- *
- * NOTES
- * No more information available yet!
- */
-BOOL WINAPI DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD
dwFlags,
- PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge,
- LPARAM lParam)
-{
- INT nCount;
- LPVOID *pWork1, *pWork2;
- INT nResult, i;
- INT nIndex;
-
- TRACE("%p %p %08lx %p %p %08lx)\n",
- hdpa1, hdpa2, dwFlags, pfnCompare, pfnMerge, lParam);
-
- if (IsBadWritePtr (hdpa1, sizeof(*hdpa1)))
- return FALSE;
-
- if (IsBadWritePtr (hdpa2, sizeof(*hdpa2)))
- return FALSE;
-
- if (IsBadCodePtr ((FARPROC)pfnCompare))
- return FALSE;
-
- if (IsBadCodePtr ((FARPROC)pfnMerge))
- return FALSE;
-
- if (!(dwFlags & DPAM_NOSORT)) {
- TRACE("sorting dpa's!\n");
- if (hdpa1->nItemCount > 0)
- DPA_Sort (hdpa1, pfnCompare, lParam);
- TRACE ("dpa 1 sorted!\n");
- if (hdpa2->nItemCount > 0)
- DPA_Sort (hdpa2, pfnCompare, lParam);
- TRACE ("dpa 2 sorted!\n");
- }
-
- if (hdpa2->nItemCount < 1)
- return TRUE;
-
- TRACE("hdpa1->nItemCount=%d hdpa2->nItemCount=%d\n",
- hdpa1->nItemCount, hdpa2->nItemCount);
-
-
- /* working but untrusted implementation */
-
- pWork1 = &(hdpa1->ptrs[hdpa1->nItemCount - 1]);
- pWork2 = &(hdpa2->ptrs[hdpa2->nItemCount - 1]);
-
- nIndex = hdpa1->nItemCount - 1;
- nCount = hdpa2->nItemCount - 1;
-
- do
- {
- if (nIndex < 0) {
- if ((nCount >= 0) && (dwFlags & DPAM_INSERT)) {
- /* Now insert the remaining new items into DPA 1 */
- TRACE("%d items to be inserted at start of DPA 1\n",
- nCount+1);
- for (i=nCount; i>=0; i--) {
- PVOID ptr;
-
- ptr = (pfnMerge)(3, *pWork2, NULL, lParam);
- if (!ptr)
- return FALSE;
- DPA_InsertPtr (hdpa1, 0, ptr);
- pWork2--;
- }
- }
- break;
- }
- nResult = (pfnCompare)(*pWork1, *pWork2, lParam);
- TRACE("compare result=%d, dpa1.cnt=%d, dpa2.cnt=%d\n",
- nResult, nIndex, nCount);
-
- if (nResult == 0)
- {
- PVOID ptr;
-
- ptr = (pfnMerge)(1, *pWork1, *pWork2, lParam);
- if (!ptr)
- return FALSE;
-
- nCount--;
- pWork2--;
- *pWork1 = ptr;
- nIndex--;
- pWork1--;
- }
- else if (nResult > 0)
- {
- /* item in DPA 1 missing from DPA 2 */
- if (dwFlags & DPAM_DELETE)
- {
- /* Now delete the extra item in DPA1 */
- PVOID ptr;
-
- ptr = DPA_DeletePtr (hdpa1, hdpa1->nItemCount - 1);
-
- (pfnMerge)(2, ptr, NULL, lParam);
- }
- nIndex--;
- pWork1--;
- }
- else
- {
- /* new item in DPA 2 */
- if (dwFlags & DPAM_INSERT)
- {
- /* Now insert the new item in DPA 1 */
- PVOID ptr;
-
- ptr = (pfnMerge)(3, *pWork2, NULL, lParam);
- if (!ptr)
- return FALSE;
- DPA_InsertPtr (hdpa1, nIndex+1, ptr);
- }
- nCount--;
- pWork2--;
- }
-
- }
- while (nCount >= 0);
-
- return TRUE;
-}
-
-
-/**********************************************************************
****
* Alloc [COMCTL32.71]
*
* Allocates memory block from the dll's private heap
@@ -1416,912 +1111,6 @@
/***********************************************************************
***
- * DSA_Create [COMCTL32.320]
- *
- * Creates a dynamic storage array
- *
- * PARAMS
- * nSize [I] size of the array elements
- * nGrow [I] number of elements by which the array grows when it is
filled
- *
- * RETURNS
- * Success: pointer to an array control structure. Use this like a
handle.
- * Failure: NULL
- *
- * NOTES
- * The DSA_ functions can be used to create and manipulate arrays
of
- * fixed-size memory blocks. These arrays can store any kind of
data
- * (e.g. strings and icons).
- */
-HDSA WINAPI DSA_Create (INT nSize, INT nGrow)
-{
- HDSA hdsa;
-
- TRACE("(size=%d grow=%d)\n", nSize, nGrow);
-
- hdsa = Alloc (sizeof(*hdsa));
- if (hdsa)
- {
- hdsa->nItemCount = 0;
- hdsa->pData = NULL;
- hdsa->nMaxCount = 0;
- hdsa->nItemSize = nSize;
- hdsa->nGrow = max(1, nGrow);
- }
-
- return hdsa;
-}
-
-
-/**********************************************************************
****
- * DSA_Destroy [COMCTL32.321]
- *
- * Destroys a dynamic storage array
- *
- * PARAMS
- * hdsa [I] pointer to the array control structure
- *
- * RETURNS
- * Success: TRUE
- * Failure: FALSE
- */
-BOOL WINAPI DSA_Destroy (const HDSA hdsa)
-{
- TRACE("(%p)\n", hdsa);
-
- if (!hdsa)
- return FALSE;
-
- if (hdsa->pData && (!Free (hdsa->pData)))
- return FALSE;
-
- return Free (hdsa);
-}
-
-
-/**********************************************************************
****
- * DSA_GetItem [COMCTL32.322]
- *
- * Copies the specified item into a caller-supplied buffer.
- *
- * PARAMS
- * hdsa [I] pointer to the array control structure
- * nIndex [I] number of the Item to get
- * pDest [O] destination buffer. Has to be >= dwElementSize.
- *
- * RETURNS
- * Success: TRUE
- * Failure: FALSE
- */
-BOOL WINAPI DSA_GetItem (const HDSA hdsa, INT nIndex, LPVOID pDest)
-{
- LPVOID pSrc;
-
- TRACE("(%p %d %p)\n", hdsa, nIndex, pDest);
-
- if (!hdsa)
- return FALSE;
- if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
- return FALSE;
-
- pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
- memmove (pDest, pSrc, hdsa->nItemSize);
-
- return TRUE;
-}
-
-
-/**********************************************************************
****
- * DSA_GetItemPtr [COMCTL32.323]
- *
- * Retrieves a pointer to the specified item.
- *
- * PARAMS
- * hdsa [I] pointer to the array control structure
- * nIndex [I] index of the desired item
- *
- * RETURNS
- * Success: pointer to an item
- * Failure: NULL
- */
-LPVOID WINAPI DSA_GetItemPtr (const HDSA hdsa, INT nIndex)
-{
- LPVOID pSrc;
-
- TRACE("(%p %d)\n", hdsa, nIndex);
-
- if (!hdsa)
- return NULL;
- if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
- return NULL;
-
- pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
-
- TRACE("-- ret=%p\n", pSrc);
-
- return pSrc;
-}
-
-
-/**********************************************************************
****
- * DSA_SetItem [COMCTL32.325]
- *
- * Sets the contents of an item in the array.
- *
- * PARAMS
- * hdsa [I] pointer to the array control structure
- * nIndex [I] index for the item
- * pSrc [I] pointer to the new item data
- *
- * RETURNS
- * Success: TRUE
- * Failure: FALSE
- */
-BOOL WINAPI DSA_SetItem (const HDSA hdsa, INT nIndex, LPVOID pSrc)
-{
- INT nSize, nNewItems;
- LPVOID pDest, lpTemp;
-
- TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
-
- if ((!hdsa) || nIndex < 0)
- return FALSE;
-
- if (hdsa->nItemCount <= nIndex) {
- /* within the old array */
- if (hdsa->nMaxCount > nIndex) {
- /* within the allocated space, set a new boundary */
- hdsa->nItemCount = nIndex + 1;
- }
- else {
- /* resize the block of memory */
- nNewItems =
- hdsa->nGrow * ((INT)(((nIndex + 1) - 1) / hdsa->nGrow) +
1);
- nSize = hdsa->nItemSize * nNewItems;
-
- lpTemp = ReAlloc (hdsa->pData, nSize);
- if (!lpTemp)
- return FALSE;
-
- hdsa->nMaxCount = nNewItems;
- hdsa->nItemCount = nIndex + 1;
- hdsa->pData = lpTemp;
- }
- }
-
- /* put the new entry in */
- pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
- TRACE("-- move dest=%p src=%p size=%d\n",
- pDest, pSrc, hdsa->nItemSize);
- memmove (pDest, pSrc, hdsa->nItemSize);
-
- return TRUE;
-}
-
-
-/**********************************************************************
****
- * DSA_InsertItem [COMCTL32.324]
- *
- * Inserts an item into the array at the specified index.
- *
- * PARAMS
- * hdsa [I] pointer to the array control structure
- * nIndex [I] index for the new item
- * pSrc [I] pointer to the element
- *
- * RETURNS
- * Success: position of the new item
- * Failure: -1
- */
-INT WINAPI DSA_InsertItem (const HDSA hdsa, INT nIndex, LPVOID pSrc)
-{
- INT nNewItems, nSize;
- LPVOID lpTemp, lpDest;
-
- TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
-
- if ((!hdsa) || nIndex < 0)
- return -1;
-
- /* when nIndex >= nItemCount then append */
- if (nIndex >= hdsa->nItemCount)
- nIndex = hdsa->nItemCount;
-
- /* do we need to resize ? */
- if (hdsa->nItemCount >= hdsa->nMaxCount) {
- nNewItems = hdsa->nMaxCount + hdsa->nGrow;
- nSize = hdsa->nItemSize * nNewItems;
-
- lpTemp = ReAlloc (hdsa->pData, nSize);
- if (!lpTemp)
- return -1;
-
- hdsa->nMaxCount = nNewItems;
- hdsa->pData = lpTemp;
- }
-
- /* do we need to move elements ? */
- if (nIndex < hdsa->nItemCount) {
- lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
- lpDest = (char *) lpTemp + hdsa->nItemSize;
- nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize;
- TRACE("-- move dest=%p src=%p size=%d\n",
- lpDest, lpTemp, nSize);
- memmove (lpDest, lpTemp, nSize);
- }
-
- /* ok, we can put the new Item in */
- hdsa->nItemCount++;
- lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
- TRACE("-- move dest=%p src=%p size=%d\n",
- lpDest, pSrc, hdsa->nItemSize);
- memmove (lpDest, pSrc, hdsa->nItemSize);
-
- return nIndex;
-}
-
-
-/**********************************************************************
****
- * DSA_DeleteItem [COMCTL32.326]
- *
- * Deletes the specified item from the array.
- *
- * PARAMS
- * hdsa [I] pointer to the array control structure
- * nIndex [I] index for the element to delete
- *
- * RETURNS
- * Success: number of the deleted element
- * Failure: -1
- */
-INT WINAPI DSA_DeleteItem (const HDSA hdsa, INT nIndex)
-{
- LPVOID lpDest,lpSrc;
- INT nSize;
-
- TRACE("(%p %d)\n", hdsa, nIndex);
-
- if (!hdsa)
- return -1;
- if (nIndex < 0 || nIndex >= hdsa->nItemCount)
- return -1;
-
- /* do we need to move ? */
- if (nIndex < hdsa->nItemCount - 1) {
- lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
- lpSrc = (char *) lpDest + hdsa->nItemSize;
- nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1);
- TRACE("-- move dest=%p src=%p size=%d\n",
- lpDest, lpSrc, nSize);
- memmove (lpDest, lpSrc, nSize);
- }
-
- hdsa->nItemCount--;
-
- /* free memory ? */
- if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) {
- nSize = hdsa->nItemSize * hdsa->nItemCount;
-
- lpDest = ReAlloc (hdsa->pData, nSize);
- if (!lpDest)
- return -1;
-
- hdsa->nMaxCount = hdsa->nItemCount;
- hdsa->pData = lpDest;
- }
-
- return nIndex;
-}
-
-
-/**********************************************************************
****
- * DSA_DeleteAllItems [COMCTL32.327]
- *
- * Removes all items and reinitializes the array.
- *
- * PARAMS
- * hdsa [I] pointer to the array control structure
- *
- * RETURNS
- * Success: TRUE
- * Failure: FALSE
- */
-BOOL WINAPI DSA_DeleteAllItems (const HDSA hdsa)
-{
- TRACE("(%p)\n", hdsa);
-
- if (!hdsa)
- return FALSE;
- if (hdsa->pData && (!Free (hdsa->pData)))
- return FALSE;
-
- hdsa->nItemCount = 0;
- hdsa->pData = NULL;
- hdsa->nMaxCount = 0;
-
- return TRUE;
-}
-
-
-/**********************************************************************
****
- * DPA_Destroy [COMCTL32.329]
- *
- * Destroys a dynamic pointer array
- *
- * PARAMS
- * hdpa [I] handle (pointer) to the pointer array
- *
- * RETURNS
- * Success: TRUE
- * Failure: FALSE
- */
-BOOL WINAPI DPA_Destroy (const HDPA hdpa)
-{
- TRACE("(%p)\n", hdpa);
-
- if (!hdpa)
- return FALSE;
-
- if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
- return FALSE;
-
- return HeapFree (hdpa->hHeap, 0, hdpa);
-}
-
-
-/**********************************************************************
****
- * DPA_Grow [COMCTL32.330]
- *
- * Sets the growth amount.
- *
- * PARAMS
- * hdpa [I] handle (pointer) to the existing (source) pointer
array
- * nGrow [I] number of items by which the array grows when it's too
small
- *
- * RETURNS
- * Success: TRUE
- * Failure: FALSE
- */
-BOOL WINAPI DPA_Grow (const HDPA hdpa, INT nGrow)
-{
- TRACE("(%p %d)\n", hdpa, nGrow);
-
- if (!hdpa)
- return FALSE;
-
- hdpa->nGrow = max(8, nGrow);
-
- return TRUE;
-}
-
-
-/**********************************************************************
****
- * DPA_Clone [COMCTL32.331]
- *
- * Copies a pointer array to an other one or creates a copy
- *
- * PARAMS
- * hdpa [I] handle (pointer) to the existing (source) pointer
array
- * hdpaNew [O] handle (pointer) to the destination pointer array
- *
- * RETURNS
- * Success: pointer to the destination pointer array.
- * Failure: NULL
- *
- * NOTES
- * - If the 'hdpaNew' is a NULL-Pointer, a copy of the source
pointer
- * array will be created and it's handle (pointer) is returned.
- * - If 'hdpa' is a NULL-Pointer, the original implementation
crashes,
- * this implementation just returns NULL.
- */
-HDPA WINAPI DPA_Clone (const HDPA hdpa, const HDPA hdpaNew)
-{
- INT nNewItems, nSize;
- HDPA hdpaTemp;
-
- if (!hdpa)
- return NULL;
-
- TRACE("(%p %p)\n", hdpa, hdpaNew);
-
- if (!hdpaNew) {
- /* create a new DPA */
- hdpaTemp = HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
- sizeof(*hdpaTemp));
- hdpaTemp->hHeap = hdpa->hHeap;
- hdpaTemp->nGrow = hdpa->nGrow;
- }
- else
- hdpaTemp = hdpaNew;
-
- if (hdpaTemp->ptrs) {
- /* remove old pointer array */
- HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs);
- hdpaTemp->ptrs = NULL;
- hdpaTemp->nItemCount = 0;
- hdpaTemp->nMaxCount = 0;
- }
-
- /* create a new pointer array */
- nNewItems = hdpaTemp->nGrow *
- ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1);
- nSize = nNewItems * sizeof(LPVOID);
- hdpaTemp->ptrs = HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY,
nSize);
- hdpaTemp->nMaxCount = nNewItems;
-
- /* clone the pointer array */
- hdpaTemp->nItemCount = hdpa->nItemCount;
- memmove (hdpaTemp->ptrs, hdpa->ptrs,
- hdpaTemp->nItemCount * sizeof(LPVOID));
-
- return hdpaTemp;
-}
-
-
-/**********************************************************************
****
- * DPA_GetPtr [COMCTL32.332]
- *
- * Retrieves a pointer from a dynamic pointer array
- *
- * PARAMS
- * hdpa [I] handle (pointer) to the pointer array
- * nIndex [I] array index of the desired pointer
- *
- * RETURNS
- * Success: pointer
- * Failure: NULL
- */
-LPVOID WINAPI DPA_GetPtr (const HDPA hdpa, INT nIndex)
-{
- TRACE("(%p %d)\n", hdpa, nIndex);
-
- if (!hdpa)
- return NULL;
- if (!hdpa->ptrs) {
- WARN("no pointer array.\n");
- return NULL;
- }
- if ((nIndex < 0) || (nIndex >= hdpa->nItemCount)) {
- WARN("not enough pointers in array (%d vs
%d).\n",nIndex,hdpa->nItemCount);
- return NULL;
- }
-
- TRACE("-- %p\n", hdpa->ptrs[nIndex]);
-
- return hdpa->ptrs[nIndex];
-}
-
-
-/**********************************************************************
****
- * DPA_GetPtrIndex [COMCTL32.333]
- *
- * Retrieves the index of the specified pointer
- *
- * PARAMS
- * hdpa [I] handle (pointer) to the pointer array
- * p [I] pointer
- *
- * RETURNS
- * Success: index of the specified pointer
- * Failure: -1
- */
-INT WINAPI DPA_GetPtrIndex (const HDPA hdpa, LPVOID p)
-{
- INT i;
-
- if (!hdpa || !hdpa->ptrs)
- return -1;
-
- for (i = 0; i < hdpa->nItemCount; i++) {
- if (hdpa->ptrs[i] == p)
- return i;
- }
-
- return -1;
-}
-
-
-/**********************************************************************
****
- * DPA_InsertPtr [COMCTL32.334]
- *
- * Inserts a pointer into a dynamic pointer array
- *
- * PARAMS
- * hdpa [I] handle (pointer) to the array
- * i [I] array index
- * p [I] pointer to insert
- *
- * RETURNS
- * Success: index of the inserted pointer
- * Failure: -1
- */
-INT WINAPI DPA_InsertPtr (const HDPA hdpa, INT i, LPVOID p)
-{
- TRACE("(%p %d %p)\n", hdpa, i, p);
-
- if (!hdpa || i < 0) return -1;
-
- if (i >= 0x7fff)
- i = hdpa->nItemCount;
-
- if (i >= hdpa->nItemCount)
- return DPA_SetPtr(hdpa, i, p) ? i : -1;
-
- /* create empty spot at the end */
- if (!DPA_SetPtr(hdpa, hdpa->nItemCount, 0)) return -1;
- memmove (hdpa->ptrs + i + 1, hdpa->ptrs + i, (hdpa->nItemCount - i
- 1) * sizeof(LPVOID));
- hdpa->ptrs[i] = p;
- return i;
-}
-
-/**********************************************************************
****
- * DPA_SetPtr [COMCTL32.335]
- *
- * Sets a pointer in the pointer array
- *
- * PARAMS
- * hdpa [I] handle (pointer) to the pointer array
- * i [I] index of the pointer that will be set
- * p [I] pointer to be set
- *
- * RETURNS
- * Success: TRUE
- * Failure: FALSE
- */
-BOOL WINAPI DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p)
-{
- LPVOID *lpTemp;
-
- TRACE("(%p %d %p)\n", hdpa, i, p);
-
- if (!hdpa || i < 0 || i > 0x7fff)
- return FALSE;
-
- if (hdpa->nItemCount <= i) {
- /* within the old array */
- if (hdpa->nMaxCount <= i) {
- /* resize the block of memory */
- INT nNewItems =
- hdpa->nGrow * ((INT)(((i+1) - 1) / hdpa->nGrow) + 1);
- INT nSize = nNewItems * sizeof(LPVOID);
-
- if (hdpa->ptrs)
- lpTemp = HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
hdpa->ptrs, nSize);
- else
- lpTemp = HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
nSize);
-
- if (!lpTemp)
- return FALSE;
-
- hdpa->nMaxCount = nNewItems;
- hdpa->ptrs = lpTemp;
- }
- hdpa->nItemCount = i+1;
- }
-
- /* put the new entry in */
- hdpa->ptrs[i] = p;
-
- return TRUE;
-}
-
-
-/**********************************************************************
****
- * DPA_DeletePtr [COMCTL32.336]
- *
- * Removes a pointer from the pointer array.
- *
- * PARAMS
- * hdpa [I] handle (pointer) to the pointer array
- * i [I] index of the pointer that will be deleted
- *
- * RETURNS
- * Success: deleted pointer
- * Failure: NULL
- */
-LPVOID WINAPI DPA_DeletePtr (const HDPA hdpa, INT i)
-{
- LPVOID *lpDest, *lpSrc, lpTemp = NULL;
- INT nSize;
-
- TRACE("(%p %d)\n", hdpa, i);
-
- if ((!hdpa) || i < 0 || i >= hdpa->nItemCount)
- return NULL;
-
- lpTemp = hdpa->ptrs[i];
-
- /* do we need to move ?*/
- if (i < hdpa->nItemCount - 1) {
- lpDest = hdpa->ptrs + i;
- lpSrc = lpDest + 1;
- nSize = (hdpa->nItemCount - i - 1) * sizeof(LPVOID);
- TRACE("-- move dest=%p src=%p size=%x\n",
- lpDest, lpSrc, nSize);
- memmove (lpDest, lpSrc, nSize);
- }
-
- hdpa->nItemCount --;
-
- /* free memory ?*/
- if ((hdpa->nMaxCount - hdpa->nItemCount) >= hdpa->nGrow) {
- INT nNewItems = max(hdpa->nGrow * 2, hdpa->nItemCount);
- nSize = nNewItems * sizeof(LPVOID);
- lpDest = HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
- hdpa->ptrs, nSize);
- if (!lpDest)
- return NULL;
-
- hdpa->nMaxCount = nNewItems;
- hdpa->ptrs = (LPVOID*)lpDest;
- }
-
- return lpTemp;
-}
-
-
-/**********************************************************************
****
- * DPA_DeleteAllPtrs [COMCTL32.337]
- *
- * Removes all pointers and reinitializes the array.
- *
- * PARAMS
- * hdpa [I] handle (pointer) to the pointer array
- *
- * RETURNS
- * Success: TRUE
- * Failure: FALSE
- */
[truncated at 1000 lines; 2397 more skipped]