433
cfgui_remove_item(HWND hwtv,
435
khui_config_node node;
439
for (hChild = TreeView_GetChild(hwtv, hItem);
441
hChild = TreeView_GetChild(hwtv, hItem)) {
443
cfgui_remove_item(hwtv, hChild);
447
ZeroMemory(&itemex, sizeof(itemex));
449
itemex.mask = TVIF_PARAM;
450
itemex.hItem = hItem;
452
TreeView_GetChild(hwtv, &itemex);
454
node = (khui_config_node) itemex.lParam;
458
hw = khui_cfg_get_hwnd(node);
463
khui_cfg_release(node);
466
TreeView_DeleteItem(hwtv, hItem);
469
struct cfgui_child_info {
471
khui_config_node node;
475
#define CI_ALLOC_INCR 8
478
cfgui_sync_node(cfgui_wnd_data * d,
482
khui_config_node child;
484
struct cfgui_child_info * childinfo = NULL;
485
khm_size n_childinfo = 0;
486
khm_size nc_childinfo = 0;
489
/* first, get the list of children from the treeview control */
490
for (hChild = TreeView_GetChild(hwtv, hItem);
492
hChild = TreeView_GetNextSibling(hwtv, hChild)) {
494
if (n_childinfo >= nc_childinfo) {
495
nc_childinfo = UBOUNDSS(n_childinfo + 1,
496
CI_ALLOC_INCR, CI_ALLOC_INCR);
498
assert(nc_childinfo > n_childinfo);
500
childinfo = PREALLOC(childinfo,
501
sizeof(*childinfo) * nc_childinfo);
507
ZeroMemory(&childinfo[n_childinfo],
508
sizeof(childinfo[n_childinfo]));
510
childinfo[n_childinfo].hItem = hChild;
511
childinfo[n_childinfo].checked = FALSE;
515
/* now, go through the list of actual nodes and make sure they
518
for (khui_cfg_get_first_child(c, &child);
520
khui_cfg_get_next_release(&child)) {
522
hChild = (HTREEITEM) khui_cfg_get_param(child);
524
for (i=0; i < n_childinfo; i++) {
525
if (childinfo[i].hItem == hChild)
529
if (i < n_childinfo) {
530
childinfo[i].checked = TRUE;
532
/* add it to the list, so we can create the node in the
533
tree view control later. */
534
if (n_childinfo >= nc_childinfo) {
535
nc_childinfo = UBOUNDSS(n_childinfo + 1,
536
CI_ALLOC_INCR, CI_ALLOC_INCR);
538
assert(nc_childinfo > n_childinfo);
540
childinfo = PREALLOC(childinfo,
541
sizeof(*childinfo) * nc_childinfo);
547
ZeroMemory(&childinfo[n_childinfo],
548
sizeof(childinfo[n_childinfo]));
550
childinfo[n_childinfo].node = child;
551
khui_cfg_hold(child);
556
/* by this point, the childinfo list contains items of the
559
1. childinfo[i].hItem != NULL && childinfo[i].checked == TRUE
561
Corresponds to a tree view item that has a matching
562
configuration node. Nothing to do here.
564
2. childinfo[i].hItem != NULL && childinfo[i].checked == FALSE
566
Corresponds to a tree view item that has no matching
567
configuration node. These should be removed.
569
3. childinfo[i].hItem == NULL && childinfo[i].node != NULL
571
Corresponds to a configuration node that has no matching
572
tree view item. These nodes should be added.
575
/* first do the removals */
576
for (i=0; i < n_childinfo; i++) {
577
if (childinfo[i].hItem == NULL)
578
break; /* nothing more to see from this point
580
if (!childinfo[i].checked) {
582
cfgui_remove_item(hwtv, childinfo[i].hItem);
586
/* continue from where the previous loop left off */
587
for (; i < n_childinfo; i++) {
589
assert(childinfo[i].hItem == NULL);
590
assert(childinfo[i].node != NULL);
593
cfgui_add_node(d, hwtv, childinfo[i].node, c, FALSE);
595
khui_cfg_release(childinfo[i].node);
596
childinfo[i].node = NULL;
602
/* finally recurse through to the next level */
603
for (hChild = TreeView_GetChild(hwtv, hItem);
605
hChild = TreeView_GetNextSibling(hwtv, hChild)) {
609
ZeroMemory(&itemex, sizeof(itemex));
611
itemex.mask = TVIF_PARAM;
612
itemex.hItem = hChild;
614
TreeView_GetItem(hwtv, &itemex);
617
child = (khui_config_node) itemex.lParam;
619
cfgui_sync_node(d, hwtv, child, hChild);
625
cfgui_sync_node_list(cfgui_wnd_data * d, HWND hwnd) {
629
hwtv = GetDlgItem(hwnd, IDC_CFG_NODELIST);
630
hItem = TreeView_GetRoot(hwtv);
632
cfgui_sync_node(d, hwtv, NULL, hItem);
426
636
cfgui_update_state(HWND hwnd,
428
638
khui_config_node node) {