work to get drawing done based on regions and not rects. remove unneeded code in nsBaseWidget and removed tabs. add InvalidateRegion() method to nsIWidget. did InvalidateRegion implimentation on unix. a=shaver r=beard
git-svn-id: svn://10.0.0.236/trunk@49180 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
b5bbc1919b
commit
a27e5441c4
@ -23,6 +23,7 @@
|
||||
#include "nsRect.h"
|
||||
|
||||
class nsIRenderingContext;
|
||||
class nsIRegion;
|
||||
class nsIWidget;
|
||||
class nsIMenuItem;
|
||||
|
||||
@ -89,6 +90,8 @@ struct nsSizeEvent : public nsGUIEvent {
|
||||
struct nsPaintEvent : public nsGUIEvent {
|
||||
/// Context to paint in.
|
||||
nsIRenderingContext *renderingContext;
|
||||
/// area to paint (should be used instead of rect)
|
||||
nsIRegion *region;
|
||||
/// x,y, width, height in pixels of area to paint
|
||||
nsRect *rect;
|
||||
};
|
||||
|
||||
@ -477,6 +477,15 @@ class nsIWidget : public nsISupports {
|
||||
|
||||
NS_IMETHOD Invalidate(const nsRect & aRect, PRBool aIsSynchronous) = 0;
|
||||
|
||||
/**
|
||||
* Invalidate a specified region for a widget and repaints it.
|
||||
*
|
||||
* @param aIsSynchronouse PR_TRUE then repaint synchronously. If PR_FALSE repaint later.
|
||||
* @see #Update()
|
||||
*/
|
||||
|
||||
NS_IMETHOD InvalidateRegion(const nsIRegion* aRegion, PRBool aIsSynchronous) = 0;
|
||||
|
||||
/**
|
||||
* Force a synchronous repaint of the window if there are dirty rects.
|
||||
*
|
||||
@ -643,12 +652,14 @@ class nsIWidget : public nsISupports {
|
||||
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus) = 0;
|
||||
|
||||
|
||||
#ifdef LOSER
|
||||
/**
|
||||
* FSets the vertical scrollbar widget
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetVerticalScrollbar(nsIWidget * aScrollbar) = 0;
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* For printing and lightweight widgets
|
||||
*
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIScriptableRegion.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsRect.h"
|
||||
@ -466,6 +467,14 @@ interface nsIWidget : nsISupports
|
||||
*/
|
||||
void InvalidateRect([const] in nsRect aRect, in PRBool aIsSynchronous);
|
||||
|
||||
/**
|
||||
* Invalidate a specified rect for a widget and repaints it.
|
||||
*
|
||||
* @param aIsSynchronouse PR_TRUE then repaint synchronously. If PR_FALSE repaint later.
|
||||
* @see #Update()
|
||||
*/
|
||||
void InvalidateRect([const] in nsIScriptableRegion aRegion, in PRBool aIsSynchronous);
|
||||
|
||||
/**
|
||||
* Force a synchronous repaint of the window if there are dirty rects.
|
||||
*
|
||||
|
||||
@ -212,7 +212,7 @@ nsGtkUtils::gdk_window_flash(GdkWindow * aGdkWindow,
|
||||
|
||||
XSync(display, False);
|
||||
|
||||
usleep(aInterval);
|
||||
usleep(aInterval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -753,6 +753,41 @@ NS_IMETHODIMP nsWidget::Invalidate(const nsRect & aRect, PRBool aIsSynchronous)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsWidget::InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous)
|
||||
{
|
||||
nsRegionRectSet *regionRectSet = nsnull;
|
||||
|
||||
mUpdateArea->Union(*aRegion);
|
||||
|
||||
if (NS_FAILED(mUpdateArea->GetRects(®ionRectSet)))
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mUpdateArea->Union(*aRegion);
|
||||
|
||||
PRUint32 len;
|
||||
PRUint32 i;
|
||||
|
||||
len = regionRectSet->mRectsLen;
|
||||
|
||||
for (i=0;i<len;++i)
|
||||
{
|
||||
nsRegionRect *r = &(regionRectSet->mRects[i]);
|
||||
|
||||
gtk_widget_queue_draw_area(mWidget,
|
||||
r->x, r->y,
|
||||
r->width, r->height);
|
||||
}
|
||||
|
||||
// drop the const.. whats the right thing to do here?
|
||||
((nsIRegion*)aRegion)->FreeRects(regionRectSet);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsWidget::Update(void)
|
||||
{
|
||||
if (!mWidget)
|
||||
@ -846,6 +881,12 @@ NS_IMETHODIMP nsWidget::SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWidget::SetTitle(const nsString &aTitle)
|
||||
{
|
||||
gtk_widget_set_name(mWidget, "foo");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsWidget::CreateWidget(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
|
||||
@ -120,6 +120,10 @@ public:
|
||||
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight);
|
||||
NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight);
|
||||
|
||||
// Use this to set the name of a widget for normal widgets.. not the same as the nsWindow version
|
||||
NS_IMETHOD SetTitle(const nsString& aTitle);
|
||||
|
||||
|
||||
virtual void ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY);
|
||||
|
||||
// the following are nsWindow specific, and just stubbed here
|
||||
@ -132,6 +136,7 @@ public:
|
||||
|
||||
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
|
||||
NS_IMETHOD Invalidate(const nsRect &aRect, PRBool aIsSynchronous);
|
||||
NS_IMETHOD InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous);
|
||||
NS_IMETHOD Update(void);
|
||||
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
|
||||
|
||||
|
||||
@ -426,6 +426,10 @@ PRBool nsWindow::OnExpose(nsPaintEvent &event)
|
||||
mUpdateArea->Union(event.rect->x, event.rect->y, event.rect->width, event.rect->height);
|
||||
|
||||
|
||||
// NS_ADDREF(mUpdateArea);
|
||||
// event.region = mUpdateArea;
|
||||
|
||||
|
||||
// printf("\n\n");
|
||||
PRInt32 x, y, w, h;
|
||||
mUpdateArea->GetBoundingBox(&x,&y,&w,&h);
|
||||
@ -453,6 +457,7 @@ PRBool nsWindow::OnExpose(nsPaintEvent &event)
|
||||
|
||||
result = DispatchWindowEvent(&event);
|
||||
NS_RELEASE(event.renderingContext);
|
||||
// NS_RELEASE(mUpdateArea);
|
||||
}
|
||||
|
||||
|
||||
@ -509,6 +514,9 @@ PRBool nsWindow::OnDraw(nsPaintEvent &event)
|
||||
#endif // NS_DEBUG
|
||||
|
||||
|
||||
// NS_ADDREF(mUpdateArea);
|
||||
// event.region = mUpdateArea;
|
||||
|
||||
// printf("\n\n");
|
||||
PRInt32 x, y, w, h;
|
||||
mUpdateArea->GetBoundingBox(&x,&y,&w,&h);
|
||||
@ -536,6 +544,7 @@ PRBool nsWindow::OnDraw(nsPaintEvent &event)
|
||||
|
||||
result = DispatchWindowEvent(&event);
|
||||
NS_RELEASE(event.renderingContext);
|
||||
// NS_RELEASE(mUpdateArea);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -114,7 +114,9 @@ nsWindow::nsWindow() : nsBaseWidget()
|
||||
|
||||
mHitMenu = nsnull;
|
||||
mHitSubMenus = new nsVoidArray();
|
||||
#ifdef LOSER
|
||||
mVScrollbar = nsnull;
|
||||
#endif
|
||||
mIsInMouseCapture = PR_FALSE;
|
||||
|
||||
mIMEProperty = 0;
|
||||
@ -2590,7 +2592,9 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
||||
case WM_SETTINGCHANGE:
|
||||
firstTime = TRUE;
|
||||
// Fall through
|
||||
case WM_MOUSEWHEEL: {
|
||||
case WM_MOUSEWHEEL:
|
||||
#ifdef LOSER
|
||||
{
|
||||
if (firstTime) {
|
||||
firstTime = FALSE;
|
||||
//printf("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ WM_SETTINGCHANGE\n");
|
||||
@ -2611,6 +2615,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
||||
}
|
||||
}
|
||||
HWND scrollbar = NULL;
|
||||
|
||||
if (nsnull != mVScrollbar) {
|
||||
scrollbar = (HWND)mVScrollbar->GetNativeData(NS_NATIVE_WINDOW);
|
||||
}
|
||||
@ -2634,7 +2639,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
||||
}
|
||||
return 0 ;
|
||||
} break;
|
||||
|
||||
#endif
|
||||
|
||||
case WM_PALETTECHANGED:
|
||||
if ((HWND)wParam == mWnd) {
|
||||
|
||||
@ -60,7 +60,9 @@ nsBaseWidget::nsBaseWidget()
|
||||
, mIsDestroying(PR_FALSE)
|
||||
, mOnDestroyCalled(PR_FALSE)
|
||||
, mBounds(0,0,0,0)
|
||||
#ifdef LOSER
|
||||
, mVScrollbar(nsnull)
|
||||
#endif
|
||||
, mZIndex(0)
|
||||
{
|
||||
NS_NewISupportsArray(getter_AddRefs(mChildren));
|
||||
@ -77,7 +79,9 @@ nsBaseWidget::nsBaseWidget()
|
||||
nsBaseWidget::~nsBaseWidget()
|
||||
{
|
||||
NS_IF_RELEASE(mMenuListener);
|
||||
#ifdef LOSER
|
||||
NS_IF_RELEASE(mVScrollbar);
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@ -86,67 +90,69 @@ nsBaseWidget::~nsBaseWidget()
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
void nsBaseWidget::BaseCreate(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData)
|
||||
{
|
||||
if (nsnull == mToolkit) {
|
||||
if (nsnull != aToolkit) {
|
||||
mToolkit = (nsIToolkit*)aToolkit;
|
||||
NS_ADDREF(mToolkit);
|
||||
}
|
||||
else {
|
||||
if (nsnull != aParent) {
|
||||
mToolkit = (nsIToolkit*)(aParent->GetToolkit()); // the call AddRef's, we don't have to
|
||||
}
|
||||
// it's some top level window with no toolkit passed in.
|
||||
// Create a default toolkit with the current thread
|
||||
else {
|
||||
static NS_DEFINE_CID(kToolkitCID, NS_TOOLKIT_CID);
|
||||
|
||||
nsresult res;
|
||||
res = nsComponentManager::CreateInstance(kToolkitCID, nsnull, NS_GET_IID(nsIToolkit), (void **)&mToolkit);
|
||||
if (NS_OK != res)
|
||||
NS_ASSERTION(PR_FALSE, "Can not create a toolkit in nsBaseWidget::Create");
|
||||
if (mToolkit)
|
||||
mToolkit->Init(PR_GetCurrentThread());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mAppShell = aAppShell;
|
||||
NS_IF_ADDREF(mAppShell);
|
||||
|
||||
// save the event callback function
|
||||
mEventCallback = aHandleEventFunction;
|
||||
|
||||
// keep a reference to the device context
|
||||
if (aContext) {
|
||||
mContext = aContext;
|
||||
NS_ADDREF(mContext);
|
||||
if (nsnull == mToolkit) {
|
||||
if (nsnull != aToolkit) {
|
||||
mToolkit = (nsIToolkit*)aToolkit;
|
||||
NS_ADDREF(mToolkit);
|
||||
}
|
||||
else {
|
||||
nsresult res;
|
||||
|
||||
static NS_DEFINE_CID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
||||
|
||||
res = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull, NS_GET_IID(nsIDeviceContext), (void **)&mContext);
|
||||
|
||||
if (NS_OK == res)
|
||||
mContext->Init(nsnull);
|
||||
if (nsnull != aParent) {
|
||||
mToolkit = (nsIToolkit*)(aParent->GetToolkit()); // the call AddRef's, we don't have to
|
||||
}
|
||||
// it's some top level window with no toolkit passed in.
|
||||
// Create a default toolkit with the current thread
|
||||
else {
|
||||
static NS_DEFINE_CID(kToolkitCID, NS_TOOLKIT_CID);
|
||||
|
||||
nsresult res;
|
||||
res = nsComponentManager::CreateInstance(kToolkitCID, nsnull,
|
||||
NS_GET_IID(nsIToolkit), (void **)&mToolkit);
|
||||
if (NS_OK != res)
|
||||
NS_ASSERTION(PR_FALSE, "Can not create a toolkit in nsBaseWidget::Create");
|
||||
if (mToolkit)
|
||||
mToolkit->Init(PR_GetCurrentThread());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mAppShell = aAppShell;
|
||||
NS_IF_ADDREF(mAppShell);
|
||||
|
||||
// save the event callback function
|
||||
mEventCallback = aHandleEventFunction;
|
||||
|
||||
// keep a reference to the device context
|
||||
if (aContext) {
|
||||
mContext = aContext;
|
||||
NS_ADDREF(mContext);
|
||||
}
|
||||
else {
|
||||
nsresult res;
|
||||
|
||||
static NS_DEFINE_CID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
||||
|
||||
res = nsComponentManager::CreateInstance(kDeviceContextCID, nsnull,
|
||||
NS_GET_IID(nsIDeviceContext), (void **)&mContext);
|
||||
|
||||
if (nsnull != aInitData) {
|
||||
PreCreateWidget(aInitData);
|
||||
}
|
||||
if (NS_OK == res)
|
||||
mContext->Init(nsnull);
|
||||
}
|
||||
|
||||
if (aParent) {
|
||||
aParent->AddChild(this);
|
||||
}
|
||||
if (nsnull != aInitData) {
|
||||
PreCreateWidget(aInitData);
|
||||
}
|
||||
|
||||
if (aParent) {
|
||||
aParent->AddChild(this);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBaseWidget::CaptureMouse(PRBool aCapture)
|
||||
@ -154,6 +160,11 @@ NS_IMETHODIMP nsBaseWidget::CaptureMouse(PRBool aCapture)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBaseWidget::InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Accessor functions to get/set the client data
|
||||
@ -185,9 +196,9 @@ NS_METHOD nsBaseWidget::Destroy()
|
||||
parent->RemoveChild(this);
|
||||
NS_RELEASE(parent);
|
||||
}
|
||||
|
||||
#ifdef LOSER
|
||||
NS_IF_RELEASE(mVScrollbar);
|
||||
|
||||
#endif
|
||||
// disconnect listeners.
|
||||
NS_IF_RELEASE(mMouseListener);
|
||||
NS_IF_RELEASE(mEventListener);
|
||||
@ -303,7 +314,7 @@ NS_IMETHODIMP nsBaseWidget::GetZIndex(PRInt32* aZIndex)
|
||||
//-------------------------------------------------------------------------
|
||||
nscolor nsBaseWidget::GetForegroundColor(void)
|
||||
{
|
||||
return mForeground;
|
||||
return mForeground;
|
||||
}
|
||||
|
||||
|
||||
@ -314,8 +325,8 @@ nscolor nsBaseWidget::GetForegroundColor(void)
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsBaseWidget::SetForegroundColor(const nscolor &aColor)
|
||||
{
|
||||
mForeground = aColor;
|
||||
return NS_OK;
|
||||
mForeground = aColor;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -326,7 +337,7 @@ NS_METHOD nsBaseWidget::SetForegroundColor(const nscolor &aColor)
|
||||
//-------------------------------------------------------------------------
|
||||
nscolor nsBaseWidget::GetBackgroundColor(void)
|
||||
{
|
||||
return mBackground;
|
||||
return mBackground;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@ -336,8 +347,8 @@ nscolor nsBaseWidget::GetBackgroundColor(void)
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsBaseWidget::SetBackgroundColor(const nscolor &aColor)
|
||||
{
|
||||
mBackground = aColor;
|
||||
return NS_OK;
|
||||
mBackground = aColor;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@ -347,7 +358,7 @@ NS_METHOD nsBaseWidget::SetBackgroundColor(const nscolor &aColor)
|
||||
//-------------------------------------------------------------------------
|
||||
nsCursor nsBaseWidget::GetCursor()
|
||||
{
|
||||
return mCursor;
|
||||
return mCursor;
|
||||
}
|
||||
|
||||
NS_METHOD nsBaseWidget::SetCursor(nsCursor aCursor)
|
||||
@ -411,8 +422,8 @@ nsIDeviceContext* nsBaseWidget::GetDeviceContext()
|
||||
|
||||
nsIAppShell *nsBaseWidget::GetAppShell()
|
||||
{
|
||||
NS_IF_ADDREF(mAppShell);
|
||||
return mAppShell;
|
||||
NS_IF_ADDREF(mAppShell);
|
||||
return mAppShell;
|
||||
}
|
||||
|
||||
|
||||
@ -423,131 +434,10 @@ nsIAppShell *nsBaseWidget::GetAppShell()
|
||||
//-------------------------------------------------------------------------
|
||||
void nsBaseWidget::OnDestroy()
|
||||
{
|
||||
// release references to device context, toolkit, and app shell
|
||||
NS_IF_RELEASE(mContext);
|
||||
NS_IF_RELEASE(mToolkit);
|
||||
NS_IF_RELEASE(mAppShell);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
nsBaseWidget::Enumerator::Enumerator(nsBaseWidget & inParent)
|
||||
: mCurrentPosition(0), mParent(inParent)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsBaseWidget::Enumerator::~Enumerator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//enumerator interfaces
|
||||
NS_IMETHODIMP
|
||||
nsBaseWidget::Enumerator::Next()
|
||||
{
|
||||
PRUint32 itemCount = 0;
|
||||
mParent.mChildren->Count(&itemCount);
|
||||
if (mCurrentPosition < itemCount - 1 )
|
||||
mCurrentPosition ++;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseWidget::Enumerator::Prev()
|
||||
{
|
||||
if (mCurrentPosition > 0 )
|
||||
mCurrentPosition --;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseWidget::Enumerator::CurrentItem(nsISupports **aItem)
|
||||
{
|
||||
if (!aItem)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
PRUint32 itemCount = 0;
|
||||
mParent.mChildren->Count(&itemCount);
|
||||
if ( mCurrentPosition < itemCount ) {
|
||||
nsISupports* widget = mParent.mChildren->ElementAt(mCurrentPosition);
|
||||
// NS_IF_ADDREF(widget); already addref'd in nsSupportsArray::ElementAt()
|
||||
*aItem = widget;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseWidget::Enumerator::First()
|
||||
{
|
||||
PRUint32 itemCount = 0;
|
||||
mParent.mChildren->Count(&itemCount);
|
||||
if ( itemCount ) {
|
||||
mCurrentPosition = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseWidget::Enumerator::Last()
|
||||
{
|
||||
PRUint32 itemCount = 0;
|
||||
mParent.mChildren->Count(&itemCount);
|
||||
if ( itemCount ) {
|
||||
mCurrentPosition = itemCount - 1;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseWidget::Enumerator::IsDone()
|
||||
{
|
||||
PRUint32 itemCount = 0;
|
||||
mParent.mChildren->Count(&itemCount);
|
||||
|
||||
if ((mCurrentPosition == itemCount-1) || (itemCount == 0) ){ //empty lists always return done
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
return NS_COMFALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
// release references to device context, toolkit, and app shell
|
||||
NS_IF_RELEASE(mContext);
|
||||
NS_IF_RELEASE(mToolkit);
|
||||
NS_IF_RELEASE(mAppShell);
|
||||
}
|
||||
|
||||
|
||||
@ -565,11 +455,6 @@ NS_METHOD nsBaseWidget::SetBorderStyle(nsBorderStyle aBorderStyle)
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD nsBaseWidget::SetTitle(const nsString& aTitle)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a mouse pressed event
|
||||
*
|
||||
@ -658,7 +543,7 @@ NS_METHOD nsBaseWidget::SetBounds(const nsRect &aRect)
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -765,6 +650,7 @@ NS_METHOD nsBaseWidget::Paint(nsIRenderingContext& aRenderingContext,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef LOSER
|
||||
NS_METHOD nsBaseWidget::SetVerticalScrollbar(nsIWidget * aWidget)
|
||||
{
|
||||
NS_IF_RELEASE(mVScrollbar);
|
||||
@ -772,6 +658,7 @@ NS_METHOD nsBaseWidget::SetVerticalScrollbar(nsIWidget * aWidget)
|
||||
NS_IF_ADDREF(mVScrollbar);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_METHOD nsBaseWidget::EnableDragDrop(PRBool aEnable)
|
||||
{
|
||||
@ -783,12 +670,6 @@ NS_METHOD nsBaseWidget::SetModal(void)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsBaseWidget::CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -1079,3 +960,143 @@ nsBaseWidget::debug_CleanupCrapSoThatBruceAndPurifyAreHappy()
|
||||
|
||||
#endif // NS_DEBUG
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
nsBaseWidget::Enumerator::Enumerator(nsBaseWidget & inParent)
|
||||
: mCurrentPosition(0), mParent(inParent)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsBaseWidget::Enumerator::~Enumerator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//enumerator interfaces
|
||||
NS_IMETHODIMP
|
||||
nsBaseWidget::Enumerator::Next()
|
||||
{
|
||||
PRUint32 itemCount = 0;
|
||||
mParent.mChildren->Count(&itemCount);
|
||||
if (mCurrentPosition < itemCount - 1 )
|
||||
mCurrentPosition ++;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseWidget::Enumerator::Prev()
|
||||
{
|
||||
if (mCurrentPosition > 0 )
|
||||
mCurrentPosition --;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseWidget::Enumerator::CurrentItem(nsISupports **aItem)
|
||||
{
|
||||
if (!aItem)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
PRUint32 itemCount = 0;
|
||||
mParent.mChildren->Count(&itemCount);
|
||||
if ( mCurrentPosition < itemCount ) {
|
||||
nsISupports* widget = mParent.mChildren->ElementAt(mCurrentPosition);
|
||||
// NS_IF_ADDREF(widget); already addref'd in nsSupportsArray::ElementAt()
|
||||
*aItem = widget;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseWidget::Enumerator::First()
|
||||
{
|
||||
PRUint32 itemCount = 0;
|
||||
mParent.mChildren->Count(&itemCount);
|
||||
if ( itemCount ) {
|
||||
mCurrentPosition = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseWidget::Enumerator::Last()
|
||||
{
|
||||
PRUint32 itemCount = 0;
|
||||
mParent.mChildren->Count(&itemCount);
|
||||
if ( itemCount ) {
|
||||
mCurrentPosition = itemCount - 1;
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseWidget::Enumerator::IsDone()
|
||||
{
|
||||
PRUint32 itemCount = 0;
|
||||
mParent.mChildren->Count(&itemCount);
|
||||
|
||||
if ((mCurrentPosition == itemCount-1) || (itemCount == 0) ){ //empty lists always return done
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
return NS_COMFALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -44,127 +44,129 @@ class nsBaseWidget : public nsIWidget
|
||||
{
|
||||
|
||||
public:
|
||||
nsBaseWidget();
|
||||
virtual ~nsBaseWidget();
|
||||
nsBaseWidget();
|
||||
virtual ~nsBaseWidget();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aWidgetInitData) { return NS_OK;}
|
||||
|
||||
// nsIWidget interface
|
||||
NS_IMETHOD CaptureMouse(PRBool aCapture);
|
||||
NS_IMETHOD InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous);
|
||||
NS_IMETHOD GetClientData(void*& aClientData);
|
||||
NS_IMETHOD SetClientData(void* aClientData);
|
||||
NS_IMETHOD Destroy();
|
||||
virtual nsIWidget* GetParent(void);
|
||||
virtual nsIEnumerator* GetChildren();
|
||||
virtual void AddChild(nsIWidget* aChild);
|
||||
virtual void RemoveChild(nsIWidget* aChild);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_IMETHOD SetZIndex(PRInt32 aZIndex);
|
||||
NS_IMETHOD GetZIndex(PRInt32* aZIndex);
|
||||
|
||||
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aWidgetInitData) { return NS_OK;}
|
||||
|
||||
// nsIWidget interface
|
||||
NS_IMETHOD CaptureMouse(PRBool aCapture);
|
||||
NS_IMETHOD GetClientData(void*& aClientData);
|
||||
NS_IMETHOD SetClientData(void* aClientData);
|
||||
NS_IMETHOD Destroy();
|
||||
virtual nsIWidget* GetParent(void);
|
||||
virtual nsIEnumerator* GetChildren();
|
||||
virtual void AddChild(nsIWidget* aChild);
|
||||
virtual void RemoveChild(nsIWidget* aChild);
|
||||
|
||||
NS_IMETHOD SetZIndex(PRInt32 aZIndex);
|
||||
NS_IMETHOD GetZIndex(PRInt32* aZIndex);
|
||||
|
||||
virtual nscolor GetForegroundColor(void);
|
||||
NS_IMETHOD SetForegroundColor(const nscolor &aColor);
|
||||
virtual nscolor GetBackgroundColor(void);
|
||||
NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
|
||||
virtual nsCursor GetCursor();
|
||||
NS_IMETHOD SetCursor(nsCursor aCursor);
|
||||
virtual nsIRenderingContext* GetRenderingContext();
|
||||
virtual nsIDeviceContext* GetDeviceContext();
|
||||
virtual nsIAppShell * GetAppShell();
|
||||
virtual nsIToolkit* GetToolkit();
|
||||
NS_IMETHOD SetModal(void);
|
||||
NS_IMETHOD SetWindowType(nsWindowType aWindowType);
|
||||
NS_IMETHOD SetBorderStyle(nsBorderStyle aBorderStyle);
|
||||
NS_IMETHOD SetTitle(const nsString& aTitle);
|
||||
NS_IMETHOD AddMouseListener(nsIMouseListener * aListener);
|
||||
NS_IMETHOD AddEventListener(nsIEventListener * aListener);
|
||||
NS_IMETHOD AddMenuListener(nsIMenuListener * aListener);
|
||||
NS_IMETHOD SetBounds(const nsRect &aRect);
|
||||
NS_IMETHOD GetBounds(nsRect &aRect);
|
||||
NS_IMETHOD GetBoundsAppUnits(nsRect &aRect, float aAppUnits);
|
||||
NS_IMETHOD GetClientBounds(nsRect &aRect);
|
||||
NS_IMETHOD GetBorderSize(PRInt32 &aWidth, PRInt32 &aHeight);
|
||||
NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect);
|
||||
NS_IMETHOD SetVerticalScrollbar(nsIWidget * aScrollbar);
|
||||
NS_IMETHOD EnableDragDrop(PRBool aEnable);
|
||||
virtual void ConvertToDeviceCoordinates(nscoord &aX,nscoord &aY) {}
|
||||
virtual void FreeNativeData(void * data, PRUint32 aDataType) {}//~~~
|
||||
|
||||
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture);
|
||||
virtual nscolor GetForegroundColor(void);
|
||||
NS_IMETHOD SetForegroundColor(const nscolor &aColor);
|
||||
virtual nscolor GetBackgroundColor(void);
|
||||
NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
|
||||
virtual nsCursor GetCursor();
|
||||
NS_IMETHOD SetCursor(nsCursor aCursor);
|
||||
virtual nsIRenderingContext* GetRenderingContext();
|
||||
virtual nsIDeviceContext* GetDeviceContext();
|
||||
virtual nsIAppShell * GetAppShell();
|
||||
virtual nsIToolkit* GetToolkit();
|
||||
NS_IMETHOD SetModal(void);
|
||||
NS_IMETHOD SetWindowType(nsWindowType aWindowType);
|
||||
NS_IMETHOD SetBorderStyle(nsBorderStyle aBorderStyle);
|
||||
NS_IMETHOD AddMouseListener(nsIMouseListener * aListener);
|
||||
NS_IMETHOD AddEventListener(nsIEventListener * aListener);
|
||||
NS_IMETHOD AddMenuListener(nsIMenuListener * aListener);
|
||||
NS_IMETHOD SetBounds(const nsRect &aRect);
|
||||
NS_IMETHOD GetBounds(nsRect &aRect);
|
||||
NS_IMETHOD GetBoundsAppUnits(nsRect &aRect, float aAppUnits);
|
||||
NS_IMETHOD GetClientBounds(nsRect &aRect);
|
||||
NS_IMETHOD GetBorderSize(PRInt32 &aWidth, PRInt32 &aHeight);
|
||||
NS_IMETHOD Paint(nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect);
|
||||
#ifdef LOSER
|
||||
NS_IMETHOD SetVerticalScrollbar(nsIWidget * aScrollbar);
|
||||
#endif
|
||||
NS_IMETHOD EnableDragDrop(PRBool aEnable);
|
||||
virtual void ConvertToDeviceCoordinates(nscoord &aX,nscoord &aY) {}
|
||||
virtual void FreeNativeData(void * data, PRUint32 aDataType) {}//~~~
|
||||
|
||||
protected:
|
||||
|
||||
virtual void DrawScaledRect(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect & aRect,
|
||||
float aScale,
|
||||
float aAppUnits);
|
||||
virtual void DrawScaledLine(nsIRenderingContext& aRenderingContext,
|
||||
nscoord aSX, nscoord aSY, nscoord aEX, nscoord aEY,
|
||||
float aScale, float aAppUnits, PRBool aIsHorz);
|
||||
virtual void OnDestroy();
|
||||
virtual void BaseCreate(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData);
|
||||
virtual void DrawScaledRect(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect & aRect,
|
||||
float aScale,
|
||||
float aAppUnits);
|
||||
virtual void DrawScaledLine(nsIRenderingContext& aRenderingContext,
|
||||
nscoord aSX, nscoord aSY, nscoord aEX, nscoord aEY,
|
||||
float aScale, float aAppUnits, PRBool aIsHorz);
|
||||
virtual void OnDestroy();
|
||||
virtual void BaseCreate(nsIWidget *aParent,
|
||||
const nsRect &aRect,
|
||||
EVENT_CALLBACK aHandleEventFunction,
|
||||
nsIDeviceContext *aContext,
|
||||
nsIAppShell *aAppShell,
|
||||
nsIToolkit *aToolkit,
|
||||
nsWidgetInitData *aInitData);
|
||||
|
||||
protected:
|
||||
void* mClientData;
|
||||
EVENT_CALLBACK mEventCallback;
|
||||
nsIDeviceContext *mContext;
|
||||
nsIAppShell *mAppShell;
|
||||
nsIToolkit *mToolkit;
|
||||
nsIMouseListener *mMouseListener;
|
||||
nsIEventListener *mEventListener;
|
||||
nsIMenuListener *mMenuListener;
|
||||
nscolor mBackground;
|
||||
nscolor mForeground;
|
||||
nsCursor mCursor;
|
||||
nsWindowType mWindowType;
|
||||
nsBorderStyle mBorderStyle;
|
||||
PRBool mIsShiftDown;
|
||||
PRBool mIsControlDown;
|
||||
PRBool mIsAltDown;
|
||||
PRBool mIsDestroying;
|
||||
PRBool mOnDestroyCalled;
|
||||
nsRect mBounds;
|
||||
nsIWidget *mVScrollbar;
|
||||
PRInt32 mZIndex;
|
||||
void* mClientData;
|
||||
EVENT_CALLBACK mEventCallback;
|
||||
nsIDeviceContext *mContext;
|
||||
nsIAppShell *mAppShell;
|
||||
nsIToolkit *mToolkit;
|
||||
nsIMouseListener *mMouseListener;
|
||||
nsIEventListener *mEventListener;
|
||||
nsIMenuListener *mMenuListener;
|
||||
nscolor mBackground;
|
||||
nscolor mForeground;
|
||||
nsCursor mCursor;
|
||||
nsWindowType mWindowType;
|
||||
nsBorderStyle mBorderStyle;
|
||||
PRBool mIsShiftDown;
|
||||
PRBool mIsControlDown;
|
||||
PRBool mIsAltDown;
|
||||
PRBool mIsDestroying;
|
||||
PRBool mOnDestroyCalled;
|
||||
nsRect mBounds;
|
||||
#ifdef LOSER
|
||||
nsIWidget *mVScrollbar;
|
||||
#endif
|
||||
PRInt32 mZIndex;
|
||||
|
||||
// keep the list of children
|
||||
nsCOMPtr<nsISupportsArray> mChildren;
|
||||
nsCOMPtr<nsISupportsArray> mChildren;
|
||||
|
||||
class Enumerator : public nsIBidirectionalEnumerator {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
class Enumerator : public nsIBidirectionalEnumerator {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
Enumerator(nsBaseWidget & inParent);
|
||||
virtual ~Enumerator();
|
||||
Enumerator(nsBaseWidget & inParent);
|
||||
virtual ~Enumerator();
|
||||
|
||||
NS_DECL_NSIENUMERATOR
|
||||
NS_DECL_NSIBIDIRECTIONALENUMERATOR
|
||||
NS_DECL_NSIENUMERATOR
|
||||
NS_DECL_NSIBIDIRECTIONALENUMERATOR
|
||||
|
||||
private:
|
||||
PRUint32 mCurrentPosition;
|
||||
nsBaseWidget& mParent;
|
||||
};
|
||||
friend class Enumerator;
|
||||
private:
|
||||
PRUint32 mCurrentPosition;
|
||||
nsBaseWidget& mParent;
|
||||
};
|
||||
friend class Enumerator;
|
||||
|
||||
// Enumeration of the methods which are accessable on the "main GUI thread"
|
||||
// via the CallMethod(...) mechanism...
|
||||
// see nsSwitchToUIThread
|
||||
enum {
|
||||
CREATE = 0x0101,
|
||||
CREATE_NATIVE,
|
||||
DESTROY,
|
||||
SET_FOCUS,
|
||||
SET_CURSOR,
|
||||
CREATE_HACK
|
||||
};
|
||||
enum {
|
||||
CREATE = 0x0101,
|
||||
CREATE_NATIVE,
|
||||
DESTROY,
|
||||
SET_FOCUS,
|
||||
SET_CURSOR,
|
||||
CREATE_HACK
|
||||
};
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
protected:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user