ReactOS 0.4.15-dev-8390-g075894b
treeview.c File Reference
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <ctype.h>
#include <stdarg.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "commctrl.h"
#include "comctl32.h"
#include "uxtheme.h"
#include "vssym32.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "wine/exception.h"
#include "wine/heap.h"
Include dependency graph for treeview.c:

Go to the source code of this file.

Classes

struct  tagTREEVIEW_INFO
 
struct  _TREEITEM
 

Macros

#define NONAMELESSUNION
 
#define KEY_DELAY   450
 
#define TV_HSCROLL   0x01 /* treeview too large to fit in window */
 
#define TV_VSCROLL   0x02 /* (horizontal/vertical) */
 
#define TV_LDRAG   0x04 /* Lbutton pushed to start drag */
 
#define TV_LDRAGGING   0x08 /* Lbutton pushed, mouse moved. */
 
#define TV_RDRAG   0x10 /* ditto Rbutton */
 
#define TV_RDRAGGING   0x20
 
#define TV_EDIT_TIMER   2
 
#define TV_EDIT_TIMER_SET   2
 
#define TEXT_CALLBACK_SIZE   260
 
#define TREEVIEW_LEFT_MARGIN   8
 
#define MINIMUM_INDENT   19
 
#define CALLBACK_MASK_ALL   (TVIF_TEXT|TVIF_CHILDREN|TVIF_IMAGE|TVIF_SELECTEDIMAGE)
 
#define STATEIMAGEINDEX(x)   (((x) >> 12) & 0x0f)
 
#define OVERLAYIMAGEINDEX(x)   (((x) >> 8) & 0x0f)
 
#define ISVISIBLE(x)   ((x)->visibleOrder >= 0)
 
#define GETLINECOLOR(x)   ((x) == CLR_DEFAULT ? comctl32_color.clrGrayText : (x))
 
#define GETBKCOLOR(x)   ((x) == CLR_NONE ? comctl32_color.clrWindow : (x))
 
#define GETTXTCOLOR(x)   ((x) == CLR_NONE ? comctl32_color.clrWindowText : (x))
 
#define GETINSCOLOR(x)   ((x) == CLR_DEFAULT ? comctl32_color.clrBtnText : (x))
 
#define TVHEIGHT_MIN   16
 
#define TVHEIGHT_FONT_ADJUST   3 /* 2 for focus border + 1 for margin some apps assume */
 
#define SCROLL_ENTRY(dir, code)   { ((dir) << 7) | (code) }
 

Typedefs

typedef struct tagTREEVIEW_INFO TREEVIEW_INFO
 
typedef struct _TREEITEM TREEVIEW_ITEM
 
typedef VOID(* TREEVIEW_ItemEnumFunc) (TREEVIEW_INFO *, TREEVIEW_ITEM *, LPVOID)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (treeview)
 
static VOID TREEVIEW_Invalidate (const TREEVIEW_INFO *, const TREEVIEW_ITEM *)
 
static LRESULT TREEVIEW_DoSelectItem (TREEVIEW_INFO *, INT, HTREEITEM, INT)
 
static VOID TREEVIEW_SetFirstVisible (TREEVIEW_INFO *, TREEVIEW_ITEM *, BOOL)
 
static LRESULT TREEVIEW_EnsureVisible (TREEVIEW_INFO *, HTREEITEM, BOOL)
 
static LRESULT TREEVIEW_EndEditLabelNow (TREEVIEW_INFO *infoPtr, BOOL bCancel)
 
static VOID TREEVIEW_UpdateScrollBars (TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_HScroll (TREEVIEW_INFO *, WPARAM)
 
static void TREEVIEW_VerifyTree (TREEVIEW_INFO *infoPtr)
 
static TREEVIEW_INFOTREEVIEW_GetInfoPtr (HWND hwnd)
 
static int TREEVIEW_GetItemIndex (const TREEVIEW_INFO *infoPtr, HTREEITEM handle)
 
static BOOL item_changed (const TREEVIEW_ITEM *tiOld, const TREEVIEW_ITEM *tiNew, const TVITEMEXW *tvChange)
 
static BOOL TREEVIEW_ValidItem (const TREEVIEW_INFO *infoPtr, HTREEITEM handle)
 
static HFONT TREEVIEW_CreateBoldFont (HFONT hOrigFont)
 
static HFONT TREEVIEW_CreateUnderlineFont (HFONT hOrigFont)
 
static HFONT TREEVIEW_CreateBoldUnderlineFont (HFONT hfont)
 
static HFONT TREEVIEW_FontForItem (const TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *item)
 
static const charTREEVIEW_ItemName (const TREEVIEW_ITEM *item)
 
static BOOL TREEVIEW_IsChildOf (const TREEVIEW_ITEM *parent, const TREEVIEW_ITEM *child)
 
static BOOL TREEVIEW_IsFullRowSelect (const TREEVIEW_INFO *infoPtr)
 
static BOOL TREEVIEW_IsItemHit (const TREEVIEW_INFO *infoPtr, const TVHITTESTINFO *ht)
 
static TREEVIEW_ITEMTREEVIEW_GetLastListItem (const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
 
static TREEVIEW_ITEMTREEVIEW_GetPrevListItem (const TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *tvItem)
 
static TREEVIEW_ITEMTREEVIEW_GetNextListItem (const TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *tvItem)
 
static TREEVIEW_ITEMTREEVIEW_GetListItem (const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, LONG count)
 
static INT get_notifycode (const TREEVIEW_INFO *infoPtr, INT code)
 
static BOOL TREEVIEW_SendRealNotify (const TREEVIEW_INFO *infoPtr, UINT code, NMHDR *hdr)
 
static BOOL TREEVIEW_SendSimpleNotify (const TREEVIEW_INFO *infoPtr, UINT code)
 
static VOID TREEVIEW_TVItemFromItem (const TREEVIEW_INFO *infoPtr, UINT mask, TVITEMW *tvItem, TREEVIEW_ITEM *item)
 
static BOOL TREEVIEW_SendTreeviewNotify (const TREEVIEW_INFO *infoPtr, UINT code, UINT action, UINT mask, HTREEITEM oldItem, HTREEITEM newItem)
 
static BOOL TREEVIEW_SendTreeviewDnDNotify (const TREEVIEW_INFO *infoPtr, UINT code, HTREEITEM dragItem, POINT pt)
 
static BOOL TREEVIEW_SendCustomDrawNotify (const TREEVIEW_INFO *infoPtr, DWORD dwDrawStage, HDC hdc, RECT rc)
 
static BOOL TREEVIEW_SendCustomDrawItemNotify (const TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item, UINT uItemDrawState, NMTVCUSTOMDRAW *nmcdhdr)
 
static BOOL TREEVIEW_BeginLabelEditNotify (const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *editItem)
 
static void TREEVIEW_UpdateDispInfo (const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, UINT mask)
 
static BOOL TREEVIEW_HasChildren (const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
 
static INT TREEVIEW_NotifyFormat (TREEVIEW_INFO *infoPtr, HWND hwndFrom, UINT nCommand)
 
static VOID TREEVIEW_ComputeItemInternalMetrics (const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
 
static VOID TREEVIEW_ComputeTextWidth (const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, HDC hDC)
 
static VOID TREEVIEW_ComputeItemRect (const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
 
static void TREEVIEW_RecalculateVisibleOrder (TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *start)
 
static VOID TREEVIEW_UpdateSubTree (const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *root)
 
static TREEVIEW_ITEMTREEVIEW_AllocateItem (const TREEVIEW_INFO *infoPtr)
 
static void TREEVIEW_FreeItem (TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
 
static void TREEVIEW_InsertBefore (TREEVIEW_ITEM *newItem, TREEVIEW_ITEM *sibling, TREEVIEW_ITEM *parent)
 
static void TREEVIEW_InsertAfter (TREEVIEW_ITEM *newItem, TREEVIEW_ITEM *sibling, TREEVIEW_ITEM *parent)
 
static BOOL TREEVIEW_DoSetItemT (const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, const TVITEMEXW *tvItem, BOOL isW)
 
static LRESULT TREEVIEW_InsertItemT (TREEVIEW_INFO *infoPtr, const TVINSERTSTRUCTW *ptdi, BOOL isW)
 
static void TREEVIEW_RemoveItem (TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
 
static void TREEVIEW_RemoveAllChildren (TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *parentItem)
 
static void TREEVIEW_UnlinkItem (const TREEVIEW_ITEM *item)
 
static void TREEVIEW_RemoveTree (TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_DeleteItem (TREEVIEW_INFO *infoPtr, HTREEITEM item)
 
static LRESULT TREEVIEW_SetRedraw (TREEVIEW_INFO *infoPtr, WPARAM wParam)
 
static LRESULT TREEVIEW_GetIndent (const TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_SetIndent (TREEVIEW_INFO *infoPtr, UINT newIndent)
 
static LRESULT TREEVIEW_GetToolTips (const TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_SetToolTips (TREEVIEW_INFO *infoPtr, HWND hwndTT)
 
static LRESULT TREEVIEW_SetUnicodeFormat (TREEVIEW_INFO *infoPtr, BOOL fUnicode)
 
static LRESULT TREEVIEW_GetUnicodeFormat (const TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_GetScrollTime (const TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_SetScrollTime (TREEVIEW_INFO *infoPtr, UINT uScrollTime)
 
static LRESULT TREEVIEW_GetImageList (const TREEVIEW_INFO *infoPtr, WPARAM wParam)
 
static UINT TREEVIEW_NaturalHeight (const TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_SetImageList (TREEVIEW_INFO *infoPtr, UINT type, HIMAGELIST himlNew)
 
static LRESULT TREEVIEW_SetItemHeight (TREEVIEW_INFO *infoPtr, INT newHeight)
 
static LRESULT TREEVIEW_GetItemHeight (const TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_GetFont (const TREEVIEW_INFO *infoPtr)
 
static INT CALLBACK TREEVIEW_ResetTextWidth (LPVOID pItem, LPVOID unused)
 
static LRESULT TREEVIEW_SetFont (TREEVIEW_INFO *infoPtr, HFONT hFont, BOOL bRedraw)
 
static LRESULT TREEVIEW_GetLineColor (const TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_SetLineColor (TREEVIEW_INFO *infoPtr, COLORREF color)
 
static LRESULT TREEVIEW_GetTextColor (const TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_SetTextColor (TREEVIEW_INFO *infoPtr, COLORREF color)
 
static LRESULT TREEVIEW_GetBkColor (const TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_SetBkColor (TREEVIEW_INFO *infoPtr, COLORREF newColor)
 
static LRESULT TREEVIEW_GetInsertMarkColor (const TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_SetInsertMarkColor (TREEVIEW_INFO *infoPtr, COLORREF color)
 
static LRESULT TREEVIEW_SetInsertMark (TREEVIEW_INFO *infoPtr, BOOL wParam, HTREEITEM item)
 
static LRESULT TREEVIEW_GetItemRect (const TREEVIEW_INFO *infoPtr, BOOL fTextRect, LPRECT lpRect)
 
static LRESULT TREEVIEW_GetVisibleCount (const TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_GetItemT (const TREEVIEW_INFO *infoPtr, LPTVITEMEXW tvItem, BOOL isW)
 
static LRESULT TREEVIEW_SetItemT (TREEVIEW_INFO *infoPtr, const TVITEMEXW *tvItem, BOOL isW)
 
static LRESULT TREEVIEW_GetItemState (const TREEVIEW_INFO *infoPtr, HTREEITEM item, UINT mask)
 
static LRESULT TREEVIEW_GetNextItem (const TREEVIEW_INFO *infoPtr, UINT which, HTREEITEM item)
 
static LRESULT TREEVIEW_GetCount (const TREEVIEW_INFO *infoPtr)
 
static VOID TREEVIEW_ToggleItemState (const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
 
static void TREEVIEW_DrawItemLines (const TREEVIEW_INFO *infoPtr, HDC hdc, const TREEVIEW_ITEM *item)
 
static void TREEVIEW_DrawItem (const TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item)
 
static void TREEVIEW_FillBkgnd (const TREEVIEW_INFO *infoPtr, HDC hdc, const RECT *rc)
 
static LRESULT TREEVIEW_EraseBackground (const TREEVIEW_INFO *infoPtr, HDC hdc)
 
static void TREEVIEW_Refresh (TREEVIEW_INFO *infoPtr, HDC hdc, const RECT *rc)
 
static void TREEVIEW_InvalidateItem (const TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *item)
 
static void TREEVIEW_InitCheckboxes (TREEVIEW_INFO *infoPtr)
 
static void TREEVIEW_ResetImageStateIndex (TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
 
static LRESULT TREEVIEW_Paint (TREEVIEW_INFO *infoPtr, HDC hdc_ref)
 
static LRESULT TREEVIEW_PrintClient (TREEVIEW_INFO *infoPtr, HDC hdc, DWORD options)
 
static INT WINAPI TREEVIEW_CallBackCompare (const TREEVIEW_ITEM *first, const TREEVIEW_ITEM *second, const TVSORTCB *pCallBackSort)
 
static INT WINAPI TREEVIEW_SortOnName (TREEVIEW_ITEM *first, TREEVIEW_ITEM *second, const TREEVIEW_INFO *infoPtr)
 
static INT TREEVIEW_CountChildren (const TREEVIEW_ITEM *item)
 
static HDPA TREEVIEW_BuildChildDPA (const TREEVIEW_ITEM *item)
 
static LRESULT TREEVIEW_Sort (TREEVIEW_INFO *infoPtr, HTREEITEM parent, LPTVSORTCB pSort)
 
static LRESULT TREEVIEW_SortChildrenCB (TREEVIEW_INFO *infoPtr, LPTVSORTCB pSort)
 
static LRESULT TREEVIEW_SortChildren (TREEVIEW_INFO *infoPtr, LPARAM lParam)
 
static BOOL TREEVIEW_SendExpanding (const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, UINT action)
 
static VOID TREEVIEW_SendExpanded (const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, UINT action)
 
static BOOL TREEVIEW_Collapse (TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, BOOL bRemoveChildren, BOOL bUser)
 
static BOOL TREEVIEW_Expand (TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, BOOL partial, BOOL user)
 
static void TREEVIEW_SingleExpand (TREEVIEW_INFO *infoPtr, HTREEITEM selection, HTREEITEM item)
 
static BOOL TREEVIEW_Toggle (TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, BOOL user)
 
static VOID TREEVIEW_ExpandAll (TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
 
static LRESULT TREEVIEW_ExpandMsg (TREEVIEW_INFO *infoPtr, UINT flag, HTREEITEM item)
 
static TREEVIEW_ITEMTREEVIEW_HitTestPoint (const TREEVIEW_INFO *infoPtr, POINT pt)
 
static TREEVIEW_ITEMTREEVIEW_HitTest (const TREEVIEW_INFO *infoPtr, LPTVHITTESTINFO lpht)
 
static LRESULT TREEVIEW_GetEditControl (const TREEVIEW_INFO *infoPtr)
 
static LRESULT CALLBACK TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static LRESULT TREEVIEW_Command (TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 
static HWND TREEVIEW_EditLabel (TREEVIEW_INFO *infoPtr, HTREEITEM hItem)
 
static LRESULT TREEVIEW_HandleTimer (TREEVIEW_INFO *infoPtr, WPARAM wParam)
 
static LRESULT TREEVIEW_TrackMouse (const TREEVIEW_INFO *infoPtr, POINT pt)
 
static LRESULT TREEVIEW_LButtonDoubleClick (TREEVIEW_INFO *infoPtr, LPARAM lParam)
 
static LRESULT TREEVIEW_LButtonDown (TREEVIEW_INFO *infoPtr, LPARAM lParam)
 
static LRESULT TREEVIEW_RButtonDown (TREEVIEW_INFO *infoPtr, LPARAM lParam)
 
static LRESULT TREEVIEW_CreateDragImage (TREEVIEW_INFO *infoPtr, LPARAM lParam)
 
static LRESULT TREEVIEW_SelectItem (TREEVIEW_INFO *infoPtr, INT wParam, HTREEITEM item)
 
static INT TREEVIEW_ProcessLetterKeys (TREEVIEW_INFO *infoPtr, WPARAM charCode, LPARAM keyData)
 
static LRESULT TREEVIEW_VScroll (TREEVIEW_INFO *infoPtr, WPARAM wParam)
 
static LRESULT TREEVIEW_MouseWheel (TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 
static LRESULT TREEVIEW_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
 
static LRESULT TREEVIEW_Destroy (TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_ScrollKeyDown (TREEVIEW_INFO *infoPtr, WPARAM key)
 
static LRESULT TREEVIEW_KeyDown (TREEVIEW_INFO *infoPtr, WPARAM wParam)
 
static LRESULT TREEVIEW_MouseLeave (TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_MouseMove (TREEVIEW_INFO *infoPtr, LPARAM lParam)
 
static BOOL TREEVIEW_NCPaint (const TREEVIEW_INFO *infoPtr, HRGN region, LPARAM lParam)
 
static LRESULT TREEVIEW_Notify (const TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 
static LRESULT TREEVIEW_Size (TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 
static LRESULT TREEVIEW_StyleChanged (TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 
static LRESULT TREEVIEW_SetCursor (const TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 
static LRESULT TREEVIEW_SetFocus (TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_KillFocus (const TREEVIEW_INFO *infoPtr)
 
static LRESULT TREEVIEW_ThemeChanged (const TREEVIEW_INFO *infoPtr)
 
static LRESULT WINAPI TREEVIEW_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
VOID TREEVIEW_Register (void)
 
VOID TREEVIEW_Unregister (void)
 
static void TREEVIEW_VerifyChildren (TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *item)
 
static void TREEVIEW_VerifyItemCommon (TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *item)
 
static void TREEVIEW_VerifyItem (TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *item)
 
static void TREEVIEW_VerifyRoot (TREEVIEW_INFO *infoPtr)
 

Variables

static const WCHAR themeClass [] = { 'T','r','e','e','v','i','e','w',0 }
 

Macro Definition Documentation

◆ CALLBACK_MASK_ALL

Definition at line 196 of file treeview.c.

◆ GETBKCOLOR

#define GETBKCOLOR (   x)    ((x) == CLR_NONE ? comctl32_color.clrWindow : (x))

Definition at line 203 of file treeview.c.

◆ GETINSCOLOR

#define GETINSCOLOR (   x)    ((x) == CLR_DEFAULT ? comctl32_color.clrBtnText : (x))

Definition at line 205 of file treeview.c.

◆ GETLINECOLOR

#define GETLINECOLOR (   x)    ((x) == CLR_DEFAULT ? comctl32_color.clrGrayText : (x))

Definition at line 202 of file treeview.c.

◆ GETTXTCOLOR

#define GETTXTCOLOR (   x)    ((x) == CLR_NONE ? comctl32_color.clrWindowText : (x))

Definition at line 204 of file treeview.c.

◆ ISVISIBLE

#define ISVISIBLE (   x)    ((x)->visibleOrder >= 0)

Definition at line 200 of file treeview.c.

◆ KEY_DELAY

#define KEY_DELAY   450

Definition at line 174 of file treeview.c.

◆ MINIMUM_INDENT

#define MINIMUM_INDENT   19

Definition at line 194 of file treeview.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 53 of file treeview.c.

◆ OVERLAYIMAGEINDEX

#define OVERLAYIMAGEINDEX (   x)    (((x) >> 8) & 0x0f)

Definition at line 199 of file treeview.c.

◆ SCROLL_ENTRY

#define SCROLL_ENTRY (   dir,
  code 
)    { ((dir) << 7) | (code) }

◆ STATEIMAGEINDEX

#define STATEIMAGEINDEX (   x)    (((x) >> 12) & 0x0f)

Definition at line 198 of file treeview.c.

◆ TEXT_CALLBACK_SIZE

#define TEXT_CALLBACK_SIZE   260

Definition at line 190 of file treeview.c.

◆ TREEVIEW_LEFT_MARGIN

#define TREEVIEW_LEFT_MARGIN   8

Definition at line 192 of file treeview.c.

◆ TV_EDIT_TIMER

#define TV_EDIT_TIMER   2

Definition at line 187 of file treeview.c.

◆ TV_EDIT_TIMER_SET

#define TV_EDIT_TIMER_SET   2

Definition at line 188 of file treeview.c.

◆ TV_HSCROLL

#define TV_HSCROLL   0x01 /* treeview too large to fit in window */

Definition at line 178 of file treeview.c.

◆ TV_LDRAG

#define TV_LDRAG   0x04 /* Lbutton pushed to start drag */

Definition at line 180 of file treeview.c.

◆ TV_LDRAGGING

#define TV_LDRAGGING   0x08 /* Lbutton pushed, mouse moved. */

Definition at line 181 of file treeview.c.

◆ TV_RDRAG

#define TV_RDRAG   0x10 /* ditto Rbutton */

Definition at line 182 of file treeview.c.

◆ TV_RDRAGGING

#define TV_RDRAGGING   0x20

Definition at line 183 of file treeview.c.

◆ TV_VSCROLL

#define TV_VSCROLL   0x02 /* (horizontal/vertical) */

Definition at line 179 of file treeview.c.

◆ TVHEIGHT_FONT_ADJUST

#define TVHEIGHT_FONT_ADJUST   3 /* 2 for focus border + 1 for margin some apps assume */

Definition at line 1730 of file treeview.c.

◆ TVHEIGHT_MIN

#define TVHEIGHT_MIN   16

Definition at line 1729 of file treeview.c.

Typedef Documentation

◆ TREEVIEW_INFO

◆ TREEVIEW_ITEM

◆ TREEVIEW_ItemEnumFunc

typedef VOID(* TREEVIEW_ItemEnumFunc) (TREEVIEW_INFO *, TREEVIEW_ITEM *, LPVOID)

Definition at line 210 of file treeview.c.

Function Documentation

◆ get_notifycode()

static INT get_notifycode ( const TREEVIEW_INFO infoPtr,
INT  code 
)
static

Definition at line 499 of file treeview.c.

500{
501 if (!infoPtr->bNtfUnicode) {
502 switch (code) {
504 case TVN_SELCHANGEDW: return TVN_SELCHANGEDA;
509 case TVN_BEGINDRAGW: return TVN_BEGINDRAGA;
510 case TVN_BEGINRDRAGW: return TVN_BEGINRDRAGA;
511 case TVN_DELETEITEMW: return TVN_DELETEITEMA;
514 case TVN_GETINFOTIPW: return TVN_GETINFOTIPA;
515 }
516 }
517 return code;
518}
#define TVN_ENDLABELEDITA
Definition: commctrl.h:3711
#define TVN_SELCHANGINGW
Definition: commctrl.h:3646
#define TVN_ITEMEXPANDEDW
Definition: commctrl.h:3702
#define TVN_BEGINRDRAGW
Definition: commctrl.h:3706
#define TVN_SETDISPINFOW
Definition: commctrl.h:3657
#define TVN_ITEMEXPANDINGA
Definition: commctrl.h:3699
#define TVN_BEGINLABELEDITA
Definition: commctrl.h:3709
#define TVN_GETINFOTIPW
Definition: commctrl.h:3715
#define TVN_SELCHANGEDW
Definition: commctrl.h:3648
#define TVN_BEGINRDRAGA
Definition: commctrl.h:3705
#define TVN_ITEMEXPANDEDA
Definition: commctrl.h:3701
#define TVN_GETDISPINFOW
Definition: commctrl.h:3655
#define TVN_SELCHANGINGA
Definition: commctrl.h:3645
#define TVN_BEGINDRAGW
Definition: commctrl.h:3704
#define TVN_DELETEITEMA
Definition: commctrl.h:3707
#define TVN_BEGINDRAGA
Definition: commctrl.h:3703
#define TVN_GETDISPINFOA
Definition: commctrl.h:3654
#define TVN_ITEMEXPANDINGW
Definition: commctrl.h:3700
#define TVN_BEGINLABELEDITW
Definition: commctrl.h:3710
#define TVN_SELCHANGEDA
Definition: commctrl.h:3647
#define TVN_SETDISPINFOA
Definition: commctrl.h:3656
#define TVN_ENDLABELEDITW
Definition: commctrl.h:3712
#define TVN_DELETEITEMW
Definition: commctrl.h:3708
#define TVN_GETINFOTIPA
Definition: commctrl.h:3714
Definition: inflate.c:139

Referenced by TREEVIEW_SendRealNotify().

◆ item_changed()

static BOOL item_changed ( const TREEVIEW_ITEM tiOld,
const TREEVIEW_ITEM tiNew,
const TVITEMEXW tvChange 
)
inlinestatic

Definition at line 241 of file treeview.c.

243{
244 /* Number of children has changed */
245 if ((tvChange->mask & TVIF_CHILDREN) && (tiOld->cChildren != tiNew->cChildren))
246 return TRUE;
247
248 /* Image has changed and it's not a callback */
249 if ((tvChange->mask & TVIF_IMAGE) && (tiOld->iImage != tiNew->iImage) &&
250 tiNew->iImage != I_IMAGECALLBACK)
251 return TRUE;
252
253 /* Selected image has changed and it's not a callback */
254 if ((tvChange->mask & TVIF_SELECTEDIMAGE) && (tiOld->iSelectedImage != tiNew->iSelectedImage) &&
256 return TRUE;
257
258 if ((tvChange->mask & TVIF_EXPANDEDIMAGE) && (tiOld->iExpandedImage != tiNew->iExpandedImage) &&
260 return TRUE;
261
262 /* Text has changed and it's not a callback */
263 if ((tvChange->mask & TVIF_TEXT) && (tiOld->pszText != tiNew->pszText) &&
265 return TRUE;
266
267 /* Indent has changed */
268 if ((tvChange->mask & TVIF_INTEGRAL) && (tiOld->iIntegral != tiNew->iIntegral))
269 return TRUE;
270
271 /* Item state has changed */
272 if ((tvChange->mask & TVIF_STATE) && ((tiOld->state ^ tiNew->state) & tvChange->stateMask ))
273 return TRUE;
274
275 return FALSE;
276}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define I_IMAGECALLBACK
Definition: commctrl.h:2385
#define TVIF_INTEGRAL
Definition: commctrl.h:3274
#define TVIF_TEXT
Definition: commctrl.h:3266
#define LPSTR_TEXTCALLBACKW
Definition: commctrl.h:2380
#define TVIF_IMAGE
Definition: commctrl.h:3267
#define TVIF_EXPANDEDIMAGE
Definition: commctrl.h:3279
#define TVIF_CHILDREN
Definition: commctrl.h:3272
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3271
#define TVIF_STATE
Definition: commctrl.h:3269
int cChildren
Definition: treeview.c:154
LPWSTR pszText
Definition: treeview.c:149
UINT state
Definition: treeview.c:147
int iIntegral
Definition: treeview.c:156
int iImage
Definition: treeview.c:151
int iSelectedImage
Definition: treeview.c:152
int iExpandedImage
Definition: treeview.c:153
UINT stateMask
Definition: commctrl.h:3349

Referenced by TREEVIEW_SetItemT().

◆ TREEVIEW_AllocateItem()

static TREEVIEW_ITEM * TREEVIEW_AllocateItem ( const TREEVIEW_INFO infoPtr)
static

Definition at line 1003 of file treeview.c.

1004{
1005 TREEVIEW_ITEM *newItem = heap_alloc_zero(sizeof(*newItem));
1006
1007 if (!newItem)
1008 return NULL;
1009
1010 /* I_IMAGENONE would make more sense but this is neither what is
1011 * documented (MSDN doesn't specify) nor what Windows actually does
1012 * (it sets it to zero)... and I can so imagine an application using
1013 * inc/dec to toggle the images. */
1014 newItem->iImage = 0;
1015 newItem->iSelectedImage = 0;
1016 newItem->iExpandedImage = (WORD)I_IMAGENONE;
1017 newItem->infoPtr = infoPtr;
1018
1019 if (DPA_InsertPtr(infoPtr->items, INT_MAX, newItem) == -1)
1020 {
1021 heap_free(newItem);
1022 return NULL;
1023 }
1024
1025 return newItem;
1026}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define NULL
Definition: types.h:112
INT WINAPI DPA_InsertPtr(HDPA hdpa, INT i, LPVOID p)
Definition: dpa.c:591
unsigned short WORD
Definition: ntddk_ex.h:93
#define INT_MAX
Definition: limits.h:40
#define I_IMAGENONE
Definition: commctrl.h:2386
const TREEVIEW_INFO * infoPtr
Definition: treeview.c:170

Referenced by TREEVIEW_Create(), and TREEVIEW_InsertItemT().

◆ TREEVIEW_BeginLabelEditNotify()

static BOOL TREEVIEW_BeginLabelEditNotify ( const TREEVIEW_INFO infoPtr,
TREEVIEW_ITEM editItem 
)
static

Definition at line 686 of file treeview.c.

687{
688 NMTVDISPINFOW tvdi;
689 BOOL ret;
690
692 &tvdi.item, editItem);
693
695
696 if (!infoPtr->bNtfUnicode)
697 heap_free(tvdi.item.pszText);
698
699 return ret;
700}
static VOID TREEVIEW_TVItemFromItem(const TREEVIEW_INFO *infoPtr, UINT mask, TVITEMW *tvItem, TREEVIEW_ITEM *item)
Definition: treeview.c:540
static BOOL TREEVIEW_SendRealNotify(const TREEVIEW_INFO *infoPtr, UINT code, NMHDR *hdr)
Definition: treeview.c:521
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TVIF_HANDLE
Definition: commctrl.h:3270
#define TVIF_PARAM
Definition: commctrl.h:3268
TVITEMW item
Definition: commctrl.h:3672
LPWSTR pszText
Definition: commctrl.h:3320
int ret

Referenced by TREEVIEW_EditLabel().

◆ TREEVIEW_BuildChildDPA()

static HDPA TREEVIEW_BuildChildDPA ( const TREEVIEW_ITEM item)
static

Definition at line 3147 of file treeview.c.

3148{
3150
3151 HDPA list = DPA_Create(8);
3152 if (list == 0) return NULL;
3153
3154 for (child = item->firstChild; child != NULL; child = child->nextSibling)
3155 {
3156 if (DPA_InsertPtr(list, INT_MAX, child) == -1)
3157 {
3159 return NULL;
3160 }
3161 }
3162
3163 return list;
3164}
Definition: list.h:37
BOOL WINAPI DPA_Destroy(HDPA hdpa)
Definition: dpa.c:396
HDPA WINAPI DPA_Create(INT nGrow)
Definition: dpa.c:950
static HWND child
Definition: cursoricon.c:298
static ATOM item
Definition: dde.c:856
#define list
Definition: rosglue.h:35
Definition: dpa.c:49

Referenced by TREEVIEW_Sort().

◆ TREEVIEW_CallBackCompare()

static INT WINAPI TREEVIEW_CallBackCompare ( const TREEVIEW_ITEM first,
const TREEVIEW_ITEM second,
const TVSORTCB pCallBackSort 
)
static

Definition at line 3102 of file treeview.c.

3104{
3105 /* Forward the call to the client-defined callback */
3106 return pCallBackSort->lpfnCompare(first->lParam,
3107 second->lParam,
3108 pCallBackSort->lParam);
3109}
const GLint * first
Definition: glext.h:5794
LPARAM lParam
Definition: treeview.c:155
LPARAM lParam
Definition: commctrl.h:3616
PFNTVCOMPARE lpfnCompare
Definition: commctrl.h:3615

Referenced by TREEVIEW_Sort().

◆ TREEVIEW_Collapse()

static BOOL TREEVIEW_Collapse ( TREEVIEW_INFO infoPtr,
TREEVIEW_ITEM item,
BOOL  bRemoveChildren,
BOOL  bUser 
)
static

Definition at line 3341 of file treeview.c.

3343{
3344 UINT action = TVE_COLLAPSE | (bRemoveChildren ? TVE_COLLAPSERESET : 0);
3345 BOOL bSetSelection, bSetFirstVisible;
3346 RECT scrollRect;
3347 LONG scrollDist = 0;
3348 TREEVIEW_ITEM *nextItem = NULL, *tmpItem;
3349 BOOL wasExpanded;
3350
3351 TRACE("TVE_COLLAPSE %p %s\n", item, TREEVIEW_ItemName(item));
3352
3353 if (!TREEVIEW_HasChildren(infoPtr, item))
3354 return FALSE;
3355
3356 if (bUser)
3358
3359 if (item->firstChild == NULL)
3360 return FALSE;
3361
3362 wasExpanded = (item->state & TVIS_EXPANDED) != 0;
3363 item->state &= ~TVIS_EXPANDED;
3364
3365 if (wasExpanded && bUser)
3367
3368 bSetSelection = (infoPtr->selectedItem != NULL
3369 && TREEVIEW_IsChildOf(item, infoPtr->selectedItem));
3370
3371 bSetFirstVisible = (infoPtr->firstVisible != NULL
3372 && TREEVIEW_IsChildOf(item, infoPtr->firstVisible));
3373
3374 tmpItem = item;
3375 while (tmpItem)
3376 {
3377 if (tmpItem->nextSibling)
3378 {
3379 nextItem = tmpItem->nextSibling;
3380 break;
3381 }
3382 tmpItem = tmpItem->parent;
3383 }
3384
3385 if (nextItem)
3386 scrollDist = nextItem->rect.top;
3387
3388 if (bRemoveChildren)
3389 {
3390 INT old_cChildren = item->cChildren;
3391 TRACE("TVE_COLLAPSERESET\n");
3392 item->state &= ~TVIS_EXPANDEDONCE;
3394 item->cChildren = old_cChildren;
3395 }
3396 if (!wasExpanded)
3397 return FALSE;
3398
3399 if (item->firstChild)
3400 {
3401 TREEVIEW_ITEM *i, *sibling;
3402
3403 sibling = TREEVIEW_GetNextListItem(infoPtr, item);
3404
3405 for (i = item->firstChild; i != sibling;
3406 i = TREEVIEW_GetNextListItem(infoPtr, i))
3407 {
3408 i->visibleOrder = -1;
3409 }
3410 }
3411
3413
3414 if (nextItem)
3415 scrollDist = -(scrollDist - nextItem->rect.top);
3416
3417 if (bSetSelection)
3418 {
3419 /* Don't call DoSelectItem, it sends notifications. */
3420 if (TREEVIEW_ValidItem(infoPtr, infoPtr->selectedItem))
3421 infoPtr->selectedItem->state &= ~TVIS_SELECTED;
3422 item->state |= TVIS_SELECTED;
3423 infoPtr->selectedItem = item;
3424 }
3425
3427
3428 scrollRect.left = 0;
3429 scrollRect.right = infoPtr->clientWidth;
3430 scrollRect.bottom = infoPtr->clientHeight;
3431
3432 if (nextItem)
3433 {
3434 scrollRect.top = nextItem->rect.top;
3435
3436 ScrollWindowEx (infoPtr->hwnd, 0, scrollDist, &scrollRect, &scrollRect,
3438 TREEVIEW_Invalidate(infoPtr, item);
3439 } else {
3440 scrollRect.top = item->rect.top;
3441 InvalidateRect(infoPtr->hwnd, &scrollRect, TRUE);
3442 }
3443
3445 bSetFirstVisible ? item : infoPtr->firstVisible,
3446 TRUE);
3447
3448 return wasExpanded;
3449}
static VOID TREEVIEW_Invalidate(const TREEVIEW_INFO *, const TREEVIEW_ITEM *)
Definition: treeview.c:2968
static void TREEVIEW_RecalculateVisibleOrder(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *start)
Definition: treeview.c:929
static VOID TREEVIEW_UpdateScrollBars(TREEVIEW_INFO *infoPtr)
Definition: treeview.c:2756
static void TREEVIEW_RemoveAllChildren(TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *parentItem)
Definition: treeview.c:1440
static VOID TREEVIEW_SendExpanded(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, UINT action)
Definition: treeview.c:3328
static TREEVIEW_ITEM * TREEVIEW_GetNextListItem(const TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *tvItem)
Definition: treeview.c:427
static const char * TREEVIEW_ItemName(const TREEVIEW_ITEM *item)
Definition: treeview.c:336
static BOOL TREEVIEW_ValidItem(const TREEVIEW_INFO *infoPtr, HTREEITEM handle)
Definition: treeview.c:282
static VOID TREEVIEW_SetFirstVisible(TREEVIEW_INFO *, TREEVIEW_ITEM *, BOOL)
Definition: treeview.c:4836
static BOOL TREEVIEW_HasChildren(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
Definition: treeview.c:834
static BOOL TREEVIEW_SendExpanding(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, UINT action)
Definition: treeview.c:3318
static BOOL TREEVIEW_IsChildOf(const TREEVIEW_ITEM *parent, const TREEVIEW_ITEM *child)
Definition: treeview.c:346
const WCHAR * action
Definition: action.c:7479
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
long LONG
Definition: pedump.c:60
#define TVE_COLLAPSERESET
Definition: commctrl.h:3426
#define TVIS_SELECTED
Definition: commctrl.h:3280
#define TVE_COLLAPSE
Definition: commctrl.h:3422
#define TVIS_EXPANDED
Definition: commctrl.h:3284
#define TRACE(s)
Definition: solgame.cpp:4
RECT rect
Definition: treeview.c:160
HTREEITEM parent
Definition: treeview.c:142
HTREEITEM nextSibling
Definition: treeview.c:143
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
HTREEITEM selectedItem
Definition: treeview.c:95
LONG clientHeight
Definition: treeview.c:89
HTREEITEM firstVisible
Definition: treeview.c:100
LONG clientWidth
Definition: treeview.c:88
int32_t INT
Definition: typedefs.h:58
#define SW_INVALIDATE
Definition: winuser.h:2579
#define SW_ERASE
Definition: winuser.h:2580
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)

Referenced by TREEVIEW_ExpandMsg(), TREEVIEW_KeyDown(), TREEVIEW_SingleExpand(), and TREEVIEW_Toggle().

◆ TREEVIEW_Command()

static LRESULT TREEVIEW_Command ( TREEVIEW_INFO infoPtr,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 3829 of file treeview.c.

3830{
3831 TRACE("code=0x%x, id=0x%x, handle=0x%lx\n", HIWORD(wParam), LOWORD(wParam), lParam);
3832
3833 switch (HIWORD(wParam))
3834 {
3835 case EN_UPDATE:
3836 {
3837 /*
3838 * Adjust the edit window size
3839 */
3840 WCHAR buffer[1024];
3841 TREEVIEW_ITEM *editItem = infoPtr->editItem;
3842 HDC hdc = GetDC(infoPtr->hwndEdit);
3843 SIZE sz;
3844 HFONT hFont, hOldFont = 0;
3845
3846 TRACE("edit=%p\n", infoPtr->hwndEdit);
3847
3848 if (!IsWindow(infoPtr->hwndEdit) || !hdc) return FALSE;
3849
3850 infoPtr->bLabelChanged = TRUE;
3851
3853
3854 /* Select font to get the right dimension of the string */
3855 hFont = (HFONT)SendMessageW(infoPtr->hwndEdit, WM_GETFONT, 0, 0);
3856
3857 if (hFont != 0)
3858 {
3859 hOldFont = SelectObject(hdc, hFont);
3860 }
3861
3863 {
3864 TEXTMETRICW textMetric;
3865
3866 /* Add Extra spacing for the next character */
3867 GetTextMetricsW(hdc, &textMetric);
3868 sz.cx += (textMetric.tmMaxCharWidth * 2);
3869
3870 sz.cx = max(sz.cx, textMetric.tmMaxCharWidth * 3);
3871 sz.cx = min(sz.cx,
3872 infoPtr->clientWidth - editItem->textOffset + 2);
3873
3874 SetWindowPos(infoPtr->hwndEdit,
3875 HWND_TOP,
3876 0,
3877 0,
3878 sz.cx,
3879 editItem->rect.bottom - editItem->rect.top + 3,
3881 }
3882
3883 if (hFont != 0)
3884 {
3885 SelectObject(hdc, hOldFont);
3886 }
3887
3888 ReleaseDC(infoPtr->hwnd, hdc);
3889 break;
3890 }
3891 case EN_KILLFOCUS:
3892 /* apparently we should respect passed handle value */
3893 if (infoPtr->hwndEdit != (HWND)lParam) return FALSE;
3894
3896 break;
3897
3898 default:
3899 return SendMessageW(infoPtr->hwndNotify, WM_COMMAND, wParam, lParam);
3900 }
3901
3902 return 0;
3903}
HFONT hFont
Definition: main.c:53
#define ARRAY_SIZE(A)
Definition: main.h:33
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static LRESULT TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel)
Definition: treeview.c:4008
GLuint buffer
Definition: glext.h:5915
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define min(a, b)
Definition: monoChain.cc:55
#define LOWORD(l)
Definition: pedump.c:82
#define strlenW(s)
Definition: unicode.h:34
LONG cx
Definition: kdterminal.h:27
LONG textOffset
Definition: treeview.c:164
LONG tmMaxCharWidth
Definition: wingdi.h:2389
HTREEITEM editItem
Definition: treeview.c:98
BOOL bLabelChanged
Definition: treeview.c:123
#define max(a, b)
Definition: svc.c:63
#define HIWORD(l)
Definition: typedefs.h:247
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1384
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define EN_KILLFOCUS
Definition: winuser.h:2025
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define EN_UPDATE
Definition: winuser.h:2028
#define SWP_DRAWFRAME
Definition: winuser.h:1239
#define SWP_NOMOVE
Definition: winuser.h:1244
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_GETFONT
Definition: winuser.h:1651
#define HWND_TOP
Definition: winuser.h:1207
HDC WINAPI GetDC(_In_opt_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_ComputeItemInternalMetrics()

static VOID TREEVIEW_ComputeItemInternalMetrics ( const TREEVIEW_INFO infoPtr,
TREEVIEW_ITEM item 
)
static

Definition at line 866 of file treeview.c.

867{
868 /* has TVS_LINESATROOT and (TVS_HASLINES|TVS_HASBUTTONS) */
871
872 item->linesOffset = infoPtr->uIndent * (lar ? item->iLevel : item->iLevel - 1)
873 - infoPtr->scrollX;
874 item->stateOffset = item->linesOffset + infoPtr->uIndent;
875 item->imageOffset = item->stateOffset
876 + (STATEIMAGEINDEX(item->state) ? infoPtr->stateImageWidth : 0);
877 item->textOffset = item->imageOffset + infoPtr->normalImageWidth;
878}
#define STATEIMAGEINDEX(x)
Definition: treeview.c:198
#define TVS_LINESATROOT
Definition: commctrl.h:3249
#define TVS_HASLINES
Definition: commctrl.h:3248
#define TVS_HASBUTTONS
Definition: commctrl.h:3247
int normalImageWidth
Definition: treeview.c:128

Referenced by TREEVIEW_InsertItemT(), TREEVIEW_RecalculateVisibleOrder(), TREEVIEW_SetItemT(), and TREEVIEW_UpdateSubTree().

◆ TREEVIEW_ComputeItemRect()

static VOID TREEVIEW_ComputeItemRect ( const TREEVIEW_INFO infoPtr,
TREEVIEW_ITEM item 
)
static

Definition at line 915 of file treeview.c.

916{
917 item->rect.top = infoPtr->uItemHeight *
918 (item->visibleOrder - infoPtr->firstVisible->visibleOrder);
919
920 item->rect.bottom = item->rect.top
921 + infoPtr->uItemHeight * item->iIntegral - 1;
922
923 item->rect.left = 0;
924 item->rect.right = infoPtr->clientWidth;
925}
LONG visibleOrder
Definition: treeview.c:166
UINT uItemHeight
Definition: treeview.c:85

Referenced by TREEVIEW_RecalculateVisibleOrder().

◆ TREEVIEW_ComputeTextWidth()

static VOID TREEVIEW_ComputeTextWidth ( const TREEVIEW_INFO infoPtr,
TREEVIEW_ITEM item,
HDC  hDC 
)
static

Definition at line 881 of file treeview.c.

882{
883 HDC hdc;
884 HFONT hOldFont=0;
885 SIZE sz;
886
887 /* DRAW's OM docker creates items like this */
888 if (item->pszText == NULL)
889 {
890 item->textWidth = 0;
891 return;
892 }
893
894 if (hDC != 0)
895 {
896 hdc = hDC;
897 }
898 else
899 {
900 hdc = GetDC(infoPtr->hwnd);
901 hOldFont = SelectObject(hdc, TREEVIEW_FontForItem(infoPtr, item));
902 }
903
904 GetTextExtentPoint32W(hdc, item->pszText, strlenW(item->pszText), &sz);
905 item->textWidth = sz.cx;
906
907 if (hDC == 0)
908 {
909 SelectObject(hdc, hOldFont);
910 ReleaseDC(0, hdc);
911 }
912}
static HDC hDC
Definition: 3dtext.c:33
static HFONT TREEVIEW_FontForItem(const TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *item)
Definition: treeview.c:325

Referenced by TREEVIEW_DrawItem(), TREEVIEW_EndEditLabelNow(), TREEVIEW_GetItemRect(), TREEVIEW_HitTest(), TREEVIEW_InsertItemT(), TREEVIEW_SetItemT(), and TREEVIEW_UpdateSubTree().

◆ TREEVIEW_CountChildren()

static INT TREEVIEW_CountChildren ( const TREEVIEW_ITEM item)
static

Definition at line 3133 of file treeview.c.

3134{
3135 INT cChildren = 0;
3136 HTREEITEM hti;
3137
3138 for (hti = item->firstChild; hti != NULL; hti = hti->nextSibling)
3139 cChildren++;
3140
3141 return cChildren;
3142}

Referenced by TREEVIEW_Sort().

◆ TREEVIEW_Create()

static LRESULT TREEVIEW_Create ( HWND  hwnd,
const CREATESTRUCTW lpcs 
)
static

Definition at line 5092 of file treeview.c.

5093{
5094 RECT rcClient;
5095 TREEVIEW_INFO *infoPtr;
5096 LOGFONTW lf;
5097
5098 TRACE("wnd %p, style 0x%x\n", hwnd, GetWindowLongW(hwnd, GWL_STYLE));
5099
5100 infoPtr = heap_alloc_zero(sizeof(TREEVIEW_INFO));
5101
5102 if (infoPtr == NULL)
5103 {
5104 ERR("could not allocate info memory!\n");
5105 return 0;
5106 }
5107
5108 SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)infoPtr);
5109
5110 infoPtr->hwnd = hwnd;
5111 infoPtr->dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
5112 infoPtr->Timer = 0;
5113 infoPtr->uNumItems = 0;
5114 infoPtr->cdmode = 0;
5115 infoPtr->uScrollTime = 300; /* milliseconds */
5116 infoPtr->bRedraw = TRUE;
5117
5118 GetClientRect(hwnd, &rcClient);
5119
5120 /* No scroll bars yet. */
5121 infoPtr->clientWidth = rcClient.right;
5122 infoPtr->clientHeight = rcClient.bottom;
5123 infoPtr->uInternalStatus = 0;
5124
5125 infoPtr->treeWidth = 0;
5126 infoPtr->treeHeight = 0;
5127
5128 infoPtr->uIndent = MINIMUM_INDENT;
5129 infoPtr->selectedItem = NULL;
5130 infoPtr->focusedItem = NULL;
5131 infoPtr->hotItem = NULL;
5132 infoPtr->editItem = NULL;
5133 infoPtr->firstVisible = NULL;
5134 infoPtr->maxVisibleOrder = 0;
5135 infoPtr->dropItem = NULL;
5136 infoPtr->insertMarkItem = NULL;
5137 infoPtr->insertBeforeorAfter = 0;
5138 /* dragList */
5139
5140 infoPtr->scrollX = 0;
5141 infoPtr->wheelRemainder = 0;
5142
5143 infoPtr->clrBk = CLR_NONE; /* use system color */
5144 infoPtr->clrText = CLR_NONE; /* use system color */
5145 infoPtr->clrLine = CLR_DEFAULT;
5146 infoPtr->clrInsertMark = CLR_DEFAULT;
5147
5148 /* hwndToolTip */
5149
5150 infoPtr->hwndEdit = NULL;
5151 infoPtr->wpEditOrig = NULL;
5152 infoPtr->bIgnoreEditKillFocus = FALSE;
5153 infoPtr->bLabelChanged = FALSE;
5154
5155 infoPtr->himlNormal = NULL;
5156 infoPtr->himlState = NULL;
5157 infoPtr->normalImageWidth = 0;
5158 infoPtr->normalImageHeight = 0;
5159 infoPtr->stateImageWidth = 0;
5160 infoPtr->stateImageHeight = 0;
5161
5162 infoPtr->items = DPA_Create(16);
5163
5165 infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectW(&lf);
5166 infoPtr->hBoldFont = TREEVIEW_CreateBoldFont(infoPtr->hFont);
5169 infoPtr->hcurHand = LoadCursorW(NULL, (LPWSTR)IDC_HAND);
5170
5171 infoPtr->uItemHeight = TREEVIEW_NaturalHeight(infoPtr);
5172
5173 infoPtr->root = TREEVIEW_AllocateItem(infoPtr);
5174 infoPtr->root->state = TVIS_EXPANDED;
5175 infoPtr->root->iLevel = -1;
5176 infoPtr->root->visibleOrder = -1;
5177
5178 infoPtr->hwndNotify = lpcs->hwndParent;
5179 infoPtr->hwndToolTip = 0;
5180
5181 /* Determine what type of notify should be issued (sets infoPtr->bNtfUnicode) */
5182 TREEVIEW_NotifyFormat(infoPtr, infoPtr->hwndNotify, NF_REQUERY);
5183
5184 if (!(infoPtr->dwStyle & TVS_NOTOOLTIPS))
5187 hwnd, 0, 0, 0);
5188
5189 /* Make sure actual scrollbar state is consistent with uInternalStatus */
5192
5194
5195 return 0;
5196}
#define ERR(fmt,...)
Definition: precomp.h:57
static UINT TREEVIEW_NaturalHeight(const TREEVIEW_INFO *infoPtr)
Definition: treeview.c:1734
#define MINIMUM_INDENT
Definition: treeview.c:194
static HFONT TREEVIEW_CreateUnderlineFont(HFONT hOrigFont)
Definition: treeview.c:304
static INT TREEVIEW_NotifyFormat(TREEVIEW_INFO *infoPtr, HWND hwndFrom, UINT nCommand)
Definition: treeview.c:842
static const WCHAR themeClass[]
Definition: treeview.c:207
static TREEVIEW_ITEM * TREEVIEW_AllocateItem(const TREEVIEW_INFO *infoPtr)
Definition: treeview.c:1003
static HFONT TREEVIEW_CreateBoldFont(HFONT hOrigFont)
Definition: treeview.c:294
static HFONT TREEVIEW_CreateBoldUnderlineFont(HFONT hfont)
Definition: treeview.c:314
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
Definition: system.c:835
#define WS_POPUP
Definition: pedump.c:616
#define CLR_NONE
Definition: commctrl.h:319
#define TOOLTIPS_CLASSW
Definition: commctrl.h:1707
#define CLR_DEFAULT
Definition: commctrl.h:320
#define TVS_NOTOOLTIPS
Definition: commctrl.h:3254
int iLevel
Definition: treeview.c:157
LONG maxVisibleOrder
Definition: treeview.c:101
BOOL bIgnoreEditKillFocus
Definition: treeview.c:122
HTREEITEM focusedItem
Definition: treeview.c:97
HIMAGELIST himlState
Definition: treeview.c:129
HCURSOR hcurHand
Definition: treeview.c:117
UINT uScrollTime
Definition: treeview.c:82
HTREEITEM hotItem
Definition: treeview.c:96
COLORREF clrInsertMark
Definition: treeview.c:111
COLORREF clrText
Definition: treeview.c:109
BOOL insertBeforeorAfter
Definition: treeview.c:104
COLORREF clrBk
Definition: treeview.c:108
HFONT hBoldUnderlineFont
Definition: treeview.c:116
HTREEITEM root
Definition: treeview.c:77
HFONT hUnderlineFont
Definition: treeview.c:115
HIMAGELIST himlNormal
Definition: treeview.c:126
int stateImageHeight
Definition: treeview.c:130
WNDPROC wpEditOrig
Definition: treeview.c:121
HFONT hDefaultFont
Definition: treeview.c:113
UINT uInternalStatus
Definition: treeview.c:78
COLORREF clrLine
Definition: treeview.c:110
HTREEITEM dropItem
Definition: treeview.c:102
int normalImageHeight
Definition: treeview.c:127
HTREEITEM insertMarkItem
Definition: treeview.c:103
uint32_t DWORD_PTR
Definition: typedefs.h:65
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
#define SB_VERT
Definition: winuser.h:553
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define SPI_GETICONTITLELOGFONT
Definition: winuser.h:1380
#define NF_REQUERY
Definition: winuser.h:2461
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2149
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define CW_USEDEFAULT
Definition: winuser.h:225
#define IDC_HAND
Definition: winuser.h:698
BOOL WINAPI ShowScrollBar(_In_ HWND, _In_ int, _In_ BOOL)
#define SetWindowLongPtrW
Definition: winuser.h:5355
#define GWL_STYLE
Definition: winuser.h:852
#define SB_HORZ
Definition: winuser.h:552
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_CreateBoldFont()

static HFONT TREEVIEW_CreateBoldFont ( HFONT  hOrigFont)
static

Definition at line 294 of file treeview.c.

295{
297
298 GetObjectW(hOrigFont, sizeof(font), &font);
299 font.lfWeight = FW_BOLD;
300 return CreateFontIndirectW(&font);
301}
Definition: mk_font.cpp:20
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define FW_BOLD
Definition: wingdi.h:378

Referenced by TREEVIEW_Create(), and TREEVIEW_SetFont().

◆ TREEVIEW_CreateBoldUnderlineFont()

static HFONT TREEVIEW_CreateBoldUnderlineFont ( HFONT  hfont)
static

Definition at line 314 of file treeview.c.

315{
317
318 GetObjectW(hfont, sizeof(font), &font);
319 font.lfWeight = FW_BOLD;
320 font.lfUnderline = TRUE;
321 return CreateFontIndirectW(&font);
322}
static HFONT hfont

Referenced by TREEVIEW_Create(), and TREEVIEW_SetFont().

◆ TREEVIEW_CreateDragImage()

static LRESULT TREEVIEW_CreateDragImage ( TREEVIEW_INFO infoPtr,
LPARAM  lParam 
)
static

Definition at line 4406 of file treeview.c.

4407{
4408 TREEVIEW_ITEM *dragItem = (HTREEITEM)lParam;
4409 INT cx, cy;
4410 HDC hdc, htopdc;
4411 HWND hwtop;
4412 HBITMAP hbmp, hOldbmp;
4413 SIZE size;
4414 RECT rc;
4415 HFONT hOldFont;
4416
4417 TRACE("\n");
4418
4419 if (!(infoPtr->himlNormal))
4420 return 0;
4421
4422 if (!dragItem || !TREEVIEW_ValidItem(infoPtr, dragItem))
4423 return 0;
4424
4425 TREEVIEW_UpdateDispInfo(infoPtr, dragItem, TVIF_TEXT);
4426
4427 hwtop = GetDesktopWindow();
4428 htopdc = GetDC(hwtop);
4429 hdc = CreateCompatibleDC(htopdc);
4430
4431 hOldFont = SelectObject(hdc, infoPtr->hFont);
4432
4433 if (dragItem->pszText)
4434 GetTextExtentPoint32W(hdc, dragItem->pszText, strlenW(dragItem->pszText),
4435 &size);
4436 else
4437 GetTextExtentPoint32A(hdc, "", 0, &size);
4438
4439 TRACE("%d %d %s\n", size.cx, size.cy, debugstr_w(dragItem->pszText));
4440 hbmp = CreateCompatibleBitmap(htopdc, size.cx, size.cy);
4441 hOldbmp = SelectObject(hdc, hbmp);
4442
4443 ImageList_GetIconSize(infoPtr->himlNormal, &cx, &cy);
4444 size.cx += cx;
4445 if (cy > size.cy)
4446 size.cy = cy;
4447
4448 infoPtr->dragList = ImageList_Create(size.cx, size.cy, ILC_COLOR, 10, 10);
4449 ImageList_Draw(infoPtr->himlNormal, dragItem->iImage, hdc, 0, 0,
4450 ILD_NORMAL);
4451
4452/*
4453 ImageList_GetImageInfo (infoPtr->himlNormal, dragItem->hItem, &iminfo);
4454 ImageList_AddMasked (infoPtr->dragList, iminfo.hbmImage, CLR_DEFAULT);
4455*/
4456
4457/* draw item text */
4458
4459 SetRect(&rc, cx, 0, size.cx, size.cy);
4460
4461 if (dragItem->pszText)
4462 DrawTextW(hdc, dragItem->pszText, strlenW(dragItem->pszText), &rc,
4463 DT_LEFT);
4464
4465 SelectObject(hdc, hOldFont);
4466 SelectObject(hdc, hOldbmp);
4467
4468 ImageList_Add(infoPtr->dragList, hbmp, 0);
4469
4470 DeleteDC(hdc);
4472 ReleaseDC(hwtop, htopdc);
4473
4474 return (LRESULT)infoPtr->dragList;
4475}
HBITMAP hbmp
BOOL WINAPI ImageList_Draw(HIMAGELIST himl, INT i, HDC hdc, INT x, INT y, UINT fStyle)
Definition: imagelist.c:1228
INT WINAPI ImageList_Add(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
Definition: imagelist.c:448
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
BOOL WINAPI ImageList_GetIconSize(HIMAGELIST himl, INT *cx, INT *cy)
Definition: imagelist.c:2037
static void TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, UINT mask)
Definition: treeview.c:703
pKey DeleteObject()
GLsizeiptr size
Definition: glext.h:5919
#define debugstr_w
Definition: kernel32.h:32
static HBITMAP
Definition: button.c:44
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
#define ILD_NORMAL
Definition: commctrl.h:417
_Out_opt_ int * cx
Definition: commctrl.h:585
struct _TREEITEM * HTREEITEM
Definition: commctrl.h:3264
#define ILC_COLOR
Definition: commctrl.h:352
HIMAGELIST dragList
Definition: treeview.c:105
LONG_PTR LRESULT
Definition: windef.h:209
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
BOOL WINAPI DeleteDC(_In_ HDC)
BOOL WINAPI GetTextExtentPoint32A(_In_ HDC hdc, _In_reads_(c) LPCSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
#define DT_LEFT
Definition: winuser.h:534
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_CreateUnderlineFont()

static HFONT TREEVIEW_CreateUnderlineFont ( HFONT  hOrigFont)
static

Definition at line 304 of file treeview.c.

305{
307
308 GetObjectW(hOrigFont, sizeof(font), &font);
309 font.lfUnderline = TRUE;
310 return CreateFontIndirectW(&font);
311}

Referenced by TREEVIEW_Create(), and TREEVIEW_SetFont().

◆ TREEVIEW_DeleteItem()

static LRESULT TREEVIEW_DeleteItem ( TREEVIEW_INFO infoPtr,
HTREEITEM  item 
)
static

Definition at line 1517 of file treeview.c.

1518{
1519 TREEVIEW_ITEM *newSelection = NULL;
1520 TREEVIEW_ITEM *newFirstVisible = NULL;
1521 TREEVIEW_ITEM *parent, *prev = NULL;
1522 BOOL visible = FALSE;
1523
1524 if (item == TVI_ROOT || !item)
1525 {
1526 TRACE("TVI_ROOT\n");
1527 parent = infoPtr->root;
1528 newSelection = NULL;
1529 visible = TRUE;
1530 TREEVIEW_RemoveTree(infoPtr);
1531 }
1532 else
1533 {
1534 if (!TREEVIEW_ValidItem(infoPtr, item))
1535 return FALSE;
1536
1537 TRACE("%p (%s)\n", item, TREEVIEW_ItemName(item));
1538 parent = item->parent;
1539
1540 if (ISVISIBLE(item))
1541 {
1542 prev = TREEVIEW_GetPrevListItem(infoPtr, item);
1543 visible = TRUE;
1544 }
1545
1546 if (infoPtr->selectedItem != NULL
1547 && (item == infoPtr->selectedItem
1548 || TREEVIEW_IsChildOf(item, infoPtr->selectedItem)))
1549 {
1550 if (item->nextSibling)
1551 newSelection = item->nextSibling;
1552 else if (item->parent != infoPtr->root)
1553 newSelection = item->parent;
1554 else
1555 newSelection = item->prevSibling;
1556 TRACE("newSelection = %p\n", newSelection);
1557 }
1558
1559 if (infoPtr->firstVisible == item)
1560 {
1561 visible = TRUE;
1562 if (item->nextSibling)
1563 newFirstVisible = item->nextSibling;
1564 else if (item->prevSibling)
1565 newFirstVisible = item->prevSibling;
1566 else if (item->parent != infoPtr->root)
1567 newFirstVisible = item->parent;
1569 }
1570 else
1571 newFirstVisible = infoPtr->firstVisible;
1572
1573 TREEVIEW_RemoveItem(infoPtr, item);
1574 }
1575
1576 /* Don't change if somebody else already has (infoPtr->selectedItem is cleared by FreeItem). */
1577 if (!infoPtr->selectedItem && newSelection)
1578 {
1579 if (TREEVIEW_ValidItem(infoPtr, newSelection))
1580 TREEVIEW_DoSelectItem(infoPtr, TVGN_CARET, newSelection, TVC_UNKNOWN);
1581 }
1582
1583 /* Validate insertMark dropItem.
1584 * hotItem ??? - used for comparison only.
1585 */
1586 if (!TREEVIEW_ValidItem(infoPtr, infoPtr->insertMarkItem))
1587 infoPtr->insertMarkItem = 0;
1588
1589 if (!TREEVIEW_ValidItem(infoPtr, infoPtr->dropItem))
1590 infoPtr->dropItem = 0;
1591
1592 if (!TREEVIEW_ValidItem(infoPtr, newFirstVisible))
1593 newFirstVisible = infoPtr->root->firstChild;
1594
1595 TREEVIEW_VerifyTree(infoPtr);
1596
1597 if (visible)
1598 TREEVIEW_SetFirstVisible(infoPtr, newFirstVisible, TRUE);
1599
1600 if (!infoPtr->bRedraw) return TRUE;
1601
1602 if (visible)
1603 {
1604 TREEVIEW_RecalculateVisibleOrder(infoPtr, prev);
1606 TREEVIEW_Invalidate(infoPtr, NULL);
1607 }
1608 else if (ISVISIBLE(parent) && !TREEVIEW_HasChildren(infoPtr, parent))
1609 {
1610 /* parent lost '+/-' - update it */
1611 TREEVIEW_Invalidate(infoPtr, parent);
1612 }
1613
1614 return TRUE;
1615}
#define ISVISIBLE(x)
Definition: treeview.c:200
static void TREEVIEW_RemoveTree(TREEVIEW_INFO *infoPtr)
Definition: treeview.c:1509
static LRESULT TREEVIEW_DoSelectItem(TREEVIEW_INFO *, INT, HTREEITEM, INT)
Definition: treeview.c:4480
static TREEVIEW_ITEM * TREEVIEW_GetPrevListItem(const TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *tvItem)
Definition: treeview.c:402
static void TREEVIEW_RemoveItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
Definition: treeview.c:1486
static void TREEVIEW_VerifyTree(TREEVIEW_INFO *infoPtr)
Definition: treeview.c:6053
r parent
Definition: btrfs.c:3010
#define TVI_ROOT
Definition: commctrl.h:3368
#define TVC_UNKNOWN
Definition: commctrl.h:3650
#define TVGN_CARET
Definition: commctrl.h:3461
HTREEITEM firstChild
Definition: treeview.c:144

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_Destroy()

static LRESULT TREEVIEW_Destroy ( TREEVIEW_INFO infoPtr)
static

Definition at line 5200 of file treeview.c.

5201{
5202 TRACE("\n");
5203
5204 /* free item data */
5205 TREEVIEW_RemoveTree(infoPtr);
5206 /* root isn't freed with other items */
5207 TREEVIEW_FreeItem(infoPtr, infoPtr->root);
5208 DPA_Destroy(infoPtr->items);
5209
5210 /* Restore original wndproc */
5211 if (infoPtr->hwndEdit)
5213 (DWORD_PTR)infoPtr->wpEditOrig);
5214
5215 CloseThemeData (GetWindowTheme (infoPtr->hwnd));
5216
5217 /* Deassociate treeview from the window before doing anything drastic. */
5218 SetWindowLongPtrW(infoPtr->hwnd, 0, 0);
5219
5220 DeleteObject(infoPtr->hDefaultFont);
5221 DeleteObject(infoPtr->hBoldFont);
5222 DeleteObject(infoPtr->hUnderlineFont);
5224 DestroyWindow(infoPtr->hwndToolTip);
5225 heap_free(infoPtr);
5226
5227 return 0;
5228}
static void TREEVIEW_FreeItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
Definition: treeview.c:1031
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:950
#define GWLP_WNDPROC
Definition: treelist.c:66
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_DoSelectItem()

static LRESULT TREEVIEW_DoSelectItem ( TREEVIEW_INFO infoPtr,
INT  action,
HTREEITEM  newSelect,
INT  cause 
)
static

Definition at line 4480 of file treeview.c.

4482{
4483 TREEVIEW_ITEM *prevSelect;
4484
4485 assert(newSelect == NULL || TREEVIEW_ValidItem(infoPtr, newSelect));
4486
4487 TRACE("Entering item %p (%s), flag 0x%x, cause 0x%x, state 0x%x\n",
4488 newSelect, TREEVIEW_ItemName(newSelect), action, cause,
4489 newSelect ? newSelect->state : 0);
4490
4491 /* reset and redraw focusedItem if focusedItem was set so we don't */
4492 /* have to worry about the previously focused item when we set a new one */
4493 TREEVIEW_InvalidateItem(infoPtr, infoPtr->focusedItem);
4494 infoPtr->focusedItem = NULL;
4495
4496 switch (action)
4497 {
4499 FIXME("TVSI_NOSINGLEEXPAND specified.\n");
4500 /* Fall through */
4501 case TVGN_CARET:
4502 prevSelect = infoPtr->selectedItem;
4503
4504 if (prevSelect == newSelect) {
4505 TREEVIEW_EnsureVisible(infoPtr, infoPtr->selectedItem, FALSE);
4506 break;
4507 }
4508
4509 if (TREEVIEW_SendTreeviewNotify(infoPtr,
4511 cause,
4513 prevSelect,
4514 newSelect))
4515 return FALSE;
4516
4517 if (prevSelect)
4518 prevSelect->state &= ~TVIS_SELECTED;
4519 if (newSelect)
4520 newSelect->state |= TVIS_SELECTED;
4521
4522 infoPtr->selectedItem = newSelect;
4523
4524 TREEVIEW_EnsureVisible(infoPtr, infoPtr->selectedItem, FALSE);
4525
4526 TREEVIEW_InvalidateItem(infoPtr, prevSelect);
4527 TREEVIEW_InvalidateItem(infoPtr, newSelect);
4528
4531 cause,
4533 prevSelect,
4534 newSelect);
4535 break;
4536
4537 case TVGN_DROPHILITE:
4538 prevSelect = infoPtr->dropItem;
4539
4540 if (prevSelect)
4541 prevSelect->state &= ~TVIS_DROPHILITED;
4542
4543 infoPtr->dropItem = newSelect;
4544
4545 if (newSelect)
4546 newSelect->state |= TVIS_DROPHILITED;
4547
4548 TREEVIEW_Invalidate(infoPtr, prevSelect);
4549 TREEVIEW_Invalidate(infoPtr, newSelect);
4550 break;
4551
4552 case TVGN_FIRSTVISIBLE:
4553 if (newSelect != NULL)
4554 {
4555 TREEVIEW_EnsureVisible(infoPtr, newSelect, FALSE);
4556 TREEVIEW_SetFirstVisible(infoPtr, newSelect, TRUE);
4557 TREEVIEW_Invalidate(infoPtr, NULL);
4558 }
4559 break;
4560 }
4561
4562 TRACE("Leaving state 0x%x\n", newSelect ? newSelect->state : 0);
4563 return TRUE;
4564}
#define FIXME(fmt,...)
Definition: precomp.h:53
static LRESULT TREEVIEW_EnsureVisible(TREEVIEW_INFO *, HTREEITEM, BOOL)
Definition: treeview.c:4739
static void TREEVIEW_InvalidateItem(const TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *item)
Definition: treeview.c:2962
static BOOL TREEVIEW_SendTreeviewNotify(const TREEVIEW_INFO *infoPtr, UINT code, UINT action, UINT mask, HTREEITEM oldItem, HTREEITEM newItem)
Definition: treeview.c:573
#define assert(x)
Definition: debug.h:53
#define TVGN_FIRSTVISIBLE
Definition: commctrl.h:3457
#define TVSI_NOSINGLEEXPAND
Definition: commctrl.h:3464
#define TVGN_DROPHILITE
Definition: commctrl.h:3460
#define TVIS_DROPHILITED
Definition: commctrl.h:3282

Referenced by TREEVIEW_DeleteItem(), TREEVIEW_KeyDown(), TREEVIEW_LButtonDown(), TREEVIEW_ProcessLetterKeys(), TREEVIEW_SelectItem(), and TREEVIEW_SetFocus().

◆ TREEVIEW_DoSetItemT()

static BOOL TREEVIEW_DoSetItemT ( const TREEVIEW_INFO infoPtr,
TREEVIEW_ITEM item,
const TVITEMEXW tvItem,
BOOL  isW 
)
static

Definition at line 1117 of file treeview.c.

1119{
1120 UINT callbackClear = 0;
1121 UINT callbackSet = 0;
1122
1123 TRACE("item %p\n", item);
1124 /* Do this first in case it fails. */
1125 if (tvItem->mask & TVIF_TEXT)
1126 {
1127 item->textWidth = 0; /* force width recalculation */
1128 if (tvItem->pszText != LPSTR_TEXTCALLBACKW && tvItem->pszText != NULL) /* covers != TEXTCALLBACKA too, and undocumented: pszText of NULL also means TEXTCALLBACK */
1129 {
1130 int len;
1131 LPWSTR newText;
1132 if (isW)
1133 len = lstrlenW(tvItem->pszText) + 1;
1134 else
1135 len = MultiByteToWideChar(CP_ACP, 0, (LPSTR)tvItem->pszText, -1, NULL, 0);
1136
1137 newText = heap_realloc(item->pszText, len * sizeof(WCHAR));
1138
1139 if (newText == NULL) return FALSE;
1140
1141 callbackClear |= TVIF_TEXT;
1142
1143 item->pszText = newText;
1144 item->cchTextMax = len;
1145 if (isW)
1146 lstrcpynW(item->pszText, tvItem->pszText, len);
1147 else
1148 MultiByteToWideChar(CP_ACP, 0, (LPSTR)tvItem->pszText, -1,
1149 item->pszText, len);
1150
1151 TRACE("setting text %s, item %p\n", debugstr_w(item->pszText), item);
1152 }
1153 else
1154 {
1155 callbackSet |= TVIF_TEXT;
1156 item->pszText = heap_realloc(item->pszText, TEXT_CALLBACK_SIZE * sizeof(WCHAR));
1157 item->cchTextMax = TEXT_CALLBACK_SIZE;
1158 TRACE("setting callback, item %p\n", item);
1159 }
1160 }
1161
1162 if (tvItem->mask & TVIF_CHILDREN)
1163 {
1164 item->cChildren = tvItem->cChildren;
1165
1166 if (item->cChildren == I_CHILDRENCALLBACK)
1167 callbackSet |= TVIF_CHILDREN;
1168 else
1169 callbackClear |= TVIF_CHILDREN;
1170 }
1171
1172 if (tvItem->mask & TVIF_IMAGE)
1173 {
1174 item->iImage = tvItem->iImage;
1175
1176 if (item->iImage == I_IMAGECALLBACK)
1177 callbackSet |= TVIF_IMAGE;
1178 else
1179 callbackClear |= TVIF_IMAGE;
1180 }
1181
1182 if (tvItem->mask & TVIF_SELECTEDIMAGE)
1183 {
1184 item->iSelectedImage = tvItem->iSelectedImage;
1185
1186 if (item->iSelectedImage == I_IMAGECALLBACK)
1187 callbackSet |= TVIF_SELECTEDIMAGE;
1188 else
1189 callbackClear |= TVIF_SELECTEDIMAGE;
1190 }
1191
1192 if (tvItem->mask & TVIF_EXPANDEDIMAGE)
1193 {
1194 item->iExpandedImage = tvItem->iExpandedImage;
1195
1196 if (item->iExpandedImage == I_IMAGECALLBACK)
1197 callbackSet |= TVIF_EXPANDEDIMAGE;
1198 else
1199 callbackClear |= TVIF_EXPANDEDIMAGE;
1200 }
1201
1202 if (tvItem->mask & TVIF_PARAM)
1203 item->lParam = tvItem->lParam;
1204
1205 /* If the application sets TVIF_INTEGRAL without
1206 * supplying a TVITEMEX structure, it's toast. */
1207 if (tvItem->mask & TVIF_INTEGRAL)
1208 item->iIntegral = tvItem->iIntegral;
1209
1210 if (tvItem->mask & TVIF_STATE)
1211 {
1212 TRACE("prevstate 0x%x, state 0x%x, mask 0x%x\n", item->state, tvItem->state,
1213 tvItem->stateMask);
1214 item->state &= ~tvItem->stateMask;
1215 item->state |= (tvItem->state & tvItem->stateMask);
1216 }
1217
1218 if (tvItem->mask & TVIF_STATEEX)
1219 {
1220 FIXME("New extended state: 0x%x\n", tvItem->uStateEx);
1221 }
1222
1223 item->callbackMask |= callbackSet;
1224 item->callbackMask &= ~callbackClear;
1225
1226 return TRUE;
1227}
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
#define TEXT_CALLBACK_SIZE
Definition: treeview.c:190
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
GLenum GLsizei len
Definition: glext.h:6722
#define I_CHILDRENCALLBACK
Definition: commctrl.h:3293
LPARAM lParam
Definition: commctrl.h:3355
int iExpandedImage
Definition: commctrl.h:3359
int iSelectedImage
Definition: commctrl.h:3353
LPWSTR pszText
Definition: commctrl.h:3350
UINT uStateEx
Definition: commctrl.h:3357
static const WCHAR isW[]
Definition: lex.c:62
char * LPSTR
Definition: xmlstorage.h:182

Referenced by TREEVIEW_InsertItemT(), and TREEVIEW_SetItemT().

◆ TREEVIEW_DrawItem()

static void TREEVIEW_DrawItem ( const TREEVIEW_INFO infoPtr,
HDC  hdc,
TREEVIEW_ITEM item 
)
static

Definition at line 2525 of file treeview.c.

2526{
2527 INT cditem;
2528 HFONT hOldFont;
2529 COLORREF oldTextColor, oldTextBkColor;
2530 int centery;
2531 BOOL inFocus = (GetFocus() == infoPtr->hwnd);
2532 NMTVCUSTOMDRAW nmcdhdr;
2533
2535
2536 /* - If item is drop target or it is selected and window is in focus -
2537 * use blue background (COLOR_HIGHLIGHT).
2538 * - If item is selected, window is not in focus, but it has style
2539 * TVS_SHOWSELALWAYS - use grey background (COLOR_BTNFACE)
2540 * - Otherwise - use background color
2541 */
2542 if ((item->state & TVIS_DROPHILITED) || ((item == infoPtr->focusedItem) && !(item->state & TVIS_SELECTED)) ||
2543 ((item->state & TVIS_SELECTED) && (!infoPtr->focusedItem || item == infoPtr->focusedItem) &&
2544 (inFocus || (infoPtr->dwStyle & TVS_SHOWSELALWAYS))))
2545 {
2546 if ((item->state & TVIS_DROPHILITED) || inFocus)
2547 {
2550 }
2551 else
2552 {
2554 nmcdhdr.clrText = GETTXTCOLOR(infoPtr->clrText);
2555 }
2556 }
2557 else
2558 {
2559 nmcdhdr.clrTextBk = GETBKCOLOR(infoPtr->clrBk);
2560 if ((infoPtr->dwStyle & TVS_TRACKSELECT) && (item == infoPtr->hotItem))
2562 else
2563 nmcdhdr.clrText = GETTXTCOLOR(infoPtr->clrText);
2564 }
2565
2566 hOldFont = SelectObject(hdc, TREEVIEW_FontForItem(infoPtr, item));
2567 oldTextColor = SetTextColor(hdc, nmcdhdr.clrText);
2568 oldTextBkColor = SetBkColor(hdc, nmcdhdr.clrTextBk);
2569
2570 /* The custom draw handler can query the text rectangle,
2571 * so get ready. */
2572 /* should already be known, set to 0 when changed */
2573 if (!item->textWidth)
2575
2576 cditem = 0;
2577
2578 if (infoPtr->cdmode & CDRF_NOTIFYITEMDRAW)
2579 {
2581 (infoPtr, hdc, item, CDDS_ITEMPREPAINT, &nmcdhdr);
2582 TRACE("prepaint:cditem-app returns 0x%x\n", cditem);
2583
2584 if (cditem & CDRF_SKIPDEFAULT)
2585 {
2586 SelectObject(hdc, hOldFont);
2587 return;
2588 }
2589 }
2590
2591 if (cditem & CDRF_NEWFONT)
2593
2594 if (TREEVIEW_IsFullRowSelect(infoPtr))
2595 {
2596 HBRUSH brush = CreateSolidBrush(nmcdhdr.clrTextBk);
2597 FillRect(hdc, &item->rect, brush);
2598 DeleteObject(brush);
2599 }
2600
2601 TREEVIEW_DrawItemLines(infoPtr, hdc, item);
2602
2603 /* reset colors. Custom draw handler can change them */
2604 SetTextColor(hdc, nmcdhdr.clrText);
2605 SetBkColor(hdc, nmcdhdr.clrTextBk);
2606
2607 centery = (item->rect.top + item->rect.bottom) / 2;
2608
2609 /*
2610 * Display the images associated with this item
2611 */
2612 {
2613 INT imageIndex;
2614
2615 /* State images are displayed to the left of the Normal image
2616 * image number is in state; zero should be `display no image'.
2617 */
2618 imageIndex = STATEIMAGEINDEX(item->state);
2619
2620 if (infoPtr->himlState && imageIndex)
2621 {
2622 ImageList_Draw(infoPtr->himlState, imageIndex, hdc,
2623 item->stateOffset,
2624 centery - infoPtr->stateImageHeight / 2,
2625 ILD_NORMAL);
2626 }
2627
2628 /* Now, draw the normal image; can be either selected,
2629 * non-selected or expanded image.
2630 */
2631
2632 if ((item->state & TVIS_SELECTED) && (item->iSelectedImage >= 0))
2633 {
2634 /* The item is currently selected */
2635 imageIndex = item->iSelectedImage;
2636 }
2637 else if ((item->state & TVIS_EXPANDED) && (item->iExpandedImage != (WORD)I_IMAGENONE))
2638 {
2639 /* The item is currently not selected but expanded */
2640 imageIndex = item->iExpandedImage;
2641 }
2642 else
2643 {
2644 /* The item is not selected and not expanded */
2645 imageIndex = item->iImage;
2646 }
2647
2648 if (infoPtr->himlNormal)
2649 {
2651
2652 style |= item->state & TVIS_OVERLAYMASK;
2653
2654 ImageList_DrawEx(infoPtr->himlNormal, imageIndex, hdc,
2655 item->imageOffset, centery - infoPtr->normalImageHeight / 2,
2656 0, 0, infoPtr->clrBk, item->state & TVIS_CUT ? GETBKCOLOR(infoPtr->clrBk) : CLR_DEFAULT,
2657 style);
2658 }
2659 }
2660
2661
2662 /*
2663 * Display the text associated with this item
2664 */
2665
2666 /* Don't paint item's text if it's being edited */
2667 if (!infoPtr->hwndEdit || (infoPtr->selectedItem != item))
2668 {
2669 if (item->pszText)
2670 {
2671 RECT rcText;
2672 UINT align;
2673 SIZE sz;
2674
2675 rcText.top = item->rect.top;
2676 rcText.bottom = item->rect.bottom;
2677 rcText.left = item->textOffset;
2678 rcText.right = rcText.left + item->textWidth + 4;
2679
2680 TRACE("drawing text %s at (%s)\n",
2681 debugstr_w(item->pszText), wine_dbgstr_rect(&rcText));
2682
2683 /* Draw it */
2684 GetTextExtentPoint32W(hdc, item->pszText, strlenW(item->pszText), &sz);
2685
2687 ExtTextOutW(hdc, rcText.left + 2, (rcText.top + rcText.bottom - sz.cy) / 2,
2689 &rcText,
2690 item->pszText,
2691 lstrlenW(item->pszText),
2692 NULL);
2694
2695 /* Draw focus box around the selected item */
2696 if ((item == infoPtr->selectedItem) && inFocus)
2697 {
2698 DrawFocusRect(hdc,&rcText);
2699 }
2700 }
2701 }
2702
2703 /* Draw insertion mark if necessary */
2704
2705 if (infoPtr->insertMarkItem)
2706 TRACE("item:%d,mark:%p\n",
2707 TREEVIEW_GetItemIndex(infoPtr, item),
2708 infoPtr->insertMarkItem);
2709
2710 if (item == infoPtr->insertMarkItem)
2711 {
2712 HPEN hNewPen, hOldPen;
2713 int offset;
2714 int left, right;
2715
2716 hNewPen = CreatePen(PS_SOLID, 2, GETINSCOLOR(infoPtr->clrInsertMark));
2717 hOldPen = SelectObject(hdc, hNewPen);
2718
2719 if (infoPtr->insertBeforeorAfter)
2720 offset = item->rect.bottom - 1;
2721 else
2722 offset = item->rect.top + 1;
2723
2724 left = item->textOffset - 2;
2725 right = item->textOffset + item->textWidth + 2;
2726
2727 MoveToEx(hdc, left, offset - 3, NULL);
2728 LineTo(hdc, left, offset + 4);
2729
2731 LineTo(hdc, right + 1, offset);
2732
2733 MoveToEx(hdc, right, offset + 3, NULL);
2734 LineTo(hdc, right, offset - 4);
2735
2736 SelectObject(hdc, hOldPen);
2737 DeleteObject(hNewPen);
2738 }
2739
2740 /* Restore the hdc state */
2741 SetTextColor(hdc, oldTextColor);
2742 SetBkColor(hdc, oldTextBkColor);
2743 SelectObject(hdc, hOldFont);
2744
2745 if (cditem & CDRF_NOTIFYPOSTPAINT)
2746 {
2748 (infoPtr, hdc, item, CDDS_ITEMPOSTPAINT, &nmcdhdr);
2749 TRACE("postpaint:cditem-app returns 0x%x\n", cditem);
2750 }
2751}
Arabic default style
Definition: afstyles.h:94
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
COMCTL32_SysColor comctl32_color
Definition: commctrl.c:82
BOOL WINAPI ImageList_DrawEx(HIMAGELIST himl, INT i, HDC hdc, INT x, INT y, INT dx, INT dy, COLORREF rgbBk, COLORREF rgbFg, UINT fStyle)
Definition: imagelist.c:1264
static BOOL TREEVIEW_SendCustomDrawItemNotify(const TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item, UINT uItemDrawState, NMTVCUSTOMDRAW *nmcdhdr)
Definition: treeview.c:650
#define CALLBACK_MASK_ALL
Definition: treeview.c:196
static int TREEVIEW_GetItemIndex(const TREEVIEW_INFO *infoPtr, HTREEITEM handle)
Definition: treeview.c:235
#define GETINSCOLOR(x)
Definition: treeview.c:205
static BOOL TREEVIEW_IsFullRowSelect(const TREEVIEW_INFO *infoPtr)
Definition: treeview.c:358
static void TREEVIEW_DrawItemLines(const TREEVIEW_INFO *infoPtr, HDC hdc, const TREEVIEW_ITEM *item)
Definition: treeview.c:2379
static VOID TREEVIEW_ComputeTextWidth(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, HDC hDC)
Definition: treeview.c:881
#define GETBKCOLOR(x)
Definition: treeview.c:203
#define GETTXTCOLOR(x)
Definition: treeview.c:204
int align(int length, int align)
Definition: dsound8.c:36
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
GLintptr offset
Definition: glext.h:5920
#define CDDS_ITEMPOSTPAINT
Definition: commctrl.h:286
#define TVS_TRACKSELECT
Definition: commctrl.h:3256
#define CDDS_ITEMPREPAINT
Definition: commctrl.h:285
#define CDRF_NOTIFYITEMDRAW
Definition: commctrl.h:275
#define TVS_SHOWSELALWAYS
Definition: commctrl.h:3252
#define CDRF_NOTIFYPOSTPAINT
Definition: commctrl.h:274
#define TVIS_CUT
Definition: commctrl.h:3281
#define CDRF_NEWFONT
Definition: commctrl.h:269
#define TVIS_OVERLAYMASK
Definition: commctrl.h:3287
#define CDRF_SKIPDEFAULT
Definition: commctrl.h:270
#define ILD_SELECTED
Definition: commctrl.h:430
COLORREF clrHighlightText
Definition: comctl32.h:170
COLORREF clrBtnFace
Definition: comctl32.h:168
COLORREF clrHighlight
Definition: comctl32.h:169
LONG cy
Definition: kdterminal.h:28
COLORREF clrText
Definition: commctrl.h:3750
COLORREF clrTextBk
Definition: commctrl.h:3751
DWORD COLORREF
Definition: windef.h:300
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
UINT WINAPI SetTextAlign(_In_ HDC, _In_ UINT)
Definition: text.c:883
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define TA_LEFT
Definition: wingdi.h:932
#define ETO_CLIPPED
Definition: wingdi.h:648
BOOL WINAPI ExtTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCWSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
#define ETO_OPAQUE
Definition: wingdi.h:647
#define TA_TOP
Definition: wingdi.h:930
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
#define PS_SOLID
Definition: wingdi.h:586
HWND WINAPI GetFocus(void)
Definition: window.c:1865
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)

Referenced by TREEVIEW_Refresh().

◆ TREEVIEW_DrawItemLines()

static void TREEVIEW_DrawItemLines ( const TREEVIEW_INFO infoPtr,
HDC  hdc,
const TREEVIEW_ITEM item 
)
static

Definition at line 2379 of file treeview.c.

2380{
2381 LONG centerx, centery;
2382 BOOL lar = ((infoPtr->dwStyle
2384 > TVS_LINESATROOT);
2385 HBRUSH hbr, hbrOld;
2386 COLORREF clrBk = GETBKCOLOR(infoPtr->clrBk);
2387
2388 if (!lar && item->iLevel == 0)
2389 return;
2390
2391 hbr = CreateSolidBrush(clrBk);
2392 hbrOld = SelectObject(hdc, hbr);
2393
2394 centerx = (item->linesOffset + item->stateOffset) / 2;
2395 centery = (item->rect.top + item->rect.bottom) / 2;
2396
2397 if (infoPtr->dwStyle & TVS_HASLINES)
2398 {
2399 HPEN hOldPen, hNewPen;
2401 LOGBRUSH lb;
2402
2403 /* Get a dotted grey pen */
2404 lb.lbStyle = BS_SOLID;
2405 lb.lbColor = GETLINECOLOR(infoPtr->clrLine);
2406 hNewPen = ExtCreatePen(PS_COSMETIC|PS_ALTERNATE, 1, &lb, 0, NULL);
2407 hOldPen = SelectObject(hdc, hNewPen);
2408
2409 /* Make sure the center is on a dot (using +2 instead
2410 * of +1 gives us pixel-by-pixel compat with native) */
2411 centery = (centery + 2) & ~1;
2412
2413 MoveToEx(hdc, item->stateOffset, centery, NULL);
2414 LineTo(hdc, centerx - 1, centery);
2415
2416 if (item->prevSibling || item->parent != infoPtr->root)
2417 {
2418 MoveToEx(hdc, centerx, item->rect.top, NULL);
2419 LineTo(hdc, centerx, centery);
2420 }
2421
2422 if (item->nextSibling)
2423 {
2424 MoveToEx(hdc, centerx, centery, NULL);
2425 LineTo(hdc, centerx, item->rect.bottom + 1);
2426 }
2427
2428 /* Draw the line from our parent to its next sibling. */
2429 parent = item->parent;
2430 while (parent != infoPtr->root)
2431 {
2432 int pcenterx = (parent->linesOffset + parent->stateOffset) / 2;
2433
2434 if (parent->nextSibling
2435 /* skip top-levels unless TVS_LINESATROOT */
2436 && parent->stateOffset > parent->linesOffset)
2437 {
2438 MoveToEx(hdc, pcenterx, item->rect.top, NULL);
2439 LineTo(hdc, pcenterx, item->rect.bottom + 1);
2440 }
2441
2442 parent = parent->parent;
2443 }
2444
2445 SelectObject(hdc, hOldPen);
2446 DeleteObject(hNewPen);
2447 }
2448
2449 /*
2450 * Display the (+/-) signs
2451 */
2452
2453 if (infoPtr->dwStyle & TVS_HASBUTTONS)
2454 {
2455 if (item->cChildren)
2456 {
2457 HTHEME theme = GetWindowTheme(infoPtr->hwnd);
2458 if (theme)
2459 {
2460 RECT glyphRect = item->rect;
2461 glyphRect.left = item->linesOffset;
2462 glyphRect.right = item->stateOffset;
2465 &glyphRect, NULL);
2466 }
2467 else
2468 {
2469 LONG height = item->rect.bottom - item->rect.top;
2470 LONG width = item->stateOffset - item->linesOffset;
2471 LONG rectsize = min(height, width) / 4;
2472 /* plussize = ceil(rectsize * 3/4) */
2473 LONG plussize = (rectsize + 1) * 3 / 4;
2474
2475 HPEN new_pen = CreatePen(PS_SOLID, 0, GETLINECOLOR(infoPtr->clrLine));
2476 HPEN old_pen = SelectObject(hdc, new_pen);
2477
2478 Rectangle(hdc, centerx - rectsize - 1, centery - rectsize - 1,
2479 centerx + rectsize + 2, centery + rectsize + 2);
2480
2481 SelectObject(hdc, old_pen);
2482 DeleteObject(new_pen);
2483
2484 /* draw +/- signs with current text color */
2485 new_pen = CreatePen(PS_SOLID, 0, GETTXTCOLOR(infoPtr->clrText));
2486 old_pen = SelectObject(hdc, new_pen);
2487
2488 if (height < 18 || width < 18)
2489 {
2490 MoveToEx(hdc, centerx - plussize + 1, centery, NULL);
2491 LineTo(hdc, centerx + plussize, centery);
2492
2493 if (!(item->state & TVIS_EXPANDED) ||
2494 (item->state & TVIS_EXPANDPARTIAL))
2495 {
2496 MoveToEx(hdc, centerx, centery - plussize + 1, NULL);
2497 LineTo(hdc, centerx, centery + plussize);
2498 }
2499 }
2500 else
2501 {
2502 Rectangle(hdc, centerx - plussize + 1, centery - 1,
2503 centerx + plussize, centery + 2);
2504
2505 if (!(item->state & TVIS_EXPANDED) ||
2506 (item->state & TVIS_EXPANDPARTIAL))
2507 {
2508 Rectangle(hdc, centerx - 1, centery - plussize + 1,
2509 centerx + 2, centery + plussize);
2510 SetPixel(hdc, centerx - 1, centery, clrBk);
2511 SetPixel(hdc, centerx + 1, centery, clrBk);
2512 }
2513 }
2514
2515 SelectObject(hdc, old_pen);
2516 DeleteObject(new_pen);
2517 }
2518 }
2519 }
2520 SelectObject(hdc, hbrOld);
2521 DeleteObject(hbr);
2522}
FORCEINLINE VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: arm.h:55
#define GETLINECOLOR(x)
Definition: treeview.c:202
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
#define TVIS_EXPANDPARTIAL
Definition: commctrl.h:3286
UINT lbStyle
Definition: wingdi.h:1747
COLORREF lbColor
Definition: wingdi.h:1748
#define GLPS_OPENED
Definition: treelist.c:142
#define TVP_GLYPH
Definition: treelist.c:136
#define GLPS_CLOSED
Definition: treelist.c:139
#define PS_ALTERNATE
Definition: wingdi.h:585
HPEN WINAPI ExtCreatePen(_In_ DWORD iPenStyle, _In_ DWORD cWidth, _In_ const LOGBRUSH *plbrush, _In_ DWORD cStyle, _In_reads_opt_(cStyle) const DWORD *pstyle)
#define PS_COSMETIC
Definition: wingdi.h:584
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define BS_SOLID
Definition: wingdi.h:1086

Referenced by TREEVIEW_DrawItem().

◆ TREEVIEW_Edit_SubclassProc()

static LRESULT CALLBACK TREEVIEW_Edit_SubclassProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 3768 of file treeview.c.

3769{
3771 BOOL bCancel = FALSE;
3772 LRESULT rc;
3773
3774 switch (uMsg)
3775 {
3776 case WM_PAINT:
3777 TRACE("WM_PAINT start\n");
3778 rc = CallWindowProcW(infoPtr->wpEditOrig, hwnd, uMsg, wParam,
3779 lParam);
3780 TRACE("WM_PAINT done\n");
3781 return rc;
3782
3783 case WM_KILLFOCUS:
3784 if (infoPtr->bIgnoreEditKillFocus)
3785 return TRUE;
3786 break;
3787
3788 case WM_DESTROY:
3789 {
3790 WNDPROC editProc = infoPtr->wpEditOrig;
3791 infoPtr->wpEditOrig = 0;
3793 return CallWindowProcW(editProc, hwnd, uMsg, wParam, lParam);
3794 }
3795
3796 case WM_GETDLGCODE:
3798
3799 case WM_KEYDOWN:
3800 if (wParam == VK_ESCAPE)
3801 {
3802 bCancel = TRUE;
3803 break;
3804 }
3805 else if (wParam == VK_RETURN)
3806 {
3807 break;
3808 }
3809
3810 /* fall through */
3811 default:
3812 return CallWindowProcW(infoPtr->wpEditOrig, hwnd, uMsg, wParam, lParam);
3813 }
3814
3815 /* Processing TVN_ENDLABELEDIT message could kill the focus */
3816 /* eg. Using a messagebox */
3817
3818 infoPtr->bIgnoreEditKillFocus = TRUE;
3819 TREEVIEW_EndEditLabelNow(infoPtr, bCancel || !infoPtr->bLabelChanged);
3820 infoPtr->bIgnoreEditKillFocus = FALSE;
3821
3822 return 0;
3823}
static TREEVIEW_INFO * TREEVIEW_GetInfoPtr(HWND hwnd)
Definition: treeview.c:228
#define WM_PAINT
Definition: winuser.h:1620
#define DLGC_WANTALLKEYS
Definition: winuser.h:2612
#define VK_RETURN
Definition: winuser.h:2201
#define DLGC_WANTARROWS
Definition: winuser.h:2610
HWND WINAPI GetParent(_In_ HWND)
#define WM_DESTROY
Definition: winuser.h:1609
#define WM_KEYDOWN
Definition: winuser.h:1715
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2906
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define VK_ESCAPE
Definition: winuser.h:2214
#define WM_KILLFOCUS
Definition: winuser.h:1614
#define WM_GETDLGCODE
Definition: winuser.h:1689

Referenced by TREEVIEW_EditLabel().

◆ TREEVIEW_EditLabel()

static HWND TREEVIEW_EditLabel ( TREEVIEW_INFO infoPtr,
HTREEITEM  hItem 
)
static

Definition at line 3906 of file treeview.c.

3907{
3908 HWND hwnd = infoPtr->hwnd;
3909 HWND hwndEdit;
3910 SIZE sz;
3912 HDC hdc;
3913 HFONT hOldFont=0;
3914 TEXTMETRICW textMetric;
3915
3916 TRACE("%p %p\n", hwnd, hItem);
3917 if (!(infoPtr->dwStyle & TVS_EDITLABELS))
3918 return NULL;
3919
3920 if (!TREEVIEW_ValidItem(infoPtr, hItem))
3921 return NULL;
3922
3923 if (infoPtr->hwndEdit)
3924 return infoPtr->hwndEdit;
3925
3926 infoPtr->bLabelChanged = FALSE;
3927
3928 /* make edit item visible */
3930
3932
3933 hdc = GetDC(hwnd);
3934 /* Select the font to get appropriate metric dimensions */
3935 if (infoPtr->hFont != 0)
3936 {
3937 hOldFont = SelectObject(hdc, infoPtr->hFont);
3938 }
3939
3940 /* Get string length in pixels */
3941 if (hItem->pszText)
3943 &sz);
3944 else
3945 GetTextExtentPoint32A(hdc, "", 0, &sz);
3946
3947 /* Add Extra spacing for the next character */
3948 GetTextMetricsW(hdc, &textMetric);
3949 sz.cx += (textMetric.tmMaxCharWidth * 2);
3950
3951 sz.cx = max(sz.cx, textMetric.tmMaxCharWidth * 3);
3952 sz.cx = min(sz.cx, infoPtr->clientWidth - hItem->textOffset + 2);
3953
3954 if (infoPtr->hFont != 0)
3955 {
3956 SelectObject(hdc, hOldFont);
3957 }
3958
3959 ReleaseDC(hwnd, hdc);
3960
3961 infoPtr->editItem = hItem;
3962
3964 WC_EDITW,
3965 0,
3968 ES_LEFT, hItem->textOffset - 2,
3969 hItem->rect.top - 1, sz.cx + 3,
3970 hItem->rect.bottom -
3971 hItem->rect.top + 3, hwnd, 0, hinst, 0);
3972/* FIXME: (HMENU)IDTVEDIT,pcs->hInstance,0); */
3973
3974 infoPtr->hwndEdit = hwndEdit;
3975
3976 /* Get a 2D border. */
3981
3984
3986 (DWORD_PTR)
3988 if (hItem->pszText)
3990
3992 {
3994 infoPtr->hwndEdit = 0;
3995 infoPtr->editItem = NULL;
3996 return NULL;
3997 }
3998
4002
4003 return hwndEdit;
4004}
HWND hwndEdit
Definition: combotst.c:65
static LRESULT CALLBACK TREEVIEW_Edit_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: treeview.c:3768
static BOOL TREEVIEW_BeginLabelEditNotify(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *editItem)
Definition: treeview.c:686
static HINSTANCE hinst
Definition: edit.c:551
#define WS_CHILD
Definition: pedump.c:617
#define ES_WANTRETURN
Definition: pedump.c:676
#define WS_BORDER
Definition: pedump.c:625
#define ES_AUTOHSCROLL
Definition: pedump.c:672
#define ES_LEFT
Definition: pedump.c:664
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WC_EDITW
Definition: commctrl.h:4687
#define TVS_EDITLABELS
Definition: commctrl.h:3250
HTREEITEM hItem
Definition: treelist.h:37
HANDLE HINSTANCE
Definition: typedefs.h:77
UINT_PTR WPARAM
Definition: windef.h:207
#define GetWindowLongPtrW
Definition: winuser.h:4829
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
#define GWLP_HINSTANCE
Definition: winuser.h:856
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define WM_SETFONT
Definition: winuser.h:1650
#define EM_SETSEL
Definition: winuser.h:2018
#define SW_SHOW
Definition: winuser.h:775
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define WS_EX_LEFT
Definition: winuser.h:391
#define GWL_EXSTYLE
Definition: winuser.h:851

Referenced by TREEVIEW_HandleTimer(), and TREEVIEW_WindowProc().

◆ TREEVIEW_EndEditLabelNow()

static LRESULT TREEVIEW_EndEditLabelNow ( TREEVIEW_INFO infoPtr,
BOOL  bCancel 
)
static

Definition at line 4008 of file treeview.c.

4009{
4010 TREEVIEW_ITEM *editedItem = infoPtr->editItem;
4011 NMTVDISPINFOW tvdi;
4012 BOOL bCommit;
4013 WCHAR tmpText[1024] = { '\0' };
4014 WCHAR *newText = tmpText;
4015 int iLength = 0;
4016
4017 if (!IsWindow(infoPtr->hwndEdit)) return FALSE;
4018
4019 tvdi.item.mask = 0;
4020 tvdi.item.hItem = editedItem;
4021 tvdi.item.state = editedItem->state;
4022 tvdi.item.lParam = editedItem->lParam;
4023
4024 if (!bCancel)
4025 {
4026 if (!infoPtr->bNtfUnicode)
4027 iLength = GetWindowTextA(infoPtr->hwndEdit, (LPSTR)tmpText, 1023);
4028 else
4029 iLength = GetWindowTextW(infoPtr->hwndEdit, tmpText, 1023);
4030
4031 if (iLength >= 1023)
4032 {
4033 ERR("Insufficient space to retrieve new item label\n");
4034 }
4035
4036 tvdi.item.mask = TVIF_TEXT;
4037 tvdi.item.pszText = tmpText;
4038 tvdi.item.cchTextMax = iLength + 1;
4039 }
4040 else
4041 {
4042 tvdi.item.pszText = NULL;
4043 tvdi.item.cchTextMax = 0;
4044 }
4045
4046 bCommit = TREEVIEW_SendRealNotify(infoPtr, TVN_ENDLABELEDITW, &tvdi.hdr);
4047
4048 if (!bCancel && bCommit) /* Apply the changes */
4049 {
4050 if (!infoPtr->bNtfUnicode)
4051 {
4052 DWORD len = MultiByteToWideChar( CP_ACP, 0, (LPSTR)tmpText, -1, NULL, 0 );
4053 newText = heap_alloc(len * sizeof(WCHAR));
4054 MultiByteToWideChar( CP_ACP, 0, (LPSTR)tmpText, -1, newText, len );
4055 iLength = len - 1;
4056 }
4057
4058 if (strcmpW(newText, editedItem->pszText) != 0)
4059 {
4060 WCHAR *ptr = heap_realloc(editedItem->pszText, sizeof(WCHAR)*(iLength + 1));
4061 if (ptr == NULL)
4062 {
4063 ERR("OutOfMemory, cannot allocate space for label\n");
4064 if (newText != tmpText) heap_free(newText);
4065 DestroyWindow(infoPtr->hwndEdit);
4066 infoPtr->hwndEdit = 0;
4067 infoPtr->editItem = NULL;
4068 return FALSE;
4069 }
4070 else
4071 {
4072 editedItem->pszText = ptr;
4073 editedItem->cchTextMax = iLength + 1;
4074 strcpyW(editedItem->pszText, newText);
4075 TREEVIEW_ComputeTextWidth(infoPtr, editedItem, 0);
4076 }
4077 }
4078 if (newText != tmpText) heap_free(newText);
4079 }
4080
4081 ShowWindow(infoPtr->hwndEdit, SW_HIDE);
4082 DestroyWindow(infoPtr->hwndEdit);
4083 infoPtr->hwndEdit = 0;
4084 infoPtr->editItem = NULL;
4085 return TRUE;
4086}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
unsigned long DWORD
Definition: ntddk_ex.h:95
static PVOID ptr
Definition: dispmode.c:27
#define strcmpW(s1, s2)
Definition: unicode.h:44
#define strcpyW(d, s)
Definition: unicode.h:35
int cchTextMax
Definition: treeview.c:150
HTREEITEM hItem
Definition: commctrl.h:3317
LPARAM lParam
Definition: commctrl.h:3325
UINT mask
Definition: commctrl.h:3316
int cchTextMax
Definition: commctrl.h:3321
UINT state
Definition: commctrl.h:3318
int WINAPI GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
Definition: window.c:1302
#define SW_HIDE
Definition: winuser.h:768

Referenced by TREEVIEW_Command(), TREEVIEW_Edit_SubclassProc(), TREEVIEW_Paint(), TREEVIEW_StyleChanged(), and TREEVIEW_WindowProc().

◆ TREEVIEW_EnsureVisible()

static LRESULT TREEVIEW_EnsureVisible ( TREEVIEW_INFO infoPtr,
HTREEITEM  item,
BOOL  bHScroll 
)
static

Definition at line 4739 of file treeview.c.

4740{
4741 int viscount;
4742 BOOL hasFirstVisible = infoPtr->firstVisible != NULL;
4743 HTREEITEM newFirstVisible = NULL;
4744 int visible_pos = -1;
4745
4746 if (!TREEVIEW_ValidItem(infoPtr, item))
4747 return FALSE;
4748
4749 if (!ISVISIBLE(item))
4750 {
4751 /* Expand parents as necessary. */
4753
4754 /* see if we are trying to ensure that root is visible */
4755 if((item != infoPtr->root) && TREEVIEW_ValidItem(infoPtr, item))
4756 parent = item->parent;
4757 else
4758 parent = item; /* this item is the topmost item */
4759
4760 while (parent != infoPtr->root)
4761 {
4762 if (!(parent->state & TVIS_EXPANDED))
4763 TREEVIEW_Expand(infoPtr, parent, FALSE, TRUE);
4764
4765 parent = parent->parent;
4766 }
4767 }
4768
4769 viscount = TREEVIEW_GetVisibleCount(infoPtr);
4770
4771 TRACE("%p (%s) %d - %d viscount(%d)\n", item, TREEVIEW_ItemName(item), item->visibleOrder,
4772 hasFirstVisible ? infoPtr->firstVisible->visibleOrder : -1, viscount);
4773
4774 if (hasFirstVisible)
4775 visible_pos = item->visibleOrder - infoPtr->firstVisible->visibleOrder;
4776
4777 if (visible_pos < 0)
4778 {
4779 /* item is before the start of the list: put it at the top. */
4780 newFirstVisible = item;
4781 }
4782 else if (visible_pos >= viscount
4783 /* Sometimes, before we are displayed, GVC is 0, causing us to
4784 * spuriously scroll up. */
4785 && visible_pos > 0 && !(infoPtr->dwStyle & TVS_NOSCROLL) )
4786 {
4787 /* item is past the end of the list. */
4788 int scroll = visible_pos - viscount;
4789
4790 newFirstVisible = TREEVIEW_GetListItem(infoPtr, infoPtr->firstVisible,
4791 scroll + 1);
4792 }
4793
4794 if (bHScroll)
4795 {
4796 /* Scroll window so item's text is visible as much as possible */
4797 /* Calculation of amount of extra space is taken from EditLabel code */
4798 INT pos, x;
4799 TEXTMETRICW textMetric;
4800 HDC hdc = GetWindowDC(infoPtr->hwnd);
4801
4802 x = item->textWidth;
4803
4804 GetTextMetricsW(hdc, &textMetric);
4805 ReleaseDC(infoPtr->hwnd, hdc);
4806
4807 x += (textMetric.tmMaxCharWidth * 2);
4808 x = max(x, textMetric.tmMaxCharWidth * 3);
4809
4810 if (item->textOffset < 0)
4811 pos = item->textOffset;
4812 else if (item->textOffset + x > infoPtr->clientWidth)
4813 {
4814 if (x > infoPtr->clientWidth)
4815 pos = item->textOffset;
4816 else
4817 pos = item->textOffset + x - infoPtr->clientWidth;
4818 }
4819 else
4820 pos = 0;
4821
4823 }
4824
4825 if (newFirstVisible != NULL && newFirstVisible != infoPtr->firstVisible)
4826 {
4827 TREEVIEW_SetFirstVisible(infoPtr, newFirstVisible, TRUE);
4828
4829 return TRUE;
4830 }
4831
4832 return FALSE;
4833}
static LRESULT TREEVIEW_HScroll(TREEVIEW_INFO *, WPARAM)
Definition: treeview.c:4970
static BOOL TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, BOOL partial, BOOL user)
Definition: treeview.c:3452
static TREEVIEW_ITEM * TREEVIEW_GetListItem(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, LONG count)
Definition: treeview.c:466
static LRESULT TREEVIEW_GetVisibleCount(const TREEVIEW_INFO *infoPtr)
Definition: treeview.c:2079
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define TVS_NOSCROLL
Definition: commctrl.h:3260
#define MAKEWPARAM(l, h)
Definition: winuser.h:4009
HDC WINAPI GetWindowDC(_In_opt_ HWND)
#define SB_THUMBPOSITION
Definition: winuser.h:572

Referenced by TREEVIEW_DoSelectItem(), TREEVIEW_EditLabel(), TREEVIEW_KeyDown(), TREEVIEW_ProcessLetterKeys(), and TREEVIEW_WindowProc().

◆ TREEVIEW_EraseBackground()

static LRESULT TREEVIEW_EraseBackground ( const TREEVIEW_INFO infoPtr,
HDC  hdc 
)
static

Definition at line 2897 of file treeview.c.

2898{
2899 RECT rect;
2900
2901 TRACE("%p\n", infoPtr);
2902
2903 GetClientRect(infoPtr->hwnd, &rect);
2904 TREEVIEW_FillBkgnd(infoPtr, hdc, &rect);
2905
2906 return 1;
2907}
static void TREEVIEW_FillBkgnd(const TREEVIEW_INFO *infoPtr, HDC hdc, const RECT *rc)
Definition: treeview.c:2885
& rect
Definition: startmenu.cpp:1413

Referenced by TREEVIEW_PrintClient(), and TREEVIEW_WindowProc().

◆ TREEVIEW_Expand()

static BOOL TREEVIEW_Expand ( TREEVIEW_INFO infoPtr,
TREEVIEW_ITEM item,
BOOL  partial,
BOOL  user 
)
static

Definition at line 3452 of file treeview.c.

3454{
3455 LONG scrollDist;
3456 LONG orgNextTop = 0;
3457 RECT scrollRect;
3458 TREEVIEW_ITEM *nextItem, *tmpItem;
3459 BOOL sendsNotifications;
3460
3461 TRACE("(%p, %p, partial=%d, %d)\n", infoPtr, item, partial, user);
3462
3463 if (!TREEVIEW_HasChildren(infoPtr, item))
3464 return FALSE;
3465
3466 tmpItem = item; nextItem = NULL;
3467 while (tmpItem)
3468 {
3469 if (tmpItem->nextSibling)
3470 {
3471 nextItem = tmpItem->nextSibling;
3472 break;
3473 }
3474 tmpItem = tmpItem->parent;
3475 }
3476
3477 if (nextItem)
3478 orgNextTop = nextItem->rect.top;
3479
3480 TRACE("TVE_EXPAND %p %s\n", item, TREEVIEW_ItemName(item));
3481
3482 sendsNotifications = user || ((item->cChildren != 0) &&
3483 !(item->state & TVIS_EXPANDEDONCE));
3484 if (sendsNotifications)
3485 {
3486 if (!TREEVIEW_SendExpanding(infoPtr, item, TVE_EXPAND))
3487 {
3488 TRACE(" TVN_ITEMEXPANDING returned TRUE, exiting...\n");
3489 return FALSE;
3490 }
3491 }
3492 if (!item->firstChild)
3493 return FALSE;
3494
3495 item->state |= TVIS_EXPANDED;
3496
3497 if (partial)
3498 FIXME("TVE_EXPANDPARTIAL not implemented\n");
3499
3500 if (ISVISIBLE(item))
3501 {
3503 TREEVIEW_UpdateSubTree(infoPtr, item);
3505
3506 scrollRect.left = 0;
3507 scrollRect.bottom = infoPtr->treeHeight;
3508 scrollRect.right = infoPtr->clientWidth;
3509 if (nextItem)
3510 {
3511 scrollDist = nextItem->rect.top - orgNextTop;
3512 scrollRect.top = orgNextTop;
3513
3514 ScrollWindowEx (infoPtr->hwnd, 0, scrollDist, &scrollRect, NULL,
3516 TREEVIEW_Invalidate (infoPtr, item);
3517 } else {
3518 scrollRect.top = item->rect.top;
3519 InvalidateRect(infoPtr->hwnd, &scrollRect, FALSE);
3520 }
3521
3522 /* Scroll up so that as many children as possible are visible.
3523 * This fails when expanding causes an HScroll bar to appear, but we
3524 * don't know that yet, so the last item is obscured. */
3525 if (item->firstChild != NULL)
3526 {
3527 int nChildren = item->lastChild->visibleOrder
3528 - item->firstChild->visibleOrder + 1;
3529
3530 int visible_pos = item->visibleOrder
3531 - infoPtr->firstVisible->visibleOrder;
3532
3533 int rows_below = TREEVIEW_GetVisibleCount(infoPtr) - visible_pos - 1;
3534
3535 if (visible_pos > 0 && nChildren > rows_below)
3536 {
3537 int scroll = nChildren - rows_below;
3538
3539 if (scroll > visible_pos)
3540 scroll = visible_pos;
3541
3542 if (scroll > 0)
3543 {
3544 TREEVIEW_ITEM *newFirstVisible
3545 = TREEVIEW_GetListItem(infoPtr, infoPtr->firstVisible,
3546 scroll);
3547
3548
3549 TREEVIEW_SetFirstVisible(infoPtr, newFirstVisible, TRUE);
3550 }
3551 }
3552 }
3553 }
3554
3555 if (sendsNotifications) {
3557 item->state |= TVIS_EXPANDEDONCE;
3558 }
3559
3560 return TRUE;
3561}
void user(int argc, const char *argv[])
Definition: cmds.c:1350
static VOID TREEVIEW_UpdateSubTree(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *root)
Definition: treeview.c:965
#define TVIS_EXPANDEDONCE
Definition: commctrl.h:3285
#define TVE_EXPAND
Definition: commctrl.h:3423

Referenced by TREEVIEW_EnsureVisible(), TREEVIEW_ExpandAll(), TREEVIEW_ExpandMsg(), TREEVIEW_KeyDown(), TREEVIEW_SingleExpand(), and TREEVIEW_Toggle().

◆ TREEVIEW_ExpandAll()

static VOID TREEVIEW_ExpandAll ( TREEVIEW_INFO infoPtr,
TREEVIEW_ITEM item 
)
static

Definition at line 3611 of file treeview.c.

3612{
3613 TREEVIEW_Expand(infoPtr, item, FALSE, TRUE);
3614
3615 for (item = item->firstChild; item != NULL; item = item->nextSibling)
3616 {
3617 if (TREEVIEW_HasChildren(infoPtr, item))
3618 TREEVIEW_ExpandAll(infoPtr, item);
3619 }
3620}
static VOID TREEVIEW_ExpandAll(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
Definition: treeview.c:3611

Referenced by TREEVIEW_ExpandAll(), and TREEVIEW_KeyDown().

◆ TREEVIEW_ExpandMsg()

static LRESULT TREEVIEW_ExpandMsg ( TREEVIEW_INFO infoPtr,
UINT  flag,
HTREEITEM  item 
)
static

Definition at line 3629 of file treeview.c.

3630{
3631 if (!TREEVIEW_ValidItem(infoPtr, item))
3632 return 0;
3633
3634 TRACE("For (%s) item:%d, flags 0x%x, state:%d\n",
3636 flag, item->state);
3637
3638 switch (flag & TVE_TOGGLE)
3639 {
3640 case TVE_COLLAPSE:
3641 return TREEVIEW_Collapse(infoPtr, item, flag & TVE_COLLAPSERESET,
3642 FALSE);
3643
3644 case TVE_EXPAND:
3645 return TREEVIEW_Expand(infoPtr, item, flag & TVE_EXPANDPARTIAL,
3646 FALSE);
3647
3648 case TVE_TOGGLE:
3649 return TREEVIEW_Toggle(infoPtr, item, FALSE);
3650
3651 default:
3652 return 0;
3653 }
3654}
static BOOL TREEVIEW_Toggle(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, BOOL user)
Definition: treeview.c:3600
static BOOL TREEVIEW_Collapse(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, BOOL bRemoveChildren, BOOL bUser)
Definition: treeview.c:3341
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
Definition: glfuncs.h:52
#define TVE_EXPANDPARTIAL
Definition: commctrl.h:3425
#define TVE_TOGGLE
Definition: commctrl.h:3424

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_FillBkgnd()

static void TREEVIEW_FillBkgnd ( const TREEVIEW_INFO infoPtr,
HDC  hdc,
const RECT rc 
)
static

Definition at line 2885 of file treeview.c.

2886{
2887 HBRUSH hBrush;
2888 COLORREF clrBk = GETBKCOLOR(infoPtr->clrBk);
2889
2890 hBrush = CreateSolidBrush(clrBk);
2891 FillRect(hdc, rc, hBrush);
2892 DeleteObject(hBrush);
2893}

Referenced by TREEVIEW_EraseBackground(), and TREEVIEW_Paint().

◆ TREEVIEW_FontForItem()

static HFONT TREEVIEW_FontForItem ( const TREEVIEW_INFO infoPtr,
const TREEVIEW_ITEM item 
)
inlinestatic

Definition at line 325 of file treeview.c.

326{
327 if ((infoPtr->dwStyle & TVS_TRACKSELECT) && (item == infoPtr->hotItem))
328 return item->state & TVIS_BOLD ? infoPtr->hBoldUnderlineFont : infoPtr->hUnderlineFont;
329 if (item->state & TVIS_BOLD)
330 return infoPtr->hBoldFont;
331 return infoPtr->hFont;
332}
#define TVIS_BOLD
Definition: commctrl.h:3283

Referenced by TREEVIEW_ComputeTextWidth(), TREEVIEW_DrawItem(), TREEVIEW_EditLabel(), and TREEVIEW_UpdateSubTree().

◆ TREEVIEW_FreeItem()

static void TREEVIEW_FreeItem ( TREEVIEW_INFO infoPtr,
TREEVIEW_ITEM item 
)
static

Definition at line 1031 of file treeview.c.

1032{
1033 DPA_DeletePtr(infoPtr->items, DPA_GetPtrIndex(infoPtr->items, item));
1034 if (infoPtr->selectedItem == item)
1035 infoPtr->selectedItem = NULL;
1036 if (infoPtr->hotItem == item)
1037 infoPtr->hotItem = NULL;
1038 if (infoPtr->focusedItem == item)
1039 infoPtr->focusedItem = NULL;
1040 if (infoPtr->firstVisible == item)
1041 infoPtr->firstVisible = NULL;
1042 if (infoPtr->dropItem == item)
1043 infoPtr->dropItem = NULL;
1044 if (infoPtr->insertMarkItem == item)
1045 infoPtr->insertMarkItem = NULL;
1046 heap_free(item);
1047}
INT WINAPI DPA_GetPtrIndex(HDPA hdpa, LPCVOID p)
Definition: dpa.c:561
LPVOID WINAPI DPA_DeletePtr(HDPA hdpa, INT i)
Definition: dpa.c:677

Referenced by TREEVIEW_Destroy(), and TREEVIEW_RemoveItem().

◆ TREEVIEW_GetBkColor()

static LRESULT TREEVIEW_GetBkColor ( const TREEVIEW_INFO infoPtr)
static

Definition at line 1975 of file treeview.c.

1976{
1977 TRACE("\n");
1978 return (LRESULT)infoPtr->clrBk;
1979}

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetCount()

static LRESULT TREEVIEW_GetCount ( const TREEVIEW_INFO infoPtr)
static

Definition at line 2331 of file treeview.c.

2332{
2333 TRACE(" %d\n", infoPtr->uNumItems);
2334 return (LRESULT)infoPtr->uNumItems;
2335}

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetEditControl()

static LRESULT TREEVIEW_GetEditControl ( const TREEVIEW_INFO infoPtr)
static

Definition at line 3762 of file treeview.c.

3763{
3764 return (LRESULT)infoPtr->hwndEdit;
3765}

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetFont()

static LRESULT TREEVIEW_GetFont ( const TREEVIEW_INFO infoPtr)
static

Definition at line 1883 of file treeview.c.

1884{
1885 TRACE("%p\n", infoPtr->hFont);
1886 return (LRESULT)infoPtr->hFont;
1887}

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetImageList()

static LRESULT TREEVIEW_GetImageList ( const TREEVIEW_INFO infoPtr,
WPARAM  wParam 
)
static

Definition at line 1712 of file treeview.c.

1713{
1714 TRACE("\n");
1715
1716 switch (wParam)
1717 {
1718 case TVSIL_NORMAL:
1719 return (LRESULT)infoPtr->himlNormal;
1720
1721 case TVSIL_STATE:
1722 return (LRESULT)infoPtr->himlState;
1723
1724 default:
1725 return 0;
1726 }
1727}
#define TVSIL_STATE
Definition: commctrl.h:3444
#define TVSIL_NORMAL
Definition: commctrl.h:3443

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetIndent()

static LRESULT TREEVIEW_GetIndent ( const TREEVIEW_INFO infoPtr)
static

Definition at line 1635 of file treeview.c.

1636{
1637 TRACE("\n");
1638 return infoPtr->uIndent;
1639}

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetInfoPtr()

static TREEVIEW_INFO * TREEVIEW_GetInfoPtr ( HWND  hwnd)
inlinestatic

Definition at line 228 of file treeview.c.

229{
231}

Referenced by TREEVIEW_Edit_SubclassProc(), and TREEVIEW_WindowProc().

◆ TREEVIEW_GetInsertMarkColor()

static LRESULT TREEVIEW_GetInsertMarkColor ( const TREEVIEW_INFO infoPtr)
static

Definition at line 1997 of file treeview.c.

1998{
1999 TRACE("\n");
2000 return (LRESULT)infoPtr->clrInsertMark;
2001}

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetItemHeight()

static LRESULT TREEVIEW_GetItemHeight ( const TREEVIEW_INFO infoPtr)
static

Definition at line 1875 of file treeview.c.

1876{
1877 TRACE("\n");
1878 return infoPtr->uItemHeight;
1879}

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetItemIndex()

static int TREEVIEW_GetItemIndex ( const TREEVIEW_INFO infoPtr,
HTREEITEM  handle 
)
inlinestatic

◆ TREEVIEW_GetItemRect()

static LRESULT TREEVIEW_GetItemRect ( const TREEVIEW_INFO infoPtr,
BOOL  fTextRect,
LPRECT  lpRect 
)
static

Definition at line 2037 of file treeview.c.

2038{
2040 const HTREEITEM *pItem = (HTREEITEM *)lpRect;
2041
2042 TRACE("\n");
2043
2044 if (pItem == NULL)
2045 return FALSE;
2046
2047 item = *pItem;
2048 if (!TREEVIEW_ValidItem(infoPtr, item) || !ISVISIBLE(item))
2049 return FALSE;
2050
2051 /*
2052 * If wParam is TRUE return the text size otherwise return
2053 * the whole item size
2054 */
2055 if (fTextRect)
2056 {
2057 /* Windows does not send TVN_GETDISPINFO here. */
2058
2059 lpRect->top = item->rect.top;
2060 lpRect->bottom = item->rect.bottom;
2061
2062 lpRect->left = item->textOffset;
2063 if (!item->textWidth)
2064 TREEVIEW_ComputeTextWidth(infoPtr, item, 0);
2065
2066 lpRect->right = item->textOffset + item->textWidth + 4;
2067 }
2068 else
2069 {
2070 *lpRect = item->rect;
2071 }
2072
2073 TRACE("%s [%s]\n", fTextRect ? "text" : "item", wine_dbgstr_rect(lpRect));
2074
2075 return TRUE;
2076}

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetItemState()

static LRESULT TREEVIEW_GetItemState ( const TREEVIEW_INFO infoPtr,
HTREEITEM  item,
UINT  mask 
)
static

Definition at line 2244 of file treeview.c.

2245{
2246 TRACE("\n");
2247
2248 if (!item || !TREEVIEW_ValidItem(infoPtr, item))
2249 return 0;
2250
2251 return (item->state & mask);
2252}
GLenum GLint GLuint mask
Definition: glext.h:6028

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetItemT()

static LRESULT TREEVIEW_GetItemT ( const TREEVIEW_INFO infoPtr,
LPTVITEMEXW  tvItem,
BOOL  isW 
)
static

Definition at line 2088 of file treeview.c.

2089{
2090 TREEVIEW_ITEM *item = tvItem->hItem;
2091
2092 if (!TREEVIEW_ValidItem(infoPtr, item))
2093 {
2094 BOOL valid_item = FALSE;
2095 if (!item) return FALSE;
2096
2097 __TRY
2098 {
2099 infoPtr = item->infoPtr;
2100 TRACE("got item from different tree %p, called from %p\n", item->infoPtr, infoPtr);
2101 valid_item = TREEVIEW_ValidItem(infoPtr, item);
2102 }
2104 {
2105 }
2106 __ENDTRY
2107 if (!valid_item) return FALSE;
2108 }
2109
2110 TREEVIEW_UpdateDispInfo(infoPtr, item, tvItem->mask);
2111
2112 if (tvItem->mask & TVIF_CHILDREN)
2113 {
2114 if (item->cChildren==I_CHILDRENCALLBACK)
2115 FIXME("I_CHILDRENCALLBACK not supported\n");
2116 tvItem->cChildren = item->cChildren;
2117 }
2118
2119 if (tvItem->mask & TVIF_HANDLE)
2120 tvItem->hItem = item;
2121
2122 if (tvItem->mask & TVIF_IMAGE)
2123 tvItem->iImage = item->iImage;
2124
2125 if (tvItem->mask & TVIF_INTEGRAL)
2126 tvItem->iIntegral = item->iIntegral;
2127
2128 /* undocumented: (mask & TVIF_PARAM) ignored and lParam is always set */
2129 tvItem->lParam = item->lParam;
2130
2131 if (tvItem->mask & TVIF_SELECTEDIMAGE)
2132 tvItem->iSelectedImage = item->iSelectedImage;
2133
2134 if (tvItem->mask & TVIF_EXPANDEDIMAGE)
2135 tvItem->iExpandedImage = item->iExpandedImage;
2136
2137 /* undocumented: stateMask and (state & TVIF_STATE) ignored, so state is always set */
2138 tvItem->state = item->state;
2139
2140 if (tvItem->mask & TVIF_TEXT)
2141 {
2142 if (item->pszText == NULL)
2143 {
2144 if (tvItem->cchTextMax > 0)
2145 tvItem->pszText[0] = '\0';
2146 }
2147 else if (isW)
2148 {
2149 if (item->pszText == LPSTR_TEXTCALLBACKW)
2150 {
2151 tvItem->pszText = LPSTR_TEXTCALLBACKW;
2152 FIXME(" GetItem called with LPSTR_TEXTCALLBACK\n");
2153 }
2154 else
2155 {
2156 lstrcpynW(tvItem->pszText, item->pszText, tvItem->cchTextMax);
2157 }
2158 }
2159 else
2160 {
2161 if (item->pszText == LPSTR_TEXTCALLBACKW)
2162 {
2164 FIXME(" GetItem called with LPSTR_TEXTCALLBACK\n");
2165 }
2166 else
2167 {
2168 WideCharToMultiByte(CP_ACP, 0, item->pszText, -1,
2169 (LPSTR)tvItem->pszText, tvItem->cchTextMax, NULL, NULL);
2170 }
2171 }
2172 }
2173
2174 if (tvItem->mask & TVIF_STATEEX)
2175 {
2176 FIXME("Extended item state not supported, returning 0.\n");
2177 tvItem->uStateEx = 0;
2178 }
2179
2180 TRACE("item <%p>, txt %p, img %d, mask 0x%x\n",
2181 item, tvItem->pszText, tvItem->iImage, tvItem->mask);
2182
2183 return TRUE;
2184}
#define __TRY
Definition: compat.h:80
#define __ENDTRY
Definition: compat.h:82
#define WideCharToMultiByte
Definition: compat.h:111
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
#define LPSTR_TEXTCALLBACKA
Definition: commctrl.h:2381
int cchTextMax
Definition: commctrl.h:3351
HTREEITEM hItem
Definition: commctrl.h:3347

Referenced by TREEVIEW_ProcessLetterKeys(), and TREEVIEW_WindowProc().

◆ TREEVIEW_GetLastListItem()

static TREEVIEW_ITEM * TREEVIEW_GetLastListItem ( const TREEVIEW_INFO infoPtr,
TREEVIEW_ITEM item 
)
static

Definition at line 379 of file treeview.c.

380{
381 if (!item) return NULL;
382
383 while (item->lastChild)
384 {
385 if (item->state & TVIS_EXPANDED)
386 item = item->lastChild;
387 else
388 break;
389 }
390
391 if (item == infoPtr->root)
392 return NULL;
393
394 return item;
395}

Referenced by TREEVIEW_GetNextItem(), TREEVIEW_GetPrevListItem(), TREEVIEW_KeyDown(), and TREEVIEW_VScroll().

◆ TREEVIEW_GetLineColor()

static LRESULT TREEVIEW_GetLineColor ( const TREEVIEW_INFO infoPtr)
static

Definition at line 1935 of file treeview.c.

1936{
1937 TRACE("\n");
1938 return (LRESULT)infoPtr->clrLine;
1939}

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetListItem()

static TREEVIEW_ITEM * TREEVIEW_GetListItem ( const TREEVIEW_INFO infoPtr,
TREEVIEW_ITEM item,
LONG  count 
)
static

Definition at line 466 of file treeview.c.

468{
469 TREEVIEW_ITEM *(*next_item)(const TREEVIEW_INFO *, const TREEVIEW_ITEM *);
470 TREEVIEW_ITEM *previousItem;
471
472 assert(item != NULL);
473
474 if (count > 0)
475 {
476 next_item = TREEVIEW_GetNextListItem;
477 }
478 else if (count < 0)
479 {
480 count = -count;
481 next_item = TREEVIEW_GetPrevListItem;
482 }
483 else
484 return item;
485
486 do
487 {
488 previousItem = item;
489 item = next_item(infoPtr, item);
490
491 } while (--count && item != NULL);
492
493
494 return item ? item : previousItem;
495}
GLuint GLuint GLsizei count
Definition: gl.h:1545

Referenced by TREEVIEW_EnsureVisible(), TREEVIEW_Expand(), TREEVIEW_KeyDown(), TREEVIEW_SetFirstVisible(), and TREEVIEW_VScroll().

◆ TREEVIEW_GetNextItem()

static LRESULT TREEVIEW_GetNextItem ( const TREEVIEW_INFO infoPtr,
UINT  which,
HTREEITEM  item 
)
static

Definition at line 2255 of file treeview.c.

2256{
2257 TREEVIEW_ITEM *retval;
2258
2259 retval = 0;
2260
2261 /* handle all the global data here */
2262 switch (which)
2263 {
2264 case TVGN_CHILD: /* Special case: child of 0 is root */
2265 if (item)
2266 break;
2267 /* fall through */
2268 case TVGN_ROOT:
2269 retval = infoPtr->root->firstChild;
2270 break;
2271
2272 case TVGN_CARET:
2273 retval = infoPtr->selectedItem;
2274 break;
2275
2276 case TVGN_FIRSTVISIBLE:
2277 retval = infoPtr->firstVisible;
2278 break;
2279
2280 case TVGN_DROPHILITE:
2281 retval = infoPtr->dropItem;
2282 break;
2283
2284 case TVGN_LASTVISIBLE:
2285 retval = TREEVIEW_GetLastListItem(infoPtr, infoPtr->root);
2286 break;
2287 }
2288
2289 if (retval)
2290 {
2291 TRACE("flags:0x%x, returns %p\n", which, retval);
2292 return (LRESULT)retval;
2293 }
2294
2295 if (item == TVI_ROOT) item = infoPtr->root;
2296
2297 if (!TREEVIEW_ValidItem(infoPtr, item))
2298 return FALSE;
2299
2300 switch (which)
2301 {
2302 case TVGN_NEXT:
2303 retval = item->nextSibling;
2304 break;
2305 case TVGN_PREVIOUS:
2306 retval = item->prevSibling;
2307 break;
2308 case TVGN_PARENT:
2309 retval = (item->parent != infoPtr->root) ? item->parent : NULL;
2310 break;
2311 case TVGN_CHILD:
2312 retval = item->firstChild;
2313 break;
2314 case TVGN_NEXTVISIBLE:
2315 retval = TREEVIEW_GetNextListItem(infoPtr, item);
2316 break;
2318 retval = TREEVIEW_GetPrevListItem(infoPtr, item);
2319 break;
2320 default:
2321 TRACE("Unknown msg 0x%x, item %p\n", which, item);
2322 break;
2323 }
2324
2325 TRACE("flags: 0x%x, item %p;returns %p\n", which, item, retval);
2326 return (LRESULT)retval;
2327}
static TREEVIEW_ITEM * TREEVIEW_GetLastListItem(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
Definition: treeview.c:379
#define TVGN_PARENT
Definition: commctrl.h:3455
#define TVGN_PREVIOUSVISIBLE
Definition: commctrl.h:3459
#define TVGN_LASTVISIBLE
Definition: commctrl.h:3462
#define TVGN_PREVIOUS
Definition: commctrl.h:3454
#define TVGN_ROOT
Definition: commctrl.h:3452
#define TVGN_NEXTVISIBLE
Definition: commctrl.h:3458
#define TVGN_CHILD
Definition: commctrl.h:3456
#define TVGN_NEXT
Definition: commctrl.h:3453
static GLenum which
Definition: wgl_font.c:159

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetNextListItem()

static TREEVIEW_ITEM * TREEVIEW_GetNextListItem ( const TREEVIEW_INFO infoPtr,
const TREEVIEW_ITEM tvItem 
)
static

Definition at line 427 of file treeview.c.

428{
429 /*
430 * If this item has children and is expanded, return the first child
431 */
432 if ((tvItem->state & TVIS_EXPANDED) && tvItem->firstChild != NULL)
433 {
434 return tvItem->firstChild;
435 }
436
437
438 /*
439 * try to get the sibling
440 */
441 if (tvItem->nextSibling)
442 return tvItem->nextSibling;
443
444 /*
445 * Otherwise, get the parent's sibling.
446 */
447 while (tvItem->parent)
448 {
449 tvItem = tvItem->parent;
450
451 if (tvItem->nextSibling)
452 return tvItem->nextSibling;
453 }
454
455 return NULL;
456}

Referenced by TREEVIEW_Collapse(), TREEVIEW_GetListItem(), TREEVIEW_GetNextItem(), TREEVIEW_HitTestPoint(), TREEVIEW_HScroll(), TREEVIEW_InsertItemT(), TREEVIEW_KeyDown(), TREEVIEW_ProcessLetterKeys(), TREEVIEW_RecalculateVisibleOrder(), TREEVIEW_Refresh(), TREEVIEW_SetFirstVisible(), TREEVIEW_Sort(), TREEVIEW_UpdateScrollBars(), TREEVIEW_UpdateSubTree(), and TREEVIEW_VScroll().

◆ TREEVIEW_GetPrevListItem()

static TREEVIEW_ITEM * TREEVIEW_GetPrevListItem ( const TREEVIEW_INFO infoPtr,
const TREEVIEW_ITEM tvItem 
)
static

Definition at line 402 of file treeview.c.

403{
404 if (tvItem->prevSibling)
405 {
406 /* This item has a prevSibling, get the last item in the sibling's tree. */
407 TREEVIEW_ITEM *upItem = tvItem->prevSibling;
408
409 if ((upItem->state & TVIS_EXPANDED) && upItem->lastChild != NULL)
410 return TREEVIEW_GetLastListItem(infoPtr, upItem->lastChild);
411 else
412 return upItem;
413 }
414 else
415 {
416 /* this item does not have a prevSibling, get the parent */
417 return (tvItem->parent != infoPtr->root) ? tvItem->parent : NULL;
418 }
419}
HTREEITEM prevSibling
Definition: treeview.c:159
HTREEITEM lastChild
Definition: treeview.c:158

Referenced by TREEVIEW_DeleteItem(), TREEVIEW_GetListItem(), TREEVIEW_GetNextItem(), TREEVIEW_InsertItemT(), TREEVIEW_KeyDown(), and TREEVIEW_VScroll().

◆ TREEVIEW_GetScrollTime()

static LRESULT TREEVIEW_GetScrollTime ( const TREEVIEW_INFO infoPtr)
static

Definition at line 1695 of file treeview.c.

1696{
1697 return infoPtr->uScrollTime;
1698}

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetTextColor()

static LRESULT TREEVIEW_GetTextColor ( const TREEVIEW_INFO infoPtr)
static

Definition at line 1953 of file treeview.c.

1954{
1955 TRACE("\n");
1956 return (LRESULT)infoPtr->clrText;
1957}

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetToolTips()

static LRESULT TREEVIEW_GetToolTips ( const TREEVIEW_INFO infoPtr)
static

Definition at line 1662 of file treeview.c.

1663{
1664 TRACE("\n");
1665 return (LRESULT)infoPtr->hwndToolTip;
1666}

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetUnicodeFormat()

static LRESULT TREEVIEW_GetUnicodeFormat ( const TREEVIEW_INFO infoPtr)
static

Definition at line 1689 of file treeview.c.

1690{
1691 return infoPtr->bNtfUnicode;
1692}

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_GetVisibleCount()

static LRESULT TREEVIEW_GetVisibleCount ( const TREEVIEW_INFO infoPtr)
inlinestatic

Definition at line 2079 of file treeview.c.

2080{
2081 /* Surprise! This does not take integral height into account. */
2082 TRACE("client=%d, item=%d\n", infoPtr->clientHeight, infoPtr->uItemHeight);
2083 return infoPtr->clientHeight / infoPtr->uItemHeight;
2084}

Referenced by TREEVIEW_EnsureVisible(), TREEVIEW_Expand(), TREEVIEW_KeyDown(), TREEVIEW_SetFirstVisible(), TREEVIEW_UpdateScrollBars(), TREEVIEW_VScroll(), and TREEVIEW_WindowProc().

◆ TREEVIEW_HandleTimer()

static LRESULT TREEVIEW_HandleTimer ( TREEVIEW_INFO infoPtr,
WPARAM  wParam 
)
static

Definition at line 4089 of file treeview.c.

4090{
4091 if (wParam != TV_EDIT_TIMER)
4092 {
4093 ERR("got unknown timer\n");
4094 return 1;
4095 }
4096
4097 KillTimer(infoPtr->hwnd, TV_EDIT_TIMER);
4098 infoPtr->Timer &= ~TV_EDIT_TIMER_SET;
4099
4100 TREEVIEW_EditLabel(infoPtr, infoPtr->selectedItem);
4101
4102 return 0;
4103}
#define TV_EDIT_TIMER
Definition: treeview.c:187
static HWND TREEVIEW_EditLabel(TREEVIEW_INFO *infoPtr, HTREEITEM hItem)
Definition: treeview.c:3906
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

Referenced by TREEVIEW_WindowProc().

◆ TREEVIEW_HasChildren()

static BOOL TREEVIEW_HasChildren ( const TREEVIEW_INFO infoPtr,
TREEVIEW_ITEM item 
)
static

Definition at line 834 of file treeview.c.

835{
837 /* Protect for a case when callback field is not changed by a host,
838 otherwise negative values trigger normal notifications. */
839 return item->cChildren != 0 && item->cChildren != I_CHILDRENCALLBACK;
840}

Referenced by TREEVIEW_Collapse(), TREEVIEW_DeleteItem(), TREEVIEW_Expand(), TREEVIEW_ExpandAll(), and TREEVIEW_KeyDown().

◆ TREEVIEW_HitTest()

static TREEVIEW_ITEM * TREEVIEW_HitTest ( const TREEVIEW_INFO infoPtr,
LPTVHITTESTINFO  lpht 
)
static

Definition at line 3681 of file treeview.c.

3682{
3684 RECT rect;
3685 UINT status;
3686 LONG x, y;
3687
3688 lpht->hItem = 0;
3689 GetClientRect(infoPtr->hwnd, &rect);
3690 status = 0;
3691 x = lpht->pt.x;
3692 y = lpht->pt.y;
3693
3694 if (x < rect.left)
3695 {
3697 }
3698 else if (x > rect.right)
3699 {
3701 }
3702
3703 if (y < rect.top)
3704 {
3705 status |= TVHT_ABOVE;
3706 }
3707 else if (y > rect.bottom)
3708 {
3709 status |= TVHT_BELOW;
3710 }
3711
3712 if (status)
3713 {
3714 lpht->flags = status;
3715 return NULL;
3716 }
3717
3718 item = TREEVIEW_HitTestPoint(infoPtr, lpht->pt);
3719 if (!item)
3720 {
3721 lpht->flags = TVHT_NOWHERE;
3722 return NULL;
3723 }
3724
3725 if (!item->textWidth)
3726 TREEVIEW_ComputeTextWidth(infoPtr, item, 0);
3727
3728 if (x >= item->textOffset + item->textWidth)
3729 {
3730 lpht->flags = TVHT_ONITEMRIGHT;
3731 }
3732 else if (x >= item->textOffset)
3733 {
3734 lpht->flags = TVHT_ONITEMLABEL;
3735 }
3736 else if (x >= item->imageOffset)
3737 {
3738 lpht->flags = TVHT_ONITEMICON;
3739 }
3740 else if (x >= item->stateOffset)
3741 {
3743 }
3744 else if (x >= item->linesOffset && infoPtr->dwStyle & TVS_HASBUTTONS)
3745 {
3746 lpht->flags = TVHT_ONITEMBUTTON;
3747 }
3748 else
3749 {
3750 lpht->flags = TVHT_ONITEMINDENT;
3751 }
3752
3753 lpht->hItem = item;
3754 TRACE("(%d,%d):result 0x%x\n", lpht->pt.x, lpht->pt.y, lpht->flags);
3755
3756 return item;
3757}
static TREEVIEW_ITEM * TREEVIEW_HitTestPoint(const TREEVIEW_INFO *infoPtr, POINT pt)
Definition: treeview.c:3659
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define TVHT_TORIGHT
Definition: commctrl.h:3535
#define TVHT_NOWHERE
Definition: commctrl.h:3524
#define TVHT_BELOW
Definition: commctrl.h:3534
#define TVHT_ABOVE
Definition: commctrl.h:3533
#define TVHT_ONITEMINDENT
Definition: commctrl.h:3528
#define TVHT_ONITEMBUTTON
Definition: commctrl.h:3529
#define TVHT_ONITEMLABEL
Definition: commctrl.h:3526
#define TVHT_ONITEMSTATEICON
Definition: commctrl.h:3531
#define TVHT_ONITEMRIGHT
Definition: commctrl.h:3530
#define TVHT_ONITEMICON
Definition: commctrl.h:3525
#define TVHT_TOLEFT
Definition: commctrl.h:3536
Definition: ps.c:97
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
HTREEITEM hItem
Definition: commctrl.h:3521

Referenced by TREEVIEW_LButtonDoubleClick(), TREEVIEW_LButtonDown(), TREEVIEW_MouseMove(), TREEVIEW_RButtonDown(), TREEVIEW_SetCursor(), and TREEVIEW_WindowProc().

◆ TREEVIEW_HitTestPoint()

static TREEVIEW_ITEM * TREEVIEW_HitTestPoint ( const TREEVIEW_INFO infoPtr,
POINT  pt 
)
static

Definition at line 3659 of file treeview.c.

3660{
3662 LONG row;
3663
3664 if (!infoPtr->firstVisible)
3665 return NULL;
3666
3667 row = pt.y / infoPtr->uItemHeight + infoPtr->firstVisible->visibleOrder;
3668
3669 for (item = infoPtr->firstVisible; item != NULL;
3671 {
3672 if (row >= item->visibleOrder
3673 && row < item->visibleOrder + item->iIntegral)
3674 break;
3675 }
3676
3677 return item;
3678}
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
#define pt(x, y)
Definition: drawing.c:79

Referenced by TREEVIEW_HitTest().

◆ TREEVIEW_HScroll()

static LRESULT TREEVIEW_HScroll ( TREEVIEW_INFO infoPtr,
WPARAM  wParam 
)
static

Definition at line 4970 of file treeview.c.

4971{
4972 int maxWidth;
4973 int scrollX = infoPtr->scrollX;
4974 int nScrollCode = LOWORD(wParam);
4975
4976 TRACE("wp %lx\n", wParam);
4977
4978 if (!(infoPtr->uInternalStatus & TV_HSCROLL))
4979 return FALSE;
4980
4981 maxWidth = infoPtr->treeWidth - infoPtr->clientWidth;
4982 /* shall never occur */
4983 if (maxWidth <= 0)
4984 {
4985 scrollX = 0;
4986 goto scroll;
4987 }
4988
4989 switch (nScrollCode)
4990 {
4991 case SB_LINELEFT:
4992 scrollX -= infoPtr->uItemHeight;
4993 break;
4994 case SB_LINERIGHT:
4995 scrollX += infoPtr->uItemHeight;
4996 break;
4997 case SB_PAGELEFT:
4998 scrollX -= infoPtr->clientWidth;
4999 break;
5000 case SB_PAGERIGHT:
5001 scrollX += infoPtr->clientWidth;
5002 break;
5003
5004 case SB_THUMBTRACK:
5005 case SB_THUMBPOSITION:
5006 scrollX = (int)(SHORT)HIWORD(wParam);
5007 break;
5008
5009 case SB_ENDSCROLL:
5010 return 0;
5011 }
5012
5013 if (scrollX > maxWidth)
5014 scrollX = maxWidth;
5015 else if (scrollX < 0)
5016 scrollX = 0;
5017
5018scroll:
5019 if (scrollX != infoPtr->scrollX)
5020 {
5022 LONG scroll_pixels = infoPtr->scrollX - scrollX;
5023
5024 for (item = infoPtr->root->firstChild; item != NULL;
5026 {
5027 item->linesOffset += scroll_pixels;
5028 item->stateOffset += scroll_pixels;
5029 item->imageOffset += scroll_pixels;
5030 item->textOffset += scroll_pixels;
5031 }
5032
5033 ScrollWindow(infoPtr->hwnd, scroll_pixels, 0, NULL, NULL);
5034 infoPtr->scrollX = scrollX;
5035 UpdateWindow(infoPtr->hwnd);
5036 }
5037
5038 if (nScrollCode != SB_THUMBTRACK)
5039 SetScrollPos(infoPtr->hwnd, SB_HORZ, scrollX, TRUE);
5040
5041 return 0;
5042}
#define TV_HSCROLL
Definition: treeview.c:178
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
short SHORT
Definition: pedump.c:59
#define SB_THUMBTRACK
Definition: winuser.h:573
#define SB_PAGERIGHT
Definition: winuser.h:571
#define SB_LINERIGHT
Definition: winuser.h:567
int WINAPI SetScrollPos(_In_ HWND, _In_ int, _In_ int, _In_ BOOL)
#define SB_LINELEFT
Definition: winuser.h:566
BOOL WINAPI UpdateWindow(_In_ HWND)
#define SB_ENDSCROLL
Definition: winuser.h:574
BOOL WINAPI ScrollWindow(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT)
#define SB_PAGELEFT
Definition: winuser.h:570

Referenced by TREEVIEW_EnsureVisible(), TREEVIEW_ScrollKeyDown(), TREEVIEW_UpdateScrollBars(), and TREEVIEW_WindowProc().

◆ TREEVIEW_InitCheckboxes()

static void TREEVIEW_InitCheckboxes ( TREEVIEW_INFO infoPtr)
static

Definition at line 2977 of file treeview.c.

2978{
2979 RECT rc;
2980 HBITMAP hbm, hbmOld;
2981 HDC hdc, hdcScreen;
2982 int nIndex;
2983
2984 infoPtr->himlState = ImageList_Create(16, 16, ILC_COLOR | ILC_MASK, 3, 0);
2985
2986 hdcScreen = GetDC(0);
2987
2988 hdc = CreateCompatibleDC(hdcScreen);
2989 hbm = CreateCompatibleBitmap(hdcScreen, 48, 16);
2990 hbmOld = SelectObject(hdc, hbm);
2991
2992 SetRect(&rc, 0, 0, 48, 16);
2993 FillRect(hdc, &rc, (HBRUSH)(COLOR_WINDOW+1));
2994
2995 SetRect(&rc, 18, 2, 30, 14);
2998
2999 SetRect(&rc, 34, 2, 46, 14);
3002
3003 SelectObject(hdc, hbmOld);
3004 nIndex = ImageList_AddMasked(infoPtr->himlState, hbm,
3006 TRACE("checkbox index %d\n", nIndex);
3007
3009 DeleteDC(hdc);
3010 ReleaseDC(0, hdcScreen);
3011
3012 infoPtr->stateImageWidth = 16;
3013 infoPtr->stateImageHeight = 16;
3014}
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:563
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
#define ILC_MASK
Definition: commctrl.h:351
COLORREF clrWindow
Definition: comctl32.h:176
#define COLOR_WINDOW
Definition: winuser.h:918
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define DFCS_FLAT
Definition: winuser.h:510
#define DFCS_BUTTONCHECK
Definition: winuser.h:496
#define DFC_BUTTON
Definition: winuser.h:476
#define DFCS_CHECKED
Definition: winuser.h:504

Referenced by TREEVIEW_Paint(), and TREEVIEW_StyleChanged().

◆ TREEVIEW_InsertAfter()

static void TREEVIEW_InsertAfter ( TREEVIEW_ITEM newItem,
TREEVIEW_ITEM sibling,
TREEVIEW_ITEM parent 
)
static

Definition at line 1089 of file treeview.c.

1091{
1092 assert(parent != NULL);
1093
1094 if (sibling != NULL)
1095 {
1096 assert(sibling->parent == parent);
1097
1098 if (sibling->nextSibling != NULL)
1099 sibling->nextSibling->prevSibling = newItem;
1100
1101 newItem->nextSibling = sibling->nextSibling;
1102 sibling->nextSibling = newItem;
1103 }
1104 else
1105 newItem->nextSibling = NULL;
1106
1107 newItem->prevSibling = sibling;
1108
1109 if (parent->lastChild == sibling)
1110 parent->lastChild = newItem;
1111
1112 if (parent->firstChild == NULL)
1113 parent->firstChild = newItem;
1114}

Referenced by TREEVIEW_InsertItemT().

◆ TREEVIEW_InsertBefore()

static void TREEVIEW_InsertBefore ( TREEVIEW_ITEM newItem,
TREEVIEW_ITEM sibling,
TREEVIEW_ITEM parent 
)