Example #1
0
/*----------------------------------------------------------------------
 * FrameMouseWheelCallback (generic callback)
 * is called when the mouse wheel is activated
 * params:
 *   + int frame :
 *   + int thot_mod_mask : what key is currently pressed
 *   [THOT_MOD_CTRL || THOT_MOD_ALT || THOT_MOD_SHIFT]
 *   + int x,y : the mouse position in the frame
 *   + int direction : >0 if wheel up <0 if wheel down
 *   + int delta : wheel delta, normally 120.
 * return:
 *   + TRUE : if the event must be forwarded to other widgets
 *   + FALSE : if the event is cought
 ----------------------------------------------------------------------*/
ThotBool FrameMouseWheelCallback( int frame, int thot_mod_mask,
                                 int direction, int delta,
                                 int x, int y )
{
  Document   document;
  View       view;

  if (direction > 0)
    {
      /* wheel mice up*/
      FrameToView (frame, &document, &view);
      if (thot_mod_mask & THOT_MOD_CTRL)
        /* if CTRL is down then zoom */
        ZoomOut (document, view);	   
      else if (thot_mod_mask & THOT_MOD_SHIFT)
        HorizontalScroll (frame, -39, 1);
      else
        VerticalScroll (frame, -39, 1);
    }
  else
    {
      /* wheel mice down */
      FrameToView (frame, &document, &view); 
      if (thot_mod_mask & THOT_MOD_CTRL)
        /* if CTRL is down then zoom */
        ZoomIn (document, view);
      else if (thot_mod_mask & THOT_MOD_SHIFT)
        HorizontalScroll (frame, 39, 1);          
      else
        VerticalScroll (frame, 39, 1);
    }
  return TRUE;
}
bool
nsListBoxBodyFrame::ReflowFinished()
{
  nsAutoScriptBlocker scriptBlocker;
  // now create or destroy any rows as needed
  CreateRows();

  // keep scrollbar in sync
  if (mAdjustScroll) {
     VerticalScroll(mYPosition);
     mAdjustScroll = false;
  }

  // if the row height changed then mark everything as a style change. 
  // That will dirty the entire listbox
  if (mRowHeightWasSet) {
    PresContext()->PresShell()->
      FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
     PRInt32 pos = mCurrentIndex * mRowHeight;
     if (mYPosition != pos) 
       mAdjustScroll = true;
    mRowHeightWasSet = false;
  }

  mReflowCallbackPosted = false;
  return true;
}
Example #3
0
/*----------------------------------------------------------------------
 * FrameVScrolledCallback (generic callback)
 * is called when the scrollbar position is changed
 * params:
 *   + int position: the new scrollbar position
 *   + int frame: the concerned frame
 ----------------------------------------------------------------------*/
void FrameVScrolledCallback (int frame, int position)
{
  int delta, x, y, width, height, left, viewed;

  if (FrameTable[frame].FrDoc &&
      documentDisplayMode[FrameTable[frame].FrDoc - 1] == NoComputedDisplay)
    return;
  ComputeDisplayedChars (frame, &x, &y, &width, &height);
  delta = position - y;
  viewed = abs (delta) / height;
  left   = abs (delta) - (int)(height * viewed);
  if (viewed <= 3)
    {
      if (delta > 0)
        delta = viewed * FrameTable[frame].FrHeight 
          + (int) ((left * FrameTable[frame].FrHeight) / height);
      else 
        delta = -(viewed * FrameTable[frame].FrHeight 
                  + (int) ((left * FrameTable[frame].FrHeight) / height));
      if (delta)
        VerticalScroll (frame, delta, 1);
    } 
  else 
    {
      delta = (int)(((float)position / (float)FrameTable[frame].FrHeight) * 100);
      JumpIntoView (frame, delta);
    }
}
Example #4
0
    LargeTextWindowStyle(const WindowStyle other):WindowStyle(other) {
        VerticalScroll();
#ifdef USE_GDI
        style |= ES_LEFT | ES_MULTILINE | ES_READONLY;
#else
        text_style |= DT_LEFT | DT_WORDBREAK;
#endif
    }
Example #5
0
/*----------------------------------------------------------------------
  PageDown scrolls one screen down.                                
  ----------------------------------------------------------------------*/
void TtcPageDown (Document document, View view)
{
  int          delta;
  int          frame;

  if (document == 0)
    return;
  frame = GetWindowNumber (document, view);
  delta = FrameTable[frame].FrHeight;
  VerticalScroll (frame, delta, 1);
}
Example #6
0
/*----------------------------------------------------------------------
  TtcLineDown scrolls one line down.                                
  ----------------------------------------------------------------------*/
void TtcLineDown (Document document, View view)
{
  int          delta;
  int          frame;

  if (document != 0)
    frame = GetWindowNumber (document, view);
  else
    frame = 0;
  delta = 13;
  VerticalScroll (frame, delta, 1);
}
Example #7
0
/* ARGSUSED */
static void 
Page(Widget w, XEvent * event, String * params, Cardinal *num_params)
{
   ScrollByLineWidget sblw = (ScrollByLineWidget) w;
   Widget bar = sblw->scroll.bar;

   if (*num_params < 1)
     return;
/*
 * If no scroll bar is visible then do not page, as the entire window is shown,
 * of scrolling has been turned off. 
 */

   if (bar == (Widget) NULL)
     return;

   switch ( params[0][0] ) {
   case 'f':
   case 'F':
     /* move one page forward */
     VerticalScroll(bar, NULL, (XtPointer)((long) bar->core.height));
     break;
   case 'b':
   case 'B':
     /* move one page backward */
     VerticalScroll(bar, NULL,  (XtPointer)(- (long) bar->core.height));
     break;
   case 'L':
   case 'l':
     /* move one line forward */
     VerticalScroll(bar, NULL, 
		(XtPointer)((long) atoi(params[1]) * sblw->scroll.font_height));
     break;
   default:
     return;
   }
}
  LargeTextWindowStyle() {
    VerticalScroll();
#ifdef USE_GDI
    style |= ES_LEFT | ES_MULTILINE | ES_READONLY;
#endif
  }
nsresult
nsListBoxBodyFrame::DoInternalPositionChanged(bool aUp, PRInt32 aDelta)
{
  if (aDelta == 0)
    return NS_OK;

  nsRefPtr<nsPresContext> presContext(PresContext());
  nsBoxLayoutState state(presContext);

  // begin timing how long it takes to scroll a row
  PRTime start = PR_Now();

  nsWeakFrame weakThis(this);
  mContent->GetDocument()->FlushPendingNotifications(Flush_Layout);
  if (!weakThis.IsAlive()) {
    return NS_OK;
  }

  {
    nsAutoScriptBlocker scriptBlocker;

    PRInt32 visibleRows = 0;
    if (mRowHeight)
      visibleRows = GetAvailableHeight()/mRowHeight;
  
    if (aDelta < visibleRows) {
      PRInt32 loseRows = aDelta;
      if (aUp) {
        // scrolling up, destroy rows from the bottom downwards
        ReverseDestroyRows(loseRows);
        mRowsToPrepend += aDelta;
        mLinkupFrame = nsnull;
      }
      else {
        // scrolling down, destroy rows from the top upwards
        DestroyRows(loseRows);
        mRowsToPrepend = 0;
      }
    }
    else {
      // We have scrolled so much that all of our current frames will
      // go off screen, so blow them all away. Weeee!
      nsIFrame *currBox = mFrames.FirstChild();
      nsCSSFrameConstructor* fc = presContext->PresShell()->FrameConstructor();
      fc->BeginUpdate();
      while (currBox) {
        nsIFrame *nextBox = currBox->GetNextSibling();
        RemoveChildFrame(state, currBox);
        currBox = nextBox;
      }
      fc->EndUpdate();
    }

    // clear frame markers so that CreateRows will re-create
    mTopFrame = mBottomFrame = nsnull; 
  
    mYPosition = mCurrentIndex*mRowHeight;
    mScrolling = true;
    presContext->PresShell()->
      FrameNeedsReflow(this, nsIPresShell::eResize, NS_FRAME_HAS_DIRTY_CHILDREN);
  }
  if (!weakThis.IsAlive()) {
    return NS_OK;
  }
  // Flush calls CreateRows
  // XXXbz there has to be a better way to do this than flushing!
  presContext->PresShell()->FlushPendingNotifications(Flush_Layout);
  if (!weakThis.IsAlive()) {
    return NS_OK;
  }

  mScrolling = false;
  
  VerticalScroll(mYPosition);

  PRTime end = PR_Now();

  PRTime difTime;
  LL_SUB(difTime, end, start);

  PRInt32 newTime;
  LL_L2I(newTime, difTime);
  newTime /= aDelta;

  // average old and new
  mTimePerRow = (newTime + mTimePerRow)/2;
  
  return NS_OK;
}
// 
// Called by nsCSSFrameConstructor when listitem content is removed.
//
void
nsListBoxBodyFrame::OnContentRemoved(nsPresContext* aPresContext,
                                     nsIContent* aContainer,
                                     nsIFrame* aChildFrame,
                                     nsIContent* aOldNextSibling)
{
  NS_ASSERTION(!aChildFrame || aChildFrame->GetParent() == this,
               "Removing frame that's not our child... Not good");
  
  if (mRowCount >= 0)
    --mRowCount;

  if (aContainer) {
    if (!aChildFrame) {
      // The row we are removing is out of view, so we need to try to
      // determine the index of its next sibling.
      PRInt32 siblingIndex = -1;
      if (aOldNextSibling) {
        nsCOMPtr<nsIContent> nextSiblingContent;
        GetListItemNextSibling(aOldNextSibling,
                               getter_AddRefs(nextSiblingContent),
                               siblingIndex);
      }
    
      // if the row being removed is off-screen and above the top frame, we need to
      // adjust our top index and tell the scrollbar to shift up one row.
      if (siblingIndex >= 0 && siblingIndex-1 < mCurrentIndex) {
        NS_PRECONDITION(mCurrentIndex > 0, "mCurrentIndex > 0");
        --mCurrentIndex;
        mYPosition = mCurrentIndex*mRowHeight;
        VerticalScroll(mYPosition);
      }
    } else if (mCurrentIndex > 0) {
      // At this point, we know we have a scrollbar, and we need to know 
      // if we are scrolled to the last row.  In this case, the behavior
      // of the scrollbar is to stay locked to the bottom.  Since we are
      // removing visible content, the first visible row will have to move
      // down by one, and we will have to insert a new frame at the top.
      
      // if the last content node has a frame, we are scrolled to the bottom
      ChildIterator iter, last;
      ChildIterator::Init(mContent, &iter, &last);
      if (iter != last) {
        iter = last;
        --iter;
        nsIContent *lastChild = *iter;
        nsIFrame* lastChildFrame = lastChild->GetPrimaryFrame();
      
        if (lastChildFrame) {
          mTopFrame = nsnull;
          mRowsToPrepend = 1;
          --mCurrentIndex;
          mYPosition = mCurrentIndex*mRowHeight;
          VerticalScroll(mYPosition);
        }
      }
    }
  }

  // if we're removing the top row, the new top row is the next row
  if (mTopFrame && mTopFrame == aChildFrame)
    mTopFrame = mTopFrame->GetNextSibling();

  // Go ahead and delete the frame.
  nsBoxLayoutState state(aPresContext);
  if (aChildFrame) {
    RemoveChildFrame(state, aChildFrame);
  }

  PresContext()->PresShell()->
    FrameNeedsReflow(this, nsIPresShell::eTreeChange,
                     NS_FRAME_HAS_DIRTY_CHILDREN);
}
Example #11
0
/*----------------------------------------------------------------------
  ShowSelectedBox shows the beginning of the selection within the frame
  and makes this frame active if the parameter active is TRUE.
  ----------------------------------------------------------------------*/
void ShowSelectedBox (int frame, ThotBool active)
{
  ViewFrame          *pFrame;
  PtrBox              pBox;
  PtrAbstractBox      pAb = NULL, pDraw;
  int                 xmin, xmax;
  int                 ymin, ymax;
  int                 x, y, dx, dy, w, h;

#ifndef _WX
  /* do not update the ActiveFrame when drawing because the selected frame is not allways the drawn one */
  if (active)
    /* make the window active */
    ChangeSelFrame (frame);
#endif /* _WX */

  pFrame = &ViewFrameTable[frame - 1];
  if (pFrame->FrSelectionBegin.VsBox != NULL && pFrame->FrReady)
    {
      pBox = pFrame->FrSelectionBegin.VsBox;
      if (pBox)
        pAb = pBox->BxAbstractBox;
      if (pBox &&
          (pBox->BxType == BoGhost ||
           pBox->BxType == BoStructGhost ||
           pBox->BxType == BoFloatGhost))
        {
          // get the position of the fist visible box
          while (pAb && pAb->AbBox &&
                 (pAb->AbBox->BxType == BoGhost ||
                  pAb->AbBox->BxType == BoStructGhost ||
                  pAb->AbBox->BxType == BoFloatGhost))
            pAb = pAb->AbFirstEnclosed;
          if (pAb)
            pBox = pAb->AbBox;
          else
            pBox = NULL;
        }
      /* Check if almost one box is displayed */
      while (pBox && pBox->BxAbstractBox &&
             pBox->BxAbstractBox->AbVisibility < pFrame->FrVisibility)
        {
          if (pBox->BxAbstractBox->AbSelected ||
              pBox == pFrame->FrSelectionBegin.VsBox)
            pBox = pBox->BxNext;
          else
            /* no box found */
            return;
        }

      // check the show of the SVG element instead of enclosed constructs
      if (pAb && FrameTable[frame].FrView == 1)
        {
          pDraw = GetParentDraw (pBox);
          if (pDraw)
            {
              pAb = pDraw;
              pBox = pAb->AbBox;
            }
        }

      if (pBox && (pBox->BxType == BoSplit || pBox->BxType == BoMulScript))
        pBox = pBox->BxNexChild;
      if (pBox)
        {
#ifdef _GL
          if (pBox->BxBoundinBoxComputed)
            {
              x = pBox->BxClipX + pFrame->FrXOrg;
              y = pBox->BxClipY + pFrame->FrYOrg;
            }
          else
#endif /* _GL*/
            {
              x = pBox->BxXOrg;
              y = pBox->BxYOrg;
            }
          GetSizesFrame (frame, &w, &h);
          xmin = pFrame->FrXOrg;
          xmax = xmin + w;
          ymin = pFrame->FrYOrg;
          ymax = ymin + h;
          /* center in the window */
          dx = pFrame->FrSelectionBegin.VsXPos;
          dy = 13;
          w /= 2;
          h /= 2;
          if (pBox->BxAbstractBox)
            {
              if (!pBox->BxAbstractBox->AbHorizPos.PosUserSpecified)
                /* the box position is not given by the user */
                {
                  if (x + dx < xmin + 10)
                    /* scroll the window */
                    HorizontalScroll (frame, x + dx - xmin - w, 0);
                  else if (x + dx > xmax - 10)
                    /* scroll the window */
                    HorizontalScroll (frame, x + dx - xmax + w, 0);
                }

              if (!pBox->BxAbstractBox->AbVertPos.PosUserSpecified)
                /* the box position is not given by the user */
                {
#ifdef _GL
                  if (pBox->BxBoundinBoxComputed &&
                      y + pBox->BxClipH < ymin + dy)
                    /* scroll the window */
                    VerticalScroll (frame, y + pBox->BxClipH - ymin - h, 0);
                    else if (y + pBox->BxHeight < ymin + dy)
                    /* scroll the window */
                    VerticalScroll (frame, y + pBox->BxHeight - ymin - h, 0);
                  else if (y > ymax - dy)
                    /* scroll the window */
                    VerticalScroll (frame, y - ymax + h, 0);
#endif /* _GL */
                }
            }
        }
    }
}
Example #12
0
/*----------------------------------------------------------------------
  IsScrolled checks if the insert point is visible in the frame.
  The parameter selection is set to 1 if the selection must be updated.
  Return:
  -  TRUE is all is okay
  -  FALSE if a scroll was done
  ----------------------------------------------------------------------*/
ThotBool IsScrolled (int frame, int selection)
{
  int                 xmin, xmax;
  int                 ymin, ymax;
  int                 x, y, dx, dy, h;
  ViewFrame          *pFrame;
  PtrBox              pBox;
  PtrAbstractBox      pDraw;
  ThotBool            result;

  pFrame = &ViewFrameTable[frame - 1];
  pBox = pFrame->FrSelectionBegin.VsBox;
  if (pBox == NULL)
    return TRUE;

  // check if the slection is within a SVG draw
  pDraw =GetParentDraw (pBox);
  if (pDraw)
    pBox = pDraw->AbBox;

#ifdef _GL
  if (pBox->BxBoundinBoxComputed)
    {
      x = pBox->BxClipX + pFrame->FrXOrg;
      y = pBox->BxClipY + pFrame->FrYOrg;
    }
  else
#endif /* _GL*/
    {
      x = pBox->BxXOrg + pFrame->FrSelectionBegin.VsXPos;
      y = pBox->BxYOrg;
    }

  h = pBox->BxHeight;
  GetSizesFrame (frame, &dx, &dy);
  xmin = pFrame->FrXOrg;
  xmax = xmin + dx;
  dx = dx / 2;
  ymin = pFrame->FrYOrg;
  ymax = ymin + dy;
  dy = dy / 2;

  /* On debloque eventuellement l'affichage */
  pFrame->FrReady = TRUE;
  if (pBox->BxAbstractBox->AbHorizPos.PosUserSpecified)
    /* C'est une creation interactive de boite, la boite sera */
    /* automatiquement placee dans la fenetre au moment de sa creation */
    result = TRUE;
  else if (x < xmin || x > xmax)
    {
      /* Deplacement du cadre le la fenetre */
      HorizontalScroll (frame, x - xmin - dx, selection);
      result = FALSE;
    }
  else
    result = TRUE;

  if (pBox->BxAbstractBox->AbVertPos.PosUserSpecified)
    /* C'est une creation interactive de boite, la boite sera */
    /* automatiquement placee dans la fenetre au moment de sa creation */
    result = TRUE;
  else if (y < ymin || y + h > ymax)
    {
      /* Deplacement du cadre le la fenetre */
      VerticalScroll (frame, y - ymin - dy, selection);
      result = FALSE;
    }
  else
    result = TRUE;
  return result;
}
Example #13
0
/*----------------------------------------------------------------------
  ShowBox displays the box pBox at the requested position in the window.
  The parameter position is:
  0 for the top of the window
  1 for the middle of the window
  2 for the bottom of the window
  When the position = 0, percent gives the percent from the top of the
  window.
  scrollUpdate is TRUE when scrollbars must be recomputed
  ----------------------------------------------------------------------*/
void ShowBox (int frame, PtrBox pBox, int position, int percent,
              ThotBool scrollUpdate)
{
  PtrAbstractBox      pBlock;
  PtrBox              pBox1;
  PtrLine             pLine;
  ViewFrame          *pFrame;
  int                 ymin, ymax;
  int                 width, height;
  int                 y, dy, h;

  if (pBox == NULL)
    return;
  pBox1 = pBox;
  pBlock = NULL;
  pLine = NULL;
  if (pBox->BxType == BoGhost ||
      pBox->BxType == BoStructGhost ||
      pBox->BxType == BoFloatGhost)
    {
      while (pBox &&
             (pBox->BxType == BoGhost ||
              pBox->BxType == BoStructGhost ||
              pBox->BxType == BoFloatGhost))
        pBox = pBox->BxAbstractBox->AbFirstEnclosed->AbBox;
      if (!pBox)
        {
          pBox = pBox1;
          while (pBox->BxType == BoGhost ||
                 pBox->BxType == BoStructGhost ||
                 pBox->BxType == BoFloatGhost)
            pBox = pBox->BxAbstractBox->AbEnclosing->AbBox;
        }
      /* manage the line instead of the box itself */
      pLine = SearchLine (pBox, frame);
      if (pLine)
        {
          pBlock = pBox->BxAbstractBox;
          while (pBlock && pBlock->AbBox->BxType != BoBlock &&
                 pBlock->AbBox->BxType != BoFloatBlock &&
                 pBlock->AbBox->BxType != BoCellBlock)
            pBlock = pBlock->AbEnclosing;
        }
    }

  if (pBox->BxType == BoSplit)
    pBox = pBox->BxNexChild;

  pFrame = &ViewFrameTable[frame - 1];
  if (pBlock && pBlock->AbBox)
    {
      y = pBlock->AbBox->BxYOrg + pLine->LiYOrg;
      h = pLine->LiHeight;
    }
  else
    {
      y = pBox->BxYOrg;
      h = pBox->BxHeight;
    }
  /* largeur et hauteur de la fenetre */
  GetSizesFrame (frame, &width, &height);
  ymin = pFrame->FrYOrg;
  ymax = ymin + height;

  /* On debloque eventuellement l'affichage */
  pFrame->FrReady = TRUE;

  if (position == 0)
    /* Affiche le haut de la boite a pourcent du haut de la fenetre */
    dy = y - ymin - ((height * percent) / 100);
  else if (position == 1)
    /* Centre le milieu de la boite sur le milieu de la fenetre */
    dy = y + (h / 2) - ymin - (height / 2);
  else
    /* Affiche en bas de la fenetre */
    dy = y + h - ymax;

  /* Il faut realiser l'affichage par scroll ou par appel explicite */
  if (dy != 0)
    VerticalScroll (frame, dy, 1);
  else if (GL_prepare (frame))
    {
      RedrawFrameBottom (frame, dy, NULL);
#ifdef _GL
      /* to be sure the scrolled page has been displayed */
      GL_Swap (frame);
#endif /* _GL */
      /* Mise a jour des ascenseurs */
      if (scrollUpdate)
        UpdateScrollbars (frame);
    }
}
Example #14
0
/*----------------------------------------------------------------------
  ShowYPosition forces the root box position in the frame.
  The parameter y gives the requested poosition
  The parameter height give the frame height
  ----------------------------------------------------------------------*/
void ShowYPosition (int frame, int y, int height)
{
  ViewFrame          *pFrame;
  PtrBox              pBox;
  int                 delta;
  int                 shift;

  pFrame = &ViewFrameTable[frame - 1];
  if (pFrame->FrAbstractBox != NULL)
    {
      pBox = pFrame->FrAbstractBox->AbBox;
      if (pBox != NULL)
        {
          /* il faut tenir compte du decalage possible de l'origine */
          /* de la fenetre par rapport au debut de l'Picture Concrete */
          shift = pFrame->FrYOrg;

          if (y == 0)	/* cadrage en haut */
            {
              if (pFrame->FrAbstractBox->AbTruncatedHead)
                JumpIntoView (frame, 0);
              else
                {
                  /* Regarde si le cadrage en haut n'est pas deja
                     effectue */
                  delta = pBox->BxYOrg - shift;
                  if (delta < 0)
                    /* Cadre la boite racine sur le bord gauche de la
                       fenetre */
                    VerticalScroll (frame, delta, 1);
                }
            }
          else if (y == height && !pFrame->FrAbstractBox->AbTruncatedTail)
            /* cadrage en bas */
            {
              /* Recupere la hauteur de la fenetre */
              GetSizesFrame (frame, &delta, &height);
              /* Regarde si le cadrage en bas n'est pas deja effectue */
              delta = pBox->BxYOrg + pBox->BxHeight - pFrame->FrYOrg -
                height;
              if (delta > 0)
                /* Cadre la boite racine en bas de la fenetreentre */
                VerticalScroll (frame, delta, 1);
            }
          else
            {
              /* Regarde si un scroll a la fin du document est demande */
              /* alors que le document n'est pas complet en fin        */
              if (y == height)
                JumpIntoView (frame, 100);
              else
                {
                  /* nouvelle position demandee */
                  delta = (int) ((float) (y * pBox->BxHeight) / (float) height);
                  /* decalage */
                  delta = delta + pBox->BxYOrg - shift;
                  VerticalScroll (frame, delta, 1);
                }
            }
        }
    }
}