зеркало из https://github.com/mozilla/gecko-dev.git
Redo all the evil event handling. We still do not resize properly, but I am
getting closer.
This commit is contained in:
Родитель
43512d12df
Коммит
98f76e2272
|
@ -131,7 +131,7 @@ PRBool nsButton::OnPaint(nsPaintEvent &aEvent)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool nsButton::OnResize(nsSizeEvent &aEvent)
|
PRBool nsButton::OnResize(nsRect &aWindowRect)
|
||||||
{
|
{
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
|
|
||||||
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
||||||
virtual PRBool OnPaint(nsPaintEvent &aEvent);
|
virtual PRBool OnPaint(nsPaintEvent &aEvent);
|
||||||
virtual PRBool OnResize(nsSizeEvent &aEvent);
|
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NS_METHOD CreateNative(GtkWidget *parentWindow);
|
NS_METHOD CreateNative(GtkWidget *parentWindow);
|
||||||
|
|
|
@ -155,7 +155,7 @@ PRBool nsCheckButton::OnPaint(nsPaintEvent &aEvent)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool nsCheckButton::OnResize(nsSizeEvent &aEvent)
|
PRBool nsCheckButton::OnResize(nsRect &aWindowRect)
|
||||||
{
|
{
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
|
|
||||||
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
||||||
virtual PRBool OnPaint(nsPaintEvent &aEvent);
|
virtual PRBool OnPaint(nsPaintEvent &aEvent);
|
||||||
virtual PRBool OnResize(nsSizeEvent &aEvent);
|
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NS_IMETHOD nsCheckButton::CreateNative(GtkWidget *parentWindow);
|
NS_IMETHOD nsCheckButton::CreateNative(GtkWidget *parentWindow);
|
||||||
|
|
|
@ -301,7 +301,7 @@ PRBool nsComboBox::OnPaint(nsPaintEvent &aEvent)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool nsComboBox::OnResize(nsSizeEvent &aEvent)
|
PRBool nsComboBox::OnResize(nsRect &aWindowRect)
|
||||||
{
|
{
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
|
|
||||||
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
||||||
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
||||||
virtual PRBool OnResize(nsSizeEvent &aEvent);
|
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||||
|
|
||||||
// nsIComboBox interface
|
// nsIComboBox interface
|
||||||
NS_IMETHOD SetMultipleSelection(PRBool aMultipleSelections);
|
NS_IMETHOD SetMultipleSelection(PRBool aMultipleSelections);
|
||||||
|
|
|
@ -139,7 +139,7 @@ PRBool nsDialog::OnPaint(nsPaintEvent &aEvent)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool nsDialog::OnResize(nsSizeEvent &aEvent)
|
PRBool nsDialog::OnResize(nsRect &aWindowRect)
|
||||||
{
|
{
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
NS_IMETHOD GetLabel(nsString& aBuffer);
|
NS_IMETHOD GetLabel(nsString& aBuffer);
|
||||||
|
|
||||||
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
||||||
virtual PRBool OnResize(nsSizeEvent &aEvent);
|
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||||
|
|
||||||
//virtual void PreCreateWidget(nsWidgetInitData *aInitData);
|
//virtual void PreCreateWidget(nsWidgetInitData *aInitData);
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ struct nsKeyConverter nsKeycodes[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
void nsGtkWidget_InitNSKeyEvent(int aEventType, nsKeyEvent& aKeyEvent,
|
void nsGtkWidget_InitNSKeyEvent(int aEventType, nsKeyEvent& aKeyEvent,
|
||||||
GtkWidget *w, gpointer p, GdkEvent * event);
|
GtkWidget *w, gpointer p, GdkEventKey * event);
|
||||||
|
|
||||||
int nsConvertKey(int keysym)
|
int nsConvertKey(int keysym)
|
||||||
{
|
{
|
||||||
|
@ -137,199 +137,243 @@ int nsConvertKey(int keysym)
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================
|
//==============================================================
|
||||||
void nsGtkWidget_InitNSEvent(GdkEvent *aGev,
|
void InitConfigureEvent(GdkEventConfigure *aGEC,
|
||||||
gpointer p,
|
gpointer p,
|
||||||
nsGUIEvent &anEvent,
|
nsSizeEvent &anEvent,
|
||||||
PRUint32 aEventType)
|
PRUint32 aEventType)
|
||||||
{
|
{
|
||||||
GdkEventButton *anXEv = (GdkEventButton*)aGev;
|
|
||||||
|
|
||||||
anEvent.message = aEventType;
|
anEvent.message = aEventType;
|
||||||
anEvent.widget = (nsWidget *) p;
|
anEvent.widget = (nsWidget *) p;
|
||||||
anEvent.eventStructType = NS_GUI_EVENT;
|
NS_ADDREF(anEvent.widget);
|
||||||
|
|
||||||
if (anXEv != NULL) {
|
anEvent.eventStructType = NS_SIZE_EVENT;
|
||||||
anEvent.point.x = nscoord(anXEv->x);
|
|
||||||
anEvent.point.y = nscoord(anXEv->y);
|
if (aGEC != NULL) {
|
||||||
|
nsRect rect(aGEC->x, aGEC->y, aGEC->width, aGEC->height);
|
||||||
|
anEvent.windowSize = ▭
|
||||||
|
anEvent.point.x = aGEC->x;
|
||||||
|
anEvent.point.y = aGEC->y;
|
||||||
|
anEvent.mWinWidth = aGEC->width;
|
||||||
|
anEvent.mWinHeight = aGEC->height;
|
||||||
}
|
}
|
||||||
|
// this usually returns 0
|
||||||
anEvent.time = anXEv->time;
|
anEvent.time = gdk_event_get_time((GdkEvent*)aGEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================
|
//==============================================================
|
||||||
void nsGtkWidget_InitNSMouseEvent(GdkEvent *aGev,
|
void InitMouseEvent(GdkEventButton *aGEB,
|
||||||
gpointer p,
|
gpointer p,
|
||||||
nsMouseEvent &anEvent,
|
nsMouseEvent &anEvent,
|
||||||
PRUint32 aEventType)
|
PRUint32 aEventType)
|
||||||
{
|
{
|
||||||
GdkEventButton *anXEv = (GdkEventButton*)aGev;
|
anEvent.message = aEventType;
|
||||||
|
anEvent.widget = (nsWidget *) p;
|
||||||
|
NS_ADDREF(anEvent.widget);
|
||||||
|
|
||||||
// Do base initialization
|
anEvent.eventStructType = NS_MOUSE_EVENT;
|
||||||
nsGtkWidget_InitNSEvent(aGev, p, anEvent, aEventType);
|
|
||||||
|
|
||||||
if (anXEv != NULL) { // Do Mouse Event specific intialization
|
if (aGEB != NULL) {
|
||||||
anEvent.time = anXEv->time;
|
anEvent.point.x = nscoord(aGEB->x);
|
||||||
anEvent.isShift = (anXEv->state & ShiftMask) ? PR_TRUE : PR_FALSE;
|
anEvent.point.y = nscoord(aGEB->y);
|
||||||
anEvent.isControl = (anXEv->state & ControlMask) ? PR_TRUE : PR_FALSE;
|
|
||||||
anEvent.isAlt = (anXEv->state & Mod1Mask) ? PR_TRUE : PR_FALSE;
|
|
||||||
// anEvent.clickCount = anXEv->button; //XXX Fix for double-clicks
|
|
||||||
anEvent.clickCount = 1; //XXX Fix for double-clicks
|
|
||||||
anEvent.eventStructType = NS_MOUSE_EVENT;
|
|
||||||
|
|
||||||
|
anEvent.isShift = (aGEB->state & ShiftMask) ? PR_TRUE : PR_FALSE;
|
||||||
|
anEvent.isControl = (aGEB->state & ControlMask) ? PR_TRUE : PR_FALSE;
|
||||||
|
anEvent.isAlt = (aGEB->state & Mod1Mask) ? PR_TRUE : PR_FALSE;
|
||||||
|
anEvent.time = aGEB->time;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//==============================================================
|
||||||
|
void InitExposeEvent(GdkEventExpose *aGEE,
|
||||||
|
gpointer p,
|
||||||
|
nsPaintEvent &anEvent,
|
||||||
|
PRUint32 aEventType)
|
||||||
|
{
|
||||||
|
anEvent.message = aEventType;
|
||||||
|
anEvent.widget = (nsWidget *) p;
|
||||||
|
NS_ADDREF(anEvent.widget);
|
||||||
|
|
||||||
|
anEvent.eventStructType = NS_PAINT_EVENT;
|
||||||
|
|
||||||
|
if (aGEE != NULL) {
|
||||||
|
nsRect rect(aGEE->area.x, aGEE->area.y, aGEE->area.width, aGEE->area.height);
|
||||||
|
anEvent.rect = ▭
|
||||||
|
anEvent.time = gdk_event_get_time((GdkEvent*)aGEE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================
|
//==============================================================
|
||||||
#ifndef MIN
|
void InitMotionEvent(GdkEventMotion *aGEM,
|
||||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
gpointer p,
|
||||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
nsMouseEvent &anEvent,
|
||||||
#endif
|
PRUint32 aEventType)
|
||||||
|
|
||||||
#define INTERSECTS(r1_x1,r1_x2,r1_y1,r1_y2,r2_x1,r2_x2,r2_y1,r2_y2) \
|
|
||||||
!((r2_x2 <= r1_x1) ||\
|
|
||||||
(r2_y2 <= r1_y1) ||\
|
|
||||||
(r2_x1 >= r1_x2) ||\
|
|
||||||
(r2_y1 >= r1_y2))
|
|
||||||
|
|
||||||
//==============================================================
|
|
||||||
typedef struct COLLAPSE_INFO {
|
|
||||||
Window win;
|
|
||||||
nsRect *r;
|
|
||||||
} CollapseInfo;
|
|
||||||
|
|
||||||
//==============================================================
|
|
||||||
#if 0
|
|
||||||
static Bool checkForExpose(Display *dpy, XEvent *evt, XtPointer client_data)
|
|
||||||
{
|
{
|
||||||
CollapseInfo *cinfo = (CollapseInfo*)client_data;
|
anEvent.message = aEventType;
|
||||||
|
anEvent.widget = (nsWidget *) p;
|
||||||
|
NS_ADDREF(anEvent.widget);
|
||||||
|
|
||||||
if ((evt->type == Expose && evt->xexpose.window == cinfo->win &&
|
anEvent.eventStructType = NS_MOUSE_EVENT;
|
||||||
INTERSECTS(cinfo->r->x, cinfo->r->width, cinfo->r->y, cinfo->r->height,
|
|
||||||
evt->xexpose.x, evt->xexpose.y,
|
|
||||||
evt->xexpose.x + evt->xexpose.width,
|
|
||||||
evt->xexpose.y + evt->xexpose.height)) ||
|
|
||||||
(evt->type == GraphicsExpose && evt->xgraphicsexpose.drawable == cinfo->win &&
|
|
||||||
INTERSECTS(cinfo->r->x, cinfo->r->width, cinfo->r->y, cinfo->r->height,
|
|
||||||
evt->xgraphicsexpose.x, evt->xgraphicsexpose.y,
|
|
||||||
evt->xgraphicsexpose.x + evt->xgraphicsexpose.width,
|
|
||||||
evt->xgraphicsexpose.y + evt->xgraphicsexpose.height))) {
|
|
||||||
|
|
||||||
return True;
|
if (aGEM != NULL) {
|
||||||
}
|
anEvent.point.x = nscoord(aGEM->x);
|
||||||
return False;
|
anEvent.point.y = nscoord(aGEM->y);
|
||||||
|
anEvent.time = aGEM->time;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
//==============================================================
|
//==============================================================
|
||||||
gint nsGtkWidget_ExposureMask_EventHandler(GtkWidget *w, GdkEventExpose *event, gpointer p)
|
void InitCrossingEvent(GdkEventCrossing *aGEC,
|
||||||
|
gpointer p,
|
||||||
|
nsMouseEvent &anEvent,
|
||||||
|
PRUint32 aEventType)
|
||||||
{
|
{
|
||||||
nsWindow *widgetWindow = (nsWindow *)p;
|
anEvent.message = aEventType;
|
||||||
|
anEvent.widget = (nsWidget *) p;
|
||||||
|
NS_ADDREF(anEvent.widget);
|
||||||
|
|
||||||
nsPaintEvent pevent;
|
anEvent.eventStructType = NS_MOUSE_EVENT;
|
||||||
nsRect rect;
|
|
||||||
nsGtkWidget_InitNSEvent((GdkEvent*)event, p, pevent, NS_PAINT);
|
|
||||||
pevent.rect = (nsRect *)▭
|
|
||||||
|
|
||||||
rect.x = event->area.x;
|
if (aGEC != NULL) {
|
||||||
rect.y = event->area.y;
|
anEvent.point.x = nscoord(aGEC->x);
|
||||||
rect.width = event->area.width;
|
anEvent.point.y = nscoord(aGEC->y);
|
||||||
rect.height = event->area.height;
|
anEvent.time = aGEC->time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (event->type == GDK_NO_EXPOSE) {
|
//==============================================================
|
||||||
|
void InitKeyEvent(GdkEventKey *aGEK,
|
||||||
|
gpointer p,
|
||||||
|
nsKeyEvent &anEvent,
|
||||||
|
PRUint32 aEventType)
|
||||||
|
{
|
||||||
|
anEvent.message = aEventType;
|
||||||
|
anEvent.widget = (nsWidget *) p;
|
||||||
|
NS_ADDREF(anEvent.widget);
|
||||||
|
|
||||||
|
anEvent.eventStructType = NS_KEY_EVENT;
|
||||||
|
|
||||||
|
if (aGEK != NULL) {
|
||||||
|
anEvent.keyCode = nsConvertKey(aGEK->keyval) & 0x00FF;
|
||||||
|
anEvent.time = aGEK->time;
|
||||||
|
anEvent.isShift = (aGEK->state & ShiftMask) ? PR_TRUE : PR_FALSE;
|
||||||
|
anEvent.isControl = (aGEK->state & ControlMask) ? PR_TRUE : PR_FALSE;
|
||||||
|
anEvent.isAlt = (aGEK->state & Mod1Mask) ? PR_TRUE : PR_FALSE;
|
||||||
|
anEvent.time = aGEK->time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*==============================================================
|
||||||
|
==============================================================
|
||||||
|
==============================================================
|
||||||
|
==============================================================*/
|
||||||
|
|
||||||
|
gint handle_configure_event(GtkWidget *w, GdkEventConfigure *event, gpointer p)
|
||||||
|
{
|
||||||
|
nsSizeEvent sevent;
|
||||||
|
InitConfigureEvent(event, p, sevent, NS_SIZE);
|
||||||
|
|
||||||
|
nsRect rect(event->x, event->y, event->width, event->height);
|
||||||
|
nsWindow *win = (nsWindow *)p;
|
||||||
|
win->OnResize(rect);
|
||||||
|
|
||||||
|
return PR_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint handle_expose_event(GtkWidget *w, GdkEventExpose *event, gpointer p)
|
||||||
|
{
|
||||||
|
if (event->type == GDK_NO_EXPOSE)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
|
||||||
/* FIXME
|
|
||||||
Display* display = XtDisplay(w);
|
|
||||||
Window window = XtWindow(w);
|
|
||||||
XEvent xev;
|
|
||||||
|
|
||||||
XSync(display, PR_FALSE);
|
|
||||||
|
|
||||||
while (XCheckTypedWindowEvent(display, window, Expose, &xev) == PR_TRUE) {
|
|
||||||
rect.x = xev.xexpose.x;
|
|
||||||
rect.y = xev.xexpose.y;
|
|
||||||
rect.width = xev.xexpose.width;
|
|
||||||
rect.height = xev.xexpose.height;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
widgetWindow->OnPaint(pevent);
|
|
||||||
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==============================================================
|
|
||||||
gint nsGtkWidget_ButtonPressMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
|
|
||||||
{
|
|
||||||
nsWindow *widgetWindow = (nsWindow *)p;
|
|
||||||
nsMouseEvent mevent;
|
|
||||||
nsGtkWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_LEFT_BUTTON_DOWN);
|
|
||||||
widgetWindow->DispatchMouseEvent(mevent);
|
|
||||||
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==============================================================
|
|
||||||
gint nsGtkWidget_ButtonReleaseMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
|
|
||||||
{
|
|
||||||
nsWindow *widgetWindow = (nsWindow *)p;
|
|
||||||
nsMouseEvent mevent;
|
|
||||||
nsGtkWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_LEFT_BUTTON_UP);
|
|
||||||
widgetWindow->DispatchMouseEvent(mevent);
|
|
||||||
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==============================================================
|
|
||||||
gint nsGtkWidget_ButtonMotionMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
|
|
||||||
{
|
|
||||||
nsPaintEvent pevent;
|
nsPaintEvent pevent;
|
||||||
nsWindow *widgetWindow = (nsWindow *)p;
|
InitExposeEvent(event, p, pevent, NS_PAINT);
|
||||||
nsMouseEvent mevent;
|
|
||||||
nsGtkWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_MOVE);
|
nsWindow *win = (nsWindow *)p;
|
||||||
widgetWindow->DispatchMouseEvent(mevent);
|
|
||||||
|
win->OnPaint(pevent);
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================
|
//==============================================================
|
||||||
gint nsGtkWidget_MotionMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
|
gint handle_button_press_event(GtkWidget *w, GdkEventButton * event, gpointer p)
|
||||||
{
|
{
|
||||||
nsWindow *widgetWindow = (nsWindow *)p;
|
|
||||||
nsMouseEvent mevent;
|
nsMouseEvent mevent;
|
||||||
nsGtkWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_MOVE);
|
int b = NS_MOUSE_LEFT_BUTTON_DOWN;
|
||||||
widgetWindow->DispatchMouseEvent(mevent);
|
#if 0
|
||||||
|
switch (event->button)
|
||||||
|
{
|
||||||
|
case GDK_BUTTON_PRESS:
|
||||||
|
b = NS_MOUSE_LEFT_BUTTON_DOWN;
|
||||||
|
break;
|
||||||
|
case GDK_2BUTTON_PRESS:
|
||||||
|
break;
|
||||||
|
case GDK_3BUTTON_PRESS:
|
||||||
|
b = NS_MOUSE_RIGHT_BUTTON_DOWN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
InitMouseEvent(event, p, mevent, b);
|
||||||
|
|
||||||
|
nsWindow *win = (nsWindow *)p;
|
||||||
|
win->DispatchMouseEvent(mevent);
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================
|
//==============================================================
|
||||||
gint nsGtkWidget_EnterMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
|
gint handle_button_release_event(GtkWidget *w, GdkEventButton * event, gpointer p)
|
||||||
{
|
{
|
||||||
nsWindow *widgetWindow = (nsWindow *)p;
|
|
||||||
nsMouseEvent mevent;
|
nsMouseEvent mevent;
|
||||||
nsGtkWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_ENTER);
|
InitMouseEvent(event, p, mevent, NS_MOUSE_LEFT_BUTTON_UP);
|
||||||
widgetWindow->DispatchMouseEvent(mevent);
|
|
||||||
|
nsWindow *win = (nsWindow *)p;
|
||||||
|
win->DispatchMouseEvent(mevent);
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================
|
//==============================================================
|
||||||
gint nsGtkWidget_LeaveMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
|
gint handle_motion_notify_event(GtkWidget *w, GdkEventMotion * event, gpointer p)
|
||||||
{
|
{
|
||||||
if (DBG) fprintf(stderr, "***************** nsGtkWidget_LeaveMask_EventHandler\n");
|
|
||||||
nsWindow * widgetWindow = (nsWindow *)p;
|
|
||||||
nsMouseEvent mevent;
|
nsMouseEvent mevent;
|
||||||
nsGtkWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_EXIT);
|
InitMotionEvent(event, p, mevent, NS_MOUSE_MOVE);
|
||||||
widgetWindow->DispatchMouseEvent(mevent);
|
|
||||||
|
nsWindow *win = (nsWindow *)p;
|
||||||
|
win->DispatchMouseEvent(mevent);
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==============================================================
|
||||||
|
gint handle_enter_notify_event(GtkWidget *w, GdkEventCrossing * event, gpointer p)
|
||||||
|
{
|
||||||
|
nsMouseEvent mevent;
|
||||||
|
InitCrossingEvent(event, p, mevent, NS_MOUSE_ENTER);
|
||||||
|
|
||||||
|
nsWindow *win = (nsWindow *)p;
|
||||||
|
win->DispatchMouseEvent(mevent);
|
||||||
|
|
||||||
|
return PR_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//==============================================================
|
||||||
|
gint handle_leave_notify_event(GtkWidget *w, GdkEventCrossing * event, gpointer p)
|
||||||
|
{
|
||||||
|
nsMouseEvent mevent;
|
||||||
|
InitCrossingEvent(event, p, mevent, NS_MOUSE_EXIT);
|
||||||
|
|
||||||
|
nsWindow *win = (nsWindow *)p;
|
||||||
|
win->DispatchMouseEvent(mevent);
|
||||||
|
|
||||||
|
return PR_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
//==============================================================
|
//==============================================================
|
||||||
gint nsGtkWidget_Focus_Callback(GtkWidget *w, gpointer p)
|
gint nsGtkWidget_Focus_Callback(GtkWidget *w, gpointer p)
|
||||||
{
|
{
|
||||||
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
|
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
|
||||||
#if 0
|
|
||||||
nsWindow * widgetWindow = (nsWindow *) p ;
|
nsWindow * widgetWindow = (nsWindow *) p ;
|
||||||
|
|
||||||
XmAnyCallbackStruct * cbs = (XmAnyCallbackStruct*)call_data;
|
XmAnyCallbackStruct * cbs = (XmAnyCallbackStruct*)call_data;
|
||||||
|
@ -337,30 +381,30 @@ gint nsGtkWidget_Focus_Callback(GtkWidget *w, gpointer p)
|
||||||
nsGtkWidget_InitNSEvent(cbs->event, p, event,
|
nsGtkWidget_InitNSEvent(cbs->event, p, event,
|
||||||
cbs->reason == XmCR_FOCUS?NS_GOTFOCUS:NS_LOSTFOCUS);
|
cbs->reason == XmCR_FOCUS?NS_GOTFOCUS:NS_LOSTFOCUS);
|
||||||
widgetWindow->DispatchFocus(event);
|
widgetWindow->DispatchFocus(event);
|
||||||
#endif
|
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
//==============================================================
|
//==============================================================
|
||||||
gint nsGtkWidget_Toggle_Callback(GtkWidget *w, gpointer p)
|
gint nsGtkWidget_Toggle_Callback(GtkWidget *w, gpointer p)
|
||||||
{
|
{
|
||||||
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
|
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
|
||||||
#if 0
|
|
||||||
nsWindow * widgetWindow = (nsWindow *) p ;
|
nsWindow * widgetWindow = (nsWindow *) p ;
|
||||||
if (DBG) fprintf(stderr, "***************** nsGtkWidget_Scrollbar_Callback\n");
|
if (DBG) fprintf(stderr, "***************** nsGtkWidget_Scrollbar_Callback\n");
|
||||||
|
|
||||||
nsScrollbarEvent sevent;
|
nsScrollbarEvent sevent;
|
||||||
XmToggleButtonCallbackStruct * cbs = (XmToggleButtonCallbackStruct*)call_data;
|
XmToggleButtonCallbackStruct * cbs = (XmToggleButtonCallbackStruct*)call_data;
|
||||||
#endif
|
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
//==============================================================
|
//==============================================================
|
||||||
gint nsGtkWidget_CheckButton_Toggle_Callback(GtkWidget *w, gpointer p)
|
gint nsGtkWidget_CheckButton_Toggle_Callback(GtkWidget *w, gpointer p)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
nsCheckButton *checkBtn = (nsCheckButton*)gtk_object_get_user_data(GTK_OBJECT(w));
|
nsCheckButton *checkBtn = (nsCheckButton*)gtk_object_get_user_data(GTK_OBJECT(w));
|
||||||
if (GTK_TOGGLE_BUTTON(w)->active)
|
if (GTK_TOGGLE_BUTTON(w)->active)
|
||||||
checkBtn->Armed();
|
checkBtn->Armed();
|
||||||
|
@ -368,30 +412,30 @@ gint nsGtkWidget_CheckButton_Toggle_Callback(GtkWidget *w, gpointer p)
|
||||||
checkBtn->DisArmed();
|
checkBtn->DisArmed();
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
//==============================================================
|
//==============================================================
|
||||||
gint nsGtkWidget_RadioButton_ArmCallback(GtkWidget *w, gpointer p)
|
gint nsGtkWidget_RadioButton_ArmCallback(GtkWidget *w, gpointer p)
|
||||||
{
|
{
|
||||||
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
|
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
|
||||||
#if 0
|
|
||||||
nsRadioButton * radioBtn = (nsRadioButton *) p ;
|
nsRadioButton * radioBtn = (nsRadioButton *) p ;
|
||||||
XmToggleButtonCallbackStruct * cbs = (XmToggleButtonCallbackStruct*)call_data;
|
XmToggleButtonCallbackStruct * cbs = (XmToggleButtonCallbackStruct*)call_data;
|
||||||
radioBtn->Armed();
|
radioBtn->Armed();
|
||||||
nsMouseEvent mevent;
|
nsMouseEvent mevent;
|
||||||
nsGtkWidget_InitNSMouseEvent(cbs->event, p, mevent, NS_MOUSE_LEFT_BUTTON_DOWN);
|
nsGtkWidget_InitNSMouseEvent(cbs->event, p, mevent, NS_MOUSE_LEFT_BUTTON_DOWN);
|
||||||
radioBtn->DispatchMouseEvent(mevent);
|
radioBtn->DispatchMouseEvent(mevent);
|
||||||
#endif
|
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
//==============================================================
|
//==============================================================
|
||||||
gint nsGtkWidget_RadioButton_DisArmCallback(GtkWidget *w, gpointer p)
|
gint nsGtkWidget_RadioButton_DisArmCallback(GtkWidget *w, gpointer p)
|
||||||
{
|
{
|
||||||
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
|
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
|
||||||
#if 0
|
|
||||||
nsRadioButton * radioBtn = (nsRadioButton *) p ;
|
nsRadioButton * radioBtn = (nsRadioButton *) p ;
|
||||||
nsScrollbarEvent sevent;
|
nsScrollbarEvent sevent;
|
||||||
XmToggleButtonCallbackStruct * cbs = (XmToggleButtonCallbackStruct*)call_data;
|
XmToggleButtonCallbackStruct * cbs = (XmToggleButtonCallbackStruct*)call_data;
|
||||||
|
@ -399,18 +443,23 @@ gint nsGtkWidget_RadioButton_DisArmCallback(GtkWidget *w, gpointer p)
|
||||||
nsMouseEvent mevent;
|
nsMouseEvent mevent;
|
||||||
nsGtkWidget_InitNSMouseEvent(cbs->event, p, mevent, NS_MOUSE_LEFT_BUTTON_UP);
|
nsGtkWidget_InitNSMouseEvent(cbs->event, p, mevent, NS_MOUSE_LEFT_BUTTON_UP);
|
||||||
radioBtn->DispatchMouseEvent(mevent);
|
radioBtn->DispatchMouseEvent(mevent);
|
||||||
#endif
|
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//==============================================================
|
//==============================================================
|
||||||
gint nsGtkWidget_Scrollbar_Callback(GtkWidget *w, gpointer p)
|
void handle_scrollbar_value_changed(GtkAdjustment *adj, gpointer p)
|
||||||
{
|
{
|
||||||
nsScrollbar *widget = (nsScrollbar*) p;
|
nsScrollbar *widget = (nsScrollbar*) p;
|
||||||
nsScrollbarEvent sevent;
|
nsScrollbarEvent sevent;
|
||||||
|
sevent.message = NS_SCROLLBAR_POS;
|
||||||
|
sevent.widget = (nsWidget *) p;
|
||||||
|
sevent.eventStructType = NS_MOUSE_EVENT;
|
||||||
|
widget->OnScroll(sevent, adj->value);
|
||||||
|
|
||||||
|
/* FIXME we need to set point.* from the event stuff. */
|
||||||
#if 0
|
#if 0
|
||||||
nsWindow * widgetWindow = (nsWindow *) p ;
|
nsWindow * widgetWindow = (nsWindow *) p ;
|
||||||
XmScrollBarCallbackStruct * cbs = (XmScrollBarCallbackStruct*) call_data;
|
XmScrollBarCallbackStruct * cbs = (XmScrollBarCallbackStruct*) call_data;
|
||||||
|
@ -454,78 +503,30 @@ gint nsGtkWidget_Scrollbar_Callback(GtkWidget *w, gpointer p)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
sevent.message = NS_SCROLLBAR_POS;
|
|
||||||
sevent.widget = (nsWidget *) p;
|
|
||||||
widget->OnScroll(sevent, GTK_ADJUSTMENT(w)->value);
|
|
||||||
return 0; /* XXX */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==============================================================
|
|
||||||
gint nsGtkWidget_Expose_Callback(GtkWidget *w, gpointer p)
|
|
||||||
{
|
|
||||||
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
|
|
||||||
#if 0
|
|
||||||
nsWindow * widgetWindow = (nsWindow *) p ;
|
|
||||||
if (widgetWindow == nsnull) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
XmDrawingAreaCallbackStruct * cbs = (XmDrawingAreaCallbackStruct *)call_data;
|
|
||||||
XEvent * event = cbs->event;
|
|
||||||
nsPaintEvent pevent;
|
|
||||||
nsRect rect;
|
|
||||||
nsGtkWidget_InitNSEvent(event, p, pevent, NS_PAINT);
|
|
||||||
pevent.rect = (nsRect *)▭
|
|
||||||
widgetWindow->OnPaint(pevent);
|
|
||||||
#endif
|
|
||||||
return 0; /* XXX */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================
|
//==============================================================
|
||||||
gint nsGtkWidget_Text_Callback(GtkWidget *w, GdkEvent* event, gpointer p)
|
gint handle_key_release_event(GtkWidget *w, GdkEventKey* event, gpointer p)
|
||||||
{
|
{
|
||||||
nsKeyEvent kevent;
|
nsKeyEvent kevent;
|
||||||
nsGtkWidget_InitNSKeyEvent(NS_KEY_UP, kevent, w, p, event);
|
InitKeyEvent(event, p, kevent, NS_KEY_UP);
|
||||||
nsWindow * widgetWindow = (nsWindow *) p ;
|
|
||||||
widgetWindow->OnKey(NS_KEY_UP, kevent.keyCode, &kevent);
|
|
||||||
|
|
||||||
#if 0
|
nsWindow * win = (nsWindow *) p;
|
||||||
nsWindow * widgetWindow = (nsWindow *) p ;
|
win->OnKey(kevent);
|
||||||
int len;
|
|
||||||
XmTextVerifyCallbackStruct *cbs = (XmTextVerifyCallbackStruct *) call_data;
|
|
||||||
PasswordData * data;
|
|
||||||
XtVaGetValues(w, XmNuserData, &data, NULL);
|
|
||||||
if (data == NULL || data->mIgnore) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cbs->reason == XmCR_ACTIVATE) {
|
return PR_FALSE;
|
||||||
printf ("Password: %s\n", data->mPassword.ToNewCString());
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cbs->startPos < cbs->currInsert) { /* backspace */
|
//==============================================================
|
||||||
cbs->endPos = data->mPassword.Length(); /* delete from here to end */
|
gint handle_key_press_event(GtkWidget *w, GdkEventKey* event, gpointer p)
|
||||||
data->mPassword.SetLength(cbs->startPos); /* backspace--terminate */
|
{
|
||||||
return;
|
nsKeyEvent kevent;
|
||||||
}
|
InitKeyEvent(event, p, kevent, NS_KEY_DOWN);
|
||||||
|
|
||||||
if (cbs->startPos == cbs->currInsert && cbs->currInsert < data->mPassword.Length()) {
|
nsWindow * win = (nsWindow *) p;
|
||||||
nsString insStr(cbs->text->ptr);
|
win->OnKey(kevent);
|
||||||
data->mPassword.Insert(insStr, cbs->currInsert, strlen(cbs->text->ptr));
|
|
||||||
} else if (cbs->startPos == cbs->currInsert && cbs->endPos != cbs->startPos) {
|
|
||||||
data->mPassword.SetLength(cbs->startPos);
|
|
||||||
printf("Setting Length [%s] at %d\n", cbs->text->ptr, cbs->currInsert);
|
|
||||||
} else if (cbs->startPos == cbs->currInsert) { /* backspace */
|
|
||||||
data->mPassword.Append(cbs->text->ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (len = 0; len < cbs->text->length; len++)
|
return PR_FALSE;
|
||||||
cbs->text->ptr[len] = '*';
|
|
||||||
#endif
|
|
||||||
return 0; /* XXX */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================
|
//==============================================================
|
||||||
|
@ -556,45 +557,6 @@ gint nsGtkWidget_FSBOk_Callback(GtkWidget *w, gpointer p)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================
|
|
||||||
void nsGtkWidget_InitNSKeyEvent(int aEventType, nsKeyEvent& aKeyEvent,
|
|
||||||
GtkWidget *w, gpointer p, GdkEvent * event)
|
|
||||||
{
|
|
||||||
nsWindow * widgetWindow = (nsWindow *) p ;
|
|
||||||
char *res;
|
|
||||||
|
|
||||||
nsGtkWidget_InitNSEvent(event, p, aKeyEvent, aEventType);
|
|
||||||
GdkEventKey *eventKey = (GdkEventKey*)event;
|
|
||||||
|
|
||||||
aKeyEvent.keyCode = nsConvertKey(eventKey->keyval) & 0x00FF;
|
|
||||||
aKeyEvent.time = eventKey->time;
|
|
||||||
aKeyEvent.isShift = (eventKey->state & ShiftMask) ? PR_TRUE : PR_FALSE;
|
|
||||||
aKeyEvent.isControl = (eventKey->state & ControlMask) ? PR_TRUE : PR_FALSE;
|
|
||||||
aKeyEvent.isAlt = (eventKey->state & Mod1Mask) ? PR_TRUE : PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==============================================================
|
|
||||||
gint nsGtkWidget_KeyPressMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
|
|
||||||
{
|
|
||||||
nsKeyEvent kevent;
|
|
||||||
nsGtkWidget_InitNSKeyEvent(NS_KEY_DOWN, kevent, w, p, event);
|
|
||||||
nsWindow * widgetWindow = (nsWindow *) p ;
|
|
||||||
widgetWindow->OnKey(NS_KEY_DOWN, kevent.keyCode, &kevent);
|
|
||||||
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==============================================================
|
|
||||||
gint nsGtkWidget_KeyReleaseMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
|
|
||||||
{
|
|
||||||
nsKeyEvent kevent;
|
|
||||||
nsGtkWidget_InitNSKeyEvent(NS_KEY_UP, kevent, w, p, event);
|
|
||||||
nsWindow * widgetWindow = (nsWindow *) p ;
|
|
||||||
widgetWindow->OnKey(NS_KEY_UP, kevent.keyCode, &kevent);
|
|
||||||
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==============================================================
|
//==============================================================
|
||||||
gint nsGtkWidget_Menu_Callback(GtkWidget *w, gpointer p)
|
gint nsGtkWidget_Menu_Callback(GtkWidget *w, gpointer p)
|
||||||
{
|
{
|
||||||
|
@ -615,38 +577,3 @@ gint nsGtkWidget_Menu_Callback(GtkWidget *w, gpointer p)
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint nsGtkWidget_Resize_EventHandler(GtkWidget *w, GtkAllocation *allocation, gpointer data)
|
|
||||||
{
|
|
||||||
nsWindow *win = (nsWindow*)data;
|
|
||||||
|
|
||||||
nsRect winBounds;
|
|
||||||
win->GetBounds(winBounds);
|
|
||||||
g_print("resize event handler:\n\tallocation->w=%d allocation->h=%d window.w=%d window.h=%d\n",
|
|
||||||
allocation->width, allocation->height, winBounds.width, winBounds.height);
|
|
||||||
if (winBounds.width != allocation->width ||
|
|
||||||
winBounds.height != allocation->height) {
|
|
||||||
g_print("\tAllocation != current window bounds. Resize.\n");
|
|
||||||
|
|
||||||
nsRect sizeBounds;
|
|
||||||
sizeBounds.x = 0;
|
|
||||||
sizeBounds.y = 0;
|
|
||||||
winBounds.width = sizeBounds.width = allocation->width;
|
|
||||||
winBounds.height = sizeBounds.height = allocation->height;
|
|
||||||
|
|
||||||
nsSizeEvent sizeEvent;
|
|
||||||
sizeEvent.eventStructType = NS_SIZE_EVENT;
|
|
||||||
sizeEvent.message = NS_SIZE;
|
|
||||||
sizeEvent.point.x = winBounds.x;
|
|
||||||
sizeEvent.point.y = winBounds.y;
|
|
||||||
sizeEvent.time = PR_IntervalNow();
|
|
||||||
sizeEvent.widget = win;
|
|
||||||
sizeEvent.nativeMsg = nsnull;
|
|
||||||
sizeEvent.windowSize = &sizeBounds;
|
|
||||||
sizeEvent.mWinWidth = winBounds.width;
|
|
||||||
sizeEvent.mWinHeight = winBounds.height;
|
|
||||||
win->OnResize(sizeEvent);
|
|
||||||
win->SetBounds(winBounds);
|
|
||||||
}
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
|
@ -24,16 +24,19 @@
|
||||||
class nsIWidget;
|
class nsIWidget;
|
||||||
class nsIMenuItem;
|
class nsIMenuItem;
|
||||||
|
|
||||||
gint nsGtkWidget_KeyPressMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
|
gint handle_configure_event(GtkWidget *w, GdkEventConfigure *event, gpointer p);
|
||||||
gint nsGtkWidget_KeyReleaseMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
|
gint handle_expose_event(GtkWidget *w, GdkEventExpose *event, gpointer p);
|
||||||
gint nsGtkWidget_ExposureMask_EventHandler(GtkWidget * w, GdkEventExpose * event, gpointer p);
|
gint handle_button_press_event(GtkWidget *w, GdkEventButton * event, gpointer p);
|
||||||
gint nsGtkWidget_ButtonPressMask_EventHandler(GtkWidget * w, GdkEvent * event, gpointer p);
|
gint handle_button_release_event(GtkWidget *w, GdkEventButton * event, gpointer p);
|
||||||
gint nsGtkWidget_ButtonReleaseMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
|
gint handle_motion_notify_event(GtkWidget *w, GdkEventMotion * event, gpointer p);
|
||||||
gint nsGtkWidget_ButtonMotionMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
|
gint handle_enter_notify_event(GtkWidget *w, GdkEventCrossing * event, gpointer p);
|
||||||
gint nsGtkWidget_MotionMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
|
gint handle_leave_notify_event(GtkWidget *w, GdkEventCrossing * event, gpointer p);
|
||||||
gint nsGtkWidget_EnterMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
|
|
||||||
gint nsGtkWidget_LeaveMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
|
gint handle_key_release_event(GtkWidget *w, GdkEventKey* event, gpointer p);
|
||||||
gint nsGtkWidget_Resize_EventHandler(GtkWidget *w, GtkAllocation *allocation, gpointer data);
|
gint handle_key_press_event(GtkWidget *w, GdkEventKey* event, gpointer p);
|
||||||
|
|
||||||
|
void handle_scrollbar_value_changed(GtkAdjustment *adjustment, gpointer p);
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
|
||||||
|
@ -42,14 +45,15 @@ gint nsGtkWidget_FSBOk_Callback(GtkWidget *w, gpointer p);
|
||||||
|
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
gint nsGtkWidget_Focus_Callback(GtkWidget *w, gpointer p);
|
gint nsGtkWidget_Focus_Callback(GtkWidget *w, gpointer p);
|
||||||
gint nsGtkWidget_Scrollbar_Callback(GtkWidget *w, gpointer p);
|
|
||||||
|
|
||||||
|
|
||||||
gint CheckButton_Toggle_Callback(GtkWidget *w, gpointer p);
|
gint CheckButton_Toggle_Callback(GtkWidget *w, gpointer p);
|
||||||
|
|
||||||
gint nsGtkWidget_RadioButton_ArmCallback(GtkWidget *w, gpointer p);
|
gint nsGtkWidget_RadioButton_ArmCallback(GtkWidget *w, gpointer p);
|
||||||
gint nsGtkWidget_RadioButton_DisArmCallback(GtkWidget *w, gpointer p);
|
gint nsGtkWidget_RadioButton_DisArmCallback(GtkWidget *w, gpointer p);
|
||||||
|
|
||||||
gint nsGtkWidget_Text_Callback(GtkWidget *w, GdkEvent* event, gpointer p);
|
gint nsGtkWidget_Text_Callback(GtkWidget *w, GdkEventKey* event, gpointer p);
|
||||||
gint nsGtkWidget_Expose_Callback(GtkWidget *w, gpointer p);
|
gint nsGtkWidget_Expose_Callback(GtkWidget *w, gpointer p);
|
||||||
|
|
||||||
gint nsGtkWidget_Refresh_Callback(gpointer call_data);
|
gint nsGtkWidget_Refresh_Callback(gpointer call_data);
|
||||||
|
|
|
@ -174,7 +174,7 @@ PRBool nsLabel::OnPaint(nsPaintEvent &aEvent)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool nsLabel::OnResize(nsSizeEvent &aEvent)
|
PRBool nsLabel::OnResize(nsRect &aWindowRect)
|
||||||
{
|
{
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
|
|
||||||
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
||||||
virtual PRBool OnPaint(nsPaintEvent &aEvent);
|
virtual PRBool OnPaint(nsPaintEvent &aEvent);
|
||||||
virtual PRBool OnResize(nsSizeEvent &aEvent);
|
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NS_METHOD CreateNative(GtkWidget *parentWindow);
|
NS_METHOD CreateNative(GtkWidget *parentWindow);
|
||||||
|
|
|
@ -375,7 +375,7 @@ PRBool nsListBox::OnPaint(nsPaintEvent &aEvent)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool nsListBox::OnResize(nsSizeEvent &aEvent)
|
PRBool nsListBox::OnResize(nsRect &aWindowRect)
|
||||||
{
|
{
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
|
|
||||||
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
||||||
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
||||||
virtual PRBool OnResize(nsSizeEvent &aEvent);
|
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||||
|
|
||||||
|
|
||||||
// nsIListBox interface
|
// nsIListBox interface
|
||||||
|
|
|
@ -156,7 +156,7 @@ PRBool nsRadioButton::OnPaint(nsPaintEvent &aEvent)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool nsRadioButton::OnResize(nsSizeEvent &aEvent)
|
PRBool nsRadioButton::OnResize(nsRect &aWindowRect)
|
||||||
{
|
{
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
// nsIRadioButton part
|
// nsIRadioButton part
|
||||||
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
||||||
virtual PRBool OnPaint(nsPaintEvent &aEvent);
|
virtual PRBool OnPaint(nsPaintEvent &aEvent);
|
||||||
virtual PRBool OnResize(nsSizeEvent &aEvent);
|
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||||
|
|
||||||
|
|
||||||
// These are needed to Override the auto check behavior
|
// These are needed to Override the auto check behavior
|
||||||
|
|
|
@ -74,7 +74,7 @@ NS_METHOD nsScrollbar::CreateNative (GtkWidget * parentWindow)
|
||||||
|
|
||||||
gtk_signal_connect (GTK_OBJECT (mAdjustment),
|
gtk_signal_connect (GTK_OBJECT (mAdjustment),
|
||||||
"value_changed",
|
"value_changed",
|
||||||
GTK_SIGNAL_FUNC (nsGtkWidget_Scrollbar_Callback),
|
GTK_SIGNAL_FUNC (handle_scrollbar_value_changed),
|
||||||
this);
|
this);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -250,7 +250,7 @@ PRBool nsScrollbar::OnPaint (nsPaintEvent & aEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PRBool nsScrollbar::OnResize (nsSizeEvent & aEvent)
|
PRBool nsScrollbar::OnResize (nsRect &aWindowRect)
|
||||||
{
|
{
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
|
|
||||||
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
||||||
virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos);
|
virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos);
|
||||||
virtual PRBool OnResize(nsSizeEvent &aEvent);
|
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NS_IMETHOD CreateNative(GtkWidget *parentWindow);
|
NS_IMETHOD CreateNative(GtkWidget *parentWindow);
|
||||||
|
|
|
@ -97,7 +97,7 @@ PRBool nsTextAreaWidget::OnPaint(nsPaintEvent & aEvent)
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
PRBool nsTextAreaWidget::OnResize(nsSizeEvent &aEvent)
|
PRBool nsTextAreaWidget::OnResize(nsRect &aWindowRect)
|
||||||
{
|
{
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||||
|
|
||||||
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
||||||
virtual PRBool OnResize(nsSizeEvent &aEvent);
|
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NS_METHOD CreateNative(GtkWidget *parentWindow);
|
NS_METHOD CreateNative(GtkWidget *parentWindow);
|
||||||
|
|
|
@ -61,7 +61,7 @@ NS_METHOD nsTextWidget::CreateNative(GtkWidget *parentWindow)
|
||||||
gtk_widget_set_name(mWidget, "nsTextWidget");
|
gtk_widget_set_name(mWidget, "nsTextWidget");
|
||||||
gtk_signal_connect(GTK_OBJECT(mWidget),
|
gtk_signal_connect(GTK_OBJECT(mWidget),
|
||||||
"key_release_event",
|
"key_release_event",
|
||||||
GTK_SIGNAL_FUNC(nsGtkWidget_Text_Callback),
|
GTK_SIGNAL_FUNC(handle_key_release_event),
|
||||||
this);
|
this);
|
||||||
gtk_widget_show(mWidget);
|
gtk_widget_show(mWidget);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -98,7 +98,7 @@ PRBool nsTextWidget::OnPaint(nsPaintEvent & aEvent)
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
PRBool nsTextWidget::OnResize(nsSizeEvent &aEvent)
|
PRBool nsTextWidget::OnResize(nsRect &aWindowRect)
|
||||||
{
|
{
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
virtual PRBool OnPaint(nsPaintEvent & aEvent);
|
||||||
virtual PRBool OnResize(nsSizeEvent &aEvent);
|
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NS_IMETHOD CreateNative(GtkWidget *parentWindow);
|
NS_IMETHOD CreateNative(GtkWidget *parentWindow);
|
||||||
|
|
|
@ -191,6 +191,39 @@ static void set_icon (GdkWindow * w)
|
||||||
gdk_pixmap_unref(pmap);
|
gdk_pixmap_unref(pmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nsWindow::InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint)
|
||||||
|
{
|
||||||
|
event.widget = this;
|
||||||
|
NS_IF_ADDREF(event.widget);
|
||||||
|
|
||||||
|
GdkEventConfigure *ge;
|
||||||
|
ge = (GdkEventConfigure*)gtk_get_current_event();
|
||||||
|
|
||||||
|
if (aPoint == nsnull) { // use the point from the event
|
||||||
|
// get the message position in client coordinates and in twips
|
||||||
|
|
||||||
|
if (mWidget != NULL) {
|
||||||
|
// ::ScreenToClient(mWnd, &cpos);
|
||||||
|
event.point.x = PRInt32(ge->x);
|
||||||
|
event.point.y = PRInt32(ge->y);
|
||||||
|
} else {
|
||||||
|
event.point.x = 0;
|
||||||
|
event.point.y = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { // use the point override if provided
|
||||||
|
event.point.x = aPoint->x;
|
||||||
|
event.point.y = aPoint->y;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.time = gdk_event_get_time((GdkEvent*)ge);
|
||||||
|
event.message = aEventType;
|
||||||
|
|
||||||
|
// mLastPoint.x = event.point.x;
|
||||||
|
// mLastPoint.y = event.point.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Create the native widget
|
// Create the native widget
|
||||||
|
@ -201,6 +234,7 @@ NS_METHOD nsWindow::CreateNative(GtkWidget *parentWidget)
|
||||||
GtkWidget *mainWindow;
|
GtkWidget *mainWindow;
|
||||||
|
|
||||||
mWidget = gtk_layout_new(PR_FALSE, PR_FALSE);
|
mWidget = gtk_layout_new(PR_FALSE, PR_FALSE);
|
||||||
|
|
||||||
gtk_widget_set_events (mWidget,
|
gtk_widget_set_events (mWidget,
|
||||||
GDK_BUTTON_PRESS_MASK |
|
GDK_BUTTON_PRESS_MASK |
|
||||||
GDK_BUTTON_RELEASE_MASK |
|
GDK_BUTTON_RELEASE_MASK |
|
||||||
|
@ -219,9 +253,9 @@ NS_METHOD nsWindow::CreateNative(GtkWidget *parentWidget)
|
||||||
GTK_SIGNAL_FUNC(window_realize_callback),
|
GTK_SIGNAL_FUNC(window_realize_callback),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gtk_signal_connect(GTK_OBJECT(mWidget),
|
gtk_signal_connect(GTK_OBJECT(mainWindow),
|
||||||
"size_allocate",
|
"configure_event",
|
||||||
GTK_SIGNAL_FUNC(nsGtkWidget_Resize_EventHandler),
|
GTK_SIGNAL_FUNC(handle_configure_event),
|
||||||
this);
|
this);
|
||||||
|
|
||||||
// VBox for the menu, etc.
|
// VBox for the menu, etc.
|
||||||
|
@ -246,44 +280,47 @@ NS_METHOD nsWindow::CreateNative(GtkWidget *parentWidget)
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
void nsWindow::InitCallbacks(char * aName)
|
void nsWindow::InitCallbacks(char * aName)
|
||||||
{
|
{
|
||||||
|
gtk_signal_connect(GTK_OBJECT(mWidget),
|
||||||
|
"configure_event",
|
||||||
|
GTK_SIGNAL_FUNC(handle_configure_event),
|
||||||
|
this);
|
||||||
|
|
||||||
gtk_signal_connect(GTK_OBJECT(mWidget),
|
gtk_signal_connect(GTK_OBJECT(mWidget),
|
||||||
"button_press_event",
|
"button_press_event",
|
||||||
GTK_SIGNAL_FUNC(nsGtkWidget_ButtonPressMask_EventHandler),
|
GTK_SIGNAL_FUNC(handle_button_press_event),
|
||||||
this);
|
this);
|
||||||
|
|
||||||
gtk_signal_connect(GTK_OBJECT(mWidget),
|
gtk_signal_connect(GTK_OBJECT(mWidget),
|
||||||
"button_release_event",
|
"button_release_event",
|
||||||
GTK_SIGNAL_FUNC(nsGtkWidget_ButtonReleaseMask_EventHandler),
|
GTK_SIGNAL_FUNC(handle_button_release_event),
|
||||||
this);
|
this);
|
||||||
|
|
||||||
gtk_signal_connect(GTK_OBJECT(mWidget),
|
gtk_signal_connect(GTK_OBJECT(mWidget),
|
||||||
"motion_notify_event",
|
"motion_notify_event",
|
||||||
GTK_SIGNAL_FUNC(nsGtkWidget_ButtonMotionMask_EventHandler),
|
GTK_SIGNAL_FUNC(handle_motion_notify_event),
|
||||||
this);
|
this);
|
||||||
|
|
||||||
gtk_signal_connect(GTK_OBJECT(mWidget),
|
gtk_signal_connect(GTK_OBJECT(mWidget),
|
||||||
"enter_notify_event",
|
"enter_notify_event",
|
||||||
GTK_SIGNAL_FUNC(nsGtkWidget_EnterMask_EventHandler),
|
GTK_SIGNAL_FUNC(handle_enter_notify_event),
|
||||||
this);
|
this);
|
||||||
|
|
||||||
gtk_signal_connect(GTK_OBJECT(mWidget),
|
gtk_signal_connect(GTK_OBJECT(mWidget),
|
||||||
"leave_notify_event",
|
"leave_notify_event",
|
||||||
GTK_SIGNAL_FUNC(nsGtkWidget_LeaveMask_EventHandler),
|
GTK_SIGNAL_FUNC(handle_leave_notify_event),
|
||||||
this);
|
this);
|
||||||
|
|
||||||
gtk_signal_connect(GTK_OBJECT(mWidget),
|
gtk_signal_connect(GTK_OBJECT(mWidget),
|
||||||
"expose_event",
|
"expose_event",
|
||||||
GTK_SIGNAL_FUNC(nsGtkWidget_ExposureMask_EventHandler),
|
GTK_SIGNAL_FUNC(handle_expose_event),
|
||||||
this);
|
this);
|
||||||
|
|
||||||
gtk_signal_connect(GTK_OBJECT(mWidget),
|
gtk_signal_connect(GTK_OBJECT(mWidget),
|
||||||
"key_press_event",
|
"key_press_event",
|
||||||
GTK_SIGNAL_FUNC(nsGtkWidget_KeyPressMask_EventHandler),
|
GTK_SIGNAL_FUNC(handle_key_press_event),
|
||||||
this);
|
this);
|
||||||
|
|
||||||
gtk_signal_connect(GTK_OBJECT(mWidget),
|
gtk_signal_connect(GTK_OBJECT(mWidget),
|
||||||
"key_release_event",
|
"key_release_event",
|
||||||
GTK_SIGNAL_FUNC(nsGtkWidget_KeyReleaseMask_EventHandler),
|
GTK_SIGNAL_FUNC(handle_key_release_event),
|
||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,24 +677,33 @@ void nsWindow::OnDestroy()
|
||||||
// NS_IF_RELEASE(mAppShell);
|
// NS_IF_RELEASE(mAppShell);
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool nsWindow::OnResize(nsSizeEvent &aEvent)
|
PRBool nsWindow::OnResize(nsRect &aWindowRect)
|
||||||
{
|
{
|
||||||
nsRect* size = aEvent.windowSize;
|
if (mEventCallback) {
|
||||||
|
nsSizeEvent event;
|
||||||
|
nsRect winBounds;
|
||||||
|
|
||||||
if (mEventCallback && !mIgnoreResize) {
|
InitEvent(event, NS_SIZE);
|
||||||
return DispatchWindowEvent(&aEvent);
|
event.windowSize = &aWindowRect;
|
||||||
|
event.eventStructType = NS_SIZE_EVENT;
|
||||||
|
GetBounds(winBounds);
|
||||||
|
|
||||||
|
event.mWinWidth = winBounds.width;
|
||||||
|
event.mWinHeight = winBounds.height;
|
||||||
|
|
||||||
|
PRBool result = DispatchWindowEvent(&event);
|
||||||
|
NS_IF_RELEASE(event.widget);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool nsWindow::OnKey(PRUint32 aEventType, PRUint32 aKeyCode, nsKeyEvent* aEvent)
|
PRBool nsWindow::OnKey(nsKeyEvent &aEvent)
|
||||||
{
|
{
|
||||||
if (mEventCallback) {
|
if (mEventCallback) {
|
||||||
return DispatchWindowEvent(aEvent);
|
return DispatchWindowEvent(&aEvent);
|
||||||
}
|
}
|
||||||
else
|
return PR_FALSE;
|
||||||
return PR_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -669,7 +715,7 @@ PRBool nsWindow::DispatchFocus(nsGUIEvent &aEvent)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool nsWindow::OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos)
|
PRBool nsWindow::OnScroll(nsScrollbarEvent &aEvent, PRUint32 cPos)
|
||||||
{
|
{
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,8 @@ public:
|
||||||
NS_IMETHOD GetClientBounds(nsRect &aRect);
|
NS_IMETHOD GetClientBounds(nsRect &aRect);
|
||||||
NS_IMETHOD GetBorderSize(PRInt32 &aWidth, PRInt32 &aHeight);
|
NS_IMETHOD GetBorderSize(PRInt32 &aWidth, PRInt32 &aHeight);
|
||||||
|
|
||||||
|
void InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint = nsnull);
|
||||||
|
|
||||||
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
|
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
|
||||||
NS_IMETHOD Invalidate(const nsRect &aRect, PRBool aIsSynchronous);
|
NS_IMETHOD Invalidate(const nsRect &aRect, PRBool aIsSynchronous);
|
||||||
NS_IMETHOD Update();
|
NS_IMETHOD Update();
|
||||||
|
@ -95,13 +97,13 @@ public:
|
||||||
// Utility methods
|
// Utility methods
|
||||||
virtual PRBool OnPaint(nsPaintEvent &event);
|
virtual PRBool OnPaint(nsPaintEvent &event);
|
||||||
virtual void OnDestroy();
|
virtual void OnDestroy();
|
||||||
PRBool OnKey(PRUint32 aEventType, PRUint32 aKeyCode, nsKeyEvent* aEvent);
|
PRBool OnKey(nsKeyEvent &aEvent);
|
||||||
PRBool DispatchFocus(nsGUIEvent &aEvent);
|
PRBool DispatchFocus(nsGUIEvent &aEvent);
|
||||||
virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos);
|
virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos);
|
||||||
void SetIgnoreResize(PRBool aIgnore);
|
void SetIgnoreResize(PRBool aIgnore);
|
||||||
PRBool IgnoreResize();
|
PRBool IgnoreResize();
|
||||||
PRUint32 GetYCoord(PRUint32 aNewY);
|
PRUint32 GetYCoord(PRUint32 aNewY);
|
||||||
virtual PRBool OnResize(nsSizeEvent &aEvent);
|
virtual PRBool OnResize(nsRect &aWindowRect);
|
||||||
|
|
||||||
// Resize event management
|
// Resize event management
|
||||||
void SetResizeRect(nsRect& aRect);
|
void SetResizeRect(nsRect& aRect);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче