コード例 #1
0
ファイル: Sctextch.cpp プロジェクト: jimmccurdy/ArchiveGit
long scCharArray::ReadAPPText( scSpecRun&			specRun,
							   stTextImportExport&	appText )

{
	TypeSpec	lastTypespec,
				typespec;
	UCS2	ch;
	UCS2	lastCh;
	CharRecord	chRec;
	long		chCount;
	int 		ret = 0;
	int 		i	= 0;
	CharRecord	chRecBuf[kMaxCharBuf];
	
	for ( lastCh = '\0', chCount = 0; ( ret = appText.GetChar( ch, typespec ) ) > 0; chCount++ ){

		if ( lastTypespec != typespec ) {
			specRun.ApplySpec( typespec, chCount, LONG_MAX ); /* set style to end of run */
			lastTypespec = typespec;
		}

			// PARAGRAPH BREAK
//		if ( ( lastCh == scHardReturn && ch == scHardReturn ) || ch == scParaEnd )
		if ( ch == scParaEnd )
			break;
			
		lastCh = ch;

		ch = CMinputMap( ch );

		chRecBuf[i].character		= ch;
		chRecBuf[i].ClearFlags();
		chRecBuf[i++].escapement	= 0;

		if ( i == kMaxCharBuf ) {
			InsertAt( GetNumItems() - 1, (ElementPtr)chRecBuf, kMaxCharBuf );
			i = 0;
		}
	}
	
	if ( i )
		InsertAt( GetNumItems() - 1, (ElementPtr)chRecBuf, i );

	Validate();
	return ret;
}
コード例 #2
0
bool ListedTextItems::HasState( int item_no, int state_no )
{
    if ( item_no >=0 && item_no<GetNumItems() )
    {
        return _skins.Get().Exists(state_no) || _fonts.Get().Exists(state_no);
    }
    return false;
}
コード例 #3
0
ファイル: tb_list.cpp プロジェクト: BibleUs/turbobadger
void *TBListBackend::RemoveFast(int index)
{
	assert(index >= 0 && index < GetNumItems());
	void *data = m_data->list[index];
	m_data->list[index] = m_data->list[m_data->num - 1];
	m_data->num--;
	return data;
}
コード例 #4
0
Rect TableListedItems::GetItemBound( int item_no  ) const
{
    if ( item_no >=0 && item_no<GetNumItems() )  
    {
        return TableWidget::RowRect(item_no);
    }
    else return Rect(); 
}
コード例 #5
0
Rect ListedTextItems::GetItemBound( int item_no  ) const
{
    if ( item_no >=0 && item_no<GetNumItems() )  
    {
        return Rect( 0, _entry_height * item_no, GetWidth(), _entry_height );  
    }
    else return Rect(); 
}
コード例 #6
0
void ListedTextItems::SetText( int item_no, const Text &text )
{
    if ( item_no >=0 && item_no<GetNumItems() )  
    { 
        GetItem(item_no)._caption=text; 
        CheckSize(text);
    }
}
コード例 #7
0
ファイル: tb_list.cpp プロジェクト: BibleUs/turbobadger
void *TBListBackend::Remove(int index)
{
	assert(index >= 0 && index < GetNumItems());
	void *data = m_data->list[index];
	if(index < m_data->num - 1)
		memmove(&m_data->list[index], &m_data->list[index + 1], (m_data->num - index - 1) * sizeof(void*));
	m_data->num--;
	return data;
}
コード例 #8
0
/** Destructor.
 * All elements which are not removed from the priority-queue
 * get deleted automatically.
 * 
 */
WOscPriorityQueue::~WOscPriorityQueue()
{

	/* empty queue as long there are items in the queue*/
	while( GetNumItems() > 0 )
		delete RemoveEarliestItem();

	delete [] m_list;
}
コード例 #9
0
ファイル: Sctextch.cpp プロジェクト: jimmccurdy/ArchiveGit
void scCharArray::DoCharacter( long&		streamSize,
							   long&		cursorSize,
							   scSpecRun&	specRun,
#ifdef _RUBI_SUPPORT
							   scRubiArray* rubiArray,
#endif							   
							   long 		offset,
							   scKeyRecord& keyRec,
							   BOOL 		textCleared )
{
	scHandleArrayLock	h( this );
	CharRecordP chRec = (CharRecordP)*h;
	
	chRec +=  offset;

	if ( keyRec.type() == scKeyRecord::overstrike && chRec->character ) {
		keyRec.replacedchar() = chRec->character;
		keyRec.replacedfield() = chRec->flags.GetField();
	}
	else {
		memmove( chRec + 1, chRec, (GetNumItems() - offset) * sizeof(CharRecord) );
		streamSize	= 1;
		keyRec.replacedchar() = 0;
	}

	chRec->character =	keyRec.keycode();
	chRec->ClearFlags();
	chRec->flags.SetField( keyRec.field() );

	if ( offset == 0 ) {
			// why is this here
		switch ( chRec->character ) {
			case scNoBreakSpace:
			case scFigureSpace:
			case scThinSpace:
			case scEnSpace:
			case scEmSpace:
				{ 
					TypeSpec ts = specRun.SpecAtOffset( 0 );
					scCachedStyle::GetCachedStyle( ts );
					chRec->escapement = scCachedStyle::GetCurrentCache().GetEscapement( chRec->character );
				}
				break;
			default:
				break;
		}
	}

	if ( !keyRec.restoreselect() ) { /* if not replacing forward deletion */
		cursorSize = 1;
		if ( !keyRec.replacedchar() )
			keyRec.replacedchar() = scBackSpace;
	}
	else
		keyRec.replacedchar() = scForwardDelete;
}
コード例 #10
0
bool TableListedItems::SetState( int item_no, int state_no )
{
    if ( item_no>=0 && item_no<GetNumItems() )
    {
        _states[item_no] = state_no;
        SetDirty( TableWidget::RowRect(item_no) );
        return true;
    }
    return false;
}
コード例 #11
0
ファイル: tb_list.cpp プロジェクト: BibleUs/turbobadger
int TBListBackend::Find(void *data) const
{
	int num = GetNumItems();
	for(int i = 0; i < num; i++)
	{
		if (Get(i) == data)
			return i;
	}
	return -1;
}
コード例 #12
0
bool ListedTextItems::SetState( int item_no, int state_no )
{
    if ( item_no >=0 && item_no<GetNumItems() )  
    { 
        GetItem(item_no)._state=state_no;  
        SetDirty();
        return true;
    }
    else return false;
}
コード例 #13
0
ファイル: hgeguictrls.cpp プロジェクト: Psih11rus/hge
char *hgeGUIListbox::GetItemText(int n)
{
	int i;
	hgeGUIListboxItem *pItem=pItems;

	if(n<0 || n>=GetNumItems()) return 0;

	for(i=0;i<n;i++) pItem=pItem->next;

	return pItem->text;
}
コード例 #14
0
ファイル: tb_list.cpp プロジェクト: BibleUs/turbobadger
bool TBListBackend::Add(void *data, int index)
{
	assert(index >= 0 && index <= GetNumItems());
	if (!GrowIfNeeded())
		return false;
	if (index < m_data->num)
		memmove(&m_data->list[index + 1], &m_data->list[index], (m_data->num - index) * sizeof(void*));
	m_data->list[index] = data;
	m_data->num++;
	return true;
}
コード例 #15
0
ファイル: Compression.cpp プロジェクト: AlVar009/bootil
			void File::ExtractToFolder( const BString & Folder )
			{
				int iItems = GetNumItems();

				for ( int i = 0; i < iItems; i++ )
				{
					BString FileName = GetFileName( i );
					BString LocalFolder = String::File::GetStripFilename( FileName );
					Bootil::File::CreateFolder( Folder + "/" + LocalFolder );
					ExtractFile( i, Folder + "/" + FileName );
				}
			}
コード例 #16
0
ファイル: hgeguictrls.cpp プロジェクト: kvakvs/hge
char* hgeGUIListbox::GetItemText(const int n) {
    hgeGUIListboxItem* pItem = items_2_;

    if (n < 0 || n >= GetNumItems()) {
        return nullptr;
    }

    for (int i = 0; i < n; i++) {
        pItem = pItem->next;
    }

    return pItem->text;
}
コード例 #17
0
void hgeGUIListbox::DeleteItem(int n)
{
	hgeGUIListboxItem *pItem=pItems, *pPrev=0;

	if(n<0 || n>=GetNumItems()) return;

	while(pItem) { pPrev=pItem;	pItem=pItem->next; }

	if(pPrev) pPrev->next=pItem->next;
	else pItems=pItem->next;
	delete pItem;
	nItems--;
}
コード例 #18
0
ファイル: Sctextch.cpp プロジェクト: jimmccurdy/ArchiveGit
int scCharArray::Insert( const USTR& str,
						  int32 			  start,
						  int32 			  end )
{
	long	oldNumItems = fNumItems;
	scAssert( end < fNumItems );

	int32	diff = ( str.len - ( end - start ) );
	
	if ( diff > 0 )
		SetNumSlots( GetNumItems() + diff );

	{
		scHandleArrayLock	h( this );
		CharRecordP 		dstCh = (CharRecordP)*h;

		memmove( dstCh + end + diff,
				 dstCh + end,
				 ( oldNumItems - end ) * fElemSize );


	
		dstCh += start;

		for ( UINT i = 0; i < str.len; i++ ) {
			dstCh[i].ClearFlags();
			dstCh[i].character = str.ptr[i];
		}
	}

	if ( diff < 0 )
		SetNumSlots( GetNumItems() + diff );

	fNumItems += diff;

	return diff;
}
コード例 #19
0
ファイル: GUIControlGroupList.cpp プロジェクト: anaconda/xbmc
std::string CGUIControlGroupList::GetLabel(int info) const
{
  switch (info)
  {
  case CONTAINER_CURRENT_ITEM:
    return StringUtils::Format("%i", GetSelectedItem());
  case CONTAINER_NUM_ITEMS:
    return StringUtils::Format("%i", GetNumItems());
  case CONTAINER_POSITION:
    return StringUtils::Format("%i", m_focusedPosition);
  default:
    break;
  }
  return "";
}
コード例 #20
0
ファイル: DDLParser.cpp プロジェクト: macton/DDLParser
  SelectItem*
  Select::FindItem ( uint32_t hash )
  {
    for ( uint32_t i = 0; i < GetNumItems(); i++ )
    {
      SelectItem* item = ( *this ) [i];

      if ( item->GetNameHash() == hash )
      {
        return item;
      }
    }

    return 0;
  }
コード例 #21
0
ファイル: hgeguictrls.cpp プロジェクト: Psih11rus/hge
void hgeGUIListbox::DeleteItem(int n)
{
	int i;
	hgeGUIListboxItem *pItem=pItems, *pPrev=0;

	if(n<0 || n>=GetNumItems()) return;

	for(i=0;i<n;i++) { pPrev=pItem;	pItem=pItem->next; }

	if(pPrev) pPrev->next=pItem->next;
	else pItems=pItem->next;

	delete pItem;
	nItems--;
}
コード例 #22
0
ファイル: GUIBaseContainer.cpp プロジェクト: FernetMenta/xbmc
std::string CGUIBaseContainer::GetLabel(int info) const
{
  std::string label;
  switch (info)
  {
  case CONTAINER_NUM_PAGES:
    label = StringUtils::Format("%u", (GetRows() + m_itemsPerPage - 1) / m_itemsPerPage);
    break;
  case CONTAINER_CURRENT_PAGE:
    label = StringUtils::Format("%u", GetCurrentPage());
    break;
  case CONTAINER_POSITION:
    label = StringUtils::Format("%i", GetCursor());
    break;
  case CONTAINER_CURRENT_ITEM:
    {
      if (m_items.size() && m_items[0]->IsFileItem() && (std::static_pointer_cast<CFileItem>(m_items[0]))->IsParentFolder())
        label = StringUtils::Format("%i", GetSelectedItem());
      else
        label = StringUtils::Format("%i", GetSelectedItem() + 1);
    }
    break;
  case CONTAINER_NUM_ALL_ITEMS:
  case CONTAINER_NUM_ITEMS:
    {
      unsigned int numItems = GetNumItems();
      if (info == CONTAINER_NUM_ITEMS && numItems && m_items[0]->IsFileItem() && (std::static_pointer_cast<CFileItem>(m_items[0]))->IsParentFolder())
        label = StringUtils::Format("%u", numItems-1);
      else
        label = StringUtils::Format("%u", numItems);
    }
    break;
  case CONTAINER_NUM_NONFOLDER_ITEMS:
    {
      int numItems = 0;
      for (auto item : m_items)
      {
        if (!item->m_bIsFolder)
          numItems++;
      }
      label = StringUtils::Format("%u", numItems);
    }
    break;
  default:
    break;
  }
  return label;
}
コード例 #23
0
ファイル: sccolinf.cpp プロジェクト: jimmccurdy/ArchiveGit
scColRedisplay* scRedispList::FindCell( const scColumn* col ) const
{
	long			limit		= GetNumItems();
	scColRedisplay* colredisp	= (scColRedisplay*)Lock();

	for ( ; limit--; colredisp++ ) {
		if ( colredisp->fColumnID == col ) {
			Unlock();
			return colredisp;
		}
	}

	Unlock();
	
	return 0;
}
コード例 #24
0
ファイル: tb_list.cpp プロジェクト: BibleUs/turbobadger
bool TBListBackend::Reserve(int new_capacity)
{
	assert(new_capacity > 0);
	if (new_capacity > GetCapacity())
	{
		int num = GetNumItems();
		if (char *new_data = (char *) realloc(m_data, sizeof(TBLIST_DATA) + sizeof(void *) * (new_capacity)))
		{
			m_data = (TBLIST_DATA *) new_data;
			m_data->num = num;
			m_data->capacity = new_capacity;
			m_data->list = (void**) (new_data + sizeof(TBLIST_DATA));
			return true;
		}
		return false;
	}
	return true;
}
コード例 #25
0
ファイル: Sctextch.cpp プロジェクト: jimmccurdy/ArchiveGit
void scCharArray::Insert( const CharRecordP srcCh,
						  long				offset,
						  long				len )
{
	long	oldNumItems = fNumItems;
	
	SetNumSlots( GetNumItems() + len );
	
	scHandleArrayLock	h( this );
	CharRecordP 		dstCh = (CharRecordP)*h;

	memmove( dstCh + offset + len,
			 dstCh + offset,
			 ( oldNumItems - offset ) * fElemSize );

	memcpy( dstCh + offset, srcCh, len * fElemSize );

	fNumItems += len;
}
コード例 #26
0
ファイル: Sctextch.cpp プロジェクト: jimmccurdy/ArchiveGit
void scCharArray::Insert( const UCS2* ch, long offset, long len )
{
	long	oldNumItems = fNumItems;
	
	SetNumSlots( GetNumItems() + len );
	
	scHandleArrayLock	h( this );
	CharRecordP 		dstCh = (CharRecordP)*h;

	memmove( dstCh + offset + len,
			 dstCh + offset,
			 ( oldNumItems - offset ) * fElemSize );

	for ( dstCh += offset; len--; dstCh++, ch++ )	{
		dstCh->charflags	= 0;
		dstCh->character	= *ch;
		dstCh->escapement	= 0;
	}

	fNumItems += len;
}
コード例 #27
0
ファイル: hgeguictrls.cpp プロジェクト: kvakvs/hge
void hgeGUIListbox::DeleteItem(const int n) {
    hgeGUIListboxItem *pItem = items_2_, *pPrev = nullptr;

    if (n < 0 || n >= GetNumItems()) {
        return;
    }

    for (int i = 0; i < n; i++) {
        pPrev = pItem;
        pItem = pItem->next;
    }

    if (pPrev) {
        pPrev->next = pItem->next;
    }
    else {
        items_2_ = pItem->next;
    }

    delete pItem;
    items_--;
}
コード例 #28
0
ファイル: Sctextch.cpp プロジェクト: jimmccurdy/ArchiveGit
void scCharArray::DoBackSpace( long&		streamSize,
							   long&		cursorSize,
							   scSpecRun&	specRun,
#ifdef _RUBI_SUPPORT
							   scRubiArray* rubiArray,
#endif							   
							   long 		offset,
							   scKeyRecord& keyRec,
							   BOOL 		textCleared )
{
	scHandleArrayLock	h( this );
	CharRecordP 		startChRec	= (CharRecordP)*h;
	CharRecordP 		chRec		= startChRec;
	
	if ( offset > 0 ) {
		chRec +=  offset - 1;
		if ( chRec->flags.IsDiscHyphen() && chRec->flags.IsLineBreak() ) {
				keyRec.replacedchar() = scDiscHyphen;
				chRec->flags.ClrDiscHyphen();
		}
		else if ( !textCleared ) {
			if ( chRec->character == scFixRelSpace || chRec->character == scFixAbsSpace )
				keyRec.escapement() = chRec->escapement;

#ifdef jis4051
			if ( chRec->flags.GetRenMoji() > 1 )
				PatchRenMoji( startChRec, chRec );
#endif

			keyRec.replacedchar()	= chRec->character;
			keyRec.replacedfield()	= chRec->flags.GetField();
			keyRec.spec()			= specRun.SpecAtOffset( offset -1 );

			memmove( chRec, chRec + 1, (GetNumItems() - offset) * sizeof(CharRecord) );
			cursorSize = streamSize = -1;
		}
	}
}
コード例 #29
0
ファイル: sccolinf.cpp プロジェクト: jimmccurdy/ArchiveGit
status scRedispList::CL_GetColumnData( APPColumn		appname,
									   scColRedisplay&	data ) const
{
	status			stat	= scSuccess;
	volatile int	locked	= false;
	volatile int	found	= false;

	try {
		long			limit		= GetNumItems();
		scColRedisplay* colredisp	= (scColRedisplay*)Lock();
		locked						= true;

		for ( ; limit--; colredisp++ ) {
			if ( colredisp->fAPPName == appname ) {
				data = *colredisp;
				found = true;
			}
		}
		raise_if( found == false, scERRstructure );
	}
	IGNORE_RERAISE;

	return stat;
}
コード例 #30
0
ファイル: Sctextch.cpp プロジェクト: jimmccurdy/ArchiveGit
long scCharArray::ReadText( scSpecRun&	specRun,
						   APPCtxPtr	ctxPtr,
						   IOFuncPtr	readFunc,
						   int			charset )
{
	UCS2	ch,
				lastCh;
	long		ret;
	long		i;
	CharRecord	chRecBuf[kMaxCharBuf];
	CharRecord	chRec;
	TypeSpec	ts		= specRun.SpecAtOffset( 0 );
	scDBCSDetector detector( ts );

	i = 0;
	
	for ( lastCh = '\0'; (ret = scAPPReadCharacter( ctxPtr, readFunc, ch, detector )) == 1L; ) {
		if ( ch < 256 && !sc_CharType[(ch)+1] )
			continue;
		
		if ( ch == scHardReturn )
			break;
		
#ifdef JAPANESE //j
	if ( IntlScript() != smJapanese )
	{ // this does not work well with japanese fonts
		if ( ch == '"' )
		{
			if ( lastCh == ' ' || lastCh == '\0' )
				ch = 0xD2;
			else
				ch = 0xD3;
		}
		else if ( ch == '-' ) {
			if ( lastCh == '-' ) {
				if ( (chRec-1)->character == '-' ) {
					(chRec-1)->character = emDash;
					continue;
				}
			}
		}
	}
#endif JAPANESE

		chRecBuf[i].ClearFlags();
		chRecBuf[i].character		= ch;
		chRecBuf[i++].escapement	= 0;

		if ( i == kMaxCharBuf ) {
			InsertAt( GetNumItems() - 1, (ElementPtr)chRecBuf, kMaxCharBuf );
			i = 0;
		}
		lastCh				= ch;
	}

	if ( i )
		InsertAt( GetNumItems() - 1, (ElementPtr)chRecBuf, i );
	
	Validate();
	
	return ret;
}