📄 vboxc.c
字号:
item.AddLabelChangeCallback ((CallbackFn *)ItemLabelChanged, this); item.AddPixmapChangeCallback((CallbackFn *)ItemPixmapChanged, this);//// Add it to the list// items.append(&item);//// If it passes the filter, add it to the visible list and/or selected list// if ( !filtFunc ) { visItems.add(&item); } else { if ( filterOutput == DISPLAY_FILTER_OUTPUT ) { if ( (*filtFunc)(item) ) { visItems.add(&item); } } else /* if ( filterOutput == SELECT_FILTER_OUTPUT ) */ { visItems.add(&item); if ( (*filtFunc)(item) ) { selItems.append(&item); } } }} // End _AddItem/*----------------------------------------------------------------------- * Add new items to this view box */voidVBoxC::AddItems(VItemListC& list){//// Remove items we already know about// VItemListC newItems; unsigned count = list.size(); int i; for (i=0; i<count; i++) { VItemC *item = list[i]; if ( !items.includes(item) ) newItems.add(item); } if ( newItems.size() == 0 ) return; PartialSelect(True);//// Add items// count = newItems.size(); for (i=0; i<count; i++) { VItemC *item = newItems[i]; _AddItem(*item); if ( selItems.includes(item) ) { item->CallSelectCallbacks(); } }//// Add items to current view// if ( realized && view ) view->AddItems(list); PartialSelect(False); changed = True;} // End AddItems/*----------------------------------------------------------------------- * Public method to add a new selected item to this view box */voidVBoxC::AddItemSelected(VItemC& item, Boolean notify){ if ( items.includes(&item) ) return;//// Add it to the lists// _AddItem(item);//// If it is not in the selected list, add it// if ( !selItems.includes(&item) ) { selItems.append(&item); }//// Add it to the current view// if ( realized && view ) view->AddItem(item); if ( notify ) item.CallSelectCallbacks(); FinishSelect(); changed = True;} // End AddItemSelected/*----------------------------------------------------------------------- * Add new selected items to this view box */voidVBoxC::AddItemsSelected(VItemListC& list, Boolean notify){//// Remove items we already know about// VItemListC newItems; unsigned count = list.size(); int i; for (i=0; i<count; i++) { VItemC *item = list[i]; if ( !items.includes(item) ) newItems.add(item); } if ( newItems.size() == 0 ) return; PartialSelect(True); count = newItems.size(); for (i=0; i<count; i++) AddItemSelected(*list[i], notify);//// Add items to the current view// if ( realized && view ) view->AddItems(list); PartialSelect(False); changed = True;} // End AddItemsSelected/*----------------------------------------------------------------------- * Public method to select the given item */voidVBoxC::SelectItem(VItemC& item, Boolean notify){//// Return if this item is already selected or is not visible// if ( selItems.includes(&item) || !visItems.includes(&item) ) return;//// Add this item to the selected list// selItems.append(&item);//// Redraw this item in the current view// changed = True; if ( realized && view ) view->RedrawItem(item);//// Call the selection callbacks for the item// if ( notify ) item.CallSelectCallbacks();//// Perform final updates after selection// FinishSelect();} // End SelectItem/*----------------------------------------------------------------------- * Select the given items */voidVBoxC::SelectItems(VItemListC& list, Boolean notify){ unsigned count = list.size(); if ( count == 0 ) return; if ( count == 1 ) SelectItem(*list[0], notify); else { PartialSelect(True); for (int i=0; i<count; i++) SelectItem(*list[i], notify); PartialSelect(False); }} // End SelectItems/*----------------------------------------------------------------------- * Select the given item and deselect all others */voidVBoxC::SelectItemOnly(VItemC& item, Boolean notify){//// Loop through selected list and deselect all items except this one// if ( selItems.includes(&item) ) { VItemListC deselectList; unsigned count = selItems.size(); for (int i=0; i<count; i++) { VItemC *sitem = selItems[i]; if ( sitem != &item ) deselectList.append(sitem); } count = deselectList.size(); if ( count == 1 ) DeselectItem(*deselectList[0], notify); else DeselectItems(deselectList, notify); }//// Item is not selected, so deselect them all and select this one// else { if ( selItems.size() <= 1 ) { if ( selItems.size() == 1 ) DeselectItem(*selItems[0], notify); SelectItem(item, notify); } else { PartialSelect(True); DeselectAllItems(notify); SelectItem(item, notify); PartialSelect(False); } } // End if item not already selected} // End SelectItemOnly/*----------------------------------------------------------------------- * Select the given items and deselect all others */voidVBoxC::SelectItemsOnly(VItemListC& list, Boolean notify){ if ( list.size() == 1 ) SelectItemOnly(*list[0], notify); else { PartialSelect(True);//// Loop through selected list and deselect all items except the requested ones// VItemListC deselectList; u_int count = selItems.size(); for (int i=0; i<count; i++) { VItemC *item = selItems[i]; if ( !list.includes(item) ) { deselectList.append(item); } } count = deselectList.size(); if ( count == 1 ) DeselectItem(*deselectList[0], notify); else DeselectItems(deselectList, notify);//// Now select the requested items// SelectItems(list, notify); PartialSelect(False); }} // End SelectItemsOnly/*----------------------------------------------------------------------- * Public method to deselect the given item */voidVBoxC::DeselectItem(VItemC& item, Boolean notify){//// Return if this item is not selected// if ( !selItems.includes(&item) ) return;//// Remove this item from the selected list// selItems.remove(&item);//// Redraw this item in the current view// changed = True; if ( realized && view ) view->RedrawItem(item);//// Call the deselection callbacks for the item// if ( notify ) item.CallDeselectCallbacks();//// Perform final updates after deselection// FinishSelect();} // End DeselectItem/*----------------------------------------------------------------------- * Deselect the given items */voidVBoxC::DeselectItems(VItemListC& list, Boolean notify){ u_int count = list.size(); if ( count == 0 ) return; if ( count == 1 ) DeselectItem(*list[0], notify); else { PartialSelect(True); for (int i=0; i<count; i++) DeselectItem(*list[i], notify); PartialSelect(False); }} // End DeselectItems/*----------------------------------------------------------------------- * Select all unselected items */voidVBoxC::SelectAllItems(Boolean notify){ SelectItems(visItems, notify);}/*----------------------------------------------------------------------- * Deselect all selected items */voidVBoxC::DeselectAllItems(Boolean notify){ u_int count = selItems.size(); if ( count == 0 ) return; if ( count == 1 ) DeselectItem(*selItems[0], notify); else {//// Copy the selected list since it will get modified in the process// Copy it in reverse order so that items will be removed from the end// VItemListC deselItems; for (int i=count-1; i>=0; i--) deselItems.append(selItems[i]); DeselectItems(deselItems, notify); }} // End DeselectAllItems/*----------------------------------------------------------------------- * Toggle the selection of the given item */voidVBoxC::ToggleItem(VItemC& item, Boolean notify){//// Deselect if selected// if ( selItems.includes(&item) ) { DeselectItem(item, notify); } else { SelectItem(item, notify); }} // End ToggleItem/*----------------------------------------------------------------------- * Toggle the selection of the given items */voidVBoxC::ToggleItems(VItemListC& list, Boolean notify){ PartialSelect(True); unsigned count = list.size(); for (int i=0; i<count; i++) { VItemC *item = list[i]; ToggleItem(*item, notify); } PartialSelect(False);} // End ToggleItems/*----------------------------------------------------------------------- * Make an item visible */voidVBoxC::ShowItem(VItemC& item){//// Return if already visible// if ( visItems.includes(&item) ) return;//// Add item to list// visItems.add(&item);//// Tell current view about change// if ( realized && view ) view->ChangeItemVis(item); changed = True;} // End ShowItem/*----------------------------------------------------------------------- * Make several items visible */voidVBoxC::ShowItems(VItemListC& list){//// Set visibility for each item// unsigned count = list.size(); for (int i=0; i<count; i++) { ShowItem(*list[i]); }} // End ShowItems/*----------------------------------------------------------------------- * Make an item invisible */voidVBoxC::HideItem(VItemC& item){//// Return if not currently visible// if ( !visItems.includes(&item) ) return;//// Remove item from list// visItems.remove(&item);//// Tell current view about change// if ( realized && view ) view->ChangeItemVis(item); changed = True;} // End HideItem/*----------------------------------------------------------------------- * Make several items invisible */voidVBoxC::HideItems(VItemListC& list){//// Remove items from visible list// unsigned count = list.size(); int i; for (i=0; i<count; i++) { visItems.remove(list[i]); }//// Tell current view about change// if ( realized && view ) { //view->ChangeItemVis(); for (i=0; i<count; i++) view->ChangeItemVis(*list[i]); } changed = True;} // End HideItems/*----------------------------------------------------------------------- * Open the given item */voidVBoxC::OpenItem(VItemC& item){//// Call the open callbacks for the item// item.CallOpenCallbacks();} // End OpenItem/*----------------------------------------------------------------------- * Refresh the box */voidVBoxC::Refresh(){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -