bug #5589. Selection area is now calculated using the inherited Reflow rather than using the calculations used for the native listbox control. Fixed varous other rendering bugs related to frame-based listboxes. bug #2797. GetSize is no longer needed in nsListControlFrame and it has been removed. Fixed frame-based combobox nsComboboxFrame so that will set it's label to the first option in the drop-down list if a default value has not been specified. Added optgroup style rules to ua.css. Opt groups now render, but there are remaining problems with selection. Modified nsButtonControlFrame::Reflow to call nsFormFrame::AddFormControlFrame. This fixes a bug where Gfx-rendered submit button's were not working. Refactored code in nsListControlFrame in preparation for supporting option groups. Refactored selection code into SingleSelect and MultiSelect paths. Removed unused code in nsListControlFrame. Removed mSelectedFrame member variable. It is no longer needed. Fixed nsListControlFrame::SetProperty so that it will toggle the selection in a single select listbox. git-svn-id: svn://10.0.0.236/trunk@30740 18797224-902f-48f8-a5cc-f745e15eee43
178 lines
7.0 KiB
C++
178 lines
7.0 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
*
|
|
* The contents of this file are subject to the Netscape Public License
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
* http://www.mozilla.org/NPL/
|
|
*
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
* for the specific language governing rights and limitations under the
|
|
* NPL.
|
|
*
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
* Communications Corporation. Portions created by Netscape are
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
* Reserved.
|
|
*/
|
|
|
|
#ifndef nsComboboxControlFrame_h___
|
|
#define nsComboboxControlFrame_h___
|
|
|
|
|
|
#include "nsHTMLContainerFrame.h"
|
|
#include "nsIFormControlFrame.h"
|
|
#include "nsIComboboxControlFrame.h"
|
|
|
|
|
|
class nsButtonControlFrame;
|
|
class nsTextControlFrame;
|
|
class nsFormFrame;
|
|
class nsIView;
|
|
class nsStyleContext;
|
|
class nsIHTMLContent;
|
|
class nsIListControlFrame;
|
|
|
|
class nsComboboxControlFrame : public nsHTMLContainerFrame,
|
|
public nsIFormControlFrame,
|
|
public nsIComboboxControlFrame
|
|
|
|
{
|
|
public:
|
|
nsComboboxControlFrame();
|
|
~nsComboboxControlFrame();
|
|
|
|
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
|
|
|
// nsIFrame
|
|
|
|
NS_IMETHOD Reflow(nsIPresContext& aCX,
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
const nsHTMLReflowState& aReflowState,
|
|
nsReflowStatus& aStatus);
|
|
|
|
NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext,
|
|
nsIStyleContext* aParentContext,
|
|
PRInt32 aParentChange,
|
|
nsStyleChangeList* aChangeList,
|
|
PRInt32* aLocalChange);
|
|
|
|
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
|
nsIRenderingContext& aRenderingContext,
|
|
const nsRect& aDirtyRect,
|
|
nsFramePaintLayer aWhichLayer);
|
|
|
|
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
|
|
nsGUIEvent* aEvent,
|
|
nsEventStatus& aEventStatus);
|
|
|
|
NS_IMETHOD GetFrameName(nsString& aResult) const;
|
|
|
|
|
|
virtual PRInt32 GetMaxNumValues();
|
|
|
|
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
|
nsString* aValues, nsString* aNames);
|
|
|
|
// nsIFormControLFrame
|
|
NS_IMETHOD SetProperty(nsIAtom* aName, const nsString& aValue);
|
|
NS_IMETHOD GetProperty(nsIAtom* aName, nsString& aValue);
|
|
virtual void PostCreateWidget(nsIPresContext* aPresContext,
|
|
nscoord& aWidth,
|
|
nscoord& aHeight);
|
|
|
|
//nsTextControlFrame* GetTextFrame() { return mTextFrame; }
|
|
|
|
//void SetTextFrame(nsTextControlFrame* aFrame) { mTextFrame = aFrame; }
|
|
|
|
//nsButtonControlFrame* GetBrowseFrame() { return mBrowseFrame; }
|
|
//void SetBrowseFrame(nsButtonControlFrame* aFrame) { mBrowseFrame = aFrame; }
|
|
void SetFocus(PRBool aOn, PRBool aRepaint);
|
|
virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
|
virtual void SetFormFrame(nsFormFrame* aFormFrame) { mFormFrame = aFormFrame; }
|
|
virtual void Reset();
|
|
NS_IMETHOD GetName(nsString* aName);
|
|
NS_IMETHOD GetType(PRInt32* aType) const;
|
|
|
|
NS_IMETHOD GetFont(nsIPresContext* aPresContext,
|
|
nsFont& aFont);
|
|
NS_IMETHOD GetFormContent(nsIContent*& aContent) const;
|
|
virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const;
|
|
virtual nscoord GetHorizontalBorderWidth(float aPixToTwip) const;
|
|
virtual nscoord GetVerticalInsidePadding(float aPixToTwip,
|
|
nscoord aInnerHeight) const;
|
|
virtual nscoord GetHorizontalInsidePadding(nsIPresContext& aPresContext,
|
|
float aPixToTwip,
|
|
nscoord aInnerWidth,
|
|
nscoord aCharWidth) const;
|
|
|
|
|
|
virtual nsresult RequiresWidget(PRBool &aRequiresWidget);
|
|
|
|
|
|
|
|
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame);
|
|
|
|
// A Static Helper Functions
|
|
|
|
// This refreshes a particular pseudo style content when a "ReResolveStyleContent" happens
|
|
static void RefreshStyleContext(nsIPresContext* aPresContext,
|
|
nsIAtom * aNewContentPseudo,
|
|
nsIStyleContext*& aCurrentStyle,
|
|
nsIContent * aContent,
|
|
nsIStyleContext* aParentStyle);
|
|
|
|
// nsIFormMouseListener
|
|
virtual void MouseClicked(nsIPresContext* aPresContext);
|
|
|
|
//nsIComboboxControlFrame
|
|
NS_IMETHOD SetDropDown(nsIFrame* aPlaceHolderFrame, nsIFrame* aDropDownFrame);
|
|
NS_IMETHOD SetDropDownStyleContexts(nsIStyleContext * aVisible, nsIStyleContext * aHidden);
|
|
NS_IMETHOD SetButtonStyleContexts(nsIStyleContext * aOut, nsIStyleContext * aPressed);
|
|
NS_IMETHOD ListWasSelected(nsIPresContext* aPresContext);
|
|
|
|
|
|
protected:
|
|
virtual void PaintComboboxControl(nsIPresContext& aPresContext,
|
|
nsIRenderingContext& aRenderingContext,
|
|
const nsRect& aDirtyRect,
|
|
nsFramePaintLayer aWhichLayer);
|
|
virtual PRIntn GetSkipSides() const;
|
|
void InitTextStr();
|
|
|
|
nsFormFrame* mFormFrame; // Parent Form Frame
|
|
nsIFrame * mPlaceHolderFrame;
|
|
nsIFrame * mListFrame; // Generic nsIFrame
|
|
nsIListControlFrame * mListControlFrame; // Specific ListControl Interface
|
|
nsRect mButtonRect; // The Arrow Button's Rect cached for Painting
|
|
|
|
// DropDown List Visibility Styles
|
|
nsIStyleContext * mVisibleStyleContext; // Style for the DropDown List to make it visible
|
|
nsIStyleContext * mHiddenStyleContext; // Style for the DropDown List to make it hidden
|
|
nsIStyleContext * mCurrentStyleContext; // The current Style state of the DropDown List
|
|
|
|
// Arrow Button Styles
|
|
nsIStyleContext * mBtnOutStyleContext; // Style when not pressed
|
|
nsIStyleContext * mBtnPressedStyleContext; // Style When Pressed
|
|
nsIStyleContext * mArrowStyle; // Arrows currrent style (for painting)
|
|
|
|
// Combobox Text Styles
|
|
nsIStyleContext * mBlockTextStyle; // Style when there is no selection and it doesn't have focus
|
|
nsIStyleContext * mBlockTextSelectedStyle; // Style when selected and it doesn't have focus
|
|
nsIStyleContext * mBlockTextSelectedFocusStyle; // Style when selected and it has focus
|
|
|
|
PRBool mFirstTime;
|
|
|
|
// State data members
|
|
nsString mTextStr;
|
|
PRBool mGotFocus;
|
|
|
|
private:
|
|
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
|
|
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
|
|
};
|
|
|
|
#endif
|
|
|
|
|