2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-11-10 02:30:16 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (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/
|
1998-11-10 02:30:16 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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.
|
1998-11-10 02:30:16 +03:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2001-11-02 10:40:01 +03:00
|
|
|
#include "nsIImageControlFrame.h"
|
1999-04-14 01:51:43 +04:00
|
|
|
#include "nsImageFrame.h"
|
1999-01-22 18:32:57 +03:00
|
|
|
#include "nsFormControlHelper.h"
|
1998-11-10 02:30:16 +03:00
|
|
|
#include "nsIFormControlFrame.h"
|
|
|
|
#include "nsIFormControl.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsLeafFrame.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsHTMLIIDs.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsViewsCID.h"
|
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
#include "nsIFontMetrics.h"
|
|
|
|
#include "nsIImage.h"
|
|
|
|
#include "nsStyleUtil.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsFormFrame.h"
|
2000-02-09 22:34:39 +03:00
|
|
|
#include "nsFormControlFrame.h"
|
2001-07-16 06:40:48 +04:00
|
|
|
#include "nsGUIEvent.h"
|
2001-11-01 18:31:13 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-05-12 01:11:38 +04:00
|
|
|
#include "nsIAccessibilityService.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
1998-11-10 02:30:16 +03:00
|
|
|
|
|
|
|
//Enumeration of possible mouse states used to detect mouse clicks
|
1999-01-22 18:32:57 +03:00
|
|
|
/*enum nsMouseState {
|
1998-11-10 02:30:16 +03:00
|
|
|
eMouseNone,
|
|
|
|
eMouseEnter,
|
1998-11-18 08:25:26 +03:00
|
|
|
eMouseExit,
|
1998-11-10 02:30:16 +03:00
|
|
|
eMouseDown,
|
1998-11-18 08:25:26 +03:00
|
|
|
eMouseUp
|
1998-11-10 02:30:16 +03:00
|
|
|
};
|
1999-01-22 18:32:57 +03:00
|
|
|
*/
|
1998-11-10 02:30:16 +03:00
|
|
|
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
|
|
|
|
1998-11-20 20:22:08 +03:00
|
|
|
#define nsImageControlFrameSuper nsImageFrame
|
|
|
|
class nsImageControlFrame : public nsImageControlFrameSuper,
|
2001-11-02 10:40:01 +03:00
|
|
|
public nsIFormControlFrame,
|
|
|
|
public nsIImageControlFrame
|
1998-11-10 02:30:16 +03:00
|
|
|
{
|
|
|
|
public:
|
1998-12-03 09:31:43 +03:00
|
|
|
nsImageControlFrame();
|
1999-11-05 02:16:47 +03:00
|
|
|
~nsImageControlFrame();
|
1998-11-10 02:30:16 +03:00
|
|
|
|
2000-05-16 16:44:32 +04:00
|
|
|
NS_IMETHOD Destroy(nsIPresContext *aPresContext);
|
|
|
|
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
1998-11-10 02:30:16 +03:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Init(nsIPresContext* aPresContext,
|
1999-11-19 18:33:29 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow);
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
1999-04-27 04:06:03 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD HandleEvent(nsIPresContext* aPresContext,
|
1998-11-10 02:30:16 +03:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsEventStatus* aEventStatus);
|
1998-11-10 02:30:16 +03:00
|
|
|
|
2001-11-01 18:31:13 +03:00
|
|
|
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
|
|
|
|
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-05-18 03:52:32 +04:00
|
|
|
NS_IMETHOD GetAccessible(nsIAccessible** aAccessible);
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-05-18 03:52:32 +04:00
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
2001-11-14 04:33:42 +03:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const {
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("ImageControl"), aResult);
|
1998-11-19 20:22:29 +03:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-11-19 20:22:29 +03:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD GetCursor(nsIPresContext* aPresContext,
|
1999-04-28 02:54:15 +04:00
|
|
|
nsPoint& aPoint,
|
|
|
|
PRInt32& aCursor);
|
|
|
|
|
1998-11-10 02:30:16 +03:00
|
|
|
virtual void MouseClicked(nsIPresContext* aPresContext);
|
|
|
|
|
|
|
|
virtual void SetFormFrame(nsFormFrame* aFormFrame) { mFormFrame = aFormFrame; }
|
|
|
|
|
|
|
|
NS_IMETHOD GetType(PRInt32* aType) const;
|
|
|
|
|
2001-11-02 10:40:01 +03:00
|
|
|
NS_IMETHOD GetName(nsAString* aName);
|
1998-11-10 02:30:16 +03:00
|
|
|
|
|
|
|
void SetFocus(PRBool aOn, PRBool aRepaint);
|
1999-08-21 04:09:24 +04:00
|
|
|
void ScrollIntoView(nsIPresContext* aPresContext);
|
1999-01-22 18:32:57 +03:00
|
|
|
NS_IMETHOD GetFont(nsIPresContext* aPresContext,
|
2000-01-25 18:25:46 +03:00
|
|
|
const nsFont*& aFont);
|
1999-01-22 18:32:57 +03:00
|
|
|
|
|
|
|
NS_IMETHOD GetFormContent(nsIContent*& aContent) const;
|
1999-11-24 09:03:41 +03:00
|
|
|
virtual nscoord GetVerticalInsidePadding(nsIPresContext* aPresContext,
|
1999-09-30 15:30:04 +04:00
|
|
|
float aPixToTwip,
|
1999-01-22 18:32:57 +03:00
|
|
|
nscoord aInnerHeight) const;
|
1999-11-24 09:03:41 +03:00
|
|
|
virtual nscoord GetHorizontalInsidePadding(nsIPresContext* aPresContext,
|
1999-01-22 18:32:57 +03:00
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerWidth,
|
|
|
|
nscoord aCharWidth) const;
|
1999-03-06 22:43:13 +03:00
|
|
|
|
|
|
|
virtual nsresult RequiresWidget(PRBool &aRequiresWidget);
|
|
|
|
|
|
|
|
|
1999-01-26 01:16:27 +03:00
|
|
|
// nsIFormControlFrame
|
2000-08-23 21:27:06 +04:00
|
|
|
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAReadableString& aValue);
|
|
|
|
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue);
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
|
2001-11-02 10:40:01 +03:00
|
|
|
NS_IMETHOD OnContentReset();
|
|
|
|
|
|
|
|
// nsIImageControlFrame
|
|
|
|
NS_IMETHOD GetClickedX(PRInt32* aX);
|
|
|
|
NS_IMETHOD GetClickedY(PRInt32* aY);
|
1999-01-22 18:32:57 +03:00
|
|
|
|
1998-11-10 02:30:16 +03:00
|
|
|
protected:
|
1999-10-26 08:44:41 +04:00
|
|
|
void GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect); // XXX this implementation is a copy of nsHTMLButtonControlFrame
|
1998-11-10 02:30:16 +03:00
|
|
|
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
|
|
|
NS_IMETHOD_(nsrefcnt) Release(void);
|
|
|
|
|
|
|
|
nsFormFrame* mFormFrame;
|
|
|
|
nsMouseState mLastMouseState;
|
|
|
|
nsPoint mLastClickPoint;
|
|
|
|
nsCursor mPreviousCursor;
|
|
|
|
nsRect mTranslatedRect;
|
|
|
|
PRBool mGotFocus;
|
2000-02-09 22:34:39 +03:00
|
|
|
|
1998-11-10 02:30:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
nsImageControlFrame::nsImageControlFrame()
|
1998-11-10 02:30:16 +03:00
|
|
|
{
|
|
|
|
mLastMouseState = eMouseNone;
|
|
|
|
mLastClickPoint = nsPoint(0,0);
|
|
|
|
mPreviousCursor = eCursor_standard;
|
|
|
|
mTranslatedRect = nsRect(0,0,0,0);
|
1999-04-27 04:06:03 +04:00
|
|
|
mGotFocus = PR_FALSE;
|
|
|
|
mFormFrame = nsnull;
|
1998-11-10 02:30:16 +03:00
|
|
|
}
|
|
|
|
|
1999-11-05 02:16:47 +03:00
|
|
|
nsImageControlFrame::~nsImageControlFrame()
|
|
|
|
{
|
2000-05-16 16:44:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageControlFrame::Destroy(nsIPresContext *aPresContext)
|
|
|
|
{
|
|
|
|
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_FALSE);
|
2000-02-09 22:34:39 +03:00
|
|
|
|
1999-11-05 02:16:47 +03:00
|
|
|
if (mFormFrame) {
|
|
|
|
mFormFrame->RemoveFormControlFrame(*this);
|
|
|
|
mFormFrame = nsnull;
|
|
|
|
}
|
2000-05-16 16:44:32 +04:00
|
|
|
return nsImageControlFrameSuper::Destroy(aPresContext);
|
1999-11-05 02:16:47 +03:00
|
|
|
}
|
|
|
|
|
1998-11-10 02:30:16 +03:00
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewImageControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-11-10 02:30:16 +03:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsImageControlFrame* it = new (aPresShell) nsImageControlFrame;
|
1999-05-12 02:03:29 +04:00
|
|
|
if (!it) {
|
1998-11-10 02:30:16 +03:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-11-10 02:30:16 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-02 04:50:15 +03:00
|
|
|
// Frames are not refcounted, no need to AddRef
|
|
|
|
NS_IMETHODIMP
|
1998-11-10 02:30:16 +03:00
|
|
|
nsImageControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
2001-01-04 23:44:42 +03:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) {
|
1998-11-10 02:30:16 +03:00
|
|
|
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
|
|
|
|
return NS_OK;
|
2001-05-12 01:11:38 +04:00
|
|
|
}
|
2001-11-02 10:40:01 +03:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIImageControlFrame))) {
|
|
|
|
*aInstancePtr = (void*) ((nsIImageControlFrame*) this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-05-12 01:11:38 +04:00
|
|
|
|
1998-11-20 20:22:08 +03:00
|
|
|
return nsImageControlFrameSuper::QueryInterface(aIID, aInstancePtr);
|
1998-11-10 02:30:16 +03:00
|
|
|
}
|
|
|
|
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-05-18 03:52:32 +04:00
|
|
|
NS_IMETHODIMP nsImageControlFrame::GetAccessible(nsIAccessible** aAccessible)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
|
|
|
|
|
|
|
if (accService) {
|
|
|
|
return accService->CreateHTML4ButtonAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-05-18 03:52:32 +04:00
|
|
|
|
1998-11-10 02:30:16 +03:00
|
|
|
nsrefcnt nsImageControlFrame::AddRef(void)
|
|
|
|
{
|
|
|
|
NS_WARNING("not supported");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsImageControlFrame::Release(void)
|
|
|
|
{
|
|
|
|
NS_WARNING("not supported");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2001-11-01 18:31:13 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageControlFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::imageControlFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsImageControlFrame::Init(nsIPresContext* aPresContext,
|
1999-11-19 18:33:29 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
// call our base class
|
|
|
|
nsresult rv = nsImageControlFrameSuper::Init(aPresContext, aContent, aParent,
|
|
|
|
aContext, aPrevInFlow);
|
|
|
|
|
|
|
|
// create our view, we need a view to grab the mouse
|
|
|
|
nsIView* view;
|
1999-11-24 09:03:41 +03:00
|
|
|
GetView(aPresContext, &view);
|
1999-11-19 18:33:29 +03:00
|
|
|
if (!view) {
|
2001-01-04 23:44:42 +03:00
|
|
|
nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, NS_GET_IID(nsIView), (void **)&view);
|
1999-11-19 18:33:29 +03:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
1999-11-19 18:33:29 +03:00
|
|
|
nsCOMPtr<nsIViewManager> viewMan;
|
|
|
|
presShell->GetViewManager(getter_AddRefs(viewMan));
|
|
|
|
|
|
|
|
nsIFrame* parWithView;
|
|
|
|
nsIView *parView;
|
1999-11-24 09:03:41 +03:00
|
|
|
GetParentWithView(aPresContext, &parWithView);
|
|
|
|
parWithView->GetView(aPresContext, &parView);
|
1999-11-19 18:33:29 +03:00
|
|
|
// the view's size is not know yet, but its size will be kept in synch with our frame.
|
|
|
|
nsRect boundBox(0, 0, 0, 0);
|
2000-04-25 08:43:11 +04:00
|
|
|
result = view->Init(viewMan, boundBox, parView);
|
2001-12-01 17:31:45 +03:00
|
|
|
viewMan->SetViewContentTransparency(view, PR_TRUE);
|
|
|
|
// XXX put the view last in document order until we know how to do better
|
|
|
|
viewMan->InsertChild(parView, view, nsnull, PR_TRUE);
|
1999-11-24 09:03:41 +03:00
|
|
|
SetView(aPresContext, view);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleVisibility* vis = (const nsStyleVisibility*) mStyleContext->GetStyleData(eStyleStruct_Visibility);
|
1999-11-19 18:33:29 +03:00
|
|
|
// set the opacity
|
2001-06-01 02:19:43 +04:00
|
|
|
viewMan->SetViewOpacity(view, vis->mOpacity);
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
|
|
|
|
1999-11-30 08:38:15 +03:00
|
|
|
return rv;
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
|
|
|
|
1999-04-27 04:06:03 +04:00
|
|
|
NS_METHOD
|
1999-11-24 09:03:41 +03:00
|
|
|
nsImageControlFrame::Reflow(nsIPresContext* aPresContext,
|
1999-04-27 04:06:03 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2000-04-22 01:51:35 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsImageControlFrame", aReflowState.reason);
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
1999-04-27 04:06:03 +04:00
|
|
|
if (!mFormFrame && (eReflowReason_Initial == aReflowState.reason)) {
|
2000-02-09 22:34:39 +03:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE);
|
1999-04-27 04:06:03 +04:00
|
|
|
// add ourself as an nsIFormControlFrame
|
1999-11-24 09:03:41 +03:00
|
|
|
nsFormFrame::AddFormControlFrame(aPresContext, *NS_STATIC_CAST(nsIFrame*, this));
|
1998-11-10 02:30:16 +03:00
|
|
|
}
|
1999-04-27 04:06:03 +04:00
|
|
|
return nsImageControlFrameSuper::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-11-10 02:30:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD
|
1999-11-24 09:03:41 +03:00
|
|
|
nsImageControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
1999-01-27 03:25:40 +03:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-11-10 02:30:16 +03:00
|
|
|
{
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
2000-08-09 03:38:00 +04:00
|
|
|
|
|
|
|
// do we have user-input style?
|
|
|
|
const nsStyleUserInterface* uiStyle;
|
2000-08-09 04:52:02 +04:00
|
|
|
GetStyleData(eStyleStruct_UserInterface, (const nsStyleStruct *&)uiStyle);
|
2000-08-09 03:38:00 +04:00
|
|
|
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
|
|
|
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
|
|
|
|
1998-11-10 02:30:16 +03:00
|
|
|
if (nsFormFrame::GetDisabled(this)) { // XXX cache disabled
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
*aEventStatus = nsEventStatus_eIgnore;
|
1998-11-10 02:30:16 +03:00
|
|
|
|
1998-11-18 08:25:26 +03:00
|
|
|
switch (aEvent->message) {
|
2000-08-04 02:17:14 +04:00
|
|
|
case NS_MOUSE_LEFT_BUTTON_UP:
|
1999-01-27 03:25:40 +03:00
|
|
|
{
|
|
|
|
// Store click point for GetNamesValues
|
2000-08-04 02:17:14 +04:00
|
|
|
// Do this on MouseUp because the specs don't say and that's what IE does.
|
1999-02-12 20:45:58 +03:00
|
|
|
float t2p;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetTwipsToPixels(&t2p);
|
1999-01-27 03:25:40 +03:00
|
|
|
mLastClickPoint.x = NSTwipsToIntPixels(aEvent->point.x, t2p);
|
|
|
|
mLastClickPoint.y = NSTwipsToIntPixels(aEvent->point.y, t2p);
|
|
|
|
|
1998-11-18 08:25:26 +03:00
|
|
|
mGotFocus = PR_TRUE;
|
1999-01-27 03:25:40 +03:00
|
|
|
break;
|
1998-11-10 02:30:16 +03:00
|
|
|
}
|
|
|
|
}
|
1998-11-20 20:22:08 +03:00
|
|
|
return nsImageControlFrameSuper::HandleEvent(aPresContext, aEvent,
|
|
|
|
aEventStatus);
|
1998-11-10 02:30:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsImageControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
|
|
|
{
|
|
|
|
mGotFocus = aOn;
|
1999-07-16 18:23:48 +04:00
|
|
|
/*if (aRepaint) {
|
1998-11-10 02:30:16 +03:00
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
|
|
|
Invalidate(rect, PR_TRUE);
|
1999-07-16 18:23:48 +04:00
|
|
|
}*/
|
1998-11-10 02:30:16 +03:00
|
|
|
}
|
|
|
|
|
1999-08-21 04:09:24 +04:00
|
|
|
void
|
|
|
|
nsImageControlFrame::ScrollIntoView(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
if (aPresContext) {
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
2000-09-08 09:53:28 +04:00
|
|
|
if (presShell) {
|
|
|
|
presShell->ScrollFrameIntoView(this,
|
2000-01-26 01:19:39 +03:00
|
|
|
NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE);
|
2000-09-08 09:53:28 +04:00
|
|
|
}
|
1999-08-21 04:09:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-10 02:30:16 +03:00
|
|
|
void
|
1999-10-26 08:44:41 +04:00
|
|
|
nsImageControlFrame::GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect)
|
1998-11-10 02:30:16 +03:00
|
|
|
{
|
|
|
|
nsIView* view;
|
|
|
|
nsPoint viewOffset(0,0);
|
1999-10-26 08:44:41 +04:00
|
|
|
GetOffsetFromView(aPresContext, viewOffset, &view);
|
1998-11-10 02:30:16 +03:00
|
|
|
while (nsnull != view) {
|
|
|
|
nsPoint tempOffset;
|
|
|
|
view->GetPosition(&tempOffset.x, &tempOffset.y);
|
|
|
|
viewOffset += tempOffset;
|
|
|
|
view->GetParent(view);
|
|
|
|
}
|
|
|
|
aRect = nsRect(viewOffset.x, viewOffset.y, mRect.width, mRect.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageControlFrame::GetType(PRInt32* aType) const
|
|
|
|
{
|
|
|
|
*aType = NS_FORM_INPUT_IMAGE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-11-02 10:40:01 +03:00
|
|
|
nsImageControlFrame::GetName(nsAString* aResult)
|
1998-11-10 02:30:16 +03:00
|
|
|
{
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_OK;
|
|
|
|
} else {
|
|
|
|
return nsFormFrame::GetName(this, *aResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-28 02:54:15 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsImageControlFrame::GetCursor(nsIPresContext* aPresContext,
|
1999-04-28 02:54:15 +04:00
|
|
|
nsPoint& aPoint,
|
|
|
|
PRInt32& aCursor)
|
|
|
|
{
|
1999-06-25 04:19:44 +04:00
|
|
|
// Use style defined cursor if one is provided, otherwise when
|
|
|
|
// the cursor style is "auto" we use the pointer cursor.
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleUserInterface* ui = (const nsStyleUserInterface*) mStyleContext->GetStyleData(eStyleStruct_UserInterface);
|
|
|
|
if (ui) {
|
|
|
|
aCursor = ui->mCursor;
|
1999-06-25 05:17:18 +04:00
|
|
|
if (NS_STYLE_CURSOR_AUTO == aCursor) {
|
|
|
|
aCursor = NS_STYLE_CURSOR_POINTER;
|
|
|
|
}
|
|
|
|
} else {
|
1999-06-25 04:19:44 +04:00
|
|
|
aCursor = NS_STYLE_CURSOR_POINTER;
|
|
|
|
}
|
1999-04-28 02:54:15 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-11-10 02:30:16 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
nsImageControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
|
|
|
{
|
2001-02-23 04:01:08 +03:00
|
|
|
if (nsnull != mFormFrame && !nsFormFrame::GetDisabled(this)) {
|
|
|
|
// Do Submit & DOM Processing
|
|
|
|
nsFormControlHelper::DoManualSubmitOrReset(aPresContext, nsnull,
|
|
|
|
mFormFrame, this, PR_TRUE, PR_TRUE);
|
1998-11-10 02:30:16 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-22 18:32:57 +03:00
|
|
|
NS_IMETHODIMP
|
2000-01-25 18:25:46 +03:00
|
|
|
nsImageControlFrame::GetFont(nsIPresContext* aPresContext,
|
|
|
|
const nsFont*& aFont)
|
1999-01-22 18:32:57 +03:00
|
|
|
{
|
2000-01-25 18:25:46 +03:00
|
|
|
return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont);
|
1999-01-22 18:32:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageControlFrame::GetFormContent(nsIContent*& aContent) const
|
|
|
|
{
|
1999-02-10 03:42:56 +03:00
|
|
|
nsIContent* content;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = GetContent(&content);
|
|
|
|
aContent = content;
|
|
|
|
return rv;
|
1999-01-22 18:32:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
1999-11-24 09:03:41 +03:00
|
|
|
nsImageControlFrame::GetVerticalInsidePadding(nsIPresContext* aPresContext,
|
1999-09-30 15:30:04 +04:00
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerHeight) const
|
1999-01-22 18:32:57 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
1999-11-24 09:03:41 +03:00
|
|
|
nsImageControlFrame::GetHorizontalInsidePadding(nsIPresContext* aPresContext,
|
1999-01-22 18:32:57 +03:00
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerWidth,
|
|
|
|
nscoord aCharWidth) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
1999-01-26 01:16:27 +03:00
|
|
|
|
1999-03-06 22:43:13 +03:00
|
|
|
nsresult nsImageControlFrame::RequiresWidget(PRBool& aRequiresWidget)
|
|
|
|
{
|
|
|
|
aRequiresWidget = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-26 08:44:41 +04:00
|
|
|
NS_IMETHODIMP nsImageControlFrame::SetProperty(nsIPresContext* aPresContext,
|
2000-08-23 21:27:06 +04:00
|
|
|
nsIAtom* aName,
|
|
|
|
const nsAReadableString& aValue)
|
1999-01-26 01:16:27 +03:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-08-23 21:27:06 +04:00
|
|
|
NS_IMETHODIMP nsImageControlFrame::GetProperty(nsIAtom* aName,
|
|
|
|
nsAWritableString& aValue)
|
1999-01-26 01:16:27 +03:00
|
|
|
{
|
2000-08-23 21:27:06 +04:00
|
|
|
aValue.Truncate();
|
1999-01-26 01:16:27 +03:00
|
|
|
return NS_OK;
|
1999-01-27 03:25:40 +03:00
|
|
|
}
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsImageControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight)
|
|
|
|
{
|
|
|
|
// mSuggestedWidth = aWidth;
|
|
|
|
// mSuggestedHeight = aHeight;
|
|
|
|
return NS_OK;
|
1999-07-16 04:26:47 +04:00
|
|
|
}
|
|
|
|
|
2001-11-02 10:40:01 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageControlFrame::OnContentReset()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageControlFrame::GetClickedX(PRInt32* aX)
|
|
|
|
{
|
|
|
|
*aX = mLastClickPoint.x;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageControlFrame::GetClickedY(PRInt32* aY)
|
|
|
|
{
|
|
|
|
*aY = mLastClickPoint.y;
|
|
|
|
return NS_OK;
|
|
|
|
}
|