int trueStringLength(const char *str, int len){
    Tizen::Base:: String bada_str;
    ByteBuffer buffer;
    buffer.Construct(len + 1);
    buffer.SetArray(( byte*)str, 0, len);
    buffer.SetByte( '\0');
    buffer.Flip();
    Tizen::Text::Utf8Encoding utf8;
    int charCount;
    utf8.GetCharCount(buffer, charCount);
  return charCount;
}
Пример #2
0
void ZLbadaPaintContext::drawString(int x, int y, const char *str, int len, bool rtl){
	Tizen::Base::String bada_str;
    ByteBuffer buffer;
    buffer.Construct(len + 1);
    buffer.SetArray((byte*)str, 0, len);
    buffer.SetByte('\0');
    buffer.Flip();
//AppLog("ZLbadaPaintContext::drawString %s",(const char *)str);
//	StringUtil::Utf8ToString((const char *)buffer.GetPointer(), bada_str);
    Utf8Encoding utf8;
    int charCount;
    utf8.GetCharCount(buffer, charCount);
    utf8.GetString(buffer, bada_str);
 //   AppLog("charCount = %d : len = %d", charCount,len);
 //   DrawEnrichedTex(x, y-myFont->GetMaxHeight(),bada_str );
 //   AppLog("myStoredSize = %d ", myStoredSize);
 //   AppLog("myFont->GetMaxHeight() = %d ", myFont->GetMaxHeight());
    //Tizen::Graphics::Color clr = Tizen::Graphics::Color::COLOR_GREEN;

	if ((myFont!=0)&&(pCanvas!=0))  {
	//	AppLog("pCanvas->SetFont(*myFont)");
	//	pCanvas->SetFont(*myFont);

	 if (myStoredItalic)
		 pCanvas->DrawText(Point(x, y - myFont->GetMaxHeight()+ deltaItalic), bada_str);
	 else
		 pCanvas->DrawText(Point(x, y - myFont->GetMaxHeight()), bada_str);
}
//	AppLog("ZLbadaPaintContext::drawString end");
 /*
 if (!myStoredItalic) pCanvas->DrawText(Point(x, y-myFont->GetMaxHeight()), bada_str);
 else{
	 int startX = x;
	 int startY= y-myFont->GetMaxHeight();
	 mchar ch;
	 for (int i=0; i<charCount; i++){
	     bada_str.GetCharAt(i, ch);
	     int rb;
	     myFont->GetRightBear(ch, rb);
	     int lb;
	     myFont->GetLeftBear(ch, lb);
	     pCanvas->DrawText(Point(startX, startY), ch);
	     startX = startX + rb;
	     }
 	 }

*/
	//pCanvas->DrawText(Point(x, y-myFont->GetMaxHeight()), bada_str, Tizen::Graphics::Color::COLOR_WHITE);
//	pCanvas->DrawText(Point(x, y-myFont->GetMaxHeight()), bada_str, charCount);
//	pCanvas->DrawText(Point(x, y), bada_str,charCount);
}
Пример #3
0
void FBReader::openLinkInBrowser(const std::string &url) const {
	if (url.empty()) {
		return;
	}
	AppLog("openLinkInBrowser url=%s",url.c_str());

   int len = url.length();
   String bada_str;
   ByteBuffer buffer;
   buffer.Construct(len + 1);
   buffer.SetArray((const byte*)url.data(), 0, len);
   buffer.SetByte( '\0');
   buffer.Flip();
   Utf8Encoding utf8;
   int charCount;
   utf8.GetCharCount(buffer, charCount);
   utf8.GetString(buffer, bada_str);

	ArrayList* pDataList = null;
	pDataList = new ArrayList();
	pDataList->Construct();
	String* pData = null;

	pData = new String(L"url:" + bada_str);
	//pData = new String(L"url:http://www.bada.com");
	pDataList->Add(*pData);
	//APPCONTROL_BROWSER
	//TODO Tizen
	AppControl* pAc;// rem  TIZEN !!!!!!!!!= AppManager::FindAppControlN(APPCONTROL_BROWSER, OPERATION_VIEW);
	//AppControl* pAc = AppManager::FindAppControlN(APPCONTROL_PROVIDER_BROWSER, APPCONTROL_OPERATION_VIEW);
	if (pAc)    {       pAc->Start(pDataList, null);       delete pAc;    }
	pDataList->RemoveAll(true);
	delete pDataList;

	/*
	shared_ptr<ProgramCollection> collection = webBrowserCollection();
	if (collection.isNull()) {
		return;
	}
	shared_ptr<Program> program = collection->currentProgram();
	if (program.isNull()) {
		return;
	}
	std::string copy = url;
//	NetworkLinkCollection::Instance().rewriteUrl(copy, true);
	ZLLogger::Instance().println("URL", copy);
	program->run("openLink", copy);*/
}
Пример #4
0
int ZLbadaPaintContext::stringWidth(const char *str, int len, bool) const {
	Tizen::Base::String bada_str;
    ByteBuffer buffer;
    buffer.Construct(len + 1);
    buffer.SetArray((byte*)str, 0, len);
    buffer.SetByte('\0');
    buffer.Flip();
//	AppLog("ZLbadaPaintContext::stringWidth %s",(const char *)buffer.GetPointer());
//	StringUtil::Utf8ToString((const char *)buffer.GetPointer(), bada_str);
    Utf8Encoding utf8;
    int charCount;
    utf8.GetCharCount(buffer, charCount);
    utf8.GetString(buffer, bada_str);

    Dimension dim;


	 //if (!myStoredItalic) {
		 myFont->GetTextExtent(bada_str, charCount, dim);
	//	AppLog("dim.width %d",dim.width);
		 return dim.width;// + charCount*(myFont->GetCharSpace());
	 /*}
	 else{
		 int width = 0;
		 //int startY = y-myFont->GetMaxHeight();
		 mchar ch;
		 for (int i=0; i<charCount; i++){
		     bada_str.GetCharAt(i, ch);
		     int rb;
		     myFont->GetRightBear(ch, rb);
		    // int lb;
		    // myFont->GetLeftBear(ch, lb);
		    // pCanvas->DrawText(Point(startX, startY), ch);
		     AppLog("width %d",width);
		     width = width + rb;
		     }
		 return width;
	 	 }*/


}