Made window support child windows under Linux:lesstif

This commit is contained in:
kmcclusk 1998-06-06 00:53:24 +00:00
Родитель 386afc4f60
Коммит 2426fd7410
2 изменённых файлов: 58 добавлений и 26 удалений

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

@ -113,22 +113,25 @@ nsWindow::~nsWindow()
} }
//-------------------------------------------------------------------------
//
// Create a window.
//
// Note: aNativeParent is always non-null if aWidgetParent is non-null.
// aNativeaParent is set regardless if the parent for the Create() was an
// nsIWidget or a Native widget.
// aNativeParent is equal to aWidgetParent->GetNativeData(NS_NATIVE_WIDGET)
//-------------------------------------------------------------------------
//------------------------------------------------------------------------- void nsWindow::CreateWindow(nsNativeWindow aNativeParent, nsIWidget *aWidgetParent,
//
// Create the proper widget
//
//-------------------------------------------------------------------------
void nsWindow::Create(nsIWidget *aParent,
const nsRect &aRect, const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction, EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext, nsIDeviceContext *aContext,
nsIToolkit *aToolkit, nsIToolkit *aToolkit,
nsWidgetInitData *aInitData) nsWidgetInitData *aInitData)
{ {
Widget mainWindow = 0, frame = 0;
Widget mainWindow, frame; Widget parentWidget = 0;
Widget parentWidget;
if (nsnull == mToolkit) { if (nsnull == mToolkit) {
if (nsnull != aToolkit) { if (nsnull != aToolkit) {
@ -136,8 +139,8 @@ void nsWindow::Create(nsIWidget *aParent,
mToolkit->AddRef(); mToolkit->AddRef();
} }
else { else {
if (nsnull != aParent) { if (nsnull != aWidgetParent) {
mToolkit = (nsToolkit*)(aParent->GetToolkit()); // the call AddRef's, we don't have to mToolkit = (nsToolkit*)(aWidgetParent->GetToolkit()); // the call AddRef's, we don't have to
} }
// it's some top level window with no toolkit passed in. // it's some top level window with no toolkit passed in.
// Create a default toolkit with the current thread // Create a default toolkit with the current thread
@ -190,53 +193,60 @@ void nsWindow::Create(nsIWidget *aParent,
} }
} }
if (aParent) { if (0==aNativeParent) {
parentWidget = (Widget) aParent->GetNativeData(NS_NATIVE_WIDGET);
} else {
parentWidget = (Widget) aInitData ; parentWidget = (Widget) aInitData ;
} }
else
parentWidget = (Widget)aNativeParent;
if (!aParent) { Widget frameParent = 0;
if (!aNativeParent) {
mainWindow = ::XtVaCreateManagedWidget("mainWindow", mainWindow = ::XtVaCreateManagedWidget("mainWindow",
xmMainWindowWidgetClass, xmMainWindowWidgetClass,
parentWidget, parentWidget,
XmNwidth, aRect.width, XmNwidth, aRect.width,
XmNheight, aRect.height, XmNheight, aRect.height,
nsnull); nsnull);
frameParent = mainWindow;
} }
else
frameParent = aNativeParent;
frame = ::XtVaCreateManagedWidget("frame", frame = ::XtVaCreateManagedWidget("frame",
xmDrawingAreaWidgetClass, xmDrawingAreaWidgetClass,
(aParent) ? parentWidget : mainWindow, frameParent,
XmNwidth, aRect.width, XmNwidth, aRect.width,
XmNheight, aRect.height, XmNheight, aRect.height,
nsnull); nsnull);
mWidget = frame ; mWidget = frame ;
if (!aParent) { if (mainWindow) {
XmMainWindowSetAreas (mainWindow, nsnull, nsnull, nsnull, nsnull, frame); XmMainWindowSetAreas (mainWindow, nsnull, nsnull, nsnull, nsnull, frame);
} }
if (aParent) { if (aWidgetParent) {
aParent->AddChild(this); aWidgetParent->AddChild(this);
} }
// Force cursor to default setting // Force cursor to default setting
mCursor = eCursor_select; mCursor = eCursor_select;
SetCursor(eCursor_standard); SetCursor(eCursor_standard);
XtAddEventHandler(mWidget, /* XtAddEventHandler(mWidget,
ExposureMask, ExposureMask,
PR_FALSE, PR_FALSE,
nsXtWidget_ExposureMask_EventHandler, nsXtWidget_ExposureMask_EventHandler,
this); this);
*/
InitCallbacks(); InitCallbacks();
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// //
// Initialize all the Callbacks // Initialize all the Callbacks
@ -284,6 +294,22 @@ void nsWindow::InitCallbacks()
} }
//-------------------------------------------------------------------------
//
// create with nsIWidget parent
//
//-------------------------------------------------------------------------
void nsWindow::Create(nsIWidget *aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
CreateWindow((nsNativeWindow)((aParent) ? aParent->GetNativeData(NS_NATIVE_WIDGET) : 0), aParent, aRect, aHandleEventFunction, aContext, aToolkit, aInitData);
}
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// //
// create with a native parent // create with a native parent
@ -296,7 +322,7 @@ void nsWindow::Create(nsNativeWindow aParent,
nsIToolkit *aToolkit, nsIToolkit *aToolkit,
nsWidgetInitData *aInitData) nsWidgetInitData *aInitData)
{ {
NS_ASSERTION(0, "nsWindow Constructor is not implemented\n"); CreateWindow(aParent, 0, aRect, aHandleEventFunction, aContext, aToolkit, aInitData);
} }
@ -419,6 +445,7 @@ void nsWindow::SetFocus(void)
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
void nsWindow::GetBounds(nsRect &aRect) void nsWindow::GetBounds(nsRect &aRect)
{ {
XWindowAttributes attrs ;
Window w = nsnull; Window w = nsnull;
if (mWidget) if (mWidget)
@ -445,10 +472,9 @@ void nsWindow::GetBounds(nsRect &aRect)
aRect.y = 0; aRect.y = 0;
aRect.width = 0; aRect.width = 0;
aRect.height = 0; aRect.height = 0;
}
} }
}
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -558,7 +584,8 @@ void* nsWindow::GetNativeData(PRUint32 aDataType)
case NS_NATIVE_WINDOW: case NS_NATIVE_WINDOW:
{ {
return (void*)XtWindow(mWidget); // return (void*)XtWindow(mWidget);
return (void*)(mWidget);
} }
break; break;
case NS_NATIVE_DISPLAY: case NS_NATIVE_DISPLAY:

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

@ -117,7 +117,12 @@ public:
protected: protected:
void InitCallbacks(); void InitCallbacks();
void CreateWindow(nsNativeWindow aNativeParent, nsIWidget *aWidgetParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData);
Widget mWidget; Widget mWidget;
EVENT_CALLBACK mEventCallback; EVENT_CALLBACK mEventCallback;