add ScrollRect method to nsIWidget -- implimented on linux and stubbed in nsBaseWidget for mac and windows. Added ifdef'd scrolling code that makes scrolling really fast on linux. Updated nsIWidget.idl (not built) to merge some changes from a branch and added ScrollRect. Added ifdefs for using gtk_fixed instead of gtk_layout as part of the new scrolling code.

This commit is contained in:
pavlov%netscape.com 1999-10-23 01:17:20 +00:00
Родитель b8be9cb3b0
Коммит 4b37cca123
7 изменённых файлов: 246 добавлений и 7 удалений

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

@ -549,6 +549,17 @@ class nsIWidget : public nsISupports {
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) = 0;
/**
* Scroll an area of this widget.
*
* @param aRect source rectangle to scroll in the widget
* @param aDx x offset from the source
* @param aDy y offset from the source
*
*/
NS_IMETHOD ScrollRect(nsRect &aSrcRect, PRInt32 aDx, PRInt32 aDy) = 0;
/**
* Internal methods
*/

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

@ -64,7 +64,7 @@ class nsIRollupListener;
[ptr] native nsIMouseListener(nsIMouseListener);
[ptr] native nsIEventListener(nsIEventListener);
[ptr] native nsIMenuListener(nsIMenuListener);
[ptr] native nsIRegion(nsIRegion);
[ptr] native nsRect(nsRect);
[ref] native nsRectRef(nsRect);
[ptr] native nsFont(nsFont);
@ -76,6 +76,7 @@ class nsIRollupListener;
native nscolor(nscolor);
native nscoord(nscoord);
native nsEventStatus(nsEventStatus);
[ref] native nsEventStatusRef(nsEventStatus);
native PR_CALLBACK(PR_CALLBACKK);
native EVENT_CALLBACK(EVENT_CALLBACK);
@ -303,7 +304,7 @@ interface nsIWidget : nsISupports
* @return the parent widget or nsnull if it does not have a parent
*
*/
void GetParent(out nsIWidget aParent);
readonly attribute nsIWidget Parent;
/**
* Show or hide this widget
@ -313,6 +314,9 @@ interface nsIWidget : nsISupports
*/
attribute PRBool Visibility;
void GetNativeData(in PRUint32 aDataType, out voidStar aData);
/**
* Make the window modal
*
@ -402,6 +406,15 @@ interface nsIWidget : nsISupports
*/
void GetBorderSize(out PRInt32 aWidth, out PRInt32 aHeight);
/**
* Get the nsIToolkit
*/
readonly attribute nsIToolkit Toolkit;
/**
* Get and Set the widget's z-index.
*/
attribute PRInt32 ZIndex;
/**
* Set/Get the foreground color for this widget
@ -459,8 +472,8 @@ interface nsIWidget : nsISupports
* @param aIsSynchronouse PR_TRUE then repaint synchronously. If PR_FALSE repaint later.
* @see #Update()
*/
void InvalidateRegion([const] in nsIScriptableRegion aRegion, in PRBool aIsSynchronous);
// void InvalidateRegion([const] in nsIScriptableRegion aRegion, in PRBool aIsSynchronous);
void InvalidateRegion([const] in nsIRegion aRegion, in PRBool aIsSynchronous);
/**
* Force a synchronous repaint of the window if there are dirty rects.
*
@ -510,6 +523,16 @@ interface nsIWidget : nsISupports
*/
void Scroll(in PRInt32 aDx, in PRInt32 aDy, in nsRect aClipRect);
/**
* Scroll an area of this widget.
*
* @param aRect source rectangle to scroll in the widget
* @param aDx x offset from the source
* @param aDy y offset from the source
*
*/
void ScrollRect(in nsRectRef aSrcRect, in PRInt32 aDx, in PRInt32 aDy);
/**
* Set the widget's title.
* Must be called after Create.
@ -583,7 +606,7 @@ interface nsIWidget : nsISupports
* Dispatches and event to the widget
*
*/
void DispatchEvent(in nsGUIEvent event, in nsEventStatus aStatus);
void DispatchEvent(in nsGUIEvent event, in nsEventStatusRef aStatus);
/**
* For printing and lightweight widgets
@ -596,7 +619,7 @@ interface nsIWidget : nsISupports
* Enables the dropping of files to a widget (XXX this is temporary)
*
*/
void EnableFileDrop(in PRBool aEnable);
void EnableDragDrop(in PRBool aEnable);
void ConvertToDeviceCoordinates(inout nscoord aX, inout nscoord aY);

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

@ -33,6 +33,8 @@
#include "nsGtkUtils.h" // for nsGtkUtils::gdk_keyboard_get_modifiers()
//#define USE_GTK_FIXED
#ifdef USE_XIM
#include "nsIServiceManager.h"
#include "nsIPref.h"
@ -430,6 +432,7 @@ NS_IMETHODIMP nsWidget::Move(PRInt32 aX, PRInt32 aY)
{
if (mWidget)
{
#ifndef USE_GTK_FIXED
GtkWidget * layout = mWidget->parent;
GtkAdjustment* ha = gtk_layout_get_hadjustment(GTK_LAYOUT(layout));
@ -467,6 +470,9 @@ NS_IMETHODIMP nsWidget::Move(PRInt32 aX, PRInt32 aY)
mWidget,
aX + x_correction,
aY + y_correction);
#else
gtk_fixed_move(GTK_FIXED(mWidget->parent), mWidget, aX, aY);
#endif
}
return NS_OK;
@ -1028,7 +1034,11 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent,
{
if (parentWidget)
{
#ifndef USE_GTK_FIXED
gtk_layout_put(GTK_LAYOUT(parentWidget), mWidget, aRect.x, aRect.y);
#else
gtk_fixed_put(GTK_FIXED(parentWidget), mWidget, aRect.x, aRect.y);
#endif
}
}

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

@ -42,6 +42,7 @@
#include "stdio.h"
//#define USE_GTK_FIXED
//-------------------------------------------------------------------------
//
@ -216,7 +217,11 @@ gint nsWindow::ConvertBorderStyles(nsBorderStyle bs)
//-------------------------------------------------------------------------
NS_METHOD nsWindow::CreateNative(GtkWidget *parentWidget)
{
#ifndef USE_GTK_FIXED
mWidget = gtk_layout_new(PR_FALSE, PR_FALSE);
#else
mWidget = gtk_fixed_new();
#endif
GTK_WIDGET_SET_FLAGS(mWidget, GTK_CAN_FOCUS);
gtk_widget_set_app_paintable(mWidget, PR_TRUE);
@ -337,12 +342,22 @@ void * nsWindow::GetNativeData(PRUint32 aDataType)
// The GTK layout widget uses a clip window to do scrolling.
// All the action happens on that window - called the 'bin_window'
if (mWidget)
{
#ifndef USE_GTK_FIXED
return (void *) GTK_LAYOUT(mWidget)->bin_window;
#else
return (void *) mWidget->window;
#endif
}
}
return nsWidget::GetNativeData(aDataType);
}
#ifdef DEBUG_pavlov
#define OH_I_LOVE_SCROLLING_SMOOTHLY
#endif
//-------------------------------------------------------------------------
//
// Scroll the bits of a window
@ -350,6 +365,82 @@ void * nsWindow::GetNativeData(PRUint32 aDataType)
//-------------------------------------------------------------------------
NS_IMETHODIMP nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
{
#ifdef OH_I_LOVE_SCROLLING_SMOOTHLY
// copy our off screen pixmap onto the window.
GdkWindow *window = nsnull;
GdkGC *gc = nsnull;
#ifndef USE_GTK_FIXED
window = GTK_LAYOUT(mWidget)->bin_window;
#else
window = mWidget->window;
#endif
gc = gdk_gc_new(window);
printf("nsWindow::Scroll(%i, %i\n", aDx, aDy);
if (aDx > 0) { /* moving left */
if (abs(aDx) < mBounds.width) { /* only copy if we arn't moving further than our width */
gdk_window_copy_area(window, gc,
aDx, aDy, // source coords
window, // source window
0, 0, // dest coords
mBounds.width - aDx, // width
mBounds.height - aDy); // height
nsRect rect(0, 0, aDx, mBounds.height);
Invalidate(rect, PR_TRUE);
} else {
Invalidate(PR_TRUE); /* redraw the widget if we are jumping more than our width */
}
} else if (aDx < 0) { /* moving right */
if (abs(aDx) < mBounds.width) { /* only copy if we arn't moving further than our width */
gdk_window_copy_area(window, gc,
0, 0, // source coords
window, // source window
-aDx, -aDy, // dest coords
mBounds.width + aDx, // width
mBounds.height + aDy); // height
nsRect rect(mBounds.width + aDx, 0, -aDx, mBounds.height);
Invalidate(rect, PR_TRUE);
} else {
Invalidate(PR_TRUE); /* redraw the widget if we are jumping more than our width */
}
}
if (aDy > 0) { /* moving up */
if (abs(aDy) < mBounds.height) { /* only copy if we arn't moving further than our height */
gdk_window_copy_area(window, gc,
aDx, aDy, // source coords
window, // source window
0, 0, // dest coords
mBounds.width - aDx, // width
mBounds.height - aDy); // height
nsRect rect(0, 0, mBounds.width, aDy);
Invalidate(rect, PR_TRUE);
} else {
Invalidate(PR_TRUE); /* redraw the widget if we are jumping more than our height */
}
} else if (aDy < 0) { /* moving down */
if (abs(aDy) < mBounds.height) { /* only copy if we arn't moving further than our height */
gdk_window_copy_area(window, gc,
0, 0, // source coords
window, // source window
-aDx, -aDy, // dest coords
mBounds.width + aDx, // width
mBounds.height + aDy); // height
nsRect rect(0, mBounds.height + aDy, mBounds.width, -aDy);
Invalidate(rect, PR_TRUE);
} else {
Invalidate(PR_TRUE); /* redraw the widget if we are jumping more than our height */
}
}
gdk_gc_destroy(gc);
#else
#ifndef USE_GTK_FIXED
if (GTK_IS_LAYOUT(mWidget)) {
GtkAdjustment* horiz = gtk_layout_get_hadjustment(GTK_LAYOUT(mWidget));
GtkAdjustment* vert = gtk_layout_get_vadjustment(GTK_LAYOUT(mWidget));
@ -358,10 +449,103 @@ NS_IMETHODIMP nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
gtk_adjustment_value_changed(horiz);
gtk_adjustment_value_changed(vert);
}
#else
printf("uhh, you don't use good scrolling and you arn't using gtklayouts.. no srcolling for you.\n");
#endif
#endif
return NS_OK;
}
NS_IMETHODIMP nsWindow::ScrollRect(nsRect &aSrcRect, PRInt32 aDx, PRInt32 aDy)
{
#ifdef OH_I_LOVE_SCROLLING_SMOOTHLY
// copy our off screen pixmap onto the window.
GdkWindow *window = nsnull;
GdkGC *gc = nsnull;
#ifndef USE_GTK_FIXED
window = GTK_LAYOUT(mWidget)->bin_window;
#else
window = mWidget->window;
#endif
gc = gdk_gc_new(window);
printf("nsWindow::Scroll(%i, %i\n", aDx, aDy);
if (aDx > 0) { /* moving left */
if (abs(aDx) < aSrcRect.width) { /* only copy if we arn't moving further than our width */
gdk_window_copy_area(window, gc,
aDx, aDy, // source coords
window, // source window
aSrcRect.x, aSrcRect.y, // dest coords
aSrcRect.width - aDx, // width
aSrcRect.height - aDy); // height
nsRect rect(0, 0, aDx, aSrcRect.height);
Invalidate(rect, PR_TRUE);
} else {
Invalidate(aSrcRect, PR_TRUE); /* redraw the area of the widget if we are jumping more than our width */
}
} else if (aDx < 0) { /* moving right */
if (abs(aDx) < aSrcRect.width) { /* only copy if we arn't moving further than our width */
gdk_window_copy_area(window, gc,
aSrcRect.x, aSrcRect.y, // source coords
window, // source window
-aDx, -aDy, // dest coords
aSrcRect.width + aDx, // width
aSrcRect.height + aDy); // height
nsRect rect(aSrcRect.width + aDx, 0, -aDx, aSrcRect.height);
Invalidate(rect, PR_TRUE);
} else {
Invalidate(aSrcRect, PR_TRUE); /* redraw the area of the widget if we are jumping more than our width */
}
}
if (aDy > 0) { /* moving up */
if (abs(aDy) < aSrcRect.height) { /* only copy if we arn't moving further than our height */
gdk_window_copy_area(window, gc,
aDx, aDy, // source coords
window, // source window
aSrcRect.x, aSrcRect.y, // dest coords
aSrcRect.width - aDx, // width
aSrcRect.height - aDy); // height
nsRect rect(0, 0, aSrcRect.width, aDy);
Invalidate(rect, PR_TRUE);
} else {
Invalidate(aSrcRect, PR_TRUE); /* redraw the area of the widget if we are jumping more than our height */
}
} else if (aDy < 0) { /* moving down */
if (abs(aDy) < aSrcRect.height) { /* only copy if we arn't moving further than our height */
gdk_window_copy_area(window, gc,
aSrcRect.x, aSrcRect.y, // source coords
window, // source window
-aDx, -aDy, // dest coords
aSrcRect.width + aDx, // width
aSrcRect.height + aDy); // height
nsRect rect(0, aSrcRect.height + aDy, aSrcRect.width, -aDy);
Invalidate(rect, PR_TRUE);
} else {
Invalidate(aSrcRect, PR_TRUE); /* redraw the area of the widget if we are jumping more than our height */
}
}
gdk_gc_destroy(gc);
#else
printf("uhh, you don't use good scrolling and you want to scroll a rect? too bad.\n");
#endif
return NS_OK;
}
NS_IMETHODIMP nsWindow::SetTitle(const nsString& aTitle)
{
if (!mShell)
@ -372,7 +556,6 @@ NS_IMETHODIMP nsWindow::SetTitle(const nsString& aTitle)
return NS_OK;
}
// Just give the window a default icon, Mozilla.
#include "mozicon50.xpm"
nsresult nsWindow::SetIcon()
@ -751,6 +934,7 @@ NS_IMETHODIMP nsWindow::Move(PRInt32 aX, PRInt32 aY)
}
else if (mWidget)
{
#ifndef USE_GTK_FIXED
GtkWidget * layout = mWidget->parent;
GtkAdjustment* ha = gtk_layout_get_hadjustment(GTK_LAYOUT(layout));
@ -764,6 +948,10 @@ NS_IMETHODIMP nsWindow::Move(PRInt32 aX, PRInt32 aY)
mWidget,
aX + x_correction,
aY + y_correction);
#else
gtk_fixed_move(GTK_FIXED(mWidget->parent), mWidget, aX, aY);
#endif
}
return NS_OK;

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

@ -49,6 +49,7 @@ public:
virtual void* GetNativeData(PRUint32 aDataType);
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect);
NS_IMETHOD ScrollRect(nsRect &aSrcRect, PRInt32 aDx, PRInt32 aDy);
NS_IMETHOD SetTitle(const nsString& aTitle);
NS_IMETHOD Show(PRBool aShow);

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

@ -675,6 +675,11 @@ NS_METHOD nsBaseWidget::Paint(nsIRenderingContext& aRenderingContext,
return NS_OK;
}
NS_IMETHODIMP nsBaseWidget::ScrollRect(nsRect &aRect, PRInt32 aDx, PRInt32 aDy)
{
return NS_ERROR_FAILURE;
}
#ifdef LOSER
NS_METHOD nsBaseWidget::SetVerticalScrollbar(nsIWidget * aWidget)
{

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

@ -87,6 +87,7 @@ public:
NS_IMETHOD GetClientBounds(nsRect &aRect);
NS_IMETHOD GetBorderSize(PRInt32 &aWidth, PRInt32 &aHeight);
NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect);
NS_IMETHOD ScrollRect(nsRect &aRect, PRInt32 aDx, PRInt32 aDy);
#ifdef LOSER
NS_IMETHOD SetVerticalScrollbar(nsIWidget * aScrollbar);
#endif