- Timestamp:
- Mar 14, 2000, 7:27:25 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/listbox.cpp
r3108 r3117 1 /* $Id: listbox.cpp,v 1.2 1 2000-03-14 15:00:59 sandervlExp $ */1 /* $Id: listbox.cpp,v 1.22 2000-03-14 18:27:25 cbratschi Exp $ */ 2 2 /* 3 3 * Listbox controls … … 18 18 #include "combo.h" 19 19 #include <misc.h> 20 #include "heapstring.h" 20 21 21 22 #define DBG_LOCALLOG DBG_listbox … … 53 54 typedef struct 54 55 { 55 LPSTR 56 LPSTR str; /* Item text */ 56 57 BOOL selected; /* Is item selected? */ 57 58 UINT height; /* Item height (only for OWNERDRAWVARIABLE) */ 58 DWORD 59 DWORD data; /* User data */ 59 60 } LB_ITEMDATA; 60 61 … … 84 85 BOOL in_focus; 85 86 HFONT font; /* Current font */ 86 LCID 87 LPHEADCOMBO 87 LCID locale; /* Current locale for string comparisons */ 88 LPHEADCOMBO lphc; /* ComboLBox */ 88 89 } LB_DESCR; 89 90 … … 94 95 #define HAS_STRINGS(descr) \ 95 96 (!IS_OWNERDRAW(descr) || ((descr)->style & LBS_HASSTRINGS)) 97 98 #define HAS_NODATA(descr) \ 99 ((descr)->style & LBS_NODATA) 96 100 97 101 #define IS_MULTISELECT(descr) \ … … 1366 1370 } 1367 1371 1368 //CB: helper from wine/memory/heap.c1369 1370 LPSTR HEAP_strdupA( HANDLE heap, DWORD flags, LPCSTR str )1371 {1372 LPSTR p = (LPSTR)HeapAlloc(heap,flags,strlen(str)+1);1373 1374 strcpy(p,str);1375 return p;1376 }1377 1378 1379 1372 /*********************************************************************** 1380 1373 * LISTBOX_InsertString … … 1533 1526 LRESULT ret; 1534 1527 1535 if (HAS_STRINGS(descr) ) return LB_ERR;1536 /* FIXME: this is far from optimal... */ 1528 if (HAS_STRINGS(descr) || !HAS_NODATA(descr)) return LB_ERR; 1529 1537 1530 if (count > descr->nb_items) 1538 1531 { 1539 while (count > descr->nb_items) 1540 if ((ret = LISTBOX_InsertString( hwnd, descr, -1, 0 )) < 0) 1541 return ret; 1542 } 1543 else if (count < descr->nb_items) 1544 { 1545 while (count < descr->nb_items) 1546 if ((ret = LISTBOX_RemoveItem( hwnd, descr, -1 )) < 0) 1547 return ret; 1548 } 1532 LB_ITEMDATA *item; 1533 INT max_items,index; 1534 UINT id = (descr->lphc) ? ID_CB_LISTBOX:GetWindowLongA(hwnd,GWL_ID); 1535 1536 max_items = count+LB_ARRAY_GRANULARITY-(count % LB_ARRAY_GRANULARITY); 1537 if (!(item = (LB_ITEMDATA*)HeapReAlloc(descr->heap,0,descr->items,max_items*sizeof(LB_ITEMDATA)))) 1538 { 1539 SEND_NOTIFICATION( hwnd, descr, LBN_ERRSPACE ); 1540 return LB_ERRSPACE; 1541 } 1542 descr->items = item; 1543 1544 /* Insert the item structure */ 1545 1546 index = descr->nb_items-1; 1547 while (count > descr->nb_items) 1548 { 1549 index++; 1550 item = &descr->items[index]; 1551 1552 item->str = ""; 1553 item->data = 0; 1554 item->height = 0; 1555 item->selected = FALSE; 1556 descr->nb_items++; 1557 1558 /* Get item height */ 1559 1560 if (descr->style & LBS_OWNERDRAWVARIABLE) 1561 { 1562 MEASUREITEMSTRUCT mis; 1563 1564 mis.CtlType = ODT_LISTBOX; 1565 mis.CtlID = id; 1566 mis.itemID = index; 1567 mis.itemData = descr->items[index].data; 1568 mis.itemHeight = descr->item_height; 1569 SendMessageA( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis ); 1570 item->height = mis.itemHeight ? mis.itemHeight : 1; 1571 } 1572 } 1573 } else if (count < descr->nb_items) 1574 { 1575 descr->nb_items = count; 1576 if (descr->selected_item >= count) descr->selected_item = count-1; 1577 if (descr->focus_item >= count) descr-> focus_item = count-1; 1578 } 1579 /* Repaint the items */ 1580 1581 LISTBOX_UpdateScroll( hwnd, descr ); 1582 InvalidateRect(hwnd,NULL,TRUE); 1583 1549 1584 return LB_OKAY; 1550 1585 }
Note:
See TracChangeset
for help on using the changeset viewer.