1998-11-09 23:30:16 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:40:37 +00: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-09 23:30:16 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00: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-09 23:30:16 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-11-09 23:30:16 +00:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 03:40:37 +00:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-11-09 23:30:16 +00:00
|
|
|
*/
|
1999-02-12 17:45:58 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1999-04-13 21:51:43 +00:00
|
|
|
#include "nsImageFrame.h"
|
1999-01-22 15:32:57 +00:00
|
|
|
#include "nsFormControlHelper.h"
|
1998-11-09 23:30:16 +00: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 19:34:39 +00:00
|
|
|
#include "nsFormControlFrame.h"
|
1998-11-09 23:30:16 +00:00
|
|
|
|
|
|
|
//Enumeration of possible mouse states used to detect mouse clicks
|
1999-01-22 15:32:57 +00:00
|
|
|
/*enum nsMouseState {
|
1998-11-09 23:30:16 +00:00
|
|
|
eMouseNone,
|
|
|
|
eMouseEnter,
|
1998-11-18 05:25:26 +00:00
|
|
|
eMouseExit,
|
1998-11-09 23:30:16 +00:00
|
|
|
eMouseDown,
|
1998-11-18 05:25:26 +00:00
|
|
|
eMouseUp
|
1998-11-09 23:30:16 +00:00
|
|
|
};
|
1999-01-22 15:32:57 +00:00
|
|
|
*/
|
1998-11-09 23:30:16 +00:00
|
|
|
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
|
|
|
|
1998-11-20 17:22:08 +00:00
|
|
|
#define nsImageControlFrameSuper nsImageFrame
|
|
|
|
class nsImageControlFrame : public nsImageControlFrameSuper,
|
1998-11-09 23:30:16 +00:00
|
|
|
public nsIFormControlFrame
|
|
|
|
{
|
|
|
|
public:
|
1998-12-03 06:31:43 +00:00
|
|
|
nsImageControlFrame();
|
1999-11-04 23:16:47 +00:00
|
|
|
~nsImageControlFrame();
|
1998-11-09 23:30:16 +00:00
|
|
|
|
2000-05-16 12:44:32 +00:00
|
|
|
NS_IMETHOD Destroy(nsIPresContext *aPresContext);
|
|
|
|
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
1998-11-09 23:30:16 +00:00
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_IMETHOD Init(nsIPresContext* aPresContext,
|
1999-11-19 15:33:29 +00:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow);
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
1999-04-27 00:06:03 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_IMETHOD HandleEvent(nsIPresContext* aPresContext,
|
1998-11-09 23:30:16 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus);
|
1998-11-09 23:30:16 +00:00
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHOD GetFrameName(nsString& aResult) const {
|
|
|
|
return MakeFrameName("ImageControl", aResult);
|
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1998-11-19 17:22:29 +00:00
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_IMETHOD GetCursor(nsIPresContext* aPresContext,
|
1999-04-27 22:54:15 +00:00
|
|
|
nsPoint& aPoint,
|
|
|
|
PRInt32& aCursor);
|
|
|
|
|
1998-11-09 23:30:16 +00: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 04:44:41 +00:00
|
|
|
virtual void Reset(nsIPresContext*) {};
|
1998-11-09 23:30:16 +00:00
|
|
|
|
|
|
|
void SetFocus(PRBool aOn, PRBool aRepaint);
|
1999-08-21 00:09:24 +00:00
|
|
|
void ScrollIntoView(nsIPresContext* aPresContext);
|
1999-01-22 15:32:57 +00:00
|
|
|
NS_IMETHOD GetFont(nsIPresContext* aPresContext,
|
2000-01-25 15:25:46 +00:00
|
|
|
const nsFont*& aFont);
|
1999-01-22 15:32:57 +00:00
|
|
|
|
|
|
|
NS_IMETHOD GetFormContent(nsIContent*& aContent) const;
|
1999-11-24 06:03:41 +00:00
|
|
|
virtual nscoord GetVerticalInsidePadding(nsIPresContext* aPresContext,
|
1999-09-30 11:30:04 +00:00
|
|
|
float aPixToTwip,
|
1999-01-22 15:32:57 +00:00
|
|
|
nscoord aInnerHeight) const;
|
1999-11-24 06:03:41 +00:00
|
|
|
virtual nscoord GetHorizontalInsidePadding(nsIPresContext* aPresContext,
|
1999-01-22 15:32:57 +00:00
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerWidth,
|
|
|
|
nscoord aCharWidth) const;
|
1999-03-06 19:43:13 +00:00
|
|
|
|
|
|
|
virtual nsresult RequiresWidget(PRBool &aRequiresWidget);
|
|
|
|
|
|
|
|
|
1999-01-25 22:16:27 +00:00
|
|
|
// nsIFormControlFrame
|
2000-08-23 17:27:06 +00: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-14 22:00:24 +00:00
|
|
|
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
|
1999-01-22 15:32:57 +00:00
|
|
|
|
1998-11-09 23:30:16 +00:00
|
|
|
protected:
|
1999-10-26 04:44:41 +00:00
|
|
|
void GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect); // XXX this implementation is a copy of nsHTMLButtonControlFrame
|
1998-11-09 23:30:16 +00: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 19:34:39 +00:00
|
|
|
|
1998-11-09 23:30:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1998-12-03 06:31:43 +00:00
|
|
|
nsImageControlFrame::nsImageControlFrame()
|
1998-11-09 23:30:16 +00:00
|
|
|
{
|
|
|
|
mLastMouseState = eMouseNone;
|
|
|
|
mLastClickPoint = nsPoint(0,0);
|
|
|
|
mPreviousCursor = eCursor_standard;
|
|
|
|
mTranslatedRect = nsRect(0,0,0,0);
|
1999-04-27 00:06:03 +00:00
|
|
|
mGotFocus = PR_FALSE;
|
|
|
|
mFormFrame = nsnull;
|
1998-11-09 23:30:16 +00:00
|
|
|
}
|
|
|
|
|
1999-11-04 23:16:47 +00:00
|
|
|
nsImageControlFrame::~nsImageControlFrame()
|
|
|
|
{
|
2000-05-16 12:44:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageControlFrame::Destroy(nsIPresContext *aPresContext)
|
|
|
|
{
|
|
|
|
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_FALSE);
|
2000-02-09 19:34:39 +00:00
|
|
|
|
1999-11-04 23:16:47 +00:00
|
|
|
if (mFormFrame) {
|
|
|
|
mFormFrame->RemoveFormControlFrame(*this);
|
|
|
|
mFormFrame = nsnull;
|
|
|
|
}
|
2000-05-16 12:44:32 +00:00
|
|
|
return nsImageControlFrameSuper::Destroy(aPresContext);
|
1999-11-04 23:16:47 +00:00
|
|
|
}
|
|
|
|
|
1998-11-09 23:30:16 +00:00
|
|
|
nsresult
|
1999-12-04 23:49:50 +00:00
|
|
|
NS_NewImageControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-11-09 23:30:16 +00:00
|
|
|
{
|
1999-05-11 22:03:29 +00:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-04 23:49:50 +00:00
|
|
|
nsImageControlFrame* it = new (aPresShell) nsImageControlFrame;
|
1999-05-11 22:03:29 +00:00
|
|
|
if (!it) {
|
1998-11-09 23:30:16 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-11 22:03:29 +00:00
|
|
|
*aNewFrame = it;
|
1998-11-09 23:30:16 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:50:15 +00:00
|
|
|
// Frames are not refcounted, no need to AddRef
|
|
|
|
NS_IMETHODIMP
|
1998-11-09 23:30:16 +00: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 20:44:42 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) {
|
1998-11-09 23:30:16 +00:00
|
|
|
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-11-20 17:22:08 +00:00
|
|
|
return nsImageControlFrameSuper::QueryInterface(aIID, aInstancePtr);
|
1998-11-09 23:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsImageControlFrame::AddRef(void)
|
|
|
|
{
|
|
|
|
NS_WARNING("not supported");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsImageControlFrame::Release(void)
|
|
|
|
{
|
|
|
|
NS_WARNING("not supported");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1999-11-19 15:33:29 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsImageControlFrame::Init(nsIPresContext* aPresContext,
|
1999-11-19 15:33:29 +00: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 06:03:41 +00:00
|
|
|
GetView(aPresContext, &view);
|
1999-11-19 15:33:29 +00:00
|
|
|
if (!view) {
|
2001-01-04 20:44:42 +00:00
|
|
|
nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, NS_GET_IID(nsIView), (void **)&view);
|
1999-11-19 15:33:29 +00:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
1999-11-24 06:03:41 +00:00
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
1999-11-19 15:33:29 +00:00
|
|
|
nsCOMPtr<nsIViewManager> viewMan;
|
|
|
|
presShell->GetViewManager(getter_AddRefs(viewMan));
|
|
|
|
|
|
|
|
nsIFrame* parWithView;
|
|
|
|
nsIView *parView;
|
1999-11-24 06:03:41 +00:00
|
|
|
GetParentWithView(aPresContext, &parWithView);
|
|
|
|
parWithView->GetView(aPresContext, &parView);
|
1999-11-19 15:33:29 +00: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 04:43:11 +00:00
|
|
|
result = view->Init(viewMan, boundBox, parView);
|
1999-11-19 15:33:29 +00:00
|
|
|
view->SetContentTransparency(PR_TRUE);
|
|
|
|
viewMan->InsertChild(parView, view, 0);
|
1999-11-24 06:03:41 +00:00
|
|
|
SetView(aPresContext, view);
|
1999-11-19 15:33:29 +00:00
|
|
|
|
|
|
|
const nsStyleColor* color = (const nsStyleColor*) mStyleContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
// set the opacity
|
|
|
|
viewMan->SetViewOpacity(view, color->mOpacity);
|
|
|
|
}
|
|
|
|
|
1999-11-30 05:38:15 +00:00
|
|
|
return rv;
|
1999-11-19 15:33:29 +00:00
|
|
|
}
|
|
|
|
|
1999-04-27 00:06:03 +00:00
|
|
|
NS_METHOD
|
1999-11-24 06:03:41 +00:00
|
|
|
nsImageControlFrame::Reflow(nsIPresContext* aPresContext,
|
1999-04-27 00:06:03 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2000-04-21 21:51:35 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsImageControlFrame", aReflowState.reason);
|
1999-04-27 00:06:03 +00:00
|
|
|
if (!mFormFrame && (eReflowReason_Initial == aReflowState.reason)) {
|
2000-02-09 19:34:39 +00:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE);
|
1999-04-27 00:06:03 +00:00
|
|
|
// add ourself as an nsIFormControlFrame
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFormFrame::AddFormControlFrame(aPresContext, *NS_STATIC_CAST(nsIFrame*, this));
|
1998-11-09 23:30:16 +00:00
|
|
|
}
|
1999-04-27 00:06:03 +00:00
|
|
|
return nsImageControlFrameSuper::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-11-09 23:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD
|
1999-11-24 06:03:41 +00:00
|
|
|
nsImageControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
1999-01-27 00:25:40 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-11-09 23:30:16 +00:00
|
|
|
{
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
2000-08-08 23:38:00 +00:00
|
|
|
|
|
|
|
// do we have user-input style?
|
|
|
|
const nsStyleUserInterface* uiStyle;
|
2000-08-09 00:52:02 +00:00
|
|
|
GetStyleData(eStyleStruct_UserInterface, (const nsStyleStruct *&)uiStyle);
|
2000-08-08 23:38:00 +00:00
|
|
|
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
|
|
|
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
|
|
|
|
1998-11-09 23:30:16 +00:00
|
|
|
if (nsFormFrame::GetDisabled(this)) { // XXX cache disabled
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
*aEventStatus = nsEventStatus_eIgnore;
|
1998-11-09 23:30:16 +00:00
|
|
|
|
1998-11-18 05:25:26 +00:00
|
|
|
switch (aEvent->message) {
|
2000-08-03 22:17:14 +00:00
|
|
|
case NS_MOUSE_LEFT_BUTTON_UP:
|
1999-01-27 00:25:40 +00:00
|
|
|
{
|
|
|
|
// Store click point for GetNamesValues
|
2000-08-03 22:17:14 +00:00
|
|
|
// Do this on MouseUp because the specs don't say and that's what IE does.
|
1999-02-12 17:45:58 +00:00
|
|
|
float t2p;
|
1999-11-24 06:03:41 +00:00
|
|
|
aPresContext->GetTwipsToPixels(&t2p);
|
1999-01-27 00:25:40 +00:00
|
|
|
mLastClickPoint.x = NSTwipsToIntPixels(aEvent->point.x, t2p);
|
|
|
|
mLastClickPoint.y = NSTwipsToIntPixels(aEvent->point.y, t2p);
|
|
|
|
|
1998-11-18 05:25:26 +00:00
|
|
|
mGotFocus = PR_TRUE;
|
1999-01-27 00:25:40 +00:00
|
|
|
break;
|
1998-11-09 23:30:16 +00:00
|
|
|
}
|
|
|
|
}
|
1998-11-20 17:22:08 +00:00
|
|
|
return nsImageControlFrameSuper::HandleEvent(aPresContext, aEvent,
|
|
|
|
aEventStatus);
|
1998-11-09 23:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsImageControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
|
|
|
{
|
|
|
|
mGotFocus = aOn;
|
1999-07-16 14:23:48 +00:00
|
|
|
/*if (aRepaint) {
|
1998-11-09 23:30:16 +00:00
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
|
|
|
Invalidate(rect, PR_TRUE);
|
1999-07-16 14:23:48 +00:00
|
|
|
}*/
|
1998-11-09 23:30:16 +00:00
|
|
|
}
|
|
|
|
|
1999-08-21 00:09:24 +00:00
|
|
|
void
|
|
|
|
nsImageControlFrame::ScrollIntoView(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
if (aPresContext) {
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
2000-09-08 05:53:28 +00:00
|
|
|
if (presShell) {
|
|
|
|
presShell->ScrollFrameIntoView(this,
|
2000-01-25 22:19:39 +00:00
|
|
|
NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE);
|
2000-09-08 05:53:28 +00:00
|
|
|
}
|
1999-08-21 00:09:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-09 23:30:16 +00:00
|
|
|
void
|
1999-10-26 04:44:41 +00:00
|
|
|
nsImageControlFrame::GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect)
|
1998-11-09 23:30:16 +00:00
|
|
|
{
|
|
|
|
nsIView* view;
|
|
|
|
nsPoint viewOffset(0,0);
|
1999-10-26 04:44:41 +00:00
|
|
|
GetOffsetFromView(aPresContext, viewOffset, &view);
|
1998-11-09 23:30:16 +00: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 02:02:43 +00:00
|
|
|
// Image control will only add it's value if it is clicked on.
|
|
|
|
// XXX Is this right?
|
1999-01-27 00:25:40 +00:00
|
|
|
return (this == (aSubmitter));
|
1998-11-09 23:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32
|
|
|
|
nsImageControlFrame::GetMaxNumValues()
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsImageControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
|
|
|
nsString* aValues, nsString* aNames)
|
|
|
|
{
|
1999-01-27 00:25:40 +00:00
|
|
|
if (aMaxNumValues <= 0) {
|
1998-11-09 23:30:16 +00:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
char buf[20];
|
|
|
|
aNumValues = 2;
|
|
|
|
|
|
|
|
sprintf(&buf[0], "%d", mLastClickPoint.x);
|
2000-04-15 21:18:29 +00:00
|
|
|
aValues[0].AssignWithConversion(&buf[0]);
|
1998-11-09 23:30:16 +00:00
|
|
|
|
|
|
|
sprintf(&buf[0], "%d", mLastClickPoint.y);
|
2000-04-15 21:18:29 +00:00
|
|
|
aValues[1].AssignWithConversion(&buf[0]);
|
1998-11-09 23:30:16 +00:00
|
|
|
|
1999-01-27 00:25:40 +00:00
|
|
|
nsAutoString name;
|
|
|
|
nsresult result = GetName(&name);
|
2000-08-03 22:05:44 +00:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == result && (name.Length() > 0)) {
|
1999-01-27 00:25:40 +00:00
|
|
|
aNames[0] = name;
|
2000-04-15 21:18:29 +00:00
|
|
|
aNames[0].AppendWithConversion(".x");
|
1999-01-27 00:25:40 +00:00
|
|
|
aNames[1] = name;
|
2000-04-15 21:18:29 +00:00
|
|
|
aNames[1].AppendWithConversion(".y");
|
1999-01-27 00:25:40 +00:00
|
|
|
} else {
|
|
|
|
// If the Image Element has no name, simply return x and y
|
|
|
|
// to Nav and IE compatability.
|
2000-04-15 21:18:29 +00:00
|
|
|
aNames[0].AssignWithConversion("x");
|
|
|
|
aNames[1].AssignWithConversion("y");
|
1999-01-27 00:25:40 +00:00
|
|
|
}
|
1998-11-09 23:30:16 +00:00
|
|
|
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
1999-04-27 22:54:15 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsImageControlFrame::GetCursor(nsIPresContext* aPresContext,
|
1999-04-27 22:54:15 +00:00
|
|
|
nsPoint& aPoint,
|
|
|
|
PRInt32& aCursor)
|
|
|
|
{
|
1999-06-25 00:19:44 +00: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 01:17:18 +00: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 00:19:44 +00:00
|
|
|
aCursor = NS_STYLE_CURSOR_POINTER;
|
|
|
|
}
|
1999-04-27 22:54:15 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-11-09 23:30:16 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
nsImageControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
|
|
|
{
|
2001-02-23 01:01:08 +00:00
|
|
|
if (nsnull != mFormFrame && !nsFormFrame::GetDisabled(this)) {
|
|
|
|
// Do Submit & DOM Processing
|
|
|
|
nsFormControlHelper::DoManualSubmitOrReset(aPresContext, nsnull,
|
|
|
|
mFormFrame, this, PR_TRUE, PR_TRUE);
|
1998-11-09 23:30:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-22 15:32:57 +00:00
|
|
|
NS_IMETHODIMP
|
2000-01-25 15:25:46 +00:00
|
|
|
nsImageControlFrame::GetFont(nsIPresContext* aPresContext,
|
|
|
|
const nsFont*& aFont)
|
1999-01-22 15:32:57 +00:00
|
|
|
{
|
2000-01-25 15:25:46 +00:00
|
|
|
return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont);
|
1999-01-22 15:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageControlFrame::GetFormContent(nsIContent*& aContent) const
|
|
|
|
{
|
1999-02-10 00:42:56 +00:00
|
|
|
nsIContent* content;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = GetContent(&content);
|
|
|
|
aContent = content;
|
|
|
|
return rv;
|
1999-01-22 15:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
1999-11-24 06:03:41 +00:00
|
|
|
nsImageControlFrame::GetVerticalInsidePadding(nsIPresContext* aPresContext,
|
1999-09-30 11:30:04 +00:00
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerHeight) const
|
1999-01-22 15:32:57 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
1999-11-24 06:03:41 +00:00
|
|
|
nsImageControlFrame::GetHorizontalInsidePadding(nsIPresContext* aPresContext,
|
1999-01-22 15:32:57 +00:00
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerWidth,
|
|
|
|
nscoord aCharWidth) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
1999-01-25 22:16:27 +00:00
|
|
|
|
1999-03-06 19:43:13 +00:00
|
|
|
nsresult nsImageControlFrame::RequiresWidget(PRBool& aRequiresWidget)
|
|
|
|
{
|
|
|
|
aRequiresWidget = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-26 04:44:41 +00:00
|
|
|
NS_IMETHODIMP nsImageControlFrame::SetProperty(nsIPresContext* aPresContext,
|
2000-08-23 17:27:06 +00:00
|
|
|
nsIAtom* aName,
|
|
|
|
const nsAReadableString& aValue)
|
1999-01-25 22:16:27 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP nsImageControlFrame::GetProperty(nsIAtom* aName,
|
|
|
|
nsAWritableString& aValue)
|
1999-01-25 22:16:27 +00:00
|
|
|
{
|
2000-08-23 17:27:06 +00:00
|
|
|
aValue.Truncate();
|
1999-01-25 22:16:27 +00:00
|
|
|
return NS_OK;
|
1999-01-27 00:25:40 +00: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-14 22:00:24 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsImageControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight)
|
|
|
|
{
|
|
|
|
// mSuggestedWidth = aWidth;
|
|
|
|
// mSuggestedHeight = aHeight;
|
|
|
|
return NS_OK;
|
1999-07-16 00:26:47 +00:00
|
|
|
}
|
|
|
|
|