Exemple #1
0
CELL * appendString(CELL * cell, CELL * list, char * joint, size_t jointLen, int trailJoint, int evalFlag)
{ 
CELL * result;
STREAM stream = {0, NULL, NULL, 0, 0};
char * sPtr;
size_t len;

openStrStream(&stream, MAX_LINE, 0);
writeStreamStr(&stream, (char *)cell->contents, cell->aux - 1);
while(list != nilCell)
	{
	if(joint == NULL)
		{
		list = getStringSize(list, &sPtr, &len, evalFlag);		
		writeStreamStr(&stream, sPtr, len);
		}
	else
		{
		list = getStringSize(list, &sPtr, &len, FALSE);
		if(jointLen) writeStreamStr(&stream, joint, jointLen);
		writeStreamStr(&stream, sPtr, len);
		}
	}

if(trailJoint)
	writeStreamStr(&stream, joint, jointLen);

result = stuffStringN(stream.buffer, stream.position);

closeStrStream(&stream);

return(result);
}
// Size
uint32_t CRequestMessage::getDataSize() const
{
    // Command
    uint32_t uiSize = getStringSize(getCommand());

    // Arguments
    uint32_t uiArgument;

    for (uiArgument = 0; uiArgument < getArgumentCount(); uiArgument++) {

        uiSize += getStringSize(getArgument(uiArgument));
    }
    return uiSize;
}
Exemple #3
0
void NDUIEdit::draw_ios_ime() //for ios
{
	CCRect scrRect;

	if (m_pPlatformInput)
	{
		//** chh 2012-06-19 **//
		scrRect = m_pkTextLabel->GetFrameRect();
		CCSize textSize = getStringSize(TEST_TEXT,m_pkTextLabel->GetFontSize());
		int HBorder = (this->GetScreenRect().size.height-textSize.height)/2;
		m_pPlatformInput->SetFrame(scrRect.origin.x, scrRect.origin.y+HBorder, 
									scrRect.size.width, scrRect.size.height);
	}

	if (m_bRecacl && m_pPlatformInput)
	{
		m_pPlatformInput->SetText(m_strText.c_str());
		m_pPlatformInput->EnableSafe(m_bPassword);
//		m_pPlatformInput->SetStyleNone();
		m_bRecacl = false;
	}

	NDPicture* pic = m_picImage;

	if (m_pPlatformInput && m_pPlatformInput->IsInputState() && m_picFocusImage)
	{
		pic	= m_picFocusImage;
	}

	if (pic)
	{
		pic->DrawInRect(scrRect);
	}
}
void CommonString::setString( const unsigned char * charstr )
{
    debugInfo (   __FILE__, __LINE__); 


    //set me to be a NULL  ?
    if( charstr == NULL)
    {
        this->clear();
        return;
    }

    //use my char pointer to set to myself ??
    if( this->stringData ==  charstr ) 
    {
        return ;
    }

    debugInfo (   __FILE__, __LINE__); 

    //set me to a empty string "" 
    if( charstr[0]==0 )
    {  
        if(string_debug_cg)
        {
            printf(" hit ! \n");
        }
        this->clear();
        return;
    }

    //If this already has string , erase it.
    if ( stringData != NULL )
    {  
        this->clear();
    }
    debugInfo (   __FILE__, __LINE__);   

    //copy 
    this->size = getStringSize( charstr ) ;
    if( string_debug_cg)
    {
        printf("size = %u \n", this->size ) ;
    } 

    stringData = new unsigned char [ this->size+1 ];    
    //Not enough memory
    if( stringData  == NULL )
    {   

        this->size = 0 ;
        return;
    }    
    strcpy( (char *)this->stringData,  ( char *) charstr ) ;    
    return ;

}
Exemple #5
0
NDUILabel* CUIChatText::CreateLabel(const char* utf8_text, unsigned int fontSize, ccColor4B color, int idItem/* = 0*/)
{
	if (!utf8_text || !utf8_text[0]) return NULL;

	NDUILabel* label = NULL;
	if (utf8_text) 
	{
		CCSize textSize = getStringSize(utf8_text, fontSize*FONT_SCALE);

		label = new NDUILabel();
		label->Initialization();
		label->SetRenderTimes(1);
		label->SetText(utf8_text);
		label->SetTag(idItem);
		label->SetFontSize(fontSize); //Label内部自适应比例.
		label->SetFontColor(color);
		label->SetFrameRect(CCRectMake(0, 0, textSize.width, textSize.height));
	}
	return label;
}
Exemple #6
0
void AspBar::getLabel(spAspDataInfo_t dataInfo, string &lbl, int &cwd, int &cht) {

    string thisLabel=AspUtil::subParamInStr(label);

    double value, scale;
    if(created_type == ANNO_YBAR) {
        value= fabs(sCoord[1].y - sCoord[0].y);
        if(dataInfo->vaxis.name == "amp") scale = 1.0;
        else scale = dataInfo->vaxis.scale;
    } else {
        value= fabs(sCoord[1].x - sCoord[0].x);
        if(dataInfo->haxis.name == "amp") scale = 1.0;
        else scale = dataInfo->haxis.scale;
    }
    char str[MAXSTR],tmpStr[MAXSTR];
    sprintf(str,"%.4f",value);
    if(thisLabel == "?") {
        lbl = string(str);
    } else {
        unsigned int p1=string::npos;
        unsigned int p2=string::npos;
        p1=thisLabel.find("%",0);
        while(p1 != string::npos) {
            p2=thisLabel.find("%",p1+1);
            if(p2 != string::npos) {
                strcpy(tmpStr,thisLabel.substr(p1+1,p2-p1-1).c_str());
                bool hz = (strcasecmp(tmpStr,"hz") == 0);
                if(hz) sprintf(str,"%.4f",value*scale);
                thisLabel = thisLabel.substr(0,p1) + string(str) + thisLabel.substr(p2+1);
                p1=thisLabel.find("%",p2+1);
            } else p1 = string::npos;
        }
        lbl = string(thisLabel);
    }

    getStringSize(lbl,cwd,cht);

    return;
}
Exemple #7
0
CELL * p_join(CELL * params)
{
char * joint = NULL;
CELL * list;
size_t jointLen = 0;
int trailJoint = 0;

params = getListHead(params, &list);
if(list == nilCell)
	return(stuffString(""));

if(list->type != CELL_STRING)
	return(errorProcExt(ERR_STRING_EXPECTED, list));

if(params != nilCell)
	{
	params = getStringSize(params, &joint, &jointLen, TRUE);
	trailJoint = getFlag(params);
	}

return(appendString(list, list->next, joint, jointLen, trailJoint, FALSE));
}
Exemple #8
0
// ****************************************************************************
// draws the string centred on cds
void MolDraw2DSVG::drawString(const std::string &str, const Point2D &cds) {
  unsigned int fontSz = scale() * fontSize();

  double string_width, string_height;
  getStringSize(str, string_width, string_height);

  double draw_x = cds.x - string_width / 2.0;
  double draw_y = cds.y - string_height / 2.0;

#if 0
  // for debugging text output
  DrawColour tcolour =colour();
  setColour(DrawColour(.8,.8,.8));
  std::vector<Point2D> poly;
  poly.push_back(Point2D(draw_x,draw_y));
  poly.push_back(Point2D(draw_x+string_width,draw_y));
  poly.push_back(Point2D(draw_x+string_width,draw_y+string_height));
  poly.push_back(Point2D(draw_x,draw_y+string_height));
  drawPolygon(poly);
  setColour(tcolour);
#endif
  std::string col = DrawColourToSVG(colour());

  Point2D draw_coords = getDrawCoords(Point2D(draw_x, draw_y));

  d_os << "<text";
  d_os << " x='" << draw_coords.x;
  d_os << "' y='" << draw_coords.y << "'";

  if (d_activeClass != "") {
    d_os << " class='" << d_activeClass << "'";
  }
  d_os << " style='font-size:" << fontSz
       << "px;font-style:normal;font-weight:normal;fill-opacity:1;stroke:none;"
          "font-family:sans-serif;text-anchor:start;"
       << "fill:" << col << "'";
  d_os << " >";

  TextDrawType draw_mode =
      TextDrawNormal;  // 0 for normal, 1 for superscript, 2 for subscript
  std::string span;
  bool first_span = true;
  for (int i = 0, is = str.length(); i < is; ++i) {
    // setStringDrawMode moves i along to the end of any <sub> or <sup>
    // markup
    if ('<' == str[i] && setStringDrawMode(str, draw_mode, i)) {
      if (!first_span) {
        escape_xhtml(span);
        d_os << span << "</tspan>";
        span = "";
      }
      first_span = false;
      d_os << "<tspan";
      switch (draw_mode) {
        case TextDrawSuperscript:
          d_os << " style='baseline-shift:super;font-size:" << fontSz * 0.75
               << "px;"
               << "'";
          break;
        case TextDrawSubscript:
          d_os << " style='baseline-shift:sub;font-size:" << fontSz * 0.75
               << "px;"
               << "'";
          break;
        default:
          break;
      }
      d_os << ">";
      continue;
    }
    if (first_span) {
      first_span = false;
      d_os << "<tspan>";
      span = "";
    }
    span += str[i];
  }
  escape_xhtml(span);
  d_os << span << "</tspan>";
  d_os << "</text>\n";
}
Exemple #9
0
CELL * p_extend(CELL * params)
{
CELL * target;
CELL * head;
CELL * tail;
SYMBOL * symbolRef;
char * pStr;
size_t size;

params = getEvalDefault(params, &target);
if((symbolRef = symbolCheck))
	{
	if(isProtected(symbolRef->flags))
		return(errorProcExt2(ERR_SYMBOL_PROTECTED, stuffSymbol(symbolRef)));
	if(isNil((CELL *)symbolRef->contents))
		{
        deleteList((CELL*)symbolRef->contents);
		head = evaluateExpression(params);
		if(isList(head->type) || head->type == CELL_STRING)
			target = copyCell(head);
        symbolRef->contents = (UINT)target;
		params = params->next;
	    }
	}

if(isList(target->type))
	{
	tail = (CELL *)target->aux;
	target->aux = (UINT)nilCell;
	if(tail == nilCell)
		{
		tail = (CELL *)target->contents;
		while(tail->next != nilCell)
			tail = tail->next;
		}

	while(params != nilCell)
		{	
		params = getListHead(params, &head);
		if(head == nilCell) continue;
		if(target->contents == (UINT)nilCell)
			{
			target->contents = (UINT)copyList(head);
			tail = lastCellCopied;
			}
		else
			{
			tail->next = copyList(head);
			target->aux = (UINT)lastCellCopied;
			tail = (CELL *)target->aux;
			}
		}
		
	}	
else if(target->type == CELL_STRING)
	{
	while(params != nilCell)
		{
		params = getStringSize(params, &pStr, &size, TRUE);
		appendCellString(target, pStr, size);
		}
	}
else return(errorProcExt(ERR_LIST_OR_STRING_EXPECTED, target));

symbolCheck = symbolRef;
pushResultFlag = FALSE;
return(target);
}