зеркало из https://github.com/mozilla/pjs.git
Added a XtManageWidget implementation lifted from the XFE code. This fixes problems where the drawing area would
spontaneously resize itself to fit its contents.
This commit is contained in:
Родитель
9ff4cf6e85
Коммит
2e13a30725
|
@ -59,7 +59,8 @@ CPPSRCS= \
|
|||
nsWindow.cpp \
|
||||
nsXtEventHandler.cpp \
|
||||
nsLookAndFeel.cpp \
|
||||
nsToolkit.cpp
|
||||
nsToolkit.cpp \
|
||||
nsXtManageWidget.cpp
|
||||
|
||||
CPP_OBJS= \
|
||||
./$(OBJDIR)/nsComboBox.o \
|
||||
|
|
|
@ -44,10 +44,15 @@
|
|||
#include "Xm/RowColumn.h"
|
||||
#include "Xm/Form.h"
|
||||
|
||||
|
||||
#define DBG 0
|
||||
|
||||
#define SET_VALUES 1
|
||||
|
||||
nsWindow* gMainWindow; //REMOVE Kludge
|
||||
nsWindow* gChildren[5];
|
||||
int gChildCount = 0;
|
||||
|
||||
//#if defined(LINUX)
|
||||
//#undef SET_VALUES
|
||||
//#endif
|
||||
|
@ -319,6 +324,7 @@ void nsWindow::CreateMainWindow(nsNativeWidget aNativeParent,
|
|||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
{
|
||||
gMainWindow = this;
|
||||
Widget mainWindow = 0, frame = 0;
|
||||
mBounds = aRect;
|
||||
mAppShell = aAppShell;
|
||||
|
@ -351,19 +357,23 @@ void nsWindow::CreateMainWindow(nsNativeWidget aNativeParent,
|
|||
shell,
|
||||
nsnull);
|
||||
XtVaSetValues(mainWindow,
|
||||
XmNallowShellResize, 1,
|
||||
XmNwidth, aRect.width, XmNheight, aRect.height, nsnull);
|
||||
}
|
||||
|
||||
frame = ::XtVaCreateManagedWidget("frame",
|
||||
xmDrawingAreaWidgetClass,
|
||||
// xmDrawingAreaWidgetClass,
|
||||
newManageClass,
|
||||
mainWindow,
|
||||
XmNwidth, aRect.width,
|
||||
XmNheight, aRect.height,
|
||||
XmNmarginHeight, 0,
|
||||
XmNmarginWidth, 0,
|
||||
XmNrecomputeSize, False,
|
||||
XmNuserData, this,
|
||||
nsnull);
|
||||
|
||||
printf("main %d\n", frame);
|
||||
|
||||
mWidget = frame ;
|
||||
|
||||
|
@ -377,10 +387,12 @@ void nsWindow::CreateMainWindow(nsNativeWidget aNativeParent,
|
|||
|
||||
InitCallbacks();
|
||||
|
||||
XtAddCallback(mWidget,
|
||||
#if 0
|
||||
XtAddCallback(mainWindow,
|
||||
XmNresizeCallback,
|
||||
nsXtWidget_Resize_Callback,
|
||||
this);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
@ -397,6 +409,9 @@ void nsWindow::CreateChildWindow(nsNativeWidget aNativeParent,
|
|||
{
|
||||
mBounds = aRect;
|
||||
mAppShell = aAppShell;
|
||||
|
||||
gChildren[gChildCount] = this;
|
||||
gChildCount++;
|
||||
|
||||
InitToolkit(aToolkit, aWidgetParent);
|
||||
|
||||
|
@ -406,15 +421,19 @@ void nsWindow::CreateChildWindow(nsNativeWidget aNativeParent,
|
|||
InitDeviceContext(aContext, (Widget)aNativeParent);
|
||||
|
||||
mWidget = ::XtVaCreateManagedWidget("frame",
|
||||
xmDrawingAreaWidgetClass,
|
||||
// xmDrawingAreaWidgetClass,
|
||||
newManageClass,
|
||||
(Widget)aNativeParent,
|
||||
XmNwidth, aRect.width,
|
||||
XmNheight, aRect.height,
|
||||
XmNmarginHeight, 0,
|
||||
XmNmarginWidth, 0,
|
||||
XmNrecomputeSize, False,
|
||||
XmNuserData, this,
|
||||
nsnull);
|
||||
|
||||
printf("child %d\n", mWidget);
|
||||
|
||||
|
||||
if (aWidgetParent) {
|
||||
aWidgetParent->AddChild(this);
|
||||
|
@ -426,10 +445,12 @@ void nsWindow::CreateChildWindow(nsNativeWidget aNativeParent,
|
|||
|
||||
InitCallbacks();
|
||||
|
||||
#if 0
|
||||
XtAddCallback(mWidget,
|
||||
XmNresizeCallback,
|
||||
nsXtWidget_Resize_Callback,
|
||||
this);
|
||||
#endif
|
||||
|
||||
|
||||
CreateGC();
|
||||
|
@ -694,6 +715,7 @@ void nsWindow::Move(PRUint32 aX, PRUint32 aY)
|
|||
//-------------------------------------------------------------------------
|
||||
void nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint)
|
||||
{
|
||||
printf("RESIZE %d w %d h %d\n",this, aWidth, aHeight);
|
||||
if (DBG) printf("$$$$$$$$$ %s::Resize %d %d Repaint: %s\n",
|
||||
gInstanceClassName, aWidth, aHeight, (aRepaint?"true":"false"));
|
||||
mBounds.width = aWidth;
|
||||
|
@ -718,6 +740,8 @@ void nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint)
|
|||
//-------------------------------------------------------------------------
|
||||
void nsWindow::Resize(PRUint32 aX, PRUint32 aY, PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint)
|
||||
{
|
||||
printf("RESIZE 2 %d w %d h %d\n",this, aWidth, aHeight);
|
||||
|
||||
mBounds.x = aX;
|
||||
mBounds.y = aY;
|
||||
mBounds.width = aWidth;
|
||||
|
@ -725,9 +749,11 @@ void nsWindow::Resize(PRUint32 aX, PRUint32 aY, PRUint32 aWidth, PRUint32 aHeigh
|
|||
// UpdateVisibilityFlag();
|
||||
// UpdateDisplay();
|
||||
#ifdef SET_VALUES
|
||||
printf("SET_VAL\n");
|
||||
XtVaSetValues(mWidget, XmNx, aX, XmNy, GetYCoord(aY),
|
||||
XmNwidth, aWidth, XmNheight, aHeight, nsnull);
|
||||
#else
|
||||
printf("CONFIGURE\n");
|
||||
XtConfigureWidget(mWidget, aX, GetYCoord(aY), aWidth, aHeight, 0);
|
||||
#endif
|
||||
}
|
||||
|
@ -1377,6 +1403,7 @@ PRBool nsWindow::OnResize(nsSizeEvent &aEvent)
|
|||
}*/
|
||||
|
||||
if (mEventCallback && !mIgnoreResize) {
|
||||
printf("DISPATCHGIN FOR %d\n", this);
|
||||
return(DispatchEvent(&aEvent));
|
||||
}
|
||||
return FALSE;
|
||||
|
@ -1486,3 +1513,35 @@ PRUint32 nsWindow::GetYCoord(PRUint32 aNewY)
|
|||
return(aNewY);
|
||||
}
|
||||
|
||||
|
||||
extern "C" void ResizeWidget(Widget w)
|
||||
{
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
nsWindow *win = 0;
|
||||
|
||||
XtVaGetValues(w, XmNuserData, &win, XmNwidth, &width, XmNheight, &height, nsnull);
|
||||
|
||||
printf("raw width win %d %d height %d\n",win, width, height);
|
||||
|
||||
nsRect bounds;
|
||||
bounds.width = width;
|
||||
bounds.height = height;
|
||||
bounds.x = 0;
|
||||
bounds.y = 0;
|
||||
win->SetResizeRect(bounds);
|
||||
|
||||
extern XtAppContext gAppContext;
|
||||
|
||||
if (! win->GetResized()) {
|
||||
if (win->IsChild()) {
|
||||
XtAppAddTimeOut(gAppContext, 250, (XtTimerCallbackProc)nsXtWidget_Refresh_Callback, win);
|
||||
}
|
||||
else {
|
||||
nsXtWidget_Refresh_Callback(win);
|
||||
}
|
||||
}
|
||||
|
||||
win->SetResized(PR_TRUE);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
|
||||
#include "Xm/Xm.h"
|
||||
|
||||
#include "nsXtManageWidget.h"
|
||||
|
||||
#define NSRGB_2_COLOREF(color) \
|
||||
RGB(NS_GET_R(color),NS_GET_G(color),NS_GET_B(color))
|
||||
|
||||
|
@ -46,6 +48,7 @@ class nsWindow : public nsIWidget
|
|||
public:
|
||||
nsWindow(nsISupports *aOuter);
|
||||
virtual ~nsWindow();
|
||||
virtual PRBool IsChild() { return(PR_FALSE); };
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
@ -233,8 +236,9 @@ private:
|
|||
class ChildWindow : public nsWindow {
|
||||
|
||||
public:
|
||||
ChildWindow(nsISupports *aOuter) : nsWindow(aOuter) {}
|
||||
ChildWindow(nsISupports *aOuter) : nsWindow(aOuter) {};
|
||||
|
||||
virtual PRBool IsChild() { return(PR_TRUE); };
|
||||
};
|
||||
|
||||
#define AGGREGATE_METHOD_DEF \
|
||||
|
|
|
@ -635,6 +635,7 @@ printf("After %d %d %d %d\n", rect.x, rect.y, rect.width, rect.height);
|
|||
//==============================================================
|
||||
void nsXtWidget_Resize_Callback(Widget w, XtPointer p, XtPointer call_data)
|
||||
{
|
||||
printf("XXXXXXX RESIZE CALLBACK\n");
|
||||
|
||||
//if (DBG)
|
||||
//fprintf(stderr, "In nsXtWidget_Resize_Callback 0x%x", p);
|
||||
|
@ -858,6 +859,7 @@ void nsXtWidget_Refresh_Callback(XtPointer call_data)
|
|||
event.windowSize = &bounds;
|
||||
|
||||
widgetWindow->SetBounds(bounds);
|
||||
printf("this %d REFRESH w %d h %d\n",widgetWindow,bounds.width, bounds.height);
|
||||
widgetWindow->OnResize(event);
|
||||
// widgetWindow->SetResized(PR_FALSE);
|
||||
|
||||
|
|
|
@ -0,0 +1,163 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
new_manage.c --- defines a subclass of XmManager
|
||||
Created: Eric Bina <ebina@netscape.com>, 17-Aug-94.
|
||||
|
||||
Excerts from the X Toolkit Intrinsics Programming Manual - O'Reilly:
|
||||
|
||||
"Writing a general-purpose composite widget is not a trivial task
|
||||
and should only be done when other options fail."
|
||||
"A truly general-purpose composite widget is a large, complex piece
|
||||
of software. You should leave this programming to the widget writers
|
||||
who write commercial widget sets, and concentrate on things that are
|
||||
more important in your application."
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
/*#include "mozilla.h"*/
|
||||
#include "nsXtManageWidget.h"
|
||||
#include "nsXtManageWidgetP.h"
|
||||
|
||||
static XtGeometryResult
|
||||
GeometryManager(Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply);
|
||||
|
||||
static void
|
||||
ChangeManaged(Widget w);
|
||||
|
||||
|
||||
extern void ResizeWidget(Widget w);
|
||||
|
||||
|
||||
NewManageClassRec newManageClassRec =
|
||||
{
|
||||
{
|
||||
/* core_class fields */
|
||||
/* superclass */ (WidgetClass) &xmManagerClassRec,
|
||||
/* class_name */ "NewManage",
|
||||
/* widget_size */ sizeof(NewManageRec),
|
||||
/* class_initialize */ NULL,
|
||||
/* class_partinit */ NULL /* ClassPartInitialize */,
|
||||
/* class_inited */ FALSE,
|
||||
/* initialize */ NULL /* Initialize */,
|
||||
/* Init hook */ NULL,
|
||||
/* realize */ XtInheritRealize /* Realize */,
|
||||
/* actions */ NULL,
|
||||
/* num_actions */ 0,
|
||||
/* resources */ NULL /* resources */,
|
||||
/* num_resources */ 0 /* XtNumber(resources) */,
|
||||
/* xrm_class */ NULLQUARK,
|
||||
/* compress_motion */ TRUE,
|
||||
/* compress_exposure */ TRUE,
|
||||
/* compress_enterleave*/ TRUE,
|
||||
/* visible_interest */ FALSE,
|
||||
/* destroy */ NULL,
|
||||
/* resize */ ResizeWidget,
|
||||
/* expose */ XtInheritExpose /* (XtExposeProc) Redisplay */,
|
||||
/* set_values */ NULL /* (XtSetValuesFunc )SetValues */,
|
||||
/* set values hook */ NULL,
|
||||
/* set values almost */ XtInheritSetValuesAlmost,
|
||||
/* get values hook */ NULL,
|
||||
/* accept_focus */ NULL,
|
||||
/* Version */ XtVersion,
|
||||
/* PRIVATE cb list */ NULL,
|
||||
/* tm_table */ XtInheritTranslations,
|
||||
/* query_geometry */ NULL /* QueryProc */,
|
||||
/* display_accelerator*/ NULL,
|
||||
/* extension */ NULL,
|
||||
},
|
||||
{
|
||||
/* composite_class fields */
|
||||
/* geometry_manager */ GeometryManager /*(XtGeometryHandler )GeometryManager*/,
|
||||
/* change_managed */ ChangeManaged /*(XtWidgetProc) ChangeManaged*/,
|
||||
/* insert_child */ XtInheritInsertChild /*(XtArgsProc) InsertChild*/,
|
||||
/* delete_child */ XtInheritDeleteChild,
|
||||
/* Extension */ NULL,
|
||||
},{
|
||||
/* Constraint class Init */
|
||||
NULL,
|
||||
0,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
|
||||
},
|
||||
/* Manager Class */
|
||||
{
|
||||
XmInheritTranslations/*ScrolledWindowXlations*/, /* translations */
|
||||
NULL /*get_resources*/, /* get resources */
|
||||
0 /*XtNumber(get_resources)*/, /* num get_resources */
|
||||
NULL, /* get_cont_resources */
|
||||
0, /* num_get_cont_resources */
|
||||
XmInheritParentProcess, /* parent_process */
|
||||
NULL, /* extension */
|
||||
},
|
||||
|
||||
{
|
||||
/* NewManage class - none */
|
||||
/* mumble */ 0
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
WidgetClass newManageClass = (WidgetClass)&newManageClassRec;
|
||||
|
||||
|
||||
static XtGeometryResult
|
||||
GeometryManager(Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply)
|
||||
{
|
||||
if (request->request_mode & XtCWQueryOnly)
|
||||
{
|
||||
return(XtGeometryYes);
|
||||
}
|
||||
|
||||
if (request->request_mode & CWX)
|
||||
{
|
||||
XtX(w) = request->x;
|
||||
}
|
||||
if (request->request_mode & CWY)
|
||||
{
|
||||
XtY(w) = request->y;
|
||||
}
|
||||
if (request->request_mode & CWWidth)
|
||||
{
|
||||
XtWidth(w) = request->width;
|
||||
}
|
||||
if (request->request_mode & CWHeight)
|
||||
{
|
||||
XtHeight(w) = request->height;
|
||||
}
|
||||
if (request->request_mode & CWBorderWidth)
|
||||
{
|
||||
XtBorderWidth(w) = request->border_width;
|
||||
}
|
||||
|
||||
return(XtGeometryYes);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ChangeManaged(Widget w)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
nsXtManageWidget.h --- defines a subclass of XmManager
|
||||
Lifted from xfe code 9/10/98. Modified to support resize.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _FE_NEWMANAGE_H_
|
||||
#define _FE_NEWMANAGE_H_
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
|
||||
extern WidgetClass newManageClass;
|
||||
typedef struct _NewManageClassRec *NewManageClass;
|
||||
typedef struct _NewManageRec *NewManage;
|
||||
|
||||
#endif /* _FE_NEWMANAGE_H_ */
|
|
@ -0,0 +1,62 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/*
|
||||
nsXtManageWidgetP.h --- defines a subclass of XmScrolledWindow
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _nsXtManageWidth_H_
|
||||
#define _nsXtManageWidth_H_
|
||||
|
||||
#include "nsXtManageWidget.h"
|
||||
#include <Xm/ManagerP.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int frogs;
|
||||
} NewManageClassPart;
|
||||
|
||||
typedef struct _NewManageClassRec
|
||||
{
|
||||
CoreClassPart core_class;
|
||||
CompositeClassPart composite_class;
|
||||
ConstraintClassPart constraint_class;
|
||||
XmManagerClassPart manager_class;
|
||||
NewManageClassPart newManage_class;
|
||||
} NewManageClassRec;
|
||||
|
||||
extern NewManageClassRec newManageClassRec;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *why;
|
||||
XtCallbackList input_callback;
|
||||
} NewManagePart;
|
||||
|
||||
typedef struct _NewManageRec
|
||||
{
|
||||
CorePart core;
|
||||
CompositePart composite;
|
||||
ConstraintPart constraint;
|
||||
XmManagerPart manager;
|
||||
NewManagePart newManage;
|
||||
} NewManageRec;
|
||||
|
||||
#endif
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче