/**
* scrollUp function
* Scroll the shown conten up on the basis of an int
* @param[in] i is the int for how much will be scrolled
*/
void SearchPageArea::scrollUp(int i) {
    selectContent("none");
    int size;
    if (currentcontisuser)
    {
        size = content.Size();
    }
    else {
        size = content["statuses"].Size();
    }
    if (index + 4 + i <size)
    {
        index += i;
    }
    else {
        index = size - 4;
    }
    if (currentcontisuser)
    {

        showUsers();
    }
    else {

        showTweets();
    }
}
NS_IMETHODIMP nsHTMLSelectOptionAccessible::DoAction(PRUint8 index)
{
  if (index == eAction_Select) {   // default action
    nsCOMPtr<nsIDOMHTMLOptionElement> newHTMLOption(do_QueryInterface(mDOMNode));
    if (!newHTMLOption) 
      return NS_ERROR_FAILURE;
    // Clear old selection
    nsCOMPtr<nsIDOMNode> oldHTMLOptionNode, selectNode;
    nsCOMPtr<nsIAccessible> parent(GetParent());
    nsCOMPtr<nsIAccessNode> accessNode(do_QueryInterface(parent));
    NS_ASSERTION(accessNode, "Unable to QI to nsIAccessNode");
    accessNode->GetDOMNode(getter_AddRefs(selectNode));
    GetFocusedOptionNode(selectNode, getter_AddRefs(oldHTMLOptionNode));
    nsCOMPtr<nsIDOMHTMLOptionElement> oldHTMLOption(do_QueryInterface(oldHTMLOptionNode));
    if (oldHTMLOption)
      oldHTMLOption->SetSelected(PR_FALSE);
    // Set new selection
    newHTMLOption->SetSelected(PR_TRUE);

    // If combo box, and open, close it
    // First, get the <select> widgets list control frame
    nsCOMPtr<nsIDOMNode> testSelectNode;
    nsCOMPtr<nsIDOMNode> thisNode(do_QueryInterface(mDOMNode));
    do {
      thisNode->GetParentNode(getter_AddRefs(testSelectNode));
      nsCOMPtr<nsIDOMHTMLSelectElement> selectControl(do_QueryInterface(testSelectNode));
      if (selectControl)
        break;
      thisNode = testSelectNode;
    } while (testSelectNode);

    nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
    nsCOMPtr<nsIContent> selectContent(do_QueryInterface(testSelectNode));
    nsCOMPtr<nsIDOMHTMLOptionElement> option(do_QueryInterface(mDOMNode));

    if (!testSelectNode || !selectContent || !presShell || !option) 
      return NS_ERROR_FAILURE;

    nsIFrame *selectFrame = presShell->GetPrimaryFrameFor(selectContent);
    nsIComboboxControlFrame *comboBoxFrame = do_QueryFrame(selectFrame);
    if (comboBoxFrame) {
      nsIFrame *listFrame = comboBoxFrame->GetDropDown();
      if (comboBoxFrame->IsDroppedDown() && listFrame) {
        // use this list control frame to roll up the list
        nsIListControlFrame *listControlFrame = do_QueryFrame(listFrame);
        if (listControlFrame) {
          PRInt32 newIndex = 0;
          option->GetIndex(&newIndex);
          listControlFrame->ComboboxFinish(newIndex);
        }
      }
    }
    return NS_OK;
  }

  return NS_ERROR_INVALID_ARG;
}
Example #3
0
void
ConsoleWindow::activate() 
{ 
    if ( !_active ) { 
        _active = true;
        _time_start = m_time;
        _time_span = 0.15;
        _selected = true;
        selectContent();
    }
}
/**
* scrollDown function
* Scroll the shown conten down on the basis of an int
* @param[in] i is the int for how much will be scrolled
*/
void SearchPageArea::scrollDown(int i) {
    selectContent("none");
    if (index - i >0)
    {
        index -= i;
    }
    else {
        index = 0;
    }
    if (currentcontisuser)
    {

        showUsers();
    }
    else {

        showTweets();
    }
}
/**
* search function
* functions searches after content in twitter with a searchWord
*/
void SearchPageArea::search() {
    selectContent("none");
    index = 0;
    if (searchWord=="") return;
    if (TwitterApp::getInstance()->hasConnection()) {
        if (userSearch)
        {
            content = TwitterApp::getInstance()->getTwitter()->userSearch(searchWord, "80");
            contentExists = true;
            currentcontisuser = true;
            showUsers();
        }
        else {
            content = TwitterApp::getInstance()->getTwitter()->search(searchWord, "80");
            contentExists = true;
            currentcontisuser = false;
            showTweets();
        }
    }
}
void nsHTMLSelectListAccessible::CacheChildren()
{
  // Cache the number of <optgroup> and <option> DOM decendents,
  // as well as the accessibles for them. Avoid whitespace text nodes.

  nsCOMPtr<nsIContent> selectContent(do_QueryInterface(mDOMNode));
  nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
  if (!selectContent || !accService) {
    mAccChildCount = eChildCountUninitialized;
    return;
  }

  if (mAccChildCount != eChildCountUninitialized) {
    return;
  }

  mAccChildCount = 0; // Avoid reentry
  PRInt32 childCount = 0;
  nsCOMPtr<nsIAccessible> lastGoodAccessible =
    CacheOptSiblings(accService, selectContent, nsnull, &childCount);
  mAccChildCount = childCount;
}
/**
* selectContent function
* Selectes Element of the ProfilePageArea
* changes style of Elemten on hand of id
* functions of other classes used
* @param[in] id of the Selected Content
*/
void ProfilePageArea::selectContent(std::string id) {

    if (currentlySelected.compare(id))
    {
        if (currentlySelected.compare("none")&& currentlySelected.compare("0"))
        {
            eyegui::ImageAlignment alignment = eyegui::ImageAlignment::STRETCHED;
            eyegui::replaceElementWithPicture(pLayout, "content" + currentlySelected, "menuebar_elements/tweet_content2.png", alignment);
            eyegui::setStyleOfElement(pLayout, "content" + currentlySelected, "block");
            eyegui::replaceElementWithBlock(pLayout, "rightSide" + currentlySelected, false);
        }
        currentlySelected = id;
        if (id.compare("none"))
        {

            if (stoi(currentlySelected) == 1 && tweetIndex != 0)
            {
                scrollDown(1);
                selectContent("2");
                return;
            }
            if (stoi(currentlySelected) == 3 && tweetIndex != tweetcontents.Size() - 3)
            {
                scrollUp(1);
                selectContent("2");
                return;
            }

            eyegui::ImageAlignment alignment = eyegui::ImageAlignment::STRETCHED;

            eyegui::replaceElementWithPicture(pLayout, "action_button_area", "actionbar_elements/ProfileActionBar/actionBarProfile" + currentlySelected + ".png", alignment);
            eyegui::setStyleOfElement(pLayout, "action_button_area", "block");
            if (currentlySelected.compare("0"))
            {
                eyegui::replaceElementWithPicture(pLayout, "content" + currentlySelected, "Eprojekt_Design/tweetSelected.png", alignment);
                eyegui::setStyleOfElement(pLayout, "content" + currentlySelected, "block");
                eyegui::replaceElementWithPicture(pLayout, "rightSide" + currentlySelected, "Eprojekt_Design/tweetConnection.png", alignment);


            }
            std::cout << "Content " + id + " has been hit" << std::endl;
            if (id.compare("0"))
            {
                if (tweetcontents[stoi(currentlySelected) + tweetIndex - 1]["entities"].HasMember("media"))
                {
                    std::vector<std::string> links;
                    for (int i = 0; i < tweetcontents[stoi(currentlySelected)-1 + tweetIndex]["extended_entities"]["media"].Size(); i++)
                    {
                        links.push_back(tweetcontents[stoi(currentlySelected)-1 + tweetIndex]["extended_entities"]["media"][i]["media_url"].GetString());
                    }
                    TwitterApp::getInstance()->actionButtonArea->mediaLinks = links;
                    TwitterApp::getInstance()->actionButtonArea->changeToTweetsWithPics(getTweetId(), getUserId(), getTweetFavorited(), getTweetRetweeted(), getTweetOwned());

                }
                else {
                    TwitterApp::getInstance()->actionButtonArea->changeToTweets(getTweetId(), getUserId(), getTweetFavorited(), getTweetRetweeted(), getTweetOwned());

                }


                          }
            else {

                TwitterApp::getInstance()->actionButtonArea->changeToProfiles(getUserId(), usercontents["following"].GetBool());
            }
            return;
        }
        TwitterApp::getInstance()->actionButtonArea->changeToNone();
    }

}
/**
* selectContent function
* Selectes Element of the SearchPageArea
* changes style of Elemten on hand of id
* functions of other classes used
* @param[in] id of the Selected Content
*/
void SearchPageArea::selectContent(std::string id) {
    if (contentExists)	{

    if (currentlySelected.compare(id))
    {
        if (currentlySelected.compare("none"))
        {
            eyegui::ImageAlignment alignment = eyegui::ImageAlignment::STRETCHED;
            eyegui::replaceElementWithPicture(pLayout, "result" + currentlySelected, "menuebar_elements/tweet_content2.png", alignment);
            eyegui::setStyleOfElement(pLayout, "result" + currentlySelected, "block");
            eyegui::replaceElementWithBlock(pLayout, "rightSide" + currentlySelected, false);
        }
        currentlySelected = id;
        if (id.compare("none"))
        {

            if (index!=0&&stoi(currentlySelected)==0)
            {
                scrollDown(1);
                selectContent("1");
                return;
            }
            int size;
            if (currentcontisuser)
            {
                size = content.Size();
            }
            else {
                size = content["statuses"].Size();
            }
            if (stoi(currentlySelected) == 3 && index != size - 4)
            {
                scrollUp(1);
                selectContent("2");
                return;
            }
            eyegui::ImageAlignment alignment = eyegui::ImageAlignment::STRETCHED;
            eyegui::replaceElementWithPicture(pLayout, "result" + currentlySelected, "Eprojekt_Design/tweetSelected.png", alignment);
            eyegui::setStyleOfElement(pLayout, "result" + currentlySelected, "block");

            eyegui::replaceElementWithPicture(pLayout, "action_button_area", "actionbar_elements/SearchActionBar/actionBarSearch" + currentlySelected + ".png", alignment);
            eyegui::setStyleOfElement(pLayout, "action_button_area", "block");

            eyegui::replaceElementWithPicture(pLayout, "rightSide" + currentlySelected, "Eprojekt_Design/tweetConnection.png", alignment);

            std::cout << "Result " + id + " has been hit" << std::endl;
            if (stoi(currentlySelected)>=counter)
            {

                return;
            }
            if (currentcontisuser)
            {
                TwitterApp::getInstance()->actionButtonArea->changeToProfilesWithGo(content[index + stoi(currentlySelected)]["id_str"].GetString(), content[index + stoi(currentlySelected)]["following"].GetBool());
            }
            else {

                if (content["statuses"][stoi(currentlySelected) + index]["entities"].HasMember("media"))
                {
                    std::vector<std::string> links;
                    for (int i = 0; i < content["statuses"][stoi(currentlySelected) + index]["entities"]["media"].Size(); i++)
                    {
                        links.push_back(content["statuses"][stoi(currentlySelected) + index]["entities"]["media"][i]["media_url"].GetString());
                    }
                    TwitterApp::getInstance()->actionButtonArea->mediaLinks = links;
                    TwitterApp::getInstance()->actionButtonArea->changeToTweetsWithPics(getTweetIdAt( stoi(currentlySelected)), getTweetUser( stoi(currentlySelected)), getLikedAt( stoi(currentlySelected)), getRetweetedAt( stoi(currentlySelected)), getOwnAt( stoi(currentlySelected)));

                }
                else {
                    TwitterApp::getInstance()->actionButtonArea->changeToTweets(getTweetIdAt( stoi(currentlySelected)), getTweetUser( stoi(currentlySelected)), getLikedAt( stoi(currentlySelected)), getRetweetedAt(stoi(currentlySelected)), getOwnAt( stoi(currentlySelected)));
                }
            }
        return;
        }
        TwitterApp::getInstance()->actionButtonArea->changeToNone();
    }
    }

}