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

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26