Commit 7e65349c authored by David Hedberg's avatar David Hedberg Committed by Alexandre Julliard

explorerframe: Implement SetItemState and GetItemState.

parent 4507905f
......@@ -254,6 +254,53 @@ static nstc_root *root_for_treeitem(NSTC2Impl *This, HTREEITEM hitem)
return root;
}
/* Find a shellitem in the tree, starting from the given node. */
static HTREEITEM search_for_shellitem(NSTC2Impl *This, HTREEITEM node,
IShellItem *psi)
{
IShellItem *psi_node;
HTREEITEM next, result = NULL;
HRESULT hr;
int cmpo;
TRACE("%p, %p, %p\n", This, node, psi);
/* Check this node */
psi_node = shellitem_from_treeitem(This, node);
hr = IShellItem_Compare(psi, psi_node, SICHINT_DISPLAY, &cmpo);
if(hr == S_OK)
return node;
/* Any children? */
next = (HTREEITEM)SendMessageW(This->hwnd_tv, TVM_GETNEXTITEM,
TVGN_CHILD, (LPARAM)node);
if(next)
{
result = search_for_shellitem(This, next, psi);
if(result) return result;
}
/* Try our next sibling. */
next = (HTREEITEM)SendMessageW(This->hwnd_tv, TVM_GETNEXTITEM,
TVGN_NEXT, (LPARAM)node);
if(next)
result = search_for_shellitem(This, next, psi);
return result;
}
static HTREEITEM treeitem_from_shellitem(NSTC2Impl *This, IShellItem *psi)
{
HTREEITEM root;
TRACE("%p, %p\n", This, psi);
root = (HTREEITEM)SendMessageW(This->hwnd_tv, TVM_GETNEXTITEM,
TVGN_ROOT, 0);
if(!root)
return NULL;
return search_for_shellitem(This, root, psi);
}
static int get_icon(LPCITEMIDLIST lpi, UINT extra_flags)
{
SHFILEINFOW sfi;
......@@ -1070,8 +1117,61 @@ static HRESULT WINAPI NSTC2_fnSetItemState(INameSpaceTreeControl2* iface,
NSTCITEMSTATE nstcisFlags)
{
NSTC2Impl *This = (NSTC2Impl*)iface;
FIXME("stub, %p (%p, %x, %x)\n", This, psi, nstcisMask, nstcisFlags);
return E_NOTIMPL;
TVITEMEXW tvi;
HTREEITEM hitem;
TRACE("%p (%p, %x, %x)\n", This, psi, nstcisMask, nstcisFlags);
hitem = treeitem_from_shellitem(This, psi);
if(!hitem) return E_INVALIDARG;
/* Passing both NSTCIS_SELECTED and NSTCIS_SELECTEDNOEXPAND results
in two TVM_SETITEMW's */
if((nstcisMask&nstcisFlags) & NSTCIS_SELECTED)
{
SendMessageW(This->hwnd_tv, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hitem);
SendMessageW(This->hwnd_tv, TVM_ENSUREVISIBLE, 0, (LPARAM)hitem);
}
if((nstcisMask&nstcisFlags) & NSTCIS_SELECTEDNOEXPAND)
{
SendMessageW(This->hwnd_tv, TVM_SELECTITEM, TVGN_CARET|TVSI_NOSINGLEEXPAND, (LPARAM)hitem);
}
/* If NSTCIS_EXPANDED is among the flags, the mask is ignored. */
if((nstcisMask|nstcisFlags) & NSTCIS_EXPANDED)
{
WPARAM arg = nstcisFlags&NSTCIS_EXPANDED ? TVE_EXPAND:TVE_COLLAPSE;
SendMessageW(This->hwnd_tv, TVM_EXPAND, arg, (LPARAM)hitem);
}
if(nstcisMask & NSTCIS_DISABLED)
tvi.mask = TVIF_STATE | TVIF_STATEEX;
else if( ((nstcisMask^nstcisFlags) & (NSTCIS_SELECTED|NSTCIS_EXPANDED|NSTCIS_SELECTEDNOEXPAND)) ||
((nstcisMask|nstcisFlags) & NSTCIS_BOLD) ||
(nstcisFlags & NSTCIS_DISABLED) )
tvi.mask = TVIF_STATE;
else
tvi.mask = 0;
if(tvi.mask)
{
tvi.stateMask = tvi.state = 0;
tvi.stateMask |= ((nstcisFlags^nstcisMask)&NSTCIS_SELECTED) ? TVIS_SELECTED : 0;
tvi.stateMask |= (nstcisMask|nstcisFlags)&NSTCIS_BOLD ? TVIS_BOLD:0;
tvi.state |= (nstcisMask&nstcisFlags)&NSTCIS_BOLD ? TVIS_BOLD:0;
if((nstcisMask&NSTCIS_EXPANDED)^(nstcisFlags&NSTCIS_EXPANDED))
{
tvi.stateMask = 0;
}
tvi.uStateEx = (nstcisFlags&nstcisMask)&NSTCIS_DISABLED?TVIS_EX_DISABLED:0;
tvi.hItem = hitem;
SendMessageW(This->hwnd_tv, TVM_SETITEMW, 0, (LPARAM)&tvi);
}
return S_OK;
}
static HRESULT WINAPI NSTC2_fnGetItemState(INameSpaceTreeControl2* iface,
......@@ -1080,8 +1180,32 @@ static HRESULT WINAPI NSTC2_fnGetItemState(INameSpaceTreeControl2* iface,
NSTCITEMSTATE *pnstcisFlags)
{
NSTC2Impl *This = (NSTC2Impl*)iface;
FIXME("stub, %p (%p, %x, %p)\n", This, psi, nstcisMask, pnstcisFlags);
return E_NOTIMPL;
HTREEITEM hitem;
TVITEMEXW tvi;
TRACE("%p (%p, %x, %p)\n", This, psi, nstcisMask, pnstcisFlags);
hitem = treeitem_from_shellitem(This, psi);
if(!hitem)
return E_INVALIDARG;
*pnstcisFlags = 0;
tvi.hItem = hitem;
tvi.mask = TVIF_STATE;
tvi.stateMask = TVIS_SELECTED|TVIS_EXPANDED|TVIS_BOLD;
if(nstcisMask & NSTCIS_DISABLED)
tvi.mask |= TVIF_STATEEX;
SendMessageW(This->hwnd_tv, TVM_GETITEMW, 0, (LPARAM)&tvi);
*pnstcisFlags |= (tvi.state & TVIS_SELECTED)?NSTCIS_SELECTED:0;
*pnstcisFlags |= (tvi.state & TVIS_EXPANDED)?NSTCIS_EXPANDED:0;
*pnstcisFlags |= (tvi.state & TVIS_BOLD)?NSTCIS_BOLD:0;
*pnstcisFlags |= (tvi.uStateEx & TVIS_EX_DISABLED)?NSTCIS_DISABLED:0;
*pnstcisFlags &= nstcisMask;
return S_OK;
}
static HRESULT WINAPI NSTC2_fnGetSelectedItems(INameSpaceTreeControl2* iface,
......
/* Message Sequence Testing Code
*
* Copyright (C) 2007 James Hawkins
* Copyright (C) 2007 Lei Zhang
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <assert.h>
#include <windows.h>
#include "wine/test.h"
/* undocumented SWP flags - from SDK 3.1 */
#define SWP_NOCLIENTSIZE 0x0800
#define SWP_NOCLIENTMOVE 0x1000
typedef enum
{
sent = 0x1,
posted = 0x2,
parent = 0x4,
wparam = 0x8,
lparam = 0x10,
defwinproc = 0x20,
beginpaint = 0x40,
optional = 0x80,
hook = 0x100,
winevent_hook =0x200,
id = 0x400
} msg_flags_t;
struct message
{
UINT message; /* the WM_* code */
msg_flags_t flags; /* message props */
WPARAM wParam; /* expected value of wParam */
LPARAM lParam; /* expected value of lParam */
UINT id; /* extra message data: id of the window,
notify code etc. */
};
struct msg_sequence
{
int count;
int size;
struct message *sequence;
};
static void add_message(struct msg_sequence **seq, int sequence_index,
const struct message *msg)
{
struct msg_sequence *msg_seq = seq[sequence_index];
if (!msg_seq->sequence)
{
msg_seq->size = 10;
msg_seq->sequence = HeapAlloc(GetProcessHeap(), 0,
msg_seq->size * sizeof (struct message));
}
if (msg_seq->count == msg_seq->size)
{
msg_seq->size *= 2;
msg_seq->sequence = HeapReAlloc(GetProcessHeap(), 0,
msg_seq->sequence,
msg_seq->size * sizeof (struct message));
}
assert(msg_seq->sequence);
msg_seq->sequence[msg_seq->count].message = msg->message;
msg_seq->sequence[msg_seq->count].flags = msg->flags;
msg_seq->sequence[msg_seq->count].wParam = msg->wParam;
msg_seq->sequence[msg_seq->count].lParam = msg->lParam;
msg_seq->sequence[msg_seq->count].id = msg->id;
msg_seq->count++;
}
static void flush_sequence(struct msg_sequence **seg, int sequence_index)
{
struct msg_sequence *msg_seq = seg[sequence_index];
HeapFree(GetProcessHeap(), 0, msg_seq->sequence);
msg_seq->sequence = NULL;
msg_seq->count = msg_seq->size = 0;
}
static void flush_sequences(struct msg_sequence **seq, int n)
{
int i;
for (i = 0; i < n; i++)
flush_sequence(seq, i);
}
/* ok_sequence is stripped out as it is not currently used. */
static void init_msg_sequences(struct msg_sequence **seq, int n)
{
int i;
for (i = 0; i < n; i++)
seq[i] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct msg_sequence));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment