Back to index

lightning-sunbird  0.9+nobinonly
nsHTMLButtonControlFrame.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef nsHTMLButtonControlFrame_h___
00039 #define nsHTMLButtonControlFrame_h___
00040 
00041 #include "nsCOMPtr.h"
00042 #include "nsHTMLContainerFrame.h"
00043 #include "nsFormControlHelper.h"
00044 #include "nsIFormControlFrame.h"
00045 #include "nsHTMLParts.h"
00046 
00047 #include "nsPresContext.h"
00048 #include "nsIPresShell.h"
00049 #include "nsStyleContext.h"
00050 #include "nsLeafFrame.h"
00051 #include "nsCSSRendering.h"
00052 #include "nsISupports.h"
00053 #include "nsStyleConsts.h"
00054 #include "nsIComponentManager.h"
00055 #include "nsButtonFrameRenderer.h"
00056 
00057 class nsIRenderingContext;
00058 
00059 class nsHTMLButtonControlFrame : public nsHTMLContainerFrame,
00060                                  public nsIFormControlFrame 
00061 {
00062 public:
00063   nsHTMLButtonControlFrame();
00064   ~nsHTMLButtonControlFrame();
00065 
00066 
00067   NS_IMETHOD  Destroy(nsPresContext *aPresContext);
00068 
00069   NS_IMETHOD  QueryInterface(const nsIID& aIID, void** aInstancePtr);
00070 
00071   NS_IMETHOD Paint(nsPresContext*      aPresContext,
00072                    nsIRenderingContext& aRenderingContext,
00073                    const nsRect&        aDirtyRect,
00074                    nsFramePaintLayer    aWhichLayer,
00075                    PRUint32             aFlags = 0);
00076 
00077   NS_IMETHOD Reflow(nsPresContext*          aPresContext,
00078                     nsHTMLReflowMetrics&     aDesiredSize,
00079                     const nsHTMLReflowState& aReflowState,
00080                     nsReflowStatus&          aStatus);
00081 
00082   virtual PRBool IsContainingBlock() const;
00083   
00084   NS_IMETHOD HandleEvent(nsPresContext* aPresContext, 
00085                          nsGUIEvent* aEvent,
00086                          nsEventStatus* aEventStatus);
00087 
00088   NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame);
00089 
00090   NS_IMETHOD SetInitialChildList(nsPresContext* aPresContext,
00091                                  nsIAtom*        aListName,
00092                                  nsIFrame*       aChildList);
00093 
00094   NS_IMETHOD  Init(nsPresContext*  aPresContext,
00095                    nsIContent*      aContent,
00096                    nsIFrame*        aParent,
00097                    nsStyleContext*  aContext,
00098                    nsIFrame*        asPrevInFlow);
00099 
00100   virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const;
00101   virtual void SetAdditionalStyleContext(PRInt32 aIndex, 
00102                                          nsStyleContext* aStyleContext);
00103  
00104   NS_IMETHOD AppendFrames(nsIAtom*        aListName,
00105                           nsIFrame*       aFrameList);
00106 
00107   NS_IMETHOD InsertFrames(nsIAtom*        aListName,
00108                           nsIFrame*       aPrevFrame,
00109                           nsIFrame*       aFrameList);
00110 
00111   NS_IMETHOD RemoveFrame(nsIAtom*        aListName,
00112                          nsIFrame*       aOldFrame);
00113 
00114   NS_IMETHOD ReplaceFrame(nsIAtom*        aListName,
00115                           nsIFrame*       aOldFrame,
00116                           nsIFrame*       aNewFrame);
00117 
00118 #ifdef ACCESSIBILITY
00119   NS_IMETHOD GetAccessible(nsIAccessible** aAccessible);
00120 #endif
00121 
00122 #ifdef DEBUG
00123   NS_IMETHOD GetFrameName(nsAString& aResult) const {
00124     return MakeFrameName(NS_LITERAL_STRING("ButtonControl"), aResult);
00125   }
00126 #endif
00127 
00128   NS_IMETHOD_(PRInt32) GetFormControlType() const;
00129   NS_IMETHOD GetName(nsAString* aName);
00130   NS_IMETHOD GetValue(nsAString* aName);
00131   NS_IMETHOD OnContentReset();
00132 
00133   void SetFocus(PRBool aOn, PRBool aRepaint);
00134   void ScrollIntoView(nsPresContext* aPresContext);
00135 
00136   NS_IMETHOD GetFormContent(nsIContent*& aContent) const;
00137   virtual nscoord GetVerticalInsidePadding(nsPresContext* aPresContext,
00138                                            float aPixToTwip,
00139                                            nscoord aInnerHeight) const;
00140   virtual nscoord GetHorizontalInsidePadding(nsPresContext* aPresContext,
00141                                              float aPixToTwip, 
00142                                              nscoord aInnerWidth,
00143                                              nscoord aCharWidth) const;
00144 
00145   // nsIFormControlFrame
00146   NS_IMETHOD SetProperty(nsPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue);
00147   NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); 
00148   NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
00149 
00150   // Inserted child content gets its frames parented by our child block
00151   virtual nsIFrame* GetContentInsertionFrame() {
00152     return GetFirstChild(nsnull)->GetContentInsertionFrame();
00153   }
00154 
00155 protected:
00156   void ReParentFrameList(nsFrameManager* aFrameManager, nsIFrame* aFrameList);
00157   virtual PRBool IsReset(PRInt32 type);
00158   virtual PRBool IsSubmit(PRInt32 type);
00159   void ReflowButtonContents(nsPresContext* aPresContext,
00160                             nsHTMLReflowMetrics& aDesiredSize,
00161                             const nsHTMLReflowState& aReflowState,
00162                             nsIFrame* aFirstKid,
00163                             const nsSize& aAvailSize,
00164                             nsReflowReason aReason,
00165                             nsMargin aFocusPadding,
00166                             nsReflowStatus& aStatus);
00167   NS_IMETHOD AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize,
00168                                                    const nsHTMLReflowState& aSuggestedReflowState);
00169   NS_IMETHOD_(nsrefcnt) AddRef(void);
00170   NS_IMETHOD_(nsrefcnt) Release(void);
00171 
00172   PRIntn GetSkipSides() const;
00173   PRBool mInline;
00174   nsButtonFrameRenderer mRenderer;
00175 
00176   //Resize Reflow OpitmizationSize;
00177   nsSize                mCacheSize;
00178   nscoord               mCachedAscent;
00179   nscoord               mCachedMaxElementWidth;
00180 };
00181 
00182 #endif
00183 
00184 
00185 
00186