bug #10503: added SetZIndex & GetZIndex. a=leaf, r=troy
git-svn-id: svn://10.0.0.236/trunk@48933 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
59e19a69f5
commit
677002e392
@ -297,8 +297,6 @@ class nsIWidget : public nsISupports {
|
||||
/**
|
||||
* Make the window modal
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetModal(void) = 0;
|
||||
|
||||
@ -345,6 +343,16 @@ class nsIWidget : public nsISupports {
|
||||
PRInt32 aHeight,
|
||||
PRBool aRepaint) = 0;
|
||||
|
||||
/**
|
||||
* Set's the widget's z-index.
|
||||
*/
|
||||
NS_IMETHOD SetZIndex(PRInt32 aZIndex) = 0;
|
||||
|
||||
/**
|
||||
* Get's the widget's z-index.
|
||||
*/
|
||||
NS_IMETHOD GetZIndex(PRInt32* aZIndex) = 0;
|
||||
|
||||
/**
|
||||
* Enable or disable this Widget
|
||||
*
|
||||
|
||||
@ -61,6 +61,7 @@ nsBaseWidget::nsBaseWidget()
|
||||
, mOnDestroyCalled(PR_FALSE)
|
||||
, mBounds(0,0,0,0)
|
||||
, mVScrollbar(nsnull)
|
||||
, mZIndex(0)
|
||||
{
|
||||
NS_NewISupportsArray(getter_AddRefs(mChildren));
|
||||
|
||||
@ -245,7 +246,56 @@ void nsBaseWidget::RemoveChild(nsIWidget* aChild)
|
||||
{
|
||||
mChildren->RemoveElement(aChild);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Sets widget's position within its parent's child list.
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsBaseWidget::SetZIndex(PRInt32 aZIndex)
|
||||
{
|
||||
mZIndex = aZIndex;
|
||||
|
||||
// reorder this child in its parent's list.
|
||||
nsBaseWidget* parent = NS_STATIC_CAST(nsBaseWidget*, GetParent());
|
||||
if (nsnull != parent) {
|
||||
parent->mChildren->RemoveElement(this);
|
||||
PRUint32 childCount, index;
|
||||
if (NS_SUCCEEDED(parent->mChildren->Count(&childCount))) {
|
||||
for (index = 0; index < childCount; index++) {
|
||||
nsCOMPtr<nsIWidget> childWidget;
|
||||
if (NS_SUCCEEDED(parent->mChildren->QueryElementAt(index, NS_GET_IID(nsIWidget), (void**)getter_AddRefs(childWidget)))) {
|
||||
PRInt32 childZIndex;
|
||||
if (NS_SUCCEEDED(childWidget->GetZIndex(&childZIndex))) {
|
||||
if (aZIndex < childZIndex) {
|
||||
parent->mChildren->InsertElementAt(this, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// were we added to the list?
|
||||
if (index == childCount) {
|
||||
parent->mChildren->AppendElement(this);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(parent);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Gets widget's position within its parent's child list.
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsBaseWidget::GetZIndex(PRInt32* aZIndex)
|
||||
{
|
||||
*aZIndex = mZIndex;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Get the foreground color
|
||||
|
||||
@ -61,6 +61,8 @@ public:
|
||||
virtual void AddChild(nsIWidget* aChild);
|
||||
virtual void RemoveChild(nsIWidget* aChild);
|
||||
|
||||
NS_IMETHOD SetZIndex(PRInt32 aZIndex);
|
||||
NS_IMETHOD GetZIndex(PRInt32* aZIndex);
|
||||
|
||||
virtual nscolor GetForegroundColor(void);
|
||||
NS_IMETHOD SetForegroundColor(const nscolor &aColor);
|
||||
@ -129,13 +131,12 @@ protected:
|
||||
PRBool mIsAltDown;
|
||||
PRBool mIsDestroying;
|
||||
PRBool mOnDestroyCalled;
|
||||
//PRInt32 mWidth;
|
||||
//PRInt32 mHeight;
|
||||
nsRect mBounds;
|
||||
nsIWidget *mVScrollbar;
|
||||
PRInt32 mZIndex;
|
||||
|
||||
// keep the list of children
|
||||
nsCOMPtr<nsISupportsArray> mChildren;
|
||||
nsCOMPtr<nsISupportsArray> mChildren;
|
||||
|
||||
class Enumerator : public nsIBidirectionalEnumerator {
|
||||
public:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user