/[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 174 by twoaday, Thu Feb 2 08:20:50 2006 UTC revision 205 by twoaday, Thu Apr 27 12:46:03 2006 UTC
# Line 34  Line 34 
34  #include "wptTypes.h"  #include "wptTypes.h"
35  #include "wptGPG.h"  #include "wptGPG.h"
36  #include "wptKeylist.h"  #include "wptKeylist.h"
37    #include "wptUTF8.h"
38  #include "resource.h"  #include "resource.h"
39    
40    
# Line 67  listview_release (listview_ctrl_t ctx) Line 68  listview_release (listview_ctrl_t ctx)
68      if (ctx->hil)      if (ctx->hil)
69          ImageList_Destroy (ctx->hil);          ImageList_Destroy (ctx->hil);
70      delete ctx;      delete ctx;
71  } /* listview_release */  }
72    
73    
74    int
75    listview_set_column_width (listview_ctrl_t ctx, int col, int width)
76    {
77        LVCOLUMN lvc;
78    
79        memset (&lvc, 0, sizeof (lvc));
80        lvc.mask = LVCF_WIDTH;
81        lvc.cx = width;
82        ListView_SetColumn (ctx->ctrl, col, &lvc);
83        return 0;
84    }
85    
86    
87  int  int
# Line 86  listview_add_column (listview_ctrl_t ctx Line 100  listview_add_column (listview_ctrl_t ctx
100          rc = 1;          rc = 1;
101      ctx->cols++;      ctx->cols++;
102      return rc;      return rc;
103  } /* listview_add_column */  }
104    
105    
106  int  int
# Line 118  listview_add_item( listview_ctrl_t ctx, Line 132  listview_add_item( listview_ctrl_t ctx,
132          rc = 1;          rc = 1;
133      ctx->items++;      ctx->items++;
134      return rc;      return rc;
135  } /* listview_add_item */  }
136    
137    
138  int  int
# Line 154  listview_add_item2 (listview_ctrl_t ctx, Line 168  listview_add_item2 (listview_ctrl_t ctx,
168          rc = 1;          rc = 1;
169      ctx->items++;      ctx->items++;
170      return rc;      return rc;
171  } /* listview_add_item2 */  }
172    
173    
174  void*  void*
# Line 185  listview_set_item2 (listview_ctrl_t ctx, Line 199  listview_set_item2 (listview_ctrl_t ctx,
199    
200    
201  void  void
202  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)
203  {        {
204      ListView_SetItemText( ctx->ctrl, pos, col, (char *)text );      ListView_SetItemText (ctx->ctrl, pos, col, (char*)text);
205  } /* listview_add_sub_item */  }
206    
207    
208  int  int
# Line 199  listview_count_items( listview_ctrl_t ct Line 213  listview_count_items( listview_ctrl_t ct
213      n = curr_sel? ListView_GetSelectedCount( ctx->ctrl ) :          n = curr_sel? ListView_GetSelectedCount( ctx->ctrl ) :    
214                    ListView_GetItemCount( ctx->ctrl );                    ListView_GetItemCount( ctx->ctrl );
215      return n;      return n;
216  } /* listview_count_items */  }
217    
218    
219  int  int
# Line 248  listview_del_all_items (listview_ctrl_t Line 262  listview_del_all_items (listview_ctrl_t
262  }  }
263    
264    
265    /* Return the index of the selected item.
266       Support both selections and checkboxes. */
267    int
268    listview_get_selected_item (listview_ctrl_t lv)
269    {
270        int pos, i;
271        
272        pos = listview_get_curr_pos (lv);
273        if (pos != -1)
274            return pos;
275        for (i=0; i < listview_count_items (lv, 0); i++) {
276            if (listview_get_item_state (lv, i))
277                return i;
278        }
279        return -1;
280    }
281    
282    
283  /* Return if the given element is selected or if the ext  /* Return if the given element is selected or if the ext
284     style is used, if the checkbox is activated. */     style is used, if the checkbox is activated. */
285  int  int
# Line 305  listview_sort_items( listview_ctrl_t ctx Line 337  listview_sort_items( listview_ctrl_t ctx
337                                      IMI_SORT_DOWNARROW : IMI_SORT_UPARROW);                                      IMI_SORT_DOWNARROW : IMI_SORT_UPARROW);
338      Header_SetItem (hheader, idx, &hdi);      Header_SetItem (hheader, idx, &hdi);
339      return 0;      return 0;
340  } /* listview_sort_items */  }
341    
342    
343  int  int
344  listview_get_curr_pos( listview_ctrl_t ctx )  listview_get_curr_pos( listview_ctrl_t ctx )
345  {        {      
346      return ListView_GetNextItem( ctx->ctrl, -1, LVNI_SELECTED );      return ListView_GetNextItem( ctx->ctrl, -1, LVNI_SELECTED );
347  } /* listview_get_curr_pos */  }
348    
349    
350  int  int
# Line 326  listview_get_item_text (listview_ctrl_t Line 358  listview_get_item_text (listview_ctrl_t
358      }      }
359      ListView_GetItemText (ctx->ctrl, pos, col, text, maxbytes);      ListView_GetItemText (ctx->ctrl, pos, col, text, maxbytes);
360      return 0;      return 0;
361  } /* listview_get_item_text */  }
362    
363    
364  /* Use extended style with checkboxes for each item. */  /* Use extended style with checkboxes for each item. */
# Line 350  int Line 382  int
382  listview_set_column_order( listview_ctrl_t ctx, int *array )  listview_set_column_order( listview_ctrl_t ctx, int *array )
383  {        {      
384      return ListView_SetColumnOrderArray( ctx->ctrl, ctx->cols, array );      return ListView_SetColumnOrderArray( ctx->ctrl, ctx->cols, array );
385  } /* listview_set_column_order */  }
386    
387    
388  void  void
389  listview_select_all (listview_ctrl_t ctx)  listview_select_all (listview_ctrl_t ctx)
390  {        {      
391      ListView_SetItemState( ctx->ctrl, -1, LVIS_SELECTED, LVIS_SELECTED );      ListView_SetItemState( ctx->ctrl, -1, LVIS_SELECTED, LVIS_SELECTED );
392  } /* listview_select_all */  }
393    
394    
395  void  void
# Line 410  listview_setview (listview_ctrl_t ctx, D Line 442  listview_setview (listview_ctrl_t ctx, D
442    
443    
444  void  void
445  listview_set_image_list (listview_ctrl_t ctx, HICON *ico, DWORD nicons)  listview_set_image_list (listview_ctrl_t ctx, int cx, int cy,
446                             HICON *ico, DWORD nicons)
447  {  {
448      HIMAGELIST hil;      HIMAGELIST hil;
449      DWORD i;      DWORD i;
450    
451      hil = ImageList_Create (16, 16, ILC_COLOR8|ILC_MASK, nicons, 1);      if (cx == 0 || cy == 0)
452            cx = cy = 16;
453    
454        hil = ImageList_Create (cx, cy, ILC_COLOR8|ILC_MASK, nicons, 1);
455      ImageList_SetBkColor (hil, CLR_NONE);      ImageList_SetBkColor (hil, CLR_NONE);
456      for (i=0; i < nicons; i++)      for (i=0; i < nicons; i++)
457          ImageList_AddIcon (hil, ico[i]);              ImageList_AddIcon (hil, ico[i]);    
458      ListView_SetImageList (ctx->ctrl, hil, LVSIL_SMALL);          ListView_SetImageList (ctx->ctrl, hil, LVSIL_SMALL);    
459  }  }
       

Legend:
Removed from v.174  
changed lines
  Added in v.205

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26