示例#1
0
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsIsIndexFrame::SaveState(SpecialStateID aStateID, nsPresState** aState)
{
  NS_ENSURE_ARG_POINTER(aState);

  *aState = nsnull;

  // Get the value string
  nsAutoString stateString;
  GetInputValue(stateString);

  if (! stateString.IsEmpty()) {

    // Construct a pres state and store value in it.
    *aState = new nsPresState();
    if (!*aState)
      return NS_ERROR_OUT_OF_MEMORY;

    nsCOMPtr<nsISupportsString> state
      (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));

    if (!state)
      return NS_ERROR_OUT_OF_MEMORY;

    state->SetData(stateString);
    (*aState)->SetStateProperty(state);
  }

  return NS_OK;
}
示例#2
0
	void Entity::mProcessAll()
	{
		//Processing external inputs and all internal operators
		for (mainDataType i = FirstExtInputPos; i < _nextOperatorId; i++)
		{
			mProcess(i);
		}

		//Processing external outputs
		//static const unsigned short rex = ExternalOutputsCount - 1;
		for (mainDataType i = 0; i < ExternalOutputsCount;)
		{
			mainDataType nextI = i + 1;// external output
			if (_chmanager->GetCorrectAnswer(i) != GetInputValue(nextI, FirstContact))
			{
				//_chmanager->ReportFailure();
				_incorrectAnswersCount++;
				return;
			}

			i = nextI;
		}

		//_chmanager->ReportSuccess();
		_correctAnswersCount++;
	}
示例#3
0
void PivotMenuAction::Activate()
{
    // Use coordinate for positioning floating elements
    glm::vec2 coordinate;
    GetInputValue("coordinate", coordinate);

    // Position of menu
    float verticalPosition = (coordinate.y > (_pTab->GetWebViewHeight() / 2)) ? 0.1f : (0.5f + _menuHeight);
    float x = (float)_pTab->GetWebViewX() + ((float)_pTab->GetWebViewWidth() * 0.1f);
    float y = (float)_pTab->GetWebViewY() + ((float)_pTab->GetWebViewHeight() * verticalPosition);
    _pTab->SetPositionOfFloatingFrameInOverlay(_menuFrameIndex, x / _pTab->GetWindowWidth(), y / _pTab->GetWindowHeight());

    // Position of pivot
    glm::vec2 pivotPosition = coordinate;
    pivotPosition.x += _pTab->GetWebViewX();
    pivotPosition.y += _pTab->GetWebViewY();
    pivotPosition.x /= _pTab->GetWindowWidth();
    pivotPosition.y /= _pTab->GetWindowHeight();
    pivotPosition.x -= _pivotSize / 2.f;
    pivotPosition.y -= _pivotSize / 2.f;
    _pTab->SetPositionOfFloatingFrameInOverlay(_pivotFrameIndex, pivotPosition.x, pivotPosition.y);

    // Make overlays visible
    _pTab->SetVisibilityOfFloatingFrameInOverlay(_menuFrameIndex, true);
    _pTab->SetVisibilityOfFloatingFrameInOverlay(_pivotFrameIndex, true);
}
int CKSInputDialog::InputPassword(const CString& prompt, const CString& defaultValue, CString& value)
{
	m_password = true;
	m_defaultValue = defaultValue;
	m_prompt = prompt;
	flag = 1;
	int ret = DoModal();
	if(ret == IDOK)
	{
		GetInputValue(value);
	}
	return ret;
}
// 输入
int CKSInputDialog::InputQuery(const CString & prompt, const CString & defaultValue, CString & value)
{
	m_defaultValue = defaultValue;
	m_password = false;
	m_prompt = prompt;
/*	flag = 0;*/
	int ret = DoModal();
	if(ret == IDOK)
	{
		GetInputValue(value);
	}
	return ret;
}
示例#6
0
main()
{
//仅仅是N=6的情况,更广泛的话,请自行解决。
//define input aray , if u extends this prog , u should dynamic allocate this
float a[6];
//define 中间数组 如果输入数字是N的话,float mult[2^N]
float mult64[64];
      int i=0;

GetInputValue(&a[0],6);
CalAllPosibility(&a[0],&mult64[0]);
    LookForNearest(&mult64[0],10.0);

}
void iPhysicsController::Update(float afTimeStep)
{
    if(mbActive==false || mbPaused) return;
    if(mpBody==NULL) return;

    cVector3f vInput = GetInputValue(mInputType);
    //Get the local input.
    if(	mbUseInputMatrixFix == false ||
            (mInputType != ePhysicsControllerInput_JointAngle && mInputType != ePhysicsControllerInput_JointDist) )
        {
            vInput = cMath::MatrixMul(cMath::MatrixInverse(mpBody->GetLocalMatrix().GetRotation()),vInput);
        }


    float fValue = GetAxisValue(mInputAxis, vInput);
    float fError = mfDestValue - fValue;

    float fOutput = GetOutputValue(fError,fValue,afTimeStep);

    if(mfMaxOutput>0)
        {
            if(fOutput>0)
                fOutput = cMath::Min(fOutput, mfMaxOutput);
            else
                fOutput = cMath::Max(fOutput, -mfMaxOutput);
        }

    if(mbLogInfo)
        Log("%s | Input: %f Dest: %f Error: %f OutPut: %f\n",msName.c_str(),fValue,mfDestValue,fError,fOutput);

    AddOutputValue(mOutputType,mOutputAxis,fOutput);

    ////////////////////////////////////////
    //Check if dest vale is reached
    if(mEndType == ePhysicsControllerEnd_OnDest && mpJoint)
        {
            if(std::abs(fValue - mfDestValue) < kEpsilonf)
                {
                    mbActive = false;
                    iPhysicsController *pNext = mpJoint->GetController(msNextController);
                    if(pNext) pNext->SetActive(true);
                }
        }
}
示例#8
0
// submission
// much of this is cut and paste from nsFormFrame::OnSubmit
NS_IMETHODIMP
nsIsIndexFrame::OnSubmit(nsPresContext* aPresContext)
{
  if (!mContent || !mInputContent) {
    return NS_ERROR_UNEXPECTED;
  }

  if (mContent->IsEditable()) {
    return NS_OK;
  }

  nsresult result = NS_OK;

  // Begin ProcessAsURLEncoded
  nsAutoString data;

  nsCOMPtr<nsIUnicodeEncoder> encoder;
  if(NS_FAILED(GetEncoder(getter_AddRefs(encoder))))  // Non-fatal error
     encoder = nsnull;

  nsAutoString value;
  GetInputValue(value);
  URLEncode(value, encoder, data);
  // End ProcessAsURLEncoded

  // make the url string
  nsAutoString href;

  // Get the document.
  // We'll need it now to form the URL we're submitting to.
  // We'll also need it later to get the DOM window when notifying form submit observers (bug 33203)
  nsCOMPtr<nsIDocument> document = mContent->GetDocument();
  if (!document) return NS_OK; // No doc means don't submit, see Bug 28988

  // Resolve url to an absolute url
  nsIURI *baseURI = document->GetDocBaseURI();
  if (!baseURI) {
    NS_ERROR("No Base URL found in Form Submit!");
    return NS_OK; // No base URL -> exit early, see Bug 30721
  }

  // If an action is not specified and we are inside 
  // a HTML document then reload the URL. This makes us
  // compatible with 4.x browsers.
  // If we are in some other type of document such as XML or
  // XUL, do nothing. This prevents undesirable reloading of
  // a document inside XUL.

  nsresult rv;
  nsCOMPtr<nsIHTMLDocument> htmlDoc;
  htmlDoc = do_QueryInterface(document, &rv);
  if (NS_FAILED(rv)) {   
    // Must be a XML, XUL or other non-HTML document type
    // so do nothing.
    return NS_OK;
  } 

  // Necko's MakeAbsoluteURI doesn't reuse the baseURL's rel path if it is
  // passed a zero length rel path.
  nsCAutoString relPath;
  baseURI->GetSpec(relPath);
  if (!relPath.IsEmpty()) {
    CopyUTF8toUTF16(relPath, href);

    // If re-using the same URL, chop off old query string (bug 25330)
    PRInt32 queryStart = href.FindChar('?');
    if (kNotFound != queryStart) {
      href.Truncate(queryStart);
    }
  } else {
    NS_ERROR("Rel path couldn't be formed in form submit!");
    return NS_ERROR_OUT_OF_MEMORY;
  }

  // Add the URI encoded form values to the URI
  // Get the scheme of the URI.
  nsCOMPtr<nsIURI> actionURL;
  nsXPIDLCString scheme;
  PRBool isJSURL = PR_FALSE;
  const nsACString &docCharset = document->GetDocumentCharacterSet();
  const nsPromiseFlatCString& flatDocCharset = PromiseFlatCString(docCharset);

  if (NS_SUCCEEDED(result = NS_NewURI(getter_AddRefs(actionURL), href,
                                      flatDocCharset.get(),
                                      baseURI))) {
    result = actionURL->SchemeIs("javascript", &isJSURL);
  }
  // Append the URI encoded variable/value pairs for GET's
  if (!isJSURL) { // Not for JS URIs, see bug 26917
    if (href.FindChar('?') == kNotFound) { // Add a ? if needed
      href.Append(PRUnichar('?'));
    } else {                              // Adding to existing query string
      if (href.Last() != '&' && href.Last() != '?') {   // Add a & if needed
        href.Append(PRUnichar('&'));
      }
    }
    href.Append(data);
  }
  nsCOMPtr<nsIURI> uri;
  result = NS_NewURI(getter_AddRefs(uri), href,
                     flatDocCharset.get(), baseURI);
  if (NS_FAILED(result)) return result;

  // Now pretend we're triggering a link
  nsContentUtils::TriggerLink(mContent, aPresContext, uri,
                              EmptyString(), PR_TRUE, PR_TRUE);
  return result;
}