ListBrowser - inverse the selection state

3 posts / 0 new
Last post
JosDuchIt
JosDuchIt's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-01-08 20:57
ListBrowser - inverse the selection state
I am gettin ideas how to inverse the selection state in a listbrowser, but none seems straightforward. Id someone has programmed such functionality, i would be glad to know how.
salass00
salass00's picture
Offline
Last seen: 4 days 12 hours ago
Joined: 2011-02-03 11:27
I haven't tested it but this
I haven't tested it but this function should do what you want:
  1. void InvertListBrowser(Object *wnd, Object *lb) {
  2. struct Window *window;
  3. struct List *list;
  4. struct Node *node;
  5. uint32 selected;
  6.  
  7. // get list
  8. IIntuition->GetAttr(LISTBROWSER_Labels, lb, (uint32 *)&list);
  9.  
  10. // remove list
  11. IIntuition->SetAttrs(lb, LISTBROWSER_Labels, ~0, TAG_END);
  12.  
  13. // make changes
  14. for (node = list->lh_Head; node->ln_Succ; node = node->ln_Succ) {
  15. selected = FALSE;
  16. IListBrowser->GetListBrowserNodeAttrs(node,
  17. LBNA_Selected, &selected,
  18. TAG_END);
  19. IListBrowser->SetListBrowserNodeAttrs(node,
  20. LBNA_Selected, !selected,
  21. TAG_END);
  22. }
  23.  
  24. // get intuition window pointer
  25. window = NULL;
  26. IIntuition->GetAttr(WINDOW_Window, wnd, (uint32)&window);
  27.  
  28. // readd list and refresh
  29. IIntuition->SetGadgetAttrs((struct Gadget *)lb, window, NULL,
  30. LISTBROWSER_Labels, list,
  31. TAG_END);
  32. }
JosDuchIt
JosDuchIt's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-01-08 20:57
@salss00 Worked out of the
@salss00 Worked out of the box. So much more simple than i imagined Thanks a lot
Log in or register to post comments