Adding cursor support for column resizing.
git-svn-id: svn://10.0.0.236/trunk@44632 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -190,8 +190,7 @@ nsTreeCellFrame::HandleEvent(nsIPresContext& aPresContext,
|
||||
HandleMouseExitEvent(aPresContext, aEvent, aEventStatus);
|
||||
else if (aEvent->message == NS_MOUSE_LEFT_DOUBLECLICK)
|
||||
HandleDoubleClickEvent(aPresContext, aEvent, aEventStatus);
|
||||
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -245,7 +244,6 @@ nsTreeCellFrame::HandleMouseExitEvent(nsIPresContext& aPresContext,
|
||||
{
|
||||
if (mIsHeader)
|
||||
{
|
||||
// Nothing to do?
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -255,6 +253,49 @@ nsTreeCellFrame::HandleMouseExitEvent(nsIPresContext& aPresContext,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsTreeCellFrame::CanResize(nsPoint& aPoint) {
|
||||
nsRect rect;
|
||||
GetRect(rect);
|
||||
PRInt32 diff = (rect.x + rect.width) - aPoint.x;
|
||||
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
mContent->GetParent(*getter_AddRefs(parent));
|
||||
PRInt32 index;
|
||||
parent->IndexOf(mContent, index);
|
||||
PRInt32 count;
|
||||
parent->ChildCount(count);
|
||||
count--;
|
||||
|
||||
if ((index > 0 && diff <= 60) || ((rect.width - diff) <= 60 && index < count)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTreeCellFrame::GetCursor(nsIPresContext& aPresContext,
|
||||
nsPoint& aPoint,
|
||||
PRInt32& aCursor)
|
||||
{
|
||||
if (mIsHeader) {
|
||||
// Figure out if the point is over the resize stuff.
|
||||
nsRect rect;
|
||||
GetRect(rect);
|
||||
PRInt32 diff = (rect.x + rect.width) - aPoint.x;
|
||||
|
||||
if (CanResize(aPoint)) {
|
||||
aCursor = NS_STYLE_CURSOR_W_RESIZE;
|
||||
}
|
||||
else {
|
||||
aCursor = NS_STYLE_CURSOR_DEFAULT;
|
||||
}
|
||||
}
|
||||
else aCursor = NS_STYLE_CURSOR_DEFAULT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsTreeCellFrame::ToggleOpenClose()
|
||||
{
|
||||
|
||||
@@ -46,6 +46,10 @@ public:
|
||||
|
||||
NS_IMETHOD Destroy(nsIPresContext& aPresContext);
|
||||
|
||||
NS_IMETHOD GetCursor(nsIPresContext& aPresContext,
|
||||
nsPoint& aPoint,
|
||||
PRInt32& aCursor);
|
||||
|
||||
void Hover(nsIPresContext& presContext, PRBool isHover, PRBool notifyForReflow = PR_TRUE);
|
||||
|
||||
nsTableFrame* GetTreeFrame();
|
||||
@@ -76,10 +80,11 @@ protected:
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus& aEventStatus);
|
||||
|
||||
PRBool CanResize(nsPoint& aPoint);
|
||||
|
||||
protected:
|
||||
// Data members
|
||||
PRBool mIsHeader; // Whether or not we're a column header
|
||||
nsTreeFrame* mTreeFrame; // Our parent tree frame.
|
||||
PRBool mAllowEvents; // Whether we let events go through.
|
||||
|
||||
}; // class nsTableCellFrame
|
||||
|
||||
Reference in New Issue
Block a user