Fixes for scrolling. Each widget does an AddChild to insert it in it's parent's

list of children.
This commit is contained in:
kmcclusk%netscape.com 1998-07-30 23:06:32 +00:00
parent 091cb4af0a
commit 5d01dfa7f3
10 changed files with 36 additions and 10 deletions

View File

@ -46,6 +46,7 @@ void nsButton::Create(nsIWidget *aParent,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
aParent->AddChild(this);
Widget parentWidget = nsnull;
if (DBG) fprintf(stderr, "aParent 0x%x\n", aParent);

View File

@ -60,7 +60,7 @@ void nsCheckButton::Create(nsIWidget *aParent,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
aParent->AddChild(this);
Widget parentWidget = nsnull;
if (DBG) fprintf(stderr, "aParent 0x%x\n", aParent);

View File

@ -321,6 +321,7 @@ void nsComboBox::Create(nsIWidget *aParent,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
aParent->AddChild(this);
Widget parentWidget = nsnull;
if (DBG) fprintf(stderr, "aParent 0x%x\n", aParent);

View File

@ -306,6 +306,7 @@ void nsListBox::Create(nsIWidget *aParent,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
aParent->AddChild(this);
Widget parentWidget = nsnull;
if (DBG) fprintf(stderr, "aParent 0x%x\n", aParent);

View File

@ -60,6 +60,7 @@ void nsRadioButton::Create(nsIWidget *aParent,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
aParent->AddChild(this);
Widget parentWidget = nsnull;
if (DBG) fprintf(stderr, "aParent 0x%x\n", aParent);

View File

@ -56,6 +56,7 @@ void nsTextAreaWidget::Create(nsIWidget *aParent,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
aParent->AddChild(this);
Widget parentWidget = nsnull;
if (DBG) fprintf(stderr, "aParent 0x%x\n", aParent);

View File

@ -60,6 +60,7 @@ void nsTextWidget::Create(nsIWidget *aParent,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
aParent->AddChild(this);
Widget parentWidget = nsnull;
if (DBG) fprintf(stderr, "aParent 0x%x\n", aParent);

View File

@ -197,7 +197,7 @@ nsWindow::nsWindow(nsISupports *aOuter):
mDisplayed = PR_FALSE;
mLowerLeft = PR_FALSE;
mCursor = eCursor_standard;
mChildCount = 0;
}
@ -549,6 +549,8 @@ void nsWindow::Create(nsIWidget *aParent,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
if (aParent)
aParent->AddChild(this);
CreateWindow((nsNativeWidget)((aParent) ? aParent->GetNativeData(NS_NATIVE_WIDGET) : 0),
aParent, aRect, aHandleEventFunction, aContext, aAppShell, aToolkit,
aInitData);
@ -610,6 +612,8 @@ nsIEnumerator* nsWindow::GetChildren()
//-------------------------------------------------------------------------
void nsWindow::AddChild(nsIWidget* aChild)
{
mChildArray[mChildCount] = aChild;
mChildCount++;
}
@ -649,9 +653,9 @@ void nsWindow::Move(PRUint32 aX, PRUint32 aY)
{
mBounds.x = aX;
mBounds.y = aY;
UpdateVisibilityFlag();
UpdateDisplay();
XtVaSetValues(mWidget, XmNx, aX, XmNy, GetYCoord(aY), nsnull);
// UpdateVisibilityFlag();
// UpdateDisplay();
XtMoveWidget(mWidget, aX, GetYCoord(aY));
}
//-------------------------------------------------------------------------
@ -665,8 +669,8 @@ void nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint)
gInstanceClassName, aWidth, aHeight, (aRepaint?"true":"false"));
mBounds.width = aWidth;
mBounds.height = aHeight;
UpdateVisibilityFlag();
UpdateDisplay();
// UpdateVisibilityFlag();
// UpdateDisplay();
XtVaSetValues(mWidget, XmNx, mBounds.x, XmNy, mBounds.y, XmNwidth, aWidth, XmNheight, aHeight, nsnull);
}
@ -682,8 +686,8 @@ void nsWindow::Resize(PRUint32 aX, PRUint32 aY, PRUint32 aWidth, PRUint32 aHeigh
mBounds.y = aY;
mBounds.width = aWidth;
mBounds.height = aHeight;
UpdateVisibilityFlag();
UpdateDisplay();
// UpdateVisibilityFlag();
// UpdateDisplay();
XtVaSetValues(mWidget, XmNx, aX, XmNy, GetYCoord(aY),
XmNwidth, aWidth, XmNheight, aHeight, nsnull);
}
@ -1058,6 +1062,20 @@ nsIAppShell* nsWindow::GetAppShell()
//-------------------------------------------------------------------------
void nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
{
int i;
// Scroll all of the form widgets
for (i = 0; i < mChildCount; i++) {
nsIWidget* widget = mChildArray[i];
nsRect rect;
widget->GetBounds(rect);
Widget w = widget->GetNativeData(NS_NATIVE_WIDGET);
rect.x = rect.x + aDx;
rect.y = rect.y + aDy;
widget->Move(rect.x, rect.y);
}
if (mWidget == nsnull) {
return;
}

View File

@ -195,6 +195,8 @@ protected:
PRBool mShown;
PRBool mVisible;
PRBool mDisplayed;
int mChildCount;
nsIWidget* mChildArray[100];
// Resize event management
nsRect mResizeRect;

View File

@ -820,7 +820,7 @@ void nsXtWidget_InitNSKeyEvent(int aEventType, nsKeyEvent& aKeyEvent, Widget w,
aKeyEvent.isShift = PR_FALSE; // modout | ShiftMask; // Fix later
aKeyEvent.isControl = PR_FALSE; // modout | ControlMask;
aKeyEvent.isAlt = PR_FALSE; // Fix later
printf("KEY Event type %d %d shift %d control %d \n", aEventType == NS_KEY_DOWN, aKeyEvent.keyCode, aKeyEvent.isShift, aKeyEvent.isControl);
// printf("KEY Event type %d %d shift %d control %d \n", aEventType == NS_KEY_DOWN, aKeyEvent.keyCode, aKeyEvent.isShift, aKeyEvent.isControl);
}
void nsXtWidget_KeyPressMask_EventHandler(Widget w, XtPointer p, XEvent * event, Boolean * b)