NS_IMETHODIMP nsXULMenuitemAccessible::GetRole(PRUint32 *aRole)
{
  nsCOMPtr<nsIDOMXULContainerElement> xulContainer(do_QueryInterface(mDOMNode));
  if (xulContainer) {
    *aRole = nsIAccessibleRole::ROLE_PARENT_MENUITEM;
    return NS_OK;
  }

  nsCOMPtr<nsIAccessible> parent;
  GetParent(getter_AddRefs(parent));
  if (parent && Role(parent) == nsIAccessibleRole::ROLE_COMBOBOX_LIST) {
    *aRole = nsIAccessibleRole::ROLE_COMBOBOX_OPTION;
    return NS_OK;
  }

  *aRole = nsIAccessibleRole::ROLE_MENUITEM;
  nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
  if (!element)
    return NS_ERROR_FAILURE;
  nsAutoString menuItemType;
  element->GetAttribute(NS_LITERAL_STRING("type"), menuItemType);
  if (menuItemType.EqualsIgnoreCase("radio"))
    *aRole = nsIAccessibleRole::ROLE_RADIO_MENU_ITEM;
  else if (menuItemType.EqualsIgnoreCase("checkbox"))
    *aRole = nsIAccessibleRole::ROLE_CHECK_MENU_ITEM;

  return NS_OK;
}
Example #2
0
nsresult
nsAccUtils::GetHeaderCellsFor(nsIAccessibleTable *aTable,
                              nsIAccessibleTableCell *aCell,
                              PRInt32 aRowOrColHeaderCells, nsIArray **aCells)
{
  nsresult rv = NS_OK;
  nsCOMPtr<nsIMutableArray> cells = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 rowIdx = -1;
  rv = aCell->GetRowIndex(&rowIdx);
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 colIdx = -1;
  rv = aCell->GetColumnIndex(&colIdx);
  NS_ENSURE_SUCCESS(rv, rv);

  PRBool moveToLeft = aRowOrColHeaderCells == eRowHeaderCells;

  // Move to the left or top to find row header cells or column header cells.
  PRInt32 index = (moveToLeft ? colIdx : rowIdx) - 1;
  for (; index >= 0; index--) {
    PRInt32 curRowIdx = moveToLeft ? rowIdx : index;
    PRInt32 curColIdx = moveToLeft ? index : colIdx;

    nsCOMPtr<nsIAccessible> cell;
    rv = aTable->GetCellAt(curRowIdx, curColIdx, getter_AddRefs(cell));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIAccessibleTableCell> tableCellAcc =
      do_QueryInterface(cell);

    // GetCellAt should always return an nsIAccessibleTableCell (XXX Bug 587529)
    NS_ENSURE_STATE(tableCellAcc);

    PRInt32 origIdx = 1;
    if (moveToLeft)
      rv = tableCellAcc->GetColumnIndex(&origIdx);
    else
      rv = tableCellAcc->GetRowIndex(&origIdx);
    NS_ENSURE_SUCCESS(rv, rv);

    if (origIdx == index) {
      // Append original header cells only.
      PRUint32 role = Role(cell);
      PRBool isHeader = moveToLeft ?
        role == nsIAccessibleRole::ROLE_ROWHEADER :
        role == nsIAccessibleRole::ROLE_COLUMNHEADER;

      if (isHeader)
        cells->AppendElement(cell, PR_FALSE);
    }
  }

  NS_ADDREF(*aCells = cells);
  return NS_OK;
}
void mog::network::ReplicateInstanceMessage::executeOnClient(ClientGame *game, const ParameterContainer &parameters, const network::InternetAddress &address) const
{
	std::string type = parameters.get("typeId");
	std::string index = parameters.get("instanceId");
	Role role = Role(std::stoi(parameters.get("role")));

	NetworkGameObject* o = dynamic_cast<NetworkGameObject*> (ConstructorDatabase::get()->create(type));
	o->setInstanceId(std::stoi(index));
	o->setRole(role);
	game->addGameObject(o);
}
Example #4
0
nsAccessible *
nsAccUtils::GetSelectableContainer(nsAccessible *aAccessible, PRUint32 aState)
{
  if (!aAccessible)
    return nsnull;

  if (!(aState & nsIAccessibleStates::STATE_SELECTABLE))
    return nsnull;

  nsAccessible* parent = aAccessible;
  while ((parent = parent->GetParent()) && !parent->IsSelect()) {
    if (Role(parent) == nsIAccessibleRole::ROLE_PANE)
      return nsnull;
  }
  return parent;
}
// --------------------------------------------------------------------------------------------------------------------------------------------------
void CGoldenArcher::RewardItem(int aIndex)
{
    int ItemLine = Role(static_cast<int>(gGAEvent.ReadFiles.size() - 1));

    LPOBJ lpObj = &gObj[aIndex];

    int ItemType, ItemIndex, Level, Durability, Luck, Skill, Option, Exc, Ancient;
    unsigned char Socket[5];

    sscanf(this->ReadFiles.at(ItemLine).c_str(), "%d %d %d %d %d %d %d %d %d %d %d %d %d %d", &ItemType, &ItemIndex, &Level, &Durability, &Luck,
           &Skill, &Option, &Exc, &Ancient, &Socket[0], &Socket[1], &Socket[2],&Socket[3],&Socket[4]);

    UINT  RewardItem = ItemType *512 + ItemIndex;

    ItemSerialCreateSend(aIndex, lpObj->MapNumber, lpObj->X, lpObj->Y, RewardItem, Level, Durability, Luck, Skill, Option, aIndex, Exc, Ancient, Socket);
}
Example #6
0
PRInt32
nsAccUtils::GetDefaultLevel(nsAccessible *aAcc)
{
  PRUint32 role = nsAccUtils::Role(aAcc);

  if (role == nsIAccessibleRole::ROLE_OUTLINEITEM)
    return 1;

  if (role == nsIAccessibleRole::ROLE_ROW) {
    nsCOMPtr<nsIAccessible> parent = aAcc->GetParent();
    if (Role(parent) == nsIAccessibleRole::ROLE_TREE_TABLE) {
      // It is a row inside flatten treegrid. Group level is always 1 until it
      // is overriden by aria-level attribute.
      return 1;
    }
  }

  return 0;
}
Example #7
0
bool Accidental::setProperty(P_ID propertyId, const QVariant& v)
      {
      switch (propertyId) {
            case P_ID::SMALL:
                  _small = v.toBool();
                  break;
            case P_ID::ACCIDENTAL_BRACKET:
                  _hasBracket = v.toBool();
                  break;
            case P_ID::ROLE:
                  _role = Role(v.toInt());
                  break;
            default:
                  return Element::setProperty(propertyId, v);
            }
      layout();
      score()->setLayoutAll(true);  // spacing changes
      return true;
      }
NS_IMETHODIMP nsXULMenupopupAccessible::GetRole(PRUint32 *aRole)
{
  nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
  if (!content) {
    return NS_ERROR_FAILURE;
  }
  nsCOMPtr<nsIAccessible> parent;
  GetParent(getter_AddRefs(parent));
  if (parent) {
    // Some widgets like the search bar have several popups, owned by buttons
    PRUint32 role = Role(parent);
    if (role == nsIAccessibleRole::ROLE_COMBOBOX ||
        role == nsIAccessibleRole::ROLE_PUSHBUTTON ||
        role == nsIAccessibleRole::ROLE_AUTOCOMPLETE) {
      *aRole = nsIAccessibleRole::ROLE_COMBOBOX_LIST;
      return NS_OK;
    }
  }
  *aRole = nsIAccessibleRole::ROLE_MENUPOPUP;
  return NS_OK;
}
Example #9
0
already_AddRefed<nsIAccessible>
nsAccUtils::GetSelectableContainer(nsIAccessible *aAccessible, PRUint32 aState)
{
  if (!aAccessible)
    return nsnull;

  if (!(aState & nsIAccessibleStates::STATE_SELECTABLE))
    return nsnull;

  nsCOMPtr<nsIAccessibleSelectable> container;
  nsCOMPtr<nsIAccessible> parent, accessible(aAccessible);
  while (!container) {
    accessible->GetParent(getter_AddRefs(parent));

    if (!parent || Role(parent) == nsIAccessibleRole::ROLE_PANE)
      return nsnull;

    container = do_QueryInterface(parent);
    parent.swap(accessible);
  }

  return accessible.forget();
}
Example #10
0
void
nsAccUtils::GetPositionAndSizeForXULContainerItem(nsIDOMNode *aNode,
                                                  PRInt32 *aPosInSet,
                                                  PRInt32 *aSetSize)
{
  nsCOMPtr<nsIDOMXULContainerItemElement> item(do_QueryInterface(aNode));
  if (!item)
    return;

  nsCOMPtr<nsIDOMXULContainerElement> container;
  item->GetParentContainer(getter_AddRefs(container));
  if (!container)
    return;

  // Get item count.
  PRUint32 itemsCount = 0;
  container->GetItemCount(&itemsCount);

  // Get item index.
  PRInt32 indexOf = 0;
  container->GetIndexOfItem(item, &indexOf);

  // Calculate set size and position in the set.
  *aSetSize = 0, *aPosInSet = 0;
  for (PRInt32 index = indexOf; index >= 0; index--) {
    nsCOMPtr<nsIDOMXULElement> item;
    container->GetItemAtIndex(index, getter_AddRefs(item));

    nsCOMPtr<nsIAccessible> itemAcc;
    GetAccService()->GetAccessibleFor(item, getter_AddRefs(itemAcc));

    if (itemAcc) {
      PRUint32 itemRole = Role(itemAcc);
      if (itemRole == nsIAccessibleRole::ROLE_SEPARATOR)
        break; // We reached the beginning of our group.

      PRUint32 itemState = State(itemAcc);
      if (!(itemState & nsIAccessibleStates::STATE_INVISIBLE)) {
        (*aSetSize)++;
        (*aPosInSet)++;
      }
    }
  }

  for (PRInt32 index = indexOf + 1; index < static_cast<PRInt32>(itemsCount);
       index++) {
    nsCOMPtr<nsIDOMXULElement> item;
    container->GetItemAtIndex(index, getter_AddRefs(item));
    
    nsCOMPtr<nsIAccessible> itemAcc;
    GetAccService()->GetAccessibleFor(item, getter_AddRefs(itemAcc));

    if (itemAcc) {
      PRUint32 itemRole = Role(itemAcc);
      if (itemRole == nsIAccessibleRole::ROLE_SEPARATOR)
        break; // We reached the end of our group.

      PRUint32 itemState = State(itemAcc);
      if (!(itemState & nsIAccessibleStates::STATE_INVISIBLE))
        (*aSetSize)++;
    }
  }
}
NS_IMETHODIMP
nsXULMenuitemAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
{
  nsresult rv = nsAccessible::GetState(aState, aExtraState);
  NS_ENSURE_SUCCESS(rv, rv);
  if (!mDOMNode) {
    return NS_OK;
  }

  // Focused?
  nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
  if (!element)
    return NS_ERROR_FAILURE;
  PRBool isFocused = PR_FALSE;
  element->HasAttribute(NS_LITERAL_STRING("_moz-menuactive"), &isFocused); 
  if (isFocused)
    *aState |= nsIAccessibleStates::STATE_FOCUSED;

  // Has Popup?
  nsAutoString tagName;
  element->GetLocalName(tagName);
  if (tagName.EqualsLiteral("menu")) {
    *aState |= nsIAccessibleStates::STATE_HASPOPUP;
    PRBool isOpen;
    element->HasAttribute(NS_LITERAL_STRING("open"), &isOpen);
    if (isOpen) {
      *aState |= nsIAccessibleStates::STATE_EXPANDED;
    }
    else {
      *aState |= nsIAccessibleStates::STATE_COLLAPSED;
    }
  }

  nsAutoString menuItemType;
  element->GetAttribute(NS_LITERAL_STRING("type"), menuItemType); 

  if (!menuItemType.IsEmpty()) {
    // Checkable?
    if (menuItemType.EqualsIgnoreCase("radio") ||
        menuItemType.EqualsIgnoreCase("checkbox"))
      *aState |= nsIAccessibleStates::STATE_CHECKABLE;

    // Checked?
    nsAutoString checkValue;
    element->GetAttribute(NS_LITERAL_STRING("checked"), checkValue);
    if (checkValue.EqualsLiteral("true")) {
      *aState |= nsIAccessibleStates::STATE_CHECKED;
    }
  }

  // Combo box listitem
  PRBool isComboboxOption =
    (Role(this) == nsIAccessibleRole::ROLE_COMBOBOX_OPTION);
  if (isComboboxOption) {
    // Is selected?
    PRBool isSelected = PR_FALSE;
    nsCOMPtr<nsIDOMXULSelectControlItemElement>
      item(do_QueryInterface(mDOMNode));
    NS_ENSURE_TRUE(item, NS_ERROR_FAILURE);
    item->GetSelected(&isSelected);

    // Is collapsed?
    PRBool isCollapsed = PR_FALSE;
    nsCOMPtr<nsIAccessible> parentAccessible(GetParent());
    if (parentAccessible &&
        State(parentAccessible) & nsIAccessibleStates::STATE_INVISIBLE) {
      isCollapsed = PR_TRUE;
    }
    
    if (isSelected) {
      *aState |= nsIAccessibleStates::STATE_SELECTED;
      
      // Selected and collapsed?
      if (isCollapsed) {
        // Set selected option offscreen/invisible according to combobox state
        nsCOMPtr<nsIAccessible> grandParentAcc;
        parentAccessible->GetParent(getter_AddRefs(grandParentAcc));
        NS_ENSURE_TRUE(grandParentAcc, NS_ERROR_FAILURE);
        NS_ASSERTION((Role(grandParentAcc) == nsIAccessibleRole::ROLE_COMBOBOX),
                     "grandparent of combobox listitem is not combobox");
        PRUint32 grandParentState, grandParentExtState;
        grandParentAcc->GetFinalState(&grandParentState, &grandParentExtState);
        *aState &= ~(nsIAccessibleStates::STATE_OFFSCREEN |
                     nsIAccessibleStates::STATE_INVISIBLE);
        *aState |= grandParentState & nsIAccessibleStates::STATE_OFFSCREEN |
                   grandParentState & nsIAccessibleStates::STATE_INVISIBLE;
        if (aExtraState) {
          *aExtraState |=
            grandParentExtState & nsIAccessibleStates::EXT_STATE_OPAQUE;
        }
      } // isCollapsed
    } // isSelected
  } // ROLE_COMBOBOX_OPTION

  // Set focusable and selectable for items that are available
  // and whose metric setting does allow disabled items to be focused.
  if (*aState & nsIAccessibleStates::STATE_UNAVAILABLE) {
    // Honour the LookAndFeel metric.
    nsCOMPtr<nsILookAndFeel> lookNFeel(do_GetService(kLookAndFeelCID));
    PRInt32 skipDisabledMenuItems = 0;
    lookNFeel->GetMetric(nsILookAndFeel::eMetric_SkipNavigatingDisabledMenuItem,
                         skipDisabledMenuItems);
    // We don't want the focusable and selectable states for combobox items,
    // so exclude them here as well.
    if (skipDisabledMenuItems || isComboboxOption) {
      return NS_OK;
    }
  }
  *aState|= (nsIAccessibleStates::STATE_FOCUSABLE |
             nsIAccessibleStates::STATE_SELECTABLE);

  return NS_OK;
}
Example #12
0
GeneralFailure::GeneralFailure(const StateId& sourceState)
    : Transition(Role(".*"), SelfRole(), ACLMessage::FAILURE, sourceState, State::GENERAL_FAILURE_STATE)
{}
Example #13
0
ConversationCancelFailure::ConversationCancelFailure()
    : Transition(Role(".*"), Role(".*"), ACLMessage::FAILURE, State::CONVERSATION_CANCELLING, State::CONVERSATION_CANCEL_FAILURE)
{
}
Example #14
0
// We loosen the role restriction here, to facilitate the integrating of the default states -- now we just need
// one state per direction (which works multidirectional)
// TODO: consider solving this issue using an embedded state machine
ConversationCancelSuccess::ConversationCancelSuccess()
    : Transition( Role(".*"), Role(".*"), ACLMessage::INFORM, State::CONVERSATION_CANCELLING, State::CONVERSATION_CANCEL_SUCCESS)
{
}
Example #15
0
void roleForm::on_btn_Add_clicked()
{
    QString newRoleName = QInputDialog::getText(this, tr("Insert Role"),
            tr("Input name for the new Role:"));

    if (newRoleName.isNull()){
        QMessageBox::critical(this, "Error", "You must enter a name for the new Role!");
        return;
    }

    if(ui->lst_Roles->findItems(newRoleName, Qt::MatchExactly).size() > 0){
        QMessageBox::critical(this, "Error", "Roles should have unique names!");
        return;
    }

    //Following Order does Matter
    roleList.insert(roleList.begin(), std::pair<std::string, Role>(newRoleName.toStdString(), Role(newRoleName.toStdString())));
    ui->lst_Roles->addItem(newRoleName);
    ui->lst_Roles->setCurrentItem(ui->lst_Roles->findItems(newRoleName, Qt::MatchExactly).front());

    return;
}