Adding support for ViewManager into xpfc
Change painting methods to pass around the rendering context and dirty rect instead of gui event to be compatible with view api's git-svn-id: svn://10.0.0.236/trunk@9582 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
1a09b34777
commit
79d217f984
@ -30,22 +30,26 @@
|
||||
#include "nsBoxLayout.h"
|
||||
#include "nsViewsCID.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsXPFCToolkit.h"
|
||||
|
||||
// XXX: This code should use XML for defining the Root UI. We need to
|
||||
// implement the stream manager first to do this, then lots of
|
||||
// this specific code should be removed (it would load trex.ui)
|
||||
|
||||
static NS_DEFINE_IID(kICalContainerIID, NS_ICALENDAR_CONTAINER_IID);
|
||||
static NS_DEFINE_IID(kICalContainerIID, NS_ICALENDAR_CONTAINER_IID);
|
||||
|
||||
static NS_DEFINE_IID(kFileWidgetCID, NS_FILEWIDGET_CID);
|
||||
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
|
||||
static NS_DEFINE_IID(kCXPFCDTD, NS_IXPFCXML_DTD_IID);
|
||||
static NS_DEFINE_IID(kCXPFCContentSink, NS_XPFCXMLCONTENTSINK_IID);
|
||||
static NS_DEFINE_IID(kCXPFCCommandServerCID, NS_XPFC_COMMAND_SERVER_CID);
|
||||
static NS_DEFINE_IID(kCXPFCHTMLCanvasCID, NS_XPFC_HTML_CANVAS_CID);
|
||||
static NS_DEFINE_IID(kFileWidgetCID, NS_FILEWIDGET_CID);
|
||||
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
|
||||
static NS_DEFINE_IID(kCXPFCDTD, NS_IXPFCXML_DTD_IID);
|
||||
static NS_DEFINE_IID(kCXPFCContentSink, NS_XPFCXMLCONTENTSINK_IID);
|
||||
static NS_DEFINE_IID(kCXPFCCommandServerCID, NS_XPFC_COMMAND_SERVER_CID);
|
||||
static NS_DEFINE_IID(kCXPFCHTMLCanvasCID, NS_XPFC_HTML_CANVAS_CID);
|
||||
|
||||
static NS_DEFINE_IID(kViewManagerCID, NS_VIEW_MANAGER_CID);
|
||||
static NS_DEFINE_IID(kIViewManagerIID, NS_IVIEWMANAGER_IID);
|
||||
static NS_DEFINE_IID(kViewManagerCID, NS_VIEW_MANAGER_CID);
|
||||
static NS_DEFINE_IID(kIViewManagerIID, NS_IVIEWMANAGER_IID);
|
||||
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
|
||||
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
||||
static NS_DEFINE_IID(kWidgetCID, NS_CHILD_CID);
|
||||
|
||||
// hardcode names of dll's
|
||||
#ifdef NS_WIN32
|
||||
@ -140,6 +144,8 @@ nsresult nsCalendarContainer::Init(nsIWidget * aParent,
|
||||
|
||||
mViewManager->Init(aParent->GetDeviceContext());
|
||||
|
||||
mViewManager->SetFrameRate(25);
|
||||
|
||||
/*
|
||||
* Create the Root UI
|
||||
*/
|
||||
@ -174,8 +180,32 @@ nsresult nsCalendarContainer::Init(nsIWidget * aParent,
|
||||
mRootUI->SetVisibility(PR_FALSE);
|
||||
((nsBoxLayout *)(mRootUI->GetLayout()))->SetLayoutAlignment(eLayoutAlignment_vertical);
|
||||
|
||||
nsIView * view = nsnull ;
|
||||
|
||||
res = nsRepository::CreateInstance(kViewCID,
|
||||
nsnull,
|
||||
kIViewIID,
|
||||
(void **)&(view));
|
||||
|
||||
if (res != NS_OK)
|
||||
return res;
|
||||
|
||||
view->Init(mViewManager,
|
||||
aBounds,
|
||||
nsnull,
|
||||
nsnull,
|
||||
nsnull,
|
||||
widget_parent->GetNativeData(NS_NATIVE_WIDGET));
|
||||
|
||||
mViewManager->SetRootView(view);
|
||||
|
||||
mViewManager->DisableRefresh();
|
||||
mViewManager->SetWindowDimensions(aBounds.width, aBounds.height);
|
||||
|
||||
gXPFCToolkit->GetCanvasManager()->Register(mRootUI,view);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Embed the Calendar Widget
|
||||
*/
|
||||
|
||||
@ -38,7 +38,8 @@ public:
|
||||
NS_IMETHOD SetBounds(const nsRect& aBounds);
|
||||
|
||||
NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) OnPaint(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD_(nsEventStatus) OnResize(nsGUIEvent *aEvent);
|
||||
|
||||
NS_IMETHOD GetClassPreferredSize(nsSize& aSize);
|
||||
|
||||
@ -30,14 +30,17 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD_(nsEventStatus) PaintForeground(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) PaintBorder(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) PaintForeground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD_(nsEventStatus) PaintBorder(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
|
||||
protected:
|
||||
~nsCalDayViewCanvas();
|
||||
|
||||
NS_IMETHOD PaintInterval(nsGUIEvent *aEvent,
|
||||
NS_IMETHOD PaintInterval(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
PRUint32 aIndex,
|
||||
PRUint32 aStart,
|
||||
PRUint32 aSpace,
|
||||
|
||||
@ -32,7 +32,8 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD_(nsEventStatus) PaintBackground(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) PaintBackground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
NS_IMETHOD AddDayViewCanvas();
|
||||
NS_IMETHOD_(PRUint32) GetNumberViewableDays();
|
||||
|
||||
@ -39,13 +39,15 @@ public:
|
||||
NS_IMETHOD_(PRUint32) GetVisibleMajorIntervals();
|
||||
NS_IMETHOD_(PRUint32) GetVisibleMinorIntervals();
|
||||
|
||||
NS_IMETHOD_(nsEventStatus) PaintBackground(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) PaintBackground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
NS_IMETHOD PaintInterval(nsGUIEvent *aEvent,
|
||||
NS_IMETHOD PaintInterval(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
PRUint32 aIndex,
|
||||
PRUint32 aStart,
|
||||
PRUint32 aSpace,
|
||||
|
||||
@ -30,7 +30,8 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD_(nsEventStatus) PaintBackground(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) PaintBackground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
|
||||
NS_IMETHOD GetClassPreferredSize(nsSize& aSize);
|
||||
|
||||
|
||||
@ -30,19 +30,21 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD_(nsEventStatus) PaintBorder(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) PaintBorder(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
|
||||
NS_IMETHOD GetClassPreferredSize(nsSize& aSize);
|
||||
|
||||
protected:
|
||||
|
||||
NS_IMETHOD PaintInterval(nsGUIEvent *aEvent,
|
||||
NS_IMETHOD PaintInterval(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
PRUint32 aIndex,
|
||||
PRUint32 aStart,
|
||||
PRUint32 aSpace,
|
||||
PRUint32 aMinorInterval);
|
||||
|
||||
NS_IMETHOD DrawTime(nsIRenderingContext * aContext,
|
||||
NS_IMETHOD DrawTime(nsIRenderingContext& aContext,
|
||||
nsRect& aRect,
|
||||
PRUint32 aIndex);
|
||||
|
||||
|
||||
@ -30,8 +30,10 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD_(nsEventStatus) PaintForeground(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) PaintBackground(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) PaintForeground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD_(nsEventStatus) PaintBackground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
|
||||
|
||||
protected:
|
||||
|
||||
@ -31,7 +31,8 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD_(nsEventStatus) PaintForeground(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) PaintForeground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
|
||||
|
||||
NS_IMETHOD_(nsString&) GetUserName();
|
||||
|
||||
@ -34,7 +34,8 @@ public:
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD SetBounds(const nsRect& aBounds);
|
||||
NS_IMETHOD_(void) SetBackgroundColor(const nscolor &aColor) ;
|
||||
NS_IMETHOD_(nsEventStatus) OnPaint(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
protected:
|
||||
~nsCalTodoComponentCanvas();
|
||||
|
||||
@ -33,6 +33,7 @@ static NS_DEFINE_IID(kCalCommandCanvasCID, NS_CAL_COMMANDCANVAS_CID);
|
||||
static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID);
|
||||
static NS_DEFINE_IID(kCTextFieldCID, NS_TEXTFIELD_CID);
|
||||
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
||||
static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID);
|
||||
|
||||
#define kNotFound -1
|
||||
|
||||
@ -124,7 +125,6 @@ nsresult nsCalCommandCanvas :: Init()
|
||||
|
||||
nsIWidget * widget = nsnull;
|
||||
nsresult res = mStaticTextField->QueryInterface(kIWidgetIID,(void**)&widget);
|
||||
gXPFCToolkit->GetCanvasManager()->Register(this, widget);
|
||||
NS_RELEASE(widget);
|
||||
|
||||
mStaticTextField->Create(GetWidget(),
|
||||
@ -152,7 +152,6 @@ nsresult nsCalCommandCanvas :: Init()
|
||||
|
||||
widget = nsnull;
|
||||
res = mTextField->QueryInterface(kIWidgetIID,(void**)&widget);
|
||||
gXPFCToolkit->GetCanvasManager()->Register(this, widget);
|
||||
NS_RELEASE(widget);
|
||||
|
||||
mTextField->Create(GetWidget(),
|
||||
@ -178,7 +177,12 @@ nsEventStatus PR_CALLBACK HandleEventTextField(nsGUIEvent *aEvent)
|
||||
if (gXPFCToolkit == nsnull)
|
||||
return nsEventStatus_eIgnore;
|
||||
|
||||
nsIXPFCCanvas * canvas = gXPFCToolkit->GetCanvasManager()->CanvasFromWidget(aEvent->widget);
|
||||
nsIXPFCCanvas * canvas = nsnull ;
|
||||
|
||||
nsresult res = aEvent->widget->QueryInterface(kIXPFCCanvasIID,(void**)&canvas);
|
||||
|
||||
if (NS_OK != res)
|
||||
return nsEventStatus_eIgnore;
|
||||
|
||||
if (canvas)
|
||||
return (canvas->HandleEvent(aEvent));
|
||||
@ -239,7 +243,8 @@ nsresult nsCalCommandCanvas :: SetBounds(const nsRect &aBounds)
|
||||
}
|
||||
|
||||
|
||||
nsEventStatus nsCalCommandCanvas :: OnPaint(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsCalCommandCanvas :: OnPaint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
mTextField->Invalidate(PR_FALSE);
|
||||
mStaticTextField->Invalidate(PR_FALSE);
|
||||
|
||||
@ -108,7 +108,8 @@ static nscolor nsDarker(nscolor c)
|
||||
* @param aMinorInterval how many minor ticks
|
||||
* @return NX_OK on success
|
||||
*/
|
||||
nsresult nsCalDayViewCanvas::PaintInterval(nsGUIEvent *aEvent,
|
||||
nsresult nsCalDayViewCanvas::PaintInterval(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
PRUint32 aIndex,
|
||||
PRUint32 aStart,
|
||||
PRUint32 aSpace,
|
||||
@ -119,12 +120,11 @@ nsresult nsCalDayViewCanvas::PaintInterval(nsGUIEvent *aEvent,
|
||||
/*
|
||||
* Paint this interval in it's entirety
|
||||
*/
|
||||
nsCalTimebarCanvas::PaintInterval(aEvent, aIndex, aStart, aSpace, aMinorInterval);
|
||||
nsCalTimebarCanvas::PaintInterval(aRenderingContext, aDirtyRect, aIndex, aStart, aSpace, aMinorInterval);
|
||||
nsRect rect;
|
||||
GetBounds(rect);
|
||||
|
||||
nsIRenderingContext * rndctx = ((nsPaintEvent*)aEvent)->renderingContext;
|
||||
rndctx->SetColor(nsLighter(nsLighter(nsDarker(GetBackgroundColor()))));
|
||||
aRenderingContext.SetColor(nsLighter(nsLighter(nsDarker(GetBackgroundColor()))));
|
||||
|
||||
aMinorInterval = 4; // XXX: this is a hack, we should specify this in the XML -sman
|
||||
|
||||
@ -142,7 +142,7 @@ nsresult nsCalDayViewCanvas::PaintInterval(nsGUIEvent *aEvent,
|
||||
PRUint32 iX = rect.x + iXSpace;
|
||||
for (i = 1; i < (PRUint32) aMinorInterval; i++)
|
||||
{
|
||||
rndctx->DrawLine(iX,iYStart, iX,iYStop);
|
||||
aRenderingContext.DrawLine(iX,iYStart, iX,iYStop);
|
||||
iX += iXSpace;
|
||||
}
|
||||
}
|
||||
@ -163,7 +163,7 @@ nsresult nsCalDayViewCanvas::PaintInterval(nsGUIEvent *aEvent,
|
||||
PRUint32 iY = rect.y + INSET + iYSpace;
|
||||
for (i = 1; i < (PRUint32) aMinorInterval; i++)
|
||||
{
|
||||
rndctx->DrawLine(iXStart,iY, iXStop,iY);
|
||||
aRenderingContext.DrawLine(iXStart,iY, iXStop,iY);
|
||||
iY += iYSpace;
|
||||
}
|
||||
}
|
||||
@ -173,16 +173,16 @@ nsresult nsCalDayViewCanvas::PaintInterval(nsGUIEvent *aEvent,
|
||||
return NS_OK ;
|
||||
}
|
||||
|
||||
nsEventStatus nsCalDayViewCanvas :: PaintBorder(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsCalDayViewCanvas :: PaintBorder(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
nsRect rect;
|
||||
|
||||
nsIRenderingContext * rndctx = ((nsPaintEvent*)aEvent)->renderingContext;
|
||||
GetBounds(rect);
|
||||
|
||||
rect.x++; rect.y++; rect.width-=2; rect.height-=2;
|
||||
rndctx->SetColor(GetForegroundColor());
|
||||
rndctx->DrawRect(rect);
|
||||
aRenderingContext.SetColor(GetForegroundColor());
|
||||
aRenderingContext.DrawRect(rect);
|
||||
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
@ -195,11 +195,11 @@ nsEventStatus nsCalDayViewCanvas :: PaintBorder(nsGUIEvent *aEvent)
|
||||
* event. There should probably be a separate mechanism that
|
||||
* connects it to VEVENTS.
|
||||
*/
|
||||
nsEventStatus nsCalDayViewCanvas :: PaintForeground(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsCalDayViewCanvas :: PaintForeground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
JulianPtrArray * evtVctr = 0;
|
||||
VEvent *pEvent = 0;
|
||||
nsIRenderingContext * rndctx = ((nsPaintEvent*)aEvent)->renderingContext;
|
||||
nsRect rect;
|
||||
char *psBuf;
|
||||
char sBuf[256];
|
||||
@ -260,7 +260,7 @@ nsEventStatus nsCalDayViewCanvas :: PaintForeground(nsGUIEvent *aEvent)
|
||||
rect.y += (int)(rect.height * sratio);
|
||||
rect.height = (int)((rect.height * eratio) - (rect.y - bounds.y));
|
||||
|
||||
rndctx->SetColor(mComponentColor);
|
||||
aRenderingContext.SetColor(mComponentColor);
|
||||
|
||||
rect.x = rect.x + 2 * INSET ;
|
||||
rect.width = rect.width - 4*INSET ;
|
||||
@ -274,24 +274,24 @@ nsEventStatus nsCalDayViewCanvas :: PaintForeground(nsGUIEvent *aEvent)
|
||||
if ((rect.y+rect.height) > (bounds.y+bounds.height))
|
||||
rect.height = (bounds.y+bounds.height)-1;
|
||||
|
||||
rndctx->FillRect(rect);
|
||||
aRenderingContext.FillRect(rect);
|
||||
|
||||
/*
|
||||
* Render the highlights
|
||||
*/
|
||||
rndctx->SetColor(nsLighter(mComponentColor));
|
||||
rndctx->DrawLine(rect.x,rect.y,rect.x+rect.width,rect.y);
|
||||
rndctx->DrawLine(rect.x,rect.y,rect.x,rect.y+rect.height);
|
||||
rndctx->SetColor(nsDarker(mComponentColor));
|
||||
rndctx->DrawLine(rect.x+rect.width,rect.y,rect.x+rect.width,rect.y+rect.height);
|
||||
rndctx->DrawLine(rect.x,rect.y+rect.height,rect.x+rect.width,rect.y+rect.height);
|
||||
aRenderingContext.SetColor(nsLighter(mComponentColor));
|
||||
aRenderingContext.DrawLine(rect.x,rect.y,rect.x+rect.width,rect.y);
|
||||
aRenderingContext.DrawLine(rect.x,rect.y,rect.x,rect.y+rect.height);
|
||||
aRenderingContext.SetColor(nsDarker(mComponentColor));
|
||||
aRenderingContext.DrawLine(rect.x+rect.width,rect.y,rect.x+rect.width,rect.y+rect.height);
|
||||
aRenderingContext.DrawLine(rect.x,rect.y+rect.height,rect.x+rect.width,rect.y+rect.height);
|
||||
|
||||
rndctx->GetFontMetrics()->GetHeight(fm_height);
|
||||
aRenderingContext.GetFontMetrics()->GetHeight(fm_height);
|
||||
|
||||
if (rect.height > fm_height)
|
||||
{
|
||||
// rndctx->SetColor(GetForegroundColor());
|
||||
rndctx->SetColor(NS_RGB(255,255,255)); /* XXX: This color should come from someplace else... */
|
||||
aRenderingContext.SetColor(NS_RGB(255,255,255)); /* XXX: This color should come from someplace else... */
|
||||
|
||||
/*
|
||||
* XXX. we need to handle '\n' in a format string...
|
||||
@ -299,13 +299,13 @@ nsEventStatus nsCalDayViewCanvas :: PaintForeground(nsGUIEvent *aEvent)
|
||||
* we need to generalize this.
|
||||
*/
|
||||
psBuf = pEvent->toStringFmt(usFmt).toCString("");
|
||||
rndctx->DrawString(psBuf,nsCRT::strlen(psBuf),rect.x+1,rect.y,0);
|
||||
aRenderingContext.DrawString(psBuf,nsCRT::strlen(psBuf),rect.x+1,rect.y,0);
|
||||
delete psBuf;
|
||||
|
||||
if (rect.height > (2 * fm_height))
|
||||
{
|
||||
psBuf = pEvent->getSummary().toCString("");
|
||||
rndctx->DrawString(psBuf,nsCRT::strlen(psBuf),rect.x+1,rect.y+fm_height,0);
|
||||
aRenderingContext.DrawString(psBuf,nsCRT::strlen(psBuf),rect.x+1,rect.y+fm_height,0);
|
||||
delete psBuf;
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,9 +114,10 @@ nsresult nsCalMultiDayViewCanvas :: Init()
|
||||
* Since our Day View's will do the painting, just ignore
|
||||
*/
|
||||
|
||||
nsEventStatus nsCalMultiDayViewCanvas :: PaintBackground(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsCalMultiDayViewCanvas :: PaintBackground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
return (nsXPFCCanvas :: PaintBackground(aEvent));
|
||||
return (nsXPFCCanvas :: PaintBackground(aRenderingContext,aDirtyRect));
|
||||
}
|
||||
|
||||
nsresult nsCalMultiDayViewCanvas :: SetNumberViewableDays(PRUint32 aNumberViewableDays)
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kCalTimebarCanvasCID, NS_CAL_TIMEBARCANVAS_CID);
|
||||
|
||||
#define INSET 1
|
||||
#define LOCAL_INSET 1
|
||||
|
||||
nsCalTimebarCanvas :: nsCalTimebarCanvas(nsISupports* outer) : nsXPFCCanvas(outer)
|
||||
{
|
||||
@ -148,14 +148,15 @@ nsICalTimeContext * nsCalTimebarCanvas :: GetTimeContext()
|
||||
}
|
||||
|
||||
|
||||
nsEventStatus nsCalTimebarCanvas :: PaintBackground(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsCalTimebarCanvas :: PaintBackground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
/*
|
||||
* Let the Base Canvas paint it's default background
|
||||
*/
|
||||
|
||||
nsRect rect;
|
||||
nsXPFCCanvas::PaintBackground(aEvent);
|
||||
nsXPFCCanvas::PaintBackground(aRenderingContext,aDirtyRect);
|
||||
|
||||
/*
|
||||
* Now paint the TimeContext over the base canvas background
|
||||
@ -180,15 +181,15 @@ nsEventStatus nsCalTimebarCanvas :: PaintBackground(nsGUIEvent *aEvent)
|
||||
space_per_interval = (rect.width) / major_intervals;
|
||||
start = rect.x;
|
||||
} else {
|
||||
space_per_interval = ((rect.height-(2*INSET)) - ((rect.height-(2*INSET)) % major_intervals)) / major_intervals;
|
||||
start = rect.y+INSET;
|
||||
space_per_interval = ((rect.height-(2*LOCAL_INSET)) - ((rect.height-(2*LOCAL_INSET)) % major_intervals)) / major_intervals;
|
||||
start = rect.y+LOCAL_INSET;
|
||||
}
|
||||
|
||||
PRUint32 i = 0;
|
||||
|
||||
for (i=0; i<=major_intervals; i++) {
|
||||
|
||||
PaintInterval(aEvent, i,start,space_per_interval, minor_intervals);
|
||||
PaintInterval(aRenderingContext, aDirtyRect, i,start,space_per_interval, minor_intervals);
|
||||
|
||||
start += space_per_interval;
|
||||
|
||||
@ -197,7 +198,8 @@ nsEventStatus nsCalTimebarCanvas :: PaintBackground(nsGUIEvent *aEvent)
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
||||
nsresult nsCalTimebarCanvas::PaintInterval(nsGUIEvent *aEvent,
|
||||
nsresult nsCalTimebarCanvas::PaintInterval(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
PRUint32 aIndex,
|
||||
PRUint32 aStart,
|
||||
PRUint32 aSpace,
|
||||
@ -211,9 +213,7 @@ nsresult nsCalTimebarCanvas::PaintInterval(nsGUIEvent *aEvent,
|
||||
|
||||
GetBounds(rect);
|
||||
|
||||
nsIRenderingContext * rndctx = ((nsPaintEvent*)aEvent)->renderingContext;
|
||||
|
||||
rndctx->SetColor(GetForegroundColor());
|
||||
aRenderingContext.SetColor(GetForegroundColor());
|
||||
|
||||
if (GetTimeContext()->GetHorizontal() == PR_TRUE) {
|
||||
rect.x = aStart;
|
||||
@ -223,7 +223,7 @@ nsresult nsCalTimebarCanvas::PaintInterval(nsGUIEvent *aEvent,
|
||||
rect.height = aSpace;
|
||||
}
|
||||
|
||||
rndctx->DrawLine(rect.x+INSET, rect.y, rect.x+rect.width-INSET, rect.y);
|
||||
aRenderingContext.DrawLine(rect.x+LOCAL_INSET, rect.y, rect.x+rect.width-LOCAL_INSET, rect.y);
|
||||
|
||||
return NS_OK ;
|
||||
}
|
||||
|
||||
@ -75,13 +75,14 @@ nsresult nsCalTimebarHeading :: Init()
|
||||
return NS_OK ;
|
||||
}
|
||||
|
||||
nsEventStatus nsCalTimebarHeading :: PaintBackground(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsCalTimebarHeading :: PaintBackground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
/*
|
||||
* Let the Base Canvas paint it's default background
|
||||
*/
|
||||
|
||||
nsXPFCCanvas::PaintBackground(aEvent);
|
||||
nsXPFCCanvas::PaintBackground(aRenderingContext,aDirtyRect);
|
||||
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
||||
@ -93,7 +93,8 @@ nsresult nsCalTimebarScale :: Init()
|
||||
* ourselves. Get the data from it
|
||||
*/
|
||||
|
||||
nsresult nsCalTimebarScale::PaintInterval(nsGUIEvent *aEvent,
|
||||
nsresult nsCalTimebarScale::PaintInterval(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
PRUint32 aIndex,
|
||||
PRUint32 aStart,
|
||||
PRUint32 aSpace,
|
||||
@ -104,12 +105,11 @@ nsresult nsCalTimebarScale::PaintInterval(nsGUIEvent *aEvent,
|
||||
/*
|
||||
* Paint this interval in it's entirety
|
||||
*/
|
||||
nsCalTimebarCanvas::PaintInterval(aEvent, aIndex, aStart, aSpace, aMinorInterval);
|
||||
nsCalTimebarCanvas::PaintInterval(aRenderingContext, aDirtyRect, aIndex, aStart, aSpace, aMinorInterval);
|
||||
nsRect rect;
|
||||
GetBounds(rect);
|
||||
|
||||
nsIRenderingContext * rndctx = ((nsPaintEvent*)aEvent)->renderingContext;
|
||||
rndctx->SetColor(GetForegroundColor());
|
||||
aRenderingContext.SetColor(GetForegroundColor());
|
||||
|
||||
aMinorInterval = 4; // XXX: this is a hack, we should specify this in the XML -sman
|
||||
|
||||
@ -127,7 +127,7 @@ nsresult nsCalTimebarScale::PaintInterval(nsGUIEvent *aEvent,
|
||||
PRUint32 iX = rect.x + iXSpace;
|
||||
for (i = 0; i < (PRUint32) aMinorInterval; i++)
|
||||
{
|
||||
rndctx->DrawLine(iX,iYStart, iX,iYStop);
|
||||
aRenderingContext.DrawLine(iX,iYStart, iX,iYStop);
|
||||
iX += iXSpace;
|
||||
}
|
||||
}
|
||||
@ -148,17 +148,17 @@ nsresult nsCalTimebarScale::PaintInterval(nsGUIEvent *aEvent,
|
||||
PRUint32 iY = rect.y + INSET + iYSpace;
|
||||
for (i = 1; i < (PRUint32) aMinorInterval; i++)
|
||||
{
|
||||
rndctx->DrawLine(iXStart,iY, iXStop,iY);
|
||||
aRenderingContext.DrawLine(iXStart,iY, iXStop,iY);
|
||||
iY += iYSpace;
|
||||
}
|
||||
}
|
||||
|
||||
DrawTime(rndctx, rect, aIndex);
|
||||
DrawTime(aRenderingContext, rect, aIndex);
|
||||
|
||||
return NS_OK ;
|
||||
}
|
||||
|
||||
nsresult nsCalTimebarScale :: DrawTime(nsIRenderingContext * aContext,
|
||||
nsresult nsCalTimebarScale :: DrawTime(nsIRenderingContext& aContext,
|
||||
nsRect& aRect,
|
||||
PRUint32 aIndex)
|
||||
{
|
||||
@ -195,8 +195,8 @@ nsresult nsCalTimebarScale :: DrawTime(nsIRenderingContext * aContext,
|
||||
* compute the Metrics for the string
|
||||
*/
|
||||
|
||||
aContext->GetFontMetrics()->GetHeight(height);
|
||||
aContext->GetFontMetrics()->GetWidth(text,width);
|
||||
aContext.GetFontMetrics()->GetHeight(height);
|
||||
aContext.GetFontMetrics()->GetWidth(text,width);
|
||||
|
||||
/*
|
||||
* center the text in our rect and draw it
|
||||
@ -208,21 +208,21 @@ nsresult nsCalTimebarScale :: DrawTime(nsIRenderingContext * aContext,
|
||||
x = aRect.x + (INSET << 1);
|
||||
y = aRect.y + (INSET << 1);
|
||||
|
||||
aContext->DrawString(text,nsCRT::strlen(text),x,y,0);
|
||||
aContext.DrawString(text,nsCRT::strlen(text),x,y,0);
|
||||
|
||||
return (NS_OK);
|
||||
}
|
||||
|
||||
nsEventStatus nsCalTimebarScale :: PaintBorder(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsCalTimebarScale :: PaintBorder(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
nsRect rect;
|
||||
|
||||
nsIRenderingContext * rndctx = ((nsPaintEvent*)aEvent)->renderingContext;
|
||||
GetBounds(rect);
|
||||
|
||||
rect.x++; rect.y++; rect.width-=2; rect.height-=2;
|
||||
rndctx->SetColor(GetForegroundColor());
|
||||
rndctx->DrawRect(rect);
|
||||
aRenderingContext.SetColor(GetForegroundColor());
|
||||
aRenderingContext.DrawRect(rect);
|
||||
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
||||
@ -70,7 +70,8 @@ nsresult nsCalTimebarTimeHeading :: Init()
|
||||
return NS_OK ;
|
||||
}
|
||||
|
||||
nsEventStatus nsCalTimebarTimeHeading :: PaintForeground(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsCalTimebarTimeHeading :: PaintForeground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
|
||||
if (GetTimeContext() == nsnull)
|
||||
@ -79,7 +80,6 @@ nsEventStatus nsCalTimebarTimeHeading :: PaintForeground(nsGUIEvent *aEvent)
|
||||
nscoord width, height, x, y;
|
||||
|
||||
nsRect rect;
|
||||
nsIRenderingContext * rndctx = ((nsPaintEvent*)aEvent)->renderingContext;
|
||||
|
||||
GetBounds(rect);
|
||||
|
||||
@ -92,8 +92,8 @@ nsEventStatus nsCalTimebarTimeHeading :: PaintForeground(nsGUIEvent *aEvent)
|
||||
* compute the Metrics for the string
|
||||
*/
|
||||
|
||||
rndctx->GetFontMetrics()->GetHeight(height);
|
||||
rndctx->GetFontMetrics()->GetWidth(*string,width);
|
||||
aRenderingContext.GetFontMetrics()->GetHeight(height);
|
||||
aRenderingContext.GetFontMetrics()->GetWidth(*string,width);
|
||||
|
||||
/*
|
||||
* XXX: If we are too big, remove the Day of the week. Need a better algorithm
|
||||
@ -104,7 +104,7 @@ nsEventStatus nsCalTimebarTimeHeading :: PaintForeground(nsGUIEvent *aEvent)
|
||||
{
|
||||
pattern = "MMM dd\n";
|
||||
GetTimeContext()->GetDTFirstVisible()->strftime(pattern, &string);
|
||||
rndctx->GetFontMetrics()->GetWidth(*string,width);
|
||||
aRenderingContext.GetFontMetrics()->GetWidth(*string,width);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -114,19 +114,20 @@ nsEventStatus nsCalTimebarTimeHeading :: PaintForeground(nsGUIEvent *aEvent)
|
||||
x = ((rect.width - width)>>1)+rect.x;
|
||||
y = ((rect.height - height)>>1)+rect.y;
|
||||
|
||||
rndctx->SetColor(GetForegroundColor());
|
||||
rndctx->DrawString(*string,nsCRT::strlen(*string),x,y,0);
|
||||
aRenderingContext.SetColor(GetForegroundColor());
|
||||
aRenderingContext.DrawString(*string,nsCRT::strlen(*string),x,y,0);
|
||||
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
||||
nsEventStatus nsCalTimebarTimeHeading :: PaintBackground(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsCalTimebarTimeHeading :: PaintBackground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
/*
|
||||
* Let the Base Canvas paint it's default background
|
||||
*/
|
||||
|
||||
nsXPFCCanvas::PaintBackground(aEvent);
|
||||
nsXPFCCanvas::PaintBackground(aRenderingContext,aDirtyRect);
|
||||
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
||||
@ -75,21 +75,20 @@ nsresult nsCalTimebarUserHeading :: Init()
|
||||
return NS_OK ;
|
||||
}
|
||||
|
||||
nsEventStatus nsCalTimebarUserHeading :: PaintForeground(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsCalTimebarUserHeading :: PaintForeground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
nscoord width, height, x, y;
|
||||
|
||||
nsRect rect;
|
||||
nsIRenderingContext * rndctx = ((nsPaintEvent*)aEvent)->renderingContext;
|
||||
|
||||
GetBounds(rect);
|
||||
|
||||
/*
|
||||
* compute the Metrics for the string
|
||||
*/
|
||||
|
||||
rndctx->GetFontMetrics()->GetHeight(height);
|
||||
rndctx->GetFontMetrics()->GetWidth(mUserName,width);
|
||||
aRenderingContext.GetFontMetrics()->GetHeight(height);
|
||||
aRenderingContext.GetFontMetrics()->GetWidth(mUserName,width);
|
||||
|
||||
/*
|
||||
* center the text in our rect and draw it
|
||||
@ -98,8 +97,8 @@ nsEventStatus nsCalTimebarUserHeading :: PaintForeground(nsGUIEvent *aEvent)
|
||||
x = ((rect.width - width)>>1)+rect.x;
|
||||
y = ((rect.height - height)>>1)+rect.y;
|
||||
|
||||
rndctx->SetColor(GetForegroundColor());
|
||||
rndctx->DrawString(mUserName,mUserName.Length(),x,y,0);
|
||||
aRenderingContext.SetColor(GetForegroundColor());
|
||||
aRenderingContext.DrawString(mUserName,mUserName.Length(),x,y,0);
|
||||
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
||||
@ -145,7 +145,8 @@ void nsCalTodoComponentCanvas :: SetBackgroundColor(const nscolor &aColor)
|
||||
nsXPFCCanvas::SetBackgroundColor(aColor);
|
||||
}
|
||||
|
||||
nsEventStatus nsCalTodoComponentCanvas :: OnPaint(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsCalTodoComponentCanvas :: OnPaint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
mWidget->Invalidate(PR_FALSE);
|
||||
return (nsEventStatus_eConsumeNoDefault);
|
||||
|
||||
@ -236,8 +236,9 @@ protected:
|
||||
nsString m_sFontName; // the name of the font face
|
||||
|
||||
public:
|
||||
NS_IMETHOD_(nsEventStatus) OnPaint(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) OnResize(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD_(nsEventStatus) OnResize(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) OnLeftButtonDown(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) OnLeftButtonUp(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) OnMouseMove(nsGUIEvent *aEvent);
|
||||
|
||||
@ -31,7 +31,8 @@ public:
|
||||
NS_IMETHOD Init();
|
||||
|
||||
// Subclass Canvas functions
|
||||
NS_IMETHOD_(nsEventStatus) PaintForeground(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) PaintForeground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD_(nsEventStatus) OnLeftButtonDown(nsGUIEvent *aEvent);
|
||||
|
||||
|
||||
@ -46,7 +47,7 @@ protected:
|
||||
private:
|
||||
NS_METHOD GetTrianglePoints(nsPoint * pts);
|
||||
NS_METHOD_(PRBool) IsPointInTriangle(nsPoint aPoint, nsPoint * aTriangle);
|
||||
NS_METHOD RenderController(nsIRenderingContext * aCtx,
|
||||
NS_METHOD RenderController(nsIRenderingContext& aCtx,
|
||||
nsPoint* aPoints,
|
||||
PRUint32 aNumPoints);
|
||||
|
||||
|
||||
@ -1610,18 +1610,18 @@ void nsCalMonthContextController::SetDefaults()
|
||||
// CMiniCalPlatform message handlers
|
||||
|
||||
|
||||
nsEventStatus nsCalMonthContextController::OnPaint(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsCalMonthContextController :: OnPaint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
nsIRenderingContext * rndctx = ((nsPaintEvent*)aEvent)->renderingContext;
|
||||
mRenderingContext = rndctx;
|
||||
mRenderingContext = &aRenderingContext;
|
||||
|
||||
PushState(mRenderingContext);
|
||||
PushState(aRenderingContext);
|
||||
|
||||
PaintBackground(aEvent);
|
||||
PaintBackground(aRenderingContext,aDirtyRect);
|
||||
|
||||
DrawMiniCal((void *)rndctx);
|
||||
DrawMiniCal((void *)mRenderingContext);
|
||||
|
||||
PopState(mRenderingContext);
|
||||
PopState(aRenderingContext);
|
||||
|
||||
mRenderingContext = nsnull;
|
||||
|
||||
|
||||
@ -68,71 +68,70 @@ nsresult nsCalTimebarContextController::QueryInterface(REFNSIID aIID, void** aIn
|
||||
NS_IMPL_ADDREF(nsCalTimebarContextController)
|
||||
NS_IMPL_RELEASE(nsCalTimebarContextController)
|
||||
|
||||
nsEventStatus nsCalTimebarContextController :: PaintForeground(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsCalTimebarContextController :: PaintForeground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
|
||||
nsPoint pts[3];
|
||||
|
||||
nsIRenderingContext * rndctx = ((nsPaintEvent*)aEvent)->renderingContext;
|
||||
|
||||
rndctx->SetColor(GetForegroundColor());
|
||||
aRenderingContext.SetColor(GetForegroundColor());
|
||||
|
||||
GetTrianglePoints(pts);
|
||||
|
||||
RenderController(rndctx, pts,3);
|
||||
RenderController(aRenderingContext, pts,3);
|
||||
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsCalTimebarContextController :: RenderController(nsIRenderingContext * aCtx,
|
||||
nsresult nsCalTimebarContextController :: RenderController(nsIRenderingContext& aCtx,
|
||||
nsPoint * aPoints,
|
||||
PRUint32 aNumPoints)
|
||||
{
|
||||
aCtx->FillPolygon(aPoints,aNumPoints);
|
||||
aCtx.FillPolygon(aPoints,aNumPoints);
|
||||
|
||||
switch(GetOrientation())
|
||||
{
|
||||
case nsContextControllerOrientation_east:
|
||||
|
||||
aCtx->SetColor(Highlight(GetForegroundColor()));
|
||||
aCtx->DrawLine(aPoints[0].x,aPoints[0].y,aPoints[1].x,aPoints[1].y);
|
||||
aCtx->DrawLine(aPoints[2].x,aPoints[2].y,aPoints[0].x,aPoints[0].y);
|
||||
aCtx.SetColor(Highlight(GetForegroundColor()));
|
||||
aCtx.DrawLine(aPoints[0].x,aPoints[0].y,aPoints[1].x,aPoints[1].y);
|
||||
aCtx.DrawLine(aPoints[2].x,aPoints[2].y,aPoints[0].x,aPoints[0].y);
|
||||
|
||||
aCtx->SetColor(Dim(GetForegroundColor()));
|
||||
aCtx->DrawLine(aPoints[1].x,aPoints[1].y,aPoints[2].x,aPoints[2].y);
|
||||
aCtx.SetColor(Dim(GetForegroundColor()));
|
||||
aCtx.DrawLine(aPoints[1].x,aPoints[1].y,aPoints[2].x,aPoints[2].y);
|
||||
|
||||
break;
|
||||
|
||||
case nsContextControllerOrientation_west:
|
||||
|
||||
aCtx->SetColor(Highlight(Highlight(GetForegroundColor())));
|
||||
aCtx->DrawLine(aPoints[0].x,aPoints[0].y,aPoints[1].x,aPoints[1].y);
|
||||
aCtx.SetColor(Highlight(Highlight(GetForegroundColor())));
|
||||
aCtx.DrawLine(aPoints[0].x,aPoints[0].y,aPoints[1].x,aPoints[1].y);
|
||||
|
||||
aCtx->SetColor(Dim(GetForegroundColor()));
|
||||
aCtx->DrawLine(aPoints[1].x,aPoints[1].y,aPoints[2].x,aPoints[2].y);
|
||||
aCtx->DrawLine(aPoints[2].x,aPoints[2].y,aPoints[0].x,aPoints[0].y);
|
||||
aCtx.SetColor(Dim(GetForegroundColor()));
|
||||
aCtx.DrawLine(aPoints[1].x,aPoints[1].y,aPoints[2].x,aPoints[2].y);
|
||||
aCtx.DrawLine(aPoints[2].x,aPoints[2].y,aPoints[0].x,aPoints[0].y);
|
||||
break;
|
||||
|
||||
case nsContextControllerOrientation_north:
|
||||
|
||||
aCtx->SetColor(Highlight(Highlight(GetForegroundColor())));
|
||||
aCtx->DrawLine(aPoints[0].x,aPoints[0].y,aPoints[1].x,aPoints[1].y);
|
||||
aCtx.SetColor(Highlight(Highlight(GetForegroundColor())));
|
||||
aCtx.DrawLine(aPoints[0].x,aPoints[0].y,aPoints[1].x,aPoints[1].y);
|
||||
|
||||
aCtx->SetColor(Highlight(GetForegroundColor()));
|
||||
aCtx->DrawLine(aPoints[1].x,aPoints[1].y,aPoints[2].x,aPoints[2].y);
|
||||
aCtx.SetColor(Highlight(GetForegroundColor()));
|
||||
aCtx.DrawLine(aPoints[1].x,aPoints[1].y,aPoints[2].x,aPoints[2].y);
|
||||
|
||||
aCtx->SetColor(Dim(GetForegroundColor()));
|
||||
aCtx->DrawLine(aPoints[2].x,aPoints[2].y,aPoints[0].x,aPoints[0].y);
|
||||
aCtx.SetColor(Dim(GetForegroundColor()));
|
||||
aCtx.DrawLine(aPoints[2].x,aPoints[2].y,aPoints[0].x,aPoints[0].y);
|
||||
break;
|
||||
|
||||
case nsContextControllerOrientation_south:
|
||||
aCtx->SetColor(Dim(GetForegroundColor()));
|
||||
aCtx->DrawLine(aPoints[0].x,aPoints[0].y,aPoints[1].x,aPoints[1].y);
|
||||
aCtx->DrawLine(aPoints[1].x,aPoints[1].y,aPoints[2].x,aPoints[2].y);
|
||||
aCtx.SetColor(Dim(GetForegroundColor()));
|
||||
aCtx.DrawLine(aPoints[0].x,aPoints[0].y,aPoints[1].x,aPoints[1].y);
|
||||
aCtx.DrawLine(aPoints[1].x,aPoints[1].y,aPoints[2].x,aPoints[2].y);
|
||||
|
||||
aCtx->SetColor(Highlight(GetForegroundColor()));
|
||||
aCtx->DrawLine(aPoints[2].x,aPoints[2].y,aPoints[0].x,aPoints[0].y);
|
||||
aCtx.SetColor(Highlight(GetForegroundColor()));
|
||||
aCtx.DrawLine(aPoints[2].x,aPoints[2].y,aPoints[0].x,aPoints[0].y);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@ -41,13 +41,11 @@
|
||||
#include "nsIImageObserver.h"
|
||||
#include "nsIImageRequest.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIViewObserver.h"
|
||||
|
||||
CLASS_EXPORT_XPFC nsXPFCCanvas : public nsIXPFCCanvas,
|
||||
public nsIXPFCObserver,
|
||||
public nsIXMLParserObject,
|
||||
public nsIImageRequestObserver,
|
||||
public nsIViewObserver
|
||||
public nsIImageRequestObserver
|
||||
|
||||
{
|
||||
public:
|
||||
@ -76,7 +74,9 @@ public:
|
||||
NS_IMETHOD_(nsEventStatus) DefaultProcessing(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent);
|
||||
|
||||
NS_IMETHOD_(nsEventStatus) OnPaint(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
NS_IMETHOD_(nsEventStatus) OnResize(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) OnMove(nsGUIEvent *aEvent);
|
||||
|
||||
@ -105,10 +105,16 @@ public:
|
||||
NS_IMETHOD_(void) AddChildCanvas(nsIXPFCCanvas * aChildCanvas, PRInt32 aPosition = -1);
|
||||
NS_IMETHOD_(void) RemoveChildCanvas(nsIXPFCCanvas * aChildCanvas);
|
||||
NS_IMETHOD_(void) Reparent(nsIXPFCCanvas * aParentCanvas);
|
||||
NS_IMETHOD_(nsEventStatus) PaintBackground(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) PaintForeground(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) PaintBorder(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) PaintChildWidgets(nsGUIEvent *aEvent);
|
||||
|
||||
NS_IMETHOD_(nsEventStatus) PaintBackground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD_(nsEventStatus) PaintForeground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD_(nsEventStatus) PaintBorder(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD_(nsEventStatus) PaintChildWidgets(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
NS_IMETHOD_(nsEventStatus) ResizeChildWidgets(nsGUIEvent *aEvent);
|
||||
|
||||
NS_IMETHOD SetOpacity(PRFloat64 aOpacity) ;
|
||||
@ -205,7 +211,7 @@ public:
|
||||
* @param aRenderingContext, rendering context to save state to
|
||||
* @result nsresult, NS_OK if successful
|
||||
*/
|
||||
NS_IMETHOD PushState(nsIRenderingContext * aRenderingContext) ;
|
||||
NS_IMETHOD PushState(nsIRenderingContext& aRenderingContext) ;
|
||||
|
||||
/**
|
||||
* Get and and set RenderingContext to this graphical state
|
||||
@ -213,7 +219,7 @@ public:
|
||||
* @return if PR_TRUE, indicates that the clipping region after
|
||||
* popping state is empty, else PR_FALSE
|
||||
*/
|
||||
NS_IMETHOD_(PRBool) PopState(nsIRenderingContext * aRenderingContext) ;
|
||||
NS_IMETHOD_(PRBool) PopState(nsIRenderingContext& aRenderingContext) ;
|
||||
|
||||
NS_IMETHOD FindLargestTabGroup(PRUint32& aTabGroup);
|
||||
NS_IMETHOD FindLargestTabID(PRUint32 aTabGroup, PRUint32& aTabID);
|
||||
@ -229,16 +235,6 @@ public:
|
||||
nsImageError aErrorType);
|
||||
|
||||
|
||||
// nsIViewObserver Interfaces
|
||||
NS_IMETHOD Paint(nsIView * aView,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD HandleEvent(nsIView * aView,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus);
|
||||
NS_IMETHOD Scrolled(nsIView * aView);
|
||||
NS_IMETHOD ResizeReflow(nsIView * aView, nscoord aWidth, nscoord aHeight);
|
||||
|
||||
|
||||
#if defined(DEBUG) && defined(XP_PC)
|
||||
NS_IMETHOD DumpCanvas(FILE * f, PRUint32 indent) ;
|
||||
@ -293,6 +289,8 @@ protected:
|
||||
nsIRenderingContext *mRenderingContext;
|
||||
nsIXPFCCanvas * mParent;
|
||||
|
||||
public:
|
||||
nsIView *mView;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -27,10 +27,12 @@
|
||||
#include "nsCom.h"
|
||||
#include "nsIVector.h"
|
||||
#include "nsIIterator.h"
|
||||
|
||||
#include "nsIXPFCCanvasManager.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIViewObserver.h"
|
||||
|
||||
class nsXPFCCanvasManager : public nsIXPFCCanvasManager
|
||||
class nsXPFCCanvasManager : public nsIXPFCCanvasManager,
|
||||
public nsIViewObserver
|
||||
{
|
||||
public:
|
||||
nsXPFCCanvasManager();
|
||||
@ -38,14 +40,25 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init() ;
|
||||
NS_IMETHOD_(nsIXPFCCanvas *) CanvasFromWidget(nsIWidget * aWidget);
|
||||
NS_IMETHOD_(nsIXPFCCanvas *) CanvasFromView(nsIView * aView);
|
||||
NS_IMETHOD GetRootCanvas(nsIXPFCCanvas ** aCanvas);
|
||||
NS_IMETHOD SetRootCanvas(nsIXPFCCanvas * aCanvas);
|
||||
NS_IMETHOD Register(nsIXPFCCanvas * aCanvas, nsIWidget * aWidget);
|
||||
NS_IMETHOD Register(nsIXPFCCanvas * aCanvas, nsIView * aView);
|
||||
NS_IMETHOD Unregister(nsIXPFCCanvas * aCanvas);
|
||||
NS_IMETHOD_(nsIXPFCCanvas *) GetFocusedCanvas();
|
||||
NS_IMETHOD SetFocusedCanvas(nsIXPFCCanvas * aCanvas);
|
||||
|
||||
// nsIViewObserver Interfaces
|
||||
NS_IMETHOD Paint(nsIView * aView,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
NS_IMETHOD HandleEvent(nsIView * aView,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus);
|
||||
NS_IMETHOD Scrolled(nsIView * aView);
|
||||
NS_IMETHOD ResizeReflow(nsIView * aView, nscoord aWidth, nscoord aHeight);
|
||||
|
||||
|
||||
protected:
|
||||
~nsXPFCCanvasManager();
|
||||
|
||||
|
||||
@ -38,7 +38,9 @@ public:
|
||||
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
|
||||
|
||||
NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) OnPaint(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
NS_IMETHOD_(nsEventStatus) OnResize(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD GetClassPreferredSize(nsSize& aSize);
|
||||
|
||||
|
||||
@ -128,7 +128,8 @@ public:
|
||||
* @param aEvent The GUI Event to be handled
|
||||
* @result nsEventStatus, status of OnPaint event processing
|
||||
*/
|
||||
NS_IMETHOD_(nsEventStatus) OnPaint(nsGUIEvent *aEvent) = 0;
|
||||
NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect) = 0;
|
||||
|
||||
/**
|
||||
* Handle an OnResize Message
|
||||
@ -557,7 +558,7 @@ public:
|
||||
* @param aRenderingContext, rendering context to save state to
|
||||
* @result nsresult, NS_OK if successful
|
||||
*/
|
||||
NS_IMETHOD PushState(nsIRenderingContext * aRenderingContext) = 0;
|
||||
NS_IMETHOD PushState(nsIRenderingContext& aRenderingContext) = 0;
|
||||
|
||||
/**
|
||||
* Get and and set RenderingContext to this graphical state
|
||||
@ -565,7 +566,7 @@ public:
|
||||
* @return if PR_TRUE, indicates that the clipping region after
|
||||
* popping state is empty, else PR_FALSE
|
||||
*/
|
||||
NS_IMETHOD_(PRBool) PopState(nsIRenderingContext * aRenderingContext) = 0;
|
||||
NS_IMETHOD_(PRBool) PopState(nsIRenderingContext& aRenderingContext) = 0;
|
||||
|
||||
/**
|
||||
* Set the tab id for this canvas
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIXPFCCanvas;
|
||||
class nsIWidget;
|
||||
class nsIView;
|
||||
|
||||
// IID for the nsIXPFCCanvasManager interface
|
||||
#define NS_IXPFC_CANVAS_MANAGER_IID \
|
||||
@ -49,7 +49,7 @@ public:
|
||||
* @param aWidget the widget aggregated by the canvas
|
||||
* @result nsIXPFCCanvas pointer, The resultant canvas, nsnull if none found
|
||||
*/
|
||||
NS_IMETHOD_(nsIXPFCCanvas *) CanvasFromWidget(nsIWidget * aWidget) = 0;
|
||||
NS_IMETHOD_(nsIXPFCCanvas *) CanvasFromView(nsIView * aView) = 0;
|
||||
|
||||
/**
|
||||
* Get a reference to the root canvas
|
||||
@ -72,7 +72,7 @@ public:
|
||||
* @result nsresult, NS_OK if successful
|
||||
*/
|
||||
NS_IMETHOD Register(nsIXPFCCanvas * aCanvas,
|
||||
nsIWidget * aWidget) = 0;
|
||||
nsIView * aView) = 0;
|
||||
|
||||
/**
|
||||
* UnRegister an association between a canvas and a widget
|
||||
|
||||
@ -39,7 +39,6 @@
|
||||
#include "nsXPFCMethodInvokerCommand.h"
|
||||
|
||||
#include "nsXPFCToolkit.h"
|
||||
#include "nsIViewObserver.h"
|
||||
|
||||
#include "nsIButton.h"
|
||||
#include "nsITabWidget.h"
|
||||
@ -110,6 +109,8 @@ nsXPFCCanvas :: nsXPFCCanvas(nsISupports* outer) :
|
||||
mImageGroup = nsnull;
|
||||
mImageRequest = nsnull;
|
||||
|
||||
mView = nsnull;
|
||||
|
||||
}
|
||||
|
||||
nsXPFCCanvas :: ~nsXPFCCanvas()
|
||||
@ -132,6 +133,7 @@ nsXPFCCanvas :: ~nsXPFCCanvas()
|
||||
NS_RELEASE(mImageGroup);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
NS_IMPL_AGGREGATED(nsXPFCCanvas)
|
||||
@ -145,7 +147,6 @@ nsresult nsXPFCCanvas::AggregatedQueryInterface(const nsIID &aIID,
|
||||
|
||||
static NS_DEFINE_IID(kCXPFCCanvasIID, NS_XPFC_CANVAS_CID);
|
||||
static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID);
|
||||
static NS_DEFINE_IID(kIViewObserverIID, NS_IVIEWOBSERVER_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kClassIID, kIXPFCCanvasIID);
|
||||
|
||||
@ -169,11 +170,6 @@ nsresult nsXPFCCanvas::AggregatedQueryInterface(const nsIID &aIID,
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIViewObserverIID)) {
|
||||
*aInstancePtr = (void*)((nsIViewObserver*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*) ((nsISupports *)&fAggregated);
|
||||
AddRef();
|
||||
@ -815,27 +811,26 @@ nsEventStatus nsXPFCCanvas :: DefaultProcessing(nsGUIEvent *aEvent)
|
||||
return (nsEventStatus_eIgnore);
|
||||
}
|
||||
|
||||
nsEventStatus nsXPFCCanvas :: OnPaint(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsXPFCCanvas :: OnPaint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
|
||||
if (mVisibility == PR_TRUE)
|
||||
{
|
||||
nsIRenderingContext * ctx = ((nsPaintEvent*)aEvent)->renderingContext;
|
||||
PushState(aRenderingContext);
|
||||
|
||||
PushState(ctx);
|
||||
PaintBackground(aRenderingContext, aDirtyRect);
|
||||
PaintBorder(aRenderingContext, aDirtyRect);
|
||||
PaintForeground(aRenderingContext, aDirtyRect);
|
||||
|
||||
PaintBackground(aEvent);
|
||||
PaintBorder(aEvent);
|
||||
PaintForeground(aEvent);
|
||||
|
||||
PopState(ctx);
|
||||
PopState(aRenderingContext);
|
||||
}
|
||||
|
||||
|
||||
PaintChildWidgets(aEvent);
|
||||
PaintChildWidgets(aRenderingContext, aDirtyRect);
|
||||
|
||||
|
||||
return (DefaultProcessing(aEvent));
|
||||
return (DefaultProcessing(nsnull));
|
||||
|
||||
}
|
||||
|
||||
@ -1125,55 +1120,57 @@ nscolor nsXPFCCanvas :: Dim(const nscolor &aColor)
|
||||
}
|
||||
|
||||
|
||||
nsEventStatus nsXPFCCanvas :: PaintBackground(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsXPFCCanvas :: PaintBackground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
|
||||
nsRect rect;
|
||||
|
||||
// Paint The Background
|
||||
nsIRenderingContext * rndctx = ((nsPaintEvent*)aEvent)->renderingContext;
|
||||
GetBounds(rect);
|
||||
nsIImage *img;
|
||||
|
||||
if ((nsnull == mImageRequest) || (nsnull == (img = mImageRequest->GetImage())))
|
||||
{
|
||||
rndctx->SetColor(GetBackgroundColor());
|
||||
rndctx->FillRect(rect);
|
||||
aRenderingContext.SetColor(GetBackgroundColor());
|
||||
aRenderingContext.FillRect(rect);
|
||||
} else
|
||||
{
|
||||
rndctx->DrawImage(img, mBounds.x, mBounds.y);
|
||||
aRenderingContext.DrawImage(img, mBounds.x, mBounds.y);
|
||||
NS_RELEASE(img);
|
||||
}
|
||||
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
||||
nsEventStatus nsXPFCCanvas :: PaintBorder(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsXPFCCanvas :: PaintBorder(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
nsRect rect;
|
||||
|
||||
nsIRenderingContext * rndctx = ((nsPaintEvent*)aEvent)->renderingContext;
|
||||
GetBounds(rect);
|
||||
|
||||
rect.x++; rect.y++; rect.width-=2; rect.height-=2;
|
||||
|
||||
rndctx->SetColor(Highlight(GetBorderColor()));
|
||||
rndctx->DrawLine(rect.x,rect.y,rect.x+rect.width,rect.y);
|
||||
rndctx->DrawLine(rect.x,rect.y,rect.x,rect.y+rect.height);
|
||||
aRenderingContext.SetColor(Highlight(GetBorderColor()));
|
||||
aRenderingContext.DrawLine(rect.x,rect.y,rect.x+rect.width,rect.y);
|
||||
aRenderingContext.DrawLine(rect.x,rect.y,rect.x,rect.y+rect.height);
|
||||
|
||||
rndctx->SetColor(Dim(GetBorderColor()));
|
||||
rndctx->DrawLine(rect.x+rect.width,rect.y,rect.x+rect.width,rect.y+rect.height);
|
||||
rndctx->DrawLine(rect.x,rect.y+rect.height,rect.x+rect.width,rect.y+rect.height);
|
||||
aRenderingContext.SetColor(Dim(GetBorderColor()));
|
||||
aRenderingContext.DrawLine(rect.x+rect.width,rect.y,rect.x+rect.width,rect.y+rect.height);
|
||||
aRenderingContext.DrawLine(rect.x,rect.y+rect.height,rect.x+rect.width,rect.y+rect.height);
|
||||
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
||||
nsEventStatus nsXPFCCanvas :: PaintForeground(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsXPFCCanvas :: PaintForeground(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
||||
nsEventStatus nsXPFCCanvas :: PaintChildWidgets(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsXPFCCanvas :: PaintChildWidgets(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
nsresult res ;
|
||||
nsIIterator * iterator ;
|
||||
@ -1197,7 +1194,7 @@ nsEventStatus nsXPFCCanvas :: PaintChildWidgets(nsGUIEvent *aEvent)
|
||||
if (rect.width != 0 && rect.height != 0)
|
||||
{
|
||||
if (((nsXPFCCanvas *)widget)->mWidget == nsnull) {
|
||||
widget->OnPaint(aEvent);
|
||||
widget->OnPaint(aRenderingContext,aDirtyRect);
|
||||
} else {
|
||||
((nsXPFCCanvas *)widget)->mWidget->Invalidate(PR_FALSE);
|
||||
}
|
||||
@ -1269,7 +1266,7 @@ nsEventStatus nsXPFCCanvas :: HandleEvent(nsGUIEvent *aEvent)
|
||||
ds = ctx->CreateDrawingSurface(&rect);
|
||||
ctx->SelectOffScreenDrawingSurface(ds);
|
||||
|
||||
es = OnPaint(aEvent);
|
||||
es = OnPaint((*((nsPaintEvent*)aEvent)->renderingContext),(*((nsPaintEvent*)aEvent)->rect));
|
||||
|
||||
ctx->CopyOffScreenBits(rect);
|
||||
ctx->DestroyDrawingSurface(ds);
|
||||
@ -2002,18 +1999,18 @@ nsresult nsXPFCCanvas::GetFontMetrics(nsIFontMetrics ** aFontMetrics)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXPFCCanvas::PushState(nsIRenderingContext * aRenderingContext)
|
||||
nsresult nsXPFCCanvas::PushState(nsIRenderingContext& aRenderingContext)
|
||||
{
|
||||
aRenderingContext->PushState();
|
||||
aRenderingContext.PushState();
|
||||
|
||||
aRenderingContext->SetFont(mFont);
|
||||
aRenderingContext.SetFont(mFont);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsXPFCCanvas::PopState(nsIRenderingContext * aRenderingContext)
|
||||
PRBool nsXPFCCanvas::PopState(nsIRenderingContext& aRenderingContext)
|
||||
{
|
||||
return (aRenderingContext->PopState());
|
||||
return (aRenderingContext.PopState());
|
||||
}
|
||||
|
||||
void nsXPFCCanvas::Notify(nsIImageRequest *aImageRequest,
|
||||
@ -2033,27 +2030,3 @@ void nsXPFCCanvas::NotifyError(nsIImageRequest *aImageRequest,
|
||||
|
||||
|
||||
|
||||
nsresult nsXPFCCanvas::Paint(nsIView * aView,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXPFCCanvas::HandleEvent(nsIView * aView,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXPFCCanvas::Scrolled(nsIView * aView)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXPFCCanvas::ResizeReflow(nsIView * aView, nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -18,22 +18,23 @@
|
||||
|
||||
#include "nsXPFCCanvasManager.h"
|
||||
#include "nsIXPFCCanvas.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsxpfcCIID.h"
|
||||
#include "nsIViewObserver.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kXPFCCanvasManagerIID, NS_IXPFC_CANVAS_MANAGER_IID);
|
||||
|
||||
static NS_DEFINE_IID(kCXPFCCanvasIID, NS_IXPFC_CANVAS_IID);
|
||||
static NS_DEFINE_IID(kCXPFCCanvasIID, NS_IXPFC_CANVAS_IID);
|
||||
static NS_DEFINE_IID(kIViewObserverIID, NS_IVIEWOBSERVER_IID);
|
||||
|
||||
class ListEntry {
|
||||
public:
|
||||
nsIWidget * widget;
|
||||
nsIView * view;
|
||||
nsIXPFCCanvas * canvas;
|
||||
|
||||
ListEntry(nsIWidget * aWidget,
|
||||
ListEntry(nsIView * aView,
|
||||
nsIXPFCCanvas * aCanvas) {
|
||||
widget = aWidget;
|
||||
view = aView;
|
||||
canvas = aCanvas;
|
||||
}
|
||||
~ListEntry() {
|
||||
@ -59,7 +60,33 @@ nsXPFCCanvasManager :: ~nsXPFCCanvasManager()
|
||||
|
||||
NS_IMPL_ADDREF(nsXPFCCanvasManager)
|
||||
NS_IMPL_RELEASE(nsXPFCCanvasManager)
|
||||
NS_IMPL_QUERY_INTERFACE(nsXPFCCanvasManager, kXPFCCanvasManagerIID)
|
||||
|
||||
nsresult nsXPFCCanvasManager::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kClassIID, kXPFCCanvasManagerIID);
|
||||
if (aIID.Equals(kClassIID)) {
|
||||
*aInstancePtr = (void*) (nsXPFCCanvasManager *)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*) (this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIViewObserverIID)) {
|
||||
*aInstancePtr = (void*)((nsIViewObserver*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return (NS_ERROR_NO_INTERFACE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult nsXPFCCanvasManager::Init()
|
||||
{
|
||||
@ -86,7 +113,7 @@ nsresult nsXPFCCanvasManager::Init()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIXPFCCanvas * nsXPFCCanvasManager::CanvasFromWidget(nsIWidget * aWidget)
|
||||
nsIXPFCCanvas * nsXPFCCanvasManager::CanvasFromView(nsIView * aView)
|
||||
{
|
||||
nsIXPFCCanvas * canvas = nsnull;
|
||||
|
||||
@ -104,7 +131,7 @@ nsIXPFCCanvas * nsXPFCCanvasManager::CanvasFromWidget(nsIWidget * aWidget)
|
||||
{
|
||||
item = (ListEntry *) iterator->CurrentItem();
|
||||
|
||||
if (item->widget == aWidget)
|
||||
if (item->view == aView)
|
||||
{
|
||||
canvas = item->canvas;
|
||||
break;
|
||||
@ -120,11 +147,11 @@ nsIXPFCCanvas * nsXPFCCanvasManager::CanvasFromWidget(nsIWidget * aWidget)
|
||||
return (canvas);
|
||||
}
|
||||
|
||||
nsresult nsXPFCCanvasManager::Register(nsIXPFCCanvas * aCanvas, nsIWidget * aWidget)
|
||||
nsresult nsXPFCCanvasManager::Register(nsIXPFCCanvas * aCanvas, nsIView * aView)
|
||||
{
|
||||
PR_EnterMonitor(monitor);
|
||||
|
||||
mList->Append(new ListEntry(aWidget, aCanvas));
|
||||
mList->Append(new ListEntry(aView, aCanvas));
|
||||
|
||||
PR_ExitMonitor(monitor);
|
||||
|
||||
@ -195,3 +222,52 @@ nsIXPFCCanvas * nsXPFCCanvasManager::GetFocusedCanvas()
|
||||
{
|
||||
return(mFocusedCanvas);
|
||||
}
|
||||
|
||||
nsresult nsXPFCCanvasManager::Paint(nsIView * aView,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
nsIXPFCCanvas * canvas = CanvasFromView(aView);
|
||||
|
||||
if (canvas == nsnull)
|
||||
return NS_OK;
|
||||
|
||||
canvas->OnPaint(aRenderingContext, aDirtyRect);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXPFCCanvasManager::HandleEvent(nsIView * aView,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
nsIXPFCCanvas * canvas = CanvasFromView(aView);
|
||||
|
||||
if (canvas == nsnull)
|
||||
return NS_OK;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXPFCCanvasManager::Scrolled(nsIView * aView)
|
||||
{
|
||||
nsIXPFCCanvas * canvas = CanvasFromView(aView);
|
||||
|
||||
if (canvas == nsnull)
|
||||
return NS_OK;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXPFCCanvasManager::ResizeReflow(nsIView * aView,
|
||||
nscoord aWidth,
|
||||
nscoord aHeight)
|
||||
{
|
||||
nsIXPFCCanvas * canvas = CanvasFromView(aView);
|
||||
|
||||
if (canvas == nsnull)
|
||||
return NS_OK;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -112,9 +112,11 @@ nsresult nsXPFCHTMLCanvas :: SetBounds(const nsRect &aBounds)
|
||||
}
|
||||
|
||||
|
||||
nsEventStatus nsXPFCHTMLCanvas :: OnPaint(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsXPFCHTMLCanvas :: OnPaint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
|
||||
{
|
||||
nsEventStatus es = nsXPFCCanvas::OnPaint(aEvent);
|
||||
nsEventStatus es = nsXPFCCanvas::OnPaint(aRenderingContext,aDirtyRect);
|
||||
if (mWebShell != nsnull)
|
||||
mWebShell->Repaint(PR_FALSE);
|
||||
return (es);
|
||||
|
||||
@ -137,7 +137,7 @@ nsresult nsxpfcFactory::CreateInstance(nsISupports *aOuter,
|
||||
} else if (mClassID.Equals(kCXPFCSubject)) {
|
||||
inst = (nsISupports *)new nsXPFCSubject();
|
||||
} else if (mClassID.Equals(kCXPFCCanvasManager)) {
|
||||
inst = (nsISupports *)new nsXPFCCanvasManager();
|
||||
inst = (nsISupports *)(nsIXPFCCanvasManager *)new nsXPFCCanvasManager();
|
||||
} else if (mClassID.Equals(kCXPFCCommand)) {
|
||||
inst = (nsISupports *)new nsXPFCCommand();
|
||||
} else if (mClassID.Equals(kCXPFCCommandServerCID)) {
|
||||
|
||||
@ -40,7 +40,8 @@ public:
|
||||
|
||||
NS_IMETHOD SetLabel(nsString& aString);
|
||||
NS_IMETHOD SetBounds(const nsRect& aBounds);
|
||||
NS_IMETHOD_(nsEventStatus) OnPaint(nsGUIEvent *aEvent);
|
||||
NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
protected:
|
||||
~nsXPFCButton();
|
||||
|
||||
@ -198,12 +198,13 @@ nsresult nsXPFCButton :: SetBounds(const nsRect &aBounds)
|
||||
|
||||
}
|
||||
|
||||
nsEventStatus nsXPFCButton :: OnPaint(nsGUIEvent *aEvent)
|
||||
nsEventStatus nsXPFCButton :: OnPaint(nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
if (GetLabel() == "Throbber")
|
||||
{
|
||||
mThrobber->Hide();
|
||||
mThrobber->Show();
|
||||
}
|
||||
return (nsXPFCCanvas::OnPaint(aEvent));
|
||||
return (nsXPFCCanvas::OnPaint(aRenderingContext,aDirtyRect));
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user