Beispiel #1
0
void scCachedStyle::SetParaStyle( const scContUnit* cu, TypeSpec& ts )
{
	if ( ts.ptr() == cachedParaStyle_.fSpec.ptr() )
		return;
	cachedPara_ = cu;
	cachedParaStyle_.Init( ts );
}
Beispiel #2
0
void scContUnit::SetDefaultSpec( TypeSpec& ts )
{
	if ( ts.ptr() != defspec_.ptr() ) {
		defspec_ = ts;
		Mark( scREBREAK );
	}
	ForceRepaint( 0, LONG_MAX );
}
Beispiel #3
0
void scTypeSpecList::Insert( TypeSpec& ts )
{	
	for ( int i = 0; i < NumItems(); i++ ) {
		if ( ts.ptr() == (*this)[i].ptr() )
			return;
	}
	Append( ts );
}
Beispiel #4
0
void scContUnit::Insert( const CharRecord&	ch,
						 TypeSpec&			spec,
						 long				offset )
{
	CharRecordP chRec = (CharRecordP)&ch;
	fCharArray.Insert( chRec, offset, 1 );
	fSpecRun.BumpOffset( offset, fCharArray.GetNumItems() );

	if ( spec.ptr() )
		fSpecRun.ApplySpec( spec, offset, offset + 1 );

	Mark( scREBREAK );
}
Beispiel #5
0
/* return true if a spec exists on a line */
BOOL scTextline::ContainTS( TypeSpec ts )
{
	scSpecRun&		run = fPara->GetSpecRun();

	int i = run.indexAtOffset( fStartOffset );

	do {
		if ( run[i].spec().ptr() == ts.ptr() )
			return true;			
	} while ( run[++i].offset() < fEndOffset );

	return false;
}
Beispiel #6
0
void scCachedStyle::StyleInvalidateCache( TypeSpec& ts )
{
	int i;

	TypeSpec nullSpec;

	for ( i = 0; i < fEntries; i++ ) {
		if ( ts.ptr() == fCachedStyles[i].GetSpec().ptr() )
			fCachedStyles[i].Init( nullSpec );
		else
			fCachedStyles[i].Init( nullSpec );			
	}
	cachedParaStyle_.Init( nullSpec );
}
Beispiel #7
0
void scContUnit::PasteText( const scContUnit*	srcPara,
							long&				offset )
{
	try {
		if ( offset == 0 ) {
			TypeSpec ts = srcPara->GetDefaultSpec();
			if ( ts.ptr() )
				SetDefaultSpec( ts );
		}
			
			// paste the specs in
		fSpecRun.InsertRun( offset, srcPara->GetContentSize(), srcPara->GetSpecRun() );

			// paste the text in
		fCharArray.Paste( ((scContUnit*)srcPara)->GetCharArray(), offset );
		Mark( scREBREAK );

#ifdef _RUBI_SUPPORT
			// paste the rubis in
		if ( fRubiArray || srcPara->GetRubiArray() ) {
	
			if ( fRubiArray && !srcPara->GetRubiArray() )
				fRubiArray->BumpRubiData( offset, srcPara->GetContentSize() );
			else if ( !fRubiArray && srcPara->GetRubiArray() ) {
				AllocRubiArray( *srcPara->GetRubiArray() );
				fRubiArray->BumpRubiData( 0, offset );
			}
			else
				fRubiArray->Paste( *srcPara->GetRubiArray(), offset, srcPara->GetContentSize() );
		}
#endif

		scTextline* txl = FindLine( offset );
		if ( txl )
			txl->Mark( scREPAINT ); /* force repaint */

		long startOffset = offset;
		offset += srcPara->GetContentSize();

		fSpecRun.SetContentSize( GetContentSize() );
		
		fCharArray.RepairText( fSpecRun, startOffset, offset );
	} 
	catch( ... ) {
		SCDebugBreak(); // remove stuff from the paragraph
		throw;
	} 
}
Beispiel #8
0
void scCachedStyle::Init( TypeSpec& ts )
{
	if ( ts.ptr() ) {
		TSGetStyle( ts, *this );
		
		SetSpec( ts );
		fTimeStamp = ++scCachedStyle::fCacheTime;

		fPtConv 	= (REAL)GetGlyphHeight() / scBaseRLUsystem;
		fSetConv	= (REAL)GetGlyphWidth()  / scBaseRLUsystem;
		 
		InitWidths();
		ComputeExtentsnCursor();
	}
	else {
		TypeSpec nullSpec;
		SetSpec( nullSpec );
		fPtConv 	= 0;
		fSetConv	= 0;
		InitWidths();
		fTimeStamp = 0;
	}
		
}
Beispiel #9
0
void scCharArray::CharInsert( long& 		cursorSize,
							  scSpecRun&	specRun,
#ifdef _RUBI_SUPPORT
							  scRubiArray*	rubiArray,
#endif							  
							  long			offset,
							  scKeyRecord&	keyRec,
							  BOOL			textCleared,
							  TypeSpec		clearedSpec )
{
		/* can we accept a spec with this character */
	BOOL		specInsert	= false;
	long		streamSize	= 0;


#if SCDEBUG > 1
	static int doit;
	if ( doit )
		specRun.PrintRun( "scCharArray::CharInsert" );
#endif

	cursorSize	= 0;

#ifdef _RUBI_SUPPORT
		// handle character insertion
	switch ( keyRec.keycode() ) {

		case scBackSpace:
			DoBackSpace( streamSize, cursorSize, specRun, rubiArray, offset, keyRec, textCleared );
			break;

		case scForwardDelete:
			DoForwardDelete( streamSize, cursorSize, specRun, rubiArray, offset, keyRec, textCleared );
			break;
			
		case scDiscHyphen:
			DoDiscHyphen( streamSize, cursorSize, specRun, rubiArray, offset, keyRec, textCleared );
			break;
			
		case scFixAbsSpace:
		case scFixRelSpace:
			DoFixSpace( streamSize, cursorSize, specRun, rubiArray, offset, keyRec, textCleared );
			break;
			
		case scFillSpace:
		default:
			DoCharacter( streamSize, cursorSize, specRun, rubiArray, offset, keyRec, textCleared );
			specInsert = true;
			break;
	}
#else
		// handle character insertion
	switch ( keyRec.keycode() ) {

		case scBackSpace:
			DoBackSpace( streamSize, cursorSize, specRun, offset, keyRec, textCleared );
			specRun.BumpOffset( MAX( offset-1, 0 ), streamSize );
			break;

		case scForwardDelete:
			DoForwardDelete( streamSize, cursorSize, specRun, offset, keyRec, textCleared );
			specRun.BumpOffset( MAX( offset, 0 ), streamSize );
			break;
			
		case scDiscHyphen:
			DoDiscHyphen( streamSize, cursorSize, specRun, offset, keyRec, textCleared );
			specRun.BumpOffset( MAX( offset-1, 0 ), streamSize );
			break;
			
		case scFixAbsSpace:
		case scFixRelSpace:
			DoFixSpace( streamSize, cursorSize, specRun, offset, keyRec, textCleared );
			specRun.BumpOffset( MAX( offset-1, 0 ), streamSize );
			break;
			
		case scFillSpace:
		default:
			DoCharacter( streamSize, cursorSize, specRun, offset, keyRec, textCleared );
			specRun.BumpOffset( MAX( offset-1, 0 ), streamSize );
			specInsert = true;
			break;
	}
	
#endif
	
	if ( streamSize ) {
		
			// we have changed the size of the stream and now
			// we must move the specRec stuff around
		fNumItems += streamSize;

#ifdef _RUBI_SUPPORT
		if ( rubiArray )
			rubiArray->BumpRubiData( MAX( offset, 0 ), streamSize );
#endif

		/* if we inserted a spec split the specrun and insert the new one */
		if ( specInsert && keyRec.spec().ptr() ) {
			specRun.ApplySpec( keyRec.spec(), offset, offset + 1 ); 	
			specRun.SetContentSize( GetContentSize() );
		}
		else if ( textCleared && clearedSpec.ptr() ) {
			specRun.ApplySpec( clearedSpec, offset, offset + 1 );		
			specRun.SetContentSize( GetContentSize() );
		}

	}
	
	RepairText( specRun, offset, offset );
	
	Validate( );
}
Beispiel #10
0
/* ==================================================================== */
void scDBCSDetector::setDBCS( TypeSpec ts )
{
	dbcs_ = ts.ptr() ? scCachedStyle::GetCachedStyle( ts ).GetBreakLang() : false;
}