コード例 #1
0
void SpinnerDefaultEditor::changed(ConstFieldMaskArg whichField, 
                            UInt32            origin,
                            BitVector         details)
{
    Inherited::changed(whichField, origin, details);

    if(whichField & SpinnerFieldMask)
    {
        _EditorTextFieldActionConnection.disconnect();
        if(getSpinner() != NULL)
        {
            _ModelStateChangedConnection = getSpinner()->getModel()->connectStateChanged(boost::bind(&SpinnerDefaultEditor::handleModelStateChanged, this, _1));
            
            if(getTextField() != NULL)
            {
                //Update the Value of the TextField
	            std::string NewValue;
                try
                {
                    getTextField()->setText(getSpinner()->getModel()->getValueAsString());
                }
                catch(boost::bad_any_cast &)
                {
		            getTextField()->setText("");
                }
            }
        }
    }

    if(whichField & TextFieldFieldMask)
    {
        clearChildren();
        _EditorTextFieldActionConnection.disconnect();
        _EditorTextFieldFocusLostConnection.disconnect();
        _EditorTextFieldKeyPressedConnection.disconnect();
        if(getTextField() != NULL)
        {
            pushToChildren(getTextField());
            _EditorTextFieldActionConnection = getTextField()->connectActionPerformed(boost::bind(&SpinnerDefaultEditor::handleEditorTextFieldActionPerformed, this, _1));
            _EditorTextFieldFocusLostConnection = getTextField()->connectFocusLost(boost::bind(&SpinnerDefaultEditor::handleEditorTextFieldFocusLost, this, _1));
            _EditorTextFieldKeyPressedConnection = getTextField()->connectKeyPressed(boost::bind(&SpinnerDefaultEditor::handleEditorTextFieldKeyPressed, this, _1));
        }
    }
}
コード例 #2
0
void SpinnerDefaultEditor::commitEdit(void)
{
    try
    {
        getSpinner()->getModel()->setValue(getTextField()->getText());
    }
    catch(IllegalArgumentException&)
    {
        //Reset to the old value
        std::string NewValue;
        try
        {
            getTextField()->setText(getSpinner()->getModel()->getValueAsString());
        }
        catch(boost::bad_any_cast &)
        {
            getTextField()->setText("");
        }
    }
}
コード例 #3
0
void SpinnerDefaultEditor::cancelEdit(void)
{
    //Reset to the old value
    std::string NewValue;
    try
    {
        getTextField()->setText(getSpinner()->getModel()->getValueAsString());
    }
    catch(boost::bad_any_cast &)
    {
        getTextField()->setText("");
    }
}
コード例 #4
0
void SpinnerDefaultEditor::handleModelStateChanged(ChangeEventDetails* const e)
{
    //Update the Value of the TextField
    std::string NewValue;
    try
    {
        getTextField()->setText(getSpinner()->getModel()->getValueAsString());
    }
    catch(boost::bad_any_cast &)
    {
        getTextField()->setText("");
    }
}
コード例 #5
0
ファイル: Board.cpp プロジェクト: vascofg/prog-dominoes
unsigned int Board::getLastValueByRow(char row) //Gets the value of the last bone on the row
{
	vector<Bone> vecRow = getRow(row);
	Bone lastBone;
	if (vecRow.size() == 0)
		if (toupper(row) == 'W' && !hasSpinner())
		{
			lastBone = rightRow[0];
			if (rightRow.size() == 1)
				lastBone.swap();
		}
		else if (!hasSpinner())
			lastBone = Bone();
		else
			lastBone = *getSpinner();
	else
		lastBone = vecRow[vecRow.size() - 1];
	if (toupper(row) == 'E' && !hasSpinner() && vecRow.size() == 1)
		return lastBone.getValue1();
	else
		return lastBone.getValue2();
}