diff --git a/layout/xul/base/Makefile.in b/layout/xul/base/Makefile.in new file mode 100644 index 000000000000..586e96d7d1ae --- /dev/null +++ b/layout/xul/base/Makefile.in @@ -0,0 +1,29 @@ +#!gmake +# +# 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. + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +DIRS = src + +include $(topsrcdir)/config/config.mk + +include $(topsrcdir)/config/rules.mk diff --git a/layout/xul/base/makefile.win b/layout/xul/base/makefile.win new file mode 100644 index 000000000000..c60dddaa76c5 --- /dev/null +++ b/layout/xul/base/makefile.win @@ -0,0 +1,22 @@ +#!nmake +# +# 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. + +DEPTH=..\..\.. + +DIRS=src + +include <$(DEPTH)\layout\config\rules.mak> diff --git a/layout/xul/base/src/nsToolbarFrame.cpp b/layout/xul/base/src/nsToolbarFrame.cpp new file mode 100644 index 000000000000..4de531fcba64 --- /dev/null +++ b/layout/xul/base/src/nsToolbarFrame.cpp @@ -0,0 +1,116 @@ +/* -*- 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 "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +// +// Mike Pinkerton +// Netscape Communications +// +// See documentation in associated header file +// + +#include "nsToolbarFrame.h" + + +// +// NS_NewToolbarFrame +// +// Creates a new Toolbar frame and returns it in |aNewFrame| +// +nsresult +NS_NewToolbarFrame ( nsIFrame*& aNewFrame, PRUint32 aFlags ) +{ + nsToolbarFrame* it = new nsToolbarFrame; + if (nsnull == it) + return NS_ERROR_OUT_OF_MEMORY; + + it->SetFlags(aFlags); + aNewFrame = it; + return NS_OK; + +} // NS_NewToolbarFrame + + +// +// nsToolbarFrame dstr +// +// Cleanup, if necessary +// +nsToolbarFrame :: ~nsToolbarFrame ( ) +{ + //*** anything? +} + + +// +// Paint +// +// Paint our background and border like normal frames, but before we draw the +// children, draw our grippies for each toolbar. +// +NS_IMETHODIMP +nsToolbarFrame :: Paint ( nsIPresContext& aPresContext, + nsIRenderingContext& aRenderingContext, + const nsRect& aDirtyRect, + nsFramePaintLayer aWhichLayer) +{ + if (eFramePaintLayer_Underlay == aWhichLayer) { + const nsStyleDisplay* disp = (const nsStyleDisplay*) + mStyleContext->GetStyleData(eStyleStruct_Display); + if (disp->mVisible && mRect.width && mRect.height) { + // Paint our background and border + PRIntn skipSides = GetSkipSides(); + const nsStyleColor* color = (const nsStyleColor*) + mStyleContext->GetStyleData(eStyleStruct_Color); + const nsStyleSpacing* spacing = (const nsStyleSpacing*) + mStyleContext->GetStyleData(eStyleStruct_Spacing); + + nsRect rect(0, 0, mRect.width, mRect.height); + nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, + aDirtyRect, rect, *color, *spacing, 0, 0); + nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, + aDirtyRect, rect, *spacing, skipSides); + } + } + + //*** anything toolbar specific here??? + + // Now paint the items. Note that child elements have the opportunity to + // override the visibility property and display even if their parent is + // hidden + PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); + return NS_OK; + +} // Paint + + +// +// Reflow +// +// Handle moving children around. +// +NS_IMETHOD +nsToolbarFrame :: Reflow ( nsIPresContext& aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus) +{ + nsBlockFrame::Reflow ( aPresContext, aDesiredSize, aReflowState, aStatus ); + +} // Reflow + diff --git a/layout/xul/base/src/nsToolbarFrame.h b/layout/xul/base/src/nsToolbarFrame.h new file mode 100644 index 000000000000..0d46496aed8c --- /dev/null +++ b/layout/xul/base/src/nsToolbarFrame.h @@ -0,0 +1,65 @@ +/* -*- 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 "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +// +// Mike Pinkerton +// Netscape Communications +// +// nsToolbarFrame is a layout object that contains items (specified as +// children in the DOM). The layout for toolbars is a little complicated, but +// it basically just lays out its children in order. Toolbars themselves +// don't know anything about grippies (as in 4.x) but are associated with them +// through toolboxes. This allows a developer to create a standalone toolbar +// (for inclusion in a webpage), which obviously doesn't need to have a grippy. +// +// As mentioned above, the Toolbar expects its toolbars to be its children in +// the DOM. The exact structure of the children is documented on: +// http://www.mozilla.org/xpfe/DMWSpecNew.html +// +// <> +// + + +#include "nsBlockFrame.h" + +class nsToolbarFrame : public nsBlockFrame +{ +public: + friend nsresult NS_NewToolbarFrame(nsIFrame*& aNewFrame, PRUint32 aFlags); + + // nsIHTMLReflow overrides + NS_IMETHOD Reflow(nsIPresContext& aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus); + NS_IMETHOD Paint(nsIPresContext& aPresContext, + nsIRenderingContext& aRenderingContext, + const nsRect& aDirtyRect, + nsFramePaintLayer aWhichLayer); + +protected: + nsToolbarFrame(); + virtual ~nsToolbarFrame(); + + // pass-by-value not allowed for a coordinator because it corresponds 1-to-1 + // with an element in the UI. + nsToolbarFrame ( const nsToolbarFrame& aFrame ) ; // DO NOT IMPLEMENT + nsToolbarFrame& operator= ( const nsToolbarFrame& aFrame ) ; // DO NOT IMPLEMENT + +}; // class nsToolbarFrame diff --git a/layout/xul/base/src/nsToolboxFrame.cpp b/layout/xul/base/src/nsToolboxFrame.cpp new file mode 100644 index 000000000000..c573f1596a0b --- /dev/null +++ b/layout/xul/base/src/nsToolboxFrame.cpp @@ -0,0 +1,118 @@ +/* -*- 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 "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +// +// Mike Pinkerton +// Netscape Communications +// +// See documentation in associated header file +// + +#include "nsToolboxFrame.h" + + +// +// NS_NewToolboxFrame +// +// Creates a new toolbox frame and returns it in |aNewFrame| +// +nsresult +NS_NewToolboxFrame ( nsIFrame*& aNewFrame, PRUint32 aFlags ) +{ + nsToolboxFrame* it = new nsToolboxFrame; + if (nsnull == it) + return NS_ERROR_OUT_OF_MEMORY; + + it->SetFlags(aFlags); + aNewFrame = it; + return NS_OK; + +} // NS_NewToolboxFrame + + +// +// nsToolboxFrame dstr +// +// Cleanup, if necessary +// +nsToolboxFrame :: ~nsToolboxFrame ( ) +{ + //*** anything? +} + + +// +// Paint +// +// Paint our background and border like normal frames, but before we draw the +// children, draw our grippies for each toolbar. +// +NS_IMETHODIMP +nsToolboxFrame :: Paint ( nsIPresContext& aPresContext, + nsIRenderingContext& aRenderingContext, + const nsRect& aDirtyRect, + nsFramePaintLayer aWhichLayer) +{ + if (eFramePaintLayer_Underlay == aWhichLayer) { + const nsStyleDisplay* disp = (const nsStyleDisplay*) + mStyleContext->GetStyleData(eStyleStruct_Display); + if (disp->mVisible && mRect.width && mRect.height) { + // Paint our background and border + PRIntn skipSides = GetSkipSides(); + const nsStyleColor* color = (const nsStyleColor*) + mStyleContext->GetStyleData(eStyleStruct_Color); + const nsStyleSpacing* spacing = (const nsStyleSpacing*) + mStyleContext->GetStyleData(eStyleStruct_Spacing); + + nsRect rect(0, 0, mRect.width, mRect.height); + nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, + aDirtyRect, rect, *color, *spacing, 0, 0); + nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, + aDirtyRect, rect, *spacing, skipSides); + } + } + + //*** draw grippies + //*** draw collapsed area under toolbars (is that a frame itself???) + + // Now paint the toolbars. Note that child elements have the opportunity to + // override the visibility property and display even if their parent is + // hidden + PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); + return NS_OK; + +} // Paint + + +// +// Reflow +// +// Handle moving children around. This may have to account for toolbars that +// grew to multiple lines or collapsed toolbars and the expando-dock at the bottom +// +NS_IMETHOD +nsToolboxFrame :: Reflow ( nsIPresContext& aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus) +{ + nsHTMLContainerFrame::Reflow ( aPresContext, aDesiredSize, aReflowState, aStatus ); + +} // Reflow + diff --git a/layout/xul/base/src/nsToolboxFrame.h b/layout/xul/base/src/nsToolboxFrame.h new file mode 100644 index 000000000000..74b1b5e84269 --- /dev/null +++ b/layout/xul/base/src/nsToolboxFrame.h @@ -0,0 +1,66 @@ +/* -*- 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 "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are Copyright (C) 1998 + * Netscape Communications Corporation. All Rights Reserved. + */ + +// +// Mike Pinkerton +// Netscape Communications +// +// nsToolboxFrame is a layout object that contains one or more toolbar frames +// (specified as children in the DOM). These toolbars are laid out one on top +// of the other, and can be of varying heights but are all of the same width +// (the full width of the toolbox). Each toolbar is associated with a "grippy" +// which can be used to either collapse a particular toolbar or as a handle to +// pick up and move a toolbar to a new position within the toolbox. When toolbars +// are collapsed, it's grippy is moved to the bottom of the box and laid on +// its side. Clicking again on the grippy will reinstate the toolbar to its previous +// position in the toolbox. +// +// As mentioned above, the toolbox expects its toolbars to be its children in +// the DOM. The exact structure of the children is documented on: +// http://www.mozilla.org/xpfe/DMWSpecNew.html +// + +#include "nsHTMLContainerFrame.h" + + +class nsToolboxFrame : public nsHTMLContainerFrame +{ +public: + friend nsresult NS_NewToolboxFrame(nsIFrame*& aNewFrame, PRUint32 aFlags); + + // nsIHTMLReflow overrides + NS_IMETHOD Reflow(nsIPresContext& aPresContext, + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus); + NS_IMETHOD Paint(nsIPresContext& aPresContext, + nsIRenderingContext& aRenderingContext, + const nsRect& aDirtyRect, + nsFramePaintLayer aWhichLayer); + +protected: + nsToolboxFrame(); + virtual ~nsToolboxFrame(); + + // pass-by-value not allowed for a coordinator because it corresponds 1-to-1 + // with an element in the UI. + nsToolboxFrame ( const nsToolboxFrame& aFrame ) ; // DO NOT IMPLEMENT + nsToolboxFrame& operator= ( const nsToolboxFrame& aFrame ) ; // DO NOT IMPLEMENT + +}; // class nsToolboxFrame