home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 February / PCWorld_2000-02_cd.bin / Software / TemaCD / tcvpa / data1.cab / MyFileGroup / INCLUDE / tcTree.h < prev    next >
Text File  |  1999-06-03  |  5KB  |  191 lines

  1. #define WC_TcTreeCtrl        "TcTreeCtrl"
  2.  
  3. #define WS_TREE_LINES        0x1
  4. #define WS_TREE_BUTTONS        0x2
  5. #define WS_TREE_ROOTLINES    0x4
  6. #define WS_TREE_MULSEL        0x8
  7. #define WS_TREE_AUTO        0x10
  8.  
  9. ////////////////////////////////////////////////////////
  10. typedef struct _TREE_DRAWPARAMS
  11. {
  12.     NMHDR   hdr;
  13.     void *    pItem;
  14.  
  15.     char    text [256];
  16.     BOOL    expanded;
  17.     BOOL    selected;
  18.     unsigned    attr;    // 1-bold, 2-ital, 4-under, 8-strikeout, 16-drop_target
  19. //    BOOL    gray;
  20.     int        img_idx;
  21.     int        my_be_exp;
  22.  
  23.     COLORREF    fColor;
  24.     COLORREF    bColor;
  25.  
  26.     HIMAGELIST    xImgLst[4];
  27.     int            xImgIdx[4];
  28. }
  29. TREE_DRAWPARAMS;
  30.  
  31. typedef struct _TREE_NOTIFY
  32. {
  33.     NMHDR   hdr;
  34.     void *    pItem;
  35.  
  36.     long    arg;
  37. }
  38. TREE_NOTIFY;
  39.  
  40. /*typedef struct _TREE_DRAGDROP
  41. {
  42.     NMHDR   hdr;
  43.     POINT    ms;
  44. }
  45. TREE_DRAGDROP;*/
  46.  
  47. ////////////////////////////////////////////////////////
  48. typedef struct _XTREE_ITEM
  49. {
  50.     DWORD        mask;        // for INSERT or SET
  51.     DWORD        item;
  52.  
  53.         DWORD        attr;
  54.         DWORD        userData;
  55.         long        image;
  56.         COLORREF    fColorN;
  57.         COLORREF    bColorN;
  58.         COLORREF    fColorS;
  59.         COLORREF    bColorS;
  60.  
  61.     char        text [256];
  62. }
  63. XTREE_ITEM;
  64.  
  65. #define XTREE_MASK_FCOLOR_N        (1<<0)
  66. #define XTREE_MASK_BCOLOR_N        (1<<1)
  67. #define XTREE_MASK_FCOLOR_S        (1<<2)
  68. #define XTREE_MASK_BCOLOR_S        (1<<3)
  69.  
  70. #define XTREE_MASK_TEXT            (1<<4)
  71. #define XTREE_MASK_DATA            (1<<5)
  72. #define XTREE_MASK_ATTR            (1<<6)
  73. #define XTREE_MASK_IMAGE        (1<<7)
  74.  
  75. ////////////////////////////////////////////////////////
  76.  
  77. enum
  78. {
  79.     TREE_N_None = -300,
  80.     TREE_N_DrawParams,    //
  81.  
  82.     TREE_N_Change,        //
  83.     TREE_N_GetLevel,    // Return Level
  84.     TREE_N_GetParent,    // Return PTR
  85.     TREE_N_GetCount,    // Return NUM
  86.     TREE_N_GetChild,    // arg=number; Return PTR
  87.     TREE_N_CanMulSel,    // Return BOOL(error)
  88.     TREE_N_Select,        // BOOL(is_sel)
  89.  
  90.     TREE_N_Expanded,    //
  91.     TREE_N_Collapsed,    //
  92.  
  93.     TREE_N_XDelete,        //
  94.     TREE_N_Changing,    // Return ERR
  95.     TREE_N_CanDragDrop,    // --
  96.  
  97.     TREE_N_TryFill,        //
  98. };
  99.  
  100.  
  101. enum
  102. {
  103. WM_TREE_SETIMAGELIST=(0x1400+1),    // lParam = hImg
  104. WM_TREE_REDRAW,            //
  105.  
  106. WM_TREE_ONINSERT,        // wParam = flags, lParam = (item *)
  107. WM_TREE_ONDELETE,        // wParam = BOOL(draw), lParam = (item *)
  108.  
  109. WM_TREE_GETINDEX,        // lParam = (item *); Return INDEX
  110. WM_TREE_SETPTR,            // wParam = INT(index), lParam = (item *)
  111.  
  112. WM_TREE_GETFOCUSED,        // Return (item *)
  113. WM_TREE_SETFOCUSED,        // wParam = BOOL(keep_sel), lParam = (item *); Return OK
  114. WM_TREE_GETSEL,            // lParam = (item*); Return BOOL
  115. WM_TREE_SETSEL,            // wParam = BOOL(sel), lParam = (item *)
  116.  
  117. WM_TREE_GETSELITEMS,    // wParam = INT(max), lParam = (item **); Return COUNT
  118. WM_TREE_GETITEMRECT,    // wParam = flags, lParam = union {RECT; Item*;}; return OK
  119.  
  120. WM_TREE_COLLAPSE,        // lParam = (item *)
  121. WM_TREE_EXPAND,            // lParam = (item *)
  122. WM_TREE_SETCOLORS,        // lParam = DWORD[8]
  123.  
  124. WM_XTREE_INSERT,        // wParam = index, lParam = (XTREE_ITEM *) // item=PARENT
  125.                         // Return xitem
  126. WM_XTREE_DELETE,        // lParam = (long)xitem
  127. WM_XTREE_SET,            // lParam = (XTREE_ITEM *)
  128. WM_XTREE_GET,            // lParam = (XTREE_ITEM *)
  129. WM_XTREE_CHILD,            // wParam = index, lParam = parent_xitem
  130. WM_XTREE_PARENT,        // lParam = xitem
  131. WM_XTREE_COUNT,            // lParam = xitem
  132.  
  133. WM_TREE_TOPVISUAL,        // Return item*
  134.  
  135. WM_TREE_CLEAR,            //
  136. WM_TREE_EXPAND_ALL,        // lParam = (item *)
  137. WM_TREE_GETBYINDEX,        // wParam = index; Return item*
  138. WM_TREE_ITEMFROMPOINT,    // lParam = MAKELONG(x,y); Return item*
  139. };
  140.  
  141. #define TcTree_Redraw(hwnd)                SendMessage(hwnd,WM_TREE_REDRAW,0,0)
  142. #define TcTree_Insert(hwnd,uitem,flg)    SendMessage(hwnd,WM_TREE_ONINSERT,flg,(LPARAM)(uitem))
  143. #define TcTree_Delete(hwnd,uitem,flg)    SendMessage(hwnd,WM_TREE_ONDELETE,flg,(LPARAM)(uitem))
  144. #define TcTree_GetFocused(hwnd)            SendMessage(hwnd,WM_TREE_GETFOCUSED,0,0)
  145. #define TcTree_SetFocused(hwnd,uitem)    SendMessage(hwnd,WM_TREE_SETFOCUSED,0,(LPARAM)(uitem))
  146. #define TcTree_Collapse(hwnd,uitem)        SendMessage(hwnd,WM_TREE_COLLAPSE,0,(LPARAM)(uitem))
  147. #define TcTree_Expand(hwnd,uitem)        SendMessage(hwnd,WM_TREE_EXPAND,0,(LPARAM)(uitem))
  148. #define TcTree_ExpandAll(hwnd,uitem)    SendMessage(hwnd,WM_TREE_EXPAND_ALL,0,(LPARAM)(uitem))
  149. #define TcTree_SetImageList(hwnd,hil)    SendMessage(hwnd,WM_TREE_SETIMAGELIST,0,(LPARAM)(hil))
  150. #define TcTree_Clear(hwnd)                SendMessage(hwnd,WM_TREE_CLEAR,0,0)
  151. #define TcTree_ItemFromPoint(hwnd,x,y)    SendMessage(hwnd,WM_TREE_ITEMFROMPOINT,0,MAKELONG(x,y))
  152.  
  153.  
  154. /*
  155.             PROMOTE / DEMOTE
  156.  
  157. SendMessage( h_Tree, WM_TREE_COLLAPSE, 0, (LPARAM)item );
  158. SendMessage( h_Tree, WM_TREE_ONDELETE, 1, (LPARAM)item );
  159.  
  160. item->Parent->Remove_Child(item);
  161. new_par->Add_Child(item);
  162. item->Parent = new_par;
  163.  
  164. SendMessage( h_Tree, WM_TREE_ONINSERT, 1, (LPARAM)item );
  165. SendMessage( h_Tree, WM_TREE_EXPAND, 0, (LPARAM)new_par );
  166.  
  167. SendMessage( h_Tree, WM_TREE_SETFOCUSED, 0, (LPARAM)item );
  168.  
  169.  
  170.             SWAP
  171.  
  172. int i1 = SendMessage( h_Tree, WM_TREE_GETINDEX, 0, (LPARAM)item1 );
  173. int i2 = SendMessage( h_Tree, WM_TREE_GETINDEX, 0, (LPARAM)item2 );
  174. SendMessage( h_Tree, WM_TREE_SETPTR, i1, (LPARAM)item2 );
  175. SendMessage( h_Tree, WM_TREE_SETPTR, i2, (LPARAM)item1 );
  176.  
  177. item1->Parent->Children.Replace( idx1+0, item2 );
  178. item1->Parent->Children.Replace( idx1+1, item1 );
  179.  
  180. */
  181.  
  182. #define TREE_CIDX_TEXT        0
  183. #define TREE_CIDX_BACK        1
  184. #define TREE_CIDX_STEXT        2
  185. #define TREE_CIDX_SBACK        3
  186. #define TREE_CIDX_STEXT2    4
  187. #define TREE_CIDX_SBACK2    5
  188. #define TREE_CIDX_PLUS        6
  189. #define TREE_CIDX_LINES        7
  190.  
  191.