/[winpt]/trunk/Src/wptListView.cpp
ViewVC logotype

Diff of /trunk/Src/wptListView.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 20 by twoaday, Wed Jul 27 11:17:22 2005 UTC revision 22 by twoaday, Wed Aug 10 11:33:35 2005 UTC
# Line 1  Line 1 
1  /* wptListView.cpp - Dynamic list view control  /* wptListView.cpp - Dynamic list view control
2   *      Copyright (C) 2000-2004 Timo Schulz   *      Copyright (C) 2000-2005 Timo Schulz
3   *      Copyright (C) 2004 Andreas Jobs   *      Copyright (C) 2004 Andreas Jobs
4   *   *
5   * This file is part of WinPT.   * This file is part of WinPT.
# Line 18  Line 18 
18   * along with WinPT; if not, write to the Free Software Foundation,   * along with WinPT; if not, write to the Free Software Foundation,
19   * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA   * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20   */   */
   
21  #include <stdio.h>  #include <stdio.h>
22  #include <windows.h>  #include <windows.h>
23  #include <commctrl.h>  #include <commctrl.h>
# Line 115  listview_add_item( listview_ctrl_t ctx, Line 114  listview_add_item( listview_ctrl_t ctx,
114    
115    
116  int  int
117  listview_add_item2( listview_ctrl_t ctx, const char * text, void * magic )  listview_add_item2 (listview_ctrl_t ctx, const char *text, void *magic)
118  {  {
119      int rc = 0;      int rc = 0;
120      LV_ITEM lvi;      LV_ITEM lvi;
# Line 132  listview_add_item2( listview_ctrl_t ctx, Line 131  listview_add_item2( listview_ctrl_t ctx,
131  } /* listview_add_item2 */  } /* listview_add_item2 */
132    
133    
134    void*
135    listview_get_item2 (listview_ctrl_t ctx, int pos)
136    {
137        LVITEM lvi;
138    
139        memset (&lvi, 0, sizeof lvi);
140        lvi.mask = LVIF_PARAM;
141        lvi.iItem = pos;
142        ListView_GetItem (ctx->ctrl, &lvi);
143        return (void*)lvi.lParam;
144    }
145    
146    int
147    listview_set_item2 (listview_ctrl_t ctx, int pos, void *magic)
148    {
149        LVITEM lvi;
150    
151        memset (&lvi, 0, sizeof (lvi));
152        lvi.mask = LVIF_PARAM;
153        lvi.iItem = pos;
154        lvi.lParam = (LPARAM)magic;
155        if (ListView_SetItem (ctx->ctrl, &lvi) == -1)
156            return 1;
157        return 0;
158    }
159    
160    
161  void  void
162  listview_add_sub_item( listview_ctrl_t ctx, int pos, int col, const char *text )  listview_add_sub_item( listview_ctrl_t ctx, int pos, int col, const char *text )
163  {        {      
# Line 289  listview_select_one (listview_ctrl_t ctx Line 315  listview_select_one (listview_ctrl_t ctx
315  }  }
316    
317    
318    void
319    listview_scroll (listview_ctrl_t ctx, int oldpos, int newpos)
320    {    
321        const int size=14;
322        
323        if (oldpos == -1)
324            oldpos = 0;
325        //log_box ("debug", 0, "oldpos=%d newpos=%d diff=%d", oldpos, newpos, newpos-oldpos);
326        ListView_Scroll (ctx->ctrl, 0, (newpos-oldpos)*size);
327    }
328    
329    
330  int  int
331  listview_find (listview_ctrl_t ctx, const char * str)  listview_find (listview_ctrl_t ctx, const char * str)
332  {  {
333      LVFINDINFO inf;      LVFINDINFO inf;
334      int pos;      int pos;
335    
336      memset (&inf, 0, sizeof inf);      memset (&inf, 0, sizeof (inf));
337      inf.flags = LVFI_STRING|LVFI_PARTIAL;      inf.flags = LVFI_STRING|LVFI_PARTIAL;
338      inf.psz = str;      inf.psz = str;
339      pos = ListView_FindItem (ctx->ctrl, -1, &inf);      pos = ListView_FindItem (ctx->ctrl, -1, &inf);

Legend:
Removed from v.20  
changed lines
  Added in v.22

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26