コード例 #1
0
// is the control in the panel?
//-----------------------------------------------------------------------------
bool CPUTGuiController::IsControlInPanel(CPUTControlID controlID, CPUTControlID panelID)
{
    CPUTControlID panelSlotID;
    if(-1==panelID)
    {
        // use the currently active panel if none specified
        panelSlotID = mActiveControlPanelSlotID;
    }
    else
    {
        panelSlotID = FindPanelIDIndex(panelID);
    }

    // invalid panel
    if(CPUT_CONTROL_ID_INVALID == panelSlotID)
        return false;

    // walk list of controls in the panel and see if control is there
    for(UINT i=0; i<mControlPanelIDList[panelSlotID]->mControlList.size(); i++)
    {
        if( controlID == mControlPanelIDList[panelSlotID]->mControlList[i]->GetControlID() )
            return true;
    }
    return false;
}
コード例 #2
0
// removes specified control from the panel (does not delete the control)
//-----------------------------------------------------------------------------
CPUTResult CPUTGuiController::RemoveControlFromPanel(CPUTControlID controlID, CPUTControlID panelID)
{
    CPUTControlID panelSlotID;
    if(CPUT_CONTROL_ID_INVALID==panelID)
    {
        // use the currently active panel if none specified
        panelSlotID = mActiveControlPanelSlotID;
    }
    else
    {
        panelSlotID = FindPanelIDIndex(panelID);
    }

    // invalid panel
    //if(CPUT_CONTROL_ID_INVALID == panelSlotID)
        //return CPUT_ERROR_INVALID_PARAMETER;

    // walk list of controls in the panel and see if control is there
    for(UINT i=0; i<mControlPanelIDList[panelSlotID]->mControlList.size(); i++)
    {
        if( controlID == mControlPanelIDList[panelSlotID]->mControlList[i]->GetControlID() )
        {
            mControlPanelIDList[panelSlotID]->mControlList.erase( (mControlPanelIDList[panelSlotID]->mControlList.begin() + i) );

            // trigger refresh
            if(mbAutoLayout)
            {
                Resize();
            }

            return CPUT_SUCCESS;
        }
    }
    return CPUT_WARNING_NOT_FOUND;
}
コード例 #3
0
// finds panel with matching ID and sets it as the active one
// if panelID is CPUT_CONTROL_ID_INVALID - it will disable all panels
//-----------------------------------------------------------------------------
CPUTResult CPUTGuiController::SetActivePanel(CPUTControlID panelID)
{
    CPUTControlID panelSlotID = FindPanelIDIndex(panelID);

    // if we found it, set it active
    if(CPUT_CONTROL_ID_INVALID == panelSlotID)
    {
        return CPUT_ERROR_NOT_FOUND;
    }

    // store previously active control
    mControlPanelIDList[mActiveControlPanelSlotID]->mpFocusControl = mpFocusControl;

    // change the active panel and refresh screen
    mActiveControlPanelSlotID = panelSlotID;
    mpFocusControl = mControlPanelIDList[mActiveControlPanelSlotID]->mpFocusControl;

    // trigger refresh
    if(mbAutoLayout)
    {
        Resize();
    }

    return CPUT_SUCCESS;
}
コード例 #4
0
// Add a control (to a panel)
//-----------------------------------------------------------------------------
CPUTResult CPUTGuiController::AddControl(CPUTControl *pControl, CPUTControlID panelID)
{
    mRecalculate = true;
    // set the global callback handler for this object
    pControl->SetControlCallback(mpHandler);

    CPUTControlID panelSlotID = FindPanelIDIndex(panelID);

    // if the panel wasn't found, add a new one
    if(CPUT_CONTROL_ID_INVALID == panelSlotID)
    {
        Panel *pNewControlPanel = new Panel();
        pNewControlPanel->mpanelID = panelID;
        pNewControlPanel->mControlList.clear();
        pNewControlPanel->mpFocusControl = NULL;

        mControlPanelIDList.push_back( pNewControlPanel );
        panelSlotID = (int)mControlPanelIDList.size()-1;

        // make the newly added panel active if none was
        // active before
        if(CPUT_CONTROL_ID_INVALID == mActiveControlPanelSlotID)
            mActiveControlPanelSlotID = panelSlotID;
    }

    // store the control in the list
    mControlPanelIDList[panelSlotID]->mControlList.push_back(pControl);

    return CPUT_SUCCESS;
}
コード例 #5
0
// removes panel and deletes all controls associated with it
//-----------------------------------------------------------------------------
CPUTResult CPUTGuiController::DeletePanel(CPUTControlID panelID)
{

    // find the panel they specified
    CPUTControlID panelSlotID = FindPanelIDIndex(panelID);

	if (panelSlotID == -1)
	{
		return CPUT_ERROR_INVALID_PARAMETER;
	}

    // walk the panel and delete all the controls in it
    for(UINT i=0; i<mControlPanelIDList[panelSlotID]->mControlList.size(); i++)
    {
        // delete each control
        SAFE_DELETE_ARRAY(mControlPanelIDList[panelSlotID]->mControlList[i]);        
    }

    // remove this panel from the control list
    mControlPanelIDList.erase(mControlPanelIDList.begin()+panelSlotID);

    // if the panel you delete is the active one, set the active panel to first
    // or invalid if none are left
    if(mActiveControlPanelSlotID == panelSlotID)
    {
        // set panel to the first panel
        if(0 == mControlPanelIDList.size())
            mActiveControlPanelSlotID = CPUT_CONTROL_ID_INVALID;
        else
            mActiveControlPanelSlotID = 0;
    }
    return CPUT_SUCCESS;
}
コード例 #6
0
// Returns the number of controls in the currently ACTIVE panel
//-----------------------------------------------------------------------------
int CPUTGuiController::GetNumberOfControlsInPanel(CPUTControlID panelID)
{
    // if not specified, returns count of currently active pane
    if(-1 == panelID)
    {
        if(CPUT_CONTROL_ID_INVALID == mActiveControlPanelSlotID)
            return 0;
        return (int) mControlPanelIDList[mActiveControlPanelSlotID]->mControlList.size();
    }

    // if panelID specified, return that number, or 0 if not found
    UINT foundID = FindPanelIDIndex(panelID);
    if(CPUT_CONTROL_ID_INVALID != foundID)
        return (int) mControlPanelIDList[foundID]->mControlList.size();

    return CPUT_CONTROL_ID_INVALID;
}
コード例 #7
0
void CPUTGuiController::DeleteControlsFromPanel(CPUTControlID panelID)
{
	// find the panel they specified
	CPUTControlID panelSlotID = FindPanelIDIndex(panelID);

	if (panelSlotID == -1)
	{
		return;
	}

	// walk the panel and delete all the controls in it
	for (UINT i = 0; i < mControlPanelIDList[panelSlotID]->mControlList.size(); i++)
	{
		// delete each control
		CPUTControl *control = mControlPanelIDList[panelSlotID]->mControlList[i];
		if (mpFocusControl == control)
			mpFocusControl = NULL;
		SAFE_DELETE_ARRAY(mControlPanelIDList[panelSlotID]->mControlList[i]);
	}
	mControlPanelIDList[panelSlotID]->mControlList.clear();
}
コード例 #8
0
// Add a control (to a panel)
//-----------------------------------------------------------------------------
CPUTResult CPUTGuiController::AddControl(CPUTControl *pControl, CPUTControlID panelID)
{
    //if(NULL == pControl)
        //return CPUT_ERROR_INVALID_PARAMETER;

    // set the global callback handler for this object
    pControl->SetControlCallback(mpHandler);

    CPUTControlID panelSlotID = FindPanelIDIndex(panelID);

    // if the panel wasn't found, add a new one
    if(CPUT_CONTROL_ID_INVALID == panelSlotID)
    {
        Panel *pNewControlPanel = new Panel();
        pNewControlPanel->mpanelID = panelID;
        pNewControlPanel->mControlList.clear();
        pNewControlPanel->mpFocusControl = NULL;

        mControlPanelIDList.push_back( pNewControlPanel );
        panelSlotID = (int)mControlPanelIDList.size()-1;

        // make the newly added panel active if none was
        // active before
        if(CPUT_CONTROL_ID_INVALID == mActiveControlPanelSlotID)
            mActiveControlPanelSlotID = panelSlotID;
    }

    // store the control in the list
    mControlPanelIDList[panelSlotID]->mControlList.push_back(pControl);

    // trigger a resize to position controls optimally
    if(mbAutoLayout)
    {
        Resize();
    }
    return CPUT_SUCCESS;
}
コード例 #9
0
CPUTResult CPUTGuiController::RemoveControlFromPanel(CPUTControl *control, CPUTControlID panelID )  // removes specified control from the panel (does not delete the control)
{
	CPUTControlID panelSlotID;
	if (CPUT_CONTROL_ID_INVALID == panelID)
	{
		// use the currently active panel if none specified
		panelSlotID = mActiveControlPanelSlotID;
	}
	else
	{
		panelSlotID = FindPanelIDIndex(panelID);
	}

	// walk list of controls in the panel and see if control is there
	for (UINT i = 0; i < mControlPanelIDList[panelSlotID]->mControlList.size(); i++)
	{
		if (control == mControlPanelIDList[panelSlotID]->mControlList[i])
		{
			mControlPanelIDList[panelSlotID]->mControlList.erase((mControlPanelIDList[panelSlotID]->mControlList.begin() + i));
			return CPUT_SUCCESS;
		}
	}
	return CPUT_WARNING_NOT_FOUND;
}