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"
|
|
|
|
|
|
|
|
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-04-13 20:24:54 +00:00
|
|
|
virtual nsresult Init(nsIViewManager* aManager,
|
|
|
|
const nsRect &aBounds,
|
|
|
|
nsIView *aParent,
|
|
|
|
const nsCID *aWindowIID = nsnull,
|
1998-05-14 21:34:08 +00:00
|
|
|
nsWidgetInitData *aWidgetInitData = nsnull,
|
1998-06-25 04:24:45 +00:00
|
|
|
nsNativeWidget aNative = nsnull,
|
1998-04-13 20:24:54 +00:00
|
|
|
PRInt32 aZIndex = 0,
|
1998-04-29 02:24:07 +00:00
|
|
|
const nsViewClip *aClip = nsnull,
|
1998-04-13 20:24:54 +00:00
|
|
|
float aOpacity = 1.0f,
|
|
|
|
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
|
1998-04-24 21:37:30 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual void Destroy();
|
|
|
|
virtual nsIViewManager * GetViewManager();
|
|
|
|
virtual nsIWidget * GetWidget();
|
1998-06-03 21:30:51 +00:00
|
|
|
virtual PRBool Paint(nsIRenderingContext& rc, const nsRect& rect,
|
1998-05-27 02:13:28 +00:00
|
|
|
PRUint32 aPaintFlags, nsIView *aBackstop = nsnull);
|
1998-06-03 21:30:51 +00:00
|
|
|
virtual PRBool Paint(nsIRenderingContext& rc, const nsIRegion& region, PRUint32 aPaintFlags);
|
1998-04-28 19:16:24 +00:00
|
|
|
virtual nsEventStatus HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags);
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual void SetPosition(nscoord x, nscoord y);
|
|
|
|
virtual void GetPosition(nscoord *x, nscoord *y);
|
1998-08-26 21:24:58 +00:00
|
|
|
virtual void SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE);
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual void GetDimensions(nscoord *width, nscoord *height);
|
1998-08-26 21:24:58 +00:00
|
|
|
virtual void SetBounds(const nsRect &aBounds, PRBool aPaint = PR_TRUE);
|
|
|
|
virtual void SetBounds(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, PRBool aPaint = PR_TRUE);
|
1998-07-07 21:51:57 +00:00
|
|
|
virtual void GetBounds(nsRect &aBounds) const;
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual void SetClip(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
|
1998-04-28 19:16:24 +00:00
|
|
|
virtual PRBool GetClip(nscoord *aLeft, nscoord *aTop, nscoord *aRight, nscoord *aBottom);
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual void SetVisibility(nsViewVisibility visibility);
|
|
|
|
virtual nsViewVisibility GetVisibility();
|
|
|
|
virtual void SetZIndex(PRInt32 zindex);
|
|
|
|
virtual PRInt32 GetZIndex();
|
|
|
|
virtual void SetParent(nsIView *aParent);
|
|
|
|
virtual nsIView *GetParent();
|
|
|
|
virtual nsIView* GetNextSibling() const;
|
|
|
|
virtual void SetNextSibling(nsIView* aNextSibling);
|
|
|
|
virtual void InsertChild(nsIView *child, nsIView *sibling);
|
|
|
|
virtual void RemoveChild(nsIView *child);
|
|
|
|
virtual PRInt32 GetChildCount();
|
|
|
|
virtual nsIView * GetChild(PRInt32 index);
|
1998-04-28 19:16:24 +00:00
|
|
|
virtual void SetTransform(nsTransform2D &aXForm);
|
|
|
|
virtual void GetTransform(nsTransform2D &aXForm);
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual void SetOpacity(float opacity);
|
|
|
|
virtual float GetOpacity();
|
|
|
|
virtual PRBool HasTransparency();
|
1998-06-03 22:49:45 +00:00
|
|
|
virtual void SetContentTransparency(PRBool aTransparent);
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
|
|
|
virtual void SetFrame(nsIFrame *aFrame);
|
|
|
|
virtual nsIFrame * GetFrame();
|
1998-06-16 17:05:42 +00:00
|
|
|
virtual nsIWidget * GetOffsetFromWidget(nscoord *aDx, nscoord *aDy);
|
|
|
|
virtual void GetScrollOffset(nscoord *aDx, nscoord *aDy);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
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;
|
|
|
|
nsIFrame *mFrame;
|
|
|
|
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
|