HTREEITEM FolderTree::SetSelectedPath(const tstring &sPath, bool bExpanded /* = false */) { tstring sSearch = sPath; sSearch = Text::toLower(sSearch); int nSearchLength = sSearch.size(); if(nSearchLength == 0) { //TRACE(_T("Cannot select a empty path\n")); return NULL; } //Remove initial part of path if the root folder is setup tstring sRootFolder = m_sRootFolder; sRootFolder = Text::toLower(sRootFolder); int nRootLength = sRootFolder.size(); if (nRootLength) { if(sSearch.find(sRootFolder) != 0) { //TRACE(_T("Could not select the path %s as the root has been configued as %s\n"), sPath, m_sRootFolder); return NULL; } sSearch = sSearch.substr(nRootLength); } //Remove trailing "\" from the path nSearchLength = sSearch.size(); if (nSearchLength > 3 && sSearch[nSearchLength-1] == _T('\\')) sSearch = sSearch.substr(0, nSearchLength-1); if (sSearch.empty()) return NULL; SetRedraw(FALSE); HTREEITEM hItemFound = TVI_ROOT; if (nRootLength && m_hRootedFolder) hItemFound = m_hRootedFolder; bool bDriveMatch = sRootFolder.empty(); bool bNetworkMatch = m_bDisplayNetwork && ((sSearch.size() > 2) && sSearch.find(_T("\\\\")) == 0); if (bNetworkMatch) { bDriveMatch = false; //Working here bool bHasPlus = HasPlusButton(m_hNetworkRoot); bool bHasChildren = (GetChildItem(m_hNetworkRoot) != NULL); if (bHasPlus && !bHasChildren) DoExpand(m_hNetworkRoot); else Expand(m_hNetworkRoot, TVE_EXPAND); hItemFound = FindServersNode(m_hNetworkRoot); sSearch = sSearch.substr(2); } if (bDriveMatch) { if (m_hMyComputerRoot) { //Working here bool bHasPlus = HasPlusButton(m_hMyComputerRoot); bool bHasChildren = (GetChildItem(m_hMyComputerRoot) != NULL); if (bHasPlus && !bHasChildren) DoExpand(m_hMyComputerRoot); else Expand(m_hMyComputerRoot, TVE_EXPAND); hItemFound = m_hMyComputerRoot; } } int nFound = sSearch.find(_T('\\')); while(nFound != tstring::npos) { tstring sMatch; if (bDriveMatch) { sMatch = sSearch.substr(0, nFound + 1); bDriveMatch = false; } else sMatch = sSearch.substr(0, nFound); hItemFound = FindSibling(hItemFound, sMatch); if (hItemFound == NULL) break; else if (!IsDrive(sPath)) { SelectItem(hItemFound); //Working here bool bHasPlus = HasPlusButton(hItemFound); bool bHasChildren = (GetChildItem(hItemFound) != NULL); if (bHasPlus && !bHasChildren) DoExpand(hItemFound); else Expand(hItemFound, TVE_EXPAND); } sSearch = sSearch.substr(nFound - 1); nFound = sSearch.find(_T('\\')); }; //The last item if (hItemFound) { if (sSearch.size()) hItemFound = FindSibling(hItemFound, sSearch); if (hItemFound) SelectItem(hItemFound); if (bExpanded) { //Working here bool bHasPlus = HasPlusButton(hItemFound); bool bHasChildren = (GetChildItem(hItemFound) != NULL); if (bHasPlus && !bHasChildren) DoExpand(hItemFound); else Expand(hItemFound, TVE_EXPAND); } } //Turn back on the redraw flag SetRedraw(TRUE); return hItemFound; }
HTREEITEM CInspectorTreeCtrl::selectFromPoint(CPoint & point) { HTREEITEM hitItem = HitTest(point); if(hitItem && hitItem != GetSelectedItem()) SelectItem(hitItem); return hitItem; }
void CDropDownUI::Init() { if( m_iCurSel < 0 ) SelectItem(0); }
bool TabBox::SelectItem(const std::wstring& pControlName) { Control* pControl = FindSubControl(pControlName); ASSERT(pControl); return SelectItem(pControl); }
// OnKeyDown(): // Called on a key-down event. This stores the state of // the modifiers and actually processes the keystrokes. void OnKeyDown(LWPanelID panel, void *data, DualKey key) { if( key == DK_SHIFT ) fk_int->shift_down = true; if( key == DK_CTRL ) fk_int->ctrl_down = true; if( key == DK_ALT ) { if( fk_int->draw_bbox && !fk_int->alt_down ) { fk_int->quickdraw_item_list = true; fk_int->RedrawItemList(); } fk_int->alt_down = true; } fk_int->last_key_down = key; // Used to move list up/down int list_height = CON_H( fk_int->item_list ) - 20; list_height = (list_height/ fk_int->dd.item_height); int max_top = fk_int->sorted_items.NumElements() - list_height; int value; static bool last_was_folded = false; // Used to determine what to do on a Fold/Unfold All switch( fk_int->last_key_down ) { case -1: // No key deperessed, do nothing break; case DK_SC_UP: if( fk_int->shift_down ) { // Jump to the top of the Item List fk->SetTopItem( 0 ); SET_INT( fk_int->item_scroll, fk->GetTopItem() ); fk_int->RedrawItemList(); } else if( fk_int->alt_down && fk_int->ctrl_down ) { ; } else if( fk_int->alt_down ) { // Scroll Group List Up (1 element) GET_INT( fk_int->group_list, value ); if( value > 0 ) { SET_INT( fk_int->group_list, --value ); OnGroupList( fk_int->group_list, fk_int ); } } else if( fk_int->ctrl_down ) { fk->SetTopItem( fk->GetTopItem() - list_height ); if( fk->GetTopItem() < 0 ) fk->SetTopItem( 0 ); SET_INT( fk_int->item_scroll, fk->GetTopItem() ); fk_int->RedrawItemList(); } else { // Scroll Item List Up (1 element) fk->SetTopItem( fk->GetTopItem() - 1 ); if( fk->GetTopItem() < 0 ) fk->SetTopItem( 0 ); else { SET_INT( fk_int->item_scroll, fk->GetTopItem() ); fk_int->RedrawItemList(); } } break; case DK_SC_DOWN: if( fk_int->shift_down ) { // Jump to the bottom of the Item List fk->SetTopItem( max_top ); SET_INT( fk_int->item_scroll, fk->GetTopItem() ); fk_int->RedrawItemList(); } else if( fk_int->alt_down && fk_int->ctrl_down ) { ; } else if( fk_int->alt_down ) { // Scroll Group List Down (1 element) GET_INT( fk_int->group_list, value ); if( value < (int)fk->GetGroupList().NumElements() - 2 ) { // Don't go to (new group)! SET_INT( fk_int->group_list, ++value ); OnGroupList( fk_int->group_list, fk_int ); } } else if( fk_int->ctrl_down ) { // Scroll Item List Down (1 page) fk->SetTopItem( fk->GetTopItem() + list_height ); if( fk->GetTopItem() > max_top ) fk->SetTopItem( max_top ); SET_INT( fk_int->item_scroll, fk->GetTopItem() ); fk_int->RedrawItemList(); } else { // Scroll Item List Down (1 element) fk->SetTopItem( fk->GetTopItem() + 1 ); if( fk->GetTopItem() > max_top ) fk->SetTopItem( max_top ); else { SET_INT( fk_int->item_scroll, fk->GetTopItem() ); fk_int->RedrawItemList(); } } break; case DK_RETURN: case DK_PAD_ENTER: case '\r': if( fk_int->shift_down ) // Add selected to group (Apply) OnGroupEditApply( fk_int->group_edit_apply, fk_int ); else // Add to selection (Apply) OnApplySelection( fk_int->apply_select_item_name, fk_int ); break; case DK_F1: // Keyboard Help case DK_HELP: OnF1( fk_int->f1, fk_int ); break; case DK_CHAR('='): // Add a New Group case DK_CHAR('+'): fk->SetCurrentGroup( fk->GetGroupList().NumElements() - 1 ); OnGroupList( fk_int->group_list, fk_int ); break; case DK_CHAR('-'): // Remove an Existing Group OnGroupDel( fk_int->group_delete, fk_int ); break; case DK_CHAR('['): // Scroll Selection Mode Up (1 element) GET_INT( fk_int->select_item_mode, value ); if( value > 0 ) { SET_INT( fk_int->select_item_mode, --value ); OnSelectionMode( fk_int->select_item_mode, fk_int ); } break; case DK_CHAR(']'): // Scroll Selection Mode Down (1 element) GET_INT( fk_int->select_item_mode, value ); if( value < num_selection_modes - 1) { SET_INT( fk_int->select_item_mode, ++value ); OnSelectionMode( fk_int->select_item_mode, fk_int ); } break; case DK_CHAR('{'): // Scroll the Group Edit Mode Up (1 element) GET_INT( fk_int->group_edit_mode, value ); if( value > 0 ) SET_INT( fk_int->group_edit_mode, --value ); break; case DK_CHAR('}'): // Scroll the Group Edit Mode Up (1 element) GET_INT( fk_int->group_edit_mode, value ); if( value < num_group_edit_modes - 1 ) SET_INT( fk_int->group_edit_mode, ++value ); break; case DK_CHAR(' '): // Cycle Select/Deselect/Invert GET_INT( fk_int->select_toggle, value ); if( value < num_selection_toggles - 1) SET_INT( fk_int->select_toggle, ++value ); else SET_INT( fk_int->select_toggle, 0 ); OnSelectionMode( fk_int->select_item_mode, fk_int ); break; case DK_CHAR('f'): // Fold/Unfold Current Item if( fk->IsCurrentItemValid() ) { fk_int->sorted_items[ fk->GetCurrentItem() ]->SetFolded( !fk_int->sorted_items[ fk->GetCurrentItem() ]->GetFolded() ); fk_int->sorted_items.Reset(); // Rebuild item list to represent fold states if( fk->GetScene().GetBaseItem().GetChildren().NumElements() > 0 ) fk->GetScene().GetBaseItem().BuildFoldedItemList( fk_int->sorted_items, true, false ); if( fk->GetCurrentItem() > fk_int->sorted_items.NumElements() - 1 ) fk->SetCurrentItem( fk_int->sorted_items.NumElements() - 1 ); OnDisplayMode( fk_int->display_item_mode, fk_int ); } break; case DK_CHAR('F'): // Fold/Unfold All Items last_was_folded = !last_was_folded; if( last_was_folded ) OnFoldList( fk_int->list_fold, fk_int ); else OnUnFoldList( fk_int->list_unfold, fk_int ); OnDisplayMode( fk_int->display_item_mode, fk_int ); break; case DK_CHAR('a'): if( fk_int->alt_down || // Select All fk_int->ctrl_down ) { SelectAll(); fk_int->RedrawItemList(); fk_int->UpdateSelectedCount(); } break; case DK_CHAR('/'): // Deselect All DeselectAll(); fk_int->UpdateSelectedCount(); fk_int->RedrawItemList(); break; case DK_CHAR('c'): if( fk_int->alt_down ) { // Select Children SelectChildren(); fk_int->UpdateSelectedCount(); } else { // Select Current And It's Children fk_int->UpdateSelectedCount(); SelectItem( fk_int->sorted_items[ fk->GetCurrentItem() ], true ); } fk_int->RedrawItemList(); break; case DK_CHAR('C'): // Deselect Current And It's Children DeselectItem( fk_int->sorted_items[ fk->GetCurrentItem() ], true ); fk_int->UpdateSelectedCount(); fk_int->RedrawItemList(); break; case DK_CHAR('g'): if( fk_int->alt_down || // Add Selected To Group fk_int->ctrl_down ) { SetSelectionToGroup( fk->GetCurrentGroup() ); fk_int->RedrawItemList(); } else { // Select all in group SelectAllInGroup( fk->GetCurrentGroup(), false ); fk_int->RedrawItemList(); } break; case DK_CHAR('G'): // Deselect all in group DeselectAllInGroup( fk->GetCurrentGroup(), false ); fk_int->UpdateSelectedCount(); fk_int->RedrawItemList(); break; case DK_CHAR( 9 ): // Cyle Display Mode - GET_INT( fk_int->display_item_mode, value ); if( fk_int->shift_down ) { // - Backward if( --value < 0 ) { value = 0; } } else { // - Forward if( ++value > 7 ) { value = 7; } } SET_INT( fk_int->display_item_mode, value ); OnDisplayMode( fk_int->display_item_mode, fk_int ); break; case DK_CHAR( '`' ): // Draw Style (that's the tilde key) if( fk->GetDrawStyle() == DRAWSTYLE_56 ) { fk->SetDrawStyle( DRAWSTYLE_L6 ); fk_int->SetStatusText( "Now using L6 Draw Style", STATUSMODE_INFO, true ); } else { fk->SetDrawStyle( DRAWSTYLE_56 ); fk_int->SetStatusText( "Now using 5.6 Draw Style", STATUSMODE_INFO, true ); } SET_INT( fk_int->opt_draw_style, fk->GetDrawStyle() ); fk_int->RedrawItemList(); break; } }
void CTabFolderUI::Init() { if( m_iCurSel == -1 ) SelectItem(0); }
void CCtrlTreeOpts::OnInit() { CCtrlTreeView::OnInit(); TCHAR itemName[1024]; HIMAGELIST hImgLst; SelectItem(NULL); DeleteAllItems(); hImgLst = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR|ILC_COLOR32|ILC_MASK, 5, 1); ImageList_AddIcon_Icolib(hImgLst, LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); ImageList_AddIcon_Icolib(hImgLst, LoadSkinnedIcon(SKINICON_OTHER_TICK)); // check on ImageList_AddIcon_Icolib(hImgLst, LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); // check off ImageList_AddIcon_Icolib(hImgLst, LoadSkinnedIcon(SKINICON_OTHER_TICK)); // radio on ImageList_AddIcon_Icolib(hImgLst, LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); // radio on ImageList_AddIcon_Icolib(hImgLst, LoadSkinnedIcon(SKINICON_OTHER_GROUPOPEN)); ImageList_AddIcon_Icolib(hImgLst, LoadSkinnedIcon(SKINICON_OTHER_GROUPSHUT)); SetImageList(hImgLst, TVSIL_NORMAL); /* build options tree. based on code from IcoLib */ for (int i = 0; i < m_options.getCount(); i++) { TCHAR* sectionName; int sectionLevel = 0; HTREEITEM hSection = NULL; lstrcpy(itemName, m_options[i]->m_szOptionName); sectionName = itemName; while (sectionName) { // allow multi-level tree TCHAR* pItemName = sectionName; HTREEITEM hItem; if (sectionName = _tcschr(sectionName, '/')) { // one level deeper *sectionName = 0; sectionName++; } hItem = FindNamedItem(hSection, pItemName); if (!sectionName || !hItem) { if (!hItem) { TVINSERTSTRUCT tvis = {0}; tvis.hParent = hSection; tvis.hInsertAfter = TVI_LAST;//TVI_SORT; tvis.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_STATE|TVIF_IMAGE|TVIF_SELECTEDIMAGE; tvis.item.pszText = pItemName; tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED; if (sectionName) { tvis.item.lParam = -1; tvis.item.state |= TVIS_BOLD; tvis.item.stateMask |= TVIS_BOLD; tvis.item.iImage = tvis.item.iSelectedImage = IMG_GRPOPEN; } else { tvis.item.lParam = i; BYTE val = *m_options[i]->m_option; if (m_options[i]->m_groupId == OPTTREE_CHECK) { tvis.item.iImage = tvis.item.iSelectedImage = val ? IMG_CHECK : IMG_NOCHECK; } else { tvis.item.iImage = tvis.item.iSelectedImage = val ? IMG_RCHECK : IMG_NORCHECK; } } hItem = InsertItem(&tvis); if (!sectionName) m_options[i]->m_hItem = hItem; } } sectionLevel++; hSection = hItem; } } TranslateTree(); ShowWindow(m_hwnd, SW_SHOW); SelectItem(FindNamedItem(0, NULL)); }
void TabFolderUI::SetAttribute(const char* name, const char* value) { if (str::Eq(name, "select")) SelectItem(atoi(value)); else ContainerUI::SetAttribute(name, value); }
void TabFolderUI::Init() { if (m_curSel == -1) SelectItem(0); }
bool wxSelectionStore::SelectRange(unsigned itemFrom, unsigned itemTo, bool select, wxArrayInt *itemsChanged) { // 100 is hardcoded but it shouldn't matter much: the important thing is // that we don't refresh everything when really few (e.g. 1 or 2) items // change state static const unsigned MANY_ITEMS = 100; wxASSERT_MSG( itemFrom <= itemTo, wxT("should be in order") ); // are we going to have more [un]selected items than the other ones? if ( itemTo - itemFrom > m_count/2 ) { if ( select != m_defaultState ) { // the default state now becomes the same as 'select' m_defaultState = select; // so all the old selections (which had state select) shouldn't be // selected any more, but all the other ones should wxSelectedIndices selOld = m_itemsSel; m_itemsSel.Empty(); // TODO: it should be possible to optimize the searches a bit // knowing the possible range unsigned item; for ( item = 0; item < itemFrom; item++ ) { if ( selOld.Index(item) == wxNOT_FOUND ) m_itemsSel.Add(item); } for ( item = itemTo + 1; item < m_count; item++ ) { if ( selOld.Index(item) == wxNOT_FOUND ) m_itemsSel.Add(item); } // many items (> half) changed state itemsChanged = NULL; } else // select == m_defaultState { // get the inclusive range of items between itemFrom and itemTo size_t count = m_itemsSel.GetCount(), start = m_itemsSel.IndexForInsert(itemFrom), end = m_itemsSel.IndexForInsert(itemTo); if ( start == count || m_itemsSel[start] < itemFrom ) { start++; } if ( end == count || m_itemsSel[end] > itemTo ) { end--; } if ( start <= end ) { // delete all of them (from end to avoid changing indices) for ( int i = end; i >= (int)start; i-- ) { if ( itemsChanged ) { if ( itemsChanged->GetCount() > MANY_ITEMS ) { // stop counting (see comment below) itemsChanged = NULL; } else { itemsChanged->Add(m_itemsSel[i]); } } m_itemsSel.RemoveAt(i); } } } } else // "few" items change state { if ( itemsChanged ) { itemsChanged->Empty(); } // just add the items to the selection for ( unsigned item = itemFrom; item <= itemTo; item++ ) { if ( SelectItem(item, select) && itemsChanged ) { itemsChanged->Add(item); if ( itemsChanged->GetCount() > MANY_ITEMS ) { // stop counting them, we'll just eat gobs of memory // for nothing at all - faster to refresh everything in // this case itemsChanged = NULL; } } } } // we set it to NULL if there are many items changing state return itemsChanged != NULL; }
void GuiComboBoxListControl::OnListControlSelectionChanged(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments) { DisplaySelectedContent(GetSelectedIndex()); SelectItem(); SelectedIndexChanged.Execute(GetNotifyEventArguments()); }
bool CDropDown::HandleMessage(CMessage* pMessage) { bool bHandled = false; CRect SubRect(m_WindowRect); SubRect.Grow(-3); if (pMessage) { switch(pMessage->MessageType()) { case CMessage::KEYBOARD_KEYDOWN: { CKeyboardMessage* pKeyboardMessage = dynamic_cast<CKeyboardMessage*>(pMessage); if (pKeyboardMessage && pMessage->Destination() == this) { switch (pKeyboardMessage->Key) { case SDLK_UP: SelectItem(GetSelectedIndex() - 1); ShowListBox(); break; case SDLK_DOWN: SelectItem(GetSelectedIndex() + 1); ShowListBox(); break; case SDLK_RETURN: case SDLK_SPACE: HideListBox(); break; case SDLK_TAB: HideListBox(); // intentional fall through: the parent frame will change focused widget default: // Forward all key downs to parent CMessageServer::Instance().QueueMessage(new CKeyboardMessage(CMessage::KEYBOARD_KEYDOWN, m_pParentWindow, this, pKeyboardMessage->ScanCode, pKeyboardMessage->Modifiers, pKeyboardMessage->Key, pKeyboardMessage->Unicode)); break; } } break; } case CMessage::MOUSE_BUTTONDOWN: { CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage); if (pMouseMessage->Button == CMouseMessage::LEFT) { if (m_pListBox->IsVisible() && m_pDropButton->GetWindowRect().SizeRect().HitTest(m_pDropButton->ViewToWindow(pMouseMessage->Point)) != CRect::RELPOS_INSIDE && m_pListBox->GetWindowRect().SizeRect().HitTest(m_pListBox->ViewToWindow(pMouseMessage->Point)) != CRect::RELPOS_INSIDE) { HideListBox(); } } break; } case CMessage::CTRL_SINGLELCLICK: { if (pMessage->Destination() == this) { if (pMessage->Source() == m_pDropButton) { if (m_pListBox->IsVisible()) { HideListBox(); } else { ShowListBox(); } bHandled = true; } } break; } case CMessage::CTRL_VALUECHANGE: { TIntMessage* pCtrlMessage = dynamic_cast<TIntMessage*>(pMessage); if (pCtrlMessage && pMessage->Destination() == this) { if (pCtrlMessage->Source() == m_pListBox) { const SListItem& ListItem = m_pListBox->GetItem(pCtrlMessage->Value()); SetWindowText(ListItem.sItemText); HideListBox(); CMessageServer::Instance().QueueMessage(new TIntMessage(CMessage::CTRL_VALUECHANGE, m_pParentWindow, this, 0)); bHandled = true; } else if (pCtrlMessage->Source() == m_pEditBox) { m_pListBox->SetAllSelections(false); HideListBox(); CMessageServer::Instance().QueueMessage(new TIntMessage(CMessage::CTRL_VALUECHANGE, m_pParentWindow, this, 0)); bHandled = true; } } break; } default : bHandled = CWindow::HandleMessage(pMessage); break; } } return bHandled; }
void P3DPlantModelTreeCtrl::OnItemRightClick (wxTreeEvent &event) { P3DBranchModel *BranchModel; P3DMaterialInstanceSimple *MaterialSimple; if (event.GetItem() != GetSelection()) { SelectItem(event.GetItem()); } BranchModel = ((P3DPlantModelTreeCtrlItemData*)(GetItemData(GetSelection())))->GetBranchModel(); wxMenu PopupMenu; wxMenu *StemModelMenu; wxMenu *AppendBranchMenu; P3DStemModel *StemModel = BranchModel->GetStemModel(); if (StemModel == 0) { } else { StemModelMenu = new wxMenu(); StemModelMenu->Append(P3D_SET_STEM_MODEL_TUBE_ID,wxT("Tube")); StemModelMenu->Append(P3D_SET_STEM_MODEL_QUAD_ID,wxT("Quad")); StemModelMenu->Append(P3D_SET_STEM_MODEL_WINGS_ID,wxT("Wings")); if (dynamic_cast<P3DStemModelTube*>(StemModel) != 0) { StemModelMenu->Enable(P3D_SET_STEM_MODEL_TUBE_ID,false); } else if (dynamic_cast<P3DStemModelQuad*>(StemModel) != 0) { StemModelMenu->Enable(P3D_SET_STEM_MODEL_QUAD_ID,false); } else if (dynamic_cast<P3DStemModelWings*>(StemModel) != 0) { StemModelMenu->Enable(P3D_SET_STEM_MODEL_WINGS_ID,false); } const P3DPluginInfoVector &GMeshPlugins = P3DApp::GetApp()->GetGMeshPlugins(); if (GMeshPlugins.size() > 0) { wxMenu *GMeshPluginsMenu = new wxMenu(); int MenuItemId = wxID_GMESH_PLUGIN_FIRST; for (unsigned int Index = 0; Index < GMeshPlugins.size(); Index++) { GMeshPluginsMenu->Append(MenuItemId++,wxString(GMeshPlugins[Index].GetMenuName(),wxConvUTF8)); } StemModelMenu->Append(P3D_SET_STEM_MODEL_GMESH_ID,wxT("G-Mesh"),GMeshPluginsMenu); } else { StemModelMenu->Append(P3D_SET_STEM_MODEL_GMESH_ID,wxT("G-Mesh")); StemModelMenu->Enable(P3D_SET_STEM_MODEL_GMESH_ID,false); } if (BranchModel->GetSubBranchCount() > 0) { StemModelMenu->Enable(P3D_SET_STEM_MODEL_QUAD_ID,false); StemModelMenu->Enable(P3D_SET_STEM_MODEL_WINGS_ID,false); StemModelMenu->Enable(P3D_SET_STEM_MODEL_GMESH_ID,false); } if (GetItemParent(GetSelection()) == GetRootItem()) { StemModelMenu->Enable(P3D_SET_STEM_MODEL_WINGS_ID,false); } } MaterialSimple = dynamic_cast<P3DMaterialInstanceSimple*>(BranchModel->GetMaterialInstance()); AppendBranchMenu = new wxMenu(); AppendBranchMenu->Append(PLANT_TREE_APPEND_BRANCH_NEW_ID,wxT("New branch")); AppendBranchMenu->Append(PLANT_TREE_APPEND_BRANCH_COPY_ID,wxT("Copy branch...")); PopupMenu.Append(PLANT_TREE_APPEND_BRANCH_ID,wxT("Append branch"),AppendBranchMenu); PopupMenu.Append(PLANT_TREE_REMOVE_STEM_ID,wxT("Delete stem")); if (GetItemParent(GetSelection()).IsOk()) { PopupMenu.AppendSeparator(); PopupMenu.Append(P3D_SET_STEM_MODEL_ID,wxT("Stem model"),StemModelMenu); wxMenuItem *DummyModeMenuItem = PopupMenu.AppendCheckItem(P3D_SET_STEM_DUMMY_MODE,wxT("Dummy")); DummyModeMenuItem->Check(BranchModel->IsDummy()); PopupMenu.AppendSeparator(); if (!BranchModel->IsDummy()) { if (MaterialSimple->IsHidden()) { PopupMenu.Append(PLANT_TREE_HIDESHOW_STEM_ID,wxT("Show")); } else { PopupMenu.Append(PLANT_TREE_HIDESHOW_STEM_ID,wxT("Hide")); } } } PopupMenu.Append(PLANT_TREE_RENAME_STEM_ID,wxT("Rename...")); if (GetRootItem() == GetSelection()) { PopupMenu.Enable(PLANT_TREE_REMOVE_STEM_ID,false); } if (BranchModel->GetSubBranchCount() < P3DBranchModelSubBranchMaxCount) { } else { PopupMenu.Enable(PLANT_TREE_APPEND_BRANCH_ID,false); } if (dynamic_cast<P3DStemModelQuad*>(StemModel) != 0) { PopupMenu.Enable(PLANT_TREE_APPEND_BRANCH_ID,false); } else if (dynamic_cast<P3DStemModelWings*>(StemModel) != 0) { PopupMenu.Enable(PLANT_TREE_APPEND_BRANCH_ID,false); } this->PopupMenu(&PopupMenu,event.GetPoint()); }
//------------------------------------------------------------------------------------------------------------------------------------ // BOOL SourceCommandLoop( LPRefObj pRefMod, ULONG ulSrcID ) { LPRefObj pRefSrc = NULL; char buf[256]; ULONG ulItemID = 0; UWORD wSel; BOOL bRet = true; pRefSrc = GetRefChildPtr_ID( pRefMod, ulSrcID ); if ( pRefSrc == NULL ) { // Create Source object and RefSrc structure. if ( AddChild( pRefMod, ulSrcID ) == true ) { printf("Source object is opened.\n"); } else { printf("Source object can't be opened.\n"); return false; } pRefSrc = GetRefChildPtr_ID( pRefMod, ulSrcID ); } // Get CameraType Command_CapGet( pRefSrc->pObject, kNkMAIDCapability_CameraType, kNkMAIDDataType_UnsignedPtr, (NKPARAM)&g_ulCameraType, NULL, NULL ); // command loop do { printf( "\nSelect (1-10, 0)\n" ); printf( " 1. Select Item Object 2. Camera settings(1) 3. Camera settings(2)\n" ); printf( " 4. Shooting Menu 5. Custom Menu 6. Async\n" ); printf( " 7. Autofocus 8. Capture 9. TerminateCapture\n" ); printf( "10. PreCapture\n" ); printf( " 0. Exit\n>" ); scanf( "%s", buf ); wSel = atoi( buf ); switch( wSel ) { case 1:// Children // Select Item Object ulItemID = 0; bRet = SelectItem( pRefSrc, &ulItemID ); if( bRet == true && ulItemID > 0 ) bRet = ItemCommandLoop( pRefSrc, ulItemID ); break; case 2:// Camera setting 1 bRet = SetUpCamera1( pRefSrc ); break; case 3:// Camera setting 2 bRet = SetUpCamera2( pRefSrc ); break; case 4:// Shooting Menu bRet = SetShootingMenu( pRefSrc ); break; case 5:// CustomSetting Menu bRet = SetCustomSettings( pRefSrc ); break; case 6:// Async bRet = Command_Async( pRefMod->pObject ); break; case 7:// AutoFocus bRet = IssueProcess( pRefSrc, kNkMAIDCapability_AutoFocus ); break; case 8:// Capture bRet = IssueProcess( pRefSrc, kNkMAIDCapability_Capture ); Command_Async( pRefSrc->pObject ); break; case 9:// TerminateCapture bRet = TerminateCaptureCapability( pRefSrc ); break; case 10:// PreCapture bRet = IssueProcess( pRefSrc, kNkMAIDCapability_PreCapture ); break; default: wSel = 0; } if ( bRet == false ) { printf( "An Error occured. Enter '0' to exit.\n>" ); scanf( "%s", buf ); bRet = true; } WaitEvent(); } while( wSel > 0 ); // Close Source_Object bRet = RemoveChild( pRefMod, ulSrcID ); return true; }
void wxSTEditorTreeCtrl::UpdateFromNotebook() { wxSTERecursionGuard guard(m_rGuard_UpdateFromNotebook); if (guard.IsInside()) return; wxSTEditorNotebook *noteBook = GetSTEditorNotebook(); if (!noteBook) return; int n; int page_count = noteBook->GetPageCount(); int note_sel = noteBook->GetSelection(); wxTreeItemId id, selId; // Check for and add a root item to the treectrl, it's hidden wxTreeItemId rootId = GetRootItem(); if (!rootId) rootId = AddRoot(_("Root"), -1, -1, NULL); // Check for and add a "Opened files" item to the treectrl wxArrayString openedfilesPath; openedfilesPath.Add(_("Opened files")); wxTreeItemId openedId = FindOrInsertItem(openedfilesPath, STE_TREECTRL_FIND_OR_INSERT); wxLongToLongHashMap windowToSTETreeItemDataMap = m_windowToSTETreeItemDataMap; Freeze(); for (n = 0; n < page_count; n++) { id = wxTreeItemId(); // start fresh wxSTEditor* editor = noteBook->GetEditor(n); wxWindow* notePage = noteBook->GetPage(n); wxSTETreeItemData* steTreeItemData = NULL; // If this editor was already added to the tree, check if it's still correct if (editor && editor->GetTreeItemData()) { // get and check the old tree item id, the filename/path could have changed steTreeItemData = editor->GetTreeItemData(); if (steTreeItemData) id = steTreeItemData->m_id; if (steTreeItemData) { if ((steTreeItemData->m_notePage == notePage) && (steTreeItemData->m_fileName == editor->GetFileName())) { // the page didn't change name, but do resync page number steTreeItemData->m_page_num = n; windowToSTETreeItemDataMap.erase((long)notePage); } else steTreeItemData = NULL; } // Something changed, redo it if (id && !steTreeItemData) { // Erase refs to this page, we will recreate it m_windowToSTETreeItemDataMap.erase((long)notePage); windowToSTETreeItemDataMap.erase((long)notePage); DeleteItem(id, true, -1, openedId); // null it and add it correctly later id = wxTreeItemId(); editor->SetTreeItemData(NULL); } } bool modified = editor->IsModified(); if (!id) { // Create new data to add to the wxTreeItem steTreeItemData = new wxSTETreeItemData(n, notePage); // Only connect the destroy handler once if (m_windowDestroyMap.find((long)notePage) == m_windowDestroyMap.end()) { m_windowDestroyMap[(long)notePage] = 1; notePage->Connect(wxID_ANY, wxEVT_DESTROY, wxWindowDestroyEventHandler(wxSTEditorTreeCtrl::OnWindowDestroy), NULL, this); } if (editor) { modified = editor->IsModified(); steTreeItemData->m_root = _("Opened files"); steTreeItemData->m_fileName = editor->GetFileName(); wxFileName fn(steTreeItemData->m_fileName); // Don't need to Normalize() since it is done in wxSTEditor::SetFilename() //if (fn.FileExists()) fn.Normalize(); switch (m_display_type) { case SHOW_FILENAME_ONLY : { steTreeItemData->m_treePath.Add(steTreeItemData->m_root); steTreeItemData->m_treePath.Add(fn.GetFullName()); break; } case SHOW_FILEPATH_ONLY : { steTreeItemData->m_treePath.Add(steTreeItemData->m_root); steTreeItemData->m_treePath.Add(fn.GetFullPath()); break; } case SHOW_PATH_THEN_FILENAME : { steTreeItemData->m_treePath.Add(steTreeItemData->m_root); steTreeItemData->m_treePath.Add(fn.GetPath()); steTreeItemData->m_treePath.Add(fn.GetFullName()); break; } case SHOW_ALL_PATHS : { steTreeItemData->m_treePath.Add(steTreeItemData->m_root); wxArrayString dirs = fn.GetDirs(); for (size_t i = 0; i < dirs.GetCount(); ++i) steTreeItemData->m_treePath.Add(dirs[i]); steTreeItemData->m_treePath.Add(fn.GetFullName()); break; } } } else { steTreeItemData->m_root = _("Others"); steTreeItemData->m_fileName = noteBook->GetPageText(n); steTreeItemData->m_treePath.Add(steTreeItemData->m_root); steTreeItemData->m_treePath.Add(steTreeItemData->m_fileName.GetFullPath()); } // Always insert a new editor since if we already did, it'd have a treeitem id. // For other windows, who knows, you can only have one tree node per notebook page name if (editor) { id = FindOrInsertItem(steTreeItemData->m_treePath, STE_TREECTRL_INSERT); SetItemImage(id, STE_TREECTRL_IMAGE_EDITOR); editor->SetTreeItemData(steTreeItemData); steTreeItemData->m_steRefData = editor->GetSTERefData(); } else { id = FindOrInsertItem(steTreeItemData->m_treePath, STE_TREECTRL_FIND_OR_INSERT); SetItemImage(id, STE_TREECTRL_IMAGE_OTHER); } // must set new data before deleting old in MSW since it checks old before setting new wxTreeItemData* oldData = GetItemData(id); steTreeItemData->m_id = id; SetItemData(id, steTreeItemData); if (oldData) delete oldData; m_windowToSTETreeItemDataMap[(long)notePage] = (long)steTreeItemData; } // we should have valid id at this point if (n == note_sel) selId = id; else if (IsBold(id)) SetItemBold(id, false); SetItemTextColour(id, modified ? *wxRED : *wxBLACK); } wxLongToLongHashMap::iterator it; for( it = windowToSTETreeItemDataMap.begin(); it != windowToSTETreeItemDataMap.end(); ++it ) { wxSTETreeItemData* oldData = (wxSTETreeItemData*)it->second; DeleteItem(oldData->m_id, true, -1, openedId); m_windowToSTETreeItemDataMap.erase(it->first); } if (selId) { SetItemBold(selId); SelectItem(selId); } SortAllChildren(GetRootItem()); Thaw(); }
BOOL CDownloads_Groups::Create(CWnd *pParent) { CRect rc (0, 0, 150, 50); if (FALSE == CTreeCtrl::Create (TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_SHOWSELALWAYS, rc, pParent, 0x9876)) return FALSE; CBitmap bmpg; bmpg.Attach (SBMP (IDB_GROUPS)); m_images.Create (16, 15, ILC_COLOR24 | ILC_MASK, 8, 2); m_images.Add (&bmpg, RGB (255, 0, 255)); SetImageList (&m_images, TVSIL_NORMAL); m_hAllGroups = InsertItem (TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE | TVIF_TEXT, "", 0, 0, TVIS_BOLD | TVIS_EXPANDED, TVIS_BOLD | TVIS_EXPANDED, 0, TVI_ROOT, TVI_LAST); SetItemData (m_hAllGroups, (ULONG) &m_filterAll); InsertGroups (); InsertFilters (); InsertHistory (); InsertDeleted (); switch (_pwndDownloads->Get_DWWN ()) { case DWWN_LISTOFDOWNLOADS: int nId; nId = _App.View_DownloadsGroups_SelectedFilterId (); switch (nId) { case -2: SelectItem (m_hTasks); break; case -1: SelectItem (m_hAllGroups); break; default: vmsDownloadsGroupSmartPtr pGrp; pGrp = _DldsGrps.FindGroup (nId); if (pGrp != NULL) SetGroupFilter (pGrp); else SelectItem (m_hTasks); break; } break; case DWWN_HISTORY: SelectItem (m_hHistory); Expand (m_hHistory, TVE_EXPAND); break; case DWWN_DELETED: SelectItem (m_hDeleted); break; } m_odmenuImages.Create (16, 15, ILC_COLOR24 | ILC_MASK, 5, 2); CBitmap bmp; bmp.Attach (SBMP (IDB_GROUPSMENU)); m_odmenuImages.Add (&bmp, RGB (255, 0, 255)); CBitmap bmp1; bmp1.Attach (SBMP (IDB_GROUPSMENU_D)); BITMAP bm; bmp1.GetBitmap (&bm); m_odmenuDImages.Create (16, bm.bmHeight, ILC_COLOR24|ILC_MASK, 3, 1); m_odmenuDImages.Add (&bmp1, RGB (255, 0, 255)); m_odmenu.SetImageList (&m_odmenuImages, &m_odmenuDImages); ApplyLanguage (); ShowWindow (SW_SHOW); SetTimer (1, 1000, NULL); return TRUE; }
void CTabFolderUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) { if( _tcscmp(pstrName, _T("select")) == 0 ) SelectItem(_ttoi(pstrValue)); else CContainerUI::SetAttribute(pstrName, pstrValue); }
void CDownloads_Groups::SetFilter_AllDownloads() { if (GetSelectedItem () != m_hAllGroups) SelectItem (m_hAllGroups); }
int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) { // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) { // Should selected items be added to the current selection or // become the new selection (discarding previously selected items) m_additive = evt->Modifier( MD_SHIFT ); // single click? Select single object if( evt->IsClick( BUT_LEFT ) ) { if( evt->Modifier( MD_CTRL ) && !m_editModules ) { highlightNet( evt->Position() ); } else { if( !m_additive ) clearSelection(); selectCursor( evt->Position() ); } } // right click? if there is any object - show the context menu else if( evt->IsClick( BUT_RIGHT ) ) { bool emptySelection = m_selection.Empty(); if( emptySelection ) selectCursor( evt->Position() ); CONTEXT_MENU& contextMenu = m_menu.Generate( m_selection ); if( contextMenu.GetMenuItemCount() > 0 ) SetContextMenu( &contextMenu, CMENU_NOW ); m_preliminary = emptySelection; } // double click? Display the properties window else if( evt->IsDblClick( BUT_LEFT ) ) { if( m_selection.Empty() ) selectCursor( evt->Position() ); m_toolMgr->RunAction( COMMON_ACTIONS::properties ); } // drag with LMB? Select multiple objects (or at least draw a selection box) or drag them else if( evt->IsDrag( BUT_LEFT ) ) { if( m_additive ) { m_preliminary = false; selectMultiple(); } else if( m_selection.Empty() ) { m_preliminary = false; // There is nothing selected, so try to select something if( !selectCursor( getView()->ToWorld( getViewControls()->GetMousePosition() ), false ) ) { // If nothings has been selected or user wants to select more // draw the selection box selectMultiple(); } else { m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" ); } } else { // Check if dragging has started within any of selected items bounding box if( selectionContains( evt->Position() ) ) { // Yes -> run the move tool and wait till it finishes m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" ); } else { // No -> clear the selection list clearSelection(); } } } else if( evt->IsAction( &COMMON_ACTIONS::selectionCursor ) ) { // GetMousePosition() is used, as it is independent of snapping settings selectCursor( getView()->ToWorld( getViewControls()->GetMousePosition() ) ); } else if( evt->IsAction( &COMMON_ACTIONS::find ) ) { find( *evt ); } else if( evt->IsAction( &COMMON_ACTIONS::findMove ) ) { findMove( *evt ); } else if( evt->IsAction( &COMMON_ACTIONS::selectItem ) ) { SelectItem( *evt ); } else if( evt->IsAction( &COMMON_ACTIONS::unselectItem ) ) { UnselectItem( *evt ); } else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO || evt->IsAction( &COMMON_ACTIONS::selectionClear ) ) { clearSelection(); } else if( evt->IsAction( &COMMON_ACTIONS::selectConnection ) ) { selectConnection( *evt ); } else if( evt->IsAction( &COMMON_ACTIONS::selectCopper ) ) { selectCopper( *evt ); } else if( evt->IsAction( &COMMON_ACTIONS::selectNet ) ) { selectNet( *evt ); } else if( evt->Action() == TA_CONTEXT_MENU_CLOSED ) { if( m_preliminary ) clearSelection(); } } // This tool is supposed to be active forever assert( false ); return 0; }
void CDownloads_Groups::SetFilter_AllHistory() { if (GetSelectedItem () != m_hHistory) SelectItem (m_hHistory); }
void MyTreeCtrl::RefreshTreeItems(Builder *pBuilder) { VTLOG1("Refreshing Tree Items:"); // Deleting the previous items can call OnSelChanged, which can cause VTB // to forget the active layer, so indicate that this is not user input. m_bUser = false; DeleteAllItems(); m_bUser = true; rootId = AddRoot(_("Layers")); SetItemBold(rootId); int image, imageSel; wxTreeItemId elevId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Grid, _("Elevation")); SetItemData(elevId, new MyTreeItemData(LT_ELEVATION)); wxTreeItemId imageId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Image, _("Images")); SetItemData(imageId, new MyTreeItemData(LT_IMAGE)); wxTreeItemId buildId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Building, _("Structures")); SetItemData(buildId, new MyTreeItemData(LT_STRUCTURE)); wxTreeItemId roadId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Road, _("Roads")); SetItemData(roadId, new MyTreeItemData(LT_ROAD)); wxTreeItemId vegId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Veg1, _("Vegetation")); SetItemData(vegId, new MyTreeItemData(LT_VEG)); wxTreeItemId waterId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Water, _("Water")); SetItemData(waterId, new MyTreeItemData(LT_WATER)); wxTreeItemId utilityId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Utility, _("Utilities")); SetItemData(utilityId, new MyTreeItemData(LT_UTILITY)); wxTreeItemId rawId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Raw, _("Raw")); SetItemData(rawId, new MyTreeItemData(LT_RAW)); image = TreeCtrlIcon_File; imageSel = TreeCtrlIcon_FileSelected; vtLayerPtr lp; int iLayers = 0; if (pBuilder) iLayers = pBuilder->NumLayers(); wxTreeItemId hSelectedItem; for (int i = 0; i < iLayers; i++) { lp = pBuilder->GetLayer(i); wxString str = MakeItemName(lp); wxTreeItemId hItem; switch (lp->GetType()) { case LT_ELEVATION: hItem = AppendItem(elevId, str, image, imageSel); break; case LT_IMAGE: hItem = AppendItem(imageId, str, image, imageSel); break; case LT_ROAD: hItem = AppendItem(roadId, str, image, imageSel); break; case LT_STRUCTURE: hItem = AppendItem(buildId, str, image, imageSel); break; case LT_VEG: hItem = AppendItem(vegId, str, image, imageSel); break; case LT_WATER: hItem = AppendItem(waterId, str, image, imageSel); break; case LT_UTILITY: hItem = AppendItem(utilityId, str, image, imageSel); break; case LT_RAW: hItem = AppendItem(rawId, str, image, imageSel); break; case LT_UNKNOWN: case LAYER_TYPES: // Keep picky compilers quiet. break; } if (hItem.IsOk()) { SetItemData(hItem, new MyTreeItemData(lp)); if (lp == pBuilder->GetActiveLayer()) hSelectedItem = hItem; if (!lp->GetVisible()) { SetItemFont(hItem, *wxITALIC_FONT); SetItemTextColour(hItem, wxColour(80,80,80)); } } } VTLOG(" %d layers.\n", iLayers); // Expand the groups after they have all their items. It doesn't work // to expand before, because then not all items are shown. Expand(elevId); Expand(imageId); Expand(roadId); Expand(buildId); Expand(vegId); Expand(waterId); Expand(utilityId); Expand(rawId); // Wait until all the groups are expanded, before highlighting the // selected item, so that it will definitely be in view. if (hSelectedItem.IsOk()) SelectItem(hSelectedItem); }
void CDownloads_Groups::SetFilter_DeletedDownloads() { if (GetSelectedItem () != m_hDeleted) SelectItem (m_hDeleted); }
void TabBox::SetAttribute(const std::wstring& strName, const std::wstring& strValue) { if( strName == _T("selectedid") ) SelectItem(_ttoi(strValue.c_str())); else if( strName == _T("fadeswitch") ) SetFadeSwitch(strValue == _T("true")); else Box::SetAttribute(strName, strValue); }
void BundleManager::OnItemSelected(wxListEvent& event) { // Get repository const long itemId = event.GetIndex(); SelectItem(itemId); }
void RegTreeCtrl::GoTo(const wxString& location) { wxStringTokenizer tk(location, wxT("\\")); wxTreeItemId id = GetRootItem(); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while ( tk.HasMoreTokens() ) { wxString subkey = tk.GetNextToken(); wxTreeItemId idCurrent = id; if ( !IsExpanded(idCurrent) ) Expand(idCurrent); wxTreeItemIdValue dummy; id = GetFirstChild(idCurrent, dummy); if ( idCurrent == GetRootItem() ) { // special case: we understand both HKCU and HKEY_CURRENT_USER here #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for ( size_t key = 0; key < wxRegKey::nStdKeys; key++ ) { if ( subkey == wxRegKey::GetStdKeyName(key) || subkey == wxRegKey::GetStdKeyShortName(key) ) { break; } id = GetNextChild(idCurrent, dummy); } } else { // enum all children #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while ( id.IsOk() ) { if ( subkey == ((TreeNode *)GetItemData(id))->m_strName ) break; id = GetNextChild(idCurrent, dummy); } } if ( !id.IsOk() ) { wxLogError(wxT("No such key '%s'."), location.c_str()); return; } } if ( id.IsOk() ) SelectItem(id); }
int CACListWnd::SelectString(LPCTSTR lpszString) { int item = FindString(-1, lpszString); SelectItem(item); return item; }
void CTabLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) { if( _tcscmp(pstrName, _T("selectedid")) == 0 ) SelectItem(_ttoi(pstrValue)); return CContainerUI::SetAttribute(pstrName, pstrValue); }
void EXTreeCtrl::SelectDataItem(IXTreeItem *pITreeItem) { if( pITreeItem==GetSelectedTreeItem() ) //dont select the same again! { return; } //-------------- // Create Parent list std::list<IXTreeItem *> lParents; std::list<IXTreeItem *>::iterator It, ItLast; if(pITreeItem == NULL) { SelectItem(NULL); return; } TRACE("parent-stack:\n"); pITreeItem->GetParentList(lParents); TRACE("Found %i generations of parents to selected item\n",lParents.size()); HTREEITEM hItem = GetRootItem(); HTREEITEM hLastItem = hItem; It = lParents.begin(); if( h2p(hItem)!=(*It) ) //root at top of parent stack! { SelectItem(0); } else { while( It!=lParents.end() ) { // // current h must be the p in the parent list. if this is not the case, the // p reported a parent, that didn't list p as a child when expanding! // ASSERT( (*It) == h2p(hItem) ); //make sure parent lists all it's children! // // expand the node // TRACE( "expanding parent {%s}\n" , h2p(hItem)->GetLabel() ); Expand(hItem,TVE_EXPAND); if( (*It)==pITreeItem ) { break; } // // find the h of the child // It++; //next generation... if( It!=lParents.end() ) { IXTreeItem* pChild = *It; hItem = GetChildItem(hItem); //search for the item that contains next ITreeItem while( hItem!=NULL ) { if( h2p(hItem)==pChild ) { break; //break search and continue treating this child as the next parent } hItem = GetNextSiblingItem(hItem); } } } if(hItem) { EnsureVisible(hItem); SelectItem(hItem); } } }
// ************************************************************************** // OnInitDialog () // // Description: // Called immediately before the dialog box is displayed. Use opportunity // to initialize controls. // // Parameters: // none // // Returns: // BOOL - Result of base class processing. // ************************************************************************** BOOL CKItemPropertiesDlg::OnInitDialog () { CString strText; // Limit the access path to 255 chars: ((CEdit *)GetDlgItem (IDC_ACCESSPATH))->LimitText (255); // Allow 10 levels of 32 character names plus a tag name of 31 characters: ((CEdit *)GetDlgItem (IDC_ITEMID))->LimitText (10*32 + 31); // Subclass image buttons: m_cNext.SubclassDlgItem (IDC_NEXT, this); m_cPrev.SubclassDlgItem (IDC_PREVIOUS, this); // Create tool tips for image buttons: m_cToolTip.Create (this); m_cToolTip.AddWindowTool (&m_cNext); m_cToolTip.AddWindowTool (&m_cPrev); // Intialize IItemProperties 2.0 list control headings: CListCtrl *pList = (CListCtrl *) GetDlgItem (IDC_LIST); ASSERT (pList != NULL); // Get rectangle that bounds list control: CRect rc; pList->GetWindowRect (&rc); // Calculate the width of the list control: int nTotalWidth; nTotalWidth = rc.right - rc.left; // Create the list control columns. Headers will be loaded from // string resources and widths will be a function of total width // of list control: for (int i = 0; i < NUMCOLUMNS; i++) { int nWidth; switch (i) { case 0: // ID strText.LoadString (IDS_ID); nWidth = nTotalWidth / 8; break; case 1: // Description strText.LoadString (IDS_DESCRIPTION); nWidth = nTotalWidth / 3; break; case 2: // Value strText.LoadString (IDS_VALUE); nWidth = nTotalWidth / 6; break; case 3: // Item ID strText.LoadString (IDS_ITEMID); nWidth = nTotalWidth / 3; break; default: ASSERT (FALSE); break; } // Insert the column: pList->InsertColumn (i, strText, LVCFMT_LEFT, nWidth); } // Enable/disable the window based on whether or not the 2.0 // functionality is available. (If m_pIItemProps interface // pointer is NULL, we can assume functionality is not available.) pList->EnableWindow (m_pIItemProps != NULL); // Select the first item: SelectItem (0); // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE return (CDialog::OnInitDialog ()); }
/* MoveItem() Sposta l'elemento in alto o in basso di una posizione. int nItem indice (base 0) dell'elemento ITEM_SKIP skip flag per tipo spostamento (precedente/successivo) */ int CListCtrlEx::MoveItem(int nItem,ITEM_SKIP skip) { int nCurrentItem = LB_ERR; int nNewItem = (nItem + (skip==PREVIOUS_ITEM ? -1 : (skip==NEXT_ITEM ? +1 : -1))); // controlla l'intervallo if(nNewItem >= 0 && nNewItem < CListCtrl::GetItemCount()) { // riga da spostare CTRL_ROW* ra = GetRowByItem(nItem); // riga precedente/successiva CTRL_ROW* ra_prevnext = GetRowByItem(nNewItem); if(ra && ra_prevnext) { int nSubItem; LV_ITEM lvitem; char szItem[MAX_ITEM_SIZE+1]; // elimina l'elemento dal controllo (chiama la classe base perche' non deve aggiornare il contatore interno) CListCtrl::DeleteItem(nItem); // testo dell'elemento strcpyn(szItem,ra->item,sizeof(szItem)); // rinumera gli indici dei due elementi coinvolti nello spostamento ra->index = nNewItem; ra_prevnext->index = nItem; // colonne dell'elemento for(nSubItem = 0,nCurrentItem = 0; nSubItem < m_nTotColumns && nCurrentItem!=LB_ERR; nSubItem++) { // l'elemento (riga) viene passata in un unico buffer, diviso in colonne dal carattere ';' lvitem.pszText = (LPSTR)GetItemToken(nSubItem,szItem); lvitem.iSubItem = nSubItem; if(nSubItem==0) { lvitem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; lvitem.iItem = nNewItem; lvitem.iImage = ra->ico; lvitem.lParam = (LPARAM)ra; lvitem.pszText = LPSTR_TEXTCALLBACK; if((nCurrentItem = CListCtrl::InsertItem(&lvitem)) < 0) nCurrentItem = LB_ERR; } else { lvitem.mask = LVIF_TEXT; lvitem.iItem = nCurrentItem; CListCtrl::SetItem(&lvitem); } } // imposta la riga come selezionata nCurrentItem = SelectItem(nNewItem); } } return(nCurrentItem); }