XPFC Implementation on top ov Views

git-svn-id: svn://10.0.0.236/trunk@10767 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
spider%netscape.com
1998-09-23 03:40:00 +00:00
parent 71efef1ee4
commit 3eefd2153b
27 changed files with 520 additions and 494 deletions

View File

@@ -224,10 +224,10 @@ NS_IMETHODIMP nsCalXMLContentSink::OpenContainer(const nsIParserNode& aNode)
if (NS_OK != res)
return res ;
object->Init();
AddToHierarchy(*object, PR_TRUE);
object->Init();
/*
* ConsumeAttributes
*/
@@ -457,10 +457,10 @@ NS_IMETHODIMP nsCalXMLContentSink::AddLeaf(const nsIParserNode& aNode)
if (NS_OK != res)
return res ;
object->Init();
AddToHierarchy(*object, PR_FALSE);
object->Init();
ConsumeAttributes(aNode,*object);
return NS_OK;
@@ -923,8 +923,13 @@ NS_IMETHODIMP nsCalXMLContentSink::DidBuildModel(PRInt32 aQualityLevel)
root->Layout();
if (root->GetWidget())
root->GetWidget()->Invalidate(PR_FALSE);
if (root->GetView())
{
nsRect bounds;
root->GetView()->GetBounds(bounds);
gXPFCToolkit->GetViewManager()->UpdateView(root->GetView(), bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER);
}
NS_RELEASE(root);

View File

@@ -17,6 +17,7 @@ CFLAGS +=-D_IMPL_NS_CALENDAR
LD_LIBS += \
raptorbase \
$(NATIVE_RAPTOR_GFX) \
raptorhtmlpars \
$(NATIVE_JULIAN_DLL) \
xpcom$(MOZ_BITS) \

View File

@@ -50,7 +50,7 @@ public:
nsScrollPreference aScrolling = nsScrollPreference_kAuto);
NS_IMETHOD Init(nsIWidget * aParent,
NS_IMETHOD Init(nsIView * aParent,
const nsRect& aBounds,
nsICalendarShell * aCalendarShell);

View File

@@ -47,7 +47,7 @@ public:
nsIPref* aPrefs,
const nsRect& aBounds,
nsScrollPreference aScrolling = nsScrollPreference_kAuto) = 0;
NS_IMETHOD Init(nsIWidget * aParent,
NS_IMETHOD Init(nsIView * aParent,
const nsRect& aBounds,
nsICalendarShell * aCalendarShell) = 0;

View File

@@ -93,12 +93,10 @@ nsCalendarContainer::~nsCalendarContainer()
}
nsresult nsCalendarContainer::Init(nsIWidget * aParent,
const nsRect& aBounds,
nsICalendarShell * aCalendarShell)
const nsRect& aBounds,
nsICalendarShell * aCalendarShell)
{
nsIWidget * widget_parent = nsnull;
RegisterFactories();
/*
@@ -176,14 +174,17 @@ nsresult nsCalendarContainer::Init(nsIWidget * aParent,
(void **)&mRootCanvas);
mRootCanvas->Init();
gXPFCToolkit->GetCanvasManager()->SetRootCanvas(mRootCanvas);
mRootCanvas->Init(aParent,
aBounds,
(((nsCalendarShell *)aCalendarShell)->mShellInstance->GetShellEventCallback()));
widget_parent = mRootCanvas->GetWidget();
nsNativeWidget native = aParent->GetNativeData(NS_NATIVE_WIDGET);
mRootCanvas->SetVisibility(PR_FALSE);
mRootCanvas->Init(native,
aBounds);
gXPFCToolkit->GetViewManager()->SetRootView(mRootCanvas->GetView());
//mRootCanvas->SetVisibility(PR_FALSE);
((nsBoxLayout *)(mRootCanvas->GetLayout()))->SetLayoutAlignment(eLayoutAlignment_vertical);
@@ -208,7 +209,7 @@ nsresult nsCalendarContainer::Init(nsIWidget * aParent,
* Widget itself should implement the nsIXPFCCanvas interface?
*/
res = mCalendarWidget->Init(widget_parent, aBounds, aCalendarShell);
res = mCalendarWidget->Init(mRootCanvas->GetView(), aBounds, aCalendarShell);
mRootCanvas->Layout();
@@ -279,44 +280,10 @@ nsresult nsCalendarContainer::AddToolbar(nsIXPFCToolbar * aToolbar)
*/
static NS_DEFINE_IID(kCWidgetCID, NS_CHILD_CID);
nsIWidget * parent = canvas->GetWidget();
nsIView * parent = canvas->GetView();
res = canvas->LoadWidget(kCWidgetCID);
res = canvas->LoadView(kViewCID);
/*
* Now, get the aggregated widget interface, and show this puppy
*/
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
nsIWidget * widget = nsnull;
res = aToolbar->QueryInterface(kIWidgetIID,(void**)&widget);
if (NS_OK == res)
{
nsRect rect(400,0,400,600);
nsSize size;
nsWidgetInitData initData ;
initData.clipChildren = PR_FALSE;
canvas->GetClassPreferredSize(size);
canvas->SetPreferredSize(size);
widget->Create(parent,
rect,
(((nsCalendarShell *)mCalendarShell)->mShellInstance->GetShellEventCallback()),
nsnull, nsnull, nsnull, &initData);
widget->Show(PR_TRUE);
NS_RELEASE(widget);
}
NS_RELEASE(canvas);
}
@@ -341,6 +308,7 @@ nsresult nsCalendarContainer::UpdateToolbars()
return NS_OK;
mRootCanvas->Layout();
w->Invalidate(PR_FALSE);
return NS_OK;
@@ -354,58 +322,26 @@ nsresult nsCalendarContainer::ShowDialog(nsIXPFCDialog * aDialog)
if (NS_OK == res)
{
//mRootCanvas->AddChildCanvas(canvas,0);
/*
* Let's add a native widget here. This code should be in XPFC
*/
/*
* We want to instantiate a window widget which the canvas
* aggregates.
*/
static NS_DEFINE_IID(kCWidgetCID, NS_WINDOW_CID);
nsIWidget * parent = mRootCanvas->GetWidget();
nsIView * parent = canvas->GetView();
res = canvas->LoadWidget(kCWidgetCID);
res = canvas->LoadView(kViewCID, &kCWidgetCID, nsnull);
/*
* Now, get the aggregated widget interface, and show this puppy
*/
nsIWidget * widget ;
canvas->GetView()->GetWidget(widget);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
nsIWidget * widget = nsnull;
widget->SetBorderStyle(eBorderStyle_dialog);
res = aDialog->QueryInterface(kIWidgetIID,(void**)&widget);
NS_RELEASE(widget);
if (NS_OK == res)
{
nsRect rect(400,0,400,600);
nsWidgetInitData initData ;
initData.clipChildren = PR_FALSE;
canvas->SetBounds(rect);
widget->SetBorderStyle(eBorderStyle_dialog);
widget->Create(parent,
rect,
(((nsCalendarShell *)mCalendarShell)->mShellInstance->GetShellEventCallback()),
nsnull, nsnull, nsnull, &initData);
widget->Resize(400,601,PR_FALSE);
widget->Show(PR_TRUE);
NS_RELEASE(widget);
}
nsRect rect(400,0,400,600);
canvas->SetBounds(rect);
NS_RELEASE(canvas);
}
return NS_OK;
}

View File

@@ -75,6 +75,7 @@ class nsICalendarShell;
#include "nsICalendarShell.h"
#include "nsCalendarShell.h"
#include "nsIView.h"
#include "plstr.h"
#include "prprf.h" /* PR_snprintf(...) */
@@ -126,7 +127,7 @@ nsresult nsCalendarWidget::Init(nsNativeWidget aNativeParent,
return NS_OK;
}
nsresult nsCalendarWidget::Init(nsIWidget * aParent,
nsresult nsCalendarWidget::Init(nsIView * aParent,
const nsRect& aBounds,
nsICalendarShell * aCalendarShell)
{
@@ -134,6 +135,7 @@ nsresult nsCalendarWidget::Init(nsIWidget * aParent,
nsresult res ;
mCalendarShell = aCalendarShell;
nsIXPFCCanvas * root;
NS_ADDREF(((nsIApplicationShell *)mCalendarShell));
@@ -154,12 +156,9 @@ nsresult nsCalendarWidget::Init(nsIWidget * aParent,
if (NS_OK != res)
return res ;
//gXPFCToolkit->GetCanvasManager()->SetRootCanvas(root);
root->Init();
//root->Init(aParent, aBounds,(((nsCalendarShell *)mCalendarShell)->mShellInstance->GetShellEventCallback()));
nsIXPFCCanvas * root_canvas ;
gXPFCToolkit->GetRootCanvas(&root_canvas);

View File

@@ -21,6 +21,7 @@
#include "nsXPFCCanvas.h"
#include "nsIView.h"
#include "nsIWidget.h"
#include "nsITextWidget.h"
#include "nsIXPFCSubject.h"
@@ -57,8 +58,8 @@ public:
private:
nsITextWidget * mTextField;
nsITextWidget * mStaticTextField;
nsIView * mTextField;
nsIView * mStaticTextField;
};

View File

@@ -36,6 +36,7 @@ public:
NS_IMETHOD_(void) SetBackgroundColor(const nscolor &aColor) ;
NS_IMETHOD_(nsEventStatus) OnPaint(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent);
protected:
~nsCalTodoComponentCanvas();

View File

@@ -27,6 +27,8 @@
#include "nsIDeviceContext.h"
#include "nsFont.h"
#include "nsIFontMetrics.h"
#include "nsViewsCID.h"
#include "nsIViewManager.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kCalCommandCanvasCID, NS_CAL_COMMANDCANVAS_CID);
@@ -40,13 +42,11 @@ static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID);
#define DEFAULT_WIDTH 25
#define DEFAULT_HEIGHT 25
nsEventStatus PR_CALLBACK HandleEventTextField(nsGUIEvent *aEvent);
nsCalCommandCanvas :: nsCalCommandCanvas(nsISupports* outer) : nsXPFCCanvas(outer)
{
NS_INIT_REFCNT();
mStaticTextField = nsnull;
mTextField = nsnull;
mTextField = nsnull;
}
nsCalCommandCanvas :: ~nsCalCommandCanvas()
@@ -54,8 +54,11 @@ nsCalCommandCanvas :: ~nsCalCommandCanvas()
gXPFCToolkit->GetCanvasManager()->Unregister(this);
NS_IF_RELEASE(mStaticTextField);
NS_IF_RELEASE(mTextField);
if (mStaticTextField != nsnull)
mStaticTextField->Destroy();
if (mTextField != nsnull)
mTextField->Destroy();
}
nsresult nsCalCommandCanvas::QueryInterface(REFNSIID aIID, void** aInstancePtr)
@@ -90,6 +93,7 @@ NS_IMPL_RELEASE(nsCalCommandCanvas)
nsresult nsCalCommandCanvas :: Init()
{
nsRect rect;
nsresult res = NS_OK;
GetBounds(rect);
@@ -99,12 +103,19 @@ nsresult nsCalCommandCanvas :: Init()
nsString text("COMMAND: ");
nsRepository::CreateInstance(kCTextFieldCID,
nsnull,
kITextWidgetIID,
(void **)&mStaticTextField);
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
res = nsRepository::CreateInstance(kViewCID,
nsnull,
kIViewIID,
(void**)&mStaticTextField);
if (NS_OK != res)
return res;
gXPFCToolkit->GetCanvasManager()->RegisterView((nsIXPFCCanvas*)this,mStaticTextField);
nsFont font("Times", NS_FONT_STYLE_NORMAL,
NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_BOLD,
@@ -112,8 +123,13 @@ nsresult nsCalCommandCanvas :: Init()
8);
nsIFontMetrics * fm ;
nsIDeviceContext * ctx;
GetWidget()->GetDeviceContext()->GetMetricsFor(font, fm);
gXPFCToolkit->GetViewManager()->GetDeviceContext(ctx);
ctx->GetMetricsFor(font, fm);
NS_RELEASE(ctx);
nscoord width ;
@@ -121,27 +137,30 @@ nsresult nsCalCommandCanvas :: Init()
rect.width = width ;
mStaticTextField->Init(gXPFCToolkit->GetViewManager(),
rect,
GetParent()->GetView(),
&kCTextFieldCID);
nsIWidget * widget = nsnull;
nsresult res = mStaticTextField->QueryInterface(kIWidgetIID,(void**)&widget);
mStaticTextField->GetWidget(widget);
if (NS_OK == res)
{
PRBool old;
PRBool old;
nsITextWidget * text_widget = nsnull;
mStaticTextField->SetReadOnly(PR_TRUE,old);
res = widget->QueryInterface(kITextWidgetIID,(void**)&text_widget);
widget->Create(GetWidget(),
rect,
HandleEventTextField,
nsnull, nsnull, nsnull);
text_widget->SetReadOnly(PR_TRUE,old);
PRUint32 length;
mStaticTextField->SetText(text,length);
widget->Show(PR_TRUE);
NS_RELEASE(widget);
}
PRUint32 length;
text_widget->SetText(text,length);
NS_RELEASE(widget);
NS_RELEASE(text_widget);
/*
* Writeable Command field
@@ -151,55 +170,34 @@ nsresult nsCalCommandCanvas :: Init()
rect.x += width;
rect.width -= width;
nsRepository::CreateInstance(kCTextFieldCID,
nsnull,
kITextWidgetIID,
(void **)&mTextField);
widget = nsnull;
res = mTextField->QueryInterface(kIWidgetIID,(void**)&widget);
if (NS_OK == res)
{
widget->Create(GetWidget(),
rect,
HandleEventTextField,
NULL);
text = "TimebarScale setbackgroundcolor #FF0000";
PRUint32 length;
mTextField->SetText(text,length);
widget->Show(PR_TRUE);
NS_RELEASE(widget);
}
return NS_OK;
}
// XXX: todo: we should be passing commands off rather than calling
// directly, and we need to put this code in the topmost event
// loop and call a method of the canvas containing the widget.
// ........
nsEventStatus PR_CALLBACK HandleEventTextField(nsGUIEvent *aEvent)
{
if (gXPFCToolkit == nsnull)
return nsEventStatus_eIgnore;
nsIXPFCCanvas * canvas = nsnull ;
nsresult res = aEvent->widget->QueryInterface(kIXPFCCanvasIID,(void**)&canvas);
res = nsRepository::CreateInstance(kViewCID,
nsnull,
kIViewIID,
(void**)&mTextField);
if (NS_OK != res)
return nsEventStatus_eIgnore;
return res;
if (canvas)
return (canvas->HandleEvent(aEvent));
gXPFCToolkit->GetCanvasManager()->RegisterView((nsIXPFCCanvas*)this,mTextField);
widget = nsnull;
return nsEventStatus_eIgnore;
mTextField->GetWidget(widget);
mTextField->Init(gXPFCToolkit->GetViewManager(),
rect,
GetParent()->GetView(),
&kCTextFieldCID);
text = "TimebarScale setbackgroundcolor #FF0000";
mTextField->GetWidget(widget);
res = widget->QueryInterface(kITextWidgetIID,(void**)&text_widget);
text_widget->SetText(text,length);
NS_RELEASE(widget);
NS_RELEASE(text_widget);
return NS_OK;
}
nsEventStatus nsCalCommandCanvas :: OnResize(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
@@ -212,61 +210,50 @@ nsEventStatus nsCalCommandCanvas :: OnResize(nscoord aX, nscoord aY, nscoord aWi
nsresult nsCalCommandCanvas :: SetBounds(const nsRect &aBounds)
{
nsXPFCCanvas::SetBounds(aBounds);
nsRect rect = aBounds;
nscoord width = 0;
if (mStaticTextField) {
nsIWidget * widget = nsnull;
nsresult res = mStaticTextField->QueryInterface(kIWidgetIID,(void**)&widget);
nsString text("COMMAND: ");
if (NS_OK == res)
{
nsFont font("Times", NS_FONT_STYLE_NORMAL,
NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_BOLD,
0,
8);
nsString text("COMMAND: ");
nsFont font("Times", NS_FONT_STYLE_NORMAL,
NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_BOLD,
0,
8);
nsIFontMetrics * fm ;
nsIFontMetrics * fm ;
nsIDeviceContext * ctx;
gXPFCToolkit->GetViewManager()->GetDeviceContext(ctx);
widget->GetDeviceContext()->GetMetricsFor(font,fm);
ctx->GetMetricsFor(font,fm);
fm->GetWidth(text,width);
NS_RELEASE(ctx);
rect.width = width ;
fm->GetWidth(text,width);
widget->Invalidate(PR_FALSE);
widget->Resize(rect.x, rect.y, rect.width, rect.height, PR_FALSE);
NS_RELEASE(widget);
}
rect.width = width ;
gXPFCToolkit->GetViewManager()->MoveViewTo(mStaticTextField, rect.x, rect.y);
gXPFCToolkit->GetViewManager()->ResizeView(mStaticTextField, rect.width, rect.height);
gXPFCToolkit->GetViewManager()->UpdateView(mStaticTextField, rect, NS_VMREFRESH_AUTO_DOUBLE_BUFFER) ;
}
if (mTextField) {
nsIWidget * widget = nsnull;
nsresult res = mTextField->QueryInterface(kIWidgetIID,(void**)&widget);
rect = aBounds;
if (NS_OK == res)
{
rect = aBounds;
rect.x += (width);
rect.width = aBounds.width - (width);
rect.x += (width);
rect.width -= (width);
gXPFCToolkit->GetViewManager()->MoveViewTo(mTextField, rect.x, rect.y);
gXPFCToolkit->GetViewManager()->ResizeView(mTextField, rect.width, rect.height);
gXPFCToolkit->GetViewManager()->UpdateView(mTextField, rect, NS_VMREFRESH_AUTO_DOUBLE_BUFFER) ;
widget->Invalidate(PR_FALSE);
widget->Resize(rect.x, rect.y, rect.width, rect.height, PR_FALSE);
NS_RELEASE(widget);
}
}
return NS_OK;
@@ -276,15 +263,6 @@ nsresult nsCalCommandCanvas :: SetBounds(const nsRect &aBounds)
nsEventStatus nsCalCommandCanvas :: OnPaint(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
{
nsIWidget * widget = nsnull;
nsresult res = mTextField->QueryInterface(kIWidgetIID,(void**)&widget);
widget->Invalidate(PR_FALSE);
NS_RELEASE(widget);
res = mStaticTextField->QueryInterface(kIWidgetIID,(void**)&widget);
widget->Invalidate(PR_FALSE);
NS_RELEASE(widget);
return nsEventStatus_eConsumeNoDefault;
}

View File

@@ -21,6 +21,9 @@
#include "nsIListWidget.h"
#include "nsWidgetsCID.h"
#include "nsIDeviceContext.h"
#include "nsViewsCID.h"
#include "nsIViewManager.h"
#include "nsCalToolkit.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
@@ -29,13 +32,11 @@ static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID);
static NS_DEFINE_IID(kIListWidgetIID, NS_ILISTWIDGET_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
static NS_DEFINE_IID(kCListWidgetCID, NS_LISTBOX_CID);
nsEventStatus PR_CALLBACK HandleEventListWidget(nsGUIEvent *aEvent);
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
nsCalTodoComponentCanvas :: nsCalTodoComponentCanvas(nsISupports* outer) : nsCalTimebarComponentCanvas(outer)
{
NS_INIT_REFCNT();
mWidget = nsnull;
}
nsCalTodoComponentCanvas :: ~nsCalTodoComponentCanvas()
@@ -76,35 +77,18 @@ nsresult nsCalTodoComponentCanvas :: Init()
GetBounds(rect);
nsIWidget * parent = GetWidget();
LoadView(kViewCID, &kCListWidgetCID);
nsIWidget * widget = nsnull;
nsIListWidget * listWidget = nsnull;
nsresult res = nsRepository::CreateInstance(kCListWidgetCID,
nsnull,
kIWidgetIID,
(void **)&mWidget);
if (NS_OK != res)
return res;
res = mWidget->QueryInterface(kIListWidgetIID, (void**)&listWidget);
if (NS_OK != res)
return res;
nsIDeviceContext * context = nsnull;
if (parent)
context = parent->GetDeviceContext();
mWidget->Create(parent,
rect,
HandleEventListWidget,
context,
nsnull, nsnull);
NS_IF_RELEASE(context);
mView->GetWidget(widget);
nsresult res = widget->QueryInterface(kIListWidgetIID, (void**)&listWidget);
nsIDeviceContext * context;
gXPFCToolkit->GetViewManager()->GetDeviceContext(context);
listWidget->AddItemAt(nsString("TODO LIST"),-1);
listWidget->AddItemAt(nsString("---------"),-1);
listWidget->AddItemAt(nsString("Todo: Item #1"),-1);
@@ -117,38 +101,38 @@ nsresult nsCalTodoComponentCanvas :: Init()
listWidget->AddItemAt(nsString("Todo: Item #8"),-1);
listWidget->AddItemAt(nsString("Todo: Item #9"),-1);
listWidget->AddItemAt(nsString("Todo: Item #10"),-1);
gXPFCToolkit->GetViewManager()->MoveViewTo(mView, rect.x, rect.y);
gXPFCToolkit->GetViewManager()->ResizeView(mView, rect.width, rect.height);
gXPFCToolkit->GetViewManager()->UpdateView(mView, rect, NS_VMREFRESH_AUTO_DOUBLE_BUFFER) ;
NS_RELEASE(context);
NS_RELEASE(widget);
NS_RELEASE(listWidget);
SetBackgroundColor(NS_RGB(255,255,192));
mWidget->Show(PR_TRUE);
return NS_OK;
}
nsEventStatus PR_CALLBACK HandleEventListWidget(nsGUIEvent *aEvent)
{
return nsEventStatus_eIgnore;
}
nsresult nsCalTodoComponentCanvas :: SetBounds(const nsRect &aBounds)
{
return (nsXPFCCanvas::SetBounds(aBounds));
//return NS_OK;
}
void nsCalTodoComponentCanvas :: SetBackgroundColor(const nscolor &aColor)
{
// if (mWidget)
// mWidget->SetBackgroundColor(aColor);
nsXPFCCanvas::SetBackgroundColor(aColor);
}
nsEventStatus nsCalTodoComponentCanvas :: OnPaint(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
{
mWidget->Invalidate(PR_FALSE);
return (nsEventStatus_eConsumeNoDefault);
}
nsEventStatus nsCalTodoComponentCanvas :: HandleEvent(nsGUIEvent *aEvent)
{
return (nsEventStatus_eIgnore);
}

View File

@@ -7,7 +7,7 @@
toolbar (type of container, generally a widget subclass)
button (type of widget)
Tags
Tags
toolbar (all container properties apply)

View File

@@ -56,8 +56,8 @@ public:
NS_IMETHOD Init();
NS_IMETHOD Init(nsNativeWidget aNativeParent, const nsRect& aBounds, EVENT_CALLBACK aHandleEventFunction);
NS_IMETHOD Init(nsIWidget * aParent, const nsRect& aBounds, EVENT_CALLBACK aHandleEventFunction);
NS_IMETHOD Init(nsNativeWidget aNativeParent, const nsRect& aBounds);
NS_IMETHOD Init(nsIView * aParent, const nsRect& aBounds);
NS_IMETHOD CreateIterator(nsIIterator ** aIterator) ;
NS_IMETHOD Layout() ;
@@ -135,6 +135,7 @@ public:
NS_IMETHOD_(PRUint32) GetTabGroup();
NS_IMETHOD_(nsIWidget *) GetWidget();
NS_IMETHOD_(nsIView *) GetView();
NS_IMETHOD_(nsIXPFCCanvas *) GetParent();
NS_IMETHOD_(void) SetParent(nsIXPFCCanvas * aCanvas);
@@ -193,7 +194,7 @@ public:
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
NS_IMETHOD_(nsIXPFCCanvas *) CanvasFromName(nsString& aName);
NS_IMETHOD CreateWidget() ;
NS_IMETHOD CreateView() ;
/**
* Get the font for this canvas
@@ -256,7 +257,11 @@ public:
NS_IMETHOD DumpCanvas(FILE * f, PRUint32 indent) ;
#endif
NS_IMETHOD LoadWidget(const nsCID &aClassIID);
NS_IMETHOD LoadView(const nsCID &aViewClassIID,
const nsCID * aWidgetClassIID = nsnull,
nsIView * aParent = nsnull,
nsWidgetInitData * aInitData = nsnull,
nsNativeWidget aNativeWidget = nsnull);
protected:
~nsXPFCCanvas();
@@ -266,13 +271,13 @@ protected:
public:
PRBool Create(char * lpszWindowName, const nsRect& rect, EVENT_CALLBACK aHandleEventFunction, nsIWidget * pParent);
PRBool Create(const nsRect& rect,
nsIView * aParent);
private:
nsILayout * mLayout;
nsIVector * mChildWidgets ;
nsRect mBounds;
nscolor mBackgroundColor;
nscolor mForegroundColor;
nscolor mBorderColor;
@@ -293,12 +298,11 @@ private:
protected:
nsISupports *mWidgetSupports;
nsIWidget *mWidget;
nsIRenderingContext *mRenderingContext;
nsIXPFCCanvas *mParent;
nsIImageRequest *mImageRequest;
nsIImageGroup *mImageGroup;
nsRect mBounds;
public:
nsIView *mView;

View File

@@ -33,6 +33,7 @@
class nsIModel;
class nsIXPFCCommand;
class nsIView;
// IID for the nsIXPFCCanvas interface
#define NS_IXPFC_CANVAS_IID \
@@ -76,19 +77,17 @@ public:
* @result The result of the initialization, NS_Ok if no errors
*/
NS_IMETHOD Init(nsNativeWidget aNativeParent,
const nsRect& aBounds,
EVENT_CALLBACK aHandleEventFunction) = 0;
const nsRect& aBounds) = 0;
/**
* Initialize the XPFCCanvas
* @param aParent a nsIWidget pointer to the parent.
* @param aParent a nsIView pointer to the parent.
* @param aBounds the bounds for thw canvas, relative to it's parent
* @param aHandleEventFunction The event procedure for handling GUIEvents
* @result The result of the initialization, NS_Ok if no errors
*/
NS_IMETHOD Init(nsIWidget * aParent,
const nsRect& aBounds,
EVENT_CALLBACK aHandleEventFunction) = 0;
NS_IMETHOD Init(nsIView * aParent,
const nsRect& aBounds) = 0;
/**
* Create an Iterator for this canvas's children
@@ -283,16 +282,22 @@ public:
NS_IMETHOD_(nsEventStatus) OnKeyDown(nsGUIEvent *aEvent) = 0;
/**
* Create an nsIWidget for this canvas
* Create an nsIView for this canvas
* @result nsresult, NS_OK if successful
*/
NS_IMETHOD CreateWidget() = 0;
NS_IMETHOD CreateView() = 0;
/**
* Get the nsIWidget associated with the nsIView with this canvas
* @result nsIWidget pointer, nsnull if no widget aggregated, else the nsIWidget interface
*/
NS_IMETHOD_(nsIWidget *) GetWidget() = 0;
/**
* Get the nsIWidget aggregated by this canvas
* @result nsIWidget pointer, nsnull if no widget aggregated, else the nsIWidget interface
*/
NS_IMETHOD_(nsIWidget *) GetWidget() = 0;
NS_IMETHOD_(nsIView *) GetView() = 0;
/**
* Get the parent canvas
@@ -653,7 +658,11 @@ public:
* @param aClassIID, The class of the nsIWidget implementation
* @result nsresult, NS_OK if successful
*/
NS_IMETHOD LoadWidget(const nsCID &aClassIID) = 0;
NS_IMETHOD LoadView(const nsCID &aViewClassIID,
const nsCID * aWidgetClassIID = nsnull,
nsIView * aParent = nsnull,
nsWidgetInitData * aInitData = nsnull,
nsNativeWidget aNativeWidget = nsnull) = 0;
};

View File

@@ -29,7 +29,6 @@
#include "nsIDeviceContext.h"
#include "nsWidgetsCID.h"
#include "nsColor.h"
#include "nsBoxLayout.h"
#include "nsIXPFCCommand.h"
#include "nsIXMLParserObject.h"
@@ -38,13 +37,12 @@
#include "nsxpfcstrings.h"
#include "nsXPFCMethodInvokerCommand.h"
#include "nsIWebViewerContainer.h"
#include "nsXPFCToolkit.h"
#include "nsIButton.h"
#include "nsITabWidget.h"
#include "nspr.h"
#include "nsViewsCID.h"
#include "nsIViewManager.h"
#define DEFAULT_WIDTH 100
#define DEFAULT_HEIGHT 100
@@ -65,6 +63,9 @@ static NS_DEFINE_IID(kXPFCCommandCID, NS_XPFC_COMMAND_CID);
static NS_DEFINE_IID(kIImageObserverIID, NS_IIMAGEREQUESTOBSERVER_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
static NS_DEFINE_IID(kCViewCID, NS_VIEW_CID);
nsXPFCCanvas :: nsXPFCCanvas(nsISupports* outer) :
@@ -78,7 +79,6 @@ nsXPFCCanvas :: nsXPFCCanvas(nsISupports* outer) :
{
NS_INIT_AGGREGATED(outer);
mWidget = nsnull;
mLayout = nsnull;
mParent = nsnull;
mBackgroundColor = NS_RGB(192,192,192);
@@ -122,8 +122,6 @@ nsXPFCCanvas :: ~nsXPFCCanvas()
{
DeleteChildren();
NS_IF_RELEASE(mWidget);
mParent = nsnull;
NS_IF_RELEASE(mLayout);
@@ -136,6 +134,8 @@ nsXPFCCanvas :: ~nsXPFCCanvas()
NS_RELEASE(mImageGroup);
}
if (nsnull != mView)
mView->Destroy();
}
@@ -194,9 +194,6 @@ nsresult nsXPFCCanvas::AggregatedQueryInterface(const nsIID &aIID,
return NS_OK;
}
if (nsnull != mWidget)
return mWidget->QueryInterface(aIID, aInstancePtr);
return NS_NOINTERFACE;
}
@@ -368,8 +365,8 @@ nsresult nsXPFCCanvas::FindLargestTabID(PRUint32 aTabGroup, PRUint32& aTabID)
nsresult nsXPFCCanvas :: SetFocus()
{
if (mWidget)
mWidget->SetFocus();
if (GetWidget())
GetWidget()->SetFocus();
return NS_OK;
}
@@ -378,19 +375,20 @@ nsresult nsXPFCCanvas :: CreateImageGroup()
{
nsresult res = NS_OK;
if ((mImageGroup != nsnull) && (GetWidget() != nsnull))
if (nsnull != mImageGroup)
return NS_OK;
res = NS_NewImageGroup(&mImageGroup);
if (NS_OK == res)
{
nsIDeviceContext * deviceCtx = GetWidget()->GetDeviceContext();
nsIDeviceContext * deviceCtx = nsnull;
gXPFCToolkit->GetViewManager()->GetDeviceContext(deviceCtx);
mImageGroup->Init(deviceCtx);
NS_RELEASE(deviceCtx);
NS_IF_RELEASE(deviceCtx);
}
return res;
@@ -559,7 +557,9 @@ nsresult nsXPFCCanvas :: SetParameter(nsString& aKey, nsString& aValue)
static NS_DEFINE_IID(kInsTabWidgetIID, NS_ITABWIDGET_IID);
nsITabWidget * tab = nsnull;
nsresult res = QueryInterface(kInsTabWidgetIID,(void**)&tab);
nsIWidget * widget = GetWidget();
nsresult res = widget->QueryInterface(kInsTabWidgetIID,(void**)&tab);
NS_RELEASE(widget);
if (NS_OK == res)
{
@@ -576,52 +576,63 @@ nsresult nsXPFCCanvas :: SetParameter(nsString& aKey, nsString& aValue)
}
nsresult nsXPFCCanvas :: LoadWidget(const nsCID &aClassIID)
nsresult nsXPFCCanvas :: LoadView(const nsCID &aViewClassIID,
const nsCID * aWidgetClassIID,
nsIView * aParent,
nsWidgetInitData * aInitData,
nsNativeWidget aNativeWidget)
{
nsresult rv;
nsresult res = NS_OK;
nsISupports * supports ;
nsRect bounds;
rv = QueryInterface(kISupportsIID, (void **) &supports);
GetBounds(bounds);
if (NS_OK != rv)
return rv;
res = nsRepository::CreateInstance(aViewClassIID,
nsnull,
kIViewIID,
(void**)&mView);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (NS_OK != res)
return res;
rv = nsRepository::CreateInstance(aClassIID,
nsnull, //supports,
kIWidgetIID,
(void**)&mWidget);
gXPFCToolkit->GetCanvasManager()->RegisterView((nsIXPFCCanvas*)this,mView);
NS_RELEASE(supports);
nsIView * view = nsnull;
if (mWidget != nsnull)
{
gXPFCToolkit->GetCanvasManager()->RegisterWidget(this,mWidget);
}
if (aParent != nsnull)
view = aParent;
else if (GetParent() != nsnull)
view = GetParent()->GetView();
return rv;
mView->Init(gXPFCToolkit->GetViewManager(),
bounds,
view,
aWidgetClassIID,
aInitData,
aNativeWidget);
return res;
}
nsresult nsXPFCCanvas :: CreateWidget()
nsresult nsXPFCCanvas :: CreateView()
{
nsresult rv;
nsresult res = NS_OK;
static NS_DEFINE_IID(kCWidgetCID, NS_CHILD_CID);
rv = LoadWidget(kCWidgetCID);
res = LoadView(kViewCID, &kCWidgetCID);
return rv;
return res;
}
nsIWidget * nsXPFCCanvas :: GetWidget()
// XXX change API to be XPCOM-ish - caller needs to release!
nsIView * nsXPFCCanvas :: GetView()
{
if (mWidget)
return mWidget;
if (nsnull != mView)
return (mView);
/*
* If we have no parent, this usually means it is during parsing.
@@ -651,17 +662,38 @@ nsIWidget * nsXPFCCanvas :: GetWidget()
if (root == nsnull)
return nsnull;
nsIWidget * widget = root->GetWidget();
nsIView * view = root->GetView();
NS_RELEASE(root);
return (widget);
return (view);
}
return (GetParent()->GetWidget());
return (GetParent()->GetView());
}
// XXX change API to be XPCOM-ish - caller needs to release!
nsIWidget * nsXPFCCanvas :: GetWidget()
{
nsIWidget * widget = nsnull;
nsIView * view = GetView();
while(widget == nsnull && view != nsnull)
{
view->GetWidget(widget);
if (widget)
break;
view->GetParent(view);
}
return (widget);
}
nsILayout * nsXPFCCanvas :: GetLayout()
{
return mLayout;
@@ -735,79 +767,44 @@ nsresult nsXPFCCanvas :: CreateDefaultLayout()
return res;
}
nsresult nsXPFCCanvas :: Init(nsNativeWidget aNativeParent, const nsRect& aBounds, EVENT_CALLBACK aHandleEventFunction)
nsresult nsXPFCCanvas :: Init(nsNativeWidget aNativeParent, const nsRect& aBounds)
{
SetBounds(aBounds) ;
nsresult res = Init();
CreateWidget();
return res ;
}
nsresult nsXPFCCanvas :: Init(nsIWidget * aParent, const nsRect& aBounds, EVENT_CALLBACK aHandleEventFunction)
{
nsresult res = Init();
CreateWidget();
Create("MiniCal", aBounds, aHandleEventFunction, aParent);
SetBounds(aBounds) ;
return res ;
}
PRBool nsXPFCCanvas::Create(char * lpszWindowName,
const nsRect& rect,
EVENT_CALLBACK aHandleEventFunction,
nsIWidget * pParent)
{
static NS_DEFINE_IID(kCChildCID, NS_CHILD_CID);
#ifdef XP_UNIX
nsRepository::RegisterFactory(kCChildCID, "libwidgetunix.so", PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kIWidgetIID, "libwidgetunix.so", PR_FALSE, PR_FALSE);
#endif
nsresult res ;
if (mWidget == nsnull)
{
res = nsRepository::CreateInstance(kCChildCID,
nsnull,
kIWidgetIID,
(void **)&(mWidget));
LoadView(kCViewCID, &kCChildCID, nsnull, nsnull, aNativeParent);
if (NS_OK != res)
return PR_FALSE;
}
return res ;
}
nsresult nsXPFCCanvas :: Init(nsIView * aParent, const nsRect& aBounds)
{
nsresult res = Init();
Create(aBounds, aParent);
SetBounds(aBounds) ;
return res ;
}
PRBool nsXPFCCanvas::Create(const nsRect& rect,
nsIView * aParent)
{
static NS_DEFINE_IID(kCChildCID, NS_CHILD_CID);
nsWidgetInitData initData ;
initData.clipChildren = PR_FALSE;
nsIDeviceContext * context = nsnull;
if (GetWidget())
context = GetWidget()->GetDeviceContext();
mWidget->Create(pParent,
rect,
aHandleEventFunction,
context,
nsnull,
nsnull,
&initData);
NS_IF_RELEASE(context);
mWidget->Show(PR_TRUE);
LoadView(kCViewCID, &kCChildCID, aParent, &initData);
return PR_TRUE;
}
@@ -839,13 +836,23 @@ nsresult nsXPFCCanvas :: SetBounds(const nsRect &aBounds)
mBounds.width = aBounds.width ;
mBounds.height = aBounds.height ;
if (mWidget) {
mWidget->Invalidate(PR_FALSE);
mWidget->Resize(aBounds.x, aBounds.y, aBounds.width, aBounds.height, PR_FALSE);
mBounds.x = 0 ;
mBounds.y = 0 ;
}
if (mView != nsnull)
{
gXPFCToolkit->GetViewManager()->MoveViewTo(mView, mBounds.x, mBounds.y);
gXPFCToolkit->GetViewManager()->ResizeView(mView, mBounds.width, mBounds.height);
nsIWidget * widget = nsnull;
mView->GetWidget(widget);
if (widget)
{
mBounds.x = 0 ;
mBounds.y = 0 ;
}
NS_IF_RELEASE(widget);
}
return NS_OK;
}
@@ -891,20 +898,21 @@ nsEventStatus nsXPFCCanvas :: OnPaint(nsIRenderingContext& aRenderingContext,
nsEventStatus nsXPFCCanvas :: OnResize(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
//SetBounds(*((nsSizeEvent*)aEvent)->windowSize);
if (mWidget != nsnull)
{
mWidget->Invalidate(PR_FALSE);
mBounds.x = 0 ;
mBounds.y = 0 ;
} else {
mBounds.x = aX ;
mBounds.y = aY ;
}
mBounds.x = aX ;
mBounds.y = aY ;
mBounds.width = aWidth ;
mBounds.height = aHeight ;
if (mView != nsnull)
{
nsRect bounds = mBounds;
bounds.x = 0;
bounds.y = 0;
gXPFCToolkit->GetViewManager()->UpdateView(mView, bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER) ;
}
mLayout->Layout();
return (DefaultProcessing(nsnull));
@@ -1010,6 +1018,14 @@ nsIXPFCCanvas * nsXPFCCanvas :: GetParent()
void nsXPFCCanvas :: SetParent(nsIXPFCCanvas * aCanvas)
{
mParent = aCanvas;
/*
* Update ye-ole view system
*/
if (mView)
mView->SetParent(aCanvas->GetView());
return ;
}
@@ -1022,8 +1038,8 @@ void nsXPFCCanvas :: SetBackgroundColor(const nscolor &aColor)
{
mBackgroundColor = aColor;
if (mWidget)
mWidget->SetBackgroundColor(aColor);
if (GetWidget() != nsnull)
GetWidget()->SetBackgroundColor(aColor);
}
nscolor nsXPFCCanvas :: GetBorderColor(void)
@@ -1045,8 +1061,8 @@ void nsXPFCCanvas :: SetForegroundColor(const nscolor &aColor)
{
mForegroundColor = aColor;
if (mWidget)
mWidget->SetForegroundColor(aColor);
if (GetWidget() != nsnull)
GetWidget()->SetForegroundColor(aColor);
}
nscolor nsXPFCCanvas :: Highlight(const nscolor &aColor)
@@ -1229,7 +1245,7 @@ nsEventStatus nsXPFCCanvas :: PaintChildWidgets(nsIRenderingContext& aRenderingC
{
nsresult res ;
nsIIterator * iterator ;
nsIXPFCCanvas * widget ;
nsIXPFCCanvas * canvas ;
nsRect rect;
// Iterate through the children
@@ -1242,18 +1258,12 @@ nsEventStatus nsXPFCCanvas :: PaintChildWidgets(nsIRenderingContext& aRenderingC
while(!(iterator->IsDone()))
{
widget = (nsIXPFCCanvas *) iterator->CurrentItem();
canvas = (nsIXPFCCanvas *) iterator->CurrentItem();
widget->GetBounds(rect);
canvas->GetBounds(rect);
if (rect.width != 0 && rect.height != 0)
{
if (((nsXPFCCanvas *)widget)->mWidget == nsnull) {
widget->OnPaint(aRenderingContext,aDirtyRect);
} else {
((nsXPFCCanvas *)widget)->mWidget->Invalidate(PR_FALSE);
}
}
canvas->OnPaint(aRenderingContext,aDirtyRect);
iterator->Next();
}
@@ -1349,8 +1359,14 @@ nsEventStatus nsXPFCCanvas :: HandleEvent(nsGUIEvent *aEvent)
{
canvas = (nsXPFCCanvas *) iterator->CurrentItem();
if (canvas->mWidget != nsnull)
canvas->mWidget->Invalidate(PR_FALSE);
if (canvas->mView != nsnull)
{
nsRect bounds;
canvas->mView->GetBounds(bounds);
bounds.x = 0;
bounds.y = 0;
gXPFCToolkit->GetViewManager()->UpdateView(canvas->mView, bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER) ;
}
iterator->Next();
}
@@ -1489,7 +1505,7 @@ PRBool nsXPFCCanvas::PaintRequested()
{
canvas = (nsXPFCCanvas *) iterator->CurrentItem();
if (canvas->mWidget == nsnull)
if (canvas->mView == nsnull)
{
if(canvas->GetVisibility() == PR_TRUE)
@@ -1947,13 +1963,30 @@ nsresult nsXPFCCanvas::Action(nsIXPFCCommand * aCommand)
* Just paint ourselves for now
*/
GetWidget()->Invalidate(PR_FALSE);
nsRect bounds;
GetView()->GetBounds(bounds);
bounds.x = 0;
bounds.y = 0;
gXPFCToolkit->GetViewManager()->UpdateView(GetView(), bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER);
return NS_OK;
}
nsCursor nsXPFCCanvas::GetCursor()
{
return (GetWidget()->GetCursor());
nsIWidget * widget = GetWidget();
nsCursor cursor = eCursor_standard;
if (widget != nsnull)
{
cursor = widget->GetCursor();
NS_RELEASE(widget);
}
return (cursor);
}
nsCursor nsXPFCCanvas::GetDefaultCursor(nsPoint& aPoint)
@@ -1985,7 +2018,16 @@ nsCursor nsXPFCCanvas::GetDefaultCursor(nsPoint& aPoint)
void nsXPFCCanvas::SetCursor(nsCursor aCursor)
{
GetWidget()->SetCursor(aCursor);
nsIWidget * widget = GetWidget();
if (widget != nsnull)
{
widget->SetCursor(aCursor);
NS_RELEASE(widget);
}
return ;
}
nsEventStatus nsXPFCCanvas::OnMouseMove(nsGUIEvent *aEvent)
@@ -2156,8 +2198,16 @@ void nsXPFCCanvas::Notify(nsIImageRequest *aImageRequest,
PRInt32 aParam1, PRInt32 aParam2,
void *aParam3)
{
nsRect bounds;
GetView()->GetBounds(bounds);
if (aNotificationType == nsImageNotification_kImageComplete)
GetWidget()->Invalidate(PR_FALSE);
{
bounds.x = 0;
bounds.y = 0;
gXPFCToolkit->GetViewManager()->UpdateView(GetView(), bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER);
}
return ;
}

View File

@@ -226,6 +226,8 @@ nsresult nsXPFCCanvasManager::RegisterView(nsIXPFCCanvas * aCanvas, nsIView * aV
PR_ExitMonitor(monitor);
aView->SetClientData((nsIViewObserver*)this);
return NS_OK;
}
@@ -417,6 +419,7 @@ nsIWebViewerContainer * nsXPFCCanvasManager::GetWebViewerContainer()
nsresult nsXPFCCanvasManager::SetViewManager(nsIViewManager * aViewManager)
{
mViewManager = aViewManager;
mViewManager->SetViewObserver((nsIViewObserver*)this);
return NS_OK;
}

View File

@@ -81,10 +81,12 @@ nsresult nsXPFCHTMLCanvas :: Init()
if (res != NS_OK)
return res;
mWebShell->Init(GetWidget()->GetNativeData(NS_NATIVE_WIDGET), 0,0,DEFAULT_WIDTH, DEFAULT_HEIGHT);
// mWebShell->SetContainer((nsIWebShellContainer*) this);
// mWebShell->SetObserver((nsIStreamObserver*)this);
// mWebShell->SetPrefs(aPrefs);
mWebShell->Init(GetWidget()->GetNativeData(NS_NATIVE_WIDGET),
0,
0,
DEFAULT_WIDTH,
DEFAULT_HEIGHT);
mWebShell->Show();
nsString url("about:blank");

View File

@@ -388,7 +388,7 @@ NS_IMETHODIMP nsXPFCXMLContentSink::AddLeaf(const nsIParserNode& aNode)
res = object->QueryInterface(kIXPFCCanvasIID,(void**)&canvas);
if (NS_OK == res)
{
canvas->CreateWidget();
canvas->CreateView();
NS_RELEASE(canvas);
}

View File

@@ -42,7 +42,7 @@ public:
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
NS_IMETHOD GetClassPreferredSize(nsSize& aSize);
NS_IMETHOD CreateWidget();
NS_IMETHOD CreateView();
NS_IMETHOD SetLabel(nsString& aString);
NS_IMETHOD SetBounds(const nsRect& aBounds);

View File

@@ -36,7 +36,7 @@ public:
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
NS_IMETHOD GetClassPreferredSize(nsSize& aSize);
NS_IMETHOD CreateWidget();
NS_IMETHOD CreateView();
NS_IMETHOD SetLabel(nsString& aString);
NS_IMETHOD SetBounds(const nsRect& aBounds);

View File

@@ -35,7 +35,7 @@ public:
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
NS_IMETHOD GetClassPreferredSize(nsSize& aSize);
NS_IMETHOD CreateWidget();
NS_IMETHOD CreateView();
protected:
~nsXPFCTabWidget();

View File

@@ -35,7 +35,7 @@ public:
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
NS_IMETHOD GetClassPreferredSize(nsSize& aSize);
NS_IMETHOD CreateWidget();
NS_IMETHOD CreateView();
NS_IMETHOD SetLabel(nsString& aString);
NS_IMETHOD_(nsEventStatus) OnKeyDown(nsGUIEvent *aEvent);

View File

@@ -37,7 +37,7 @@ public:
NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ;
NS_IMETHOD GetClassPreferredSize(nsSize& aSize);
NS_IMETHOD CreateWidget();
NS_IMETHOD CreateView();
NS_IMETHOD SetLabel(nsString& aString);
NS_IMETHOD SetBounds(const nsRect& aBounds);

View File

@@ -33,12 +33,14 @@
#include "nsIThrobber.h"
#include "nsXPItem.h"
#include "nsIWebViewerContainer.h"
#include "nsViewsCID.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kCXPButtonCID, NS_XP_BUTTON_CID);
static NS_DEFINE_IID(kCIXPButtonIID, NS_IXP_BUTTON_IID);
static NS_DEFINE_IID(kCButtonCID, NS_BUTTON_CID);
static NS_DEFINE_IID(kInsButtonIID, NS_IBUTTON_IID);
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
#define DEFAULT_WIDTH 50
#define DEFAULT_HEIGHT 50
@@ -92,7 +94,9 @@ NS_IMPL_RELEASE(nsXPButton)
nsresult nsXPButton :: Init()
{
nsresult res = nsXPItem::Init();
nsresult res = nsXPItem::Init();
LoadView(kViewCID);
return res;
}
@@ -145,7 +149,7 @@ nsresult nsXPButton :: GetClassPreferredSize(nsSize& aSize)
return (NS_OK);
}
nsresult nsXPButton :: CreateWidget()
nsresult nsXPButton :: CreateView()
{
nsresult res = NS_OK;
return res;
@@ -314,7 +318,21 @@ nsEventStatus nsXPButton::OnMouseEnter(nsGUIEvent *aEvent)
if (gXPFCToolkit->GetCanvasManager()->GetPressedCanvas() == ((nsIXPFCCanvas *)this))
mState |= eButtonState_pressed;
GetWidget()->Invalidate(PR_FALSE);
nsRect bounds;
GetView()->GetBounds(bounds);
// XXX: Need to convert coordinates to local views space.
// this means that GetBounds needs to look 'up' the
// view tree to figure out what view this canvas belongs
// to and convert thusly.
//
// Alternatively, we could just give every canvas a view...
//
bounds.x = 0;
bounds.y = 0;
gXPFCToolkit->GetViewManager()->UpdateView(GetView(), bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER);
return (nsXPItem::OnMouseEnter(aEvent));
}
@@ -322,22 +340,38 @@ nsEventStatus nsXPButton::OnMouseExit(nsGUIEvent *aEvent)
{
mState &= ~eButtonState_hover;
mState &= ~eButtonState_pressed;
GetWidget()->Invalidate(PR_FALSE);
nsRect bounds;
GetView()->GetBounds(bounds);
bounds.x = 0;
bounds.y = 0;
gXPFCToolkit->GetViewManager()->UpdateView(GetView(), bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER);
return (nsXPItem::OnMouseExit(aEvent));
}
nsEventStatus nsXPButton :: OnLeftButtonDown(nsGUIEvent *aEvent)
{
mState |= eButtonState_pressed;
GetWidget()->Invalidate(PR_FALSE);
nsRect bounds;
GetView()->GetBounds(bounds);
bounds.x = 0;
bounds.y = 0;
gXPFCToolkit->GetViewManager()->UpdateView(GetView(), bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER);
return (nsXPItem::OnLeftButtonDown(aEvent));
}
nsEventStatus nsXPButton :: OnLeftButtonUp(nsGUIEvent *aEvent)
{
mState &= ~eButtonState_pressed;
GetWidget()->Invalidate(PR_FALSE);
nsRect bounds;
GetView()->GetBounds(bounds);
bounds.x = 0;
bounds.y = 0;
gXPFCToolkit->GetViewManager()->UpdateView(GetView(), bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER);
#if 0
if (gCommandString.Length() > 0)
{
nsIWebViewerContainer * webViewerContainer = nsnull;
@@ -349,6 +383,7 @@ nsEventStatus nsXPButton :: OnLeftButtonUp(nsGUIEvent *aEvent)
NS_RELEASE(webViewerContainer);
}
}
#endif
return (nsXPItem::OnLeftButtonUp(aEvent));
}

View File

@@ -31,6 +31,10 @@
#include "nsITimer.h"
#include "nsIThrobber.h"
#include "nsViewsCID.h"
#include "nsIViewManager.h"
#include "nsXPFCToolkit.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kCXPFCButtonCID, NS_XPFC_BUTTON_CID);
static NS_DEFINE_IID(kCIXPFCButtonIID,NS_IXPFC_BUTTON_IID);
@@ -39,6 +43,7 @@ static NS_DEFINE_IID(kInsButtonIID, NS_IBUTTON_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
static NS_DEFINE_IID(kThrobberCID, NS_THROBBER_CID);
static NS_DEFINE_IID(kIThrobberIID, NS_ITHROBBER_IID);
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
#define DEFAULT_WIDTH 50
#define DEFAULT_HEIGHT 50
@@ -101,7 +106,7 @@ nsresult nsXPFCButton :: GetClassPreferredSize(nsSize& aSize)
return (NS_OK);
}
nsresult nsXPFCButton :: CreateWidget()
nsresult nsXPFCButton :: CreateView()
{
nsresult res = NS_OK;
@@ -115,7 +120,7 @@ nsresult nsXPFCButton :: CreateWidget()
return res;
nsIWidget * parent = GetWidget();
nsSize size ;
GetClassPreferredSize(size);
@@ -128,21 +133,20 @@ nsresult nsXPFCButton :: CreateWidget()
} else {
nsIView * parent = GetView();
nsIWidget * parent = GetWidget();
res = LoadWidget(kCButtonCID);
LoadView(kViewCID, &kCButtonCID, parent);
nsIWidget * bw = nsnull;
nsIButton * button = nsnull;
res = QueryInterface(kInsButtonIID,(void**)&button);
mView->GetWidget(bw);
res = bw->QueryInterface(kInsButtonIID,(void**)&button);
if (NS_OK == res)
{
nsIWidget * bw = nsnull;
res = button->QueryInterface(kIWidgetIID,(void**)&bw);
if (NS_OK == res)
{
@@ -152,25 +156,23 @@ nsresult nsXPFCButton :: CreateWidget()
nsRect rect(0,0,size.width,size.height);
bw->Create(parent,
rect,
gXPFCToolkit->GetShellEventCallback(),
nsnull);
bw->SetBackgroundColor(GetBackgroundColor());
bw->SetForegroundColor(GetForegroundColor());
bw->Show(PR_TRUE);
button->SetLabel(GetLabel());
NS_RELEASE(bw);
gXPFCToolkit->GetViewManager()->MoveViewTo(mView, rect.x, rect.y);
gXPFCToolkit->GetViewManager()->ResizeView(mView, rect.width, rect.height);
gXPFCToolkit->GetViewManager()->UpdateView(mView, rect, NS_VMREFRESH_AUTO_DOUBLE_BUFFER) ;
}
NS_RELEASE(button);
}
NS_RELEASE(bw);
SetVisibility(PR_FALSE);
}
return res;
}
@@ -187,24 +189,33 @@ nsresult nsXPFCButton :: SetLabel(nsString& aString)
*/
static NS_DEFINE_IID(kInsButtonIID, NS_IBUTTON_IID);
nsIWidget * bw = nsnull;
nsIButton * button = nsnull;
nsresult res = QueryInterface(kInsButtonIID,(void**)&button);
if (NS_OK == res)
if (mView)
{
button->SetLabel(aString);
NS_RELEASE(button);
}
mView->GetWidget(bw);
nsresult res = bw->QueryInterface(kInsButtonIID,(void**)&button);
if (NS_OK == res)
{
button->SetLabel(aString);
NS_RELEASE(button);
}
NS_RELEASE(bw);
}
return NS_OK;
}
nsresult nsXPFCButton :: SetBounds(const nsRect &aBounds)
{
if (mWidget == nsnull)
if (mView == nsnull)
{
mThrobber->MoveTo(aBounds.x, aBounds.y);
if (mThrobber)
mThrobber->MoveTo(aBounds.x, aBounds.y);
return NS_OK;
}
@@ -217,8 +228,11 @@ nsEventStatus nsXPFCButton :: OnPaint(nsIRenderingContext& aRenderingContext,
{
if (GetLabel() == "Throbber")
{
mThrobber->Hide();
mThrobber->Show();
if (mThrobber)
{
mThrobber->Hide();
mThrobber->Show();
}
}
return (nsXPFCCanvas::OnPaint(aRenderingContext,aDirtyRect));
}

View File

@@ -89,10 +89,10 @@ nsresult nsXPFCTabWidget :: GetClassPreferredSize(nsSize& aSize)
return (NS_OK);
}
nsresult nsXPFCTabWidget :: CreateWidget()
nsresult nsXPFCTabWidget :: CreateView()
{
nsresult res;
nsresult res = NS_OK;
#if 0
nsIWidget * parent = GetWidget();
res = LoadWidget(kCTabWidgetCID);
@@ -131,6 +131,6 @@ nsresult nsXPFCTabWidget :: CreateWidget()
}
SetVisibility(PR_FALSE);
#endif
return res;
}

View File

@@ -25,6 +25,9 @@
#include "nsXPFCActionCommand.h"
#include "nsRepository.h"
#include "nsxpfcCIID.h"
#include "nsViewsCID.h"
#include "nsIViewManager.h"
#include "nsXPFCToolkit.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kCXPFCTextWidgetCID, NS_XPFC_TEXTWIDGET_CID);
@@ -32,6 +35,7 @@ static NS_DEFINE_IID(kCIXPFCTextWidgetIID, NS_IXPFC_TEXTWIDGET_IID);
static NS_DEFINE_IID(kCTextWidgetCID, NS_TEXTFIELD_CID);
static NS_DEFINE_IID(kInsTextWidgetIID, NS_ITEXTWIDGET_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
#define DEFAULT_WIDTH 50
#define DEFAULT_HEIGHT 50
@@ -95,54 +99,48 @@ nsresult nsXPFCTextWidget :: GetClassPreferredSize(nsSize& aSize)
}
nsresult nsXPFCTextWidget :: CreateWidget()
nsresult nsXPFCTextWidget :: CreateView()
{
nsresult res;
nsresult res = NS_OK;
nsIWidget * parent = GetWidget();
nsIView * parent = GetView();
res = LoadWidget(kCTextWidgetCID);
LoadView(kViewCID, &kCTextWidgetCID, parent);
nsIWidget * tw = nsnull;
nsITextWidget * text_widget = nsnull;
res = QueryInterface(kInsTextWidgetIID,(void**)&text_widget);
mView->GetWidget(tw);
res = tw->QueryInterface(kInsTextWidgetIID,(void**)&text_widget);
if (NS_OK == res)
{
nsIWidget * tw = nsnull;
nsSize size ;
GetClassPreferredSize(size);
res = text_widget->QueryInterface(kIWidgetIID,(void**)&tw);
nsRect rect(0,0,size.width,size.height);
if (NS_OK == res)
{
nsSize size ;
GetClassPreferredSize(size);
tw->SetBackgroundColor(GetBackgroundColor());
tw->SetForegroundColor(GetForegroundColor());
nsRect rect(0,0,size.width,size.height);
PRUint32 num;
tw->Create(parent,
rect,
gXPFCToolkit->GetShellEventCallback(),
nsnull);
text_widget->SetText(GetLabel(),num);
tw->SetBackgroundColor(GetBackgroundColor());
tw->SetForegroundColor(GetForegroundColor());
tw->Show(PR_TRUE);
if (gXPFCToolkit->GetCanvasManager()->GetFocusedCanvas() == this)
SetFocus();
PRUint32 num;
text_widget->SetText(GetLabel(),num);
if (gXPFCToolkit->GetCanvasManager()->GetFocusedCanvas() == this)
SetFocus();
NS_RELEASE(tw);
}
gXPFCToolkit->GetViewManager()->MoveViewTo(mView, rect.x, rect.y);
gXPFCToolkit->GetViewManager()->ResizeView(mView, rect.width, rect.height);
gXPFCToolkit->GetViewManager()->UpdateView(mView, rect, NS_VMREFRESH_AUTO_DOUBLE_BUFFER) ;
NS_RELEASE(text_widget);
}
NS_RELEASE(tw);
SetVisibility(PR_FALSE);
return res;
@@ -179,7 +177,13 @@ nsEventStatus nsXPFCTextWidget::OnKeyDown(nsGUIEvent *aEvent)
nsITextWidget * text_widget = nsnull;
res = QueryInterface(kInsTextWidgetIID,(void**)&text_widget);
nsIWidget * widget = nsnull;
GetView()->GetWidget(widget);
res = widget->QueryInterface(kInsTextWidgetIID,(void**)&text_widget);
NS_RELEASE(widget);
if (NS_OK == res)
{

View File

@@ -152,7 +152,7 @@ nsresult nsXPItem :: GetClassPreferredSize(nsSize& aSize)
return (NS_OK);
}
nsresult nsXPItem :: CreateWidget()
nsresult nsXPItem :: CreateView()
{
nsresult res = NS_OK;
return res;