1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef nsHTMLButtonControlFrame_h___
39 : #define nsHTMLButtonControlFrame_h___
40 :
41 : #include "nsCOMPtr.h"
42 : #include "nsContainerFrame.h"
43 : #include "nsIFormControlFrame.h"
44 : #include "nsHTMLParts.h"
45 :
46 : #include "nsStyleContext.h"
47 : #include "nsLeafFrame.h"
48 : #include "nsCSSRendering.h"
49 : #include "nsISupports.h"
50 : #include "nsStyleConsts.h"
51 : #include "nsIComponentManager.h"
52 : #include "nsButtonFrameRenderer.h"
53 :
54 : class nsRenderingContext;
55 : class nsPresContext;
56 :
57 : class nsHTMLButtonControlFrame : public nsContainerFrame,
58 : public nsIFormControlFrame
59 : {
60 : public:
61 : nsHTMLButtonControlFrame(nsStyleContext* aContext);
62 : ~nsHTMLButtonControlFrame();
63 :
64 : virtual void DestroyFrom(nsIFrame* aDestructRoot);
65 :
66 : NS_DECL_QUERYFRAME
67 : NS_DECL_FRAMEARENA_HELPERS
68 :
69 : NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
70 : const nsRect& aDirtyRect,
71 : const nsDisplayListSet& aLists);
72 :
73 : virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext);
74 :
75 : virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext);
76 :
77 : NS_IMETHOD Reflow(nsPresContext* aPresContext,
78 : nsHTMLReflowMetrics& aDesiredSize,
79 : const nsHTMLReflowState& aReflowState,
80 : nsReflowStatus& aStatus);
81 :
82 : NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
83 : nsGUIEvent* aEvent,
84 : nsEventStatus* aEventStatus);
85 :
86 : NS_IMETHOD Init(nsIContent* aContent,
87 : nsIFrame* aParent,
88 : nsIFrame* asPrevInFlow);
89 :
90 : virtual nsStyleContext* GetAdditionalStyleContext(PRInt32 aIndex) const;
91 : virtual void SetAdditionalStyleContext(PRInt32 aIndex,
92 : nsStyleContext* aStyleContext);
93 :
94 : NS_IMETHOD AppendFrames(ChildListID aListID,
95 : nsFrameList& aFrameList);
96 :
97 : NS_IMETHOD InsertFrames(ChildListID aListID,
98 : nsIFrame* aPrevFrame,
99 : nsFrameList& aFrameList);
100 :
101 : NS_IMETHOD RemoveFrame(ChildListID aListID,
102 : nsIFrame* aOldFrame);
103 :
104 : #ifdef ACCESSIBILITY
105 : virtual already_AddRefed<nsAccessible> CreateAccessible();
106 : #endif
107 :
108 : virtual nsIAtom* GetType() const;
109 :
110 : #ifdef DEBUG
111 0 : NS_IMETHOD GetFrameName(nsAString& aResult) const {
112 0 : return MakeFrameName(NS_LITERAL_STRING("HTMLButtonControl"), aResult);
113 : }
114 : #endif
115 :
116 0 : virtual bool HonorPrintBackgroundSettings() { return false; }
117 :
118 : // nsIFormControlFrame
119 : void SetFocus(bool aOn, bool aRepaint);
120 : virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue);
121 : virtual nsresult GetFormProperty(nsIAtom* aName, nsAString& aValue) const;
122 :
123 : // Inserted child content gets its frames parented by our child block
124 0 : virtual nsIFrame* GetContentInsertionFrame() {
125 0 : return GetFirstPrincipalChild()->GetContentInsertionFrame();
126 : }
127 :
128 0 : virtual bool IsFrameOfType(PRUint32 aFlags) const
129 : {
130 : return nsContainerFrame::IsFrameOfType(aFlags &
131 0 : ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
132 : }
133 :
134 : protected:
135 0 : virtual bool IsInput() { return false; }
136 : void ReflowButtonContents(nsPresContext* aPresContext,
137 : nsHTMLReflowMetrics& aDesiredSize,
138 : const nsHTMLReflowState& aReflowState,
139 : nsIFrame* aFirstKid,
140 : nsMargin aFocusPadding,
141 : nsReflowStatus& aStatus);
142 :
143 : PRIntn GetSkipSides() const;
144 : nsButtonFrameRenderer mRenderer;
145 : };
146 :
147 : #endif
148 :
149 :
150 :
151 :
|