コード例 #1
0
// Constructor
//-----------------------------------------------------------------------------
CPUTButton::CPUTButton(const cString ControlText, CPUTControlID id, CPUTFont *pFont):
    mbStartedClickInside(false),
    mpButtonText(NULL),
    mpMirrorBufferActive(NULL),
    mpMirrorBufferPressed(NULL),
    mpMirrorBufferDisabled(NULL),
    mpFont(pFont)
{
    // initialize the state variables
    InitializeState();

    // save the control ID for callbacks
    mcontrolID = id;

    // save the font to use for text on this button
    mpFont = pFont;

    // set as enabled
    CPUTControl::SetEnable(true);

    // initialize the size lists
    memset(&mpButtonIdleSizeList, 0, sizeof(CPUT_SIZE) * CPUT_NUM_IMAGES_IN_BUTTON);
    memset(&mpButtonPressedSizeList, 0, sizeof(CPUT_SIZE) * CPUT_NUM_IMAGES_IN_BUTTON);
    memset(&mpButtonDisabledSizeList, 0, sizeof(CPUT_SIZE) * CPUT_NUM_IMAGES_IN_BUTTON);

    // set up the per-instance data
    RegisterInstanceResources();

    // set the text on the button and resize it accordingly
    SetText(ControlText);

    // set the default control position
    SetPosition( 0, 0 );

}
コード例 #2
0
// Set the Scale
//--------------------------------------------------------------------------------
CPUTResult CPUTSlider::SetScale(float StartValue, float EndValue, int NumberOfSteps)
{
    ASSERT( StartValue < EndValue, _L("Slider start greater or equal to slider end") );
    ASSERT( NumberOfSteps > 1 , _L("Slider must have more than 2 steps from start to end value") );

    mSliderStartValue = StartValue;
    mSliderEndValue = EndValue;
    mSliderNumberOfSteps = NumberOfSteps;
    mSliderNumberOfTicks = mSliderNumberOfSteps;

    // re-sizes the mirror buffers to accomidate the new items
    RegisterInstanceResources();

    // to avoid the problem of changing the scale and having the gripper be
    // out of that range, setScale always sets the gripper to the start
    // value when re-ranging the control
    SetValue(StartValue);

    // Did we calculate a reasonable number of ticks?  Or should we clamp them to a 
    // visibly pleasing amount?
    ClampTicks();

    // we've likely moved things, so re-calculate the vertex buffer
    Recalculate();

    return CPUT_SUCCESS;
}
コード例 #3
0
// Constructor
//-----------------------------------------------------------------------------
CPUTCheckbox::CPUTCheckbox(const cString ControlText, CPUTControlID id, CPUTFont *pFont):
    mbMouseInside(false),
    mbStartedClickInside(false),
    mVertexStride(0),
    mVertexOffset(0),
    mpCheckboxText(NULL),
    mpFont(pFont)
{
    // initialize the state variables
    InitialStateSet();

    // save the control ID for callbacks
    mcontrolID = id;

    // store the font to be used by this control
    mpFont = pFont;

    // set as enabled
    CPUTControl::SetEnable(true);

    // register all the instance resources
    RegisterInstanceResources();

    // set the control's text string
    SetText(ControlText);
}
コード例 #4
0
    // Constructor
    //--------------------------------------------------------------------------------
    CPUTButton::CPUTButton(const cString ControlText, CPUTControlID id):CPUTButtonBase(ControlText, id), 
        m_bMouseInside(false),
        m_bButtonDown(false),
        m_pButtonText(NULL)
    {
        CPUTResult result=CPUT_SUCCESS;

        // initialize dimensions
        m_ButtonDimensions.x=0;
        m_ButtonDimensions.y=0;
        m_ButtonDimensions.width=0;
        m_ButtonDimensions.height=0;

        // register per-button resources
        RegisterInstanceResources();      

        // set the text on the button and resize it accordingly
        SetText(ControlText);

        // set the default position
        SetPosition( 0, 0 ); 

    }
コード例 #5
0
// Constructor
//-----------------------------------------------------------------------------
CPUTDropdown::CPUTDropdown(const cString ControlName, CPUTControlID id, CPUTFont *pFont):mVertexStride(0),
    mVertexOffset(0),
    mSelectedItemIndex(0),
    mbSizeDirty(false),
    mbMouseInside(false),
    mbStartedClickInside(false),
    mbStartedClickInsideTray(false),
    mRevertItem((UINT)-1),

    mpMirrorBufferActive(NULL),
    mpMirrorBufferDisabled(NULL),
    mpButtonText(NULL),
    mpFont(pFont)
{
    // initialize the state variables
    InitialStateSet();

    // save the control ID for callbacks
    mcontrolID = id;

    // set as enabled
    CPUTControl::SetEnable(true);

    // this is a copy of whatever item is selected
    mpSelectedItemCopy = new CPUTText(pFont);

        // clear the button selected area rect
    mButtonRect.x=0; mButtonRect.y=0; mButtonRect.width=0; mButtonRect.height=0;
    mTrayDimensions.x=0; mTrayDimensions.y=0; mTrayDimensions.width=0; mTrayDimensions.height=0;

    // set the string to display with the slider
    AddSelectionItem(ControlName, true);


    // Register any instance resources
    RegisterInstanceResources();
}