diff --git a/mozilla/xpfc/canvas/Makefile b/mozilla/xpfc/canvas/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/canvas/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/canvas/inc/Makefile b/mozilla/xpfc/canvas/inc/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/canvas/inc/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/canvas/inc/manifest.mn b/mozilla/xpfc/canvas/inc/manifest.mn new file mode 100644 index 00000000000..d669af9ab81 --- /dev/null +++ b/mozilla/xpfc/canvas/inc/manifest.mn @@ -0,0 +1,23 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + nsXPFCCanvas.h \ + nsXPFCHTMLCanvas.h \ + nsXPFCCanvasManager.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/canvas/inc/nsXPFCCanvas.h b/mozilla/xpfc/canvas/inc/nsXPFCCanvas.h new file mode 100644 index 00000000000..05ea7d60b60 --- /dev/null +++ b/mozilla/xpfc/canvas/inc/nsXPFCCanvas.h @@ -0,0 +1,286 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsXPFCCanvas_h___ +#define nsXPFCCanvas_h___ + +#include "nsxpfc.h" +#include "nsAgg.h" +#include "nsxpfcCIID.h" +#include "nsIVector.h" +#include "nsIIterator.h" +#include "nsString.h" +#include "nsFont.h" +#include "nsGUIEvent.h" +#include "nsIWidget.h" +#include "nsIXPFCCanvas.h" +#include "nsILayout.h" +#include "nsIRenderingContext.h" +#include "nsColor.h" +#include "nsPoint.h" +#include "nsIXPFCObserver.h" +#include "nsIXPFCCommandReceiver.h" +#include "nsIXPFCSubject.h" +#include "nsIXMLParserObject.h" +#include "nsIImageGroup.h" +#include "nsIImageObserver.h" +#include "nsIImageRequest.h" + +CLASS_EXPORT_XPFC nsXPFCCanvas : public nsIXPFCCanvas, + public nsIXPFCObserver, + public nsIXMLParserObject, + public nsIImageRequestObserver + +{ +public: + nsXPFCCanvas(nsISupports* outer); + + NS_DECL_AGGREGATED + + 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 CreateIterator(nsIIterator ** aIterator) ; + NS_IMETHOD Layout() ; + NS_IMETHOD_(nsILayout *) GetLayout(); + + NS_IMETHOD_(nsString&) GetNameID(); + NS_IMETHOD SetNameID(nsString& aString); + + NS_IMETHOD_(nsString&) GetLabel(); + NS_IMETHOD SetLabel(nsString& aString); + + NS_IMETHOD SetBounds(const nsRect& aBounds); + NS_IMETHOD_(void) GetBounds(nsRect& aRect); + + NS_IMETHOD_(nsEventStatus) DefaultProcessing(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent); + + NS_IMETHOD_(nsEventStatus) OnPaint(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnResize(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnMove(nsGUIEvent *aEvent); + + NS_IMETHOD_(nsEventStatus) OnGotFocus(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnLostFocus(nsGUIEvent *aEvent); + + NS_IMETHOD_(nsEventStatus) OnLeftButtonDown(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnLeftButtonUp(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnLeftButtonDoubleClick(nsGUIEvent *aEvent); + + NS_IMETHOD_(nsEventStatus) OnMiddleButtonDown(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnMiddleButtonUp(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnMiddleButtonDoubleClick(nsGUIEvent *aEvent); + + NS_IMETHOD_(nsEventStatus) OnRightButtonDown(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnRightButtonUp(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnRightButtonDoubleClick(nsGUIEvent *aEvent); + + NS_IMETHOD_(nsEventStatus) OnMouseEnter(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnMouseExit(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnMouseMove(nsGUIEvent *aEvent); + + NS_IMETHOD_(nsEventStatus) OnKeyUp(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnKeyDown(nsGUIEvent *aEvent); + + 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) ResizeChildWidgets(nsGUIEvent *aEvent); + + NS_IMETHOD SetOpacity(PRFloat64 aOpacity) ; + NS_IMETHOD_(PRFloat64) GetOpacity() ; + NS_IMETHOD SetVisibility(PRBool aVisibility); + NS_IMETHOD_(PRBool) GetVisibility(); + + NS_IMETHOD SetTabID(PRUint32 aTabID); + NS_IMETHOD_(PRUint32) GetTabID(); + + NS_IMETHOD SetTabGroup(PRUint32 aTabGroup); + NS_IMETHOD_(PRUint32) GetTabGroup(); + + NS_IMETHOD_(nsIWidget *) GetWidget(); + NS_IMETHOD_(nsIXPFCCanvas *) GetParent(); + NS_IMETHOD_(void) SetParent(nsIXPFCCanvas * aCanvas); + + NS_IMETHOD_(nscolor) GetBackgroundColor(void) ; + NS_IMETHOD_(void) SetBackgroundColor(const nscolor &aColor) ; + + NS_IMETHOD_(nscolor) GetForegroundColor(void) ; + NS_IMETHOD_(void) SetForegroundColor(const nscolor &aColor) ; + + NS_IMETHOD_(nscolor) GetBorderColor(void) ; + NS_IMETHOD_(void) SetBorderColor(const nscolor &aColor) ; + + NS_IMETHOD_(nscolor) Highlight(const nscolor &aColor); + NS_IMETHOD_(nscolor) Dim(const nscolor &aColor); + + NS_IMETHOD_(nsIXPFCCanvas *) CanvasFromPoint(const nsPoint &aPoint); + NS_IMETHOD_(nsIXPFCCanvas *) CanvasFromTab(PRUint32 aTabGroup, PRUint32 aTabID); + + NS_IMETHOD GetClassPreferredSize(nsSize& aSize); + NS_IMETHOD SetFocus(); + + NS_IMETHOD GetPreferredSize(nsSize &aSize); + NS_IMETHOD GetMaximumSize(nsSize &aSize); + NS_IMETHOD GetMinimumSize(nsSize &aSize); + + NS_IMETHOD SetPreferredSize(nsSize &aSize); + NS_IMETHOD SetMaximumSize(nsSize &aSize); + NS_IMETHOD SetMinimumSize(nsSize &aSize); + + NS_IMETHOD_(PRBool) HasPreferredSize(); + NS_IMETHOD_(PRBool) HasMinimumSize(); + NS_IMETHOD_(PRBool) HasMaximumSize(); + + NS_IMETHOD_(PRFloat64) GetMajorAxisWeight(); + NS_IMETHOD_(PRFloat64) GetMinorAxisWeight(); + NS_IMETHOD SetMajorAxisWeight(PRFloat64 aWeight); + NS_IMETHOD SetMinorAxisWeight(PRFloat64 aWeight); + + NS_IMETHOD_(PRUint32) GetChildCount(); + NS_IMETHOD DeleteChildren(); + NS_IMETHOD DeleteChildren(PRUint32 aCount); + + NS_IMETHOD_(PRBool) PaintRequested(); + + // nsIXPFCObserver methods + NS_IMETHOD Update(nsIXPFCSubject * aSubject, nsIXPFCCommand * aCommand); + + + // nsIXPFCCommandReceiver methods + NS_IMETHOD Action(nsIXPFCCommand * aCommand); + + // nsIXMLParserObject methods + NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ; + + NS_IMETHOD_(nsIXPFCCanvas *) CanvasFromName(nsString& aName); + NS_IMETHOD CreateWidget() ; + + /** + * Get the font for this canvas + * @result nsFont, the canvas font + */ + NS_IMETHOD_(nsFont&) GetFont() ; + + /** + * Set the font for this canvas + * @param aFont the nsFont for this canvas + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD SetFont(nsFont& aFont) ; + + /** + * Get the font metrics for this canvas + * @param nsIFontMetrics, the canvas font metrics + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD GetFontMetrics(nsIFontMetrics ** aFontMetrics) ; + + /** + * Save canvas graphical state + * @param aRenderingContext, rendering context to save state to + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD PushState(nsIRenderingContext * aRenderingContext) ; + + /** + * Get and and set RenderingContext to this graphical state + * @param aRenderingContext, rendering context to get previously saved state from + * @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 FindLargestTabGroup(PRUint32& aTabGroup); + NS_IMETHOD FindLargestTabID(PRUint32 aTabGroup, PRUint32& aTabID); + + // nsIImageRequestObserver + virtual void Notify(nsIImageRequest *aImageRequest, + nsIImage *aImage, + nsImageNotification aNotificationType, + PRInt32 aParam1, PRInt32 aParam2, + void *aParam3); + + virtual void NotifyError(nsIImageRequest *aImageRequest, + nsImageError aErrorType); + +#if defined(DEBUG) && defined(XP_PC) + NS_IMETHOD DumpCanvas(FILE * f, PRUint32 indent) ; +#endif + + NS_IMETHOD LoadWidget(const nsCID &aClassIID); + +protected: + ~nsXPFCCanvas(); + + +public: + PRBool Create(char * lpszWindowName, const nsRect& rect, EVENT_CALLBACK aHandleEventFunction, nsIWidget * pParent); + +private: + + nsILayout * mLayout; + nsIVector * mChildWidgets ; + nsRect mBounds; + nscolor mBackgroundColor; + nscolor mForegroundColor; + nscolor mBorderColor; + nsSize mPreferredSize; + nsSize mMaximumSize; + nsSize mMinimumSize; + nsString mNameID; + nsString mLabel; + PRFloat64 mWeightMajor; + PRFloat64 mWeightMinor; + PRFloat64 mOpacity; + PRBool mVisibility; + nsFont mFont; + PRUint32 mTabID; + PRUint32 mTabGroup; + nsIImageGroup* mImageGroup; + nsIImageRequest* mImageRequest; + +// nsIWidget Aggregation +protected: + + // a Canvas CAN aggregate an nsIWidget + // mWidgetSupports is the pointer to the widget's real nsISupports. QueryInterace + // should be called on mWidgetSupports if any of the widget interface wants to + // be exposed, + // mWidget is a convenience pointer to the widget functionalities. + // mWidget is not AddRef'ed or Released otherwise we'll create a circulare + // refcount and the canvas will never go away + nsISupports *mWidgetSupports; + nsIWidget *mWidget; + + + nsIRenderingContext *mRenderingContext; + nsIXPFCCanvas * mParent; + + +}; + + + +#endif /* nsXPFCCanvas_h___ */ diff --git a/mozilla/xpfc/canvas/inc/nsXPFCCanvasManager.h b/mozilla/xpfc/canvas/inc/nsXPFCCanvasManager.h new file mode 100644 index 00000000000..56fc1b65293 --- /dev/null +++ b/mozilla/xpfc/canvas/inc/nsXPFCCanvasManager.h @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsXPFCCanvasManager_h___ +#define nsXPFCCanvasManager_h___ + +#include "nscore.h" +#include "plstr.h" +#include "prtypes.h" +#include "prmon.h" +#include "plstr.h" +#include "nsCom.h" +#include "nsIVector.h" +#include "nsIIterator.h" + +#include "nsIXPFCCanvasManager.h" + +class nsXPFCCanvasManager : public nsIXPFCCanvasManager +{ +public: + nsXPFCCanvasManager(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init() ; + NS_IMETHOD_(nsIXPFCCanvas *) CanvasFromWidget(nsIWidget * aWidget); + NS_IMETHOD GetRootCanvas(nsIXPFCCanvas ** aCanvas); + NS_IMETHOD SetRootCanvas(nsIXPFCCanvas * aCanvas); + NS_IMETHOD Register(nsIXPFCCanvas * aCanvas, nsIWidget * aWidget); + NS_IMETHOD Unregister(nsIXPFCCanvas * aCanvas); + NS_IMETHOD_(nsIXPFCCanvas *) GetFocusedCanvas(); + NS_IMETHOD SetFocusedCanvas(nsIXPFCCanvas * aCanvas); + +protected: + ~nsXPFCCanvasManager(); + +public: + PRMonitor * monitor; + +public: + nsIVector * mList ; + +private: + nsIXPFCCanvas * mRootCanvas; + nsIXPFCCanvas * mFocusedCanvas; + +}; + +#endif /* nsXPFCCanvasManager_h___ */ diff --git a/mozilla/xpfc/canvas/inc/nsXPFCHTMLCanvas.h b/mozilla/xpfc/canvas/inc/nsXPFCHTMLCanvas.h new file mode 100644 index 00000000000..7eab9b200e9 --- /dev/null +++ b/mozilla/xpfc/canvas/inc/nsXPFCHTMLCanvas.h @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsXPFCHTMLCanvas_h___ +#define nsXPFCHTMLCanvas_h___ + +#include "nsXPFCCanvas.h" +#include "nsIWebShell.h" + +class nsXPFCHTMLCanvas : public nsXPFCCanvas +{ + +public: + + nsXPFCHTMLCanvas(nsISupports* outer); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init(); + NS_IMETHOD SetBounds(const nsRect& aBounds); + + // nsIXMLParserObject methods + NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ; + + NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnPaint(nsGUIEvent *aEvent); + NS_IMETHOD_(nsEventStatus) OnResize(nsGUIEvent *aEvent); + NS_IMETHOD GetClassPreferredSize(nsSize& aSize); + +protected: + ~nsXPFCHTMLCanvas(); + +private: + nsIWebShell * mWebShell; + + +}; + +#endif /* nsXPFCHTMLCanvas_h___ */ diff --git a/mozilla/xpfc/canvas/manifest.mn b/mozilla/xpfc/canvas/manifest.mn new file mode 100644 index 00000000000..ce741a53d39 --- /dev/null +++ b/mozilla/xpfc/canvas/manifest.mn @@ -0,0 +1,15 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../.. +DEPTH = ../../../.. + +DIRS_EXPORT = public inc +DIRS_LIBS = src + diff --git a/mozilla/xpfc/canvas/public/Makefile b/mozilla/xpfc/canvas/public/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/canvas/public/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/canvas/public/manifest.mn b/mozilla/xpfc/canvas/public/manifest.mn new file mode 100644 index 00000000000..a7d4d9de00f --- /dev/null +++ b/mozilla/xpfc/canvas/public/manifest.mn @@ -0,0 +1,23 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. +DEPTH = ../../../../.. + +EXPORTS = \ + nsIXPFCCanvas.h \ + nsIXPFCCanvasManager.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/canvas/public/nsIXPFCCanvas.h b/mozilla/xpfc/canvas/public/nsIXPFCCanvas.h new file mode 100644 index 00000000000..479d99a8026 --- /dev/null +++ b/mozilla/xpfc/canvas/public/nsIXPFCCanvas.h @@ -0,0 +1,624 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIXPFCCanvas_h___ +#define nsIXPFCCanvas_h___ + +#include "nsRect.h" +#include "nsGUIEvent.h" +#include "nsIWidget.h" +#include "nsIIterator.h" +#include "nsSize.h" +#include "nsILayout.h" +#include "nsString.h" +#include "nsIFactory.h" +#include "nsFont.h" +#include "nsIFontMetrics.h" +#include "nsIRenderingContext.h" + +// IID for the nsIXPFCCanvas interface +#define NS_IXPFC_CANVAS_IID \ +{ 0x6bc9da40, 0xe9e7, 0x11d1, \ +{ 0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +/** + * XPFC Canvas interface. This is the core interface to all + * renderable components in the XPFC world + */ +class nsIXPFCCanvas : public nsISupports +{ + +public: + + /** + * Initialize the XPFCCanvas + * @result The result of the initialization, NS_Ok if no errors + */ + NS_IMETHOD Init() = 0; + + /** + * Initialize the XPFCCanvas + * @param aNativeParent a native parent for drawing into. + * @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(nsNativeWidget aNativeParent, + const nsRect& aBounds, + EVENT_CALLBACK aHandleEventFunction) = 0; + + /** + * Initialize the XPFCCanvas + * @param aParent a nsIWidget 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; + + /** + * Create an Iterator for this canvas's children + * @param aIterator out paramater which implements the iterator interface. + * @result The result of the iterator creation, NS_Ok if no errors + */ + NS_IMETHOD CreateIterator(nsIIterator ** aIterator) = 0; + + /** + * Tells this canvas to layout itself and it's children + * @result The result of the layout process, NS_Ok if no errors + */ + NS_IMETHOD Layout() = 0; + + /** + * Get a pointer to the object implementing the nsILayout interface for this canvas + * @result nsILayout pointer, nsnull if no layout object assigned, else a pointer to the layout object + */ + NS_IMETHOD_(nsILayout *) GetLayout() = 0; + + /** + * Get the Name of this canvas, relative to itself + * @result nsString reference, the name of the canvas + */ + NS_IMETHOD_(nsString&) GetNameID() = 0; + + /** + * Set the Name of this canvas, relative to itself + * @result result of setting the name. NS_OK if successful + */ + NS_IMETHOD SetNameID(nsString& aString) = 0; + + /** + * Get the Label of this canvas + * @result nsString reference, the label of the canvas + */ + NS_IMETHOD_(nsString&) GetLabel() = 0; + + /** + * Set the Label of this canvas + * @result result of setting the label. NS_OK if successful + */ + NS_IMETHOD SetLabel(nsString& aString) = 0; + + /** + * Handle a GUI Event + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of gui event processing + */ + NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnPaint Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnPaint event processing + */ + NS_IMETHOD_(nsEventStatus) OnPaint(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnResize Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnResize event processing + */ + NS_IMETHOD_(nsEventStatus) OnResize(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnMove Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnMove event processing + */ + NS_IMETHOD_(nsEventStatus) OnMove(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnGotFocus Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnGotFocus event processing + */ + NS_IMETHOD_(nsEventStatus) OnGotFocus(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnLostFocus Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnLostFocus event processing + */ + NS_IMETHOD_(nsEventStatus) OnLostFocus(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnLeftButtonDown Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnLeftButtonDown event processing + */ + NS_IMETHOD_(nsEventStatus) OnLeftButtonDown(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnLeftButtonUp Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnLeftButtonUp event processing + */ + NS_IMETHOD_(nsEventStatus) OnLeftButtonUp(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnLeftButtonDoubleClick Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnLeftButtonDoubleClick event processing + */ + NS_IMETHOD_(nsEventStatus) OnLeftButtonDoubleClick(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnMiddleButtonDown Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnMiddleButtonDown event processing + */ + NS_IMETHOD_(nsEventStatus) OnMiddleButtonDown(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnMiddleButtonUp Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnMiddleButtonUp event processing + */ + NS_IMETHOD_(nsEventStatus) OnMiddleButtonUp(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnMiddleButtonDoubleClick Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnMiddleButtonDoubleClick event processing + */ + NS_IMETHOD_(nsEventStatus) OnMiddleButtonDoubleClick(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnRightButtonDown Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnRightButtonDown event processing + */ + NS_IMETHOD_(nsEventStatus) OnRightButtonDown(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnRightButtonUp Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnRightButtonUp event processing + */ + NS_IMETHOD_(nsEventStatus) OnRightButtonUp(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnRightButtonDoubleClick Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnRightButtonDoubleClick event processing + */ + NS_IMETHOD_(nsEventStatus) OnRightButtonDoubleClick(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnMouseEnter Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnMouseEnter event processing + */ + NS_IMETHOD_(nsEventStatus) OnMouseEnter(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnMouseExit Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnMouseExit event processing + */ + NS_IMETHOD_(nsEventStatus) OnMouseExit(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnMouseMove Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnMouseMove event processing + */ + NS_IMETHOD_(nsEventStatus) OnMouseMove(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnKeyUp Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnKeyUp event processing + */ + NS_IMETHOD_(nsEventStatus) OnKeyUp(nsGUIEvent *aEvent) = 0; + + /** + * Handle an OnKeyDown Message + * @param aEvent The GUI Event to be handled + * @result nsEventStatus, status of OnKeyDown event processing + */ + NS_IMETHOD_(nsEventStatus) OnKeyDown(nsGUIEvent *aEvent) = 0; + + /** + * Create an nsIWidget for this canvas + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD CreateWidget() = 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; + + /** + * Get the parent canvas + * @result nsIXPFCCanvas pointer, nsnull if no parent, else the nsIXPFCCanvas interface + */ + NS_IMETHOD_(nsIXPFCCanvas *) GetParent() = 0; + + /** + * Set the parent canvas + * @param aCanvas The parent canvas + * @result none + */ + NS_IMETHOD_(void) SetParent(nsIXPFCCanvas * aCanvas) = 0; + + /** + * Set the bounds for this container + * @param aBounds The new canvas bounds + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD SetBounds(const nsRect& aBounds) = 0; + + /** + * Get the bounds for this container + * @param aRect Reference to an nsRect for the bounds + * @result none + */ + NS_IMETHOD_(void) GetBounds(nsRect& aRect) = 0; + + /** + * Add a child canvas + * @param aChildCanvas The child canvas to add + * @param aPosition a position for inserting, default -1 means append + * @result none + */ + NS_IMETHOD_(void) AddChildCanvas(nsIXPFCCanvas * aChildCanvas, + PRInt32 aPosition = -1) = 0; + + /** + * Remove a child canvas + * @param aChildCanvas The child canvas to be removed + * @result none + */ + NS_IMETHOD_(void) RemoveChildCanvas(nsIXPFCCanvas * aChildCanvas) = 0; + + /** + * Reparent this canvas + * @param aParentCanvas The new parent + * @result none + */ + NS_IMETHOD_(void) Reparent(nsIXPFCCanvas * aParentCanvas) = 0; + + /** + * Get the background color for this canvas + * @result nscolor the background color + */ + NS_IMETHOD_(nscolor) GetBackgroundColor(void) = 0; + + /** + * Set the background color for this canvas + * @param aColor The background color + * @result none + */ + NS_IMETHOD_(void) SetBackgroundColor(const nscolor &aColor) = 0; + + /** + * Get the foreground color for this canvas + * @result nscolor the foreground color + */ + NS_IMETHOD_(nscolor) GetForegroundColor(void) = 0; + + /** + * Set the foreground color for this canvas + * @param aColor The foreground color + * @result none + */ + NS_IMETHOD_(void) SetForegroundColor(const nscolor &aColor) = 0; + + /** + * Get the border color for this canvas + * @result nscolor the border color + */ + NS_IMETHOD_(nscolor) GetBorderColor(void) = 0; + + /** + * Set the border color for this canvas + * @param aColor The border color + * @result none + */ + NS_IMETHOD_(void) SetBorderColor(const nscolor &aColor) = 0; + + /** + * Highlight the incoming color + * @param aColor the color to be highlighted + * @result nscolor, the highlighted color + */ + NS_IMETHOD_(nscolor) Highlight(const nscolor &aColor) = 0; + + /** + * Dim the incoming color + * @param aColor the color to be dimmed + * @result nscolor, the dimmed color + */ + NS_IMETHOD_(nscolor) Dim(const nscolor &aColor) = 0; + + /** + * Find the topmost canvas given an nsPoint + * @param aPoint The point over the canvas + * @result nsIXPFCCanvas pointer, the canvas under the point + */ + NS_IMETHOD_(nsIXPFCCanvas *) CanvasFromPoint(const nsPoint &aPoint) = 0; + + /** + * Find the canvas with the given tabbing data + * @param aTabGroup The tab group + * @param aTabID The tab id + * @result nsIXPFCCanvas pointer, the canvas with the tab data + */ + NS_IMETHOD_(nsIXPFCCanvas *) CanvasFromTab(PRUint32 aTabGroup, PRUint32 aTabID) = 0; + + /** + * The the preferred size for canvas's of this class + * @param aSize, the default size for this class of canvas + * @return nsresult, NS_OK if successful + */ + NS_IMETHOD GetClassPreferredSize(nsSize& aSize) = 0; + + /** + * Get the preferred size for this canvas + * @param aSize, the preferred size, [-1,-1] if no preferred size + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD GetPreferredSize(nsSize &aSize) = 0; + + /** + * Get the maximum size for this canvas + * @param aSize, the maximum size, [-1,-1] if no maximum size + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD GetMaximumSize(nsSize &aSize) = 0; + + /** + * Get the minimum size for this canvas + * @param aSize, the minimum size, [-1,-1] if no minimum size + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD GetMinimumSize(nsSize &aSize) = 0; + + /** + * Set the preferred size for this canvas + * @param aSize, the preferred size + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD SetPreferredSize(nsSize &aSize) = 0; + + /** + * Set the maximum size for this canvas + * @param aSize, the maximum size + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD SetMaximumSize(nsSize &aSize) = 0; + + /** + * Set the minimum size for this canvas + * @param aSize, the minimum size + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD SetMinimumSize(nsSize &aSize) = 0; + + /** + * Get the major axis weight + * @result PRFloat64, The weight for the major axis + */ + NS_IMETHOD_(PRFloat64) GetMajorAxisWeight() = 0; + + /** + * Get the minor axis weight + * @result PRFloat64, The weight for the minor axis + */ + NS_IMETHOD_(PRFloat64) GetMinorAxisWeight() = 0; + + /** + * Set the major axis weight + * @param aWeight, The weight for the major axis + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD SetMajorAxisWeight(PRFloat64 aWeight) = 0; + + /** + * Set the minor axis weight + * @param aWeight, The weight for the minor axis + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD SetMinorAxisWeight(PRFloat64 aWeight) = 0; + + /** + * Check to see if this container has a preferred size associated with it + * @result PRBool, PR_TRUE if the canvas has a preferred size, else PR_FALSE + */ + NS_IMETHOD_(PRBool) HasPreferredSize() = 0; + + /** + * Check to see if this container has a minimu size associated with it + * @result PRBool, PR_TRUE if the canvas has a minimum size, else PR_FALSE + */ + NS_IMETHOD_(PRBool) HasMinimumSize() = 0; + + /** + * Check to see if this container has a maximum size associated with it + * @result PRBool, PR_TRUE if the canvas has a maximum size, else PR_FALSE + */ + NS_IMETHOD_(PRBool) HasMaximumSize() = 0; + + /** + * Get the number of children this canvas has + * @result PRUint32, The number of children + */ + NS_IMETHOD_(PRUint32) GetChildCount() = 0; + + /** + * Delete all child canvas + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD DeleteChildren() = 0; + + /** + * Delete aCount child canvas's, removing from the end + * @param aCount, the number of children to be deleted + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD DeleteChildren(PRUint32 aCount) = 0; + + /** + * Find the canvas with the given name + * @param aName, the name to search for + * @result nsIXPFCCanvas pointer, The canvas with aName, nsnull if none found + */ + NS_IMETHOD_(nsIXPFCCanvas *) CanvasFromName(nsString& aName) = 0; + + /** + * Set the opacity for this canvas + * @param aOpacity, the opacity + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD SetOpacity(PRFloat64 aOpacity) = 0; + + /** + * Get the opacity for this canvas + * @result PRFloat64, the opacity + */ + NS_IMETHOD_(PRFloat64) GetOpacity() = 0; + + /** + * Set the visibility of this canvas + * @param aVisibility, PR_TRUE if visible + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD SetVisibility(PRBool aVisibility) = 0; + + /** + * Get the visibility of this canvas + * @result PRBool, PR_TRUE if visible, else PR_FALSE + */ + NS_IMETHOD_(PRBool) GetVisibility() = 0; + + /** + * Get the font for this canvas + * @result nsFont, the canvas font + */ + NS_IMETHOD_(nsFont&) GetFont() = 0; + + /** + * Set the font for this canvas + * @param aFont the nsFont for this canvas + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD SetFont(nsFont& aFont) = 0; + + /** + * Get the font metrics for this canvas + * @param nsIFontMetrics, the canvas font metrics + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD GetFontMetrics(nsIFontMetrics ** aFontMetrics) = 0; + + + /** + * Save canvas graphical state + * @param aRenderingContext, rendering context to save state to + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD PushState(nsIRenderingContext * aRenderingContext) = 0; + + /** + * Get and and set RenderingContext to this graphical state + * @param aRenderingContext, rendering context to get previously saved state from + * @return if PR_TRUE, indicates that the clipping region after + * popping state is empty, else PR_FALSE + */ + NS_IMETHOD_(PRBool) PopState(nsIRenderingContext * aRenderingContext) = 0; + + /** + * Set the tab id for this canvas + * @param aTabID, the tab id + * @return nsresult NS_OK, if successful + */ + NS_IMETHOD SetTabID(PRUint32 aTabID) = 0; + + /** + * Get the tab id for this canvas + * @return PRUint32 the tab id + */ + NS_IMETHOD_(PRUint32) GetTabID() = 0; + + /** + * Set the tab group for this canvas + * @param aTabGroup, the tab id + * @return nsresult NS_OK, if successful + */ + NS_IMETHOD SetTabGroup(PRUint32 aTabGroup) = 0; + + /** + * Get the tab group for this canvas + * @return PRUint32 the tab group + */ + NS_IMETHOD_(PRUint32) GetTabGroup() = 0; + + /** + * Set keyboard focus to this canvas + * @return nsresult, NS_OK if successful + */ + NS_IMETHOD SetFocus() = 0; + + NS_IMETHOD FindLargestTabGroup(PRUint32& aTabGroup) = 0; + NS_IMETHOD FindLargestTabID(PRUint32 aTabGroup, PRUint32& aTabID) = 0; + + /** + * Dump the canvas hierarchy to a file + * @param f, the FILE to dump to + * @param indent, the indentation level for current canvas list + * @result nsresult, NS_OK if successful + */ +#if defined(DEBUG) && defined(XP_PC) + NS_IMETHOD DumpCanvas(FILE * f, PRUint32 indent) = 0 ; +#endif + + /** + * Load a Widget with the given class ID + * @param aClassIID, The class of the nsIWidget implementation + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD LoadWidget(const nsCID &aClassIID) = 0; + +}; + +#endif /* nsIXPFCCanvas_h___ */ diff --git a/mozilla/xpfc/canvas/public/nsIXPFCCanvasManager.h b/mozilla/xpfc/canvas/public/nsIXPFCCanvasManager.h new file mode 100644 index 00000000000..f8578161131 --- /dev/null +++ b/mozilla/xpfc/canvas/public/nsIXPFCCanvasManager.h @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIXPFCCanvasManager_h___ +#define nsIXPFCCanvasManager_h___ + +#include "nsISupports.h" + +class nsIXPFCCanvas; +class nsIWidget; + +// IID for the nsIXPFCCanvasManager interface +#define NS_IXPFC_CANVAS_MANAGER_IID \ +{ 0xa4853b10, 0x28a4, 0x11d2, \ +{ 0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +/** + * XPFC CanvasManager interface. This is the interface for managing + * canvas's within the scoope of an embeddable widget + */ +class nsIXPFCCanvasManager : public nsISupports +{ + +public: + + /** + * Initialize the nsIXPFCCanvasManager + * @result The result of the initialization, NS_Ok if no errors + */ + NS_IMETHOD Init() = 0; + + /** + * Find the canvas from the given widget + * @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; + + /** + * Get a reference to the root canvas + * @param aCanvas out paramater, the root canvas to be filled in + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD GetRootCanvas(nsIXPFCCanvas ** aCanvas) = 0; + + /** + * Set the Root Canvas + * @param aCanvas the root canvas + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD SetRootCanvas(nsIXPFCCanvas * aCanvas) = 0; + + /** + * Register an association between a canvas and a widget + * @param aCanvas the canvas + * @param aWidget the widget + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD Register(nsIXPFCCanvas * aCanvas, + nsIWidget * aWidget) = 0; + + /** + * UnRegister an association between a canvas and a widget + * @param aCanvas the canvas + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD Unregister(nsIXPFCCanvas * aCanvas) = 0; + + /** + * Get the canvas with Keyboard Focus + * @result nsIXPFCCanvas pointer, the canvas with focus + */ + NS_IMETHOD_(nsIXPFCCanvas *) GetFocusedCanvas() = 0; + + /** + * Set the canvas with Keyboard Focus + * @param nsIXPFCCanvas pointer, the canvas to set focus to + * @result nsresult, NS_OK if successful + */ + NS_IMETHOD SetFocusedCanvas(nsIXPFCCanvas * aCanvas) = 0; + +}; + +#endif /* nsIXPFCCanvasManager_h___ */ diff --git a/mozilla/xpfc/canvas/src/Makefile b/mozilla/xpfc/canvas/src/Makefile new file mode 100644 index 00000000000..ea3f7f6ed86 --- /dev/null +++ b/mozilla/xpfc/canvas/src/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + diff --git a/mozilla/xpfc/canvas/src/config.mk b/mozilla/xpfc/canvas/src/config.mk new file mode 100644 index 00000000000..315c608a00a --- /dev/null +++ b/mozilla/xpfc/canvas/src/config.mk @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES += -I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = canvas +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) diff --git a/mozilla/xpfc/canvas/src/manifest.mn b/mozilla/xpfc/canvas/src/manifest.mn new file mode 100644 index 00000000000..d106888d8db --- /dev/null +++ b/mozilla/xpfc/canvas/src/manifest.mn @@ -0,0 +1,27 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsXPFCCanvas.cpp \ + nsXPFCHTMLCanvas.cpp \ + nsXPFCCanvasManager.cpp \ + $(NULL) + +REQUIRES = xpcom raptor netlib + diff --git a/mozilla/xpfc/canvas/src/nsXPFCCanvas.cpp b/mozilla/xpfc/canvas/src/nsXPFCCanvas.cpp new file mode 100644 index 00000000000..d89672d3681 --- /dev/null +++ b/mozilla/xpfc/canvas/src/nsXPFCCanvas.cpp @@ -0,0 +1,2027 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nscore.h" +#include "nsAgg.h" +#include "nsxpfcCIID.h" +#include "nsXPFCCanvas.h" +#include "nsIVector.h" +#include "nsIIterator.h" +#include "nsString.h" +#include "nsFont.h" +#include "nsGUIEvent.h" +#include "nsIWidget.h" +#include "nsIDeviceContext.h" +#include "nsWidgetsCID.h" +#include "nsColor.h" + +#include "nsBoxLayout.h" +#include "nsIXPFCCommand.h" +#include "nsIXMLParserObject.h" +#include "nsBoxLayout.h" +#include "nsxpfcCIID.h" +#include "nsxpfcstrings.h" +#include "nsXPFCMethodInvokerCommand.h" + +#include "nsXPFCToolkit.h" + +#include "nsIButton.h" +#include "nsITabWidget.h" + +#include "nspr.h" + +#define DEFAULT_WIDTH 100 +#define DEFAULT_HEIGHT 100 + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kXPFCCanvasCID, NS_XPFC_CANVAS_CID); +static NS_DEFINE_IID(kCBoxLayoutCID, NS_BOXLAYOUT_CID); +static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID); +static NS_DEFINE_IID(kIXMLParserObjectIID, NS_IXML_PARSER_OBJECT_IID); + +static NS_DEFINE_IID(kXPFCSubjectIID, NS_IXPFC_SUBJECT_IID); +static NS_DEFINE_IID(kXPFCObserverIID, NS_IXPFC_OBSERVER_IID); +static NS_DEFINE_IID(kXPFCCommandIID, NS_IXPFC_COMMAND_IID); +static NS_DEFINE_IID(kXPFCCommandReceiverIID, NS_IXPFC_COMMANDRECEIVER_IID); +static NS_DEFINE_IID(kXPFCCommandCID, NS_XPFC_COMMAND_CID); + +static NS_DEFINE_IID(kIImageObserverIID, NS_IIMAGEREQUESTOBSERVER_IID); + + +nsXPFCCanvas :: nsXPFCCanvas(nsISupports* outer) : + mFont("Times", + NS_FONT_STYLE_NORMAL, + NS_FONT_VARIANT_NORMAL, + NS_FONT_WEIGHT_NORMAL, + 0, + 12) + +{ + NS_INIT_AGGREGATED(outer); + + mWidgetSupports = nsnull; + mWidget = nsnull; + mLayout = nsnull; + mParent = nsnull; + mBackgroundColor = NS_RGB(192,192,192); + mBorderColor = NS_RGB(192,192,192); + mForegroundColor = NS_RGB(0,0,0); + + SetPreferredSize(nsSize(-1,-1)); + SetMaximumSize(nsSize(-1,-1)); + SetMinimumSize(nsSize(-1,-1)); + + mWeightMajor = (PRFloat64)(0.0); + mWeightMinor = (PRFloat64)(0.0); + + mChildWidgets = nsnull; + + // XXX: We should probably auto-generate unique names here + mNameID = "Canvas"; + mLabel = "Default Label"; + + mOpacity = 1.0; + mVisibility = PR_TRUE; + + mBounds.x = 0 ; + mBounds.y = 0 ; + mBounds.width = 0 ; + mBounds.height = 0 ; + + mTabID = 0; + mTabGroup = 0; + + mImageGroup = nsnull; + mImageRequest = nsnull; + +} + +nsXPFCCanvas :: ~nsXPFCCanvas() +{ + DeleteChildren(); + + if (nsnull != mWidgetSupports) { + NS_RELEASE(mWidgetSupports); + } + + mParent = nsnull; + + NS_IF_RELEASE(mLayout); + NS_IF_RELEASE(mChildWidgets); + + if (mImageGroup != nsnull) + { + mImageGroup->Interrupt(); + NS_IF_RELEASE(mImageRequest); + NS_RELEASE(mImageGroup); + } + +} + +NS_IMPL_AGGREGATED(nsXPFCCanvas) + +nsresult nsXPFCCanvas::AggregatedQueryInterface(const nsIID &aIID, + void** aInstancePtr) +{ + if (NULL == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + + static NS_DEFINE_IID(kCXPFCCanvasIID, NS_XPFC_CANVAS_CID); + static NS_DEFINE_IID(kIXPFCCanvasIID, NS_IXPFC_CANVAS_IID); + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + static NS_DEFINE_IID(kClassIID, kIXPFCCanvasIID); + + if (aIID.Equals(kClassIID)) { + *aInstancePtr = (void*)((nsIXPFCCanvas*)this); + AddRef(); + return NS_OK; + } + if (aIID.Equals(kCXPFCCanvasIID)) { + *aInstancePtr = (void*)((nsIXPFCCanvas*)this); + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIXPFCCanvasIID)) { + *aInstancePtr = (void*)((nsIXPFCCanvas*)this); + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIXMLParserObjectIID)) { + *aInstancePtr = (void*)((nsIXMLParserObject*)this); + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*) ((nsISupports *)&fAggregated); + AddRef(); + return NS_OK; + } + if (aIID.Equals(kXPFCObserverIID)) { + *aInstancePtr = (void*)(nsIXPFCObserver *) this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIImageObserverIID)) { + *aInstancePtr = (void*)(nsIImageRequestObserver*)this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kXPFCCommandReceiverIID)) { + *aInstancePtr = (void*)(nsIXPFCCommandReceiver *) this; + AddRef(); + return NS_OK; + } + + if (nsnull != mWidgetSupports) + return mWidgetSupports->QueryInterface(aIID, aInstancePtr); + + return NS_NOINTERFACE; +} + +nsresult nsXPFCCanvas :: SetNameID(nsString& aString) +{ + mNameID = aString; + return NS_OK; +} + +nsString& nsXPFCCanvas :: GetNameID() +{ + return mNameID; +} + +nsresult nsXPFCCanvas :: SetLabel(nsString& aString) +{ + mLabel = aString; + return NS_OK; +} + +nsString& nsXPFCCanvas :: GetLabel() +{ + return mLabel; +} + +nsIXPFCCanvas * nsXPFCCanvas::CanvasFromName(nsString& aName) +{ + /* + * If I am the canvas, just return + */ + + if (aName == mNameID) + return this; + + /* + * Ask our children + */ + + nsresult res ; + nsIIterator * iterator ; + nsIXPFCCanvas * canvas; + nsIXPFCCanvas * child_canvas ; + nsString child; + + // Iterate through the children + res = CreateIterator(&iterator); + + if (NS_OK != res) + return nsnull; + + iterator->Init(); + + while(!(iterator->IsDone())) + { + canvas = (nsIXPFCCanvas *) iterator->CurrentItem(); + + child = canvas->GetNameID(); + + if (child == aName) { + NS_RELEASE(iterator); + return canvas; + } + + child_canvas = canvas->CanvasFromName(aName); + + if (child_canvas != nsnull) { + NS_RELEASE(iterator); + return child_canvas; + } + + iterator->Next(); + } + + NS_RELEASE(iterator); + + /* + * Nobody bit... + */ + + return nsnull; +} + +nsresult nsXPFCCanvas::FindLargestTabGroup(PRUint32& aTabGroup) +{ + + if (aTabGroup == -1) + aTabGroup = 0; + + if (GetTabGroup() > aTabGroup) + aTabGroup = GetTabGroup(); + + nsresult res ; + nsIIterator * iterator ; + nsIXPFCCanvas * canvas; + PRUint32 child_group = 0; + + + // Iterate through the children + res = CreateIterator(&iterator); + + if (NS_OK != res) + return nsnull; + + iterator->Init(); + + while(!(iterator->IsDone())) + { + canvas = (nsIXPFCCanvas *) iterator->CurrentItem(); + + child_group = canvas->GetTabGroup(); + + if (child_group > aTabGroup) + aTabGroup = child_group; + + canvas->FindLargestTabGroup(aTabGroup); + + iterator->Next(); + } + + NS_RELEASE(iterator); + + return NS_OK; +} + +nsresult nsXPFCCanvas::FindLargestTabID(PRUint32 aTabGroup, PRUint32& aTabID) +{ + + if (aTabID == -1) + aTabID = 1; + + if (GetTabGroup() == aTabGroup) + { + if (GetTabID() > aTabID) + aTabID = GetTabID(); + } + + nsresult res ; + nsIIterator * iterator ; + nsIXPFCCanvas * canvas; + + // Iterate through the children + res = CreateIterator(&iterator); + + if (NS_OK != res) + return nsnull; + + iterator->Init(); + + while(!(iterator->IsDone())) + { + canvas = (nsIXPFCCanvas *) iterator->CurrentItem(); + + if (canvas->GetTabGroup() == aTabGroup) + { + if (canvas->GetTabID() > aTabID) + aTabID = canvas->GetTabID(); + } + + canvas->FindLargestTabID(aTabGroup,aTabID); + + + iterator->Next(); + } + + NS_RELEASE(iterator); + + return NS_OK; +} + +nsresult nsXPFCCanvas :: SetFocus() +{ + if (mWidget) + mWidget->SetFocus(); + + return NS_OK; +} + +nsresult nsXPFCCanvas :: SetParameter(nsString& aKey, nsString& aValue) +{ + PRInt32 error = 0; + + if (aKey.EqualsIgnoreCase(XPFC_STRING_NAME) || aKey.EqualsIgnoreCase(XPFC_STRING_ID)) { + + SetNameID(aValue); + + } else if (aKey.EqualsIgnoreCase(XPFC_STRING_LABEL)) { + + SetLabel(aValue); + + } else if (aKey.EqualsIgnoreCase(XPFC_STRING_TABID)) { + + SetTabID(aValue.ToInteger(&error)); + + } else if (aKey.EqualsIgnoreCase(XPFC_STRING_TABGROUP)) { + + SetTabGroup(aValue.ToInteger(&error)); + + } else if (aKey.EqualsIgnoreCase(XPFC_STRING_KEYBOARDFOCUS)) { + + gXPFCToolkit->GetCanvasManager()->SetFocusedCanvas((nsIXPFCCanvas *)this); + + } else if (aKey.EqualsIgnoreCase(XPFC_STRING_LAYOUT)) { + + // XXX: Layout should implement this interface. + // Then, put functionality in the core layout class + // to identify the type of layout object needed. + + if (aValue.EqualsIgnoreCase(XPFC_STRING_XBOX)) { + ((nsBoxLayout *)GetLayout())->SetLayoutAlignment(eLayoutAlignment_horizontal); + } else if (aValue.EqualsIgnoreCase(XPFC_STRING_YBOX)) { + ((nsBoxLayout *)GetLayout())->SetLayoutAlignment(eLayoutAlignment_vertical); + } + + } else if (aKey.EqualsIgnoreCase(XPFC_STRING_BACKGROUNDCOLOR)) { + + nscolor color; + char * cstring = aValue.ToNewCString(); + + if (NS_HexToRGB(cstring,&color) == PR_TRUE) + SetBackgroundColor(color); + + delete cstring; + + } else if (aKey.EqualsIgnoreCase(XPFC_STRING_FOREGROUNDCOLOR)) { + + nscolor color; + char * cstring = aValue.ToNewCString(); + + if (NS_HexToRGB(cstring,&color) == PR_TRUE) + SetForegroundColor(color); + + delete cstring; + + } else if (aKey.EqualsIgnoreCase(XPFC_STRING_HEIGHT)) { + + // XXX: This should be major/minor axis oriented + nsSize size; + GetPreferredSize(size); + SetPreferredSize(nsSize(size.width,aValue.ToInteger(&error))); + + } else if (aKey.EqualsIgnoreCase(XPFC_STRING_WIDTH)) { + + nsSize size; + GetPreferredSize(size); + SetPreferredSize(nsSize(aValue.ToInteger(&error),size.height)); + + } else if (aKey.EqualsIgnoreCase(XPFC_STRING_BACKGROUNDIMAGE)) { + + /* + * Request to load the image + */ + + nsresult res; + + res = NS_NewImageGroup(&mImageGroup); + + if (NS_OK == res) + { + + nsIDeviceContext * deviceCtx = GetWidget()->GetDeviceContext(); + + mImageGroup->Init(deviceCtx); + + NS_RELEASE(deviceCtx); + + char * url = aValue.ToNewCString(); + + nscolor bgcolor = NS_RGB(0, 0, 0); + + + mImageRequest = mImageGroup->GetImage(url, + (nsIImageRequestObserver *)this, + &bgcolor, + mBounds.width, + mBounds.height, + 0); + + delete url; + } + + + + } else if (aKey.EqualsIgnoreCase(XPFC_STRING_WEIGHTMAJOR)) { + + SetMajorAxisWeight(aValue.ToFloat(&error)); + + if (GetMajorAxisWeight() == 0) + { + nsSize size; + nsSize sizeclass; + + GetPreferredSize(size); + GetClassPreferredSize(sizeclass); + + if (size.width == -1) + size.width = sizeclass.width; + if (size.height == -1) + size.height = sizeclass.height; + + SetPreferredSize(size); + } + + } else if (aKey.EqualsIgnoreCase(XPFC_STRING_WEIGHTMINOR)) { + + SetMinorAxisWeight(aValue.ToFloat(&error)); + + } + + /* + * Check for tab# + */ + + if (aKey.Compare("tab", PR_TRUE, 3) == 0) + { + /* + * Make sure everything after the "tab" is a valid number + */ + nsString temp = aKey.Cut(0,3); + PRInt32 theInt=temp.ToInteger(&error); + + // XXX: Temp hack til clean up widget interface + if (error == NS_OK && theInt == 1) + { + nsString strings[3]; + + strings[0] = "Tab1"; + strings[1] = "Tab2"; + strings[2] = "Tab3"; + + static NS_DEFINE_IID(kInsTabWidgetIID, NS_ITABWIDGET_IID); + + nsITabWidget * tab = nsnull; + nsresult res = QueryInterface(kInsTabWidgetIID,(void**)&tab); + + if (NS_OK == res) + { + tab->SetTabs(3,strings); + NS_RELEASE(tab); + } + + return NS_OK; + + } + } + + return NS_OK; +} + + +nsresult nsXPFCCanvas :: LoadWidget(const nsCID &aClassIID) +{ + nsresult rv; + + nsISupports * supports ; + + rv = QueryInterface(kISupportsIID, (void **) &supports); + + if (NS_OK != rv) + return rv; + + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + rv = nsRepository::CreateInstance(aClassIID, supports, kISupportsIID, (void**)&mWidgetSupports); + + if (NS_OK == rv) { + static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); + rv = mWidgetSupports->QueryInterface(kIWidgetIID, (void**)&mWidget); + if (NS_OK != rv) { + mWidgetSupports->Release(); + mWidgetSupports = NULL; + } + else { + mWidget->Release(); + } + } + + + return rv; +} + +nsresult nsXPFCCanvas :: CreateWidget() +{ + + nsresult rv; + + static NS_DEFINE_IID(kCWidgetCID, NS_CHILD_CID); + + rv = LoadWidget(kCWidgetCID); + + + return rv; +} + +nsIWidget * nsXPFCCanvas :: GetWidget() +{ + + if (mWidget) + return mWidget; + + /* + * If we have no parent, this usually means it is during parsing. + * However, a canvas needs to know who it's native parent widget + * is, so since we know it is at the root grab it there. + * + * We do this because the Init() method of canvas variants require + * knowing the parent native widget in order to do proper initialization. + * + * IFF we start offering a ReParent method somewhere, we'll need to deal + * with the change in native hierarchy (yuck). + * + */ + + if (GetParent() == nsnull) { + + nsIXPFCCanvas * root = nsnull; + + gXPFCToolkit->GetRootCanvas(&root); + + if (root == this) + { + NS_RELEASE(root); + return nsnull; + } + + if (root == nsnull) + return nsnull; + + nsIWidget * widget = root->GetWidget(); + + NS_RELEASE(root); + return (widget); + + } + + return (GetParent()->GetWidget()); + +} + +nsILayout * nsXPFCCanvas :: GetLayout() +{ + return mLayout; +} + +nsresult nsXPFCCanvas :: Init() +{ + + static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID); + + nsresult res ; + +#ifdef NS_WIN32 + #define XPFC_DLL "xpfc10.dll" +#else + #define XPFC_DLL "libxpfc10.so" +#endif + + static NS_DEFINE_IID(kCVectorIteratorCID, NS_VECTOR_ITERATOR_CID); + + nsRepository::RegisterFactory(kCVectorCID, XPFC_DLL, PR_FALSE, PR_FALSE); + nsRepository::RegisterFactory(kCVectorIteratorCID, XPFC_DLL, PR_FALSE, PR_FALSE); + + + res = nsRepository::CreateInstance(kCVectorCID, + nsnull, + kCVectorCID, + (void **)&mChildWidgets); + + if (NS_OK != res) + return res ; + + mChildWidgets->Init(); + + // XXX Box Layout is the default, but probably should not be + res = nsRepository::CreateInstance(kCBoxLayoutCID, + nsnull, + kCBoxLayoutCID, + (void **)&mLayout); + + if (NS_OK != res) + return res ; + + ((nsBoxLayout *)mLayout)->Init(this); + + return res ; +} + +nsresult nsXPFCCanvas :: Init(nsNativeWidget aNativeParent, const nsRect& aBounds, EVENT_CALLBACK aHandleEventFunction) +{ + + 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); + static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); + +#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)); + + if (NS_OK != res) + return PR_FALSE; + } + + 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); + + return PR_TRUE; +} + + + +nsresult nsXPFCCanvas :: CreateIterator(nsIIterator ** aIterator) +{ + if (mChildWidgets) { + mChildWidgets->CreateIterator(aIterator); + return NS_OK; + } + return NS_ERROR_FAILURE; +} + +nsresult nsXPFCCanvas :: Layout() +{ + if (mLayout) + return (mLayout->Layout()); + else + return NS_OK; +} + +nsresult nsXPFCCanvas :: SetBounds(const nsRect &aBounds) +{ + + mBounds.x = aBounds.x ; + mBounds.y = aBounds.y ; + 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 ; + } + + + return NS_OK; +} + +void nsXPFCCanvas :: GetBounds(nsRect &aRect) +{ + + aRect.x = mBounds.x ; + aRect.y = mBounds.y ; + aRect.width = mBounds.width ; + aRect.height = mBounds.height ; + + return ; +} + +nsEventStatus nsXPFCCanvas :: DefaultProcessing(nsGUIEvent *aEvent) +{ + return (nsEventStatus_eIgnore); +} + +nsEventStatus nsXPFCCanvas :: OnPaint(nsGUIEvent *aEvent) +{ + + if (mVisibility == PR_TRUE) + { + nsIRenderingContext * ctx = ((nsPaintEvent*)aEvent)->renderingContext; + + PushState(ctx); + + PaintBackground(aEvent); + PaintBorder(aEvent); + PaintForeground(aEvent); + + PopState(ctx); + } + + + PaintChildWidgets(aEvent); + + + return (DefaultProcessing(aEvent)); + +} + +nsEventStatus nsXPFCCanvas :: OnResize(nsGUIEvent *aEvent) +{ + //SetBounds(*((nsSizeEvent*)aEvent)->windowSize); + + if (mWidget != nsnull) + { + mWidget->Invalidate(PR_FALSE); + mBounds.x = 0 ; + mBounds.y = 0 ; + } else { + mBounds.x = ((nsSizeEvent*)aEvent)->windowSize->x ; + mBounds.y = ((nsSizeEvent*)aEvent)->windowSize->y ; + } + mBounds.width = ((nsSizeEvent*)aEvent)->windowSize->width ; + mBounds.height = ((nsSizeEvent*)aEvent)->windowSize->height ; + + mLayout->Layout(); + + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas :: OnLeftButtonDown(nsGUIEvent *aEvent) +{ + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas :: OnLeftButtonUp(nsGUIEvent *aEvent) +{ + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas :: OnLeftButtonDoubleClick(nsGUIEvent *aEvent) +{ + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas :: OnMiddleButtonDown(nsGUIEvent *aEvent) +{ + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas :: OnMiddleButtonUp(nsGUIEvent *aEvent) +{ + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas :: OnMiddleButtonDoubleClick(nsGUIEvent *aEvent) +{ + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas :: OnRightButtonDown(nsGUIEvent *aEvent) +{ + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas :: OnRightButtonUp(nsGUIEvent *aEvent) +{ + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas :: OnRightButtonDoubleClick(nsGUIEvent *aEvent) +{ + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas :: OnMove(nsGUIEvent *aEvent) +{ + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas :: OnGotFocus(nsGUIEvent *aEvent) +{ + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas :: OnLostFocus(nsGUIEvent *aEvent) +{ + return (DefaultProcessing(aEvent)); +} + +void nsXPFCCanvas :: AddChildCanvas(nsIXPFCCanvas * aChildCanvas,PRInt32 aPosition) +{ + if (aPosition >= 0) + mChildWidgets->Insert(aPosition,aChildCanvas); + else + mChildWidgets->Append(aChildCanvas); + + aChildCanvas->SetParent(this); + + NS_ADDREF(aChildCanvas); + + return ; +} + +void nsXPFCCanvas :: RemoveChildCanvas(nsIXPFCCanvas * aChildCanvas) +{ + mChildWidgets->Remove(aChildCanvas); + NS_IF_RELEASE(aChildCanvas); + aChildCanvas->SetParent(nsnull); + return ; +} + +void nsXPFCCanvas :: Reparent(nsIXPFCCanvas * aParentCanvas) +{ + if (GetParent() != nsnull) + GetParent()->RemoveChildCanvas(this); + + aParentCanvas->AddChildCanvas(this); + + return ; +} + +nsIXPFCCanvas * nsXPFCCanvas :: GetParent() +{ + return (mParent); +} + +void nsXPFCCanvas :: SetParent(nsIXPFCCanvas * aCanvas) +{ + mParent = aCanvas; + return ; +} + +nscolor nsXPFCCanvas :: GetBackgroundColor(void) +{ + return mBackgroundColor; +} + +void nsXPFCCanvas :: SetBackgroundColor(const nscolor &aColor) +{ + mBackgroundColor = aColor; + + if (mWidget) + mWidget->SetBackgroundColor(aColor); +} + +nscolor nsXPFCCanvas :: GetBorderColor(void) +{ + return mBorderColor; +} + +void nsXPFCCanvas :: SetBorderColor(const nscolor &aColor) +{ + mBorderColor = aColor; +} + +nscolor nsXPFCCanvas :: GetForegroundColor(void) +{ + return mForegroundColor; +} + +void nsXPFCCanvas :: SetForegroundColor(const nscolor &aColor) +{ + mForegroundColor = aColor; + + if (mWidget) + mWidget->SetForegroundColor(aColor); +} + +nscolor nsXPFCCanvas :: Highlight(const nscolor &aColor) +{ + PRIntn r, g, b, max, over; + + r = NS_GET_R(aColor); + g = NS_GET_G(aColor); + b = NS_GET_B(aColor); + + //10% of max color increase across the board + r += 25; + g += 25; + b += 25; + + //figure out which color is largest + if (r > g) + { + if (b > r) + max = b; + else + max = r; + } + else + { + if (b > g) + max = b; + else + max = g; + } + + //if we overflowed on this max color, increase + //other components by the overflow amount + if (max > 255) + { + over = max - 255; + + if (max == r) + { + g += over; + b += over; + } + else if (max == g) + { + r += over; + b += over; + } + else + { + r += over; + g += over; + } + } + + //clamp + if (r > 255) + r = 255; + if (g > 255) + g = 255; + if (b > 255) + b = 255; + + return NS_RGBA(r, g, b, NS_GET_A(aColor)); +} + +nscolor nsXPFCCanvas :: Dim(const nscolor &aColor) +{ + + PRIntn r, g, b, max; + + r = NS_GET_R(aColor); + g = NS_GET_G(aColor); + b = NS_GET_B(aColor); + + //10% of max color decrease across the board + r -= 25; + g -= 25; + b -= 25; + + //figure out which color is largest + if (r > g) + { + if (b > r) + max = b; + else + max = r; + } + else + { + if (b > g) + max = b; + else + max = g; + } + + //if we underflowed on this max color, decrease + //other components by the underflow amount + if (max < 0) + { + if (max == r) + { + g += max; + b += max; + } + else if (max == g) + { + r += max; + b += max; + } + else + { + r += max; + g += max; + } + } + + //clamp + if (r < 0) + r = 0; + if (g < 0) + g = 0; + if (b < 0) + b = 0; + + return NS_RGBA(r, g, b, NS_GET_A(aColor)); +} + + +nsEventStatus nsXPFCCanvas :: PaintBackground(nsGUIEvent *aEvent) +{ + + 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); + } else + { + rndctx->DrawImage(img, mBounds.x, mBounds.y); + NS_RELEASE(img); + } + + return nsEventStatus_eConsumeNoDefault; +} + +nsEventStatus nsXPFCCanvas :: PaintBorder(nsGUIEvent *aEvent) +{ + 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); + + 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); + + return nsEventStatus_eConsumeNoDefault; +} + +nsEventStatus nsXPFCCanvas :: PaintForeground(nsGUIEvent *aEvent) +{ + return nsEventStatus_eConsumeNoDefault; +} + +nsEventStatus nsXPFCCanvas :: PaintChildWidgets(nsGUIEvent *aEvent) +{ + nsresult res ; + nsIIterator * iterator ; + nsIXPFCCanvas * widget ; + nsRect rect; + + // Iterate through the children + res = CreateIterator(&iterator); + + if (NS_OK != res) + return nsEventStatus_eConsumeNoDefault; + + iterator->Init(); + + while(!(iterator->IsDone())) + { + widget = (nsIXPFCCanvas *) iterator->CurrentItem(); + + widget->GetBounds(rect); + + if (rect.width != 0 && rect.height != 0) + { + if (((nsXPFCCanvas *)widget)->mWidget == nsnull) { + widget->OnPaint(aEvent); + } else { + ((nsXPFCCanvas *)widget)->mWidget->Invalidate(PR_FALSE); + } + } + + iterator->Next(); + } + + NS_RELEASE(iterator); + + return nsEventStatus_eConsumeNoDefault; + +} + +nsEventStatus nsXPFCCanvas :: ResizeChildWidgets(nsGUIEvent *aEvent) +{ + nsIIterator * iterator; + nsIXPFCCanvas * widget ; + nsresult res; + + + // Iterate through the children + res = CreateIterator(&iterator); + + if (NS_OK != res) + return nsEventStatus_eConsumeNoDefault; + + iterator->Init(); + + while(!(iterator->IsDone())) + { + widget = (nsIXPFCCanvas *) iterator->CurrentItem(); + + widget->OnResize(aEvent); + + iterator->Next(); + } + + return nsEventStatus_eConsumeNoDefault; +} + +nsEventStatus nsXPFCCanvas :: HandleEvent(nsGUIEvent *aEvent) +{ + + if (aEvent->message == NS_PAINT || aEvent->message == NS_SIZE) + { + switch(aEvent->message) + { + case NS_PAINT: + { + //if (mVisibility == PR_TRUE) + + // Optimization:: check to see that atleast one child in + // the hierarchy wants to be painted. + + if (PaintRequested() == PR_TRUE) + { + + nsEventStatus es ; + nsRect rect; + nsDrawingSurface ds; + nsIRenderingContext * ctx = ((nsPaintEvent*)aEvent)->renderingContext; + + rect.x = ((nsPaintEvent *)aEvent)->rect->x; + rect.y = ((nsPaintEvent *)aEvent)->rect->y; + rect.width = ((nsPaintEvent *)aEvent)->rect->width; + rect.height = ((nsPaintEvent *)aEvent)->rect->height; + + ds = ctx->CreateDrawingSurface(&rect); + ctx->SelectOffScreenDrawingSurface(ds); + + es = OnPaint(aEvent); + + ctx->CopyOffScreenBits(rect); + ctx->DestroyDrawingSurface(ds); + + return es; + } else { + + // Invalidate all children with native widgets + nsIIterator * iterator; + nsXPFCCanvas * canvas ; + + nsresult res = CreateIterator(&iterator); + + if (NS_OK != res) + return (DefaultProcessing(aEvent)); + + iterator->Init(); + + while(!(iterator->IsDone())) + { + canvas = (nsXPFCCanvas *) iterator->CurrentItem(); + + if (canvas->mWidget != nsnull) + mWidget->Invalidate(PR_FALSE); + + iterator->Next(); + } + + NS_IF_RELEASE(iterator); + + } + + return (DefaultProcessing(aEvent)); + + } + break; + + case NS_SIZE: + { + OnResize(aEvent); + } + break; + + case NS_TABCHANGE: + { + // TBD... + int iiii = 0; + } + break; + + } + return (DefaultProcessing(aEvent)); + } + + if (aEvent->message == NS_DESTROY) + return (DefaultProcessing(aEvent)); + + /* + * XXX: Make this a HandleInputEvent... + */ + + nsIXPFCCanvas * canvas ; + + canvas = CanvasFromPoint(aEvent->point); + + if (canvas) { + switch(aEvent->message) { + + case NS_MOUSE_LEFT_BUTTON_DOWN: + { + canvas->OnLeftButtonDown(aEvent); + } + break; + + case NS_MOUSE_LEFT_BUTTON_UP: + { + canvas->OnLeftButtonUp(aEvent); + } + break; + + case NS_MOUSE_RIGHT_BUTTON_DOWN: + { + canvas->OnLeftButtonDown(aEvent); + } + break; + + case NS_MOUSE_RIGHT_BUTTON_UP: + { + canvas->OnLeftButtonUp(aEvent); + } + break; + + case NS_MOUSE_MOVE: + { + canvas->OnMouseMove(aEvent); + } + break; + + case NS_MOUSE_ENTER: + { + canvas->OnMouseEnter(aEvent); + } + break; + + case NS_MOUSE_EXIT: + { + canvas->OnMouseExit(aEvent); + } + break; + + case NS_KEY_UP: + { + canvas->OnKeyUp(aEvent); + } + break; + + case NS_KEY_DOWN: + { + canvas->OnKeyDown(aEvent); + } + break; + + + } + } + + return (DefaultProcessing(aEvent)); + +} + +PRBool nsXPFCCanvas::PaintRequested() +{ + PRBool bRequested = mVisibility; + nsIIterator * iterator; + nsXPFCCanvas * canvas ; + + nsresult res = CreateIterator(&iterator); + + if (NS_OK != res) + return bRequested; + + iterator->Init(); + + while(!(iterator->IsDone())) + { + canvas = (nsXPFCCanvas *) iterator->CurrentItem(); + + if (canvas->mWidget == nsnull) + { + + if(canvas->GetVisibility() == PR_TRUE) + { + bRequested = PR_TRUE; + break; + } else { + + if (canvas->PaintRequested() == PR_TRUE) + { + bRequested = PR_TRUE; + break; + } + + } + + } + + iterator->Next(); + } + + NS_IF_RELEASE(iterator); + + return bRequested; +} + +nsIXPFCCanvas * nsXPFCCanvas :: CanvasFromPoint(const nsPoint &aPoint) +{ + nsresult res; + nsIIterator * iterator ; + nsIXPFCCanvas * canvas ; + nsIXPFCCanvas * candidate = nsnull; + nsIXPFCCanvas * winner = nsnull; + nsRect rect; + + // Iterate through the children + res = CreateIterator(&iterator); + + if (NS_OK != res) + return nsnull; + + iterator->Init(); + + while(!(iterator->IsDone())) + { + canvas = (nsIXPFCCanvas *) iterator->CurrentItem(); + + canvas->GetBounds(rect); + + if (rect.Contains(aPoint)) + { + candidate = canvas; + break; + } + + iterator->Next(); + } + + if (candidate == nsnull) + { + winner = this ; + } else + { + nsIXPFCCanvas * child = candidate->CanvasFromPoint(aPoint); + + if (child == nsnull) + winner = candidate; + else + winner = candidate->CanvasFromPoint(aPoint); + } + + NS_RELEASE(iterator); + + return winner; + +} + +/* + * -1 for group or id means find the last one in that collection + */ + +nsIXPFCCanvas * nsXPFCCanvas :: CanvasFromTab(PRUint32 aTabGroup, PRUint32 aTabID) +{ + + if (aTabGroup == -1) + FindLargestTabGroup(aTabGroup); + + if (aTabID == -1) + FindLargestTabID(aTabGroup,aTabID); + + /* + * If I am the canvas, just return + */ + + if ((GetTabGroup() == aTabGroup) && (GetTabID() == aTabID)) + return this; + + /* + * Ask our children + */ + + nsresult res ; + nsIIterator * iterator ; + nsIXPFCCanvas * canvas; + nsIXPFCCanvas * child_canvas ; + + // Iterate through the children + res = CreateIterator(&iterator); + + if (NS_OK != res) + return nsnull; + + iterator->Init(); + + while(!(iterator->IsDone())) + { + canvas = (nsIXPFCCanvas *) iterator->CurrentItem(); + + if (canvas->GetTabGroup() == aTabGroup && canvas->GetTabID() == aTabID) + { + NS_RELEASE(iterator); + return canvas; + } + + child_canvas = canvas->CanvasFromTab(aTabGroup,aTabID); + + if (child_canvas != nsnull) { + NS_RELEASE(iterator); + return child_canvas; + } + + iterator->Next(); + } + + NS_RELEASE(iterator); + + /* + * Nobody bit... + */ + + return nsnull; + +} + +PRFloat64 nsXPFCCanvas :: GetMajorAxisWeight() +{ + return (mWeightMajor); +} + +PRFloat64 nsXPFCCanvas :: GetMinorAxisWeight() +{ + return (mWeightMinor); +} + +nsresult nsXPFCCanvas :: SetMajorAxisWeight(PRFloat64 aWeight) +{ + mWeightMajor = aWeight; + return NS_OK; +} + +nsresult nsXPFCCanvas :: SetMinorAxisWeight(PRFloat64 aWeight) +{ + mWeightMinor = aWeight; + return NS_OK; +} + +/* + * Our preferred size is the preferred (max) of all children + */ + +nsresult nsXPFCCanvas :: GetClassPreferredSize(nsSize& aSize) +{ + nsresult res; + nsIIterator * iterator ; + nsIXPFCCanvas * canvas ; + nsSize temp; + + aSize.width = DEFAULT_WIDTH; + aSize.height = DEFAULT_HEIGHT; + + // Iterate through the children + res = CreateIterator(&iterator); + + if (NS_OK != res) + return (res); + + iterator->Init(); + + aSize.width = 0; + aSize.height = 0; + + while(!(iterator->IsDone())) + { + canvas = (nsIXPFCCanvas *) iterator->CurrentItem(); + + canvas->GetClassPreferredSize(temp); + + if (temp.width > aSize.width) + aSize.width = temp.width; + if (temp.height > aSize.height) + aSize.height = temp.height; + + iterator->Next(); + } + + NS_RELEASE(iterator); + + + if (aSize.width == 0) + aSize.width = DEFAULT_WIDTH; + if (aSize.height == 0) + aSize.height = DEFAULT_HEIGHT; + + return (NS_OK); +} + +nsresult nsXPFCCanvas :: GetPreferredSize(nsSize &aSize) +{ + aSize = mPreferredSize ; + return NS_OK; +} +nsresult nsXPFCCanvas :: GetMaximumSize(nsSize &aSize) +{ + aSize = mMaximumSize ; + return NS_OK; +} +nsresult nsXPFCCanvas :: GetMinimumSize(nsSize &aSize) +{ + aSize = mMinimumSize ; + return NS_OK; +} + +nsresult nsXPFCCanvas :: SetPreferredSize(nsSize &aSize) +{ + mPreferredSize = aSize; + return NS_OK; +} +nsresult nsXPFCCanvas :: SetMaximumSize(nsSize &aSize) +{ + mMaximumSize = aSize; + return NS_OK; +} +nsresult nsXPFCCanvas :: SetMinimumSize(nsSize &aSize) +{ + mMinimumSize = aSize; + return NS_OK; +} + +PRBool nsXPFCCanvas :: HasPreferredSize() +{ + if (mPreferredSize.width == -1 && mPreferredSize.height == -1) + return PR_FALSE; + + return PR_TRUE; +} + +PRBool nsXPFCCanvas :: HasMinimumSize() +{ + if (mMinimumSize.width == -1 && mMinimumSize.height == -1) + return PR_FALSE; + + return PR_TRUE; +} + +PRBool nsXPFCCanvas :: HasMaximumSize() +{ + if (mMaximumSize.width == -1 && mMaximumSize.height == -1) + return PR_FALSE; + + return PR_TRUE; +} + +PRUint32 nsXPFCCanvas :: GetChildCount() +{ + nsresult res ; + nsIIterator * iterator ; + PRUint32 count = 0 ; + + res = CreateIterator(&iterator); + + if (NS_OK != res) + return res; + + iterator->Init(); + + count = iterator->Count(); + + NS_IF_RELEASE(iterator); + + return (count); +} + +nsresult nsXPFCCanvas :: DeleteChildren() +{ + return (DeleteChildren(GetChildCount())); +} + +nsresult nsXPFCCanvas :: DeleteChildren(PRUint32 aCount) +{ + nsresult res ; + nsIIterator * iterator ; + nsIXPFCCanvas * widget ; + PRUint32 index = 0; + + // Iterate through the children ... backwards + res = CreateIterator(&iterator); + + if (NS_OK != res) + return res; + + iterator->Init(); + + iterator->Last(); + + while(aCount != index) + { + widget = (nsIXPFCCanvas *) iterator->CurrentItem(); + + if (mChildWidgets != nsnull) + mChildWidgets->Remove(widget); + + NS_IF_RELEASE(widget); + + index++; + + iterator->Previous(); + } + + NS_IF_RELEASE(iterator); + + return NS_OK; + +} + +#if defined(DEBUG) && defined(XP_PC) +nsresult nsXPFCCanvas :: DumpCanvas(FILE * f, PRUint32 indent) +{ + nsRect bounds; + + for (PRInt32 i = indent; --i >= 0; ) fputs(" ", f); + + GetBounds(bounds); + + fprintf(f, "Canvas [x,y,width,height] = [%d,%d,%d,%d]\n",bounds.x, bounds.y, bounds.width, bounds.height); + + nsresult res ; + nsIIterator * iterator ; + nsIXPFCCanvas * widget ; + + // Iterate through the children + res = CreateIterator(&iterator); + + if (NS_OK == res) { + + iterator->Init(); + + while(!(iterator->IsDone())) + { + widget = (nsIXPFCCanvas *) iterator->CurrentItem(); + + widget->DumpCanvas(f, indent+1); + + iterator->Next(); + } + + NS_RELEASE(iterator); + + } + + + for (i = indent; --i >= 0; ) fputs(" ", f); + fputs(">\n", f); + + return 0; +} +#endif + + + +nsresult nsXPFCCanvas::Update(nsIXPFCSubject * aSubject, nsIXPFCCommand * aCommand) +{ + + /* + * Update our internal structure based on this update + */ + + Action(aCommand); + + return NS_OK; +} + +nsresult nsXPFCCanvas::Action(nsIXPFCCommand * aCommand) +{ + + /* + * If this is a MethodInvoker Command, invoke it. + */ + + nsresult res; + + nsXPFCMethodInvokerCommand * methodinvoker_command = nsnull; + static NS_DEFINE_IID(kXPFCMethodInvokerCommandCID, NS_XPFC_METHODINVOKER_COMMAND_CID); + + res = aCommand->QueryInterface(kXPFCMethodInvokerCommandCID,(void**)&methodinvoker_command); + + if (NS_OK == res) + { + + if (methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_SETBACKGROUNDCOLOR)) + { + nscolor color; + + char * ccolor = methodinvoker_command->mParams.ToNewCString(); + + NS_HexToRGB(ccolor, &color); + + SetBackgroundColor(color); + + delete ccolor; + } + else if (methodinvoker_command->mMethod.EqualsIgnoreCase(XPFC_STRING_GETBACKGROUNDCOLOR)) + { + nsString reply_string("ABGR = "); + + reply_string.Append(GetBackgroundColor(),16); + + methodinvoker_command->mReply = reply_string; + + } + + NS_RELEASE(methodinvoker_command); + } + + /* + * Just paint ourselves for now + */ + + GetWidget()->Invalidate(PR_FALSE); + return NS_OK; +} + +nsEventStatus nsXPFCCanvas::OnMouseMove(nsGUIEvent *aEvent) +{ + GetWidget()->SetCursor(eCursor_standard); + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas::OnMouseEnter(nsGUIEvent *aEvent) +{ + GetWidget()->SetCursor(eCursor_standard); + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas::OnMouseExit(nsGUIEvent *aEvent) +{ + GetWidget()->SetCursor(eCursor_standard); + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas::OnKeyUp(nsGUIEvent *aEvent) +{ + return (DefaultProcessing(aEvent)); +} + +nsEventStatus nsXPFCCanvas::OnKeyDown(nsGUIEvent *aEvent) +{ + + if (((nsKeyEvent*)aEvent)->keyCode == NS_VK_TAB) + { + nsIXPFCCanvas * canvas = nsnull; + nsIXPFCCanvas * parent = nsnull ; + nsIXPFCCanvas * temp = GetParent() ; + + while (temp != nsnull) + { + parent = temp; + temp = parent->GetParent(); + } + + if (parent == nsnull) + parent = this; + + if (((nsKeyEvent*)aEvent)->isShift == PR_TRUE) + { + + if (GetTabID() != 1) + canvas = parent->CanvasFromTab(GetTabGroup(), GetTabID()-1); + + if (canvas == nsnull && GetTabGroup() != 0) + canvas = parent->CanvasFromTab(GetTabGroup()-1, -1); + + if (canvas == nsnull) + canvas = parent->CanvasFromTab(-1, -1); + + if (canvas != nsnull) + gXPFCToolkit->GetCanvasManager()->SetFocusedCanvas(canvas); + } else + { + canvas = parent->CanvasFromTab(GetTabGroup(), GetTabID()+1); + + if (canvas == nsnull) + canvas = parent->CanvasFromTab(GetTabGroup()+1, 1); + + if (canvas == nsnull) + canvas = parent->CanvasFromTab(0, 1); + + if (canvas != nsnull) + gXPFCToolkit->GetCanvasManager()->SetFocusedCanvas(canvas); + } + + } + return (DefaultProcessing(aEvent)); +} + +nsresult nsXPFCCanvas::SetOpacity(PRFloat64 aOpacity) +{ + mOpacity = aOpacity; + return NS_OK; +} + +PRFloat64 nsXPFCCanvas::GetOpacity() +{ + return mOpacity; +} + +nsresult nsXPFCCanvas::SetVisibility(PRBool aVisibility) +{ + mVisibility = aVisibility; + return NS_OK; +} + +PRBool nsXPFCCanvas::GetVisibility() +{ + return mVisibility; +} + +nsresult nsXPFCCanvas::SetTabID(PRUint32 aTabID) +{ + mTabID = aTabID; + return NS_OK; +} + +PRUint32 nsXPFCCanvas::GetTabID() +{ + return mTabID; +} + +nsresult nsXPFCCanvas::SetTabGroup(PRUint32 aTabGroup) +{ + mTabGroup = aTabGroup; + return NS_OK; +} + +PRUint32 nsXPFCCanvas::GetTabGroup() +{ + return mTabGroup; +} + +nsresult nsXPFCCanvas::SetFont(nsFont& aFont) +{ + mFont = aFont; + return NS_OK; +} + +nsFont& nsXPFCCanvas::GetFont() +{ + return mFont; +} + +nsresult nsXPFCCanvas::GetFontMetrics(nsIFontMetrics ** aFontMetrics) +{ + nsIDeviceContext * context = nsnull; + + if (GetWidget()) + context = GetWidget()->GetDeviceContext(); + + if (nsnull != context) + context->GetMetricsFor(mFont,*aFontMetrics); + + NS_IF_RELEASE(context); + + return NS_OK; +} + +nsresult nsXPFCCanvas::PushState(nsIRenderingContext * aRenderingContext) +{ + aRenderingContext->PushState(); + + aRenderingContext->SetFont(mFont); + + return NS_OK; +} + +PRBool nsXPFCCanvas::PopState(nsIRenderingContext * aRenderingContext) +{ + return (aRenderingContext->PopState()); +} + +void +nsXPFCCanvas::Notify(nsIImageRequest *aImageRequest, + nsIImage *aImage, + nsImageNotification aNotificationType, + PRInt32 aParam1, PRInt32 aParam2, + void *aParam3) +{ + return ; +} + +void +nsXPFCCanvas::NotifyError(nsIImageRequest *aImageRequest, + nsImageError aErrorType) +{ + return ; +} diff --git a/mozilla/xpfc/canvas/src/nsXPFCCanvasManager.cpp b/mozilla/xpfc/canvas/src/nsXPFCCanvasManager.cpp new file mode 100644 index 00000000000..cc93edc89cb --- /dev/null +++ b/mozilla/xpfc/canvas/src/nsXPFCCanvasManager.cpp @@ -0,0 +1,197 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsXPFCCanvasManager.h" +#include "nsIXPFCCanvas.h" +#include "nsIWidget.h" +#include "nsxpfcCIID.h" + +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); + +class ListEntry { +public: + nsIWidget * widget; + nsIXPFCCanvas * canvas; + + ListEntry(nsIWidget * aWidget, + nsIXPFCCanvas * aCanvas) { + widget = aWidget; + canvas = aCanvas; + } + ~ListEntry() { + } +}; + + +nsXPFCCanvasManager :: nsXPFCCanvasManager() +{ + NS_INIT_REFCNT(); + mList = nsnull; + monitor = nsnull; + mRootCanvas = nsnull; + mFocusedCanvas = nsnull; +} + +nsXPFCCanvasManager :: ~nsXPFCCanvasManager() +{ + PR_DestroyMonitor(monitor); + NS_IF_RELEASE(mRootCanvas); + NS_IF_RELEASE(mList); +} + +NS_IMPL_ADDREF(nsXPFCCanvasManager) +NS_IMPL_RELEASE(nsXPFCCanvasManager) +NS_IMPL_QUERY_INTERFACE(nsXPFCCanvasManager, kXPFCCanvasManagerIID) + +nsresult nsXPFCCanvasManager::Init() +{ + if (mList == nsnull) { + + static NS_DEFINE_IID(kCVectorIteratorCID, NS_VECTOR_ITERATOR_CID); + static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID); + + nsresult res = nsRepository::CreateInstance(kCVectorCID, + nsnull, + kCVectorCID, + (void **)&mList); + + if (NS_OK != res) + return res ; + + mList->Init(); + } + + if (monitor == nsnull) { + monitor = PR_NewMonitor(); + } + + return NS_OK; +} + +nsIXPFCCanvas * nsXPFCCanvasManager::CanvasFromWidget(nsIWidget * aWidget) +{ + nsIXPFCCanvas * canvas = nsnull; + + PR_EnterMonitor(monitor); + + nsIIterator * iterator; + + mList->CreateIterator(&iterator); + + iterator->Init(); + + ListEntry * item ; + + while(!(iterator->IsDone())) + { + item = (ListEntry *) iterator->CurrentItem(); + + if (item->widget == aWidget) + { + canvas = item->canvas; + break; + } + + iterator->Next(); + } + + NS_RELEASE(iterator); + + PR_ExitMonitor(monitor); + + return (canvas); +} + +nsresult nsXPFCCanvasManager::Register(nsIXPFCCanvas * aCanvas, nsIWidget * aWidget) +{ + PR_EnterMonitor(monitor); + + mList->Append(new ListEntry(aWidget, aCanvas)); + + PR_ExitMonitor(monitor); + + return NS_OK; +} + +nsresult nsXPFCCanvasManager::Unregister(nsIXPFCCanvas * aCanvas) +{ + + PR_EnterMonitor(monitor); + + /* + * We need to loop through looking for a match of both and then remove them + */ + nsIIterator * iterator; + + mList->CreateIterator(&iterator); + + iterator->Init(); + + ListEntry * item ; + + while(!(iterator->IsDone())) + { + item = (ListEntry *) iterator->CurrentItem(); + + if (item->canvas == aCanvas) + { + mList->Remove((nsComponent)item); + break; + } + + iterator->Next(); + } + + NS_RELEASE(iterator); + + PR_ExitMonitor(monitor); + + return NS_OK; +} + +nsresult nsXPFCCanvasManager::GetRootCanvas(nsIXPFCCanvas ** aCanvas) +{ + *aCanvas = mRootCanvas; + NS_ADDREF(mRootCanvas); + return NS_OK; +} + +nsresult nsXPFCCanvasManager::SetRootCanvas(nsIXPFCCanvas * aCanvas) +{ + NS_IF_RELEASE(mRootCanvas); + mRootCanvas = aCanvas; + NS_ADDREF(mRootCanvas); + return NS_OK; +} + +nsresult nsXPFCCanvasManager::SetFocusedCanvas(nsIXPFCCanvas * aCanvas) +{ + mFocusedCanvas = aCanvas; + + mFocusedCanvas->SetFocus(); + + return NS_OK; +} + +nsIXPFCCanvas * nsXPFCCanvasManager::GetFocusedCanvas() +{ + return(mFocusedCanvas); +} diff --git a/mozilla/xpfc/canvas/src/nsXPFCHTMLCanvas.cpp b/mozilla/xpfc/canvas/src/nsXPFCHTMLCanvas.cpp new file mode 100644 index 00000000000..3411f2b11ca --- /dev/null +++ b/mozilla/xpfc/canvas/src/nsXPFCHTMLCanvas.cpp @@ -0,0 +1,149 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsXPFCHTMLCanvas.h" +#include "nsxpfcCIID.h" +#include "nsIWebShell.h" +#include "nsIDeviceContext.h" +#include "nsFont.h" +#include "nsIFontMetrics.h" +#include "nspr.h" +#include "nsxpfcstrings.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kXPFCHTMLCanvasCID, NS_XPFC_HTML_CANVAS_CID); + +#define kNotFound -1 + +#define DEFAULT_WIDTH 25 +#define DEFAULT_HEIGHT 25 + +nsXPFCHTMLCanvas :: nsXPFCHTMLCanvas(nsISupports* outer) : nsXPFCCanvas(outer) +{ + NS_INIT_REFCNT(); + mWebShell = nsnull; +} + +nsXPFCHTMLCanvas :: ~nsXPFCHTMLCanvas() +{ + NS_IF_RELEASE(mWebShell); +} + +nsresult nsXPFCHTMLCanvas::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, kXPFCHTMLCanvasCID); + if (aIID.Equals(kClassIID)) { + *aInstancePtr = (void*) (nsXPFCHTMLCanvas *)this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*) (this); + AddRef(); + return NS_OK; + } + return (nsXPFCCanvas::QueryInterface(aIID, aInstancePtr)); +} + +NS_IMPL_ADDREF(nsXPFCHTMLCanvas) +NS_IMPL_RELEASE(nsXPFCHTMLCanvas) + +nsresult nsXPFCHTMLCanvas :: Init() +{ + static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); + static NS_DEFINE_IID(kCWebShellCID, NS_WEB_SHELL_CID); + + nsresult res = nsRepository::CreateInstance(kCWebShellCID, + nsnull, + kIWebShellIID, + (void**)&mWebShell); + + + 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->Show(); + + nsString url("about:blank"); + + PRUnichar* p = url.ToNewUnicode(); + + mWebShell->LoadURL(p, nsnull); + + delete p; + + return NS_OK; +} + +nsEventStatus nsXPFCHTMLCanvas :: OnResize(nsGUIEvent *aEvent) +{ + return (nsXPFCCanvas::OnResize(aEvent)); +} + +nsresult nsXPFCHTMLCanvas :: SetBounds(const nsRect &aBounds) +{ + nsXPFCCanvas::SetBounds(aBounds); + if (mWebShell != nsnull) + mWebShell->SetBounds(aBounds.x,aBounds.y,aBounds.width,aBounds.height); + return (NS_OK); +} + + +nsEventStatus nsXPFCHTMLCanvas :: OnPaint(nsGUIEvent *aEvent) +{ + nsEventStatus es = nsXPFCCanvas::OnPaint(aEvent); + if (mWebShell != nsnull) + mWebShell->Repaint(PR_FALSE); + return (es); +} + +nsEventStatus nsXPFCHTMLCanvas :: HandleEvent(nsGUIEvent *aEvent) +{ + return (nsXPFCCanvas::HandleEvent(aEvent)); +} + +nsresult nsXPFCHTMLCanvas :: GetClassPreferredSize(nsSize& aSize) +{ + aSize.width = DEFAULT_WIDTH; + aSize.height = DEFAULT_HEIGHT; + return (NS_OK); +} + + +nsresult nsXPFCHTMLCanvas :: SetParameter(nsString& aKey, nsString& aValue) +{ + if (aKey.EqualsIgnoreCase(XPFC_STRING_SRC)) { + + PRUnichar* p = aValue.ToNewUnicode(); + + mWebShell->LoadURL(p, nsnull); + + delete p; + + } + + return (nsXPFCCanvas::SetParameter(aKey,aValue)); +} diff --git a/mozilla/xpfc/chrome/Makefile b/mozilla/xpfc/chrome/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/chrome/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/chrome/inc/Makefile b/mozilla/xpfc/chrome/inc/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/chrome/inc/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/chrome/inc/manifest.mn b/mozilla/xpfc/chrome/inc/manifest.mn new file mode 100644 index 00000000000..6b40f81958a --- /dev/null +++ b/mozilla/xpfc/chrome/inc/manifest.mn @@ -0,0 +1,23 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + nsMenuContainer.h \ + nsMenuItem.h \ + nsXPFCToolbar.h \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/chrome/inc/nsMenuContainer.h b/mozilla/xpfc/chrome/inc/nsMenuContainer.h new file mode 100644 index 00000000000..cd19a035a15 --- /dev/null +++ b/mozilla/xpfc/chrome/inc/nsMenuContainer.h @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef __NS_MENU_CONTAINER +#define __NS_MENU_CONTAINER + +#include "nsIMenuContainer.h" +#include "nsIMenuBar.h" +#include "nsMenuItem.h" +#include "nsIVector.h" +#include "nsIIterator.h" +#include "nsIXPFCCommandReceiver.h" + +class nsMenuContainer : public nsIMenuContainer, + public nsIMenuBar, + public nsIXPFCCommandReceiver, + public nsMenuItem +{ + +public: + + /** + * Constructor and Destructor + */ + + nsMenuContainer(); + ~nsMenuContainer(); + + /** + * ISupports Interface + */ + NS_DECL_ISUPPORTS + + /** + * Initialize Method + * @result The result of the initialization, NS_OK if no errors + */ + NS_IMETHOD Init(); + + NS_IMETHOD AddMenuItem(nsIMenuItem * aMenuItem); + NS_IMETHOD_(void*) GetNativeHandle(); + + // nsIXMLParserObject methods + NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ; + + NS_IMETHOD AddChild(nsIMenuItem * aItem); + NS_IMETHOD Update() ; + NS_IMETHOD SetShellContainer(nsIShellInstance * aShellInstance,nsIWebViewerContainer * aWebViewerContainer) ; + NS_IMETHOD_(nsIMenuItem *) MenuItemFromID(PRUint32 aID) ; + NS_IMETHOD Action(nsIXPFCCommand * aCommand) ; + +private: + NS_IMETHOD ProcessActionCommand(nsString& aAction); + +protected: + nsIVector * mChildMenus ; + nsIShellInstance * mShellInstance; + nsIWebViewerContainer * mWebViewerContainer; +}; + + + +#endif diff --git a/mozilla/xpfc/chrome/inc/nsMenuItem.h b/mozilla/xpfc/chrome/inc/nsMenuItem.h new file mode 100644 index 00000000000..c70d592a125 --- /dev/null +++ b/mozilla/xpfc/chrome/inc/nsMenuItem.h @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef __NS_MENU_ITEM +#define __NS_MENU_ITEM + +#include "nsIMenuItem.h" +#include "nsIXMLParserObject.h" +#include "nsIXPFCCommandReceiver.h" + +class nsMenuItem : public nsIMenuItem, + public nsIXMLParserObject +{ + +public: + + /** + * Constructor and Destructor + */ + + nsMenuItem(); + ~nsMenuItem(); + + /** + * ISupports Interface + */ + NS_DECL_ISUPPORTS + + /** + * Initialize Method + * @result The result of the initialization, NS_OK if no errors + */ + NS_IMETHOD Init(); + + // nsIXMLParserObject methods + NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ; + + NS_IMETHOD SetName(nsString& aName) ; + NS_IMETHOD_(nsString&) GetName() ; + NS_IMETHOD SetLabel(nsString& aLabel) ; + NS_IMETHOD_(nsString&) GetLabel() ; + NS_IMETHOD SetCommand(nsString& aLabel); + NS_IMETHOD_(nsString&) GetCommand(); + + NS_IMETHOD_(nsIMenuContainer *) GetParent(); + NS_IMETHOD SetParent(nsIMenuContainer * aMenuContainer); + + NS_IMETHOD_(PRBool) IsSeparator() ; + + NS_IMETHOD_(nsAlignmentStyle) GetAlignmentStyle(); + NS_IMETHOD SetAlignmentStyle(nsAlignmentStyle aAlignmentStyle); + + NS_IMETHOD_(PRUint32) GetMenuID() ; + NS_IMETHOD SetMenuID(PRUint32 aID) ; + + NS_IMETHOD SendCommand() ; + NS_IMETHOD SetReceiver(nsIXPFCCommandReceiver * aReceiver) ; + + NS_IMETHOD_(PRBool) GetEnabled(); + NS_IMETHOD SetEnabled(PRBool aEnable); + +private: + nsString mName; + nsString mLabel; + nsString mCommand; + nsIMenuContainer * mParent; + PRBool mSeparator; + nsAlignmentStyle mAlignmentStyle; + PRUint32 mID; + nsIXPFCCommandReceiver * mReceiver; + PRBool mEnabled; +}; + + +#endif diff --git a/mozilla/xpfc/chrome/inc/nsXPFCToolbar.h b/mozilla/xpfc/chrome/inc/nsXPFCToolbar.h new file mode 100644 index 00000000000..9c0f76ffd33 --- /dev/null +++ b/mozilla/xpfc/chrome/inc/nsXPFCToolbar.h @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsXPFCToolbar_h___ +#define nsXPFCToolbar_h___ + +#include "nsIXPFCToolbar.h" +#include "nsXPFCCanvas.h" + +class nsXPFCToolbar : public nsIXPFCToolbar, + public nsXPFCCanvas + +{ +public: + nsXPFCToolbar(nsISupports* outer); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init(); + + NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ; + NS_IMETHOD GetClassPreferredSize(nsSize& aSize); + +protected: + ~nsXPFCToolbar(); + + +}; + +#endif /* nsXPFCToolbar_h___ */ diff --git a/mozilla/xpfc/chrome/manifest.mn b/mozilla/xpfc/chrome/manifest.mn new file mode 100644 index 00000000000..31c885e982d --- /dev/null +++ b/mozilla/xpfc/chrome/manifest.mn @@ -0,0 +1,16 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../.. +DEPTH = ../../../.. + +DIRS_EXPORT = public inc +DIRS_LIBS = src +DIRS = $(PLATFORM_DIRECTORY) + diff --git a/mozilla/xpfc/chrome/public/Makefile b/mozilla/xpfc/chrome/public/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/chrome/public/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/chrome/public/manifest.mn b/mozilla/xpfc/chrome/public/manifest.mn new file mode 100644 index 00000000000..4dc9a2e6161 --- /dev/null +++ b/mozilla/xpfc/chrome/public/manifest.mn @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. +DEPTH = ../../../../.. + +EXPORTS = \ + nsIMenuBar.h \ + nsIMenuContainer.h \ + nsIMenuItem.h \ + nsIXPFCToolbar.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/chrome/public/nsIMenuBar.h b/mozilla/xpfc/chrome/public/nsIMenuBar.h new file mode 100644 index 00000000000..4948a53f22e --- /dev/null +++ b/mozilla/xpfc/chrome/public/nsIMenuBar.h @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIMenuBar_h___ +#define nsIMenuBar_h___ + +#include "nsISupports.h" +#include "nsIShellInstance.h" +#include "nsIMenuItem.h" +#include "nsIMenuContainer.h" +#include "nsIWebViewerContainer.h" + +// 52fb95f0-2cbe-11d2-9246-00805f8a7ab6 +#define NS_IMENUBAR_IID \ + { 0x52fb95f0, 0x2cbe, 0x11d2, \ + {0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +class nsIMenuBar : public nsISupports +{ + +public: + + NS_IMETHOD SetShellContainer(nsIShellInstance * aShellInstance, + nsIWebViewerContainer * aWebViewerContainer) = 0 ; + NS_IMETHOD_(nsIMenuItem *) MenuItemFromID(PRUint32 aID) = 0; +}; + +#endif /* nsIMenuBar_h___ */ + diff --git a/mozilla/xpfc/chrome/public/nsIMenuContainer.h b/mozilla/xpfc/chrome/public/nsIMenuContainer.h new file mode 100644 index 00000000000..ef72d5d399a --- /dev/null +++ b/mozilla/xpfc/chrome/public/nsIMenuContainer.h @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIMenuContainer_h___ +#define nsIMenuContainer_h___ + +#include "nsISupports.h" +#include "nsIShellInstance.h" +#include "nsIMenuItem.h" + +// 0b396820-2f54-11d2-bede-00805f8a8dbd +#define NS_IMENUCONTAINER_IID \ + { 0x0b396820, 0x2f54, 0x11d2, \ + {0xbe, 0xde, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd} } + +class nsIMenuContainer : public nsISupports +{ + +public: + + /** + * Initialize the MenuContainer + * @result The result of the initialization, NS_Ok if no errors + */ + NS_IMETHOD Init() = 0; + + NS_IMETHOD AddMenuItem(nsIMenuItem * aMenuItem) = 0; + NS_IMETHOD_(void*) GetNativeHandle() = 0; + NS_IMETHOD AddChild(nsIMenuItem * aItem) = 0; + NS_IMETHOD Update() = 0; + NS_IMETHOD_(nsIMenuItem *) MenuItemFromID(PRUint32 aID) = 0; + +}; + +#endif /* nsIMenuContainer_h___ */ + diff --git a/mozilla/xpfc/chrome/public/nsIMenuItem.h b/mozilla/xpfc/chrome/public/nsIMenuItem.h new file mode 100644 index 00000000000..68ce124e333 --- /dev/null +++ b/mozilla/xpfc/chrome/public/nsIMenuItem.h @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIMenuItem_h___ +#define nsIMenuItem_h___ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIXPFCCommandReceiver.h" + +// 8a400b00-2cbe-11d2-9246-00805f8a7ab6 +#define NS_IMENUITEM_IID \ + { 0x8a400b00, 0x2cbe, 0x11d2, \ + {0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +class nsIMenuContainer; + +enum nsAlignmentStyle +{ + eAlignmentStyle_none, + eAlignmentStyle_left, + eAlignmentStyle_right +}; + + +class nsIMenuItem : public nsISupports +{ + +public: + + /** + * Initialize the MenuBar + * @result The result of the initialization, NS_Ok if no errors + */ + NS_IMETHOD Init() = 0; + + NS_IMETHOD SetName(nsString& aName) = 0; + NS_IMETHOD_(nsString&) GetName() = 0; + + NS_IMETHOD SetLabel(nsString& aLabel) = 0; + NS_IMETHOD_(nsString&) GetLabel() = 0; + + NS_IMETHOD SetCommand(nsString& aLabel) = 0; + NS_IMETHOD_(nsString&) GetCommand() = 0; + + NS_IMETHOD_(nsIMenuContainer *) GetParent() = 0; + NS_IMETHOD SetParent(nsIMenuContainer * aMenuContainer) = 0; + + NS_IMETHOD_(PRBool) IsSeparator() = 0; + NS_IMETHOD_(nsAlignmentStyle) GetAlignmentStyle() = 0; + NS_IMETHOD SetAlignmentStyle(nsAlignmentStyle aAlignmentStyle) = 0; + + NS_IMETHOD_(PRUint32) GetMenuID() = 0; + NS_IMETHOD SetMenuID(PRUint32 aID) = 0; + + NS_IMETHOD SendCommand() = 0; + + NS_IMETHOD SetReceiver(nsIXPFCCommandReceiver * aReceiver) = 0; + + NS_IMETHOD_(PRBool) GetEnabled() = 0; + NS_IMETHOD SetEnabled(PRBool aEnable) = 0; +}; + +#endif /* nsIMenuItem_h___ */ + diff --git a/mozilla/xpfc/chrome/public/nsIXPFCToolbar.h b/mozilla/xpfc/chrome/public/nsIXPFCToolbar.h new file mode 100644 index 00000000000..3c0c791689c --- /dev/null +++ b/mozilla/xpfc/chrome/public/nsIXPFCToolbar.h @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIXPFCToolbar_h___ +#define nsIXPFCToolbar_h___ + +#include "nsISupports.h" + +// deb24690-35f8-11d2-9248-00805f8a7ab6 +#define NS_IXPFC_TOOLBAR_IID \ + { 0xdeb24690, 0x35f8, 0x11d2, \ + {0x92, 0x48, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +class nsIXPFCToolbar : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0; +}; + +#endif /* nsIXPFCToolbar_h___ */ + diff --git a/mozilla/xpfc/chrome/src/Makefile b/mozilla/xpfc/chrome/src/Makefile new file mode 100644 index 00000000000..ea3f7f6ed86 --- /dev/null +++ b/mozilla/xpfc/chrome/src/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + diff --git a/mozilla/xpfc/chrome/src/config.mk b/mozilla/xpfc/chrome/src/config.mk new file mode 100644 index 00000000000..61d5e941835 --- /dev/null +++ b/mozilla/xpfc/chrome/src/config.mk @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES += -I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = chrome +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) diff --git a/mozilla/xpfc/chrome/src/manifest.mn b/mozilla/xpfc/chrome/src/manifest.mn new file mode 100644 index 00000000000..7f6a3bcb66c --- /dev/null +++ b/mozilla/xpfc/chrome/src/manifest.mn @@ -0,0 +1,27 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsMenuContainer.cpp \ + nsMenuItem.cpp \ + nsXPFCToolbar.cpp \ + $(NULL) + +REQUIRES = xpcom raptor netlib + diff --git a/mozilla/xpfc/chrome/src/nsMenuContainer.cpp b/mozilla/xpfc/chrome/src/nsMenuContainer.cpp new file mode 100644 index 00000000000..dbbd13b105a --- /dev/null +++ b/mozilla/xpfc/chrome/src/nsMenuContainer.cpp @@ -0,0 +1,322 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nscore.h" +#include "nsMenuContainer.h" +#include "nsIXMLParserObject.h" +#include "nspr.h" +#include "plstr.h" +#include "nsxpfcCIID.h" +#include "nsXPFCActionCommand.h" +#include "nsWidgetsCID.h" +#include "nsIFileWidget.h" +#include "nsIWebViewerContainer.h" + +static NS_DEFINE_IID(kIXMLParserObjectIID, NS_IXML_PARSER_OBJECT_IID); +static NS_DEFINE_IID(kCIMenuContainerIID, NS_IMENUCONTAINER_IID); +static NS_DEFINE_IID(kCIMenuItemIID, NS_IMENUITEM_IID); +static NS_DEFINE_IID(kFileWidgetCID, NS_FILEWIDGET_CID); +static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID); +static NS_DEFINE_IID(kXPFCCommandReceiverIID, NS_IXPFC_COMMANDRECEIVER_IID); + +nsMenuContainer::nsMenuContainer() : nsMenuItem() +{ + NS_INIT_REFCNT(); + mChildMenus = nsnull; + mShellInstance = nsnull; + mWebViewerContainer = nsnull; +} + +nsMenuContainer::~nsMenuContainer() +{ +} + +NS_DEFINE_IID(kIMenuContainerIID, NS_IMENUCONTAINER_IID); + +NS_IMPL_ADDREF(nsMenuContainer) +NS_IMPL_RELEASE(nsMenuContainer) + +nsresult nsMenuContainer::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, kIMenuContainerIID); + static NS_DEFINE_IID(kIMenuBarIID, NS_IMENUBAR_IID); + + if (aIID.Equals(kClassIID)) { + *aInstancePtr = (void*) this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*) (this); + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIMenuBarIID)) { + *aInstancePtr = (nsIMenuBar*) (this); + AddRef(); + return NS_OK; + } + if (aIID.Equals(kXPFCCommandReceiverIID)) { + *aInstancePtr = (void*)(nsIXPFCCommandReceiver *) this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIXMLParserObjectIID)) { + *aInstancePtr = (nsIXMLParserObject*) (this); + AddRef(); + return NS_OK; + } + + return (nsMenuItem::QueryInterface(aIID,aInstancePtr)); + +} + +nsresult nsMenuContainer::Init() +{ + static NS_DEFINE_IID(kCVectorCID, NS_VECTOR_CID); + nsresult res = nsRepository::CreateInstance(kCVectorCID, + nsnull, + kCVectorCID, + (void **)&mChildMenus); + + if (NS_OK != res) + return res ; + + mChildMenus->Init(); + + return NS_OK; +} + +void* nsMenuContainer::GetNativeHandle() +{ + return (nsnull); +} + +nsresult nsMenuContainer :: SetParameter(nsString& aKey, nsString& aValue) +{ + return (nsMenuItem::SetParameter(aKey,aValue)); +} + +nsresult nsMenuContainer :: AddMenuItem(nsIMenuItem * aMenuItem) +{ + return NS_OK; +} + +nsresult nsMenuContainer :: AddChild(nsIMenuItem * aItem) +{ + mChildMenus->Append(aItem); + + aItem->SetParent(this); + + return (NS_OK); +} + + +nsresult nsMenuContainer :: Update() +{ + return NS_OK; +} + +nsresult nsMenuContainer :: SetShellContainer(nsIShellInstance * aShellInstance, + nsIWebViewerContainer * aWebViewerContainer) +{ + mShellInstance = aShellInstance; + mWebViewerContainer = aWebViewerContainer; + + /* + * Make this the default receiver for the menubar on the webview container + */ + + mWebViewerContainer->GetMenuManager()->SetDefaultReceiver((nsIXPFCCommandReceiver *)this); + + return (NS_OK); +} + +nsIMenuItem * nsMenuContainer :: MenuItemFromID(PRUint32 aID) +{ + nsresult res; + nsIIterator * iterator = nsnull; + nsIMenuItem * item = nsnull; + nsIMenuItem * child = nsnull; + nsIMenuContainer * container = nsnull; + PRBool bFoundItem = PR_FALSE; + + res = mChildMenus->CreateIterator(&iterator); + + if (res != NS_OK) + return nsnull; + + iterator->Init(); + + while(!(iterator->IsDone())) + { + item = (nsIMenuItem *) iterator->CurrentItem(); + + if (item->GetMenuID() == aID) + { + bFoundItem = PR_TRUE; + break; + } + + iterator->Next(); + } + + if (bFoundItem == PR_FALSE) + { + item = nsnull; + + iterator->Init(); + + while(!(iterator->IsDone())) + { + child = (nsIMenuItem *) iterator->CurrentItem(); + + res = child->QueryInterface(kCIMenuContainerIID, (void**)&container); + + if (NS_OK == res) + { + + item = container->MenuItemFromID(aID); + + NS_RELEASE(container); + + if (item != nsnull) + break; + } + + iterator->Next(); + } + + } + + NS_RELEASE(iterator); + + return item; +} + +nsresult nsMenuContainer :: Action(nsIXPFCCommand * aCommand) +{ + + /* + * Check to see this is an ActionCommand + */ + + nsresult res; + + nsXPFCActionCommand * action_command = nsnull; + static NS_DEFINE_IID(kXPFCActionCommandCID, NS_XPFC_ACTION_COMMAND_CID); + + res = aCommand->QueryInterface(kXPFCActionCommandCID,(void**)&action_command); + + if (NS_OK != res) + return res; + + + /* + * Yeah, this is an action command. Do something + */ + + ProcessActionCommand(action_command->mAction); + + NS_RELEASE(action_command); + + return NS_OK; +} + +nsresult nsMenuContainer::ProcessActionCommand(nsString& aAction) +{ + /* + * Handle File Open... + */ + + if (aAction == "FileOpen") + { + PRBool selectedFileName = PR_FALSE; + nsIFileWidget *fileWidget; + nsString title("Open UI"); + nsString name; + + nsresult rv = nsRepository::CreateInstance(kFileWidgetCID, + nsnull, + kIFileWidgetIID, + (void**)&fileWidget); + if (NS_OK == rv) + { + nsString titles[] = {"all files","calendar ui", "xpfc ui" }; + nsString filters[] = {"*.*", "*.cal", "*.ui"}; + + fileWidget->SetFilterList(3, titles, filters); + + fileWidget->Create(mShellInstance->GetApplicationWidget(), + title, + eMode_load, + nsnull, + nsnull); + + PRUint32 result = fileWidget->Show(); + + if (result) + { + fileWidget->GetFile(name); + selectedFileName = PR_TRUE; + } + + NS_RELEASE(fileWidget); + } + + if (selectedFileName == PR_TRUE) + { + if (mWebViewerContainer) + mWebViewerContainer->LoadURL(name,nsnull); + } + + /* + * Handle Application Exit + */ + + } else if (aAction == "ApplicationExit") { + + mShellInstance->ExitApplication(); + + } else if (aAction == "StartCommandServer") { + + nsIApplicationShell * shell = nsnull; + + mWebViewerContainer->GetApplicationShell(shell); + + shell->StartCommandServer(); + + } else if (aAction == "LaunchCommandClient") { + + mShellInstance->LaunchApplication(nsString("trextest")); + + } else if (aAction == "ComposeEvent") { + + if (mWebViewerContainer) + mWebViewerContainer->LoadURL("resource://res/ui/compose_event.ui",nsnull); + + } + + + return NS_OK; +} \ No newline at end of file diff --git a/mozilla/xpfc/chrome/src/nsMenuItem.cpp b/mozilla/xpfc/chrome/src/nsMenuItem.cpp new file mode 100644 index 00000000000..251e27c45ab --- /dev/null +++ b/mozilla/xpfc/chrome/src/nsMenuItem.cpp @@ -0,0 +1,240 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nscore.h" +#include "nsMenuItem.h" +#include "nsIXMLParserObject.h" +#include "nsXPFCActionCommand.h" +#include "nsRepository.h" +#include "nsxpfcCIID.h" + +static NS_DEFINE_IID(kIXMLParserObjectIID, NS_IXML_PARSER_OBJECT_IID); + +nsMenuItem::nsMenuItem() +{ + NS_INIT_REFCNT(); + mName = "Item"; + mLabel = "Label"; + mParent = nsnull; + mSeparator = PR_FALSE; + mAlignmentStyle = eAlignmentStyle_none; + mID = 0; + mReceiver = nsnull; + mCommand = "Command"; + mEnabled = PR_TRUE; +} + +nsMenuItem::~nsMenuItem() +{ +} + +NS_DEFINE_IID(kIMenuItemIID, NS_IMENUITEM_IID); + +NS_IMPL_ADDREF(nsMenuItem) +NS_IMPL_RELEASE(nsMenuItem) + +nsresult nsMenuItem::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, kIMenuItemIID); + + if (aIID.Equals(kClassIID)) { + *aInstancePtr = (void*) this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*) (this); + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIXMLParserObjectIID)) { + *aInstancePtr = (nsIXMLParserObject*) (this); + AddRef(); + return NS_OK; + } + + return NS_NOINTERFACE; + +} + +nsresult nsMenuItem::Init() +{ + return NS_OK; +} + +nsresult nsMenuItem :: SetParameter(nsString& aKey, nsString& aValue) +{ + if (aKey == "name") { + + SetName(aValue); + + } else if (aKey == "align") { + + if (aValue == "left") + mAlignmentStyle = eAlignmentStyle_left; + else if (aValue == "right") + mAlignmentStyle = eAlignmentStyle_right; + + } else if (aKey == "enable") { + + if (aValue == "False") + mEnabled = PR_FALSE; + else if (aValue == "True") + mEnabled = PR_TRUE; + + } else if (aKey == "type") { + + if (aValue == "separator") + mSeparator = PR_TRUE; + + } else if (aKey == "label") { + + SetLabel(aValue); + + } else if (aKey == "command") { + + SetCommand(aValue); + + } + + + return NS_OK; +} + +PRBool nsMenuItem::IsSeparator() +{ + return (mSeparator); +} + +nsAlignmentStyle nsMenuItem::GetAlignmentStyle() +{ + return (mAlignmentStyle); +} + +nsresult nsMenuItem::SetAlignmentStyle(nsAlignmentStyle aAlignmentStyle) +{ + mAlignmentStyle = aAlignmentStyle; + return NS_OK; +} + +PRBool nsMenuItem::GetEnabled() +{ + return (mEnabled); +} + +nsresult nsMenuItem::SetEnabled(PRBool aEnable) +{ + mEnabled = aEnable; + return NS_OK; +} + +nsresult nsMenuItem :: SetName(nsString& aName) +{ + mName = aName; + return NS_OK; +} + +nsString& nsMenuItem :: GetName() +{ + return (mName); +} + +nsresult nsMenuItem :: SetCommand(nsString& aCommand) +{ + mCommand = aCommand; + return NS_OK; +} + +nsString& nsMenuItem :: GetCommand() +{ + return (mCommand); +} + +nsresult nsMenuItem :: SetLabel(nsString& aLabel) +{ + mLabel = aLabel; + return NS_OK; +} + +nsString& nsMenuItem :: GetLabel() +{ + return (mLabel); +} + +nsIMenuContainer * nsMenuItem::GetParent() +{ + return (mParent); +} + +nsresult nsMenuItem::SetParent(nsIMenuContainer * aParent) +{ + mParent = aParent; + return NS_OK; +} + +nsresult nsMenuItem :: SetMenuID(PRUint32 aID) +{ + mID = aID; + return NS_OK; +} + +PRUint32 nsMenuItem :: GetMenuID() +{ + return (mID); +} + +nsresult nsMenuItem::SetReceiver(nsIXPFCCommandReceiver * aReceiver) +{ + mReceiver = aReceiver; + return NS_OK; +} + +nsresult nsMenuItem :: SendCommand() +{ + if (mReceiver == nsnull) + return NS_OK; + + nsXPFCActionCommand * command; + + static NS_DEFINE_IID(kCXPFCActionCommandCID, NS_XPFC_ACTION_COMMAND_CID); + static NS_DEFINE_IID(kXPFCCommandIID, NS_IXPFC_COMMAND_IID); + + nsresult res = nsRepository::CreateInstance(kCXPFCActionCommandCID, + nsnull, + kXPFCCommandIID, + (void **)&command); + + if (NS_OK != res) + return res ; + + command->Init(); + + command->mAction = mCommand; + + mReceiver->Action(command); + + NS_RELEASE(command); + + return (NS_OK); +} + diff --git a/mozilla/xpfc/chrome/src/nsXPFCToolbar.cpp b/mozilla/xpfc/chrome/src/nsXPFCToolbar.cpp new file mode 100644 index 00000000000..28a1b498a91 --- /dev/null +++ b/mozilla/xpfc/chrome/src/nsXPFCToolbar.cpp @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsXPFCToolbar.h" +#include "nsxpfcCIID.h" +#include "nspr.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kCXPFCToolbarCID, NS_XPFC_TOOLBAR_CID); +static NS_DEFINE_IID(kCIXPFCToolbarIID, NS_IXPFC_TOOLBAR_IID); + +#define DEFAULT_WIDTH 50 +#define DEFAULT_HEIGHT 50 + +nsXPFCToolbar :: nsXPFCToolbar(nsISupports* outer) : nsXPFCCanvas(outer) +{ + NS_INIT_REFCNT(); +} + +nsXPFCToolbar :: ~nsXPFCToolbar() +{ +} + +nsresult nsXPFCToolbar::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, kCXPFCToolbarCID); + if (aIID.Equals(kClassIID)) { + *aInstancePtr = (void*) (nsXPFCToolbar *)this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kCIXPFCToolbarIID)) { + *aInstancePtr = (void*) (nsIXPFCToolbar *)this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*) (this); + AddRef(); + return NS_OK; + } + return (nsXPFCCanvas::QueryInterface(aIID, aInstancePtr)); +} + +NS_IMPL_ADDREF(nsXPFCToolbar) +NS_IMPL_RELEASE(nsXPFCToolbar) + +nsresult nsXPFCToolbar :: Init() +{ + return (nsXPFCCanvas::Init()); +} + +nsresult nsXPFCToolbar :: SetParameter(nsString& aKey, nsString& aValue) +{ + return (nsXPFCCanvas::SetParameter(aKey, aValue)); +} + +nsresult nsXPFCToolbar :: GetClassPreferredSize(nsSize& aSize) +{ + aSize.width = DEFAULT_WIDTH; + aSize.height = DEFAULT_HEIGHT; + return (NS_OK); +} + diff --git a/mozilla/xpfc/chrome/unix/Makefile b/mozilla/xpfc/chrome/unix/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/chrome/unix/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/chrome/unix/inc/Makefile b/mozilla/xpfc/chrome/unix/inc/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/chrome/unix/inc/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/chrome/unix/inc/manifest.mn b/mozilla/xpfc/chrome/unix/inc/manifest.mn new file mode 100644 index 00000000000..ad26bd919a6 --- /dev/null +++ b/mozilla/xpfc/chrome/unix/inc/manifest.mn @@ -0,0 +1,21 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + nsMenuContainerUnix.h \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/chrome/unix/inc/nsMenuContainerUnix.h b/mozilla/xpfc/chrome/unix/inc/nsMenuContainerUnix.h new file mode 100644 index 00000000000..1475ecc814b --- /dev/null +++ b/mozilla/xpfc/chrome/unix/inc/nsMenuContainerUnix.h @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef __NS_MENU_CONTAINER_UNIX +#define __NS_MENU_CONTAINER_UNIX + +#include "nsMenuContainer.h" + +#include +#include +#include +#include +#include +#include + +class nsMenuContainerUnix : public nsMenuContainer +{ + +public: + + nsMenuContainerUnix(); + +protected: + virtual ~nsMenuContainerUnix(); + + NS_IMETHOD SetShellInstance(nsIShellInstance * aShellInstance) ; + NS_IMETHOD AddMenuItem(nsIMenuItem * aMenuItem); + NS_IMETHOD_(void*) GetNativeHandle(); + NS_IMETHOD Update() ; + +private: + Widget mMenuBar; + +}; + +#endif diff --git a/mozilla/xpfc/chrome/unix/manifest.mn b/mozilla/xpfc/chrome/unix/manifest.mn new file mode 100644 index 00000000000..e94c397fe52 --- /dev/null +++ b/mozilla/xpfc/chrome/unix/manifest.mn @@ -0,0 +1,15 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. +DEPTH = ../../../../.. + +DIRS_EXPORT = inc +DIRS_LIBS = src + diff --git a/mozilla/xpfc/chrome/unix/src/Makefile b/mozilla/xpfc/chrome/unix/src/Makefile new file mode 100644 index 00000000000..ea3f7f6ed86 --- /dev/null +++ b/mozilla/xpfc/chrome/unix/src/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + diff --git a/mozilla/xpfc/chrome/unix/src/config.mk b/mozilla/xpfc/chrome/unix/src/config.mk new file mode 100644 index 00000000000..215423c158e --- /dev/null +++ b/mozilla/xpfc/chrome/unix/src/config.mk @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES += -I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = chrome_unix +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) diff --git a/mozilla/xpfc/chrome/unix/src/manifest.mn b/mozilla/xpfc/chrome/unix/src/manifest.mn new file mode 100644 index 00000000000..621f654f31f --- /dev/null +++ b/mozilla/xpfc/chrome/unix/src/manifest.mn @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsMenuContainerUnix.cpp \ + $(NULL) + +REQUIRES = xpcom raptor netlib + diff --git a/mozilla/xpfc/chrome/unix/src/nsMenuContainerUnix.cpp b/mozilla/xpfc/chrome/unix/src/nsMenuContainerUnix.cpp new file mode 100644 index 00000000000..54ba11075b6 --- /dev/null +++ b/mozilla/xpfc/chrome/unix/src/nsMenuContainerUnix.cpp @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nscore.h" +#include "nsMenuContainerUnix.h" + +#include +#include +#include +#include +#include +#include + +static NS_DEFINE_IID(kCIMenuContainerIID, NS_IMENUCONTAINER_IID); +static NS_DEFINE_IID(kCIMenuItemIID, NS_IMENUITEM_IID); + +nsMenuContainerUnix::nsMenuContainerUnix() : nsMenuContainer() +{ + mMenuBar = nsnull; +} + +nsMenuContainerUnix::~nsMenuContainerUnix() +{ +} + +void* nsMenuContainerUnix::GetNativeHandle() +{ + return nsnull; +} + +nsresult nsMenuContainerUnix :: AddMenuItem(nsIMenuItem * aMenuItem) +{ + return NS_OK; +} + + +nsresult nsMenuContainerUnix :: Update() +{ + return NS_OK; +} + +nsresult nsMenuContainerUnix :: SetShellInstance(nsIShellInstance * aShellInstance) +{ + nsIWidget * window = aShellInstance->GetApplicationWidget(); + + Widget parent = XtParent((Widget)window->GetNativeData(NS_NATIVE_WIDGET)); + + mMenuBar = ::XmCreateMenuBar(parent, "menubar", nsnull, 0); + + XtManageChild(mMenuBar); + + return (NS_OK); +} diff --git a/mozilla/xpfc/chrome/windows/Makefile b/mozilla/xpfc/chrome/windows/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/chrome/windows/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/chrome/windows/inc/Makefile b/mozilla/xpfc/chrome/windows/inc/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/chrome/windows/inc/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/chrome/windows/inc/manifest.mn b/mozilla/xpfc/chrome/windows/inc/manifest.mn new file mode 100644 index 00000000000..cc98965cb5b --- /dev/null +++ b/mozilla/xpfc/chrome/windows/inc/manifest.mn @@ -0,0 +1,21 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + nsMenuContainerWin.h \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/chrome/windows/inc/nsMenuContainerWin.h b/mozilla/xpfc/chrome/windows/inc/nsMenuContainerWin.h new file mode 100644 index 00000000000..5c38ec5dff5 --- /dev/null +++ b/mozilla/xpfc/chrome/windows/inc/nsMenuContainerWin.h @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef __NS_MENU_CONTAINER_WIN +#define __NS_MENU_CONTAINER_WIN + +#include "nsMenuContainer.h" +#include "windows.h" + +class nsMenuContainerWin : public nsMenuContainer +{ + +public: + + nsMenuContainerWin(); + +protected: + virtual ~nsMenuContainerWin(); + + NS_IMETHOD SetShellContainer(nsIShellInstance * aShellInstance,nsIWebViewerContainer * aWebViewerContainer) ; + NS_IMETHOD AddMenuItem(nsIMenuItem * aMenuItem); + NS_IMETHOD_(void*) GetNativeHandle(); + NS_IMETHOD Update() ; + +protected: + HMENU mMenu; + HWND mHwnd; +}; + +#endif diff --git a/mozilla/xpfc/chrome/windows/manifest.mn b/mozilla/xpfc/chrome/windows/manifest.mn new file mode 100644 index 00000000000..e94c397fe52 --- /dev/null +++ b/mozilla/xpfc/chrome/windows/manifest.mn @@ -0,0 +1,15 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. +DEPTH = ../../../../.. + +DIRS_EXPORT = inc +DIRS_LIBS = src + diff --git a/mozilla/xpfc/chrome/windows/src/Makefile b/mozilla/xpfc/chrome/windows/src/Makefile new file mode 100644 index 00000000000..ea3f7f6ed86 --- /dev/null +++ b/mozilla/xpfc/chrome/windows/src/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + diff --git a/mozilla/xpfc/chrome/windows/src/config.mk b/mozilla/xpfc/chrome/windows/src/config.mk new file mode 100644 index 00000000000..01e24fac37c --- /dev/null +++ b/mozilla/xpfc/chrome/windows/src/config.mk @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES += -I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = chrome_windows +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) diff --git a/mozilla/xpfc/chrome/windows/src/manifest.mn b/mozilla/xpfc/chrome/windows/src/manifest.mn new file mode 100644 index 00000000000..2bcf5b38c1d --- /dev/null +++ b/mozilla/xpfc/chrome/windows/src/manifest.mn @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsMenuContainerWin.cpp \ + $(NULL) + +REQUIRES = xpcom raptor netlib + diff --git a/mozilla/xpfc/chrome/windows/src/nsMenuContainerWin.cpp b/mozilla/xpfc/chrome/windows/src/nsMenuContainerWin.cpp new file mode 100644 index 00000000000..8b40246953b --- /dev/null +++ b/mozilla/xpfc/chrome/windows/src/nsMenuContainerWin.cpp @@ -0,0 +1,159 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nscore.h" +#include "nsMenuContainerWin.h" +#include "windows.h" + +static NS_DEFINE_IID(kCIMenuContainerIID, NS_IMENUCONTAINER_IID); +static NS_DEFINE_IID(kCIMenuItemIID, NS_IMENUITEM_IID); + +nsMenuContainerWin::nsMenuContainerWin() : nsMenuContainer() +{ + mHwnd = nsnull; + mMenu = nsnull; +} + +nsMenuContainerWin::~nsMenuContainerWin() +{ +} + +void* nsMenuContainerWin::GetNativeHandle() +{ + if (mMenu != nsnull) + return ((void*)mMenu); + + if (GetParent() != nsnull) + return (GetParent()->GetNativeHandle()); + + return nsnull; + +} + +nsresult nsMenuContainerWin :: AddMenuItem(nsIMenuItem * aMenuItem) +{ + if (mMenu == nsnull) + mMenu = ::CreatePopupMenu(); + + PRUint32 flags = MF_STRING; + + char * name = aMenuItem->GetLabel().ToNewCString(); + + if (aMenuItem->GetAlignmentStyle() == eAlignmentStyle_right) + flags |= MF_HELP; + + if (aMenuItem->GetEnabled() == PR_FALSE) + flags |= MF_GRAYED; + + if (aMenuItem->IsSeparator() == PR_TRUE) + flags = MF_SEPARATOR; + + ::AppendMenu(mMenu, flags, aMenuItem->GetMenuID(), (LPSTR)name); + + delete name; + + return NS_OK; +} + + +nsresult nsMenuContainerWin :: Update() +{ + + nsresult res; + nsIIterator * iterator = nsnull; + nsIMenuItem * item; + nsIMenuContainer * container; + + res = mChildMenus->CreateIterator(&iterator); + + if (res != NS_OK) + return res; + + iterator->Init(); + + while(!(iterator->IsDone())) + { + item = (nsIMenuItem *) iterator->CurrentItem(); + + res = item->QueryInterface(kCIMenuContainerIID, (void**)&container); + + if (NS_OK == res) + { + container->Update(); + + NS_RELEASE(container); + + } else { + + /* + * Just add this is a basic menu item + */ + + AddMenuItem(item); + } + + iterator->Next(); + } + + /* + * If I am a native popup, we want to add me to the closest parent + * with a menu. + */ + if (mMenu != nsnull) + { + if (GetParent() && GetParent()->GetNativeHandle()) + { + + nsIMenuItem * container_item = nsnull; + + res = GetParent()->QueryInterface(kCIMenuItemIID,(void**)&container_item); + + if (res == NS_OK) + { + char * name = container_item->GetLabel().ToNewCString(); + + ::AppendMenu(GetParent()->GetNativeHandle(), + MF_POPUP, + (PRUint32)mMenu, + (LPSTR)name); + + delete name; + + NS_RELEASE(container_item); + } + } + } + + NS_RELEASE(iterator); + + if (mHwnd) + ::DrawMenuBar(mHwnd); + + return NS_OK; +} + +nsresult nsMenuContainerWin :: SetShellContainer(nsIShellInstance * aShellInstance, + nsIWebViewerContainer * aWebViewerContainer) +{ + + mHwnd = aShellInstance->GetApplicationWindowNativeInstance(); + mMenu = ::CreateMenu(); + ::SetMenu(mHwnd, mMenu); + + return (nsMenuContainer::SetShellContainer(aShellInstance,aWebViewerContainer)); +} diff --git a/mozilla/xpfc/core/Makefile b/mozilla/xpfc/core/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/core/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/core/inc/Makefile b/mozilla/xpfc/core/inc/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/core/inc/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/core/inc/manifest.mn b/mozilla/xpfc/core/inc/manifest.mn new file mode 100644 index 00000000000..add756b802d --- /dev/null +++ b/mozilla/xpfc/core/inc/manifest.mn @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + nsxpfcCIID.h \ + nsxpfcstrings.h \ + nsxpfc.h \ + nsxpfcFactory.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/core/inc/nsxpfc.h b/mozilla/xpfc/core/inc/nsxpfc.h new file mode 100644 index 00000000000..f95f46258d6 --- /dev/null +++ b/mozilla/xpfc/core/inc/nsxpfc.h @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ +#ifndef nsxpfc_h___ +#define nsxpfc_h___ + +#include "nscore.h" + +#ifdef XP_PC +#pragma warning( disable : 4275 4251 ) // Disable warning messages +#endif + +#ifdef _IMPL_NS_XPFC +#define NS_XPFC NS_EXPORT +#else +#define NS_XPFC NS_IMPORT +#endif + +#if defined(XP_MAC) + #define CLASS_EXPORT_XPFC NS_XPFC class +#else + #define CLASS_EXPORT_XPFC class NS_XPFC +#endif + +#endif /* nsxpfc_h___ */ diff --git a/mozilla/xpfc/core/inc/nsxpfcCIID.h b/mozilla/xpfc/core/inc/nsxpfcCIID.h new file mode 100644 index 00000000000..916204876f7 --- /dev/null +++ b/mozilla/xpfc/core/inc/nsxpfcCIID.h @@ -0,0 +1,176 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsxpfcCIID_h__ +#define nsxpfcCIID_h__ + +#include "nsISupports.h" +#include "nsIFactory.h" +#include "nsRepository.h" + +// c38e93c0-386e-11d2-9249-00805f8a7ab6 +#define NS_XPFC_COMMAND_SERVER_CID \ + { 0xc38e93c0, 0x386e, 0x11d2, \ + {0x92, 0x49, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +#define NS_XPFC_SHELL_INSTANCE_CID \ + { 0x90487580, 0xfefe, 0x11d1, \ + {0xbe, 0xcd, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd} } + +// 03dd8f40-3610-11d2-9248-00805f8a7ab6 +#define NS_STREAM_MANAGER_CID \ + { 0x03dd8f40, 0x3610, 0x11d2, \ + {0x92, 0x48, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +// cd5cd8b0-3b80-11d2-bee0-00805f8a8dbd +#define NS_XPFC_DIALOG_CID \ + { 0xcd5cd8b0, 0x3b80, 0x11d2, \ + {0xbe, 0xe0, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd} } + +// 55395780-3b98-11d2-bee0-00805f8a8dbd +#define NS_XPFC_BUTTON_CID \ + { 0x55395780, 0x3b98, 0x11d2, \ + {0xbe, 0xe0, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd} } + +// cd53e4b0-3b99-11d2-bee0-00805f8a8dbd +#define NS_XPFC_TEXTWIDGET_CID \ + { 0xcd53e4b0, 0x3b99, 0x11d2, \ + {0xbe, 0xe0, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd} } + +// dafa9a80-3b99-11d2-bee0-00805f8a8dbd +#define NS_XPFC_TABWIDGET_CID \ + { 0xdafa9a80, 0x3b99, 0x11d2, \ + {0xbe, 0xe0, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd} } + +// 5de8a290-35f9-11d2-9248-00805f8a7ab6 +#define NS_XPFC_TOOLBAR_CID \ + { 0x5de8a290, 0x35f9, 0x11d2, \ + {0x92, 0x48, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +// 74222650-2d76-11d2-9246-00805f8a7ab6 +#define NS_MENUBAR_CID \ + { 0x74222650, 0x2d76, 0x11d2, \ + {0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +// c78daa60-30a9-11d2-9247-00805f8a7ab6 +#define NS_MENU_MANAGER_CID \ + { 0xc78daa60, 0x30a9, 0x11d2, \ + {0x92, 0x47, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +// 782ae760-35fb-11d2-9248-00805f8a7ab6 +#define NS_TOOLBAR_MANAGER_CID \ + { 0x782ae760, 0x35fb, 0x11d2, \ + {0x92, 0x48, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +// 6c4e09a0-2f54-11d2-bede-00805f8a8dbd +#define NS_MENUCONTAINER_CID \ + { 0x6c4e09a0, 0x2f54, 0x11d2, \ + {0xbe, 0xde, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd} } + +// 7a01c6d0-2d76-11d2-9246-00805f8a7ab6 +#define NS_MENUITEM_CID \ + { 0x7a01c6d0, 0x2d76, 0x11d2, \ + {0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +#define NS_IAPPLICATIONSHELL_CID \ + { 0x2293d960, 0xdeff, 0x11d1, \ + {0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +// ce401b60-2e1e-11d2-9246-00805f8a7ab +#define NS_XPFCXMLCONTENTSINK_IID \ +{ 0xce401b60, 0x2e1e, 0x11d2, \ + {0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +// d422ca40-2e1e-11d2-9246-00805f8a7ab6 +#define NS_IXPFCXML_DTD_IID \ +{ 0xd422ca40, 0x2e1e, 0x11d2, \ + {0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + +//8c091510-eb84-11d1-9244-00805f8a7ab6 +#define NS_VECTOR_CID \ +{ 0x8c091510, 0xeb84, 0x11d1, \ +{ 0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +//24439be0-eb85-11d1-9244-00805f8a7ab6 +#define NS_VECTOR_ITERATOR_CID \ +{ 0x24439be0, 0xeb85, 0x11d1, \ +{ 0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +//f16fb1e0-27db-11d2-9246-00805f8a7ab6 +#define NS_STACK_CID \ +{ 0xf16fb1e0, 0x27db, 0x11d2, \ +{ 0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +//0156b2a0-f73d-11d1-9244-00805f8a7ab6 +#define NS_LAYOUT_CID \ +{ 0x0156b2a0, 0xf73d, 0x11d1, \ +{ 0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +//96562f50-fb29-11d1-becb-00805f8a8dbd +#define NS_BOXLAYOUT_CID \ +{ 0x96562f50, 0xfb29, 0x11d1, \ +{ 0xbe, 0xcb, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd } } + +//0241c670-1f57-11d2-bed9-00805f8a8dbd +#define NS_XPFC_OBSERVERMANAGER_CID \ +{ 0x0241c670, 0x1f57, 0x11d2, \ +{ 0xbe, 0xd9, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd } } + +//7a1e8ca0-1f53-11d2-bed9-00805f8a8dbd +#define NS_XPFC_OBSERVER_CID \ +{ 0x7a1e8ca0, 0x1f53, 0x11d2, \ +{ 0xbe, 0xd9, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd } } + +//a4c7f8b0-1f55-11d2-bed9-00805f8a8dbd +#define NS_XPFC_SUBJECT_CID \ +{ 0xa4c7f8b0, 0x1f55, 0x11d2, \ +{ 0xbe, 0xd9, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd } } + +//82613bd0-1f46-11d2-bed9-00805f8a8dbd +#define NS_XPFC_COMMAND_CID \ +{ 0x82613bd0, 0x1f46, 0x11d2, \ +{ 0xbe, 0xd9, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd } } + +//2d093010-e9e7-11d1-9244-00805f8a7ab6 +#define NS_XPFC_CANVAS_CID \ +{ 0x2d093010, 0xe9e7, 0x11d1, \ +{ 0x92, 0x44, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +//0b4ff5b0-3dda-11d2-bee1-00805f8a8dbd +#define NS_XPFC_HTML_CANVAS_CID \ +{ 0x0b4ff5b0, 0x3dda, 0x11d2, \ +{ 0xbe, 0xe1, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd } } + +//92789710-28a6-11d2-9246-00805f8a7ab6 +#define NS_XPFC_CANVASMANAGER_CID \ +{ 0x92789710, 0x28a6, 0x11d2, \ +{ 0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +//8d2f7410-28c3-11d2-9246-00805f8a7ab6 +#define NS_XPFC_METHODINVOKER_COMMAND_CID \ +{ 0x8d2f7410, 0x28c3, 0x11d2, \ +{ 0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +//667b7530-33b5-11d2-9248-00805f8a7ab6 +#define NS_XPFC_ACTION_COMMAND_CID \ +{ 0x667b7530, 0x33b5, 0x11d2, \ +{ 0x92, 0x48, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + + + +#endif diff --git a/mozilla/xpfc/core/inc/nsxpfcFactory.h b/mozilla/xpfc/core/inc/nsxpfcFactory.h new file mode 100644 index 00000000000..498140da58c --- /dev/null +++ b/mozilla/xpfc/core/inc/nsxpfcFactory.h @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsxpfc.h" +#include "nsIFactory.h" +#include "nsISupports.h" +#include "nsxpfcCIID.h" + +#include "nsxpfc.h" +#include "nsIFactory.h" +#include "nsISupports.h" +#include "nsxpfcCIID.h" + +#include "nsShellInstance.h" +#include "nsIMenuBar.h" +#include "nsXPFCToolbar.h" +#include "nsXPFCDialog.h" +#include "nsXPFCButton.h" +#include "nsXPFCTabWidget.h" +#include "nsXPFCTextWidget.h" +#include "nsMenuContainer.h" +#include "nsMenuItem.h" +#include "nsXPFCXMLDTD.h" +#include "nsXPFCXMLContentSink.h" +#include "nsMenuManager.h" +#include "nsToolbarManager.h" +#include "nsStreamManager.h" +#include "nsVector.h" +#include "nsVectorIterator.h" +#include "nsStack.h" +#include "nsLayout.h" +#include "nsBoxLayout.h" +#include "nsXPFCObserver.h" +#include "nsXPFCObserverManager.h" +#include "nsXPFCSubject.h" +#include "nsXPFCCommand.h" +#include "nsXPFCCanvas.h" +#include "nsXPFCCanvasManager.h" +#include "nsXPFCMethodInvokerCommand.h" +#include "nsXPFCActionCommand.h" +#include "nsCommandServer.h" +#include "nsXPFCHTMLCanvas.h" + +static NS_DEFINE_IID(kCShellInstance, NS_XPFC_SHELL_INSTANCE_CID); +static NS_DEFINE_IID(kCMenuItem, NS_MENUITEM_CID); +static NS_DEFINE_IID(kCMenuBar, NS_MENUBAR_CID); +static NS_DEFINE_IID(kCMenuContainer, NS_MENUCONTAINER_CID); +static NS_DEFINE_IID(kCMenuManager, NS_MENU_MANAGER_CID); +static NS_DEFINE_IID(kCStreamManager, NS_STREAM_MANAGER_CID); +static NS_DEFINE_IID(kIStreamManager, NS_ISTREAM_MANAGER_IID); +static NS_DEFINE_IID(kCXPFCDTD, NS_IXPFCXML_DTD_IID); +static NS_DEFINE_IID(kCXPFCContentSink, NS_XPFCXMLCONTENTSINK_IID); +static NS_DEFINE_IID(kCXPFCToolbar, NS_XPFC_TOOLBAR_CID); +static NS_DEFINE_IID(kCToolbarManager, NS_TOOLBAR_MANAGER_CID); +static NS_DEFINE_IID(kCXPFCDialog, NS_XPFC_DIALOG_CID); +static NS_DEFINE_IID(kCXPFCButton, NS_XPFC_BUTTON_CID); +static NS_DEFINE_IID(kCXPFCTabWidget, NS_XPFC_TABWIDGET_CID); +static NS_DEFINE_IID(kCXPFCTextWidget, NS_XPFC_TEXTWIDGET_CID); +static NS_DEFINE_IID(kCVector, NS_VECTOR_CID); +static NS_DEFINE_IID(kCVectorIterator, NS_VECTOR_ITERATOR_CID); +static NS_DEFINE_IID(kCLayout, NS_LAYOUT_CID); +static NS_DEFINE_IID(kILayout, NS_ILAYOUT_IID); +static NS_DEFINE_IID(kCBoxLayout, NS_BOXLAYOUT_CID); +static NS_DEFINE_IID(kCXPFCObserver, NS_XPFC_OBSERVER_CID); +static NS_DEFINE_IID(kCXPFCObserverManager, NS_XPFC_OBSERVERMANAGER_CID); +static NS_DEFINE_IID(kCXPFCSubject, NS_XPFC_SUBJECT_CID); +static NS_DEFINE_IID(kCXPFCCommand, NS_XPFC_COMMAND_CID); +static NS_DEFINE_IID(kCXPFCCanvas, NS_XPFC_CANVAS_CID); +static NS_DEFINE_IID(kCXPFCHTMLCanvas, NS_XPFC_HTML_CANVAS_CID); +static NS_DEFINE_IID(kCXPFCCanvasManager, NS_XPFC_CANVASMANAGER_CID); +static NS_DEFINE_IID(kIXPFCCanvas, NS_IXPFC_CANVAS_IID); +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); +static NS_DEFINE_IID(kCStack, NS_STACK_CID); +static NS_DEFINE_IID(kCXPFCMethodInvokerCommand, NS_XPFC_METHODINVOKER_COMMAND_CID); +static NS_DEFINE_IID(kCXPFCCommandServerCID, NS_XPFC_COMMAND_SERVER_CID); +static NS_DEFINE_IID(kCXPFCActionCommand, NS_XPFC_ACTION_COMMAND_CID); + +class nsxpfcFactory : public nsIFactory +{ + public: + // nsISupports methods + NS_IMETHOD QueryInterface(const nsIID &aIID, + void **aResult); + NS_IMETHOD_(nsrefcnt) AddRef(void); + NS_IMETHOD_(nsrefcnt) Release(void); + + // nsIFactory methods + NS_IMETHOD CreateInstance(nsISupports *aOuter, + const nsIID &aIID, + void **aResult); + + NS_IMETHOD LockFactory(PRBool aLock); + + nsxpfcFactory(const nsCID &aClass); + ~nsxpfcFactory(); + + protected: + nsrefcnt mRefCnt; + nsCID mClassID; +}; + diff --git a/mozilla/xpfc/core/inc/nsxpfcstrings.h b/mozilla/xpfc/core/inc/nsxpfcstrings.h new file mode 100644 index 00000000000..2405036d599 --- /dev/null +++ b/mozilla/xpfc/core/inc/nsxpfcstrings.h @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef NS_XPFCSTRINGS__ +#define NS_XPFCSTRINGS__ + +#define XPFC_STRING_QUESTIONMARK "?" +#define XPFC_STRING_BACKGROUNDCOLOR "backgroundcolor" +#define XPFC_STRING_BACKGROUNDIMAGE "backgroundimage" +#define XPFC_STRING_CLASS "class" +#define XPFC_STRING_CONTAINER "container" +#define XPFC_STRING_FOREGROUNDCOLOR "foregroundcolor" +#define XPFC_STRING_GETBACKGROUNDCOLOR "getbackgroundcolor" +#define XPFC_STRING_HEIGHT "height" +#define XPFC_STRING_HELP "help" +#define XPFC_STRING_HTML_CANVAS "htmlcanvas" +#define XPFC_STRING_ID "id" +#define XPFC_STRING_KEYBOARDFOCUS "keyboardfocus" +#define XPFC_STRING_LABEL "label" +#define XPFC_STRING_LAYOUT "layout" +#define XPFC_STRING_MENUCONTAINER "menucontainer" +#define XPFC_STRING_NAME "name" +#define XPFC_STRING_SETBACKGROUNDCOLOR "setbackgroundcolor" +#define XPFC_STRING_SRC "src" +#define XPFC_STRING_TABGROUP "tabgroup" +#define XPFC_STRING_TABID "tabid" +#define XPFC_STRING_USEPREFERREDSIZE "usepreferredsize" +#define XPFC_STRING_WEIGHTMAJOR "weightmajor" +#define XPFC_STRING_WEIGHTMINOR "weightminor" +#define XPFC_STRING_WIDTH "width" +#define XPFC_STRING_XBOX "xbox" +#define XPFC_STRING_YBOX "ybox" + +#endif + + diff --git a/mozilla/xpfc/core/manifest.mn b/mozilla/xpfc/core/manifest.mn new file mode 100644 index 00000000000..d4096b1579d --- /dev/null +++ b/mozilla/xpfc/core/manifest.mn @@ -0,0 +1,17 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../.. +DEPTH = ../../../.. + +DIRS_EXPORT = inc +DIRS_LIBS = src + +DIRS = $(PLATFORM_DIRECTORY) + diff --git a/mozilla/xpfc/core/src/Makefile b/mozilla/xpfc/core/src/Makefile new file mode 100644 index 00000000000..60df328e33a --- /dev/null +++ b/mozilla/xpfc/core/src/Makefile @@ -0,0 +1,54 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/core/src/config.mk b/mozilla/xpfc/core/src/config.mk new file mode 100644 index 00000000000..3e8c6c54d82 --- /dev/null +++ b/mozilla/xpfc/core/src/config.mk @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES += -I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = core +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) + diff --git a/mozilla/xpfc/core/src/manifest.mn b/mozilla/xpfc/core/src/manifest.mn new file mode 100644 index 00000000000..ba76ff54173 --- /dev/null +++ b/mozilla/xpfc/core/src/manifest.mn @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsxpfcFactory.cpp \ + $(NULL) + +REQUIRES = shell xpcom raptor netlib + diff --git a/mozilla/xpfc/core/src/nsxpfcFactory.cpp b/mozilla/xpfc/core/src/nsxpfcFactory.cpp new file mode 100644 index 00000000000..046719af752 --- /dev/null +++ b/mozilla/xpfc/core/src/nsxpfcFactory.cpp @@ -0,0 +1,166 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsxpfc.h" +#include "nsIFactory.h" +#include "nsISupports.h" +#include "nsxpfcCIID.h" +#include "nsxpfcFactory.h" + + +nsxpfcFactory::nsxpfcFactory(const nsCID &aClass) +{ + mRefCnt = 0; + mClassID = aClass; +} + +nsxpfcFactory::~nsxpfcFactory() +{ + NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction"); +} + +nsresult nsxpfcFactory::QueryInterface(const nsIID &aIID, + void **aResult) +{ + if (aResult == NULL) { + return NS_ERROR_NULL_POINTER; + } + + // Always NULL result, in case of failure + *aResult = NULL; + + if (aIID.Equals(kISupportsIID)) { + *aResult = (void *)(nsISupports*)this; + } else if (aIID.Equals(kIFactoryIID)) { + *aResult = (void *)(nsIFactory*)this; + } + + if (*aResult == NULL) { + return NS_NOINTERFACE; + } + + AddRef(); // Increase reference count for caller + return NS_OK; +} + +nsrefcnt nsxpfcFactory::AddRef() +{ + return ++mRefCnt; +} + +nsrefcnt nsxpfcFactory::Release() +{ + if (--mRefCnt == 0) { + delete this; + return 0; // Don't access mRefCnt after deleting! + } + return mRefCnt; +} + +nsresult nsxpfcFactory::CreateInstance(nsISupports *aOuter, + const nsIID &aIID, + void **aResult) +{ + if (aResult == NULL) { + return NS_ERROR_NULL_POINTER; + } + + *aResult = NULL; + + nsISupports *inst = nsnull; + + if (mClassID.Equals(kCShellInstance)) { + inst = (nsISupports *)new nsShellInstance(); + } else if (mClassID.Equals(kCXPFCCanvas)) { + nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsXPFCCanvas(aOuter); + canvas->QueryInterface(kISupportsIID,(void **)&inst); + } else if (mClassID.Equals(kCXPFCHTMLCanvas)) { + nsXPFCHTMLCanvas * canvas = (nsXPFCHTMLCanvas *)new nsXPFCHTMLCanvas(aOuter); + canvas->QueryInterface(kISupportsIID,(void **)&inst); + } else if (mClassID.Equals(kCMenuContainer)) { + inst = (nsISupports *)(nsIMenuContainer *)new nsMenuContainer(); + } else if (mClassID.Equals(kCXPFCToolbar)) { + inst = (nsISupports *)(nsIXPFCToolbar *)new nsXPFCToolbar(aOuter); + } else if (mClassID.Equals(kCXPFCDialog)) { + inst = (nsISupports *)(nsIXPFCDialog *)new nsXPFCDialog(aOuter); + } else if (mClassID.Equals(kCXPFCButton)) { + inst = (nsISupports *)(nsIXPFCButton *)new nsXPFCButton(aOuter); + } else if (mClassID.Equals(kCXPFCTextWidget)) { + inst = (nsISupports *)(nsIXPFCTextWidget *)new nsXPFCTextWidget(aOuter); + } else if (mClassID.Equals(kCXPFCTabWidget)) { + inst = (nsISupports *)(nsIXPFCTabWidget *)new nsXPFCTabWidget(aOuter); + } else if (mClassID.Equals(kCMenuManager)) { + inst = (nsISupports *)(nsIMenuManager *)new nsMenuManager(); + } else if (mClassID.Equals(kCToolbarManager)) { + inst = (nsISupports *)(nsIToolbarManager *)new nsToolbarManager(); + } else if (mClassID.Equals(kCStreamManager)) { + inst = (nsISupports *)(nsIStreamManager *)new nsStreamManager(); + } else if (mClassID.Equals(kCMenuItem)) { + inst = (nsISupports *)(nsIMenuItem *)new nsMenuItem(); + } else if (mClassID.Equals(kCXPFCDTD)) { + inst = (nsISupports *)new nsXPFCXMLDTD(); + } else if (mClassID.Equals(kCXPFCContentSink)) { + inst = (nsISupports *)new nsXPFCXMLContentSink(); + } else if (mClassID.Equals(kCVector)) { + inst = (nsISupports *)new nsVector(); + } else if (mClassID.Equals(kCVectorIterator)) { + inst = (nsISupports *)new nsVectorIterator(); + } else if (mClassID.Equals(kCStack)) { + inst = (nsISupports *)new nsStack(); + } else if (mClassID.Equals(kCLayout)) { + inst = (nsISupports *)new nsLayout(); + } else if (mClassID.Equals(kCBoxLayout)) { + inst = (nsISupports *)new nsBoxLayout(); + } else if (mClassID.Equals(kCXPFCObserver)) { + inst = (nsISupports *)new nsXPFCObserver(); + } else if (mClassID.Equals(kCXPFCObserverManager)) { + inst = (nsISupports *)new nsXPFCObserverManager(); + } else if (mClassID.Equals(kCXPFCMethodInvokerCommand)) { + inst = (nsISupports *)new nsXPFCMethodInvokerCommand(); + } else if (mClassID.Equals(kCXPFCActionCommand)) { + inst = (nsISupports *)new nsXPFCActionCommand(); + } else if (mClassID.Equals(kCXPFCSubject)) { + inst = (nsISupports *)new nsXPFCSubject(); + } else if (mClassID.Equals(kCXPFCCanvasManager)) { + inst = (nsISupports *)new nsXPFCCanvasManager(); + } else if (mClassID.Equals(kCXPFCCommand)) { + inst = (nsISupports *)new nsXPFCCommand(); + } else if (mClassID.Equals(kCXPFCCommandServerCID)) { + inst = (nsISupports *)new nsCommandServer(); + } + + if (inst == NULL) { + return NS_ERROR_OUT_OF_MEMORY; + } + + nsresult res = inst->QueryInterface(aIID, aResult); + + if (res != NS_OK) { + // We didn't get the right interface, so clean up + delete inst; + } + + return res; +} + +nsresult nsxpfcFactory::LockFactory(PRBool aLock) +{ + // Not implemented in simplest case. + return NS_OK; +} + diff --git a/mozilla/xpfc/core/unix/Makefile b/mozilla/xpfc/core/unix/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/core/unix/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/core/unix/manifest.mn b/mozilla/xpfc/core/unix/manifest.mn new file mode 100644 index 00000000000..fe78c326fa6 --- /dev/null +++ b/mozilla/xpfc/core/unix/manifest.mn @@ -0,0 +1,13 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. +DEPTH = ../../../../.. + +DIRS_LIBS = src diff --git a/mozilla/xpfc/core/unix/src/Makefile b/mozilla/xpfc/core/unix/src/Makefile new file mode 100644 index 00000000000..60df328e33a --- /dev/null +++ b/mozilla/xpfc/core/unix/src/Makefile @@ -0,0 +1,54 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/core/unix/src/config.mk b/mozilla/xpfc/core/unix/src/config.mk new file mode 100644 index 00000000000..ff019df21d7 --- /dev/null +++ b/mozilla/xpfc/core/unix/src/config.mk @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES += -I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = core_unix +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) + diff --git a/mozilla/xpfc/core/unix/src/manifest.mn b/mozilla/xpfc/core/unix/src/manifest.mn new file mode 100644 index 00000000000..b1be0305147 --- /dev/null +++ b/mozilla/xpfc/core/unix/src/manifest.mn @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsxpfcFactoryUnix.cpp \ + $(NULL) + +REQUIRES = shell xpcom raptor netlib + diff --git a/mozilla/xpfc/core/unix/src/nsxpfcFactoryUnix.cpp b/mozilla/xpfc/core/unix/src/nsxpfcFactoryUnix.cpp new file mode 100644 index 00000000000..0aec51cba6e --- /dev/null +++ b/mozilla/xpfc/core/unix/src/nsxpfcFactoryUnix.cpp @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsxpfcFactory.h" +#include "nsMenuContainerUnix.h" + +class nsxpfcFactoryUnix : public nsxpfcFactory +{ + public: + + NS_IMETHOD CreateInstance(nsISupports *aOuter, + const nsIID &aIID, + void **aResult); + + + nsxpfcFactoryUnix(const nsCID &aClass); + ~nsxpfcFactoryUnix(); + +}; + +nsxpfcFactoryUnix::nsxpfcFactoryUnix(const nsCID &aClass) : nsxpfcFactory(aClass) +{ +} + +nsxpfcFactoryUnix::~nsxpfcFactoryUnix() +{ +} + +nsresult nsxpfcFactoryUnix::CreateInstance(nsISupports *aOuter, + const nsIID &aIID, + void **aResult) +{ + if (aResult == NULL) { + return NS_ERROR_NULL_POINTER; + } + + *aResult = NULL; + + nsISupports *inst = nsnull; + + if (mClassID.Equals(kCMenuBar)) { + inst = (nsISupports *)(nsIMenuBar *)new nsMenuContainerUnix(); + } else if (mClassID.Equals(kCMenuContainer)) { + inst = (nsISupports *)(nsIMenuContainer *)new nsMenuContainerUnix(); + } + + if (inst == NULL) + return (nsxpfcFactory::CreateInstance(aOuter,aIID,aResult)); + + nsresult res = inst->QueryInterface(aIID, aResult); + + if (res != NS_OK) + delete inst; + + return res; +} + +// return the proper factory to the caller +extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, nsIFactory **aFactory) +{ + if (nsnull == aFactory) { + return NS_ERROR_NULL_POINTER; + } + + *aFactory = new nsxpfcFactoryUnix(aClass); + + if (nsnull == aFactory) { + return NS_ERROR_OUT_OF_MEMORY; + } + + return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory); +} + diff --git a/mozilla/xpfc/core/windows/Makefile b/mozilla/xpfc/core/windows/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/core/windows/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/core/windows/manifest.mn b/mozilla/xpfc/core/windows/manifest.mn new file mode 100644 index 00000000000..e748bb5a8a1 --- /dev/null +++ b/mozilla/xpfc/core/windows/manifest.mn @@ -0,0 +1,14 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. +DEPTH = ../../../../.. + +DIRS_LIBS = src + diff --git a/mozilla/xpfc/core/windows/src/Makefile b/mozilla/xpfc/core/windows/src/Makefile new file mode 100644 index 00000000000..60df328e33a --- /dev/null +++ b/mozilla/xpfc/core/windows/src/Makefile @@ -0,0 +1,54 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/core/windows/src/config.mk b/mozilla/xpfc/core/windows/src/config.mk new file mode 100644 index 00000000000..d131e6e62d4 --- /dev/null +++ b/mozilla/xpfc/core/windows/src/config.mk @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES += -I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = core_windows +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) + diff --git a/mozilla/xpfc/core/windows/src/manifest.mn b/mozilla/xpfc/core/windows/src/manifest.mn new file mode 100644 index 00000000000..a0d1fa38546 --- /dev/null +++ b/mozilla/xpfc/core/windows/src/manifest.mn @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsxpfcFactoryWin.cpp \ + $(NULL) + +REQUIRES = shell xpcom raptor netlib + diff --git a/mozilla/xpfc/core/windows/src/nsxpfcFactoryWin.cpp b/mozilla/xpfc/core/windows/src/nsxpfcFactoryWin.cpp new file mode 100644 index 00000000000..b59cf50d845 --- /dev/null +++ b/mozilla/xpfc/core/windows/src/nsxpfcFactoryWin.cpp @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsxpfcFactory.h" +#include "nsMenuContainerWin.h" + +class nsxpfcFactoryWin : public nsxpfcFactory +{ + public: + + NS_IMETHOD CreateInstance(nsISupports *aOuter, + const nsIID &aIID, + void **aResult); + + + nsxpfcFactoryWin(const nsCID &aClass); + ~nsxpfcFactoryWin(); + +}; + +nsxpfcFactoryWin::nsxpfcFactoryWin(const nsCID &aClass) : nsxpfcFactory(aClass) +{ +} + +nsxpfcFactoryWin::~nsxpfcFactoryWin() +{ +} + +nsresult nsxpfcFactoryWin::CreateInstance(nsISupports *aOuter, + const nsIID &aIID, + void **aResult) +{ + if (aResult == NULL) { + return NS_ERROR_NULL_POINTER; + } + + *aResult = NULL; + + nsISupports *inst = nsnull; + + if (mClassID.Equals(kCMenuBar)) { + inst = (nsISupports *)(nsIMenuBar *)new nsMenuContainerWin(); + } else if (mClassID.Equals(kCMenuContainer)) { + inst = (nsISupports *)(nsIMenuContainer *)new nsMenuContainerWin(); + } + + if (inst == NULL) + return (nsxpfcFactory::CreateInstance(aOuter,aIID,aResult)); + + nsresult res = inst->QueryInterface(aIID, aResult); + + if (res != NS_OK) + delete inst; + + return res; +} + +// return the proper factory to the caller +extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, nsIFactory **aFactory) +{ + if (nsnull == aFactory) { + return NS_ERROR_NULL_POINTER; + } + + *aFactory = new nsxpfcFactoryWin(aClass); + + if (nsnull == aFactory) { + return NS_ERROR_OUT_OF_MEMORY; + } + + return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory); +} + diff --git a/mozilla/xpfc/dialog/Makefile b/mozilla/xpfc/dialog/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/dialog/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/dialog/inc/Makefile b/mozilla/xpfc/dialog/inc/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/dialog/inc/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/dialog/inc/manifest.mn b/mozilla/xpfc/dialog/inc/manifest.mn new file mode 100644 index 00000000000..30778f3261d --- /dev/null +++ b/mozilla/xpfc/dialog/inc/manifest.mn @@ -0,0 +1,21 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + nsXPFCDialog.h \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/dialog/inc/nsXPFCDialog.h b/mozilla/xpfc/dialog/inc/nsXPFCDialog.h new file mode 100644 index 00000000000..6e7e47a3641 --- /dev/null +++ b/mozilla/xpfc/dialog/inc/nsXPFCDialog.h @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsXPFCDialog_h___ +#define nsXPFCDialog_h___ + +#include "nsIXPFCDialog.h" +#include "nsXPFCCanvas.h" + +class nsXPFCDialog : public nsIXPFCDialog, + public nsXPFCCanvas + +{ +public: + nsXPFCDialog(nsISupports* outer); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init(); + + NS_IMETHOD SetParameter(nsString& aKey, nsString& aValue) ; + NS_IMETHOD GetClassPreferredSize(nsSize& aSize); + +protected: + ~nsXPFCDialog(); + + +}; + +#endif /* nsXPFCDialog_h___ */ diff --git a/mozilla/xpfc/dialog/manifest.mn b/mozilla/xpfc/dialog/manifest.mn new file mode 100644 index 00000000000..ce741a53d39 --- /dev/null +++ b/mozilla/xpfc/dialog/manifest.mn @@ -0,0 +1,15 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../.. +DEPTH = ../../../.. + +DIRS_EXPORT = public inc +DIRS_LIBS = src + diff --git a/mozilla/xpfc/dialog/public/Makefile b/mozilla/xpfc/dialog/public/Makefile new file mode 100644 index 00000000000..61267ebf415 --- /dev/null +++ b/mozilla/xpfc/dialog/public/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + + diff --git a/mozilla/xpfc/dialog/public/manifest.mn b/mozilla/xpfc/dialog/public/manifest.mn new file mode 100644 index 00000000000..15ef760c42b --- /dev/null +++ b/mozilla/xpfc/dialog/public/manifest.mn @@ -0,0 +1,22 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. +DEPTH = ../../../../.. + +EXPORTS = \ + nsIXPFCDialog.h \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +REQUIRES = raptor diff --git a/mozilla/xpfc/dialog/public/nsIXPFCDialog.h b/mozilla/xpfc/dialog/public/nsIXPFCDialog.h new file mode 100644 index 00000000000..95e525403b8 --- /dev/null +++ b/mozilla/xpfc/dialog/public/nsIXPFCDialog.h @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIXPFCDialog_h___ +#define nsIXPFCDialog_h___ + +#include "nsISupports.h" + +//52ae6d80-3b81-11d2-bee0-00805f8a8dbd +#define NS_IXPFC_DIALOG_IID \ + { 0x52ae6d80, 0x3b81, 0x11d2, \ + {0xbe, 0xe0, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd} } + +class nsIXPFCDialog : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0; +}; + +#endif /* nsIXPFCDialog_h___ */ + diff --git a/mozilla/xpfc/dialog/src/Makefile b/mozilla/xpfc/dialog/src/Makefile new file mode 100644 index 00000000000..ea3f7f6ed86 --- /dev/null +++ b/mozilla/xpfc/dialog/src/Makefile @@ -0,0 +1,53 @@ +#! gmake +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include config.mk + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(GDEPTH)/gconfig/ruleset.mk +include $(GDEPTH)/gconfig/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + diff --git a/mozilla/xpfc/dialog/src/config.mk b/mozilla/xpfc/dialog/src/config.mk new file mode 100644 index 00000000000..54f583561f0 --- /dev/null +++ b/mozilla/xpfc/dialog/src/config.mk @@ -0,0 +1,24 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright © 1996, 1997 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# + +# +# Override TARGETS variable so that only static libraries +# are specifed as dependencies within rules.mk. +# + +CFLAGS +=-D_IMPL_NS_XPFC -DNSPR20 +INCLUDES += -I../inc -I$(GDEPTH)/include + +LIBRARY_NAME = dialog +LIBRARY_VERSION = 10 + +ARCHIVE_ONLY = 1 + +TARGETS = $(LIBRARY) diff --git a/mozilla/xpfc/dialog/src/manifest.mn b/mozilla/xpfc/dialog/src/manifest.mn new file mode 100644 index 00000000000..fea93b5021c --- /dev/null +++ b/mozilla/xpfc/dialog/src/manifest.mn @@ -0,0 +1,25 @@ +# +# CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF +# NETSCAPE COMMUNICATIONS CORPORATION +# Copyright (C) 1996 Netscape Communications Corporation. All Rights +# Reserved. Use of this Source Code is subject to the terms of the +# applicable license agreement from Netscape Communications Corporation. +# The copyright notice(s) in this Source Code does not indicate actual or +# intended publication of this Source Code. +# +GDEPTH = ../../../../.. + +EXPORTS = \ + $(NULL) + +PRIVATE_EXPORTS = \ + $(NULL) + +MODULE = xpfc + +CPPSRCS = \ + nsXPFCDialog.cpp \ + $(NULL) + +REQUIRES = xpcom raptor netlib + diff --git a/mozilla/xpfc/dialog/src/nsXPFCDialog.cpp b/mozilla/xpfc/dialog/src/nsXPFCDialog.cpp new file mode 100644 index 00000000000..74ba1b2b25a --- /dev/null +++ b/mozilla/xpfc/dialog/src/nsXPFCDialog.cpp @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsXPFCDialog.h" +#include "nsxpfcCIID.h" +#include "nspr.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kCXPFCDialogCID, NS_XPFC_DIALOG_CID); +static NS_DEFINE_IID(kCIXPFCDialogIID, NS_IXPFC_DIALOG_IID); + +#define DEFAULT_WIDTH 300 +#define DEFAULT_HEIGHT 300 + +nsXPFCDialog :: nsXPFCDialog(nsISupports* outer) : nsXPFCCanvas(outer) +{ + NS_INIT_REFCNT(); +} + +nsXPFCDialog :: ~nsXPFCDialog() +{ +} + +nsresult nsXPFCDialog::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, kCXPFCDialogCID); + if (aIID.Equals(kClassIID)) { + *aInstancePtr = (void*) (nsXPFCDialog *)this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kCIXPFCDialogIID)) { + *aInstancePtr = (void*) (nsIXPFCDialog *)this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*) (this); + AddRef(); + return NS_OK; + } + return (nsXPFCCanvas::QueryInterface(aIID, aInstancePtr)); +} + +NS_IMPL_ADDREF(nsXPFCDialog) +NS_IMPL_RELEASE(nsXPFCDialog) + +nsresult nsXPFCDialog :: Init() +{ + nsresult res = nsXPFCCanvas::Init(); + + return res; +} + +nsresult nsXPFCDialog :: SetParameter(nsString& aKey, nsString& aValue) +{ + return (nsXPFCCanvas::SetParameter(aKey, aValue)); +} + +nsresult nsXPFCDialog :: GetClassPreferredSize(nsSize& aSize) +{ + aSize.width = DEFAULT_WIDTH; + aSize.height = DEFAULT_HEIGHT; + return (NS_OK); +} +