void StandardPresenter::addField( PresentableField * pField )
	{
		CharBuffer * pBuffer = _charBuffer(pField);
		int nLines = _countLines( pBuffer );
	
		_setFieldDataBlock(pField,0);					// Make sure pointer is null for the realloc call.
		void * pBlock = _reallocBlock(pField,nLines);
		
		_updateLineInfo( _header(pBlock), _lineInfo(pBlock), pBuffer, _baseStyle(pField), _state(pField) );
		_updatePreferredSize( _header(pBlock), _lineInfo(pBlock) );	
	}
	void StandardPresenter::onRefresh( PresentableField * pField )
	{
		CharBuffer * pBuffer = _charBuffer(pField);
		int nLines = _countLines( pBuffer );
	
		void * pBlock = _fieldDataBlock(pField);
		if( !pBlock || _header(pBlock)->nbLines != nLines )
			pBlock = _reallocBlock(pField,nLines);
		
		_updateLineInfo( _header(pBlock), _lineInfo(pBlock), pBuffer, _baseStyle(pField), _state(pField) );
		_updatePreferredSize( _header(pBlock), _lineInfo(pBlock) );
	}
示例#3
0
 //------------------------------------------------------------------------
 int qt_dbtreemodel_impl::_TextAlignmentRole( int section ) const
 {
     Qt::AlignmentFlag horz = Qt::AlignLeft;;
     Qt::AlignmentFlag vert = Qt::AlignVCenter;
     
     const TreeModel::Header *header = _header( section );
     if( ! header )
         return ( int ) horz | vert;
     
     const TreeModel::Canvas *canvas = header->canvas();        
     if( canvas )
     {
         AlignmentFlags::const_iterator it = _horizontal_flags.find( canvas->alignH() );
         if( it != _horizontal_flags.end() )
         {
             horz = it->second;
         }
         
         it = _vertical_flags.find( canvas->alignV() );
         if( it != _vertical_flags.end() )
         {
             vert = it->second;
         }
     }
     
     return ( int ) horz | vert;
 }
示例#4
0
static int count_fl(OBJ l){
  int c = 0;
  while (l != NULL){
    c++; l = _getLink(_header(l));
  }
  return c;
}
	void StandardPresenter::renderField( PresentableField * pField, GfxDevice * pDevice, const Rect& canvas, const Rect& clip )
	{
		void * pBlock = _fieldDataBlock(pField);
		BlockHeader * pHeader = _header(pBlock);
		LineInfo * pLineInfo = _lineInfo(pBlock);
		const Char * pCharArray = _charBuffer(pField)->chars();
		
		Coord lineStart = canvas.pos();
		lineStart.y += _textOfsY( pHeader, canvas.h );
	
		TextAttr2		baseAttr;
		_baseStyle(pField)->exportAttr( _state(pField), &baseAttr );
	
		TextAttr2		attr = baseAttr;
		Font_p pFont = attr.pFont;
		Glyphset_p pGlyphSet = pFont->getGlyphset( WG_FONT_NORMAL, attr.size);
		
		for( int i = 0 ; i < pHeader->nbLines ; i++ )
		{
			if( lineStart.y < clip.y + clip.h && lineStart.y + pLineInfo->height > clip.y )
			{		
				lineStart.x = canvas.x + _lineOfsX( pLineInfo, canvas.w );
				const Char * pChars = pCharArray + pLineInfo->offset;
	
				Glyph_p	pGlyph;
				Glyph_p	pPrevGlyph;
				
				Coord pos = lineStart;
				pos.y += pLineInfo->base;
				
				for( int x = 0 ; x < pLineInfo->length ; x++ )
				{
					// TODO: Include handling of special characters
					// TODO: Support char-style changes.
				
					pGlyph = pGlyphSet->getGlyph(pChars->getGlyph(),attr.size);
	
					if( pGlyph )
					{
						const GlyphBitmap * pBitmap = pGlyph->getBitmap();
						pDevice->clipBlit( clip, pBitmap->pSurface, pBitmap->rect, pos.x + pBitmap->bearingX, pos.y + pBitmap->bearingY  );
	
						pos.x += pGlyph->advance();
						if( pPrevGlyph )
							pos.x += pGlyphSet->getKerning(pPrevGlyph, pGlyph, attr.size);
					}
					else if( pChars->getGlyph() == 32 )
						pos.x += pGlyphSet->getWhitespaceAdvance( attr.size );
						
					pPrevGlyph = pGlyph;
					pChars++;
				}			
			}
			
			lineStart.y += pLineInfo->spacing;
			pLineInfo++;
		}
		
	}
示例#6
0
//
// send() - sends data on the SPI buss to the VDIP.  Returns 
//          true if the write was accepted, or false otherwise.
//          If false, that means that the VDIP buffer was full
//          and the write needs to be attempted again.
//
bool VDIPSPI::send(unsigned char data, bool statusByte /* = false */)
{
  _header(false,statusByte);                   // set up for a write

  for(int i=8; i--; ) {
    digitalWrite(_mosiPin,(data&0x80)?HIGH:LOW);
    SPI_CLK_UP;
    SPI_CLK_DOWN;
    data <<=1;
  }

  return(_statusbit());
}
示例#7
0
 //------------------------------------------------------------------------
 QString qt_dbtreemodel_impl::_ToolTipRole( int section ) const
 {
     const TreeModel::Header *header = _header( section );
     if( ! header )
         return _empty.c_str();
     
     const TreeModel::Canvas *canvas = header->canvas();
     if( canvas )
     {
         return qt_dbtreemodel::tr( canvas->toolTip().c_str() );
     }
     
     return _empty.c_str();
 }
示例#8
0
//
// recv() - the receive routine that grabs a byte from
//           either status or data.  The routine returns true if
//           the read was of new data, false otherwise.  The given
//           data pointer is filled-in in either case.
//
bool VDIPSPI::recv(unsigned char *data, bool statusByte /* = false */)
{
  *data = 0;
  _header(true,statusByte);                    // set up for a read

  for( int i = 8; i--; ) {
    *data <<= 1;
    *data |= (digitalRead(_misoPin) == HIGH)?0x01:0x00;
    SPI_CLK_UP;
    SPI_CLK_DOWN;
  }

  return(_statusbit());
}
示例#9
0
 //------------------------------------------------------------------------
 QIcon qt_dbtreemodel_impl::_DecorationRole( int section ) const
 {
     QIcon icon;
     
     const TreeModel::Header *header = _header( section );
     if( ! header )
         return icon;
     
     const TreeModel::Canvas *canvas = header->canvas();
     if( canvas )
     {
         icon.addFile( canvas->icon().c_str() );
     }
     
     return icon;
 }
示例#10
0
 //------------------------------------------------------------------------
 QString qt_dbtreemodel_impl::_DisplayRole( int section ) const
 {
     const TreeModel::Header *header = _header( section );
     if( ! header )
         return _empty.c_str();
         
     const TreeModel::Canvas *canvas = header->canvas();        
     if( canvas )
     {
         if( canvas->data().size() )
             return qt_dbtreemodel::tr( canvas->data().c_str() );
             
         return qt_dbtreemodel::tr( canvas->text().c_str() );
     }
     
     return _empty.c_str();
 }
示例#11
0
void
MMO_Generator_::_generateModel ()
{
  _initSections ();
  _variables ();
  _header ();
  _initMatrices ();
  _solver->model ();
  _solver->modelDeps ();
  _solver->zeroCrossing ();
  _solver->handler ();
  _solver->output ();
  _solver->initialCode ();
  _variablesInitCode();
  _writer->print (WR_HEADER);
  _writer->print (WR_GLOBAL_VARS);
  _solver->print (SOL_MODEL_SETTINGS);
  _solver->print (SOL_MODEL);
  _solver->print (SOL_DEPS);
  if (!_writer->isEmpty (WR_ZC_SIMPLE) || !_writer->isEmpty (WR_ZC_GENERIC))
    {
      _solver->print (SOL_ZC);
      if (!_writer->isEmpty (WR_HANDLER_POS_SIMPLE)
	  || !_writer->isEmpty (WR_HANDLER_POS_GENERIC))
	{
	  _solver->print (SOL_HANDLER_POS);
	}
      if (!_writer->isEmpty (WR_HANDLER_NEG_SIMPLE)
	  || !_writer->isEmpty (WR_HANDLER_NEG_GENERIC))
	{
	  _solver->print (SOL_HANDLER_NEG);
	}
    }
  if (!_writer->isEmpty (WR_OUTPUT_SIMPLE)
      || !_writer->isEmpty (WR_OUTPUT_GENERIC))
    {
      _solver->print (SOL_OUTPUT);
    }
  _solver->print (SOL_INIT);
}
示例#12
0
 //------------------------------------------------------------------------
 QVariant qt_dbtreemodel_impl::_TextColorRole( int section ) const
 {
     QVariant color = _parent ?
                      _parent->headerDataDefault( section, Qt::Horizontal, Qt::TextColorRole ) :
                      QVariant();
     
     const TreeModel::Header *header = _header( section );
     if( ! header )
         return color;
     
     const TreeModel::Canvas *canvas = header->canvas();
     if( canvas )
     {
         const TreeModel::Color* ptr = canvas->font() ? canvas->font()->color() : NULL;
         if( ptr )
         {
             return QColor( ptr->red(), ptr->green(), ptr->blue(), ptr->alpha() );
         }
     }
     
     return color;
 }
示例#13
0
 //------------------------------------------------------------------------
 QFont qt_dbtreemodel_impl::_FontRole( int section ) const
 {
     QFont font;
     
     const TreeModel::Header *header = _header( section );
     if( ! header )
         return font;
     
     const TreeModel::Canvas *canvas = header->canvas();
     if( canvas )
     {
         const TreeModel::Font* ptr = canvas->font();
         if( ptr )
         {
             font.setFamily   ( ptr->family().c_str() );
             font.setPointSize( ptr->pointSize()      );
             font.setItalic   ( ptr->italic()         );
             font.setUnderline( ptr->underline()      );
             font.setBold     ( ptr->bold()           );
         }
     }
     
     return font;
 }
示例#14
0
static OBJ parse(FILE *f, HASHTAB t, OBJ *ep){
    OBJ d;
    int shared;
  
    d = read_obj(f,ep);
    if (*ep) return NIL;

    if (isVal(d)) {
	return d;
    } else if (isRefToCell(d)) {
	WORD lab = getLabel(d);
	int i; HASHENTRY e;
	i = lab % HASHSIZE;
	for (e = t->tab[i]; e; e = e->next) {
	    if (e->label == lab) {
		/* increment RC of refered cell and return it. */
		_incRc(_header(e->obj),1);
		return e->obj;
	    }
	}
	/* Format error. */
	copy_some(__ABinFile_AinvalidFormat,1);
	*ep = __ABinFile_AinvalidFormat;
	return NIL;
    } else if ((shared = isSharedCell(d)) || isExclCell(d)) {
	int sz = getSize(d), fs = getFlags(d), i; 
	intptr_t flds;
	OBJ * data; OBJ ob; WORD lab;
	    
	if (shared) {
	    lab = (WORD)read_obj(f,ep);
	    if (*ep) return NIL;
	    if (!isRefToCell(lab)){
		copy_some(__ABinFile_AinvalidFormat,1);
		*ep = __ABinFile_AinvalidFormat;
		return NIL;
	    }
	}

	if (sz % flat_offset_ssize == big_escape_ssize){
	    flds = (intptr_t)read_obj(f,ep);
	    if (*ep) return NIL;
	    ob = _bigAlloc(flds);
	    _mkHeader(_header(ob),sz,1);
	    ((BCELL)ob)->size = pack_word(flds);
	    data = _bdata(ob);
	} else {
	    flds = sz % flat_offset_ssize;
	    _alloc(flds,ob);
	    _mkHeader(_header(ob),sz,1);
	    data = _data(ob);
	}
	_flags(_header(ob)) = fs;
	    
	if (shared){
	    HASHENTRY e;
	    lab = getLabel(lab);
	    e = newEntry();
	    e->label = lab; e->obj = ob;
	    i = lab % HASHSIZE;
	    e->next = t->tab[i]; t->tab[i] = e;
	}

	if (sz >= flat_offset_ssize) {
	    if (fs & (1 << byte_flat_sflag)){
		/* read two words and rest as char stream */
		/* (UPDATE STRING FORMAT) */
		unsigned char * cdata = (unsigned char*)(data+2);
		int ch, cflds = (flds-2) * sizeof(OBJ);
		data[0] = read_obj(f,ep); data[1] = read_obj(f,ep); 
		for (i = 0; i < cflds && !*ep; i++) {
		    if ((ch = getc(f)) != EOF){
			cdata[i] = ch;
		    } else
			get_unix_failure(errno,*ep);
		}
	    } else {
		/* read contents of unstructured cell. */
		for (i = 0; i < flds && !*ep; i++) {
		    data[i] = read_obj(f,ep);
		}
	    }
	} else {
	    /* recursivly parse structured cell. */
	    for (i = 0; i < flds && !*ep; i++) {
		data[i] = parse(f,t,ep);
	    }
	}

	/* process closures */
	if (tst_sflag(ob, closure_sflag)){
	    char msgbuf[128];
	    char * msg = link_closure(ob);
	    if (msg){
	      strcpy(msgbuf, (char*)
		       data_denotation(__ABinFile_AlinkErrorPrefix));
	      strcat(msgbuf, (char*)
		       data_denotation(((CLOSURE)ob)->symbolid));
		strcat(msgbuf,"': ");
		strcat(msgbuf,msg);
		*ep = declare_failure_answer(msgbuf);
		return NIL;
	    }
	}

	return ob;

    } else {
	copy_some(__ABinFile_AinvalidFormat,1);
	*ep = __ABinFile_AinvalidFormat;
	return NIL;
    }
}
示例#15
0
static void dump(FILE *f, HASHTAB t, OBJ ob, int *labct, OBJ *ep) {

    if (is_structured(ob)){
	int sz = _size(_header(ob)), fs = _flags(_header(ob)), i; 
	intptr_t flds;
	OBJ *data;

	if (_tstRc(_header(ob),1)) {
	    write_obj(f,mkExclCell(fs,sz),ep);
	    if (*ep) return;
	} else {
	    HASHENTRY e;

	    /* check if object already dumped */
	    i = (WORD)ob % HASHSIZE;
	    for (e = t->tab[i]; e; e = e->next) {
		if (e->obj == ob) {
		    write_obj(f,mkRefToCell(e->label),ep);
		    return;
		}
	    }

	    /* first time dumping a shared cell */
	    write_obj(f,mkSharedCell(fs,sz),ep);
	    if (*ep) return;

	    /* create new entry in hashtab and assign 
	       label to it, since we might have to visit it again. 
	       */
	    e = newEntry();
	    e->label = (*labct)++;
	    write_obj(f,mkRefToCell(e->label),ep);
	    if (*ep) return;
	    e->obj = ob;
	    e->next = t->tab[i]; t->tab[i] = e;
	}

	/* calculate no of fields */
	if (sz % flat_offset_ssize == big_escape_ssize){
	    flds = unpack_word(((BCELL)ob)->size);
	    write_obj(f,(OBJ)flds,ep);
	    if (*ep) return;
	    data = _bdata(ob);
	} else {
	    flds = sz % flat_offset_ssize;
	    data = _data(ob);
	}

	if (sz >= flat_offset_ssize) {
	    if (fs & (1 << byte_flat_sflag)){
		/* write 2 words and rest as char stream */
		unsigned char * cdata = (unsigned char*)(data+2);
		int cflds = (flds-2) * sizeof(OBJ);
		write_obj(f,data[0],ep); write_obj(f,data[1],ep); 
		for (i = 0; i < cflds && !*ep; i++) {
		    if (putc(cdata[i],f) != cdata[i]){
			get_unix_failure(errno,*ep);
		    }
		}
	    } else {
		/* write fields as coded longwords */
		for (i = 0; i < flds && !*ep; i++) {
		    write_obj(f,data[i],ep);
		}
	    }
	} else {
	    /* recursivly dump fields. */
	    for (i = 0; i < flds && !*ep; i++) {
		dump(f,t,data[i],labct,ep);
	    }
	}
    } else {
	write_obj(f,ob,ep);
    }
}
	int StandardPresenter::matchingHeight( const PresentableField * pField, int width ) const
	{
		return _header(_fieldDataBlock(pField))->preferredSize.h;
	}
	Size StandardPresenter::preferredSize( const PresentableField * pField ) const
	{
		return _header(_fieldDataBlock(pField))->preferredSize;
	}