Bug 365866. Expose appropriate tree table state, name and actions for cells that are checkboxes and cyclers. Patch by david.bolter@utoronto.ca. r=aaronlev, r=surkov, r=bienvenu, sr=mscott

This commit is contained in:
aaronleventhal%moonset.net 2007-02-08 19:48:32 +00:00
Родитель c2c355cdc9
Коммит 3aa794ee3c
6 изменённых файлов: 84 добавлений и 12 удалений

Просмотреть файл

@ -547,7 +547,14 @@ NS_IMETHODIMP nsXULTreeitemAccessible::Shutdown()
NS_IMETHODIMP nsXULTreeitemAccessible::GetName(nsAString& aName)
{
NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE);
return mTreeView->GetCellText(mRow, mColumn, aName);
mTreeView->GetCellText(mRow, mColumn, aName);
// if still no name try cell value
if (aName.IsEmpty()) {
mTreeView->GetCellValue(mRow, mColumn, aName);
}
return NS_OK;
}
NS_IMETHODIMP nsXULTreeitemAccessible::GetUniqueID(void **aUniqueID)
@ -614,7 +621,7 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetState(PRUint32 *_retval)
return NS_OK;
}
// "activate" action is available for all treeitems
// "activate" (xor "cycle") action is available for all treeitems
// "expand/collapse" action is avaible for treeitem which is container
NS_IMETHODIMP nsXULTreeitemAccessible::GetNumActions(PRUint8 *_retval)
{
@ -632,10 +639,17 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetNumActions(PRUint8 *_retval)
// Return the name of our actions
NS_IMETHODIMP nsXULTreeitemAccessible::GetActionName(PRUint8 index, nsAString& _retval)
{
NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(mColumn && mTree && mTreeView, NS_ERROR_FAILURE);
if (index == eAction_Click) {
nsAccessible::GetTranslatedString(NS_LITERAL_STRING("activate"), _retval);
PRBool isCycler;
mColumn->GetCycler(&isCycler);
if (isCycler) {
nsAccessible::GetTranslatedString(NS_LITERAL_STRING("cycle"), _retval);
}
else {
nsAccessible::GetTranslatedString(NS_LITERAL_STRING("activate"), _retval);
}
return NS_OK;
}
else if (index == eAction_Expand) {
@ -754,16 +768,24 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetPreviousSibling(nsIAccessible **aPrevi
NS_IMETHODIMP nsXULTreeitemAccessible::DoAction(PRUint8 index)
{
NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(mColumn && mTree && mTreeView, NS_ERROR_FAILURE);
if (index == eAction_Click) {
nsCOMPtr<nsITreeSelection> selection;
mTreeView->GetSelection(getter_AddRefs(selection));
if (selection) {
nsresult rv = selection->Select(mRow);
mTree->EnsureRowIsVisible(mRow);
return rv;
nsresult rv = NS_OK;
PRBool isCycler;
mColumn->GetCycler(&isCycler);
if (isCycler) {
rv = mTreeView->CycleCell(mRow, mColumn);
}
else {
nsCOMPtr<nsITreeSelection> selection;
mTreeView->GetSelection(getter_AddRefs(selection));
if (selection) {
rv = selection->Select(mRow);
mTree->EnsureRowIsVisible(mRow);
}
}
return rv;
}
else if (index == eAction_Expand) {
PRBool isContainer;

Просмотреть файл

@ -10,3 +10,4 @@ click = Click
collapse= Collapse
expand = Expand
activate= Activate
cycle = Cycle

Просмотреть файл

@ -10,3 +10,4 @@ click = Click
collapse= Collapse
expand = Expand
activate= Activate
cycle = Cycle

Просмотреть файл

@ -10,3 +10,4 @@ click = Click
collapse= Collapse
expand = Expand
activate= Activate
cycle = Cycle

Просмотреть файл

@ -120,6 +120,15 @@ errorGettingDB=Unable to open the summary file for %S. Perhaps there was an erro
defaultServerTag=(Default)
useDefaultServer=Use default server
# Used in message database list view to provide a text value for graphic based cells.
messageRead=Read
messageUnread=Unread
messageHasFlag=Starred
messageHasNoFlag=Not Starred
messageHasAttachment=Has Attachment
messageHasNoAttachment=No Attachment
# Used in the SMTP Account Settings panel when a server value has no properties
smtpServerList-NotSpecified=<not specified>
smtpServer-SecureConnection-Type-0=None

Просмотреть файл

@ -1526,7 +1526,45 @@ nsMsgDBView::GetProgressMode(PRInt32 aRow, nsITreeColumn* aCol, PRInt32* _retval
NS_IMETHODIMP nsMsgDBView::GetCellValue(PRInt32 aRow, nsITreeColumn* aCol, nsAString& aValue)
{
return NS_OK;
nsCOMPtr <nsIMsgDBHdr> msgHdr;
nsresult rv = GetMsgHdrForViewIndex(aRow, getter_AddRefs(msgHdr));
if (NS_FAILED(rv) || !msgHdr)
{
ClearHdrCache();
return NS_MSG_INVALID_DBVIEW_INDEX;
}
const PRUnichar* colID;
aCol->GetIdConst(&colID);
PRUint32 flags;
msgHdr->GetFlags(&flags);
// provide a string "value" for cells that do not normally have text.
switch (colID[0])
{
case 'a': // attachment column
aValue.Assign(GetString ((flags & MSG_FLAG_ATTACHMENT) ?
NS_LITERAL_STRING("messageHasAttachment").get()
: NS_LITERAL_STRING("messageHasNoAttachment").get()));
break;
case 'f': // flagged (starred) column
aValue.Assign(GetString ((flags & MSG_FLAG_MARKED) ?
NS_LITERAL_STRING("messageHasFlag").get()
: NS_LITERAL_STRING("messageHasNoFlag").get()));
break;
case 'u': // read/unread column
aValue.Assign(GetString ((flags & MSG_FLAG_READ) ?
NS_LITERAL_STRING("messageRead").get()
: NS_LITERAL_STRING("messageUnread").get()));
break;
default:
aValue.Assign(colID);
break;
}
return rv;
}
//add a custom column handler