Back to index

lightning-sunbird  0.9+nobinonly
nsTextBoxFrame.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 Communicator client 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  *   Peter Annema <disttsc@bart.nl>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 #ifndef nsTextBoxFrame_h___
00039 #define nsTextBoxFrame_h___
00040 
00041 #include "nsLeafBoxFrame.h"
00042 
00043 class nsAccessKeyInfo;
00044 
00045 typedef nsLeafBoxFrame nsTextBoxFrameSuper;
00046 class nsTextBoxFrame : public nsTextBoxFrameSuper
00047 {
00048 public:
00049 
00050   // nsIBox
00051   NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
00052   NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
00053   NS_IMETHOD GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent);
00054   NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
00055   NS_IMETHOD NeedsRecalc();
00056 
00057   enum CroppingStyle { CropNone, CropLeft, CropRight, CropCenter };
00058 
00059   friend nsresult NS_NewTextBoxFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame);
00060 
00061   NS_IMETHOD  Init(nsPresContext*  aPresContext,
00062                    nsIContent*      aContent,
00063                    nsIFrame*        aParent,
00064                    nsStyleContext*  aContext,
00065                    nsIFrame*        asPrevInFlow);
00066 
00067   NS_IMETHOD Destroy(nsPresContext* aPresContext);
00068 
00069   NS_IMETHOD AttributeChanged(nsIContent*     aChild,
00070                               PRInt32         aNameSpaceID,
00071                               nsIAtom*        aAttribute,
00072                               PRInt32         aModType);
00073 
00074 #ifdef DEBUG
00075   NS_IMETHOD GetFrameName(nsAString& aResult) const;
00076 #endif
00077 
00078   virtual void UpdateAttributes(nsPresContext*  aPresContext,
00079                                 nsIAtom*         aAttribute,
00080                                 PRBool&          aResize,
00081                                 PRBool&          aRedraw);
00082 
00083 
00084   NS_IMETHOD Paint(nsPresContext*      aPresContext,
00085                    nsIRenderingContext& aRenderingContext,
00086                    const nsRect&        aDirtyRect,
00087                    nsFramePaintLayer    aWhichLayer,
00088                    PRUint32             aFlags = 0);
00089 
00090 
00091   virtual ~nsTextBoxFrame();
00092 protected:
00093   friend class nsAsyncAccesskeyUpdate;
00094   // Should be called only by nsAsyncAccesskeyUpdate.
00095   // Returns PR_TRUE if accesskey was updated.
00096   PRBool UpdateAccesskey(nsWeakFrame& aWeakThis);
00097 
00098   void UpdateAccessTitle();
00099   void UpdateAccessIndex();
00100 
00101   NS_IMETHOD PaintTitle(nsPresContext*      aPresContext,
00102                         nsIRenderingContext& aRenderingContext,
00103                         const nsRect&        aDirtyRect,
00104                         const nsRect&        aRect);
00105 
00106   virtual void LayoutTitle(nsPresContext*      aPresContext,
00107                            nsIRenderingContext& aRenderingContext,
00108                            const nsRect&        aRect);
00109 
00110   virtual void CalculateUnderline(nsIRenderingContext& aRenderingContext);
00111 
00112   virtual void CalcTextSize(nsBoxLayoutState& aBoxLayoutState);
00113 
00114   nsTextBoxFrame(nsIPresShell* aShell);
00115 
00116   virtual void CalculateTitleForWidth(nsPresContext*      aPresContext,
00117                                       nsIRenderingContext& aRenderingContext,
00118                                       nscoord              aWidth);
00119 
00120   virtual void GetTextSize(nsPresContext*      aPresContext,
00121                            nsIRenderingContext& aRenderingContext,
00122                            const nsString&      aString,
00123                            nsSize&              aSize,
00124                            nscoord&             aAscent);
00125 
00126   nsresult RegUnregAccessKey(nsPresContext* aPresContext,
00127                              PRBool          aDoReg);
00128 
00129 private:
00130 
00131   PRBool AlwaysAppendAccessKey();
00132   PRBool InsertSeparatorBeforeAccessKey();
00133 
00134   CroppingStyle mCropType;
00135   nsString mTitle;
00136   nsString mCroppedTitle;
00137   nsString mAccessKey;
00138   nscoord mTitleWidth;
00139   nsAccessKeyInfo* mAccessKeyInfo;
00140   PRPackedBool mNeedsRecalc;
00141   PRPackedBool mNeedsReflowCallback;
00142   nsSize mTextSize;
00143   nscoord mAscent;
00144 
00145   static PRBool gAlwaysAppendAccessKey;
00146   static PRBool gAccessKeyPrefInitialized;
00147   static PRBool gInsertSeparatorBeforeAccessKey;
00148   static PRBool gInsertSeparatorPrefInitialized;
00149 
00150 }; // class nsTextBoxFrame
00151 
00152 #endif /* nsTextBoxFrame_h___ */