/** * name: ShowItem * class: CPsTree * desc: displays on of the items in the treeview * param: iPageIndex - the index of the treeitem in the array. * needWidth - gives and takes the width, the treeview must have to show all items properly * return: TRUE if item was added successfully, FALSE otherwise **/ HTREEITEM CPsTree::ShowItem(const int iPageIndex, LPWORD needWidth) { TVINSERTSTRUCT tvii; CPsTreeItem *pti; // check parameters if (!_hWndTree || !IsIndexValid(iPageIndex) || !(pti = _pItems[iPageIndex]) || !pti->Name() || !pti->Label()) { MsgErr(GetParent(_hWndTree), LPGENT("Due to a parameter error, one of the treeitems can't be added!")); return NULL; } // item is visible at the moment if ((tvii.itemex.hItem = pti->Hti()) == NULL) { RECT rc; const int iParent = pti->Parent(); // init the rest of the treeitem tvii.hParent = IsIndexValid(iParent) ? ShowItem(iParent, needWidth) : NULL; tvii.hInsertAfter = (_dwFlags & PSTVF_SORTTREE) ? TVI_SORT : TVI_LAST; tvii.itemex.mask = TVIF_TEXT|TVIF_PARAM|TVIF_STATE; tvii.itemex.pszText = pti->Label(); tvii.itemex.state = pti->State() == DBTVIS_EXPANDED ? TVIS_EXPANDED : 0; tvii.itemex.stateMask = TVIS_EXPANDED; tvii.itemex.lParam = iPageIndex; // set images if ((tvii.itemex.iImage = tvii.itemex.iSelectedImage = pti->Image()) != -1) { tvii.itemex.mask |= TVIF_IMAGE|TVIF_SELECTEDIMAGE; } // insert item into tree if set visible if ((tvii.itemex.hItem = TreeView_InsertItem(_hWndTree, &tvii)) == NULL) { MsgErr(GetParent(_hWndTree), LPGENT("A fatal error occurred on adding a property sheet page!\nDialog creation aborted!")); return NULL; } pti->Hti(tvii.itemex.hItem); // calculate width of treeview if (needWidth && TreeView_GetItemRect(_hWndTree, pti->Hti(), &rc, TRUE) && rc.right > *needWidth) { *needWidth = (WORD)rc.right; } } return tvii.itemex.hItem; }
/** * name: SaveState * class: CPsTree * desc: saves the current tree to database * param: none * return: nothing **/ void CPsTree::SaveState() { CPsTreeItem *pti = CurrentItem(); if (_hWndTree && (_dwFlags & (PSTVF_LABEL_CHANGED|PSTVF_POS_CHANGED|PSTVF_STATE_CHANGED))) { SHORT i; int iItem = 0; // save all visible items WORD numErrors = SaveItemsState(TREE_ROOTITEM, TVGN_ROOT, iItem); // save all invisible items of the current subtree for (i = 0; i < _numItems; i++) { if (!_pItems[i]->Hti()) { LPSTR pszGroup; if (!IsIndexValid(_pItems[i]->Parent()) || !(pszGroup = _pItems[_pItems[i]->Parent()]->Name())) pszGroup = TREE_ROOTITEM; numErrors += _pItems[i]->DBSaveItemState(pszGroup, iItem++, DBTVIS_INVISIBLE, _dwFlags); } } // remove changed flags RemoveFlags(PSTVF_STATE_CHANGED|PSTVF_LABEL_CHANGED|PSTVF_POS_CHANGED); } // save current selected item if (pti) db_set_utf(NULL, MODNAME, SET_LASTITEM, pti->Name()); else db_unset(NULL, MODNAME, SET_LASTITEM); }
bool CCodeAnalysis::IsAddrValid(UINT32 addr) { unsigned index; if (!analyser->GetIndexOfAddr(addr, index)) return false; return IsIndexValid(index); }
void Lights::SetLightAttenStartAndEnd(int index, float start, float end) { if(IsIndexValid(index)) { m_startAndEndAtten[index].x_ = start; m_startAndEndAtten[index].y_ = end; } }
/** * name: HideItem * class: CPsTree * desc: is called if icolib's icons have changed * param: iPageIndex - the index of the treeitem in the array. * return: nothing **/ void CPsTree::HideItem(const int iPageIndex) { if (IsIndexValid(iPageIndex)) { TreeView_DeleteItem(_hWndTree, _pItems[iPageIndex]->Hti()); _pItems[iPageIndex]->Hti(0); _dwFlags |= PSTVF_STATE_CHANGED; } }
void Lights::SetLightSpotLight(int index, float radius, const Vector3Df& dir, float outAngle, float inAngle) { if(IsIndexValid(index)) { m_radius[index] = radius; m_dir[index] = dir; m_angleInnerCone[index] = cos(DegreesToRadians(inAngle)); m_angleOuterCone[index] = cos(DegreesToRadians(outAngle)); } }
void Lights::SetLightPoint(int index, float radius) { if(IsIndexValid(index)) { m_radius[index] = radius; m_dir[index] = Vector3Df(); m_angleInnerCone[index] = 0.0f; m_angleOuterCone[index] = 0.0f; } }
bool CCodeAnalysis::GetNextValidIndex(unsigned &index) { if (IsIndexValid(index)) return true; set<unsigned>::iterator it = validIndexSet.lower_bound(index); if (it == validIndexSet.end()) return false; index = *it; return true; }
bool CCodeAnalysis::GetNextValidAddr(UINT32 &addr) { unsigned index; if (!analyser->GetIndexOfAddr(addr, index)) return false; if (IsIndexValid(index)) return true; set<unsigned>::iterator it = validIndexSet.lower_bound(index); if (it == validIndexSet.end()) return false; return analyser->GetAddrOfIndex(*it, addr); }