1998-11-10 02:30:16 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03: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
|
|
|
*
|
1999-11-06 06:40:37 +03: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.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-11-10 02:30:16 +03:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-11-10 02:30:16 +03:00
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.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-05-12 01:11:38 +04:00
|
|
|
#include "nsIAccessibilityService.h"
|
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,
|
1998-11-10 02:30:16 +03:00
|
|
|
public nsIFormControlFrame
|
|
|
|
{
|
|
|
|
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
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHOD GetFrameName(nsString& aResult) const {
|
|
|
|
return MakeFrameName("ImageControl", aResult);
|
|
|
|
}
|
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; }
|
|
|
|
|
|
|
|
PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
|
|
|
|
|
|
|
virtual PRInt32 GetMaxNumValues();
|
|
|
|
|
|
|
|
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
|
|
|
nsString* aValues, nsString* aNames);
|
|
|
|
|
|
|
|
NS_IMETHOD GetType(PRInt32* aType) const;
|
|
|
|
|
|
|
|
NS_IMETHOD GetName(nsString* aName);
|
|
|
|
|
1999-10-26 08:44:41 +04:00
|
|
|
virtual void Reset(nsIPresContext*) {};
|
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);
|
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
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIAccessible))) {
|
|
|
|
nsresult rv;
|
|
|
|
NS_WITH_SERVICE(nsIAccessibilityService, accService, "@mozilla.org/accessibilityService;1", &rv);
|
|
|
|
if (accService) {
|
|
|
|
nsIAccessible* acc = nsnull;
|
|
|
|
accService->CreateHTML4ButtonAccessible(NS_STATIC_CAST(nsIFrame*, this),&acc);
|
|
|
|
*aInstancePtr = acc;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1998-11-20 20:22:08 +03:00
|
|
|
return nsImageControlFrameSuper::QueryInterface(aIID, aInstancePtr);
|
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;
|
|
|
|
}
|
|
|
|
|
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);
|
1999-11-19 18:33:29 +03:00
|
|
|
view->SetContentTransparency(PR_TRUE);
|
|
|
|
viewMan->InsertChild(parView, view, 0);
|
1999-11-24 09:03:41 +03:00
|
|
|
SetView(aPresContext, view);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
|
|
|
const nsStyleColor* color = (const nsStyleColor*) mStyleContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
// set the opacity
|
|
|
|
viewMan->SetViewOpacity(view, color->mOpacity);
|
|
|
|
}
|
|
|
|
|
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);
|
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
|
|
|
|
nsImageControlFrame::GetName(nsString* aResult)
|
|
|
|
{
|
|
|
|
if (nsnull == aResult) {
|
|
|
|
return NS_OK;
|
|
|
|
} else {
|
|
|
|
return nsFormFrame::GetName(this, *aResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsImageControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
|
|
|
{
|
2000-06-29 06:02:43 +04:00
|
|
|
// Image control will only add it's value if it is clicked on.
|
|
|
|
// XXX Is this right?
|
1999-01-27 03:25:40 +03:00
|
|
|
return (this == (aSubmitter));
|
1998-11-10 02:30:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32
|
|
|
|
nsImageControlFrame::GetMaxNumValues()
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsImageControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
|
|
|
nsString* aValues, nsString* aNames)
|
|
|
|
{
|
1999-01-27 03:25:40 +03:00
|
|
|
if (aMaxNumValues <= 0) {
|
1998-11-10 02:30:16 +03:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
char buf[20];
|
|
|
|
aNumValues = 2;
|
|
|
|
|
|
|
|
sprintf(&buf[0], "%d", mLastClickPoint.x);
|
2000-04-16 01:18:29 +04:00
|
|
|
aValues[0].AssignWithConversion(&buf[0]);
|
1998-11-10 02:30:16 +03:00
|
|
|
|
|
|
|
sprintf(&buf[0], "%d", mLastClickPoint.y);
|
2000-04-16 01:18:29 +04:00
|
|
|
aValues[1].AssignWithConversion(&buf[0]);
|
1998-11-10 02:30:16 +03:00
|
|
|
|
1999-01-27 03:25:40 +03:00
|
|
|
nsAutoString name;
|
|
|
|
nsresult result = GetName(&name);
|
2000-08-04 02:05:44 +04:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == result && (name.Length() > 0)) {
|
1999-01-27 03:25:40 +03:00
|
|
|
aNames[0] = name;
|
2000-04-16 01:18:29 +04:00
|
|
|
aNames[0].AppendWithConversion(".x");
|
1999-01-27 03:25:40 +03:00
|
|
|
aNames[1] = name;
|
2000-04-16 01:18:29 +04:00
|
|
|
aNames[1].AppendWithConversion(".y");
|
1999-01-27 03:25:40 +03:00
|
|
|
} else {
|
|
|
|
// If the Image Element has no name, simply return x and y
|
|
|
|
// to Nav and IE compatability.
|
2000-04-16 01:18:29 +04:00
|
|
|
aNames[0].AssignWithConversion("x");
|
|
|
|
aNames[1].AssignWithConversion("y");
|
1999-01-27 03:25:40 +03:00
|
|
|
}
|
1998-11-10 02:30:16 +03:00
|
|
|
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
const nsStyleColor* styleColor;
|
|
|
|
GetStyleData(eStyleStruct_Color, (const nsStyleStruct*&)styleColor);
|
1999-06-25 05:17:18 +04:00
|
|
|
NS_ASSERTION(styleColor,"null color style struct");
|
|
|
|
|
|
|
|
if (styleColor) {
|
|
|
|
aCursor = styleColor->mCursor;
|
|
|
|
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
|
|
|
}
|
|
|
|
|