Ejemplo n.º 1
0
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;
}
Ejemplo n.º 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;
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
Rect TableListedItems::GetItemBound( int item_no  ) const
{
    if ( item_no >=0 && item_no<GetNumItems() )  
    {
        return TableWidget::RowRect(item_no);
    }
    else return Rect(); 
}
Ejemplo n.º 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(); 
}
Ejemplo n.º 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);
    }
}
Ejemplo n.º 7
0
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;
}
Ejemplo n.º 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;
}
Ejemplo n.º 9
0
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;
}
Ejemplo n.º 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;
}
Ejemplo n.º 11
0
int TBListBackend::Find(void *data) const
{
	int num = GetNumItems();
	for(int i = 0; i < num; i++)
	{
		if (Get(i) == data)
			return i;
	}
	return -1;
}
Ejemplo n.º 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;
}
Ejemplo n.º 13
0
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;
}
Ejemplo n.º 14
0
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;
}
Ejemplo n.º 15
0
			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 );
				}
			}
Ejemplo n.º 16
0
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;
}
Ejemplo n.º 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--;
}
Ejemplo n.º 18
0
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;
}
Ejemplo n.º 19
0
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 "";
}
Ejemplo n.º 20
0
  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;
  }
Ejemplo n.º 21
0
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--;
}
Ejemplo n.º 22
0
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;
}
Ejemplo n.º 23
0
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;
}
Ejemplo n.º 24
0
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;
}
Ejemplo n.º 25
0
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;
}
Ejemplo n.º 26
0
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;
}
Ejemplo n.º 27
0
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_--;
}
Ejemplo n.º 28
0
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;
		}
	}
}
Ejemplo n.º 29
0
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;
}
Ejemplo n.º 30
0
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;
}