2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-06-30 22:17:43 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
1999-06-30 22:17:43 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +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.
|
1999-06-30 22:17:43 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
2000-11-16 22:25:45 +00:00
|
|
|
* Blake Ross <blakeross@telocity.com>
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-06-30 22:17:43 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Eric Vaughan
|
|
|
|
// Netscape Communications
|
|
|
|
//
|
|
|
|
// See documentation in associated header file
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "nsSplitterFrame.h"
|
2006-12-26 17:47:52 +00:00
|
|
|
#include "nsGkAtoms.h"
|
1999-06-30 22:17:43 +00:00
|
|
|
#include "nsISupportsArray.h"
|
|
|
|
#include "nsIDOMElement.h"
|
2003-10-21 11:43:40 +00:00
|
|
|
#include "nsIDOMXULElement.h"
|
1999-06-30 22:17:43 +00:00
|
|
|
#include "nsIDOMDocument.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2000-12-30 19:22:22 +00:00
|
|
|
#include "nsIDocument.h"
|
1999-06-30 22:17:43 +00:00
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsScrollbarButtonFrame.h"
|
1999-09-05 20:46:59 +00:00
|
|
|
#include "nsIDOMMouseListener.h"
|
|
|
|
#include "nsIDOMMouseMotionListener.h"
|
2007-05-14 09:11:38 +00:00
|
|
|
#include "nsIDOMEventTarget.h"
|
1999-09-05 20:46:59 +00:00
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsIScrollableView.h"
|
1999-11-03 07:11:45 +00:00
|
|
|
#include "nsIDOMMouseEvent.h"
|
1999-09-05 20:46:59 +00:00
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsFrameNavigator.h"
|
|
|
|
#include "nsHTMLParts.h"
|
2000-11-16 22:25:45 +00:00
|
|
|
#include "nsILookAndFeel.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
1999-09-14 22:17:19 +00:00
|
|
|
#include "nsWidgetsCID.h"
|
2000-03-31 07:02:06 +00:00
|
|
|
#include "nsBoxLayoutState.h"
|
2000-05-09 21:42:40 +00:00
|
|
|
#include "nsIXBLService.h"
|
|
|
|
#include "nsIServiceManager.h"
|
2000-09-01 00:59:09 +00:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsGUIEvent.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2001-02-19 21:50:04 +00:00
|
|
|
#include "nsContentCID.h"
|
2004-01-28 00:18:22 +00:00
|
|
|
#include "nsStyleSet.h"
|
2005-08-23 03:57:07 +00:00
|
|
|
#include "nsLayoutUtils.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
2006-04-24 05:40:11 +00:00
|
|
|
#include "nsContentUtils.h"
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2002-01-09 15:46:39 +00:00
|
|
|
// was used in nsSplitterFrame::Init but now commented out
|
|
|
|
//static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
2000-11-16 22:25:45 +00:00
|
|
|
PRInt32 realTimeDrag;
|
1999-06-30 22:17:43 +00:00
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
class nsSplitterInfo {
|
|
|
|
public:
|
2003-12-21 04:04:05 +00:00
|
|
|
nscoord min;
|
|
|
|
nscoord max;
|
|
|
|
nscoord current;
|
|
|
|
nscoord changed;
|
2005-10-11 18:59:58 +00:00
|
|
|
nsCOMPtr<nsIContent> childElem;
|
2003-12-21 04:04:05 +00:00
|
|
|
PRInt32 flex;
|
|
|
|
PRInt32 index;
|
1999-09-05 20:46:59 +00:00
|
|
|
};
|
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
class nsSplitterFrameInner : public nsIDOMMouseListener, public nsIDOMMouseMotionListener {
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner(nsSplitterFrame* aSplitter)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
mOuter = aSplitter;
|
1999-09-05 20:46:59 +00:00
|
|
|
mPressed = PR_FALSE;
|
|
|
|
}
|
2000-04-03 03:55:38 +00:00
|
|
|
virtual ~nsSplitterFrameInner();
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2007-05-21 07:33:32 +00:00
|
|
|
void Disconnect() { mOuter = nsnull; }
|
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
// mouse listener
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
|
|
|
|
NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
|
|
|
|
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent) { return NS_OK; }
|
|
|
|
NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent) { return NS_OK; }
|
|
|
|
NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent) { return NS_OK; }
|
|
|
|
NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent) { return MouseMove(aMouseEvent); }
|
|
|
|
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
// mouse motion listener
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
NS_IMETHOD MouseMove(nsIDOMEvent* aMouseEvent);
|
|
|
|
NS_IMETHOD DragMove(nsIDOMEvent* aMouseEvent) { return NS_OK; }
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void MouseDrag(nsPresContext* aPresContext, nsGUIEvent* aEvent);
|
|
|
|
void MouseUp(nsPresContext* aPresContext, nsGUIEvent* aEvent);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void AdjustChildren(nsPresContext* aPresContext);
|
|
|
|
void AdjustChildren(nsPresContext* aPresContext, nsSplitterInfo* aChildInfos, PRInt32 aCount, PRBool aIsHorizontal);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
void AddRemoveSpace(nscoord aDiff,
|
|
|
|
nsSplitterInfo* aChildInfos,
|
|
|
|
PRInt32 aCount,
|
|
|
|
PRInt32& aSpaceLeft);
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void ResizeChildTo(nsPresContext* aPresContext,
|
1999-10-26 04:44:41 +00:00
|
|
|
nscoord& aDiff,
|
1999-09-05 20:46:59 +00:00
|
|
|
nsSplitterInfo* aChildrenBeforeInfos,
|
|
|
|
nsSplitterInfo* aChildrenAfterInfos,
|
|
|
|
PRInt32 aChildrenBeforeCount,
|
|
|
|
PRInt32 aChildrenAfterCount,
|
|
|
|
PRBool aBounded);
|
|
|
|
|
|
|
|
void UpdateState();
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void AddListener(nsPresContext* aPresContext);
|
1999-09-05 20:46:59 +00:00
|
|
|
void RemoveListener();
|
|
|
|
|
1999-09-08 23:51:02 +00:00
|
|
|
enum ResizeType { Closest, Farthest, Grow };
|
2006-07-19 22:30:33 +00:00
|
|
|
enum State { Open, CollapsedBefore, CollapsedAfter, Dragging };
|
|
|
|
enum CollapseDirection { Before, After };
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
ResizeType GetResizeBefore();
|
|
|
|
ResizeType GetResizeAfter();
|
|
|
|
State GetState();
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
//nsresult CaptureMouse(nsPresContext* aPresContext, PRBool aGrabMouseEvents);
|
|
|
|
//PRBool IsMouseCaptured(nsPresContext* aPresContext);
|
1999-09-05 20:46:59 +00:00
|
|
|
void Reverse(nsSplitterInfo*& aIndexes, PRInt32 aCount);
|
2006-07-19 22:30:33 +00:00
|
|
|
PRBool SupportsCollapseDirection(CollapseDirection aDirection);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void MoveSplitterBy(nsPresContext* aPresContext, nscoord aDiff);
|
2000-03-31 07:02:06 +00:00
|
|
|
void EnsureOrient();
|
2000-04-11 23:55:15 +00:00
|
|
|
void SetPreferredSize(nsBoxLayoutState& aState, nsIBox* aChildBox, nscoord aOnePixel, PRBool aIsHorizontal, nscoord* aSize);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
|
|
|
nsSplitterFrame* mOuter;
|
1999-09-05 20:46:59 +00:00
|
|
|
PRBool mDidDrag;
|
2005-08-23 03:57:07 +00:00
|
|
|
nscoord mDragStart;
|
1999-09-05 20:46:59 +00:00
|
|
|
nscoord mCurrentPos;
|
2000-03-31 07:02:06 +00:00
|
|
|
nsIBox* mParentBox;
|
1999-09-05 20:46:59 +00:00
|
|
|
PRBool mPressed;
|
|
|
|
nsSplitterInfo* mChildInfosBefore;
|
|
|
|
nsSplitterInfo* mChildInfosAfter;
|
|
|
|
PRInt32 mChildInfosBeforeCount;
|
|
|
|
PRInt32 mChildInfosAfterCount;
|
|
|
|
State mState;
|
|
|
|
nscoord mSplitterPos;
|
1999-09-08 23:51:02 +00:00
|
|
|
nscoord mSplitterViewPos;
|
2000-08-30 21:51:02 +00:00
|
|
|
PRBool mDragging;
|
2000-03-31 07:02:06 +00:00
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
NS_IMPL_ISUPPORTS2(nsSplitterFrameInner, nsIDOMMouseListener, nsIDOMMouseMotionListener)
|
1999-09-05 20:46:59 +00:00
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::ResizeType
|
|
|
|
nsSplitterFrameInner::GetResizeBefore()
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2006-01-10 20:00:39 +00:00
|
|
|
if (mOuter->GetContent()->
|
2006-12-26 17:47:52 +00:00
|
|
|
AttrValueIs(kNameSpaceID_None, nsGkAtoms::resizebefore,
|
2006-01-10 20:00:39 +00:00
|
|
|
NS_LITERAL_STRING("farthest"), eCaseMatters))
|
2003-12-21 04:04:05 +00:00
|
|
|
return Farthest;
|
|
|
|
return Closest;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
2000-04-03 03:55:38 +00:00
|
|
|
nsSplitterFrameInner::~nsSplitterFrameInner()
|
|
|
|
{
|
|
|
|
delete[] mChildInfosBefore;
|
|
|
|
delete[] mChildInfosAfter;
|
|
|
|
}
|
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::ResizeType
|
|
|
|
nsSplitterFrameInner::GetResizeAfter()
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2006-04-24 05:40:11 +00:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2006-12-26 17:47:52 +00:00
|
|
|
{&nsGkAtoms::farthest, &nsGkAtoms::grow, nsnull};
|
2006-04-24 05:40:11 +00:00
|
|
|
switch (mOuter->GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
2006-12-26 17:47:52 +00:00
|
|
|
nsGkAtoms::resizeafter,
|
2006-04-24 05:40:11 +00:00
|
|
|
strings, eCaseMatters)) {
|
|
|
|
case 0: return Farthest;
|
|
|
|
case 1: return Grow;
|
|
|
|
}
|
2003-12-21 04:04:05 +00:00
|
|
|
return Closest;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::State
|
|
|
|
nsSplitterFrameInner::GetState()
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2006-04-24 05:40:11 +00:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2006-12-26 17:47:52 +00:00
|
|
|
{&nsGkAtoms::dragging, &nsGkAtoms::collapsed, nsnull};
|
2006-07-19 22:30:33 +00:00
|
|
|
static nsIContent::AttrValuesArray strings_substate[] =
|
2006-12-26 17:47:52 +00:00
|
|
|
{&nsGkAtoms::before, &nsGkAtoms::after, nsnull};
|
2006-04-24 05:40:11 +00:00
|
|
|
switch (mOuter->GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
2006-12-26 17:47:52 +00:00
|
|
|
nsGkAtoms::state,
|
2006-04-24 05:40:11 +00:00
|
|
|
strings, eCaseMatters)) {
|
|
|
|
case 0: return Dragging;
|
2006-07-19 22:30:33 +00:00
|
|
|
case 1:
|
|
|
|
switch (mOuter->GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
2006-12-26 17:47:52 +00:00
|
|
|
nsGkAtoms::substate,
|
2006-07-19 22:30:33 +00:00
|
|
|
strings_substate,
|
|
|
|
eCaseMatters)) {
|
|
|
|
case 0: return CollapsedBefore;
|
|
|
|
case 1: return CollapsedAfter;
|
|
|
|
default:
|
|
|
|
if (SupportsCollapseDirection(After))
|
|
|
|
return CollapsedAfter;
|
|
|
|
return CollapsedBefore;
|
|
|
|
}
|
2006-04-24 05:40:11 +00:00
|
|
|
}
|
2003-12-21 04:04:05 +00:00
|
|
|
return Open;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
1999-06-30 22:17:43 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// NS_NewSplitterFrame
|
|
|
|
//
|
2005-10-26 21:46:39 +00:00
|
|
|
// Creates a new Toolbar frame and returns it
|
1999-06-30 22:17:43 +00:00
|
|
|
//
|
2005-10-26 21:46:39 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewSplitterFrame (nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-06-30 22:17:43 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsSplitterFrame(aPresShell, aContext);
|
1999-06-30 22:17:43 +00:00
|
|
|
} // NS_NewSplitterFrame
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsSplitterFrame::nsSplitterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
: nsBoxFrame(aPresShell, aContext),
|
2003-12-21 04:04:05 +00:00
|
|
|
mInner(0)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-21 07:33:32 +00:00
|
|
|
void
|
|
|
|
nsSplitterFrame::Destroy()
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2003-12-21 04:04:05 +00:00
|
|
|
if (mInner) {
|
|
|
|
mInner->RemoveListener();
|
2007-05-21 07:33:32 +00:00
|
|
|
mInner->Disconnect();
|
2003-12-21 04:04:05 +00:00
|
|
|
mInner->Release();
|
2007-05-21 07:33:32 +00:00
|
|
|
mInner = nsnull;
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
2007-05-21 07:33:32 +00:00
|
|
|
nsBoxFrame::Destroy();
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
2000-05-26 06:42:29 +00:00
|
|
|
|
1999-12-22 01:57:29 +00:00
|
|
|
//
|
|
|
|
// QueryInterface
|
|
|
|
//
|
1999-12-21 19:28:15 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsSplitterFrame)
|
2000-01-26 22:35:53 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame)
|
1999-12-22 01:57:29 +00:00
|
|
|
|
1999-12-21 19:28:15 +00:00
|
|
|
|
1999-09-14 22:17:19 +00:00
|
|
|
NS_IMETHODIMP
|
2004-12-30 21:56:11 +00:00
|
|
|
nsSplitterFrame::GetCursor(const nsPoint& aPoint,
|
|
|
|
nsIFrame::Cursor& aCursor)
|
1999-09-14 22:17:19 +00:00
|
|
|
{
|
2004-12-30 21:56:11 +00:00
|
|
|
return nsBoxFrame::GetCursor(aPoint, aCursor);
|
2000-01-18 23:14:25 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
/*
|
|
|
|
if (IsHorizontal())
|
1999-09-14 22:17:19 +00:00
|
|
|
aCursor = NS_STYLE_CURSOR_N_RESIZE;
|
2003-12-21 04:04:05 +00:00
|
|
|
else
|
1999-09-14 22:17:19 +00:00
|
|
|
aCursor = NS_STYLE_CURSOR_W_RESIZE;
|
2003-12-21 04:04:05 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
*/
|
1999-09-14 22:17:19 +00:00
|
|
|
}
|
|
|
|
|
1999-06-30 22:17:43 +00:00
|
|
|
NS_IMETHODIMP
|
2005-09-07 16:49:21 +00:00
|
|
|
nsSplitterFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
2003-07-11 21:16:12 +00:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aModType)
|
1999-06-30 22:17:43 +00:00
|
|
|
{
|
2005-09-07 16:49:21 +00:00
|
|
|
nsresult rv = nsBoxFrame::AttributeChanged(aNameSpaceID, aAttribute,
|
|
|
|
aModType);
|
1999-06-30 22:17:43 +00:00
|
|
|
// if the alignment changed. Let the grippy know
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aAttribute == nsGkAtoms::align) {
|
2003-12-21 04:04:05 +00:00
|
|
|
// tell the slider its attribute changed so it can
|
|
|
|
// update itself
|
|
|
|
nsIFrame* grippy = nsnull;
|
2007-03-30 21:11:41 +00:00
|
|
|
nsScrollbarButtonFrame::GetChildWithTag(PresContext(), nsGkAtoms::grippy, this, grippy);
|
2003-12-21 04:04:05 +00:00
|
|
|
if (grippy)
|
2005-09-07 16:49:21 +00:00
|
|
|
grippy->AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
2006-12-26 17:47:52 +00:00
|
|
|
} else if (aAttribute == nsGkAtoms::state) {
|
2003-12-21 04:04:05 +00:00
|
|
|
mInner->UpdateState();
|
1999-06-30 22:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize us. If we are in a box get our alignment so we know what direction we are
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
2006-03-09 18:55:21 +00:00
|
|
|
nsSplitterFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1999-06-30 22:17:43 +00:00
|
|
|
{
|
2003-12-21 04:04:05 +00:00
|
|
|
NS_ENSURE_FALSE(mInner, NS_ERROR_ALREADY_INITIALIZED);
|
|
|
|
mInner = new nsSplitterFrameInner(this);
|
|
|
|
if (!mInner)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
mInner->AddRef();
|
|
|
|
mInner->mChildInfosAfter = nsnull;
|
|
|
|
mInner->mChildInfosBefore = nsnull;
|
|
|
|
mInner->mState = nsSplitterFrameInner::Open;
|
|
|
|
mInner->mDragging = PR_FALSE;
|
2004-10-28 07:25:57 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
// make it real time drag for now due to problems
|
|
|
|
nsCOMPtr<nsILookAndFeel> lookAndFeel = do_GetService(kLookAndFeelCID);
|
|
|
|
if (lookAndFeel) {
|
|
|
|
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_DragFullWindow, realTimeDrag);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
realTimeDrag = 1;
|
2000-11-16 22:25:45 +00:00
|
|
|
}
|
|
|
|
|
2001-10-26 00:09:12 +00:00
|
|
|
// determine orientation of parent, and if vertical, set orient to vertical
|
|
|
|
// on splitter content, then re-resolve style
|
2001-11-22 21:41:47 +00:00
|
|
|
// |newContext| to Release the reference after the call to nsBoxFrame::Init
|
2003-02-22 00:32:13 +00:00
|
|
|
nsRefPtr<nsStyleContext> newContext;
|
2004-09-28 18:37:50 +00:00
|
|
|
if (aParent && aParent->IsBoxFrame()) {
|
2007-01-31 16:02:42 +00:00
|
|
|
if (!aParent->IsHorizontal()) {
|
2006-04-24 05:40:11 +00:00
|
|
|
if (!nsContentUtils::HasNonEmptyAttr(aContent, kNameSpaceID_None,
|
2006-12-26 17:47:52 +00:00
|
|
|
nsGkAtoms::orient)) {
|
|
|
|
aContent->SetAttr(kNameSpaceID_None, nsGkAtoms::orient,
|
2001-10-26 00:09:12 +00:00
|
|
|
NS_LITERAL_STRING("vertical"), PR_FALSE);
|
2006-03-26 21:30:36 +00:00
|
|
|
nsStyleContext* parentStyleContext = aParent->GetStyleContext();
|
|
|
|
newContext = GetStyleContext()->GetRuleNode()->GetPresContext()->StyleSet()->
|
|
|
|
ResolveStyleFor(aContent, parentStyleContext);
|
|
|
|
SetStyleContextWithoutNotification(newContext);
|
2001-10-26 00:09:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsresult rv = nsBoxFrame::Init(aContent, aParent, aPrevInFlow);
|
2007-05-14 00:42:38 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1999-06-30 22:17:43 +00:00
|
|
|
|
2007-05-14 00:42:38 +00:00
|
|
|
rv = nsHTMLContainerFrame::CreateViewForFrame(this, nsnull, PR_TRUE);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2000-02-14 01:42:09 +00:00
|
|
|
|
2001-12-01 14:31:45 +00:00
|
|
|
if (!realTimeDrag) {
|
2007-05-14 00:42:38 +00:00
|
|
|
nsIView* view = GetView();
|
2003-12-21 04:04:05 +00:00
|
|
|
// currently this only works on win32 and mac
|
|
|
|
static NS_DEFINE_CID(kCChildCID, NS_CHILD_CID);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
// Need to have a widget to appear on top of other widgets.
|
2007-05-14 00:42:38 +00:00
|
|
|
NS_ASSERTION(!view->HasWidget(), "have an unwanted widget");
|
|
|
|
if (!view->HasWidget()) {
|
|
|
|
view->CreateWidget(kCChildCID);
|
|
|
|
}
|
2000-11-16 22:25:45 +00:00
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
mInner->mState = nsSplitterFrameInner::Open;
|
2007-03-30 21:11:41 +00:00
|
|
|
mInner->AddListener(PresContext());
|
2000-03-31 07:02:06 +00:00
|
|
|
mInner->mParentBox = nsnull;
|
1999-06-30 22:17:43 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
NS_IMETHODIMP
|
2000-07-07 22:24:06 +00:00
|
|
|
nsSplitterFrame::DoLayout(nsBoxLayoutState& aState)
|
2000-03-31 07:02:06 +00:00
|
|
|
{
|
2004-09-28 18:37:50 +00:00
|
|
|
if (GetStateBits() & NS_FRAME_FIRST_REFLOW)
|
2000-05-26 06:42:29 +00:00
|
|
|
{
|
2007-02-22 18:05:14 +00:00
|
|
|
mInner->mParentBox = GetParentBox();
|
2000-03-31 07:02:06 +00:00
|
|
|
mInner->UpdateState();
|
|
|
|
}
|
2000-05-26 06:42:29 +00:00
|
|
|
|
2000-07-07 22:24:06 +00:00
|
|
|
return nsBoxFrame::DoLayout(aState);
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
|
|
|
|
2001-03-08 00:47:22 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
nsSplitterFrame::GetInitialOrientation(PRBool& aIsHorizontal)
|
|
|
|
{
|
2007-02-22 18:05:14 +00:00
|
|
|
nsIBox* box = GetParentBox();
|
2001-03-08 00:47:22 +00:00
|
|
|
if (box) {
|
2007-01-31 16:02:42 +00:00
|
|
|
aIsHorizontal = !box->IsHorizontal();
|
2001-03-08 00:47:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
nsBoxFrame::GetInitialOrientation(aIsHorizontal);
|
|
|
|
}
|
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrame::HandlePress(nsPresContext* aPresContext,
|
1999-09-05 20:46:59 +00:00
|
|
|
nsGUIEvent * aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrame::HandleMultiplePress(nsPresContext* aPresContext,
|
1999-09-05 20:46:59 +00:00
|
|
|
nsGUIEvent * aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrame::HandleDrag(nsPresContext* aPresContext,
|
1999-09-05 20:46:59 +00:00
|
|
|
nsGUIEvent * aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2003-12-21 04:04:05 +00:00
|
|
|
return NS_OK;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrame::HandleRelease(nsPresContext* aPresContext,
|
1999-09-05 20:46:59 +00:00
|
|
|
nsGUIEvent * aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSplitterFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2005-09-19 02:15:54 +00:00
|
|
|
{
|
2006-01-26 02:29:17 +00:00
|
|
|
nsresult rv = nsBoxFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
// if the mouse is captured always return us as the frame.
|
2000-08-30 21:51:02 +00:00
|
|
|
if (mInner->mDragging)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2000-03-22 02:43:08 +00:00
|
|
|
// XXX It's probably better not to check visibility here, right?
|
2006-01-26 02:29:17 +00:00
|
|
|
return aLists.Outlines()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayEventReceiver(this));
|
2003-11-15 00:47:43 +00:00
|
|
|
}
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
return NS_OK;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrame::HandleEvent(nsPresContext* aPresContext,
|
1999-09-05 20:46:59 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2006-10-02 06:50:34 +00:00
|
|
|
nsWeakFrame weakFrame(this);
|
|
|
|
nsRefPtr<nsSplitterFrameInner> kungFuDeathGrip(mInner);
|
2003-12-21 04:04:05 +00:00
|
|
|
switch (aEvent->message) {
|
1999-09-05 20:46:59 +00:00
|
|
|
case NS_MOUSE_MOVE:
|
2003-12-21 04:04:05 +00:00
|
|
|
mInner->MouseDrag(aPresContext, aEvent);
|
1999-09-05 20:46:59 +00:00
|
|
|
break;
|
|
|
|
|
2006-11-16 21:35:39 +00:00
|
|
|
case NS_MOUSE_BUTTON_UP:
|
|
|
|
if (aEvent->eventStructType == NS_MOUSE_EVENT &&
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsMouseEvent*>(aEvent)->button ==
|
2006-11-16 21:35:39 +00:00
|
|
|
nsMouseEvent::eLeftButton) {
|
|
|
|
mInner->MouseUp(aPresContext, aEvent);
|
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-10-02 06:50:34 +00:00
|
|
|
NS_ENSURE_STATE(weakFrame.IsAlive());
|
2000-08-30 21:51:02 +00:00
|
|
|
return nsBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
1999-09-08 23:51:02 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrameInner::MouseUp(nsPresContext* aPresContext, nsGUIEvent* aEvent)
|
1999-09-08 23:51:02 +00:00
|
|
|
{
|
2007-05-21 07:33:32 +00:00
|
|
|
if (mDragging && mOuter) {
|
2003-12-21 04:04:05 +00:00
|
|
|
AdjustChildren(aPresContext);
|
|
|
|
AddListener(aPresContext);
|
|
|
|
mOuter->CaptureMouse(aPresContext, PR_FALSE);
|
|
|
|
mDragging = PR_FALSE;
|
|
|
|
State newState = GetState();
|
|
|
|
// if the state is dragging then make it Open.
|
|
|
|
if (newState == Dragging)
|
2006-12-26 17:47:52 +00:00
|
|
|
mOuter->mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::state, EmptyString(), PR_TRUE);
|
2003-10-21 11:43:40 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
mPressed = PR_FALSE;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
// if we dragged then fire a command event.
|
|
|
|
if (mDidDrag) {
|
|
|
|
nsCOMPtr<nsIDOMXULElement> element = do_QueryInterface(mOuter->GetContent());
|
|
|
|
element->DoCommand();
|
|
|
|
}
|
|
|
|
|
|
|
|
//printf("MouseUp\n");
|
|
|
|
}
|
2005-10-11 18:59:58 +00:00
|
|
|
|
|
|
|
delete[] mChildInfosBefore;
|
|
|
|
delete[] mChildInfosAfter;
|
|
|
|
mChildInfosBefore = nsnull;
|
|
|
|
mChildInfosAfter = nsnull;
|
1999-09-08 23:51:02 +00:00
|
|
|
}
|
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrameInner::MouseDrag(nsPresContext* aPresContext, nsGUIEvent* aEvent)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2007-05-21 07:33:32 +00:00
|
|
|
if (mDragging && mOuter) {
|
1999-09-14 22:17:19 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
//printf("Dragging\n");
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
PRBool isHorizontal = !mOuter->IsHorizontal();
|
|
|
|
// convert coord to pixels
|
2005-08-23 20:48:56 +00:00
|
|
|
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
|
|
|
|
mParentBox);
|
2005-08-23 03:57:07 +00:00
|
|
|
nscoord pos = isHorizontal ? pt.x : pt.y;
|
1999-09-14 22:17:19 +00:00
|
|
|
|
2005-08-23 03:57:07 +00:00
|
|
|
// mDragStart is in frame coordinates
|
|
|
|
nscoord start = mDragStart;
|
2005-04-18 05:18:34 +00:00
|
|
|
|
2005-11-20 22:05:24 +00:00
|
|
|
// take our current position and subtract the start location
|
2003-12-21 04:04:05 +00:00
|
|
|
pos -= start;
|
|
|
|
|
|
|
|
//printf("Diff=%d\n", pos);
|
|
|
|
|
|
|
|
ResizeType resizeAfter = GetResizeAfter();
|
|
|
|
|
|
|
|
PRBool bounded;
|
|
|
|
|
|
|
|
if (resizeAfter == nsSplitterFrameInner::Grow)
|
|
|
|
bounded = PR_FALSE;
|
|
|
|
else
|
|
|
|
bounded = PR_TRUE;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
for (i=0; i < mChildInfosBeforeCount; i++)
|
|
|
|
mChildInfosBefore[i].changed = mChildInfosBefore[i].current;
|
|
|
|
|
|
|
|
for (i=0; i < mChildInfosAfterCount; i++)
|
|
|
|
mChildInfosAfter[i].changed = mChildInfosAfter[i].current;
|
|
|
|
|
|
|
|
nscoord oldPos = pos;
|
|
|
|
|
|
|
|
ResizeChildTo(aPresContext, pos, mChildInfosBefore, mChildInfosAfter, mChildInfosBeforeCount, mChildInfosAfterCount, bounded);
|
|
|
|
|
|
|
|
State currentState = GetState();
|
2006-07-19 22:30:33 +00:00
|
|
|
PRBool supportsBefore = SupportsCollapseDirection(Before);
|
|
|
|
PRBool supportsAfter = SupportsCollapseDirection(After);
|
2003-12-21 04:04:05 +00:00
|
|
|
|
|
|
|
// if we are in a collapsed position
|
2006-07-19 22:30:33 +00:00
|
|
|
if (realTimeDrag && ((oldPos > 0 && oldPos > pos && supportsAfter) ||
|
|
|
|
(oldPos < 0 && oldPos < pos && supportsBefore)))
|
2003-12-21 04:04:05 +00:00
|
|
|
{
|
|
|
|
// and we are not collapsed then collapse
|
|
|
|
if (currentState == Dragging) {
|
|
|
|
if (oldPos > 0 && oldPos > pos)
|
|
|
|
{
|
|
|
|
//printf("Collapse right\n");
|
2006-07-19 22:30:33 +00:00
|
|
|
if (supportsAfter)
|
2003-12-21 04:04:05 +00:00
|
|
|
{
|
2006-09-03 20:25:58 +00:00
|
|
|
nsCOMPtr<nsIContent> outer = mOuter->mContent;
|
2006-12-26 17:47:52 +00:00
|
|
|
outer->SetAttr(kNameSpaceID_None, nsGkAtoms::substate,
|
2006-09-03 20:25:58 +00:00
|
|
|
NS_LITERAL_STRING("after"),
|
|
|
|
PR_TRUE);
|
2006-12-26 17:47:52 +00:00
|
|
|
outer->SetAttr(kNameSpaceID_None, nsGkAtoms::state,
|
2006-09-03 20:25:58 +00:00
|
|
|
NS_LITERAL_STRING("collapsed"),
|
|
|
|
PR_TRUE);
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if (oldPos < 0 && oldPos < pos)
|
|
|
|
{
|
|
|
|
//printf("Collapse left\n");
|
2006-07-19 22:30:33 +00:00
|
|
|
if (supportsBefore)
|
2003-12-21 04:04:05 +00:00
|
|
|
{
|
2006-09-03 20:25:58 +00:00
|
|
|
nsCOMPtr<nsIContent> outer = mOuter->mContent;
|
2006-12-26 17:47:52 +00:00
|
|
|
outer->SetAttr(kNameSpaceID_None, nsGkAtoms::substate,
|
2006-09-03 20:25:58 +00:00
|
|
|
NS_LITERAL_STRING("before"),
|
|
|
|
PR_TRUE);
|
2006-12-26 17:47:52 +00:00
|
|
|
outer->SetAttr(kNameSpaceID_None, nsGkAtoms::state,
|
2006-09-03 20:25:58 +00:00
|
|
|
NS_LITERAL_STRING("collapsed"),
|
|
|
|
PR_TRUE);
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// if we are not in a collapsed position and we are not dragging make sure
|
|
|
|
// we are dragging.
|
|
|
|
if (currentState != Dragging)
|
2006-12-26 17:47:52 +00:00
|
|
|
mOuter->mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::state, NS_LITERAL_STRING("dragging"), PR_TRUE);
|
2003-12-21 04:04:05 +00:00
|
|
|
if (realTimeDrag)
|
|
|
|
AdjustChildren(aPresContext);
|
|
|
|
else
|
|
|
|
MoveSplitterBy(aPresContext, pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
// printf("----- resize ----- ");
|
|
|
|
/*
|
|
|
|
for (i=0; i < mChildInfosBeforeCount; i++)
|
|
|
|
printf("before, index=%d, current=%d, changed=%d\n", mChildInfosBefore[i].index, mChildInfosBefore[i].current, mChildInfosBefore[i].changed);
|
|
|
|
for (i=0; i < mChildInfosAfterCount; i++)
|
|
|
|
printf("after, index=%d, current=%d, changed=%d\n", mChildInfosAfter[i].index, mChildInfosAfter[i].current, mChildInfosAfter[i].changed);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2003-12-21 05:36:36 +00:00
|
|
|
nsIPresShell *shell = aPresContext->PresShell();
|
2003-12-21 04:04:05 +00:00
|
|
|
|
2007-05-06 19:16:51 +00:00
|
|
|
shell->FrameNeedsReflow(mOuter, nsIPresShell::eStyleChange,
|
|
|
|
NS_FRAME_IS_DIRTY);
|
2003-12-21 04:04:05 +00:00
|
|
|
*/
|
|
|
|
mDidDrag = PR_TRUE;
|
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrameInner::AddListener(nsPresContext* aPresContext)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2007-05-14 09:11:38 +00:00
|
|
|
mOuter->GetContent()->
|
2007-07-08 07:08:04 +00:00
|
|
|
AddEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
|
2007-05-14 09:11:38 +00:00
|
|
|
NS_GET_IID(nsIDOMMouseListener));
|
|
|
|
mOuter->GetContent()->
|
2007-07-08 07:08:04 +00:00
|
|
|
AddEventListenerByIID(static_cast<nsIDOMMouseMotionListener*>(this),
|
2007-05-14 09:11:38 +00:00
|
|
|
NS_GET_IID(nsIDOMMouseMotionListener));
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::RemoveListener()
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2007-05-21 07:33:32 +00:00
|
|
|
ENSURE_TRUE(mOuter);
|
2007-05-14 09:11:38 +00:00
|
|
|
mOuter->GetContent()->
|
2007-07-08 07:08:04 +00:00
|
|
|
RemoveEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
|
2007-05-14 09:11:38 +00:00
|
|
|
NS_GET_IID(nsIDOMMouseListener));
|
|
|
|
mOuter->GetContent()->
|
2007-07-08 07:08:04 +00:00
|
|
|
RemoveEventListenerByIID(static_cast<nsIDOMMouseMotionListener*>(this),
|
2007-05-14 09:11:38 +00:00
|
|
|
NS_GET_IID(nsIDOMMouseMotionListener));
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
2000-05-26 06:42:29 +00:00
|
|
|
/*
|
1999-09-05 20:46:59 +00:00
|
|
|
nsresult
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrameInner :: CaptureMouse(nsPresContext* aPresContext, PRBool aGrabMouseEvents)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2003-12-21 04:04:05 +00:00
|
|
|
// get its view
|
2003-08-04 12:39:51 +00:00
|
|
|
nsIView* view = mOuter->GetView();
|
1999-09-05 20:46:59 +00:00
|
|
|
PRBool result;
|
|
|
|
|
|
|
|
if (view) {
|
2003-08-04 12:39:51 +00:00
|
|
|
nsIViewManager* viewMan = view->GetViewManager();
|
1999-09-05 20:46:59 +00:00
|
|
|
if (viewMan) {
|
2003-08-04 12:39:51 +00:00
|
|
|
// nsIWidget* widget = view->GetWidget();
|
1999-09-05 20:46:59 +00:00
|
|
|
if (aGrabMouseEvents) {
|
|
|
|
viewMan->GrabMouseEvents(view,result);
|
2003-12-21 04:04:05 +00:00
|
|
|
// if (widget)
|
1999-09-22 03:11:47 +00:00
|
|
|
// widget->CaptureMouse(PR_TRUE);
|
1999-09-05 20:46:59 +00:00
|
|
|
} else {
|
|
|
|
viewMan->GrabMouseEvents(nsnull,result);
|
1999-09-22 03:11:47 +00:00
|
|
|
// if (widget)
|
|
|
|
// widget->CaptureMouse(PR_FALSE);
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-26 06:42:29 +00:00
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
PRBool
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrameInner :: IsMouseCaptured(nsPresContext* aPresContext)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
|
|
|
// get its view
|
2003-08-04 12:39:51 +00:00
|
|
|
nsIView* view = mOuter->GetView();
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
if (view) {
|
2003-08-04 12:39:51 +00:00
|
|
|
nsIViewManager* viewMan = view->GetViewManager();
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
if (viewMan) {
|
|
|
|
nsIView* grabbingView;
|
|
|
|
viewMan->GetMouseEventGrabber(grabbingView);
|
|
|
|
if (grabbingView == view)
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2000-05-26 06:42:29 +00:00
|
|
|
*/
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
nsresult
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::MouseUp(nsIDOMEvent* aMouseEvent)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2007-05-21 07:33:32 +00:00
|
|
|
NS_ENSURE_TRUE(mOuter, NS_OK);
|
1999-09-05 20:46:59 +00:00
|
|
|
mPressed = PR_FALSE;
|
2002-04-10 04:58:02 +00:00
|
|
|
|
2007-03-30 21:11:41 +00:00
|
|
|
mOuter->CaptureMouse(mOuter->PresContext(), PR_FALSE);
|
2002-04-10 04:58:02 +00:00
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2007-05-21 07:33:32 +00:00
|
|
|
NS_ENSURE_TRUE(mOuter, NS_OK);
|
2000-05-15 22:43:47 +00:00
|
|
|
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));
|
|
|
|
|
|
|
|
PRUint16 button = 0;
|
|
|
|
mouseEvent->GetButton(&button);
|
|
|
|
|
|
|
|
// only if left button
|
2001-03-02 03:07:53 +00:00
|
|
|
if (button != 0)
|
2000-05-15 22:43:47 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2006-01-10 20:00:39 +00:00
|
|
|
if (mOuter->GetContent()->
|
2006-12-26 17:47:52 +00:00
|
|
|
AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
|
|
|
|
nsGkAtoms::_true, eCaseMatters))
|
2000-09-08 06:55:10 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2007-02-22 18:05:14 +00:00
|
|
|
mParentBox = mOuter->GetParentBox();
|
2006-03-24 21:05:11 +00:00
|
|
|
if (!mParentBox)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
// get our index
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext* outerPresContext = mOuter->PresContext();
|
2006-03-24 21:05:11 +00:00
|
|
|
nscoord childIndex = nsFrameNavigator::IndexOf(outerPresContext, mParentBox, mOuter);
|
|
|
|
PRInt32 childCount = nsFrameNavigator::CountFrames(outerPresContext, mParentBox);
|
|
|
|
|
|
|
|
// if it's 0 or the last index then stop right here.
|
|
|
|
if (childIndex == 0 || childIndex == childCount - 1)
|
|
|
|
return NS_OK;
|
|
|
|
|
2007-04-29 22:24:59 +00:00
|
|
|
nsCOMPtr<nsIRenderingContext> rc;
|
|
|
|
nsresult rv = outerPresContext->PresShell()->
|
|
|
|
CreateRenderingContext(mOuter, getter_AddRefs(rc));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsBoxLayoutState state(outerPresContext, rc);
|
1999-09-05 20:46:59 +00:00
|
|
|
mCurrentPos = 0;
|
|
|
|
mPressed = PR_TRUE;
|
|
|
|
|
|
|
|
mDidDrag = PR_FALSE;
|
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
EnsureOrient();
|
2000-03-31 07:02:06 +00:00
|
|
|
PRBool isHorizontal = !mOuter->IsHorizontal();
|
2001-08-15 04:09:41 +00:00
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
ResizeType resizeBefore = GetResizeBefore();
|
|
|
|
ResizeType resizeAfter = GetResizeAfter();
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
delete[] mChildInfosBefore;
|
|
|
|
delete[] mChildInfosAfter;
|
1999-09-05 20:46:59 +00:00
|
|
|
mChildInfosBefore = new nsSplitterInfo[childCount];
|
|
|
|
mChildInfosAfter = new nsSplitterInfo[childCount];
|
|
|
|
|
|
|
|
// create info 2 lists. One of the children before us and one after.
|
|
|
|
PRInt32 count = 0;
|
|
|
|
mChildInfosBeforeCount = 0;
|
|
|
|
mChildInfosAfterCount = 0;
|
|
|
|
|
2007-02-22 18:05:14 +00:00
|
|
|
nsIBox* childBox = mParentBox->GetChildBox();
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
while (nsnull != childBox)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2004-09-28 18:37:50 +00:00
|
|
|
nsIContent* content = childBox->GetContent();
|
2007-02-27 00:14:01 +00:00
|
|
|
nsIDocument* doc = content->GetOwnerDoc();
|
|
|
|
nsIAtom* atom;
|
|
|
|
if (doc) {
|
2000-05-24 08:19:10 +00:00
|
|
|
PRInt32 dummy;
|
2007-02-27 00:14:01 +00:00
|
|
|
atom = doc->BindingManager()->ResolveTag(content, &dummy);
|
|
|
|
} else {
|
2003-11-19 01:20:56 +00:00
|
|
|
atom = content->Tag();
|
2007-02-27 00:14:01 +00:00
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
// skip over any splitters
|
2006-12-26 17:47:52 +00:00
|
|
|
if (atom != nsGkAtoms::splitter) {
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize prefSize = childBox->GetPrefSize(state);
|
|
|
|
nsSize minSize = childBox->GetMinSize(state);
|
|
|
|
nsSize maxSize = childBox->GetMaxSize(state);
|
2000-03-31 07:02:06 +00:00
|
|
|
nsBox::BoundsCheck(minSize, prefSize, maxSize);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
mOuter->AddMargin(childBox, minSize);
|
|
|
|
mOuter->AddMargin(childBox, prefSize);
|
|
|
|
mOuter->AddMargin(childBox, maxSize);
|
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
nscoord flex = childBox->GetFlex(state);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
nsMargin margin(0,0,0,0);
|
2000-03-31 07:02:06 +00:00
|
|
|
childBox->GetMargin(margin);
|
2004-09-28 18:37:50 +00:00
|
|
|
nsRect r(childBox->GetRect());
|
1999-09-05 20:46:59 +00:00
|
|
|
r.Inflate(margin);
|
|
|
|
|
2002-07-16 01:45:38 +00:00
|
|
|
// We need to check for hidden attribute too, since treecols with
|
|
|
|
// the hidden="true" attribute are not really hidden, just collapsed
|
2006-12-26 17:47:52 +00:00
|
|
|
if (!content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::fixed,
|
|
|
|
nsGkAtoms::_true, eCaseMatters) &&
|
|
|
|
!content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden,
|
|
|
|
nsGkAtoms::_true, eCaseMatters)) {
|
2002-07-16 01:45:38 +00:00
|
|
|
if (count < childIndex) {
|
2005-10-11 18:59:58 +00:00
|
|
|
mChildInfosBefore[mChildInfosBeforeCount].childElem = content;
|
2000-09-08 06:55:10 +00:00
|
|
|
mChildInfosBefore[mChildInfosBeforeCount].min = isHorizontal ? minSize.width : minSize.height;
|
|
|
|
mChildInfosBefore[mChildInfosBeforeCount].max = isHorizontal ? maxSize.width : maxSize.height;
|
|
|
|
mChildInfosBefore[mChildInfosBeforeCount].current = isHorizontal ? r.width : r.height;
|
|
|
|
mChildInfosBefore[mChildInfosBeforeCount].flex = flex;
|
|
|
|
mChildInfosBefore[mChildInfosBeforeCount].index = count;
|
|
|
|
mChildInfosBefore[mChildInfosBeforeCount].changed = mChildInfosBefore[mChildInfosBeforeCount].current;
|
|
|
|
mChildInfosBeforeCount++;
|
2002-07-16 01:45:38 +00:00
|
|
|
} else if (count > childIndex) {
|
2005-10-11 18:59:58 +00:00
|
|
|
mChildInfosAfter[mChildInfosAfterCount].childElem = content;
|
2000-09-08 06:55:10 +00:00
|
|
|
mChildInfosAfter[mChildInfosAfterCount].min = isHorizontal ? minSize.width : minSize.height;
|
|
|
|
mChildInfosAfter[mChildInfosAfterCount].max = isHorizontal ? maxSize.width : maxSize.height;
|
|
|
|
mChildInfosAfter[mChildInfosAfterCount].current = isHorizontal ? r.width : r.height;
|
|
|
|
mChildInfosAfter[mChildInfosAfterCount].flex = flex;
|
|
|
|
mChildInfosAfter[mChildInfosAfterCount].index = count;
|
2002-07-16 01:45:38 +00:00
|
|
|
mChildInfosAfter[mChildInfosAfterCount].changed = mChildInfosAfter[mChildInfosAfterCount].current;
|
2000-09-08 06:55:10 +00:00
|
|
|
mChildInfosAfterCount++;
|
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-22 18:05:14 +00:00
|
|
|
childBox = childBox->GetNextBox();
|
1999-09-05 20:46:59 +00:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
if (!mParentBox->IsNormalDirection()) {
|
2001-08-15 04:09:41 +00:00
|
|
|
// The before array is really the after array, and the order needs to be reversed.
|
|
|
|
// First reverse both arrays.
|
|
|
|
Reverse(mChildInfosBefore, mChildInfosBeforeCount);
|
|
|
|
Reverse(mChildInfosAfter, mChildInfosAfterCount);
|
|
|
|
|
|
|
|
// Now swap the two arrays.
|
|
|
|
nscoord newAfterCount = mChildInfosBeforeCount;
|
|
|
|
mChildInfosBeforeCount = mChildInfosAfterCount;
|
|
|
|
mChildInfosAfterCount = newAfterCount;
|
|
|
|
nsSplitterInfo* temp = mChildInfosAfter;
|
|
|
|
mChildInfosAfter = mChildInfosBefore;
|
|
|
|
mChildInfosBefore = temp;
|
|
|
|
}
|
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
// if the resizebefore is closest we must reverse the list because the first child in the list
|
1999-09-08 23:51:02 +00:00
|
|
|
// is the Farthest we want the first child to be the closest.
|
1999-09-05 20:46:59 +00:00
|
|
|
if (resizeBefore == Closest)
|
|
|
|
Reverse(mChildInfosBefore, mChildInfosBeforeCount);
|
|
|
|
|
1999-09-08 23:51:02 +00:00
|
|
|
// if the resizeafter is the Farthest we must reverse the list because the first child in the list
|
|
|
|
// is the closest we want the first child to be the Farthest.
|
|
|
|
if (resizeAfter == Farthest)
|
1999-09-05 20:46:59 +00:00
|
|
|
Reverse(mChildInfosAfter, mChildInfosAfterCount);
|
|
|
|
|
|
|
|
// grow only applys to the children after. If grow is set then no space should be taken out of any children after
|
|
|
|
// us. To do this we just set the size of that list to be 0.
|
|
|
|
if (resizeAfter == Grow)
|
|
|
|
mChildInfosAfterCount = 0;
|
|
|
|
|
2003-08-04 12:39:51 +00:00
|
|
|
nsRect vr = mOuter->GetView()->GetBounds();
|
1999-09-08 23:51:02 +00:00
|
|
|
|
2005-08-23 03:57:07 +00:00
|
|
|
PRInt32 c;
|
|
|
|
nsPoint pt = nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(mouseEvent,
|
2005-08-23 20:48:56 +00:00
|
|
|
mParentBox);
|
1999-09-05 20:46:59 +00:00
|
|
|
if (isHorizontal) {
|
2005-08-23 03:57:07 +00:00
|
|
|
c = pt.x;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
mSplitterPos = mOuter->mRect.x;
|
1999-09-08 23:51:02 +00:00
|
|
|
mSplitterViewPos = vr.x;
|
1999-09-05 20:46:59 +00:00
|
|
|
} else {
|
2005-08-23 03:57:07 +00:00
|
|
|
c = pt.y;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
mSplitterPos = mOuter->mRect.y;
|
1999-09-08 23:51:02 +00:00
|
|
|
mSplitterViewPos = vr.y;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
2005-08-23 03:57:07 +00:00
|
|
|
mDragStart = c;
|
2005-12-15 03:30:17 +00:00
|
|
|
|
2005-08-23 03:57:07 +00:00
|
|
|
//printf("Pressed mDragStart=%d\n",mDragStart);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2005-12-15 03:30:17 +00:00
|
|
|
mOuter->CaptureMouse(outerPresContext, PR_TRUE);
|
2002-03-27 05:49:56 +00:00
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::MouseMove(nsIDOMEvent* aMouseEvent)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2007-05-21 07:33:32 +00:00
|
|
|
NS_ENSURE_TRUE(mOuter, NS_OK);
|
1999-09-05 20:46:59 +00:00
|
|
|
if (!mPressed)
|
2005-12-15 03:30:17 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2000-08-30 21:51:02 +00:00
|
|
|
if (mDragging)
|
1999-09-05 20:46:59 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2007-05-21 07:33:32 +00:00
|
|
|
nsCOMPtr<nsIDOMMouseListener> kungfuDeathGrip(this);
|
2006-12-26 17:47:52 +00:00
|
|
|
mOuter->mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::state, NS_LITERAL_STRING("dragging"), PR_TRUE);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
RemoveListener();
|
2000-08-30 21:51:02 +00:00
|
|
|
mDragging = PR_TRUE;
|
1999-09-05 20:46:59 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::Reverse(nsSplitterInfo*& aChildInfos, PRInt32 aCount)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
|
|
|
nsSplitterInfo* infos = new nsSplitterInfo[aCount];
|
|
|
|
|
|
|
|
for (int i=0; i < aCount; i++)
|
|
|
|
infos[i] = aChildInfos[aCount - 1 - i];
|
|
|
|
|
2000-04-03 03:55:38 +00:00
|
|
|
delete[] aChildInfos;
|
1999-09-05 20:46:59 +00:00
|
|
|
aChildInfos = infos;
|
|
|
|
}
|
|
|
|
|
2006-07-19 22:30:33 +00:00
|
|
|
PRBool
|
|
|
|
nsSplitterFrameInner::SupportsCollapseDirection
|
|
|
|
(
|
|
|
|
nsSplitterFrameInner::CollapseDirection aDirection
|
|
|
|
)
|
1999-09-14 22:17:19 +00:00
|
|
|
{
|
2006-04-24 05:40:11 +00:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2006-12-26 17:47:52 +00:00
|
|
|
{&nsGkAtoms::before, &nsGkAtoms::after, &nsGkAtoms::both, nsnull};
|
2006-07-19 22:30:33 +00:00
|
|
|
|
2006-04-24 05:40:11 +00:00
|
|
|
switch (mOuter->mContent->FindAttrValueIn(kNameSpaceID_None,
|
2006-12-26 17:47:52 +00:00
|
|
|
nsGkAtoms::collapse,
|
2006-04-24 05:40:11 +00:00
|
|
|
strings, eCaseMatters)) {
|
2006-07-19 22:30:33 +00:00
|
|
|
case 0:
|
|
|
|
return (aDirection == Before);
|
|
|
|
case 1:
|
|
|
|
return (aDirection == After);
|
|
|
|
case 2:
|
|
|
|
return PR_TRUE;
|
2006-04-24 05:40:11 +00:00
|
|
|
}
|
2005-10-28 11:25:24 +00:00
|
|
|
|
2006-07-19 22:30:33 +00:00
|
|
|
return PR_FALSE;
|
1999-09-14 22:17:19 +00:00
|
|
|
}
|
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
void
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::UpdateState()
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2000-03-08 00:14:53 +00:00
|
|
|
// State Transitions:
|
2006-07-19 22:30:33 +00:00
|
|
|
// Open -> Dragging
|
|
|
|
// Open -> CollapsedBefore
|
|
|
|
// Open -> CollapsedAfter
|
|
|
|
// CollapsedBefore -> Open
|
|
|
|
// CollapsedBefore -> Dragging
|
|
|
|
// CollapsedAfter -> Open
|
|
|
|
// CollapsedAfter -> Dragging
|
|
|
|
// Dragging -> Open
|
|
|
|
// Dragging -> CollapsedBefore (auto collapse)
|
|
|
|
// Dragging -> CollapsedAfter (auto collapse)
|
1999-09-14 22:17:19 +00:00
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
State newState = GetState();
|
|
|
|
|
2000-03-08 00:14:53 +00:00
|
|
|
if (newState == mState) {
|
|
|
|
// No change.
|
2003-12-21 04:04:05 +00:00
|
|
|
return;
|
2000-03-08 00:14:53 +00:00
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2006-07-19 22:30:33 +00:00
|
|
|
if (SupportsCollapseDirection(Before) || SupportsCollapseDirection(After)) {
|
2003-12-21 04:04:05 +00:00
|
|
|
nsIBox* splitter = mOuter;
|
|
|
|
// Find the splitter's immediate sibling.
|
|
|
|
nsIBox* splitterSibling =
|
2007-03-30 21:11:41 +00:00
|
|
|
nsFrameNavigator::GetChildBeforeAfter(mOuter->PresContext(), splitter,
|
2006-07-19 22:30:33 +00:00
|
|
|
(newState == CollapsedBefore ||
|
|
|
|
mState == CollapsedBefore));
|
2003-12-21 04:04:05 +00:00
|
|
|
if (splitterSibling) {
|
2006-09-03 20:25:58 +00:00
|
|
|
nsCOMPtr<nsIContent> sibling = splitterSibling->GetContent();
|
2003-12-21 04:04:05 +00:00
|
|
|
if (sibling) {
|
2006-07-19 22:30:33 +00:00
|
|
|
if (mState == CollapsedBefore || mState == CollapsedAfter) {
|
|
|
|
// CollapsedBefore -> Open
|
|
|
|
// CollapsedBefore -> Dragging
|
|
|
|
// CollapsedAfter -> Open
|
|
|
|
// CollapsedAfter -> Dragging
|
2006-12-26 17:47:52 +00:00
|
|
|
sibling->UnsetAttr(kNameSpaceID_None, nsGkAtoms::collapsed,
|
2003-12-21 04:04:05 +00:00
|
|
|
PR_TRUE);
|
2006-07-19 22:30:33 +00:00
|
|
|
} else if ((mState == Open || mState == Dragging)
|
|
|
|
&& (newState == CollapsedBefore ||
|
|
|
|
newState == CollapsedAfter)) {
|
|
|
|
// Open -> CollapsedBefore / CollapsedAfter
|
|
|
|
// Dragging -> CollapsedBefore / CollapsedAfter
|
2006-12-26 17:47:52 +00:00
|
|
|
sibling->SetAttr(kNameSpaceID_None, nsGkAtoms::collapsed,
|
2003-12-21 04:04:05 +00:00
|
|
|
NS_LITERAL_STRING("true"), PR_TRUE);
|
2000-03-08 02:33:52 +00:00
|
|
|
}
|
2000-03-08 00:14:53 +00:00
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
|
|
|
mState = newState;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsSplitterFrameInner::EnsureOrient()
|
|
|
|
{
|
2004-09-28 18:37:50 +00:00
|
|
|
PRBool isHorizontal = !(mParentBox->GetStateBits() & NS_STATE_IS_HORIZONTAL);
|
2000-03-31 07:02:06 +00:00
|
|
|
if (isHorizontal)
|
2003-12-21 04:04:05 +00:00
|
|
|
mOuter->mState |= NS_STATE_IS_HORIZONTAL;
|
2000-03-31 07:02:06 +00:00
|
|
|
else
|
2003-12-21 04:04:05 +00:00
|
|
|
mOuter->mState &= ~NS_STATE_IS_HORIZONTAL;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrameInner::AdjustChildren(nsPresContext* aPresContext)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2000-03-31 07:02:06 +00:00
|
|
|
EnsureOrient();
|
|
|
|
PRBool isHorizontal = !mOuter->IsHorizontal();
|
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
AdjustChildren(aPresContext, mChildInfosBefore, mChildInfosBeforeCount, isHorizontal);
|
|
|
|
AdjustChildren(aPresContext, mChildInfosAfter, mChildInfosAfterCount, isHorizontal);
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2000-10-28 22:17:53 +00:00
|
|
|
// printf("----- Posting Dirty -----\n");
|
2000-03-31 07:02:06 +00:00
|
|
|
|
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
if (realTimeDrag) {
|
2004-05-27 22:08:42 +00:00
|
|
|
aPresContext->PresShell()->FlushPendingNotifications(Flush_Display);
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
|
|
|
else {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
aPresContext->PresShell()->
|
2007-05-06 19:16:51 +00:00
|
|
|
FrameNeedsReflow(mOuter, nsIPresShell::eTreeChange, NS_FRAME_IS_DIRTY);
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
2005-10-11 18:59:58 +00:00
|
|
|
static nsIBox* GetChildBoxForContent(nsIBox* aParentBox, nsIContent* aContent)
|
|
|
|
{
|
2007-02-22 18:05:14 +00:00
|
|
|
nsIBox* childBox = aParentBox->GetChildBox();
|
2005-10-11 18:59:58 +00:00
|
|
|
|
|
|
|
while (nsnull != childBox) {
|
|
|
|
if (childBox->GetContent() == aContent) {
|
|
|
|
return childBox;
|
|
|
|
}
|
2007-02-22 18:05:14 +00:00
|
|
|
childBox = childBox->GetNextBox();
|
2005-10-11 18:59:58 +00:00
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrameInner::AdjustChildren(nsPresContext* aPresContext, nsSplitterInfo* aChildInfos, PRInt32 aCount, PRBool aIsHorizontal)
|
1999-09-05 20:46:59 +00:00
|
|
|
{
|
2003-12-21 04:04:05 +00:00
|
|
|
///printf("------- AdjustChildren------\n");
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
nsBoxLayoutState state(aPresContext);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2007-02-07 07:46:44 +00:00
|
|
|
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
// first set all the widths.
|
2007-02-22 18:05:14 +00:00
|
|
|
nsIBox* child = mOuter->GetChildBox();
|
2003-12-21 04:04:05 +00:00
|
|
|
while(child)
|
|
|
|
{
|
|
|
|
SetPreferredSize(state, child, onePixel, aIsHorizontal, nsnull);
|
2007-02-22 18:05:14 +00:00
|
|
|
child = child->GetNextBox();
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
2000-04-11 23:55:15 +00:00
|
|
|
|
2003-12-21 04:04:05 +00:00
|
|
|
// now set our changed widths.
|
|
|
|
for (int i=0; i < aCount; i++)
|
|
|
|
{
|
|
|
|
nscoord pref = aChildInfos[i].changed;
|
2005-10-11 18:59:58 +00:00
|
|
|
nsIBox* childBox = GetChildBoxForContent(mParentBox, aChildInfos[i].childElem);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2005-10-11 18:59:58 +00:00
|
|
|
if (childBox) {
|
|
|
|
SetPreferredSize(state, childBox, onePixel, aIsHorizontal, &pref);
|
|
|
|
}
|
2003-12-21 04:04:05 +00:00
|
|
|
}
|
2000-04-11 23:55:15 +00:00
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2000-04-11 23:55:15 +00:00
|
|
|
void
|
|
|
|
nsSplitterFrameInner::SetPreferredSize(nsBoxLayoutState& aState, nsIBox* aChildBox, nscoord aOnePixel, PRBool aIsHorizontal, nscoord* aSize)
|
|
|
|
{
|
2000-10-28 22:17:53 +00:00
|
|
|
//printf("current=%d, pref=%d", current/onePixel, pref/onePixel);
|
2000-04-11 23:55:15 +00:00
|
|
|
|
|
|
|
nscoord current = 0;
|
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
nsRect rect(aChildBox->GetRect());
|
2000-04-11 23:55:15 +00:00
|
|
|
if (aIsHorizontal)
|
|
|
|
current = rect.width;
|
|
|
|
else
|
|
|
|
current = rect.height;
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2000-04-11 23:55:15 +00:00
|
|
|
nscoord pref = 0;
|
|
|
|
|
|
|
|
if (!aSize)
|
|
|
|
{
|
|
|
|
if (aIsHorizontal)
|
|
|
|
pref = rect.width;
|
|
|
|
else
|
|
|
|
pref = rect.height;
|
|
|
|
} else {
|
|
|
|
pref = *aSize;
|
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2000-04-11 23:55:15 +00:00
|
|
|
nsMargin margin(0,0,0,0);
|
|
|
|
aChildBox->GetMargin(margin);
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2000-04-11 23:55:15 +00:00
|
|
|
nsCOMPtr<nsIAtom> attribute;
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2000-04-11 23:55:15 +00:00
|
|
|
if (aIsHorizontal) {
|
2003-12-21 04:04:05 +00:00
|
|
|
pref -= (margin.left + margin.right);
|
2006-12-26 17:47:52 +00:00
|
|
|
attribute = nsGkAtoms::width;
|
2000-04-11 23:55:15 +00:00
|
|
|
} else {
|
2003-12-21 04:04:05 +00:00
|
|
|
pref -= (margin.top + margin.bottom);
|
2006-12-26 17:47:52 +00:00
|
|
|
attribute = nsGkAtoms::height;
|
2000-04-11 23:55:15 +00:00
|
|
|
}
|
1999-09-05 20:46:59 +00:00
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
nsIContent* content = aChildBox->GetContent();
|
2000-04-11 23:55:15 +00:00
|
|
|
|
|
|
|
// set its preferred size.
|
2002-12-31 12:50:10 +00:00
|
|
|
nsAutoString prefValue;
|
|
|
|
prefValue.AppendInt(pref/aOnePixel);
|
2006-01-10 20:00:39 +00:00
|
|
|
if (content->AttrValueIs(kNameSpaceID_None, attribute,
|
|
|
|
prefValue, eCaseMatters))
|
2000-04-11 23:55:15 +00:00
|
|
|
return;
|
|
|
|
|
2006-09-03 20:25:58 +00:00
|
|
|
nsWeakFrame weakBox(aChildBox);
|
2002-12-31 12:50:10 +00:00
|
|
|
content->SetAttr(kNameSpaceID_None, attribute, prefValue, PR_TRUE);
|
2006-09-03 20:25:58 +00:00
|
|
|
ENSURE_TRUE(weakBox.IsAlive());
|
2007-05-06 19:16:51 +00:00
|
|
|
aState.PresShell()->FrameNeedsReflow(aChildBox, nsIPresShell::eStyleChange,
|
|
|
|
NS_FRAME_IS_DIRTY);
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
nsSplitterFrameInner::AddRemoveSpace(nscoord aDiff,
|
1999-09-05 20:46:59 +00:00
|
|
|
nsSplitterInfo* aChildInfos,
|
|
|
|
PRInt32 aCount,
|
|
|
|
PRInt32& aSpaceLeft)
|
|
|
|
{
|
|
|
|
aSpaceLeft = 0;
|
|
|
|
|
|
|
|
for (int i=0; i < aCount; i++) {
|
|
|
|
nscoord min = aChildInfos[i].min;
|
|
|
|
nscoord max = aChildInfos[i].max;
|
|
|
|
nscoord& c = aChildInfos[i].changed;
|
|
|
|
|
|
|
|
// figure our how much space to add or remove
|
|
|
|
if (c + aDiff < min) {
|
2003-12-21 04:04:05 +00:00
|
|
|
aDiff += (c - min);
|
|
|
|
c = min;
|
1999-09-05 20:46:59 +00:00
|
|
|
} else if (c + aDiff > max) {
|
2003-12-21 04:04:05 +00:00
|
|
|
aDiff -= (max - c);
|
|
|
|
c = max;
|
1999-09-05 20:46:59 +00:00
|
|
|
} else {
|
2003-12-21 04:04:05 +00:00
|
|
|
c += aDiff;
|
|
|
|
aDiff = 0;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// there is not space left? We are done
|
|
|
|
if (aDiff == 0)
|
2003-12-21 04:04:05 +00:00
|
|
|
break;
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aSpaceLeft = aDiff;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ok if we want to resize a child we will know the actual size in pixels we want it to be.
|
|
|
|
* This is not the preferred size. But they only way we can change a child is my manipulating its
|
|
|
|
* preferred size. So give the actual pixel size this return method will return figure out the preferred
|
|
|
|
* size and set it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrameInner::ResizeChildTo(nsPresContext* aPresContext,
|
1999-10-26 04:44:41 +00:00
|
|
|
nscoord& aDiff,
|
1999-09-05 20:46:59 +00:00
|
|
|
nsSplitterInfo* aChildrenBeforeInfos,
|
|
|
|
nsSplitterInfo* aChildrenAfterInfos,
|
|
|
|
PRInt32 aChildrenBeforeCount,
|
|
|
|
PRInt32 aChildrenAfterCount,
|
|
|
|
PRBool aBounded)
|
|
|
|
{
|
|
|
|
nscoord spaceLeft;
|
|
|
|
AddRemoveSpace(aDiff, aChildrenBeforeInfos,aChildrenBeforeCount,spaceLeft);
|
|
|
|
|
|
|
|
// if there is any space left over remove it from the dif we were originally given
|
|
|
|
aDiff -= spaceLeft;
|
|
|
|
AddRemoveSpace(-aDiff, aChildrenAfterInfos,aChildrenAfterCount,spaceLeft);
|
|
|
|
|
|
|
|
if (spaceLeft != 0) {
|
|
|
|
if (aBounded) {
|
|
|
|
aDiff += spaceLeft;
|
|
|
|
AddRemoveSpace(spaceLeft, aChildrenBeforeInfos,aChildrenBeforeCount,spaceLeft);
|
|
|
|
} else {
|
|
|
|
spaceLeft = 0;
|
|
|
|
}
|
|
|
|
}
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
}
|
|
|
|
|
1999-09-05 20:46:59 +00:00
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsSplitterFrameInner::MoveSplitterBy(nsPresContext* aPresContext, nscoord aDiff)
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
{
|
2001-09-18 21:47:32 +00:00
|
|
|
const nsRect& r = mOuter->mRect;
|
2003-08-04 12:39:51 +00:00
|
|
|
nsIView *v = mOuter->GetView();
|
|
|
|
nsIViewManager* vm = v->GetViewManager();
|
|
|
|
nsRect vr = v->GetBounds();
|
1999-09-14 22:17:19 +00:00
|
|
|
nsRect invalid;
|
2000-03-31 07:02:06 +00:00
|
|
|
EnsureOrient();
|
|
|
|
PRBool isHorizontal = !mOuter->IsHorizontal();
|
|
|
|
if (isHorizontal) {
|
2003-12-21 04:04:05 +00:00
|
|
|
mOuter->SetPosition(nsPoint(mSplitterPos + aDiff, r.y));
|
|
|
|
vm->MoveViewTo(v, mSplitterViewPos + aDiff, vr.y);
|
|
|
|
invalid.UnionRect(r,mOuter->mRect);
|
1999-09-05 20:46:59 +00:00
|
|
|
} else {
|
2003-12-21 04:04:05 +00:00
|
|
|
mOuter->SetPosition(nsPoint(r.x, mSplitterPos + aDiff));
|
|
|
|
vm->MoveViewTo(v, vr.x, mSplitterViewPos + aDiff);
|
|
|
|
invalid.UnionRect(r,mOuter->mRect);
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// redraw immediately only what changed. This is animation so
|
|
|
|
// it must be immediate.
|
2000-03-31 07:02:06 +00:00
|
|
|
nsBoxLayoutState state(aPresContext);
|
|
|
|
mParentBox->Redraw(state, &invalid, PR_TRUE);
|
1999-09-05 20:46:59 +00:00
|
|
|
}
|