File Removed.
git-svn-id: svn://10.0.0.236/trunk@44713 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
98e9ad76ea
commit
319d439c19
@ -1,460 +0,0 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
// pinkerton - this should be removed when the onload handler is called at
|
||||
// the correct time so that changes to content in there notify the frames.
|
||||
#define ONLOAD_CALLED_TOO_EARLY 1
|
||||
|
||||
#include "nsTriStateCheckboxFrame.h"
|
||||
|
||||
#include "nsFormControlHelper.h"
|
||||
#include "nsIContent.h"
|
||||
#include "prtypes.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsCSSRendering.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
||||
|
||||
//
|
||||
// GetDepressAtom [static]
|
||||
//
|
||||
// Use a lazily instantiated static initialization scheme to create an atom that
|
||||
// represents the attribute set when the button is depressed.
|
||||
//
|
||||
void
|
||||
nsTriStateCheckboxFrame :: GetDepressAtom ( nsCOMPtr<nsIAtom>* outAtom )
|
||||
{
|
||||
static nsCOMPtr<nsIAtom> depressAtom = dont_QueryInterface(NS_NewAtom("depress"));
|
||||
*outAtom = depressAtom;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// NS_NewTriStateCheckboxFrame
|
||||
//
|
||||
// Wrapper for creating a new tristate checkbox
|
||||
//
|
||||
nsresult
|
||||
NS_NewTriStateCheckboxFrame(nsIFrame** aNewFrame)
|
||||
{
|
||||
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
||||
if (nsnull == aNewFrame) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsTriStateCheckboxFrame* it = new nsTriStateCheckboxFrame;
|
||||
if ( !it )
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aNewFrame = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// nsTriStateCheckboxFrame cntr
|
||||
//
|
||||
nsTriStateCheckboxFrame::nsTriStateCheckboxFrame()
|
||||
: mMouseDownOnCheckbox(PR_FALSE), mHasOnceBeenInMixedState(PR_FALSE)
|
||||
{
|
||||
|
||||
} // cntr
|
||||
|
||||
|
||||
//
|
||||
// GetCurrentCheckState
|
||||
//
|
||||
// Looks in the DOM to find out what the value is. 0 is off, 1 is on, 2 is mixed.
|
||||
// This will default to "off" if no value is set in the DOM.
|
||||
//
|
||||
nsTriStateCheckboxFrame::CheckState
|
||||
nsTriStateCheckboxFrame::GetCurrentCheckState()
|
||||
{
|
||||
nsString value;
|
||||
CheckState outState = eOff;
|
||||
nsresult res = mContent->GetAttribute ( kNameSpaceID_None, nsHTMLAtoms::value, value );
|
||||
if ( res == NS_CONTENT_ATTR_HAS_VALUE )
|
||||
outState = StringToCheckState(value);
|
||||
|
||||
#if ONLOAD_CALLED_TOO_EARLY
|
||||
// this code really belongs in AttributeChanged, but is needed here because
|
||||
// setting the value in onload doesn't trip the AttributeChanged method on the frame
|
||||
if ( outState == eMixed )
|
||||
mHasOnceBeenInMixedState = PR_TRUE;
|
||||
#endif
|
||||
|
||||
return outState;
|
||||
} // GetCurrentCheckState
|
||||
|
||||
|
||||
//
|
||||
// SetCurrentCheckState
|
||||
//
|
||||
// Sets the value in the DOM. 0 is off, 1 is on, 2 is mixed.
|
||||
//
|
||||
void
|
||||
nsTriStateCheckboxFrame::SetCurrentCheckState(CheckState aState)
|
||||
{
|
||||
nsString valueAsString;
|
||||
CheckStateToString ( aState, valueAsString );
|
||||
mContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, valueAsString, PR_TRUE);
|
||||
|
||||
} // SetCurrentCheckState
|
||||
|
||||
|
||||
//
|
||||
// MouseClicked
|
||||
//
|
||||
// handle when the mouse is clicked in the box. If the check is on or off, toggle it.
|
||||
// If the state is mixed, then set it to off. You can't ever get back to mixed.
|
||||
//
|
||||
void
|
||||
nsTriStateCheckboxFrame::MouseClicked ( const nsIPresContext & aPresContext)
|
||||
{
|
||||
mMouseDownOnCheckbox = PR_FALSE;
|
||||
CheckState oldState = GetCurrentCheckState();
|
||||
CheckState newState = eOn;
|
||||
switch ( oldState ) {
|
||||
case eOn:
|
||||
newState = eOff;
|
||||
break;
|
||||
|
||||
case eMixed:
|
||||
newState = eOn;
|
||||
break;
|
||||
|
||||
case eOff:
|
||||
newState = mHasOnceBeenInMixedState ? eMixed: eOn;
|
||||
}
|
||||
SetCurrentCheckState(newState);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// PaintCheckBox
|
||||
//
|
||||
// Paint the checkbox depending on the mode
|
||||
//
|
||||
void
|
||||
nsTriStateCheckboxFrame::PaintCheckBox(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
aRenderingContext.PushState();
|
||||
|
||||
float p2t;
|
||||
aPresContext.GetScaledPixelsToTwips(&p2t);
|
||||
|
||||
// Get current checked state through content model.
|
||||
CheckState checked = GetCurrentCheckState();
|
||||
switch ( checked ) {
|
||||
case eOn:
|
||||
{
|
||||
const nsStyleColor* color = (const nsStyleColor*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
aRenderingContext.SetColor(color->mColor);
|
||||
nsFormControlHelper::PaintCheckMark(aRenderingContext, p2t, mRect.width, mRect.height);
|
||||
break;
|
||||
}
|
||||
|
||||
case eMixed:
|
||||
{
|
||||
const nsStyleColor* color = (const nsStyleColor*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
aRenderingContext.SetColor(color->mColor);
|
||||
PaintMixedMark(aRenderingContext, p2t, mRect.width, mRect.height);
|
||||
break;
|
||||
}
|
||||
|
||||
} // case of value of checkbox
|
||||
|
||||
PRBool clip;
|
||||
aRenderingContext.PopState(clip);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// PaintMixedMark
|
||||
//
|
||||
// Like nsFormControlHelper::PaintCheckMark(), but paints the horizontal "mixed"
|
||||
// bar inside the box.
|
||||
//
|
||||
void
|
||||
nsTriStateCheckboxFrame::PaintMixedMark(nsIRenderingContext& aRenderingContext,
|
||||
float aPixelsToTwips, PRUint32 aWidth, PRUint32 aHeight)
|
||||
{
|
||||
const PRUint32 checkpoints = 4;
|
||||
const PRUint32 checksize = 6; //This is value is determined by added 2 units to the end
|
||||
//of the 7X& pixel rectangle below to provide some white space
|
||||
//around the checkmark when it is rendered.
|
||||
|
||||
// Points come from the coordinates on a 7X7 pixels
|
||||
// box with 0,0 at the lower left.
|
||||
nscoord checkedPolygonDef[] = { 1,2, 5,2, 5,4, 1,4 };
|
||||
// Location of the center point of the checkmark
|
||||
const PRUint32 centerx = 3;
|
||||
const PRUint32 centery = 3;
|
||||
|
||||
nsPoint checkedPolygon[checkpoints];
|
||||
PRUint32 defIndex = 0;
|
||||
PRUint32 polyIndex = 0;
|
||||
|
||||
// Scale the checkmark based on the smallest dimension
|
||||
PRUint32 size = aWidth / checksize;
|
||||
if (aHeight < aWidth)
|
||||
size = aHeight / checksize;
|
||||
|
||||
// Center and offset each point in the polygon definition.
|
||||
for (defIndex = 0; defIndex < (checkpoints * 2); defIndex++) {
|
||||
checkedPolygon[polyIndex].x = nscoord((((checkedPolygonDef[defIndex]) - centerx) * (size)) + (aWidth / 2));
|
||||
defIndex++;
|
||||
checkedPolygon[polyIndex].y = nscoord((((checkedPolygonDef[defIndex]) - centery) * (size)) + (aHeight / 2));
|
||||
polyIndex++;
|
||||
}
|
||||
|
||||
aRenderingContext.FillPolygon(checkedPolygon, checkpoints);
|
||||
|
||||
} // PaintMixedMark
|
||||
|
||||
|
||||
//
|
||||
// Paint
|
||||
//
|
||||
// Overidden to handle drawing the checkmark in addition to everything else
|
||||
//
|
||||
NS_METHOD
|
||||
nsTriStateCheckboxFrame::Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer)
|
||||
{
|
||||
// Paint the background
|
||||
nsLeafFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
||||
// Paint the checkmark
|
||||
PaintCheckBox(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// HandleEvent
|
||||
//
|
||||
// Track the mouse and handle clicks
|
||||
//
|
||||
NS_METHOD
|
||||
nsTriStateCheckboxFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus)
|
||||
{
|
||||
if (aEventStatus == nsEventStatus_eConsumeNoDefault )
|
||||
return NS_OK;
|
||||
|
||||
nsresult retVal = NS_OK;
|
||||
switch (aEvent->message) {
|
||||
case NS_KEY_PRESS:
|
||||
if (NS_KEY_EVENT == aEvent->eventStructType) {
|
||||
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
|
||||
if (NS_VK_SPACE == keyEvent->keyCode || NS_VK_RETURN == keyEvent->keyCode) {
|
||||
MouseClicked(aPresContext);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
{
|
||||
// set "depressed" state so CSS redraws us
|
||||
DisplayDepressed();
|
||||
mMouseDownOnCheckbox = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case NS_MOUSE_EXIT:
|
||||
{
|
||||
// clear "depressed" state so css redraws us
|
||||
if ( mMouseDownOnCheckbox )
|
||||
DisplayNormal();
|
||||
mMouseDownOnCheckbox = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
case NS_MOUSE_ENTER:
|
||||
{
|
||||
// if the mouse is down, reset the depressed attribute so CSS redraws.
|
||||
if ( mMouseDownOnCheckbox )
|
||||
DisplayDepressed();
|
||||
break;
|
||||
}
|
||||
|
||||
case NS_MOUSE_LEFT_CLICK:
|
||||
case NS_MOUSE_LEFT_BUTTON_UP:
|
||||
if ( mMouseDownOnCheckbox )
|
||||
MouseClicked(aPresContext);
|
||||
DisplayNormal();
|
||||
break;
|
||||
|
||||
default:
|
||||
retVal = nsLeafFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
||||
}
|
||||
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault; //XXX ???
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// DisplayDepressed
|
||||
//
|
||||
// Tickle the right attributes so that CSS draws us in a depressed state. Used
|
||||
// when doing mouse tracking
|
||||
//
|
||||
void
|
||||
nsTriStateCheckboxFrame :: DisplayDepressed ( )
|
||||
{
|
||||
nsCOMPtr<nsIAtom> depressAtom;
|
||||
GetDepressAtom(&depressAtom);
|
||||
mContent->SetAttribute(kNameSpaceID_None, depressAtom, NS_STRING_TRUE, PR_TRUE);
|
||||
|
||||
} // DisplayDepressed
|
||||
|
||||
|
||||
//
|
||||
// DisplayNormal
|
||||
//
|
||||
// Tickle the right attributes so that CSS draws us in a normal state. Used
|
||||
// when doing mouse tracking to reset us when the mouse leaves or at the end.
|
||||
//
|
||||
void
|
||||
nsTriStateCheckboxFrame :: DisplayNormal ( )
|
||||
{
|
||||
nsCOMPtr<nsIAtom> depressAtom;
|
||||
GetDepressAtom(&depressAtom);
|
||||
mContent->UnsetAttribute(kNameSpaceID_None, depressAtom, PR_TRUE);
|
||||
|
||||
} // DisplayNormal
|
||||
|
||||
|
||||
//
|
||||
// StringToCheckState
|
||||
//
|
||||
// Converts from a string to a CheckState enum
|
||||
//
|
||||
nsTriStateCheckboxFrame::CheckState
|
||||
nsTriStateCheckboxFrame :: StringToCheckState ( const nsString & aStateAsString )
|
||||
{
|
||||
if ( aStateAsString == NS_STRING_TRUE )
|
||||
return eOn;
|
||||
else if ( aStateAsString == NS_STRING_FALSE )
|
||||
return eOff;
|
||||
|
||||
// not true and not false means mixed
|
||||
return eMixed;
|
||||
|
||||
} // StringToCheckState
|
||||
|
||||
|
||||
//
|
||||
// CheckStateToString
|
||||
//
|
||||
// Converts from a CheckState to a string
|
||||
//
|
||||
void
|
||||
nsTriStateCheckboxFrame :: CheckStateToString ( CheckState inState, nsString& outStateAsString )
|
||||
{
|
||||
switch ( inState ) {
|
||||
case eOn:
|
||||
outStateAsString = NS_STRING_TRUE;
|
||||
break;
|
||||
|
||||
case eOff:
|
||||
outStateAsString = NS_STRING_FALSE;
|
||||
break;
|
||||
|
||||
case eMixed:
|
||||
outStateAsString = "2";
|
||||
break;
|
||||
}
|
||||
} // CheckStateToString
|
||||
|
||||
|
||||
void
|
||||
nsTriStateCheckboxFrame :: GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aDesiredLayoutSize)
|
||||
{
|
||||
nsSize styleSize;
|
||||
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedWidth) {
|
||||
styleSize.width = aReflowState.mComputedWidth;
|
||||
}
|
||||
else {
|
||||
styleSize.width = CSS_NOTSET;
|
||||
}
|
||||
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) {
|
||||
styleSize.height = aReflowState.mComputedHeight;
|
||||
}
|
||||
else {
|
||||
styleSize.height = CSS_NOTSET;
|
||||
}
|
||||
|
||||
// subclasses should always override this method, but if not and no css, make it small
|
||||
aDesiredLayoutSize.width = (styleSize.width > CSS_NOTSET) ? styleSize.width : 200;
|
||||
aDesiredLayoutSize.height = (styleSize.height > CSS_NOTSET) ? styleSize.height : 200;
|
||||
aDesiredLayoutSize.ascent = aDesiredLayoutSize.height;
|
||||
aDesiredLayoutSize.descent = 0;
|
||||
if (aDesiredLayoutSize.maxElementSize) {
|
||||
aDesiredLayoutSize.maxElementSize->width = aDesiredLayoutSize.width;
|
||||
aDesiredLayoutSize.maxElementSize->height = aDesiredLayoutSize.height;
|
||||
}
|
||||
|
||||
} // GetDesiredSize
|
||||
|
||||
|
||||
//
|
||||
// AttributeChanged
|
||||
//
|
||||
// We only want to show the mixed state if the button has ever been in that
|
||||
// state in the past. That means that we need to trap all changes to the "value"
|
||||
// attribute and see if we ever get set to "mixed"
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsTriStateCheckboxFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
#if !ONLOAD_CALLED_TOO_EARLY
|
||||
// onload handlers are called to early, so we have to do this code
|
||||
// elsewhere. It really belongs HERE.
|
||||
if ( aAttribute == nsHTMLAtoms::value ) {
|
||||
CheckState newState = GetCurrentCheckState();
|
||||
if ( newState == eMixed ) {
|
||||
mHasOnceBeenInMixedState = PR_TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// process normally regardless.
|
||||
result = nsLeafFrame::AttributeChanged(aPresContext, aChild, aAttribute, aHint);
|
||||
|
||||
return result;
|
||||
|
||||
} // AttributeChanged
|
||||
@ -1,126 +0,0 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
//
|
||||
// nsTriStateCheckboxFrame
|
||||
//
|
||||
// A sibling of a checkbox, but with an extra state, mixed, that represents
|
||||
// something in between on and off.
|
||||
//
|
||||
// An example will explain it best. Say you
|
||||
// select some text, part of which is bold, and go to a dialog that lets you
|
||||
// customize the styles of that text. The checkboxes for each style should
|
||||
// represent the current state of the text, but what value should the "Bold"
|
||||
// checkbox have? All the text isn't bold, so it shouldn't be on, but some
|
||||
// if it is, so you want to indicate that to the user. Hence, a 3rd state.
|
||||
//
|
||||
// Clicking the control when it is mixed would uncheck the control, as if
|
||||
// it is totally off. In the above example, the entire selection would be
|
||||
// unbolded. Clicking it again would check the control and bold the entire
|
||||
// selection. Clicking a third time would get back into the mixed state.
|
||||
//
|
||||
// Note that the user can only get into the mixed state when the control
|
||||
// has been in that state at some previous time during its lifetime. That
|
||||
// means that it must be explicitly set to "mixed" at some point in order
|
||||
// for the user to get there by clicking. This is done by setting the "value"
|
||||
// attribute to "2". If this is not done, this checkbox behaves just like
|
||||
// the normal checkbox.
|
||||
//
|
||||
// The only DOM APIs that this checkbox supports are the generic XML DOM APIs.
|
||||
// This is mainly a result of the fact that our content node is a XUL content
|
||||
// node, and we (read: hyatt) would have to go off and implement these
|
||||
// extra HTMLInputElement APIs to match the API set of the normal checkbox.
|
||||
// We're not going to do that, so you're just going to have to live with
|
||||
// getting and setting the "value" attribute ;)
|
||||
//
|
||||
|
||||
#ifndef nsTriStateCheckboxFrame_h__
|
||||
#define nsTriStateCheckboxFrame_h__
|
||||
|
||||
|
||||
#include "nsLeafFrame.h"
|
||||
#include "prtypes.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsIPresContext;
|
||||
class nsString;
|
||||
class nsIContent;
|
||||
|
||||
|
||||
nsresult NS_NewTriStateCheckboxFrame(nsIFrame** aResult) ;
|
||||
|
||||
|
||||
class nsTriStateCheckboxFrame : public nsLeafFrame
|
||||
{
|
||||
public:
|
||||
nsTriStateCheckboxFrame();
|
||||
|
||||
// nsIFrame overrides
|
||||
NS_IMETHOD GetFrameName(nsString& aResult) const {
|
||||
return MakeFrameName("TriStateCheckboxFrame", aResult);
|
||||
}
|
||||
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aHint) ;
|
||||
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aDesiredSize) ;
|
||||
|
||||
enum CheckState { eOff, eOn, eMixed } ;
|
||||
|
||||
CheckState GetCurrentCheckState() ;
|
||||
void SetCurrentCheckState(CheckState aState) ;
|
||||
|
||||
virtual void MouseClicked(const nsIPresContext & aPresContext);
|
||||
|
||||
virtual void PaintCheckBox(nsIPresContext& aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
virtual void PaintMixedMark(nsIRenderingContext& aRenderingContext,
|
||||
float aPixelsToTwips, PRUint32 aWidth, PRUint32 aHeight) ;
|
||||
|
||||
void DisplayDepressed ( ) ;
|
||||
void DisplayNormal ( ) ;
|
||||
|
||||
// utility routine for converting from DOM values to internal enum
|
||||
void CheckStateToString ( CheckState inState, nsString& outStateAsString ) ;
|
||||
CheckState StringToCheckState ( const nsString & aStateAsString ) ;
|
||||
|
||||
PRBool mMouseDownOnCheckbox; // for tracking clicks
|
||||
PRBool mHasOnceBeenInMixedState; // since we only want to show the
|
||||
|
||||
// atom for the "depress" attribute. We will have a CSS rule that
|
||||
// when this is set, draws the button depressed.
|
||||
static void GetDepressAtom(nsCOMPtr<nsIAtom>* outAtom) ;
|
||||
|
||||
}; // class nsTriStateCheckboxFrame
|
||||
|
||||
#endif
|
||||
@ -1,41 +0,0 @@
|
||||
/* -*- 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 nsIContentConnector_h___
|
||||
#define nsIContentConnector_h___
|
||||
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
class nsIContent;
|
||||
|
||||
// {FC41CD61-796E-11d2-BF86-00105A1B0627}
|
||||
#define NS_ICONTENTCONNECTOR_IID \
|
||||
{ 0xfc41cd61, 0x796e, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
class nsIContentConnector : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICONTENTCONNECTOR_IID)
|
||||
|
||||
NS_IMETHOD SetContentRoot(nsIContent* pContent) = 0;
|
||||
|
||||
NS_IMETHOD_(nsEventStatus) HandleEvent(nsGUIEvent *aEvent) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIContentConnector_h___ */
|
||||
|
||||
@ -1,85 +0,0 @@
|
||||
/* -*- 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 nsIDragService_h__
|
||||
#define nsIDragService_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIDragSession;
|
||||
class nsITransferable;
|
||||
class nsISupportsArray;
|
||||
class nsIRegion;
|
||||
|
||||
// {8B5314BB-DB01-11d2-96CE-0060B0FB9956}
|
||||
#define NS_IDRAGSERVICE_IID \
|
||||
{ 0x8b5314bb, 0xdb01, 0x11d2, { 0x96, 0xce, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } }
|
||||
|
||||
|
||||
class nsIDragService : public nsISupports {
|
||||
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDRAGSERVICE_IID)
|
||||
|
||||
enum {
|
||||
DRAGDROP_ACTION_NONE = 0x0000,
|
||||
DRAGDROP_ACTION_COPY = 0x0001,
|
||||
DRAGDROP_ACTION_MOVE = 0x0002,
|
||||
DRAGDROP_ACTION_LINK = 0x0004
|
||||
};
|
||||
|
||||
/**
|
||||
* Starts a modal drag session with an array of transaferables
|
||||
*
|
||||
* @param anArrayTransferables - an array of transferables to be dragged
|
||||
* @param aRegion - a region containing rectangles for cursor feedback,
|
||||
* in window coordinates.
|
||||
*/
|
||||
NS_IMETHOD InvokeDragSession (nsISupportsArray * anArrayTransferables, nsIRegion * aRegion, PRUint32 aActionType) = 0;
|
||||
|
||||
/**
|
||||
* Returns the current Drag Session
|
||||
*
|
||||
* @param aSession the current drag session
|
||||
*/
|
||||
NS_IMETHOD GetCurrentSession (nsIDragSession ** aSession) = 0;
|
||||
|
||||
/**
|
||||
* Tells the Drag Service to start a drag session. This is called when
|
||||
* an external drag occurs
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD StartDragSession () = 0;
|
||||
|
||||
/**
|
||||
* Tells the Drag Service to end a drag session. This is called when
|
||||
* an external drag occurs
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD EndDragSession () = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
// NS_IMETHOD HasDragStarted ( nsIDOMEvent* inInitialMouseDown, nsIDOMEvent* inMostRecentMouseEvent,
|
||||
// PRBool* outHasStarted ) ;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,116 +0,0 @@
|
||||
/* -*- 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 nsIDragSession_h__
|
||||
#define nsIDragSession_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsITransferable;
|
||||
struct nsSize;
|
||||
|
||||
// {CBA22C53-FCCE-11d2-96D4-0060B0FB9956}
|
||||
|
||||
#define NS_IDRAGSESSION_IID \
|
||||
{ 0xcba22c53, 0xfcce, 0x11d2, { 0x96, 0xd4, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } };
|
||||
|
||||
class nsIDragSession : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDRAGSESSION_IID)
|
||||
|
||||
/**
|
||||
* Set the current state of the drag whether it can be dropped or not.
|
||||
* usually the target "frame" sets this so the native system can render the correct feedback
|
||||
*
|
||||
* @param aCanDrop indicates whether it can be dropped here
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetCanDrop (PRBool aCanDrop) = 0;
|
||||
|
||||
/**
|
||||
* Retrieves whether the drag can be dropped at this location
|
||||
*
|
||||
* @param aCanDrop indicates whether it can be dropped here
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetCanDrop (PRBool * aCanDrop) = 0;
|
||||
|
||||
/**
|
||||
* Sets the action (copy, move, link, et.c) for the current drag
|
||||
*
|
||||
* @param anAction the current action
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetDragAction (PRUint32 anAction) = 0;
|
||||
|
||||
/**
|
||||
* Gets the action (copy, move, link, et.c) for the current drag
|
||||
*
|
||||
* @param anAction the current action
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetDragAction (PRUint32 * anAction) = 0;
|
||||
|
||||
/**
|
||||
* Sets the current width and height if the drag target area.
|
||||
* It will contain the current size of the Frame that the drag is currently in
|
||||
*
|
||||
* @param aDragTargetSize contains width/height of the current target
|
||||
*/
|
||||
|
||||
NS_IMETHOD SetTargetSize (nsSize aDragTargetSize) = 0;
|
||||
|
||||
/**
|
||||
* Gets the current width and height if the drag target area.
|
||||
* It will contain the current size of the Frame that the drag is currently in
|
||||
*
|
||||
* @param aCanDrop indicates whether it can be dropped here
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetTargetSize (nsSize * aDragTargetSize) = 0;
|
||||
|
||||
/**
|
||||
* Get data from a Drag->Drop
|
||||
*
|
||||
* @param aTransferable the transferable for the data to be put into
|
||||
* @param aItemIndex which of multiple drag items, zero-based
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetData (nsITransferable * aTransferable, PRUint32 aItemIndex) = 0;
|
||||
|
||||
/**
|
||||
* Get the number items that were dropped
|
||||
*
|
||||
* @param aNumItems the number of dropped items
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetNumDropItems (PRUint32 * aNumItems) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Check to set if ant of the native data on the clipboard matches this data flavor
|
||||
*
|
||||
* @result NS_OK if if the data flavor is supported and, NS_ERROR_FAILURE is it is not
|
||||
*/
|
||||
|
||||
NS_IMETHOD IsDataFlavorSupported(nsString * aDataFlavor) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,54 +0,0 @@
|
||||
/* -*- 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 nsIFileListTransferable_h__
|
||||
#define nsIFileListTransferable_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsVoidArray;
|
||||
|
||||
#define FileListMime "filelist"
|
||||
|
||||
// {E93E73B1-0197-11d3-96D4-0060B0FB9956}
|
||||
#define NS_IFILELISTTRANSFERABLE_IID \
|
||||
{ 0xe93e73b1, 0x197, 0x11d3, { 0x96, 0xd4, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } }
|
||||
|
||||
class nsIFileListTransferable : public nsISupports {
|
||||
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFILELISTTRANSFERABLE_IID)
|
||||
|
||||
/**
|
||||
* Copies the list of nsFileSpecs items from aFileList to the internal data member
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetFileList(nsVoidArray * aFileList) = 0;
|
||||
|
||||
/**
|
||||
* Copies the list of nsFileSpecs items from the internal data member to the
|
||||
* aFileList nsVoidArray
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetFileList(nsVoidArray * aFileList) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,78 +0,0 @@
|
||||
/* -*- 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 nsIFormatConverter_h__
|
||||
#define nsIFormatConverter_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsVoidArray;
|
||||
|
||||
// {948A0023-E3A7-11d2-96CF-0060B0FB9956}
|
||||
#define NS_IFORMATCONVERTER_IID \
|
||||
{ 0x948a0023, 0xe3a7, 0x11d2, { 0x96, 0xcf, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } }
|
||||
|
||||
class nsIFormatConverter : public nsISupports {
|
||||
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFORMATCONVERTER_IID)
|
||||
|
||||
/**
|
||||
* Get the list of the "input" data flavors, in otherwords, the flavors
|
||||
* that this converter can convert "from" (the incoming data to the converter)
|
||||
*
|
||||
* @param aDataFlavorList fills list with supported flavors
|
||||
*/
|
||||
NS_IMETHOD GetInputDataFlavors(nsVoidArray ** aDataFlavorList) = 0;
|
||||
|
||||
/**
|
||||
* Get the list of the "output" data flavors, in otherwords, the flavors
|
||||
* that this converter can convert "to" (the outgoing data of the converter)
|
||||
*
|
||||
* @param aDataFlavorList fills list with supported flavors
|
||||
*/
|
||||
NS_IMETHOD GetOutputDataFlavors(nsVoidArray ** aDataFlavorList) = 0;
|
||||
|
||||
/**
|
||||
* Determines whether a converion from one flavor to another is supported
|
||||
*
|
||||
* @param aFromFormatConverter flavor to convert from
|
||||
* @param aFromFormatConverter flavor to convert to
|
||||
* @returns returns NS_OK if it can be converted
|
||||
*/
|
||||
NS_IMETHOD CanConvert(nsString * aFromDataFlavor, nsString * aToDataFlavor) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether a converion from one flavor to another
|
||||
*
|
||||
* @param aFromFormatConverter flavor to convert from
|
||||
* @param aFromFormatConverter flavor to convert to (destination own the memory)
|
||||
* @returns returns NS_OK if it was converted
|
||||
*/
|
||||
NS_IMETHOD Convert(nsString * aFromDataFlavor, void * aFromData, PRUint32 aDataLen,
|
||||
nsString * aToDataFlavor, void ** aToData, PRUint32 * aDataToLen) = 0;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,146 +0,0 @@
|
||||
/* -*- 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 nsITransferable_h__
|
||||
#define nsITransferable_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsString;
|
||||
class nsVoidArray;
|
||||
class nsIFormatConverter;
|
||||
|
||||
#define kTextMime "text/plain"
|
||||
#define kXIFMime "text/xif"
|
||||
#define kUnicodeMime "text/unicode"
|
||||
#define kHTMLMime "text/html"
|
||||
#define kAOLMailMime "AOLMAIL"
|
||||
#define kPNGImageMime "image/png"
|
||||
#define kJPEGImageMime "image/jpg"
|
||||
#define kGIFImageMime "image/gif"
|
||||
#define kDropFilesMime "text/dropfiles"
|
||||
|
||||
|
||||
// {8B5314BC-DB01-11d2-96CE-0060B0FB9956}
|
||||
#define NS_ITRANSFERABLE_IID \
|
||||
{ 0x8b5314bc, 0xdb01, 0x11d2, { 0x96, 0xce, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } }
|
||||
|
||||
class nsITransferable : public nsISupports {
|
||||
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITRANSFERABLE_IID)
|
||||
|
||||
/**
|
||||
* Computes a list of flavors that the transferable can export, either through
|
||||
* intrinsic knowledge or output data converters.
|
||||
*
|
||||
* @param aDataFlavorList fills list with supported flavors. This is a copy of
|
||||
* the internal list, so it may be edited w/out affecting the transferable.
|
||||
*/
|
||||
NS_IMETHOD FlavorsTransferableCanExport ( nsVoidArray** outFlavorList ) = 0;
|
||||
|
||||
/**
|
||||
* Get the list of data flavors that this transferable supports (w/out conversion).
|
||||
* (NOTE: We're not sure how useful this is in the presence of the above two methods,
|
||||
* but figured we'd keep it around just in case).
|
||||
*
|
||||
* @param aDataFlavorList fills list with supported flavors. This is a copy of
|
||||
* the internal list, so it may be edited w/out affecting the transferable.
|
||||
*/
|
||||
NS_IMETHOD GetTransferDataFlavors(nsVoidArray ** aDataFlavorList) = 0;
|
||||
|
||||
/**
|
||||
* Given a flavor retrieve the data.
|
||||
*
|
||||
* @param aFlavor (in parameter) the flavor of data to retrieve
|
||||
* @param aData the data. This is NOT a copy, so the caller MUST NOT DELETE it.
|
||||
* @param aDataLen the length of the data
|
||||
*/
|
||||
NS_IMETHOD GetTransferData(nsString * aFlavor, void ** aData, PRUint32 * aDataLen) = 0;
|
||||
|
||||
/**
|
||||
* Given a flavor retrieve the data.
|
||||
*
|
||||
* @param aFlavor (out parameter) the flavor of data that was retrieved
|
||||
* @param aData the data. This is NOT a copy, so the caller MUST NOT DELETE it.
|
||||
* @param aDataLen the length of the data
|
||||
*/
|
||||
NS_IMETHOD GetAnyTransferData(nsString * aFlavor, void ** aData, PRUint32 * aDataLen) = 0;
|
||||
|
||||
/**
|
||||
* Returns PR_TRUE if the data is large.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD_(PRBool) IsLargeDataSet() = 0;
|
||||
|
||||
///////////////////////////////
|
||||
// Setter part of interface
|
||||
///////////////////////////////
|
||||
|
||||
/**
|
||||
* Computes a list of flavors that the transferable can accept into it, either through
|
||||
* intrinsic knowledge or input data converters.
|
||||
*
|
||||
* @param outFlavorList fills list with supported flavors. This is a copy of
|
||||
* the internal list, so it may be edited w/out affecting the transferable.
|
||||
*/
|
||||
NS_IMETHOD FlavorsTransferableCanImport ( nsVoidArray** outFlavorList ) = 0;
|
||||
|
||||
/**
|
||||
* Gets the data from the transferable as a specified DataFlavor. The transferable still
|
||||
* owns the data, so the caller must NOT delete it.
|
||||
*
|
||||
* @param aFlavor the flavor of data that is being set
|
||||
* @param aData the data
|
||||
* @param aDataLen the length of the data
|
||||
*/
|
||||
NS_IMETHOD SetTransferData(nsString * aFlavor, void * aData, PRUint32 aDataLen) = 0;
|
||||
|
||||
/**
|
||||
* Add the data flavor, indicating that this transferable
|
||||
* can receive this type of flavor
|
||||
*
|
||||
* @param aDataFlavor a new data flavor to handle
|
||||
*/
|
||||
NS_IMETHOD AddDataFlavor(nsString * aDataFlavor) = 0;
|
||||
|
||||
/**
|
||||
* Removes the data flavor by MIME name (NOT by pointer addr)
|
||||
*
|
||||
* @param aDataFlavor a data flavor to remove
|
||||
*/
|
||||
NS_IMETHOD RemoveDataFlavor(nsString * aDataFlavor) = 0;
|
||||
|
||||
/**
|
||||
* Sets the converter for this transferable
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetConverter(nsIFormatConverter * aConverter) = 0;
|
||||
|
||||
/**
|
||||
* Gets the converter for this transferable
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetConverter(nsIFormatConverter ** aConverter) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,267 +0,0 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsFileListTransferable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
static NS_DEFINE_IID(kCDataFlavorCID, NS_DATAFLAVOR_CID);
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsFileListTransferable)
|
||||
NS_IMPL_RELEASE(nsFileListTransferable)
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// nsFileListTransferable constructor
|
||||
//-------------------------------------------------------------------------
|
||||
nsFileListTransferable::nsFileListTransferable()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mFileList = new nsVoidArray();
|
||||
|
||||
mFileListDataFlavor = kDropFilesMime;
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// nsFileListTransferable destructor
|
||||
//-------------------------------------------------------------------------
|
||||
nsFileListTransferable::~nsFileListTransferable()
|
||||
{
|
||||
ClearFileList();
|
||||
delete mFileList;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// @param aIID The name of the class implementing the method
|
||||
// @param _classiiddef The name of the #define symbol that defines the IID
|
||||
// for the class (e.g. NS_ISUPPORTS_IID)
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsresult nsFileListTransferable::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsresult rv = NS_NOINTERFACE;
|
||||
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsITransferable>::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsITransferable*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsIFileListTransferable>::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsIFileListTransferable*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsFileListTransferable::GetTransferDataFlavors(nsVoidArray ** aDataFlavorList)
|
||||
{
|
||||
nsVoidArray * array = new nsVoidArray();
|
||||
if (nsnull != array) {
|
||||
array->AppendElement(new nsString(mFileListDataFlavor)); // this addref's for us
|
||||
*aDataFlavorList = array;
|
||||
} else {
|
||||
aDataFlavorList = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// The transferable owns the data (memory) and only gives the aData a copy of the pointer address to it.
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsFileListTransferable::GetTransferData(nsString * aDataFlavor, void ** aData, PRUint32 * aDataLen)
|
||||
{
|
||||
if (nsnull != aDataFlavor) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (nsnull != mFileList && mFileListDataFlavor.Equals(*aDataFlavor)) {
|
||||
*aData = mFileList;
|
||||
*aDataLen = mFileList->Count();
|
||||
return NS_OK;
|
||||
} else {
|
||||
*aData = nsnull;
|
||||
aDataLen = 0;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFileListTransferable::GetAnyTransferData(nsString * aDataFlavor, void ** aData, PRUint32 * aDataLen)
|
||||
{
|
||||
if (nsnull != aDataFlavor) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aData = mFileList;
|
||||
*aDataLen = mFileList->Count();
|
||||
*aDataFlavor = mFileListDataFlavor;
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
//---------------------------------------------------
|
||||
// remove all the items and delete them
|
||||
//---------------------------------------------------
|
||||
void nsFileListTransferable::ClearFileList()
|
||||
{
|
||||
if (nsnull != mFileList) {
|
||||
PRInt32 ii;
|
||||
for (ii=0;ii<mFileList->Count();ii++) {
|
||||
nsFileSpec * fileSpec = (nsFileSpec *)mFileList->ElementAt(ii);
|
||||
if (fileSpec) {
|
||||
delete[] fileSpec;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
// The transferable now owns the data (the memory pointing to it)
|
||||
//---------------------------------------------------
|
||||
NS_IMETHODIMP nsFileListTransferable::SetTransferData(nsString * aDataFlavor, void * aData, PRUint32 aDataLen)
|
||||
{
|
||||
if (aData == nsnull && mFileListDataFlavor.Equals(*aDataFlavor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
ClearFileList();
|
||||
|
||||
mFileList = (nsVoidArray *)aData;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
NS_IMETHODIMP_(PRBool) nsFileListTransferable::IsLargeDataSet()
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
// Copy List
|
||||
//---------------------------------------------------
|
||||
NS_IMETHODIMP nsFileListTransferable::CopyFileList(nsVoidArray * aFromFileList,
|
||||
nsVoidArray * aToFileList)
|
||||
{
|
||||
PRInt32 i;
|
||||
for (i=0;i<aFromFileList->Count();i++) {
|
||||
nsFileSpec * fs = (nsFileSpec *)aFromFileList->ElementAt(i);
|
||||
nsFileSpec * newFS = new nsFileSpec(*fs);
|
||||
aToFileList->AppendElement(newFS);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
// Copies the list
|
||||
//---------------------------------------------------
|
||||
NS_IMETHODIMP nsFileListTransferable::SetFileList(nsVoidArray * aFileList)
|
||||
{
|
||||
if (nsnull != aFileList && nsnull != mFileList) {
|
||||
ClearFileList();
|
||||
CopyFileList(aFileList, mFileList);
|
||||
}
|
||||
|
||||
mFileList = aFileList;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
// Fills the list provided by the caller
|
||||
//---------------------------------------------------
|
||||
NS_IMETHODIMP nsFileListTransferable::GetFileList(nsVoidArray * aFileList)
|
||||
{
|
||||
if (nsnull != aFileList && nsnull != mFileList) {
|
||||
CopyFileList(mFileList, aFileList);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
// FlavorsTransferableCanImport
|
||||
//
|
||||
// Computes a list of flavors that the transferable can accept into it, either through
|
||||
// intrinsic knowledge or input data converters.
|
||||
//---------------------------------------------------
|
||||
NS_IMETHODIMP nsFileListTransferable::FlavorsTransferableCanImport( nsVoidArray ** aOutFlavorList )
|
||||
{
|
||||
if ( !aOutFlavorList )
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
return GetTransferDataFlavors(aOutFlavorList); // addrefs
|
||||
|
||||
} // FlavorsTransferableCanImport
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
// FlavorsTransferableCanExport
|
||||
//
|
||||
// Computes a list of flavors that the transferable can export, either through
|
||||
// intrinsic knowledge or output data converters.
|
||||
//---------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsFileListTransferable::FlavorsTransferableCanExport( nsVoidArray** aOutFlavorList )
|
||||
{
|
||||
if ( !aOutFlavorList )
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
return GetTransferDataFlavors(aOutFlavorList); // addrefs
|
||||
|
||||
} // FlavorsTransferableCanImport
|
||||
|
||||
//---------------------------------------------------
|
||||
NS_IMETHODIMP nsFileListTransferable::AddDataFlavor(nsString * aDataFlavor)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
NS_IMETHODIMP nsFileListTransferable::RemoveDataFlavor(nsString * aDataFlavor)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
NS_IMETHODIMP nsFileListTransferable::SetConverter(nsIFormatConverter * aConverter)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
NS_IMETHODIMP nsFileListTransferable::GetConverter(nsIFormatConverter ** aConverter)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@ -1,89 +0,0 @@
|
||||
/* -*- 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 nsFileListTransferable_h__
|
||||
#define nsFileListTransferable_h__
|
||||
|
||||
#include "nsITransferable.h"
|
||||
#include "nsIFileListTransferable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
||||
class nsISupportsArray;
|
||||
class nsDataObj;
|
||||
class nsVoidArray;
|
||||
|
||||
|
||||
/**
|
||||
* XP FileListTransferable wrapper
|
||||
*/
|
||||
|
||||
class nsFileListTransferable : public nsIFileListTransferable, public nsITransferable
|
||||
{
|
||||
|
||||
public:
|
||||
nsFileListTransferable();
|
||||
virtual ~nsFileListTransferable();
|
||||
|
||||
//nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
||||
//////////////////////////
|
||||
// nsITransferable
|
||||
//////////////////////////
|
||||
NS_IMETHOD FlavorsTransferableCanExport ( nsVoidArray** outFlavorList ) ;
|
||||
NS_IMETHOD GetTransferDataFlavors(nsVoidArray ** aDataFlavorList);
|
||||
|
||||
// Transferable still owns |aData|. Do not delete it.
|
||||
NS_IMETHOD GetTransferData(nsString * aFlavor, void ** aData, PRUint32 * aDataLen);
|
||||
NS_IMETHOD GetAnyTransferData(nsString * aFlavor, void ** aData, PRUint32 * aDataLen);
|
||||
NS_IMETHOD_(PRBool) IsLargeDataSet();
|
||||
|
||||
//////////////////////////
|
||||
// nsIFileListTransferable
|
||||
//////////////////////////
|
||||
NS_IMETHOD SetFileList(nsVoidArray * aFileList);
|
||||
NS_IMETHOD GetFileList(nsVoidArray * aFileList);
|
||||
|
||||
//////////////////////////
|
||||
// Getter interface
|
||||
//////////////////////////
|
||||
NS_IMETHOD FlavorsTransferableCanImport ( nsVoidArray** outFlavorList ) ;
|
||||
|
||||
NS_IMETHOD SetTransferData(nsString * aFlavor, void * aData, PRUint32 aDataLen); // Transferable consumes |aData|. Do not delete it.
|
||||
|
||||
NS_IMETHOD AddDataFlavor(nsString * aDataFlavor);
|
||||
NS_IMETHOD RemoveDataFlavor(nsString * aDataFlavor);
|
||||
|
||||
NS_IMETHOD SetConverter(nsIFormatConverter * aConverter);
|
||||
NS_IMETHOD GetConverter(nsIFormatConverter ** aConverter);
|
||||
|
||||
|
||||
protected:
|
||||
void ClearFileList();
|
||||
NS_IMETHODIMP CopyFileList(nsVoidArray * aFromFileList,
|
||||
nsVoidArray * aToFileList);
|
||||
|
||||
nsVoidArray * mFileList;
|
||||
nsString mFileListDataFlavor;
|
||||
|
||||
};
|
||||
|
||||
#endif // nsFileListTransferable_h__
|
||||
Loading…
x
Reference in New Issue
Block a user