sync all my changes. removed lots of code that is provided in nsBaseWidget,

added focus handlers, etc etc etc
This commit is contained in:
pavlov%pavlov.net 1999-01-12 03:56:33 +00:00
Родитель 1e7c09ace7
Коммит b0a13ace63
6 изменённых файлов: 71 добавлений и 170 удалений

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

@ -301,6 +301,23 @@ void InitKeyEvent(GdkEventKey *aGEK,
}
}
//==============================================================
void InitFocusEvent(GdkEventFocus *aGEF,
gpointer p,
nsGUIEvent &anEvent,
PRUint32 aEventType)
{
anEvent.message = aEventType;
anEvent.widget = (nsWidget *) p;
NS_ADDREF(anEvent.widget);
anEvent.eventStructType = NS_GUI_EVENT;
anEvent.time = 0;
anEvent.point.x = 0;
anEvent.point.y = 0;
}
/*==============================================================
==============================================================
=============================================================
@ -472,6 +489,30 @@ gint handle_leave_notify_event(GtkWidget *w, GdkEventCrossing * event, gpointer
return PR_FALSE;
}
//==============================================================
gint handle_focus_in_event(GtkWidget *w, GdkEventFocus * event, gpointer p)
{
nsGUIEvent gevent;
InitFocusEvent(event, p, gevent, NS_GOTFOCUS);
nsWindow *win = (nsWindow *)p;
win->DispatchFocus(gevent);
return PR_FALSE;
}
//==============================================================
gint handle_focus_out_event(GtkWidget *w, GdkEventFocus * event, gpointer p)
{
nsGUIEvent gevent;
InitFocusEvent(event, p, gevent, NS_LOSTFOCUS);
nsWindow *win = (nsWindow *)p;
win->DispatchFocus(gevent);
return PR_FALSE;
}
#if 0
//==============================================================
gint nsGtkWidget_Focus_Callback(GtkWidget *w, gpointer p)

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

@ -36,6 +36,9 @@ gint handle_leave_notify_event(GtkWidget *w, GdkEventCrossing * event, gpointer
gint handle_key_release_event(GtkWidget *w, GdkEventKey* event, gpointer p);
gint handle_key_press_event(GtkWidget *w, GdkEventKey* event, gpointer p);
gint handle_focus_in_event(GtkWidget *w, GdkEventFocus * event, gpointer p);
gint handle_focus_out_event(GtkWidget *w, GdkEventFocus * event, gpointer p);
void handle_scrollbar_value_changed(GtkAdjustment *adjustment, gpointer p);

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

@ -256,31 +256,6 @@ NS_METHOD nsWidget::GetBounds(nsRect &aRect)
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Set the background color
//
//-------------------------------------------------------------------------
NS_METHOD nsWidget::SetBackgroundColor(const nscolor &aColor)
{
GtkStyle *style;
GdkColor color;
mBackground = aColor;
nsBaseWidget::SetBackgroundColor(aColor);
/* FIXME do we need the rest of this? (look at the windows code) */
NSCOLOR_TO_GDKCOLOR(color, aColor);
#ifdef DBG
g_print("nsWidget::SetBackgroundColor %d %d %d\n", color.red, color.blue, color.green);
#endif
style = gtk_style_copy(mWidget->style);
style->bg[GTK_STATE_NORMAL] = color;
gtk_widget_set_style(mWidget, style);
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Get this component font
@ -412,6 +387,7 @@ void *nsWidget::GetNativeData(PRUint32 aDataType)
return res;
}
default:
g_print("nsWidget::GetNativeData(%i) - weird value\n", aDataType);
break;
}
return nsnull;
@ -427,18 +403,6 @@ NS_METHOD nsWidget::SetColorMap(nsColorMap *aColorMap)
return NS_OK;
}
nsIDeviceContext* nsWidget::GetDeviceContext(void)
{
NS_NOTYETIMPLEMENTED("nsWidget::GetDeviceContext");
return mContext;
}
nsIAppShell* nsWidget::GetAppShell(void)
{
NS_NOTYETIMPLEMENTED("nsWidget::GetAppShell");
return nsnull;
}
NS_METHOD nsWidget::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
{
NS_NOTYETIMPLEMENTED("nsWidget::Scroll");
@ -571,30 +535,7 @@ void nsWidget::InitCallbacks(char *aName)
NS_NOTYETIMPLEMENTED("nsWidget::InitCallbacks");
}
nsIRenderingContext* nsWidget::GetRenderingContext()
{
nsIRenderingContext * ctx = nsnull;
if (GetNativeData(NS_NATIVE_WIDGET)) {
nsresult res;
static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
res = nsRepository::CreateInstance(kRenderingContextCID, nsnull,
kRenderingContextIID,
(void **)&ctx);
if (NS_OK == res)
ctx->Init(mContext, this);
NS_ASSERTION(NULL != ctx, "Null rendering context");
}
return ctx;
}
/* this is only used for nsWindow's */
void nsWidget::CreateGC()
{
if (mWidget && !mGC)

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

@ -72,8 +72,6 @@ class nsWidget : public nsBaseWidget
NS_IMETHOD GetBounds(nsRect &aRect);
NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
nsIFontMetrics *GetFont(void);
NS_IMETHOD SetFont(const nsFont &aFont);
@ -82,8 +80,6 @@ class nsWidget : public nsBaseWidget
NS_IMETHOD SetColorMap(nsColorMap *aColorMap);
void* GetNativeData(PRUint32 aDataType);
nsIRenderingContext *GetRenderingContext(void);
nsIDeviceContext *GetDeviceContext(void);
NS_IMETHOD WidgetToScreen(const nsRect &aOldRect, nsRect &aNewRect);
NS_IMETHOD ScreenToWidget(const nsRect &aOldRect, nsRect &aNewRect);
@ -100,7 +96,6 @@ class nsWidget : public nsBaseWidget
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect);
NS_IMETHOD SetMenuBar(nsIMenuBar *aMenuBar);
nsIAppShell *GetAppShell(void);
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
NS_IMETHOD Invalidate(const nsRect &aRect, PRBool aIsSynchronous);

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

@ -130,12 +130,13 @@ NS_METHOD nsWindow::CreateNative(GtkWidget *parentWidget)
gtk_widget_set_events (mWidget,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK |
GDK_EXPOSURE_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_EXPOSURE_MASK |
GDK_FOCUS_CHANGE_MASK |
GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK);
GDK_KEY_RELEASE_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK);
if (!parentWidget) {
@ -200,6 +201,14 @@ void nsWindow::InitCallbacks(char * aName)
"key_release_event",
GTK_SIGNAL_FUNC(handle_key_release_event),
this);
gtk_signal_connect(GTK_OBJECT(mWidget),
"focus_in_event",
GTK_SIGNAL_FUNC(handle_focus_in_event),
this);
gtk_signal_connect(GTK_OBJECT(mWidget),
"focus_out_event",
GTK_SIGNAL_FUNC(handle_focus_out_event),
this);
}
//-------------------------------------------------------------------------
@ -290,33 +299,6 @@ NS_IMETHODIMP nsWindow::Update()
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Create a rendering context from this nsWindow
//
//-------------------------------------------------------------------------
nsIRenderingContext* nsWindow::GetRenderingContext()
{
nsIRenderingContext * ctx = nsnull;
if (GetNativeData(NS_NATIVE_WIDGET)) {
nsresult res;
static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
static NS_DEFINE_IID(kRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
res = nsRepository::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&ctx);
if (NS_OK == res)
ctx->Init(mContext, this);
NS_ASSERTION(NULL != ctx, "Null rendering context");
}
return ctx;
}
//-------------------------------------------------------------------------
//
// Return some native data according to aDataType
@ -349,28 +331,6 @@ NS_METHOD nsWindow::SetColorMap(nsColorMap *aColorMap)
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Return the used device context
//
//-------------------------------------------------------------------------
nsIDeviceContext* nsWindow::GetDeviceContext()
{
NS_IF_ADDREF(mContext);
return mContext;
}
//-------------------------------------------------------------------------
//
// Return the used app shell
//
//-------------------------------------------------------------------------
nsIAppShell* nsWindow::GetAppShell()
{
NS_IF_ADDREF(mAppShell);
return mAppShell;
}
//-------------------------------------------------------------------------
//
// Scroll the bits of a window
@ -389,11 +349,6 @@ NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
return NS_OK;
}
NS_METHOD nsWindow::SetBorderStyle(nsBorderStyle aBorderStyle)
{
return NS_OK;
}
NS_METHOD nsWindow::SetTitle(const nsString& aTitle)
{
if (mVBox) // Top level widget (has correct parent)
@ -508,30 +463,3 @@ NS_METHOD nsWindow::SetMenuBar(nsIMenuBar * aMenuBar)
gtk_box_reorder_child(GTK_BOX(mVBox), menubar, 0);
return NS_OK;
}
/**
*
*
**/
NS_METHOD nsWindow::GetClientBounds(nsRect &aRect)
{
return GetBounds(aRect);
}
/**
* Calculates the border width and height
*
**/
NS_METHOD nsWindow::GetBorderSize(PRInt32 &aWidth, PRInt32 &aHeight)
{
nsRect rectWin;
nsRect rectClient;
GetBounds(rectWin);
GetClientBounds(rectClient);
aWidth = rectWin.width - rectClient.width;
aHeight = rectWin.height - rectClient.height;
return NS_OK;
}

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

@ -47,29 +47,22 @@ public:
virtual void ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY);
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aWidgetInitData) { return NS_OK; }
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aWidgetInitData) { return NS_OK; }
virtual void* GetNativeData(PRUint32 aDataType);
virtual void* GetNativeData(PRUint32 aDataType);
NS_IMETHOD GetClientBounds(nsRect &aRect);
NS_IMETHOD GetBorderSize(PRInt32 &aWidth, PRInt32 &aHeight);
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
NS_IMETHOD Invalidate(const nsRect &aRect, PRBool aIsSynchronous);
NS_IMETHOD Update();
NS_IMETHOD SetColorMap(nsColorMap *aColorMap);
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect);
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
NS_IMETHOD Invalidate(const nsRect &aRect, PRBool aIsSynchronous);
NS_IMETHOD Update();
virtual nsIRenderingContext* GetRenderingContext();
NS_IMETHOD SetColorMap(nsColorMap *aColorMap);
virtual nsIDeviceContext* GetDeviceContext();
virtual nsIAppShell * GetAppShell();
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect);
NS_IMETHOD SetTitle(const nsString& aTitle);
NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar);
NS_IMETHOD SetBorderStyle(nsBorderStyle aBorderStyle);
NS_IMETHOD SetTitle(const nsString& aTitle);
NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar);
NS_IMETHOD SetTooltips(PRUint32 aNumberOfTips,nsRect* aTooltipAreas[]);
NS_IMETHOD UpdateTooltips(nsRect* aNewTips[]);
NS_IMETHOD RemoveTooltips();
NS_IMETHOD SetTooltips(PRUint32 aNumberOfTips,nsRect* aTooltipAreas[]);
NS_IMETHOD UpdateTooltips(nsRect* aNewTips[]);
NS_IMETHOD RemoveTooltips();
NS_IMETHOD BeginResizingChildren(void);
NS_IMETHOD EndResizingChildren(void);