1998-04-13 20:24:54 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsView_h___
|
|
|
|
#define nsView_h___
|
|
|
|
|
|
|
|
#include "nsViewManager.h"
|
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsIWidget.h"
|
|
|
|
#include "nsIFactory.h"
|
1998-08-28 03:05:23 +00:00
|
|
|
#include "nsIViewObserver.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
class nsIPresContext;
|
|
|
|
|
|
|
|
class nsView : public nsIView
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsView();
|
|
|
|
|
1998-08-08 04:23:33 +00:00
|
|
|
// Overloaded new operator. Initializes the memory to 0
|
1998-04-13 20:24:54 +00:00
|
|
|
void* operator new(size_t sz) {
|
|
|
|
void* rv = new char[sz];
|
|
|
|
nsCRT::zero(rv, sz);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-08-08 04:23:33 +00:00
|
|
|
// nsISupports
|
|
|
|
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-08-08 04:23:33 +00:00
|
|
|
// nsIView
|
1998-08-30 19:16:11 +00:00
|
|
|
NS_IMETHOD Init(nsIViewManager* aManager,
|
|
|
|
const nsRect &aBounds,
|
|
|
|
nsIView *aParent,
|
|
|
|
const nsCID *aWindowIID = nsnull,
|
|
|
|
nsWidgetInitData *aWidgetInitData = nsnull,
|
|
|
|
nsNativeWidget aNative = nsnull,
|
|
|
|
PRInt32 aZIndex = 0,
|
|
|
|
const nsViewClip *aClip = nsnull,
|
|
|
|
float aOpacity = 1.0f,
|
|
|
|
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
|
|
|
|
|
|
|
|
NS_IMETHOD Destroy();
|
|
|
|
NS_IMETHOD GetViewManager(nsIViewManager *&aViewMgr);
|
|
|
|
NS_IMETHOD GetWidget(nsIWidget *&aWidget);
|
|
|
|
NS_IMETHOD Paint(nsIRenderingContext& rc, const nsRect& rect,
|
|
|
|
PRUint32 aPaintFlags, nsIView *aBackstop, PRBool &aResult);
|
|
|
|
NS_IMETHOD Paint(nsIRenderingContext& rc, const nsIRegion& region,
|
|
|
|
PRUint32 aPaintFlags, PRBool &aResult);
|
|
|
|
NS_IMETHOD HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags, nsEventStatus &aStatus);
|
|
|
|
NS_IMETHOD SetPosition(nscoord x, nscoord y);
|
|
|
|
NS_IMETHOD GetPosition(nscoord *x, nscoord *y);
|
|
|
|
NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE);
|
|
|
|
NS_IMETHOD GetDimensions(nscoord *width, nscoord *height);
|
|
|
|
NS_IMETHOD SetBounds(const nsRect &aBounds, PRBool aPaint = PR_TRUE);
|
|
|
|
NS_IMETHOD SetBounds(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, PRBool aPaint = PR_TRUE);
|
|
|
|
NS_IMETHOD GetBounds(nsRect &aBounds) const;
|
|
|
|
NS_IMETHOD SetClip(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
|
|
|
|
NS_IMETHOD GetClip(nscoord *aLeft, nscoord *aTop, nscoord *aRight, nscoord *aBottom, PRBool &aResult);
|
|
|
|
NS_IMETHOD SetVisibility(nsViewVisibility visibility);
|
|
|
|
NS_IMETHOD GetVisibility(nsViewVisibility &aVisibility);
|
|
|
|
NS_IMETHOD SetZIndex(PRInt32 zindex);
|
|
|
|
NS_IMETHOD GetZIndex(PRInt32 &aZIndex);
|
|
|
|
NS_IMETHOD SetParent(nsIView *aParent);
|
|
|
|
NS_IMETHOD GetParent(nsIView *&aParent);
|
|
|
|
NS_IMETHOD GetNextSibling(nsIView *&aNextSibling) const;
|
|
|
|
NS_IMETHOD SetNextSibling(nsIView* aNextSibling);
|
|
|
|
NS_IMETHOD InsertChild(nsIView *child, nsIView *sibling);
|
|
|
|
NS_IMETHOD RemoveChild(nsIView *child);
|
|
|
|
NS_IMETHOD GetChildCount(PRInt32 &aCount);
|
|
|
|
NS_IMETHOD GetChild(PRInt32 index, nsIView*& aChild);
|
|
|
|
NS_IMETHOD SetTransform(nsTransform2D &aXForm);
|
|
|
|
NS_IMETHOD GetTransform(nsTransform2D &aXForm);
|
|
|
|
NS_IMETHOD SetOpacity(float opacity);
|
|
|
|
NS_IMETHOD GetOpacity(float &aOpacity);
|
|
|
|
NS_IMETHOD HasTransparency(PRBool &aTransparent);
|
|
|
|
NS_IMETHOD SetContentTransparency(PRBool aTransparent);
|
|
|
|
NS_IMETHOD SetClientData(void *aData);
|
|
|
|
NS_IMETHOD GetClientData(void *&aData);
|
|
|
|
NS_IMETHOD GetOffsetFromWidget(nscoord *aDx, nscoord *aDy, nsIWidget *&aWidget);
|
|
|
|
NS_IMETHOD GetScrollOffset(nscoord *aDx, nscoord *aDy);
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
|
|
|
|
1998-08-08 04:23:33 +00:00
|
|
|
// Helper function to get the view that's associated with a widget
|
|
|
|
static nsIView* GetViewFor(nsIWidget* aWidget);
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
protected:
|
1998-06-23 18:44:06 +00:00
|
|
|
virtual ~nsView();
|
1998-04-13 20:24:54 +00:00
|
|
|
//
|
|
|
|
virtual nsresult LoadWidget(const nsCID &aClassIID);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsIViewManager *mViewManager;
|
|
|
|
nsIView *mParent;
|
|
|
|
nsIWidget *mWindow;
|
|
|
|
|
|
|
|
//XXX should there be pointers to last child so backward walking is fast?
|
|
|
|
nsIView *mNextSibling;
|
|
|
|
nsIView *mFirstChild;
|
1998-08-28 03:05:23 +00:00
|
|
|
void *mClientData;
|
1998-04-13 20:24:54 +00:00
|
|
|
PRInt32 mZindex;
|
|
|
|
nsViewVisibility mVis;
|
|
|
|
PRInt32 mNumKids;
|
|
|
|
nsRect mBounds;
|
1998-04-29 02:24:07 +00:00
|
|
|
nsViewClip mClip;
|
1998-04-28 19:16:24 +00:00
|
|
|
nsTransform2D *mXForm;
|
|
|
|
float mOpacity;
|
1998-06-03 22:49:45 +00:00
|
|
|
PRInt32 mVFlags;
|
1998-08-08 04:23:33 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
|
|
|
NS_IMETHOD_(nsrefcnt) Release(void);
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
1998-06-03 22:49:45 +00:00
|
|
|
#define VIEW_FLAG_DYING 0x0001
|
|
|
|
#define VIEW_FLAG_TRANSPARENT 0x0002
|
|
|
|
|
|
|
|
#define ALL_VIEW_FLAGS (VIEW_FLAG_DYING | VIEW_FLAG_TRANSPARENT)
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
#endif
|