NS_IMETHODIMP
sbLocalDatabaseMediaListViewSelection::SelectOnly(PRInt32 aIndex)
{
  NS_ENSURE_ARG_RANGE(aIndex, 0, (PRInt32) mLength - 1);
  nsresult rv;

  mCurrentIndex = aIndex;
  rv = GetUniqueIdForIndex(mCurrentIndex, mCurrentUID);
  NS_ENSURE_SUCCESS(rv, rv);

  mSelection.Clear();
  mSelectionIsAll = PR_FALSE;

  rv = AddToSelection(aIndex);
  NS_ENSURE_SUCCESS(rv, rv);

  CheckSelectAll();

  NOTIFY_LISTENERS(OnSelectionChanged, ());

#ifdef DEBUG
  LogSelection();
#endif

  return NS_OK;
}
NS_IMETHODIMP
sbLocalDatabaseMediaListViewSelection::Toggle(PRInt32 aIndex)
{
  NS_ENSURE_ARG_RANGE((PRInt32) aIndex, 0, (PRInt32) mLength - 1);
  nsresult rv;

  mCurrentIndex = aIndex;
  rv = GetUniqueIdForIndex(mCurrentIndex, mCurrentUID);
  NS_ENSURE_SUCCESS(rv, rv);

  // If have an all selection, fill the selection with everything but the
  // toggled index
  if (mSelectionIsAll) {
    mSelectionIsAll = PR_FALSE;
    for (PRUint32 i = 0; i < mLength; i++) {
      if (i != (PRUint32) aIndex) {
        rv = AddToSelection(i);
        NS_ENSURE_SUCCESS(rv, rv);
      }
    }
    return NS_OK;
  }

  // Otherwise, simply do the toggle
  PRBool isSelected;
  rv = IsIndexSelected(aIndex, &isSelected);
  NS_ENSURE_SUCCESS(rv, rv);

  if (isSelected) {
    rv = RemoveFromSelection(aIndex);
    NS_ENSURE_SUCCESS(rv, rv);
  }
  else {
    rv = AddToSelection(aIndex);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  CheckSelectAll();

  NOTIFY_LISTENERS(OnSelectionChanged, ());

#ifdef DEBUG
  LogSelection();
#endif

  return NS_OK;
}
Exemplo n.º 3
0
/* DoSelectAll()
 * ====================================================================
 */
void
DoSelectAll( void )
{
    int  index;
    int  ocount;
    int  unselected;
    
    /* Count Number of Selected Fonts */
    ocount = CountSelectedFonts( available_list, SPD_FONT );
    unselected = available_count - ocount;
    
    if( !unselected )
    {
        form_alert( 1, nosel );
        ChangeButton( ad_inactive, ISELECT, FALSE );
        return;
    }
    
    if( form_alert( 1, selall ) == 1 )
    {
       SelectAllUnusedFonts();
       
       index = Get_Findex( available_list, Active_Slit[0] );

       mover_setup( available_list, available_count,
		    IBASE, ISLIDER, IUP, IDOWN,
		    ILINE0, ILINE13, ILINE, index, INACTIVE_HEIGHT );

       RedrawObject( tree, IBASE );
       Objc_draw( tree, ILINE, MAX_DEPTH, NULL );

       if( IsDisabled( IINSTALL ) )
          ChangeButton( ad_inactive, IINSTALL, TRUE );
    
       if( IsDisabled( ICONFIG ) )
          ChangeButton( ad_inactive, ICONFIG, TRUE );
    }   
    CheckSelectAll( TRUE );
}
NS_IMETHODIMP
sbLocalDatabaseMediaListViewSelection::SelectRange(PRInt32 aStartIndex,
                                                   PRInt32 aEndIndex)
{
  TRACE(("sbLocalDatabaseMediaListViewSelection[0x%.8x] - SelectRange(%d, %d)",
         this, aStartIndex, aEndIndex));

  NS_ENSURE_ARG_RANGE(aStartIndex, 0, (PRInt32) mLength - 1);
  NS_ENSURE_ARG_RANGE(aEndIndex,   0, (PRInt32) mLength - 1);

  nsresult rv;

  if (mSelectionIsAll) {
    return NS_OK;
  }

  mCurrentIndex = aEndIndex;
  rv = GetUniqueIdForIndex(mCurrentIndex, mCurrentUID);
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 start = PR_MIN(aStartIndex, aEndIndex);
  PRInt32 end   = PR_MAX(aStartIndex, aEndIndex);

  for (PRInt32 i = start; i <= end; i++) {
    rv = AddToSelection((PRUint32) i);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  CheckSelectAll();

  NOTIFY_LISTENERS(OnSelectionChanged, ());

#ifdef DEBUG
  LogSelection();
#endif

  return NS_OK;
}
Exemplo n.º 5
0
/* DoAvailable()
 * ===================================================================
 */
void
DoAvailable( void )
{
    PrevTree = ad_front;
    Reset_Tree( ad_inactive );


    NoExit( IINSTALL );
    Disable( IINSTALL );
    
    NoExit( ICONFIG );
    Disable( ICONFIG );


    /* Read in the UnUsed fonts, if necessary */
    
    if( !Fonts_Loaded )
    {
      MF_Save();
      Scan_Message( ad_scan, TRUE );	

      read_fonts( TRUE, FALSE );

      Scan_Message( ad_scan, FALSE );
      MF_Restore();
    }  

    CheckSelectAll( FALSE );
    
    mover_setup( available_list, available_count,
		 IBASE, ISLIDER, IUP, IDOWN,
		 ILINE0, ILINE13, ILINE, 0, INACTIVE_HEIGHT );
    HideObj( ILINE );		 
    Objc_draw( tree, ROOT, MAX_DEPTH, NULL ); 
    ShowObj( ILINE );
    RedrawBase( tree, ILINE );
}
Exemplo n.º 6
0
/* MoveToInstalled()
 * ====================================================================
 * Move any Available fonts to the Installed List.
 * type -> 0 -> USE Available list CALLS
 *      -> 1 -> Skip available list calls
 */
void
MoveToInstalled( int flag )
{
    FON_PTR curptr;
    FON_PTR xcurptr;
    int     index;

    curptr = available_list;

    /* Try to maintain the top node displayed to remain that way if
     * at all possible.
     */
    xcurptr = Active_Slit[ 0 ];
    if( curptr && xcurptr )
    	index = Get_Findex( curptr, xcurptr );

    /* Go through the list looking for selected nodes ( AFLAG == TRUE )
     * and set their SEL() to FALSE.
     * Where SEL == TRUE means installed. and SEL == FALSE means 
     * available.
     * Set MakeWidth Tables flag if moving Outline Fonts TO INSTALLED!
     */
    while( curptr )
    {
       if( AFLAG( curptr ) )
       {
           if( FTYPE( curptr ) == SPD_FONT )
             MakeWidthFlag = TRUE;
           SEL( curptr ) = TRUE;
       }    
       curptr = FNEXT( curptr );
    }


    /* Now, fix up the linked list for both the
     * available and installed fonts.
     */
    free_arena_links();
    installed_count = build_list( &installed_list, &installed_last, ACTIVE );
    available_count = build_list( &available_list, &available_last, INACTIVE );

    /* Prompt to save SYS files */
    SetChangeFlag();

    if( !flag )
    {
       mover_setup( available_list, available_count,
		    IBASE, ISLIDER, IUP, IDOWN,
		    ILINE0, ILINE13, ILINE, index, INACTIVE_HEIGHT );

       RedrawObject( tree, IBASE );
       Objc_draw( tree, ILINE, MAX_DEPTH, NULL );
    
       if( !IsDisabled( IINSTALL ) )
          ChangeButton( ad_inactive, IINSTALL, FALSE );
    
       if( !IsDisabled( ICONFIG ) )
          ChangeButton( ad_inactive, ICONFIG, FALSE );
          
       CheckSelectAll( TRUE );
    }      
}