Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Public Attributes
nsSplitterFrameInner Class Reference
Inheritance diagram for nsSplitterFrameInner:
Inheritance graph
[legend]
Collaboration diagram for nsSplitterFrameInner:
Collaboration graph
[legend]

List of all members.

Public Types

enum  ResizeType { Closest, Farthest, Grow }
enum  State { Open, Collapsed, Dragging }
enum  CollapseDirection { Before, After, None }

Public Member Functions

NS_DECL_ISUPPORTS nsSplitterFrameInner (nsSplitterFrame *aSplitter)
virtual ~nsSplitterFrameInner ()
NS_IMETHOD MouseDown (nsIDOMEvent *aMouseEvent)
 Processes a mouse down event.
NS_IMETHOD MouseUp (nsIDOMEvent *aMouseEvent)
 Processes a mouse up event.
NS_IMETHOD MouseClick (nsIDOMEvent *aMouseEvent)
 Processes a mouse click event.
NS_IMETHOD MouseDblClick (nsIDOMEvent *aMouseEvent)
 Processes a mouse click event.
NS_IMETHOD MouseOver (nsIDOMEvent *aMouseEvent)
 Processes a mouse enter event.
NS_IMETHOD MouseOut (nsIDOMEvent *aMouseEvent)
 Processes a mouse leave event.
NS_IMETHOD HandleEvent (nsIDOMEvent *aEvent)
NS_IMETHOD MouseMove (nsIDOMEvent *aMouseEvent)
 Processes a mouse move event.
NS_IMETHOD DragMove (nsIDOMEvent *aMouseEvent)
 Processes a drag move event.
void MouseDrag (nsPresContext *aPresContext, nsGUIEvent *aEvent)
void MouseUp (nsPresContext *aPresContext, nsGUIEvent *aEvent)
void AdjustChildren (nsPresContext *aPresContext)
void AdjustChildren (nsPresContext *aPresContext, nsSplitterInfo *aChildInfos, PRInt32 aCount, PRBool aIsHorizontal)
void AddRemoveSpace (nscoord aDiff, nsSplitterInfo *aChildInfos, PRInt32 aCount, PRInt32 &aSpaceLeft)
void ResizeChildTo (nsPresContext *aPresContext, nscoord &aDiff, nsSplitterInfo *aChildrenBeforeInfos, nsSplitterInfo *aChildrenAfterInfos, PRInt32 aChildrenBeforeCount, PRInt32 aChildrenAfterCount, PRBool aBounded)
 Ok if we want to resize a child we will know the actual size in pixels we want it to be.
void UpdateState ()
void AddListener (nsPresContext *aPresContext)
void RemoveListener ()
ResizeType GetResizeBefore ()
ResizeType GetResizeAfter ()
State GetState ()
void Reverse (nsSplitterInfo *&aIndexes, PRInt32 aCount)
CollapseDirection GetCollapseDirection ()
void MoveSplitterBy (nsPresContext *aPresContext, nscoord aDiff)
void EnsureOrient ()
void SetPreferredSize (nsBoxLayoutState &aState, nsIBox *aChildBox, nscoord aOnePixel, PRBool aIsHorizontal, nscoord *aSize)
void handleEvent (in nsIDOMEvent event)
 This method is called whenever an event occurs of the type for which the EventListener interface was registered.

Public Attributes

nsSplitterFramemOuter
PRBool mDidDrag
PRInt32 mDragStartPx
nscoord mCurrentPos
nsIBox * mParentBox
PRBool mPressed
nsSplitterInfomChildInfosBefore
nsSplitterInfomChildInfosAfter
PRInt32 mChildInfosBeforeCount
PRInt32 mChildInfosAfterCount
State mState
nscoord mSplitterPos
nscoord mSplitterViewPos
PRBool mDragging

Detailed Description

Definition at line 95 of file nsSplitterFrame.cpp.


Member Enumeration Documentation

Enumerator:
Before 
After 
None 

Definition at line 147 of file nsSplitterFrame.cpp.

{ Before, After, None };
Enumerator:
Closest 
Farthest 
Grow 

Definition at line 145 of file nsSplitterFrame.cpp.

Enumerator:
Open 
Collapsed 
Dragging 

Definition at line 146 of file nsSplitterFrame.cpp.


Constructor & Destructor Documentation

Definition at line 101 of file nsSplitterFrame.cpp.

  {
    mOuter = aSplitter;
    mPressed = PR_FALSE;
  }

Definition at line 193 of file nsSplitterFrame.cpp.

{
  delete[] mChildInfosBefore;
  delete[] mChildInfosAfter;
}

Member Function Documentation

Definition at line 641 of file nsSplitterFrame.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nsSplitterFrameInner::AddRemoveSpace ( nscoord  aDiff,
nsSplitterInfo aChildInfos,
PRInt32  aCount,
PRInt32 aSpaceLeft 
)

Definition at line 1133 of file nsSplitterFrame.cpp.

{
  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) {
      aDiff += (c - min);
      c = min;
    } else if (c + aDiff > max) {
      aDiff -= (max - c);
      c = max;
    } else {
      c += aDiff;
      aDiff = 0;
    }

    // there is not space left? We are done
    if (aDiff == 0)
      break;
  }

  aSpaceLeft = aDiff;
}

Here is the caller graph for this function:

Definition at line 1005 of file nsSplitterFrame.cpp.

{
  EnsureOrient();
  PRBool isHorizontal = !mOuter->IsHorizontal();

  AdjustChildren(aPresContext, mChildInfosBefore, mChildInfosBeforeCount, isHorizontal);
  AdjustChildren(aPresContext, mChildInfosAfter, mChildInfosAfterCount, isHorizontal);
   
  
   // printf("----- Posting Dirty -----\n");

   
  if (realTimeDrag) {
    nsIView* view = mParentBox->GetView();

    if (!view) {
        nsPoint   offset;
        mParentBox->GetOffsetFromView(offset, &view);
        NS_ASSERTION(nsnull != view, "no view");
    }
    aPresContext->PresShell()->FlushPendingNotifications(Flush_Display);
  }
  else {
    nsBoxLayoutState state(aPresContext);
    mOuter->MarkDirty(state);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsSplitterFrameInner::AdjustChildren ( nsPresContext aPresContext,
nsSplitterInfo aChildInfos,
PRInt32  aCount,
PRBool  aIsHorizontal 
)

printf("------- AdjustChildren------\n");

Definition at line 1048 of file nsSplitterFrame.cpp.

{

  nsBoxLayoutState state(aPresContext);

  nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);

  // first set all the widths.
  nsIBox* child = nsnull;
  mOuter->GetChildBox(&child);
  while(child)
  {
    SetPreferredSize(state, child, onePixel, aIsHorizontal, nsnull);
    child->GetNextBox(&child);
  }

  // now set our changed widths.
  for (int i=0; i < aCount; i++) 
  {
    nscoord   pref       = aChildInfos[i].changed;
    nsIBox* childBox     = GetChildBoxForContent(mParentBox, aChildInfos[i].childElem);

    if (childBox) {
      SetPreferredSize(state, childBox, onePixel, aIsHorizontal, &pref);
    }
  }
}

Here is the call graph for this function:

NS_IMETHOD nsSplitterFrameInner::DragMove ( nsIDOMEvent aMouseEvent) [inline, virtual]

Processes a drag move event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseMotionListener.

Definition at line 119 of file nsSplitterFrame.cpp.

{ return NS_OK; }

Definition at line 995 of file nsSplitterFrame.cpp.

{
  PRBool isHorizontal = !(mParentBox->GetStateBits() & NS_STATE_IS_HORIZONTAL);
  if (isHorizontal)
    mOuter->mState |= NS_STATE_IS_HORIZONTAL;
  else
    mOuter->mState &= ~NS_STATE_IS_HORIZONTAL;
}

Here is the caller graph for this function:

Definition at line 932 of file nsSplitterFrame.cpp.

{
    nsString value;
    if (NS_CONTENT_ATTR_HAS_VALUE == mOuter->mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::collapse, value))
    {
     if (value.EqualsLiteral("before"))
         return Before;
     else if (value.EqualsLiteral("after"))
         return After;
     else 
       return None;
    } else {
        return None;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 200 of file nsSplitterFrame.cpp.

{
  nsString value;
  mOuter->GetContent()->GetAttr(kNameSpaceID_None,
                                nsXULAtoms::resizeafter, value);
  if (value.EqualsLiteral("farthest"))
    return Farthest;
  if (value.EqualsLiteral("grow"))
    return Grow;
  return Closest;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 183 of file nsSplitterFrame.cpp.

{
  nsString value;
  mOuter->GetContent()->GetAttr(kNameSpaceID_None,
                                nsXULAtoms::resizebefore, value);
  if (value.EqualsLiteral("farthest"))
    return Farthest;
  return Closest;
}

Here is the caller graph for this function:

Definition at line 213 of file nsSplitterFrame.cpp.

{
  nsString value;
  mOuter->GetContent()->GetAttr(kNameSpaceID_None,
                                nsXULAtoms::state, value);
  if (value.EqualsLiteral("dragging"))
    return Dragging;
  if (value.EqualsLiteral("collapsed"))
    return Collapsed;
  return Open;
}

Here is the call graph for this function:

Here is the caller graph for this function:

This method is called whenever an event occurs of the type for which the EventListener interface was registered.

Parameters:
evtThe Event contains contextual information about the event. It also contains the stopPropagation and preventDefault methods which are used in determining the event's flow and default action.

Definition at line 115 of file nsSplitterFrame.cpp.

{ return NS_OK; }
NS_IMETHOD nsSplitterFrameInner::MouseClick ( nsIDOMEvent aMouseEvent) [inline, virtual]

Processes a mouse click event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 111 of file nsSplitterFrame.cpp.

{ return NS_OK; }
NS_IMETHOD nsSplitterFrameInner::MouseDblClick ( nsIDOMEvent aMouseEvent) [inline, virtual]

Processes a mouse click event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 112 of file nsSplitterFrame.cpp.

{ return NS_OK; }

Processes a mouse down event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 720 of file nsSplitterFrame.cpp.

{  
  nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));

  PRUint16 button = 0;
  mouseEvent->GetButton(&button);

  // only if left button
  if (button != 0)
     return NS_OK;

  nsAutoString disabled;
  mOuter->GetContent()->GetAttr(kNameSpaceID_None,
                                nsHTMLAtoms::disabled, disabled);
  if (disabled.EqualsLiteral("true"))
    return NS_OK;

  nsBoxLayoutState state(mOuter->mPresContext);
  mCurrentPos = 0;
  mPressed = PR_TRUE;

  mDidDrag = PR_FALSE;

  mOuter->GetParentBox(&mParentBox);
  
  // get our index
  nscoord childIndex = nsFrameNavigator::IndexOf(mOuter->mPresContext, mParentBox, mOuter);
  PRInt32 childCount = nsFrameNavigator::CountFrames(mOuter->mPresContext, mParentBox);

  // if its 0 or the last index then stop right here.
  if (childIndex == 0 || childIndex == childCount-1) {
    mPressed = PR_FALSE;
    return NS_OK;
  }

  EnsureOrient();
  PRBool isHorizontal = !mOuter->IsHorizontal();
  
  ResizeType resizeBefore = GetResizeBefore();
  ResizeType resizeAfter  = GetResizeAfter();

  delete[] mChildInfosBefore;
  delete[] mChildInfosAfter;
  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;

  nsIBox* childBox = nsnull;
  mParentBox->GetChildBox(&childBox); 

  while (nsnull != childBox) 
  { 
    nsIContent* content = childBox->GetContent();
    nsCOMPtr<nsIAtom> atom;
    nsresult rv;
    nsCOMPtr<nsIXBLService> xblService = 
             do_GetService("@mozilla.org/xbl;1", &rv);

    if (NS_SUCCEEDED(rv) && xblService) {
      PRInt32 dummy;
      xblService->ResolveTag(content, &dummy, getter_AddRefs(atom));
    } else
      atom = content->Tag();

    // skip over any splitters
    if (atom != nsXULAtoms::splitter) { 
        nsSize prefSize(0,0);
        nsSize minSize(0,0);
        nsSize maxSize(0,0);
        nscoord flex = 0;

        childBox->GetPrefSize(state, prefSize);
        childBox->GetMinSize(state, minSize);
        childBox->GetMaxSize(state, maxSize);
        nsBox::BoundsCheck(minSize, prefSize, maxSize);

        mOuter->AddMargin(childBox, minSize);
        mOuter->AddMargin(childBox, prefSize);
        mOuter->AddMargin(childBox, maxSize);

        childBox->GetFlex(state, flex);

        nsMargin margin(0,0,0,0);
        childBox->GetMargin(margin);
        nsRect r(childBox->GetRect());
        r.Inflate(margin);

        nsAutoString fixed, hidden;
        content->GetAttr(kNameSpaceID_None, nsXULAtoms::fixed, fixed);
        // We need to check for hidden attribute too, since treecols with
        // the hidden="true" attribute are not really hidden, just collapsed
        content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::hidden, hidden);

        NS_NAMED_LITERAL_STRING(attrTrue, "true");
        if (!attrTrue.Equals(fixed) && !attrTrue.Equals(hidden)) {
            if (count < childIndex) {
                mChildInfosBefore[mChildInfosBeforeCount].childElem = content;
                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++;
            } else if (count > childIndex) {
                mChildInfosAfter[mChildInfosAfterCount].childElem = content;
                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;
                mChildInfosAfter[mChildInfosAfterCount].changed = mChildInfosAfter[mChildInfosAfterCount].current;
                mChildInfosAfterCount++;
            }
        } 
    }
    
    rv = childBox->GetNextBox(&childBox);
    NS_ASSERTION(rv == NS_OK,"failed to get next child");
    count++;
  }

  PRBool isNormalDirection = PR_TRUE;
  mParentBox->GetDirection(isNormalDirection);
  if (!isNormalDirection) {
    // 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;
  }

  // if the resizebefore is closest we must reverse the list because the first child in the list
  // is the Farthest we want the first child to be the closest.
  if (resizeBefore == Closest)
     Reverse(mChildInfosBefore, mChildInfosBeforeCount);

  // 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)
     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;

  nsRect vr = mOuter->GetView()->GetBounds();

  PRInt32 c = 0;
  if (isHorizontal) {
     mouseEvent->GetClientX(&c);
     mSplitterPos = mOuter->mRect.x;
     mSplitterViewPos = vr.x;
  } else {
     mouseEvent->GetClientY(&c);
     mSplitterPos = mOuter->mRect.y;
     mSplitterViewPos = vr.y;
  }

  mDragStartPx = c;
    
  //printf("Pressed mDragStartPx=%d\n",mDragStartPx);

  mOuter->CaptureMouse(mOuter->mPresContext, PR_TRUE);

  return NS_OK;
}

Here is the call graph for this function:

void nsSplitterFrameInner::MouseDrag ( nsPresContext aPresContext,
nsGUIEvent aEvent 
)

Definition at line 526 of file nsSplitterFrame.cpp.

{
  if (mDragging) {

    //printf("Dragging\n");

    PRBool isHorizontal = !mOuter->IsHorizontal();
    // convert coord to pixels
    nscoord pos = isHorizontal ? aEvent->point.x : aEvent->point.y;

    // mDragStartPx is in pixels and is in our client area's coordinate system.
    // so we need to first convert it so twips and then get it into our
    // coordinate system.

    // convert start to twips
    nscoord start = aPresContext->IntScaledPixelsToTwips(mDragStartPx);

    // get it into our coordinate system (that is, the coordinate
    // system that aEvent->point is in)
    nsIView* eventCoordView;
    nsPoint offsetFromView;
    mOuter->GetOffsetFromView(offsetFromView, &eventCoordView);
    NS_ASSERTION(eventCoordView, "No view?");

    nsIView* rootView;
    aPresContext->GetViewManager()->GetRootView(rootView);
    NS_ASSERTION(rootView, "No root view?");
    
    nsPoint eventCoordViewOffset = eventCoordView->GetOffsetTo(rootView);
    
    start -= (isHorizontal ? eventCoordViewOffset.x : eventCoordViewOffset.y);
    
    // take our current position and substract the start location
    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();
    CollapseDirection dir = GetCollapseDirection();

    // if we are in a collapsed position
    if (realTimeDrag && ((oldPos > 0 && oldPos > pos && dir == After) || (oldPos < 0 && oldPos < pos && dir == Before)))
    {
      // and we are not collapsed then collapse
      if (currentState == Dragging) {
        if (oldPos > 0 && oldPos > pos)
        {
          //printf("Collapse right\n");
          if (GetCollapseDirection() == After) 
          {
            mOuter->mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::state, NS_LITERAL_STRING("collapsed"), PR_TRUE);
          }

        } else if (oldPos < 0 && oldPos < pos)
        {
          //printf("Collapse left\n");
          if (GetCollapseDirection() == Before) 
          {
            mOuter->mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::state, NS_LITERAL_STRING("collapsed"), PR_TRUE);
          }
        }
      }
    } else {
      // if we are not in a collapsed position and we are not dragging make sure
      // we are dragging.
      if (currentState != Dragging)
        mOuter->mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::state, NS_LITERAL_STRING("dragging"), PR_TRUE);
      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);
    */

    /*
      nsIPresShell *shell = aPresContext->PresShell();

      shell->AppendReflowCommand(mOuter->mParent, eReflowType_StyleChanged,
                                 nsnull);
     
      mOuter->mState |= NS_FRAME_IS_DIRTY;
      mOuter->mParent->ReflowDirtyChild(shell, mOuter);
    */
    mDidDrag = PR_TRUE;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Processes a mouse move event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseMotionListener.

Definition at line 901 of file nsSplitterFrame.cpp.

{  
  //printf("Mouse move\n");

  if (!mPressed)
      return NS_OK;
  
  if (mDragging)
    return NS_OK;

  mOuter->mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::state, NS_LITERAL_STRING("dragging"), PR_TRUE);

  RemoveListener();
  mDragging = PR_TRUE;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsSplitterFrameInner::MouseOut ( nsIDOMEvent aMouseEvent) [inline, virtual]

Processes a mouse leave event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 114 of file nsSplitterFrame.cpp.

{ return MouseMove(aMouseEvent); }

Here is the call graph for this function:

NS_IMETHOD nsSplitterFrameInner::MouseOver ( nsIDOMEvent aMouseEvent) [inline, virtual]

Processes a mouse enter event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 113 of file nsSplitterFrame.cpp.

{ return NS_OK; }
nsresult nsSplitterFrameInner::MouseUp ( nsIDOMEvent aMouseEvent) [virtual]

Processes a mouse up event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMMouseListener.

Definition at line 710 of file nsSplitterFrame.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nsSplitterFrameInner::MouseUp ( nsPresContext aPresContext,
nsGUIEvent aEvent 
)

Definition at line 496 of file nsSplitterFrame.cpp.

{
  if (mDragging) {
    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)
      mOuter->mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::state, EmptyString(), PR_TRUE);

    mPressed = PR_FALSE;

    // if we dragged then fire a command event.
    if (mDidDrag) {
      nsCOMPtr<nsIDOMXULElement> element = do_QueryInterface(mOuter->GetContent());
      element->DoCommand();
    }

    //printf("MouseUp\n");
  }

  delete[] mChildInfosBefore;
  delete[] mChildInfosAfter;
  mChildInfosBefore = nsnull;
  mChildInfosAfter = nsnull;
}

Here is the call graph for this function:

Definition at line 1200 of file nsSplitterFrame.cpp.

{
  const nsRect& r = mOuter->mRect;
  nsIView *v = mOuter->GetView();
  nsIViewManager* vm = v->GetViewManager();
  nsRect vr = v->GetBounds();
  nsRect invalid;
  EnsureOrient();
  PRBool isHorizontal = !mOuter->IsHorizontal();
  if (isHorizontal) {
    mOuter->SetPosition(nsPoint(mSplitterPos + aDiff, r.y));
    vm->MoveViewTo(v, mSplitterViewPos + aDiff, vr.y);
    invalid.UnionRect(r,mOuter->mRect);
  } else {
    mOuter->SetPosition(nsPoint(r.x, mSplitterPos + aDiff));
    vm->MoveViewTo(v, vr.x, mSplitterViewPos + aDiff);
    invalid.UnionRect(r,mOuter->mRect);
  }

  // redraw immediately only what changed. This is animation so 
  // it must be immediate.
  nsBoxLayoutState state(aPresContext);
  mParentBox->Redraw(state, &invalid, PR_TRUE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 651 of file nsSplitterFrame.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nsSplitterFrameInner::ResizeChildTo ( nsPresContext aPresContext,
nscoord aDiff,
nsSplitterInfo aChildrenBeforeInfos,
nsSplitterInfo aChildrenAfterInfos,
PRInt32  aChildrenBeforeCount,
PRInt32  aChildrenAfterCount,
PRBool  aBounded 
)

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.

Definition at line 1173 of file nsSplitterFrame.cpp.

{ 
  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;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 920 of file nsSplitterFrame.cpp.

{
    nsSplitterInfo* infos = new nsSplitterInfo[aCount];

    for (int i=0; i < aCount; i++)
       infos[i] = aChildInfos[aCount - 1 - i];

    delete[] aChildInfos;
    aChildInfos = infos;
}

Here is the caller graph for this function:

void nsSplitterFrameInner::SetPreferredSize ( nsBoxLayoutState aState,
nsIBox *  aChildBox,
nscoord  aOnePixel,
PRBool  aIsHorizontal,
nscoord aSize 
)

Definition at line 1078 of file nsSplitterFrame.cpp.

{
  //printf("current=%d, pref=%d", current/onePixel, pref/onePixel);
 
  nscoord current = 0;

  nsRect rect(aChildBox->GetRect());
  if (aIsHorizontal) 
    current = rect.width;
  else
    current = rect.height;

  nscoord pref = 0;

  if (!aSize)
  {
    if (aIsHorizontal) 
      pref = rect.width;
    else
      pref = rect.height;
  } else {
    pref = *aSize;
  }

  nsMargin margin(0,0,0,0);
  aChildBox->GetMargin(margin);

  nsCOMPtr<nsIAtom> attribute;

  if (aIsHorizontal) {
    pref -= (margin.left + margin.right);
    attribute = nsHTMLAtoms::width;
  } else {
    pref -= (margin.top + margin.bottom);
    attribute = nsHTMLAtoms::height;
  }

  nsIContent* content = aChildBox->GetContent();

  // set its preferred size.
  nsAutoString prefValue;
  prefValue.AppendInt(pref/aOnePixel);
  nsAutoString oldValue;
  content->GetAttr(kNameSpaceID_None, attribute, oldValue);
  if (oldValue.Equals(prefValue))
     return;

  nsWeakFrame weakBox(aChildBox);
  content->SetAttr(kNameSpaceID_None, attribute, prefValue, PR_TRUE);
  ENSURE_TRUE(weakBox.IsAlive());
  aChildBox->MarkDirty(aState);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 949 of file nsSplitterFrame.cpp.

{
  // State Transitions:
  //   Open      -> Dragging
  //   Open      -> Collapsed
  //   Collapsed -> Open
  //   Collapsed -> Dragging
  //   Dragging  -> Open
  //   Dragging  -> Collapsed (auto collapse)

  State newState = GetState(); 

  if (newState == mState) {
    // No change.
    return;
  }

  CollapseDirection direction = GetCollapseDirection();
  if (direction != None) {
    nsIBox* splitter = mOuter;
    // Find the splitter's immediate sibling.
    nsIBox* splitterSibling =
      nsFrameNavigator::GetChildBeforeAfter(mOuter->mPresContext, splitter,
                                            (direction == Before));
    if (splitterSibling) {
      nsIContent* sibling = splitterSibling->GetContent();
      if (sibling) {
        if (mState == Collapsed) {
          // Collapsed -> Open
          // Collapsed -> Dragging
          sibling->UnsetAttr(kNameSpaceID_None, nsXULAtoms::collapsed,
                             PR_TRUE);
        } else if ((mState == Open || mState == Dragging) 
                   && newState == Collapsed) {
          // Open -> Collapsed
          // Dragging -> Collapsed
          sibling->SetAttr(kNameSpaceID_None, nsXULAtoms::collapsed,
                           NS_LITERAL_STRING("true"), PR_TRUE);
        }
      }
    }
  }
  mState = newState;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 169 of file nsSplitterFrame.cpp.

Definition at line 171 of file nsSplitterFrame.cpp.

Definition at line 168 of file nsSplitterFrame.cpp.

Definition at line 170 of file nsSplitterFrame.cpp.

Definition at line 165 of file nsSplitterFrame.cpp.

Definition at line 163 of file nsSplitterFrame.cpp.

Definition at line 175 of file nsSplitterFrame.cpp.

Definition at line 164 of file nsSplitterFrame.cpp.

Definition at line 162 of file nsSplitterFrame.cpp.

Definition at line 166 of file nsSplitterFrame.cpp.

Definition at line 167 of file nsSplitterFrame.cpp.

Definition at line 173 of file nsSplitterFrame.cpp.

Definition at line 174 of file nsSplitterFrame.cpp.

Definition at line 172 of file nsSplitterFrame.cpp.


The documentation for this class was generated from the following file: