Example #1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// TreeCache::Add():
//      Add a position to the cache if applicable..
//
bool
TreeCache::Add (Position * pos, treeT * pTree, Filter * filter)
{
    // Is this tree in the cache already?
    int index = LookupIndex (pos);
    if (index >= 0) {
        // It is! Set the MostRecentIndex:
        MostRecentIndex = index;
        return true;
    }

    // Quick test for the common condition of the cache being full and
    // this tree having a count too low to be added:
    if (Policy == TREECACHE_Smallest  &&  NumInUse == CacheSize
        &&  pTree->totalCount < LowestTotal) {
        return false;
    }

    // Now, we add this tree to the end of the cache it is not full, or
    // if it is full, check if its count is high enough to be added.

    if (NumInUse == CacheSize) {
        // Cache is full!
        // If replacing the smallest, we know its total is high enough
        // to be added, from the test above.

        if (Policy == TREECACHE_Oldest) {
            // Replace the oldest node:
            MostRecentIndex = (MostRecentIndex+1) % CacheSize;
            AddTree (MostRecentIndex, pos, pTree, filter);
        } else {
            // Replace the smallest node:
            AddTree (LowestTotalIndex, pos, pTree, filter);

            // Find the NEW lowest total, the next tree to be evicted:
            LowestTotal = pTree->totalCount;
            for (uint i=0; i < CacheSize; i++) {
                if (Cache[i].tree.totalCount < LowestTotal) {
                    LowestTotal = Cache[i].tree.totalCount;
                    LowestTotalIndex = i;
                }
            }
        }

    } else {
        // Cache is not yet full. Add the position to the cache:
        AddTree (NumInUse, pos, pTree, filter);

        // Update LowestTotal if necessary:
        if (NumInUse == 0  ||  pTree->totalCount < LowestTotal) {
            LowestTotal = pTree->totalCount;
            LowestTotalIndex = NumInUse;
        }
        NumInUse++;
    }
    return true;
}
Example #2
0
    BinarySearchTree(BinarySearchTree& in_bst)
    {
        if(NULL!=root)
            in_bst.root = new Node(root->val);
        else
            return;

        AddTree(in_bst.root, root->left);
        AddTree(in_bst.root, root->right);
    }
Example #3
0
bool MemMgr::GrowOrShrinkStack(StackSpace *space, POLYUNSIGNED newSize)
{
    size_t iSpace = newSize*sizeof(PolyWord);
    PolyWord *newSpace = (PolyWord*)osMemoryManager->Allocate(iSpace, PERMISSION_READ|PERMISSION_WRITE);
    if (newSpace == 0)
    {
        if (debugOptions & DEBUG_MEMMGR)
            Log("MMGR: Unable to change size of stack %p from %lu to %lu: insufficient space\n",
                space, space->spaceSize(), newSize);
        return false;
    }
    // The size may have been rounded up to a block boundary.
    newSize = iSpace/sizeof(PolyWord);
    try {
        AddTree(space, newSpace, newSpace+newSize);
    }
    catch (std::bad_alloc a) {
        RemoveTree(space, newSpace, newSpace+newSize);
        delete space;
        return 0;
    }
    CopyStackFrame(space->stack(), space->spaceSize(), (StackObject*)newSpace, newSize);
    if (debugOptions & DEBUG_MEMMGR)
        Log("MMGR: Size of stack %p changed from %lu to %lu at %p\n", space, space->spaceSize(), newSize, newSpace);
    RemoveTree(space); // Remove it BEFORE freeing the space - another thread may allocate it
    osMemoryManager->Free(space->bottom, (char*)space->top - (char*)space->bottom);
    space->bottom = newSpace;
    space->top = newSpace+newSize;
    return true;
}
void CSpiderTaskTree::OnFileAdded(fsDLWebPageTree root, fsDLWebPageTree child)
{
	int iIndex = FindTree (root);
	if (iIndex == -1)
		return;

	AddTree (child, m_vConfs [iIndex].hItem);
	Expand (m_vConfs [iIndex].hItem, TVE_EXPAND);
}
Example #5
0
StackSpace *MemMgr::NewStackSpace(POLYUNSIGNED size)
{
    PLocker lock(&stackSpaceLock);

    try {
        StackSpace *space = new StackSpace;
        size_t iSpace = size*sizeof(PolyWord);
        space->bottom =
            (PolyWord*)osMemoryManager->Allocate(iSpace, PERMISSION_READ|PERMISSION_WRITE);
        if (space->bottom == 0)
        {
            if (debugOptions & DEBUG_MEMMGR)
                Log("MMGR: New stack space: insufficient space\n");
            delete space;
            return 0;
        }

        // The size may have been rounded up to a block boundary.
        size = iSpace/sizeof(PolyWord);
        space->top = space->bottom + size;
        space->spaceType = ST_STACK;
        space->isMutable = true;

        // Extend the permanent memory table and add this space to it.
        StackSpace **table =
            (StackSpace **)realloc(sSpaces, (nsSpaces+1) * sizeof(StackSpace *));
        if (table == 0)
        {
            if (debugOptions & DEBUG_MEMMGR)
                Log("MMGR: New stack space: table realloc failed\n");
            delete space;
            return 0;
        }
        sSpaces = table;
        // Add the stack space to the tree.  This ensures that operations such as
        // LocalSpaceForAddress will work for addresses within the stack.  We can
        // get them in the RTS with functions such as quot_rem and exception stack.
        // It's not clear whether they really appear in the GC.
        try {
            AddTree(space);
        }
        catch (std::bad_alloc a) {
            RemoveTree(space);
            delete space;
            return 0;
        }
        sSpaces[nsSpaces++] = space;
        if (debugOptions & DEBUG_MEMMGR)
            Log("MMGR: New stack space %p allocated at %p size %lu\n", space, space->bottom, space->spaceSize());
        return space;
    }
    catch (std::bad_alloc a) {
        if (debugOptions & DEBUG_MEMMGR)
            Log("MMGR: New stack space: \"new\" failed\n");
        return 0;
    }
}
void MemCheckOutputView::ShowPageView(size_t page)
{
    // CL_DEBUG1(PLUGIN_PREFIX("MemCheckOutputView::ShowPage()"));

    if(page < 1)
        m_currentPage = 1;
    else if(page > m_pageMax)
        m_currentPage = m_pageMax;
    else
        m_currentPage = page;

    if(m_currentPage == 0)
        m_textCtrlPageNumber->Clear();
    else
        pageValidator.TransferToWindow(); // it sets m_textCtrlPageNumber

    m_currentPageIsEmptyView = true;
    m_currentItem = wxDataViewItem(0);
    m_onValueChangedLocked = false;
    m_markedErrorsCount = 0;
    m_dataViewCtrlErrorsModel->Clear();

    if(m_totalErrorsView == 0) return;

    ErrorList& errorList = m_plugin->GetProcessor()->GetErrors();
    long iStart = (long)(m_currentPage - 1) * m_plugin->GetSettings()->GetResultPageSize();
    long iStop =
        (long)std::min(m_totalErrorsView - 1, m_currentPage * m_plugin->GetSettings()->GetResultPageSize() - 1);
    // CL_DEBUG1(PLUGIN_PREFIX("start - stop = %lu - %lu", iStart, iStop));
    m_currentPageIsEmptyView = (iStop - iStart) < 0;

    // this should never happen if m_totalErrorsView > 0, but...
    if(m_currentPageIsEmptyView) return;

    wxWindowDisabler disableAll;
    wxBusyInfo wait(wxT(BUSY_MESSAGE));
    m_mgr->GetTheApp()->Yield();

    unsigned int flags = 0;
    if(m_plugin->GetSettings()->GetOmitNonWorkspace()) flags |= MC_IT_OMIT_NONWORKSPACE;
    if(m_plugin->GetSettings()->GetOmitDuplications()) flags |= MC_IT_OMIT_DUPLICATIONS;
    if(m_plugin->GetSettings()->GetOmitSuppressed()) flags |= MC_IT_OMIT_SUPPRESSED;
    size_t i = 0;
    MemCheckIterTools::ErrorListIterator it = MemCheckIterTools::Factory(errorList, m_workspacePath, flags);
    for(; i < iStart && it != errorList.end(); ++i, ++it)
        ; // skipping item before start
    // CL_DEBUG1(PLUGIN_PREFIX("items skiped"));
    m_mgr->GetTheApp()->Yield();
    for(; i <= iStop; ++i, ++it) {
        if(it == errorList.end()) {
            CL_WARNING(PLUGIN_PREFIX("Some items skiped. Total errors count mismatches the iterator."));
            break;
        }
        AddTree(wxDataViewItem(0), *it); // CL_DEBUG1(PLUGIN_PREFIX("adding %lu", i));
        if(!(i % WAIT_UPDATE_PER_ITEMS)) m_mgr->GetTheApp()->Yield();
    }
}
Example #7
0
// Create an entry for the IO space.
MemSpace* MemMgr::InitIOSpace(PolyWord *base, POLYUNSIGNED words)
{
    ioSpace->bottom = base;
    ioSpace->top = ioSpace->bottom + words;
    ioSpace->spaceType = ST_IO;
    ioSpace->isMutable = false;
    AddTree(ioSpace);
    return ioSpace;
}
Example #8
0
void __fastcall TmForm::SpTreeClick(TObject *Sender)
{
    // если нет ни одного дерева то создать
    TPageControl *pc;
    TMenuItem *curr=(TMenuItem *)Sender;
    if(curr!=N24&&curr!=N29)
    {
        return;
    }
    switch(curr->Tag)
    {
    case 1:
        {
            pc=RightPC;
            break;
        }
    case -1:
        {
            pc=LeftPC;
            break;
        }
    default:
        return;
    }
    if(Tabs.size())
    {
        TTabSheet *t=GetLastTab(0);
        if(t)
        {
            t->PageControl=pc;
            // если есть хоть одно показать последнее выбранное
        }
        else
        {
            AddTree(pc, 0, Info);
        }
    }
    else
    {
        AddTree(pc, 0, Info);
    }
}
void CSpiderTaskTree::UpdateAll()
{
	DeleteAllItems ();
	m_vConfs.clear ();
	
	if (m_wpd == NULL)
		return;

	fsDLWebPageTree tree = m_wpd->GetRootPage ();

	AddTree (tree, TVI_ROOT);
}
Example #10
0
void ITreeDrawer::AddTrees()
{
	const CFeatureSet& features = featureHandler->GetActiveFeatures();

	for (CFeatureSet::const_iterator it = features.begin(); it != features.end(); ++it) {
		const CFeature* f = *it;

		if (f->def->drawType >= DRAWTYPE_TREE) {
			AddTree(f->id, f->def->drawType - 1, f->pos, 1.0f);
		}
	}
}
Example #11
0
void ITreeDrawer::AddTrees()
{
	for (int fID = 0; /* no test*/; fID++) {
		const CFeature* f = featureHandler->GetFeature(fID);

		if (f) {
			if (f->def->drawType >= DRAWTYPE_TREE) {
				AddTree(f->def->drawType - 1, f->pos, 1.0f);
			}
		} else {
			break;
		}
	}
}
void ExampleFilteredSimDataAnalysis::InitAnalysis()
{
   // INITIALISATION PERFORMED AT BEGINNING OF ANALYSIS
   // Here you define:
   //   - global variables
   //   - histograms
   //   - trees
   //
   // NB: no access to multidetector array or reaction
   //     kinematics yet: see InitRun()

   // DEFINITION OF GLOBAL VARIABLES FOR ANALYSIS

   // charged particle multiplicity
   KVVarGlob* v = AddGV("KVVGSum", "Mcha");
   v->SetOption("mode", "mult");
   v->SetSelection(KVParticleCondition("_NUC_->GetZ()>0"));

   AddGV("KVZtot", "ZTOT");//total charge
   AddGV("KVZVtot", "ZVTOT");//total pseudo-momentum
   ZMAX = (KVZmax*)AddGV("KVZmax", "ZMAX");//fragments sorted by Z

   // DEFINITION OF TREE USED TO STORE RESULTS
   CreateTreeFile();

   TTree* t = new TTree("data", GetOpt("SimulationInfos"));

   // add a branch to tree for each defined global variable
   GetGVList()->MakeBranches(t);

   // add branches to be filled by user
   t->Branch("mult", &mult);
   t->Branch("Z", Z, "Z[mult]/I");
   t->Branch("A", A, "A[mult]/I");
   t->Branch("array", array, "array[mult]/I");
   t->Branch("idcode", idcode, "idcode[mult]/I");
   t->Branch("ecode", ecode, "ecode[mult]/I");
   t->Branch("Ameasured", Ameasured, "Ameasured[mult]/I");
   t->Branch("Vper", Vper, "Vper[mult]/D");
   t->Branch("Vpar", Vpar, "Vpar[mult]/D");
   t->Branch("ELab", ELab, "ELab[mult]/D");
   t->Branch("ThetaLab", ThetaLab, "ThetaLab[mult]/D");
   t->Branch("PhiLab", PhiLab, "PhiLab[mult]/D");

   AddTree(t);

   // check if we can access the original simulated events before filtering
   // (activated when selecting both filtered & simulated files in kaliveda-sim GUI)
   link_to_unfiltered_simulation = IsOptGiven("AuxFiles");
}
Example #13
0
// Create and initialise a new export space and add it to the table.
PermanentMemSpace* MemMgr::NewExportSpace(POLYUNSIGNED size, bool mut, bool noOv)
{
    try {
        PermanentMemSpace *space = new PermanentMemSpace;
        space->spaceType = ST_EXPORT;
        space->isMutable = mut;
        space->noOverwrite = noOv;
        space->index = nextIndex++;
        // Allocate the memory itself.
        size_t iSpace = size*sizeof(PolyWord);
        space->bottom  =
            (PolyWord*)osMemoryManager->Allocate(iSpace, PERMISSION_READ|PERMISSION_WRITE|PERMISSION_EXEC);

        if (space->bottom == 0)
        {
            delete space;
            return 0;
        }
        space->isOwnSpace = true;
 
        // The size may have been rounded up to a block boundary.
        size = iSpace/sizeof(PolyWord);
        space->top = space->bottom + size;
        space->topPointer = space->bottom;

        // Add to the table.
        PermanentMemSpace **table = (PermanentMemSpace **)realloc(eSpaces, (neSpaces+1) * sizeof(PermanentMemSpace *));
        if (table == 0)
        {
            delete space;
            return 0;
        }
        eSpaces = table;
        try {
            AddTree(space);
        }
        catch (std::bad_alloc a) {
            RemoveTree(space);
            delete space;
            return 0;
        }
        eSpaces[neSpaces++] = space;
        return space;
    }
    catch (std::bad_alloc a) {
        return 0;
    }
}
void MemCheckOutputView::AddTree(const wxDataViewItem& parentItem, MemCheckError& error)
{
    // CL_DEBUG1(PLUGIN_PREFIX("error #\t'%s'", error.label));

    wxVariant variantBitmap;
    variantBitmap << wxXmlResource::Get()->LoadBitmap(wxT("memcheck_transparent"));

    wxVector<wxVariant> cols;
    cols.push_back(variantBitmap);
    cols.push_back(wxVariant(false));
    cols.push_back(MemCheckDVCErrorsModel::CreateIconTextVariant(error.label,
        (error.type == MemCheckError::TYPE_AUXILIARY ? wxXmlResource::Get()->LoadBitmap(wxT("memcheck_auxiliary")) :
                                                       wxXmlResource::Get()->LoadBitmap(wxT("memcheck_error")))));
    cols.push_back(wxString());
    cols.push_back(wxString());
    cols.push_back(wxString());
    wxDataViewItem errorItem =
        m_dataViewCtrlErrorsModel->AppendItem(parentItem, cols, new MemCheckErrorReferrer(error));

    for(ErrorList::iterator it = error.nestedErrors.begin(); it != error.nestedErrors.end(); ++it) {
        AddTree(errorItem, *it);
    }

    unsigned int flags = 0;
    if(m_plugin->GetSettings()->GetOmitNonWorkspace()) flags |= MC_IT_OMIT_NONWORKSPACE;
    if(m_plugin->GetSettings()->GetOmitDuplications()) flags |= MC_IT_OMIT_DUPLICATIONS;
    if(m_plugin->GetSettings()->GetOmitSuppressed()) flags |= MC_IT_OMIT_SUPPRESSED;

    wxBitmap bmpLocation = wxXmlResource::Get()->LoadBitmap(wxT("memcheck_location"));
    MemCheckIterTools::LocationListIterator it = MemCheckIterTools::Factory(error.locations, m_workspacePath, flags);
    for(; it != error.locations.end(); ++it) {
        MemCheckErrorLocation& location = *it;
        cols.clear();
        cols.push_back(variantBitmap);
        cols.push_back(wxVariant(false));
        cols.push_back(MemCheckDVCErrorsModel::CreateIconTextVariant(location.func, bmpLocation));
        cols.push_back(wxVariant(location.getFile(m_workspacePath)));

        wxString strLine;
        strLine << location.line;
        cols.push_back(strLine);
        cols.push_back(wxVariant(location.getObj(m_workspacePath)));
        m_dataViewCtrlErrorsModel->AppendItem(errorItem, cols,
            ((location.line > 0 && !location.file.IsEmpty()) ? new MemCheckErrorLocationReferrer(location) : NULL));
    }
}
void CSpiderTaskTree::AddTree(fsDLWebPageTree tree, HTREEITEM hParent)
{
	fsDLWebPage *wp = tree->GetData ();
	int iImage = GetDownloadImage (wp);
	HTREEITEM hItem = InsertItem (wp->strURL, iImage,  iImage, hParent, TVI_SORT);
	
	_Conformity conf; 
	conf.hItem = hItem;
	conf.wptree = tree;
	m_vConfs.add (conf);

	SetItemData (hItem, (DWORD)tree);

	
	for (int i = 0; i < tree->GetLeafCount (); i++)
		AddTree (tree->GetLeaf (i), hItem);

	Expand (hItem, TVE_EXPAND);
}
Example #16
0
// Add a local memory space to the table.
bool MemMgr::AddLocalSpace(LocalMemSpace *space)
{
    // Add to the table.
    LocalMemSpace **table = (LocalMemSpace **)realloc(lSpaces, (nlSpaces+1) * sizeof(LocalMemSpace *));
    if (table == 0) return false;
    lSpaces = table;
    // Update the B-tree.
    try {
        AddTree(space);
    }
    catch (std::bad_alloc a) {
        RemoveTree(space);
        return false;
    }
    // The entries in the local table are ordered so that the copy phase of the full
    // GC simply has to copy to an entry earlier in the table.  Immutable spaces come
    // first, followed by mutable spaces and finally allocation spaces.
    if (space->allocationSpace)
        lSpaces[nlSpaces++] = space; // Just add at the end
    else if (space->isMutable)
    {
        // Add before the allocation spaces
        unsigned s;
        for (s = nlSpaces; s > 0 && lSpaces[s-1]->allocationSpace; s--)
            lSpaces[s] = lSpaces[s-1];
        lSpaces[s] = space;
        nlSpaces++;
    }
    else
    {
        // Immutable space: Add before the mutable spaces
        unsigned s;
        for (s = nlSpaces; s > 0 && lSpaces[s-1]->isMutable; s--)
            lSpaces[s] = lSpaces[s-1];
        lSpaces[s] = space;
        nlSpaces++;
    }
    return true;
}
Example #17
0
// Create an entry for a permanent space.
PermanentMemSpace* MemMgr::NewPermanentSpace(PolyWord *base, POLYUNSIGNED words,
                                             unsigned flags, unsigned index, unsigned hierarchy /*= 0*/)
{
    try {
        PermanentMemSpace *space = new PermanentMemSpace;
        space->bottom = base;
        space->topPointer = space->top = space->bottom + words;
        space->spaceType = ST_PERMANENT;
        space->isMutable = flags & MTF_WRITEABLE ? true : false;
        space->noOverwrite = flags & MTF_NO_OVERWRITE ? true : false;
        space->byteOnly = flags & MTF_BYTES ? true : false;
        space->index = index;
        space->hierarchy = hierarchy;
        if (index >= nextIndex) nextIndex = index+1;

        // Extend the permanent memory table and add this space to it.
        PermanentMemSpace **table =
            (PermanentMemSpace **)realloc(pSpaces, (npSpaces+1) * sizeof(PermanentMemSpace *));
        if (table == 0)
        {
            delete space;
            return 0;
        }
        pSpaces = table;
        try {
            AddTree(space);
        }
        catch (std::bad_alloc a) {
            RemoveTree(space);
            delete space;
            return 0;
        }
        pSpaces[npSpaces++] = space;
        return space;
    }
    catch (std::bad_alloc a) {
        return 0;
    }
}
void SimulatedEventAnalysisTemplate::InitAnalysis()
{
   // INITIALISATION PERFORMED AT BEGINNING OF ANALYSIS
   // Here you define:
   //   - global variables
   //   - histograms
   //   - trees

   // DEFINITION OF GLOBAL VARIABLES FOR ANALYSIS

   // charged particle multiplicity
   KVVarGlob* v = AddGV("KVVGSum", "Mcha");
   v->SetOption("mode", "mult");
   v->SetSelection(KVParticleCondition("_NUC_->GetZ()>0"));

   ZMAX = (KVZmax*)AddGV("KVZmax", "ZMAX");//fragments sorted by Z

   // DEFINITION OF TREE USED TO STORE RESULTS
   CreateTreeFile();

   TTree* t = new TTree("data", GetOpt("SimulationInfos"));

   // add a branch to tree for each defined global variable
   GetGVList()->MakeBranches(t);

   // add branches to be filled by user
   t->Branch("mult", &mult);
   t->Branch("Z", Z, "Z[mult]/I");
   t->Branch("A", A, "A[mult]/I");
   t->Branch("Vper", Vper, "Vper[mult]/D");
   t->Branch("Vpar", Vpar, "Vpar[mult]/D");
   t->Branch("E", E, "E[mult]/D");
   t->Branch("Theta", Theta, "Theta[mult]/D");
   t->Branch("Phi", Phi, "Phi[mult]/D");

   AddTree(t);

}
void ExampleINDRAAnalysis::InitAnalysis(void)
{
   // Declaration of histograms, global variables, etc.
   // Called at the beginning of the analysis
   // The examples given are compatible with interactive, batch,
   // and PROOFLite analyses.

   /*** ADDING GLOBAL VARIABLES TO THE ANALYSIS ***/
   /* These will be automatically calculated for each event before
      your Analysis() method will be called                        */
   AddGV("KVZtot", "ztot");                             // total charge
   AddGV("KVZVtot", "zvtot")->SetMaxNumBranches(1);     // total Z*vpar
   AddGV("KVEtransLCP", "et12");                        // total LCP transverse energy
   AddGV("KVFlowTensor", "tensor")->SetOption("weight", "RKE");  // relativistic CM KE tensor
   GetGV("tensor")->SetSelection("_NUC_->GetZ()>2");
   GetGV("tensor")->SetMaxNumBranches(2);               // FlowAngle & Sphericity branches
   AddGV("KVMultLeg", "Mlcp");
   AddGV("KVTensPCM", "tenspcm")->SetMaxNumBranches(2); // FlowAngle & Sphericity branches

   /*** USING A TREE ***/
   CreateTreeFile();//<--- essential
   TTree* t = new TTree("myTree", "");
   AddTree(t);
   GetGVList()->MakeBranches(t); // store global variable values in branches
   t->AddVar(Mult, I);
   t->AddVar(MTensor, I);
   t->AddVar(Run, I);
   t->AddVar(Trigger, I);
   t->AddVar(EventNumber, I);

   /*** DEFINE WHERE TO SAVE THE RESULTS ***/
   // When running in batch/PROOF mode, we use the job name
   if (gDataAnalyser->GetBatchSystem())
      SetCombinedOutputFile(Form("%s.root", gDataAnalyser->GetBatchSystem()->GetJobName()));
   else
      SetCombinedOutputFile(Form("ExampleINDRAAnalysis_results.root"));
}
Example #20
0
void __fastcall TmForm::TreeBTNClick(TObject *Sender)
{
    AddTree(LeftPC, 0, Info);
}
Example #21
0
void ITreeDrawer::RenderFeatureCreated(const CFeature* feature) {
	// support /give'ing tree objects
	if (feature->def->drawType >= DRAWTYPE_TREE) {
		AddTree(feature->id, feature->def->drawType - 1, feature->pos, 1.0f);
	}
}
Example #22
0
void ITreeDrawer::RenderFeatureMoved(const CFeature* feature, const float3& oldpos, const float3& newpos) {
	if (feature->def->drawType >= DRAWTYPE_TREE) {
		DeleteTree(feature->id, oldpos);
		AddTree(feature->id, feature->def->drawType - 1, newpos, 1.0f);
	}
}
Example #23
0
static int MenuCommand(WPARAM wParam, HWND hWnd)
{
    BOOL vis;
    HTREEITEM hSelect;
    WCHAR wszAbout[MAX_LOAD_STRING];
    WCHAR wszAboutVer[MAX_LOAD_STRING];

    switch(wParam)
    {
        case IDM_ABOUT:
            LoadStringW(globals.hMainInst, IDS_ABOUT, wszAbout,
                    sizeof(wszAbout)/sizeof(wszAbout[0]));
            LoadStringW(globals.hMainInst, IDS_ABOUTVER, wszAboutVer,
                    sizeof(wszAboutVer)/sizeof(wszAboutVer[0]));
            ShellAboutW(hWnd, wszAbout, wszAboutVer, NULL);
            break;
        case IDM_COPYCLSID:
            hSelect = (HTREEITEM)SendMessageW(globals.hTree,
                    TVM_GETNEXTITEM, TVGN_CARET, 0);
            CopyClsid(hSelect);
            break;
        case IDM_HTMLTAG:
            hSelect = (HTREEITEM)SendMessageW(globals.hTree,
                    TVM_GETNEXTITEM, TVGN_CARET, 0);
            CopyHTMLTag(hSelect);
            break;
        case IDM_CREATEINST:
            hSelect = (HTREEITEM)SendMessageW(globals.hTree,
                    TVM_GETNEXTITEM, TVGN_CARET, 0);
            CreateInst(hSelect, NULL);
            SendMessageW(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hSelect);
            break;
        case IDM_CREATEINSTON:
            if(DialogBoxW(0, MAKEINTRESOURCEW(DLG_CREATEINSTON),
                        hWnd, CreateInstOnProc) == IDCANCEL) break;
            hSelect = (HTREEITEM)SendMessageW(globals.hTree,
                    TVM_GETNEXTITEM, TVGN_CARET, 0);
            CreateInst(hSelect, globals.wszMachineName);
            SendMessageW(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hSelect);
            break;
        case IDM_RELEASEINST:
            hSelect = (HTREEITEM)SendMessageW(globals.hTree,
                    TVM_GETNEXTITEM, TVGN_CARET, 0);
            ReleaseInst(hSelect);
            RefreshMenu(hSelect);
            RefreshDetails(hSelect);
            break;
        case IDM_EXPERT:
            globals.bExpert = !globals.bExpert;
            CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
                    globals.bExpert ? MF_CHECKED : MF_UNCHECKED);
            EmptyTree();
            if(globals.bExpert) AddTreeEx();
            else AddTree();
            hSelect = (HTREEITEM)SendMessageW(globals.hTree,
                    TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)TVI_ROOT);
            SendMessageW(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect);
            RefreshMenu(hSelect);
            break;
        case IDM_FLAG_INSERV:
            vis = globals.dwClsCtx&CLSCTX_INPROC_SERVER;
            globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_SERVER);
            globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_SERVER);
            if(!globals.dwClsCtx) globals.dwClsCtx = vis;
            else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
                    vis ? MF_UNCHECKED : MF_CHECKED);
            break;
        case IDM_FLAG_INHANDL:
            vis = globals.dwClsCtx&CLSCTX_INPROC_HANDLER;
            globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_HANDLER);
            globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_HANDLER);
            if(!globals.dwClsCtx) globals.dwClsCtx = vis;
            else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
                    vis ? MF_UNCHECKED : MF_CHECKED);
            break;
        case IDM_FLAG_LOCSERV:
            vis = globals.dwClsCtx&CLSCTX_LOCAL_SERVER;
            globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_LOCAL_SERVER);
            globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_LOCAL_SERVER);
            if(!globals.dwClsCtx) globals.dwClsCtx = vis;
            else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
                    vis ? MF_UNCHECKED : MF_CHECKED);
            break;
        case IDM_FLAG_REMSERV:
            vis = globals.dwClsCtx&CLSCTX_REMOTE_SERVER;
            globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_REMOTE_SERVER);
            globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_REMOTE_SERVER);
            if(!globals.dwClsCtx) globals.dwClsCtx = vis;
            else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
                    vis ? MF_UNCHECKED : MF_CHECKED);
            break;
        case IDM_REFRESH:
            EmptyTree();
            if(globals.bExpert) AddTreeEx();
            else AddTree();
            hSelect = (HTREEITEM)SendMessageW(globals.hTree,
                    TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)TVI_ROOT);
            SendMessageW(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect);
            RefreshMenu(hSelect);
            break;
        case IDM_REGEDIT:
        {
            STARTUPINFOW si;
            PROCESS_INFORMATION pi;
            WCHAR app[MAX_PATH];

            GetWindowsDirectoryW( app, MAX_PATH - sizeof(wszRegEdit)/sizeof(WCHAR) );
            lstrcatW( app, wszRegEdit );
            memset(&si, 0, sizeof(si));
            si.cb = sizeof(si);
            if (CreateProcessW(app, app, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
            {
                CloseHandle(pi.hProcess);
                CloseHandle(pi.hThread);
            }
            break;
        }
        case IDM_STATUSBAR:
            vis = IsWindowVisible(globals.hStatusBar);
            ShowWindow(globals.hStatusBar, vis ? SW_HIDE : SW_SHOW);
            CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
                    vis ? MF_UNCHECKED : MF_CHECKED);
            ResizeChild();
            break;
        case IDM_SYSCONF:
            DialogBoxW(0, MAKEINTRESOURCEW(DLG_SYSCONF), hWnd, SysConfProc);
            break;
        case IDM_TOOLBAR:
            vis = IsWindowVisible(globals.hToolBar);
            ShowWindow(globals.hToolBar, vis ? SW_HIDE : SW_SHOW);
            CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
                    vis ? MF_UNCHECKED : MF_CHECKED);
            ResizeChild();
            break;
        case IDM_TYPELIB:
            {
            static const WCHAR filterW[] = {'%','s','%','c','*','.','t','l','b',';','*','.','o','l','b',';','*','.','d','l','l',';','*','.','o','c','x',';','*','.','e','x','e','%','c','%','s','%','c','*','.','*','%','c',0};
            OPENFILENAMEW ofn;
            static WCHAR wszTitle[MAX_LOAD_STRING];
            static WCHAR wszName[MAX_LOAD_STRING];
            WCHAR filter_typelib[MAX_LOAD_STRING], filter_all[MAX_LOAD_STRING], filter[MAX_PATH];

            LoadStringW(globals.hMainInst, IDS_OPEN, wszTitle, sizeof(wszTitle)/sizeof(wszTitle[0]));
            LoadStringW(globals.hMainInst, IDS_OPEN_FILTER_TYPELIB, filter_typelib, sizeof(filter_typelib)/sizeof(WCHAR));
            LoadStringW(globals.hMainInst, IDS_OPEN_FILTER_ALL, filter_all, sizeof(filter_all)/sizeof(WCHAR));
            snprintfW( filter, MAX_PATH, filterW, filter_typelib, 0, 0, filter_all, 0, 0 );
            InitOpenFileName(hWnd, &ofn, filter, wszTitle, wszName);
            if(GetOpenFileNameW(&ofn)) CreateTypeLibWindow(globals.hMainInst, wszName);
            break;
            }
        case IDM_VIEW:
            hSelect = (HTREEITEM)SendMessageW(globals.hTree,
                    TVM_GETNEXTITEM, TVGN_CARET, 0);
            if(IsInterface(hSelect)) InterfaceViewer(hSelect);
            else CreateTypeLibWindow(globals.hMainInst, NULL);
            break;
        case IDM_EXIT:
            DestroyWindow(hWnd);
            break;
    }
    return 0;
}
Example #24
0
__fastcall TmForm::TmForm(TComponent *Owner):TForm(Owner), UserID(0)
{
#ifndef NODB
    ADC->ConnectionString="FILE NAME="+ExtractFileDir(Application->ExeName)+
        "\\lib\\connect.udl";

    ADC->Connected=true;
#endif
    DB=new cSQL(ADC);
    TLogIn *wnd=new TLogIn(this, DB);
    wnd->ShowModal();
    selected=0;
    if(wnd->ModalResult==mrOk)
    {
        Tabs.clear();
        IcoData=new IconsData(this);
        LoadIL();
        UserID=wnd->Get_UserID();
        // настройка содержимого
        String sql="call administration.Get_Rights('"+String(UserID)+"')";
        TADOQuery *rez=DB->SendSQL(sql);
        bool SpView=false, TehRead=false, TehEdit=false, NormEdit=false, plan_pr_va_det=false,
        otbor_po_ceu=false, mat_ved=false, texnologic=false,Orders=false,manufacture_view=false;
        if(rez&&rez->RecordCount)
        {
            for (rez->First(); !rez->Eof; rez->Next())
            {
                const String val=rez->FieldByName("progname")->Value;
                if (val=="SpView")
                {
                    SpView=true;
                }
                if (val=="TehRead")
                {
                    TehRead=true;
                }
                if (val=="TehEdit")
                {
                    TehEdit=true;
                }
                if (val=="NormEdit")
                {
                    NormEdit=true;
                }
                if (val=="plan_pr_va_det")
                {
                    plan_pr_va_det=true;
                }
                if (val=="otbor_po_ceu")
                {
                    otbor_po_ceu=true;
                }
                if (val=="mat_ved")
                {
                    mat_ved=true;
                }
                if (val=="texnologic")
                {
                    texnologic=true;
                }
                if (val=="OrderView")
                {
                    Orders=true;
                }
                if (val=="manufacture_view")
                {
                    manufacture_view=true;
                }
            }
        }
        delete rez;
        //
        N24->Visible=SpView;
        N29->Visible=SpView;
        TreeBTN->Visible=SpView;
        //
        N26->Visible=false; // TehRead;
        N27->Visible=false; // TehRead;
        TechnologicVievBTN->Visible=false; // TehRead;
        //
        N6->Visible=TehEdit+NormEdit+TehRead;
        N30->Visible=TehEdit+NormEdit+TehRead;
        TechnologicBTN->Visible=TehEdit+NormEdit+TehRead;
        //
        N18->Enabled=plan_pr_va_det;
        N19->Enabled=otbor_po_ceu;
        N20->Enabled=mat_ved;
        N21->Enabled=mat_ved;
        N22->Enabled=texnologic;
        //
        OrdersBTN->Visible=Orders;
        N13->Visible=Orders;
        N25->Visible=Orders;
        //
        N28->Visible=manufacture_view;
        N28->Enabled=manufacture_view;
        N33->Visible=manufacture_view;
        N33->Enabled=manufacture_view;
        N34->Visible=manufacture_view;
        N34->Enabled=manufacture_view;
        N35->Visible=manufacture_view;
        N35->Enabled=manufacture_view;
        ManufactureBTN->Visible = manufacture_view;
        N36->Visible=manufacture_view;
        N37->Visible=manufacture_view;
        if(SpView)
        {
            AddTree(LeftPC, 0, Info);
        }
        /* if (TehEdit+NormEdit)
         {
         AddTexTab(RightPC,0);
         } */
        AddSearch(RightPC);

        String name=""; //добавить запрос на получение имени для отчета
        sql="call administration.Get_Name('"+String(UserID)+"')";
        rez=DB->SendSQL(sql);
        if (rez&&rez->RecordCount)
        {
            name=rez->FieldByName("name")->Value;
        }
        delete rez;
        HINSTANCE Reports=LoadLibrary(String("lib\\Reports.dll").c_str());
        // загружаем длл
        if(Reports)
        {
            RepInit=(init_func)GetProcAddress(Reports, "_Init");
            if(RepInit)
            {
                RepInit(name, DB);
                RepStart=(RepStart_func)GetProcAddress(Reports, "_Report");
                // получаем указатель на функцию
            }
        }
    }
    else
    {
        Application->Terminate();
    }
    /* динамический вызов
     typedef bool (*InetIsOffline_func)(int);
     InetIsOffline_func InetIsOffline;
     HINSTANCE LibHeader=LoadLibrary(String("URL.DLL").c_str());//загружаем длл
     if(!LibHeader){
     throw Exception("Не удалось загрузить библиотеку URL.DLL");
     };
     InetIsOffline=(InetIsOffline_func)GetProcAddress(LibHeader,"InetIsOffline");//получаем указатель на функцию
     if(!InetIsOffline){
     throw Exception("В библиотеке URL.DLL не найдена функция InetIsOffline");
     };
     //вызов функции
     int Flag;
     bool result=InetIsOffline(Flag);
     //освобождение библиотеки
     FreeLibrary(LibHeader);
     */
}
Example #25
0
static int MenuCommand(WPARAM wParam, HWND hWnd)
{
    BOOL vis;
    HTREEITEM hSelect;
    WCHAR wszAbout[MAX_LOAD_STRING];
    WCHAR wszAboutVer[MAX_LOAD_STRING];

    switch(wParam)
    {
        case IDM_ABOUT:
            LoadString(globals.hMainInst, IDS_ABOUT, wszAbout,
                    sizeof(WCHAR[MAX_LOAD_STRING]));
            LoadString(globals.hMainInst, IDS_ABOUTVER, wszAboutVer,
                    sizeof(WCHAR[MAX_LOAD_STRING]));
            ShellAbout(hWnd, wszAbout, wszAboutVer, NULL);
            break;
        case IDM_COPYCLSID:
            hSelect = TreeView_GetSelection(globals.hTree);
            CopyClsid(hSelect);
            break;
        case IDM_HTMLTAG:
            hSelect = TreeView_GetSelection(globals.hTree);
            CopyHTMLTag(hSelect);
            break;
        case IDM_CREATEINST:
            hSelect = TreeView_GetSelection(globals.hTree);
            CreateInst(hSelect, NULL);
            SendMessage(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hSelect);
            break;
        case IDM_CREATEINSTON:
            if(DialogBox(0, MAKEINTRESOURCE(DLG_CREATEINSTON),
                        hWnd, CreateInstOnProc) == IDCANCEL) break;
            hSelect = TreeView_GetSelection(globals.hTree);
            CreateInst(hSelect, globals.wszMachineName);
            SendMessage(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hSelect);
            break;
        case IDM_RELEASEINST:
            hSelect = TreeView_GetSelection(globals.hTree);
            ReleaseInst(hSelect);
            RefreshMenu(hSelect);
            RefreshDetails(hSelect);
            break;
        case IDM_EXPERT:
            globals.bExpert = !globals.bExpert;
            CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
                    globals.bExpert ? MF_CHECKED : MF_UNCHECKED);
            EmptyTree();
            if(globals.bExpert) AddTreeEx();
            else AddTree();
            hSelect = TreeView_GetChild(globals.hTree, TVI_ROOT);
            SendMessage(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect);
            RefreshMenu(hSelect);
            break;
        case IDM_FLAG_INSERV:
            vis = globals.dwClsCtx&CLSCTX_INPROC_SERVER;
            globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_SERVER);
            globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_SERVER);
            if(!globals.dwClsCtx) globals.dwClsCtx = vis;
            else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
                    vis ? MF_UNCHECKED : MF_CHECKED);
            break;
        case IDM_FLAG_INHANDL:
            vis = globals.dwClsCtx&CLSCTX_INPROC_HANDLER;
            globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_HANDLER);
            globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_HANDLER);
            if(!globals.dwClsCtx) globals.dwClsCtx = vis;
            else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
                    vis ? MF_UNCHECKED : MF_CHECKED);
            break;
        case IDM_FLAG_LOCSERV:
            vis = globals.dwClsCtx&CLSCTX_LOCAL_SERVER;
            globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_LOCAL_SERVER);
            globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_LOCAL_SERVER);
            if(!globals.dwClsCtx) globals.dwClsCtx = vis;
            else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
                    vis ? MF_UNCHECKED : MF_CHECKED);
            break;
        case IDM_FLAG_REMSERV:
            vis = globals.dwClsCtx&CLSCTX_REMOTE_SERVER;
            globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_REMOTE_SERVER);
            globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_REMOTE_SERVER);
            if(!globals.dwClsCtx) globals.dwClsCtx = vis;
            else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
                    vis ? MF_UNCHECKED : MF_CHECKED);
            break;
        case IDM_REFRESH:
            EmptyTree();
            if(globals.bExpert) AddTreeEx();
            else AddTree();
            hSelect = TreeView_GetChild(globals.hTree, TVI_ROOT);
            SendMessage(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect);
            RefreshMenu(hSelect);
            break;
        case IDM_REGEDIT:
        {
            STARTUPINFO si;
            PROCESS_INFORMATION pi;

            memset(&si, 0, sizeof(si));
            si.cb = sizeof(si);
            CreateProcess(NULL, wszRegEdit, NULL, NULL, FALSE, 0,
                    NULL, NULL, &si, &pi);
            CloseHandle(pi.hProcess);
            CloseHandle(pi.hThread);
            break;
        }
        case IDM_STATUSBAR:
            vis = IsWindowVisible(globals.hStatusBar);
            ShowWindow(globals.hStatusBar, vis ? SW_HIDE : SW_SHOW);
            CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
                    vis ? MF_UNCHECKED : MF_CHECKED);
            ResizeChild();
            break;
        case IDM_SYSCONF:
            DialogBox(0, MAKEINTRESOURCE(DLG_SYSCONF), hWnd, SysConfProc);
            break;
        case IDM_TOOLBAR:
            vis = IsWindowVisible(globals.hToolBar);
            ShowWindow(globals.hToolBar, vis ? SW_HIDE : SW_SHOW);
            CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
                    vis ? MF_UNCHECKED : MF_CHECKED);
            ResizeChild();
            break;
        case IDM_TYPELIB:
            {
            OPENFILENAME ofn;
            static WCHAR wszTitle[MAX_LOAD_STRING];
            static WCHAR wszName[MAX_LOAD_STRING];
            static WCHAR wszFilter[MAX_LOAD_STRING];

            LoadString(globals.hMainInst, IDS_OPEN, wszTitle, sizeof(wszTitle));
            LoadString(globals.hMainInst, IDS_OPEN_TYPELIB_FILTER, wszFilter, sizeof(wszFilter));
            InitOpenFileName(hWnd, &ofn, wszFilter, wszTitle, wszName);
            if(GetOpenFileName(&ofn)) CreateTypeLibWindow(globals.hMainInst, wszName);
            break;
            }
        case IDM_VIEW:
            hSelect = TreeView_GetSelection(globals.hTree);
            if(IsInterface(hSelect)) InterfaceViewer(hSelect);
            else CreateTypeLibWindow(globals.hMainInst, NULL);
            break;
        case IDM_EXIT:
            DestroyWindow(hWnd);
            break;
    }
    return 0;
}
Example #26
0
void CItemBrowserDlg::ShowCurrent ()
{
	HTREEITEM hSel = NULL;
	unsigned char *pauchData = NULL;

	//
	// Just put a big FAT ASS wait cursor around the whole thing
	//

	CWaitCursor sWC;

	//
	// Reset the treeview
	//

	m_tv .DeleteAllItems ();

	//
	// Get what we are browsing
	//

	Browse_What nBrowseWhat = m_nBrowseWhat;
	if (nBrowseWhat == Browse_What_EncPlace)
	{
		if (m_cbBrowseFor .GetCurSel () == 0)
			nBrowseWhat = Browse_What_Encounters;
		else
			nBrowseWhat = Browse_What_Placeables;
	}

	//
	// Get the current combo setting
	//

	int nSel = m_cbSource .GetCurSel ();
	if (nSel < 0)
		return;

	//
	// If this is the first selection, then we use the NWN files
	//

	UINT32 ulSize;
	bool fAllocated;
	if (nSel == 0)
	{
		if (nBrowseWhat == Browse_What_Items)
		{
			pauchData = g_sStdLoader .LoadResource ("itempalstd", 
				NwnResType_ITP, &ulSize, &fAllocated);
		}
		else if (nBrowseWhat == Browse_What_Encounters)
		{
			pauchData = g_sStdLoader .LoadResource ("creaturepalstd", 
				NwnResType_ITP, &ulSize, &fAllocated);
		}
		else if (nBrowseWhat == Browse_What_Placeables)
		{
			pauchData = g_sStdLoader .LoadResource ("placeablepalstd", 
				NwnResType_ITP, &ulSize, &fAllocated);
		}
		else
			_ASSERTE (FALSE);
	}
	else
	{
		CString str;
		m_cbSource .GetLBText (nSel, str);
		CNwnModuleFile sMod;
		if (sMod .Open (g_strNwnModuleDir + str))
		{
			if (nBrowseWhat == Browse_What_Items)
			{
				pauchData = sMod .LoadRes ("itempalcus", 
				    NwnResType_ITP, &ulSize, &fAllocated);
			}
			else if (nBrowseWhat == Browse_What_Encounters)
			{
				pauchData = sMod .LoadRes ("creaturepalcus", 
				    NwnResType_ITP, &ulSize, &fAllocated);
			}
			else if (nBrowseWhat == Browse_What_Placeables)
			{
				pauchData = sMod .LoadRes ("placeablepalcus", 
				    NwnResType_ITP, &ulSize, &fAllocated);
			}
			else
				_ASSERTE (FALSE);
		}
	}

	//
	// If nothing was found
	//

	if (pauchData == NULL)
	{
		CString str;
		str .LoadString (IDS_ERR_NOPALETTE);
		::MessageBox (m_hWnd, str, g_szAppName, MB_OK);
		return;
	}

	//
	// Load up the tree
	//

	CNwnHierarchy sPal (pauchData, ulSize, fAllocated);
	CNwnHierarchy::Entry *pEntry = sPal .GetEntry (0);
	UINT32 *plMap = sPal .GetMultiMapTable (pEntry);
	for (int j = 0; j < pEntry ->ulCount; j++)
	{
		int nElement = plMap [j];
		const CNwnHierarchy::Element *pElement = 
			sPal .GetElement (nElement);
		if (pElement ->ulType == CNwnHierarchy::ElementType_LIST)
		{
			UINT32 *plList = sPal .GetListTable (pElement);
			long lCount = *plList++;
			for (j = 0; j < lCount; j++)
				AddTree (sPal, plList [j], TVI_ROOT, hSel);
		}
	}

	//
	// If there is a selection, then select it
	//

	if (hSel != NULL)
	{
		m_tv .EnsureVisible (hSel);
		m_tv .SelectItem (hSel);
		m_strSelection .Empty ();
	}
}
Example #27
0
void CItemBrowserDlg::AddTree (CNwnHierarchy &sPal, 
	int nEntry, HTREEITEM hParent, HTREEITEM &hSel)
{
	char szName [64];
	char szBlueprint [64];
	int nList = -1;

	//
	// Init the string
	//

	szName [0] = szBlueprint [0] = 0;

	//
	// Get the entry in question
	//

	CNwnHierarchy::Entry *pEntry = sPal .GetEntry (nEntry);

	//
	// Collect information about what we need to add
	//

	UINT32 *plMap = sPal .GetMultiMapTable (pEntry);
	for (int j = 0; j < pEntry ->ulCount; j++)
	{
		int nElement = plMap [j];
		const CNwnHierarchy::Element *pElement = 
			sPal .GetElement (nElement);

		//
		// If this is a list, get the element
		//

		if (pElement ->ulType == CNwnHierarchy::ElementType_LIST)
		{
            nList = nElement;
		}

		//
		// Otherwise, inspect the variable name to get 
		// the other information
		//

		else 
		{

			//
			// Get the name
			//

			CNwnHierarchy::VarName *pVarName = 
				sPal .GetVarName (pElement ->ulVarName);

			//
			// If this is the strref, get the name
			//

			if (stricmp (pVarName ->szName, "STRREF") == 0)
			{
				g_sDialogTlkFile .GetString (pElement ->u32Data, 
					szName, _countof (szName));
			}

			//
			// If this is a name, get the name
			//

			else if (stricmp (pVarName ->szName, "NAME") == 0)
			{
				sPal .GetElementLongString (pElement, 
					szName, _countof (szName));
			}

			//
			// If this is a resref, get the blueprint
			//

			else if (stricmp (pVarName ->szName, "RESREF") == 0)
			{
				sPal .GetElementShortString (pElement, 
					szBlueprint, _countof (szBlueprint));
			}
		}
	}

	//
	// Generate the name
	//

	CString str (szName);
	if (szBlueprint [0] != 0)
	{
		str += _T (" [");
		str += szBlueprint;
		str += _T ("]");
	}

	//
	// Add to the tree view
	//

	TVINSERTSTRUCT tvi;
	tvi .hParent = hParent;
	tvi .hInsertAfter = TVI_LAST;
	tvi .item .mask = TVIF_PARAM | TVIF_TEXT;
	tvi .item .hItem = 0;
	tvi .item .state = 0;
	tvi .item .stateMask = 0;
	tvi .item .pszText = (LPTSTR) (LPCTSTR) str;
	tvi .item .cchTextMax = 0;
	tvi .item .iImage = 0;
	tvi .item .iSelectedImage = 0;
	tvi .item .cChildren = 0;
	tvi .item .lParam = (nList == -1);
	HTREEITEM hTI = m_tv .InsertItem (&tvi);

	//
	// If we found our selection
	//

	if (szBlueprint [0] && _tcsicmp (m_strSelection, szBlueprint) == 0)
		hSel = hTI;

	//
	// If we have a list, add this list
	//

	if (hTI != NULL && nList != -1)
	{
		const CNwnHierarchy::Element *pElement = sPal .GetElement (nList);
		UINT32 *plList = sPal .GetListTable (pElement);
		long lCount = *plList++;
		for (j = 0; j < lCount; j++)
			AddTree (sPal, plList [j], hTI, hSel);
	}
}