예제 #1
0
    void onDraw(SkCanvas* canvas) override {
        SkPaint paint;
        paint.setAntiAlias(true);
        paint.setLCDRenderText(true);
        paint.setSubpixelText(true);
        paint.setTypeface(fTypefaces[0]);
        paint.setTextSize(192);

        // Make sure the nul character does not cause problems.
        paint.measureText("\0", 1);

        SkScalar x = 20;
        SkScalar y = 128;
        SkString text("ABCDEFGHIJ");
        draw_string(canvas, text, x, y, paint);
        y += 100;
        SkString text2("KLMNOPQRS");
        draw_string(canvas, text2, x, y, paint);
        y += 100;
        SkString text3("TUVWXYZ012");
        draw_string(canvas, text3, x, y, paint);
        y += 100;
        paint.setTypeface(fTypefaces[1]);
        draw_string(canvas, text, x, y, paint);
        y += 100;
        draw_string(canvas, text2, x, y, paint);
        y += 100;
        draw_string(canvas, text3, x, y, paint);
        y += 100;
    }
예제 #2
0
namespace LightSpeed {

defineTest test_textToBase64("baseX.textToBase64","UHJpc2VybmUgemx1dG91Y2t5IGt1biB1cGVsIGRhYmVsc2tlIGtvZHk=MTIzNA==",[](PrintTextA &out) {

	CharsToBytesConvert charToByte;
	ByteToBase64Convert base64conv;
	ConverterChain<CharsToBytesConvert &, ByteToBase64Convert &> convChain(charToByte, base64conv);

	ConstStrA text("Priserne zlutoucky kun upel dabelske kody");
	StringA conv = StringA(convertString(convChain, text));
	out("%1") << conv;

	base64conv.eolb = false;

	ConstStrA text2("1234");
	StringA conv2 = StringA(convertString(convChain, text2));
	out("%1") << conv2;
});

defineTest test_base64ToText("baseX.base64ToText","Priserne zlutoucky kun upel dabelske kody",[](PrintTextA &out){


	BytesToCharsConvert charToByte;
	Base64ToByteConvert base64conv;
	ConverterChain<Base64ToByteConvert &, BytesToCharsConvert &> convChain(base64conv,charToByte);

	ConstStrA text("UHJpc2VybmUgemx1dG91Y2t5IGt1biB1cGVsIGRhYmVsc2tlIGtvZHk=");
	StringA conv = StringA(convertString(convChain, text));
	out("%1") << conv;

});

}
예제 #3
0
void GUI::TextBox::draw(sf::RenderTarget &target, sf::RenderStates states) const {
    states.transform *= getTransform();

    sf::Text text(mString.compare("") == 0 ? mKeyHolder : mString, Application::app->getFontHolder()->get(Fonts::Main),
                  18);
    text.setColor(mString.compare("") == 0 ? mInactiveColor : mTextColor);
    text.setPosition(mViewOffset,mBackgroundRectangle.getSize().y*0.33f - (text.getLocalBounds().height/2.f+text.getLocalBounds().top));

    sf::RenderTexture renderTexture;
    renderTexture.create(mBackgroundRectangle.getSize().x-20,mBackgroundRectangle.getSize().y*0.66f);
    renderTexture.clear(sf::Color::White);
    renderTexture.draw(text); // or any other drawable


    if (isActive()) {

        if (mCursorBlinkCount<31) {
            sf::Text text2(mString.substr(0,mCurrentCaretPosition),Application::app->getFontHolder()->get(Fonts::Main),18);
            sf::RectangleShape rect(sf::Vector2f(2, mBackgroundRectangle.getSize().y*0.66f));
            rect.setFillColor(mActiveColor);
            rect.setPosition(text2.getGlobalBounds().width-1+mViewOffset,0);
            renderTexture.draw(rect);
        }
    }

    renderTexture.display();
    sf::Sprite sprite(renderTexture.getTexture());
    sprite.setPosition(10,mBackgroundRectangle.getSize().y/6.f);

    target.draw(mBackgroundRectangle, states);
    target.draw(sprite, states);
}
예제 #4
0
파일: main.cpp 프로젝트: Arnaud474/Warmux
void AppWarmux::DisplayLoadingPicture()
{
  Config *config = Config::GetInstance();

  std::string txt_version =
    _("Version") + std::string(" ") + Constants::WARMUX_VERSION;
  std::string filename = config->GetDataDir() + "menu" PATH_SEPARATOR "background_loading.jpg";

  Surface surfaceLoading(filename.c_str());
  Sprite loading_image(surfaceLoading);

  loading_image.ScaleSize(video->window.GetSize());
  loading_image.Blit(video->window, 0, 0);

  GameTime::GetInstance()->Reset();

  Text text1(_("Warmux launching..."), white_color,
             Font::FONT_HUGE, Font::FONT_BOLD, true);
  Text text2(txt_version, white_color, Font::FONT_HUGE, Font::FONT_BOLD,
             true);

  Point2i windowCenter = video->window.GetSize() / 2;

  text1.DrawCenter(windowCenter);
  text2.DrawCenter(windowCenter
                   + Point2i(0, Font::GetInstance(Font::FONT_HUGE, Font::FONT_BOLD)->GetHeight() + 20));

  video->window.Flip();
}
예제 #5
0
void video_manager::record_frame()
{
	// ignore if nothing to do
	if (m_mngfile == NULL && m_avifile == NULL)
		return;

	// start the profiler and get the current time
	g_profiler.start(PROFILER_MOVIE_REC);
	attotime curtime = machine().time();

	// create the bitmap
	create_snapshot_bitmap(NULL);

	// loop until we hit the right time
	while (m_movie_next_frame_time <= curtime)
	{
		// handle an AVI recording
		if (m_avifile != NULL)
		{
			// write the next frame
			avi_error avierr = avi_append_video_frame(m_avifile, m_snap_bitmap);
			if (avierr != AVIERR_NONE)
			{
				g_profiler.stop();
				return end_recording();
			}
		}

		// handle a MNG recording
		if (m_mngfile != NULL)
		{
			// set up the text fields in the movie info
			png_info pnginfo = { 0 };
			if (m_movie_frame == 0)
			{
				astring text1(emulator_info::get_appname(), " ", build_version);
				astring text2(machine().system().manufacturer, " ", machine().system().description);
				png_add_text(&pnginfo, "Software", text1);
				png_add_text(&pnginfo, "System", text2);
			}

			// write the next frame
			const rgb_t *palette = (machine().palette != NULL) ? palette_entry_list_adjusted(machine().palette) : NULL;
			png_error error = mng_capture_frame(*m_mngfile, &pnginfo, m_snap_bitmap, machine().total_colors(), palette);
			png_free(&pnginfo);
			if (error != PNGERR_NONE)
			{
				g_profiler.stop();
				return end_recording();
			}
		}

		// advance time
		m_movie_next_frame_time += m_movie_frame_period;
		m_movie_frame++;
	}
	g_profiler.stop();
}
예제 #6
0
// Log messages to the text control
void MyFrame::Log(const wxString& text)
{
    if (m_textCtrl)
    {
        wxString text2(text);
        text2.Replace(wxT("\n"), wxT(" "));
        text2.Replace(wxT("\r"), wxT(" "));
        m_textCtrl->SetInsertionPointEnd();
        m_textCtrl->WriteText(text2 + wxT("\n"));
    }
}
예제 #7
0
ustring xml_text_embed_in_tags(int level, const ustring tag, const ustring & text)
{
  // Handle < and > and &.
  ustring text2(text);
  xml_handle_entities(text2, NULL);
  // Embed the text.
  ustring result;
  for (int i = 0; i < level; i++)
    result.append("  ");
  result.append("<" + tag + ">" + text2 + "</" + tag + ">");
  return result;
}
void CCalendarSettingsQuery::ConstructL()
{				
	CALLSTACKITEM_N(_CL("CCalendarSettingsQuery"), _CL("ConstructL"));
	iSelections = new (ELeave) CDesCArrayFlat(10);
	

	auto_ptr<HBufC> text1( StringLoader::LoadL( R_TEXT_WELCOME_SHOW_TITLE_OF_EVENT ) );
	auto_ptr<HBufC> text2( StringLoader::LoadL( R_TEXT_WELCOME_SHOW_BUSY_INSTEAD ) );
	auto_ptr<HBufC> text3( StringLoader::LoadL( R_TEXT_WELCOME_DONT_SHARE_EVENTS ) );

	
	iSelections->AppendL( *text1 );
	iSelections->AppendL( *text2 );
	iSelections->AppendL( *text3 );
}
예제 #9
0
파일: TextUtil.cpp 프로젝트: ppara/XCSoar
TextUtil::Texture
TextUtil::getTextTextureGL(const char *text) const
{
  Java::String text2(env, text);
  jintArray jresult = (jintArray)
    env->CallObjectMethod(Get(), midGetTextTextureGL,
                          text2.Get());
  jint result[5];
  if (!Java::DiscardException(env) && jresult != nullptr) {
    env->GetIntArrayRegion(jresult, 0, 5, result);
    env->DeleteLocalRef(jresult);
  } else {
    result[0] = result[1] = result[2] = result[3] = result[4] = 0;
  }

  return Texture(result[0], result[1], result[2], result[3], result[4]);
}
void CFinalQuery::ConstructL()
{				
	CALLSTACKITEM_N(_CL("CFinalQuery"), _CL("ConstructL"));
	iSelections = new (ELeave) CDesCArrayFlat(10);

#ifdef ADD_SHORTCUT_QUERY
	auto_ptr<HBufC> text1( StringLoader::LoadL( R_TEXT_WELCOME_ADD_SHORTCUT_TO_IDLE) );
	auto_ptr<HBufC> text2( StringLoader::LoadL( R_TEXT_WELCOME_LAUNCH_JAIKU ) );
	
	iSelections->AppendL( *text1 );
	iSelections->AppendL( *text2 );
#else
	auto_ptr<HBufC> text1( StringLoader::LoadL( R_TEXT_WELCOME_LAUNCH_JAIKU__NOSHORTCUT ) );
	
	iSelections->AppendL( *text1 );
#endif
}
예제 #11
0
void PopupMenu::add(std::string const & text, int id, bool escapeFltkChars /* true */)
{
    assert(id > 0);

    std::string text2(text);

    if (escapeFltkChars)
    {
        // escape label special chars
        if (!text2.empty() && text2[0] == '_')
        {
            text2.insert(0, "\\");
        }
        boost::replace_all(text2, "&", "\\&");
        boost::replace_all(text2, "/", "\\/");
    }

    menu_.add(text2.c_str(), 0, 0, reinterpret_cast<void*>(static_cast<intptr_t>(id)) );
}
예제 #12
0
파일: TextUtil.cpp 프로젝트: ppara/XCSoar
PixelSize
TextUtil::getTextBounds(const char *text) const
{
  jint extent[2];

  Java::String text2(env, text);
  jintArray paramExtent = (jintArray)
    env->CallObjectMethod(Get(), midGetTextBounds,
                          text2.Get());
  if (!Java::DiscardException(env)) {
    env->GetIntArrayRegion(paramExtent, 0, 2, extent);
    env->DeleteLocalRef(paramExtent);
  } else {
    /* Java exception has occurred; return zeroes */
    extent[0] = 0;
    extent[1] = 0;
  }

  return { extent[0], extent[1] };
}
예제 #13
0
ParseWords::ParseWords(const ustring & text)
// Parses a line of text in its separate words.
// Note: This is comparable to object Parse, but does a better job.
{
  // Load text into buffer.
  ustring text2(text);
  text2.append(" ");
  GtkTextBuffer *textbuffer;
  textbuffer = gtk_text_buffer_new(NULL);
  gtk_text_buffer_set_text(textbuffer, text2.c_str(), -1);
  // Iterators.  
  GtkTextIter startiter, enditer;
  // Parse into separate words.
  gtk_text_buffer_get_start_iter(textbuffer, &enditer);
  while (gtk_text_iter_forward_word_end(&enditer)) {
    startiter = enditer;
    gtk_text_iter_backward_word_start(&startiter);
    ustring word = gtk_text_iter_get_text(&startiter, &enditer);
    words.push_back(word);
  }
  // Free memory
  g_object_unref(textbuffer);
}
예제 #14
0
void Engine::view(sf::RenderWindow &SCREEN)
{
	sf::Sprite spr;
	spr.setTexture( Engine::CARDS );

	spr.setTextureRect( Engine::TILE[ Engine::cCARD-1 ]);
	spr.setPosition(10, 22);

	std::stringstream ss1;
	ss1 << "Winning Streak : " << Engine::win;
	sf::Text text1( ss1.str(), Engine::MONA, 20);
	text1.setPosition(170, 22);

	std::stringstream ss2;
	ss2 << "Total Score : " << Engine::score;
	sf::Text text2( ss2.str(), Engine::MONA, 20);
	text2.setPosition(170, 52);

	SCREEN.clear();
	SCREEN.draw(text1);
	SCREEN.draw(text2);
	SCREEN.draw(spr);
	SCREEN.display();
}
예제 #15
0
파일: ut.cpp 프로젝트: nkirov/timetool
void Ut::read_write()
{
qDebug() << "begin read_write";
	QFile inp(filename);
	if (!inp.open(QFile::ReadOnly))
	{
qDebug() << "ERROR1";
		return;
	}
	QTextStream text1(&inp);
	
	QString filename2 = filename.left(filename.size() - 6) + "ut.txt";
qDebug() << filename << "-->" << filename2;
	QFile out(filename2);
	if (!out.open(QFile::WriteOnly))
	{
qDebug() << "ERROR2";
		return;
	}
	QTextStream text2(&out);

	while (!text1.atEnd())
	{
		QString line(text1.readLine());
		if (line.mid(42,1) != " ") text2 << line << endl;
		else if (ui.JD2UT->isChecked()) text2 << convJD(line) << endl;
        else text2 << conv(line) << endl;
	}
	inp.close();
	out.close();

	ui.convert->setText("DONE!");
	ui.convert->setDisabled(true);
	write_cfg();
qDebug() << "end read_write";	
}
예제 #16
0
void video_manager::save_snapshot(screen_device *screen, emu_file &file)
{
	// validate
	assert(!m_snap_native || screen != NULL);

	// create the bitmap to pass in
	create_snapshot_bitmap(screen);

	// add two text entries describing the image
	astring text1(emulator_info::get_appname(), " ", build_version);
	astring text2(machine().system().manufacturer, " ", machine().system().description);
	png_info pnginfo = { 0 };
	png_add_text(&pnginfo, "Software", text1);
	png_add_text(&pnginfo, "System", text2);

	// now do the actual work
	const rgb_t *palette = (machine().palette != NULL) ? palette_entry_list_adjusted(machine().palette) : NULL;
	png_error error = png_write_bitmap(file, &pnginfo, m_snap_bitmap, machine().total_colors(), palette);
	if (error != PNGERR_NONE)
		mame_printf_error("Error generating PNG for snapshot: png_error = %d\n", error);

	// free any data allocated
	png_free(&pnginfo);
}
예제 #17
0
// Return true iff S1 is a prefix of S2
static bool is_prefix(const MString& m1, const MString& m2)
{
    XmString s1 = m1.xmstring();
    XmString s2 = m2.xmstring();

    XmStringContext c1;
    XmStringContext c2;

    XmStringInitContext(&c1, s1);
    XmStringInitContext(&c2, s2);

    XmStringComponentType t1 = XmSTRING_COMPONENT_UNKNOWN;
    XmStringComponentType t2 = XmSTRING_COMPONENT_UNKNOWN;

    while (t1 != XmSTRING_COMPONENT_END && t2 != XmSTRING_COMPONENT_END)
    {
	char *s_text1            = 0;
	XmStringCharSet s_cs1    = 0;
	XmStringDirection d1     = XmSTRING_DIRECTION_DEFAULT;
	XmStringComponentType u1 = XmSTRING_COMPONENT_UNKNOWN;
	unsigned short ul1       = 0;
	unsigned char *s_uv1     = 0;
	
	t1 = XmStringGetNextComponent(c1, &s_text1, &s_cs1, &d1, 
				      &u1, &ul1, &s_uv1);

	char *s_text2            = 0;
	XmStringCharSet s_cs2    = 0;
	XmStringDirection d2     = XmSTRING_DIRECTION_DEFAULT;
	XmStringComponentType u2 = XmSTRING_COMPONENT_UNKNOWN;
	unsigned short ul2       = 0;
	unsigned char *s_uv2     = 0;

	t2 = XmStringGetNextComponent(c2, &s_text2, &s_cs2, &d2,
				      &u2, &ul2, &s_uv2);

	// Upon EOF in LessTif 0.82, XmStringGetNextComponent()
	// returns XmSTRING_COMPONENT_UNKNOWN instead of
	// XmSTRING_COMPONENT_END.  Work around this.
	if (t1 == XmSTRING_COMPONENT_UNKNOWN && s_uv1 == 0)
	    t1 = XmSTRING_COMPONENT_END;
	if (t2 == XmSTRING_COMPONENT_UNKNOWN && s_uv2 == 0)
	    t2 = XmSTRING_COMPONENT_END;

	// Place string values in strings
	string text1(s_text1 == 0 ? "" : s_text1);
	string text2(s_text2 == 0 ? "" : s_text2);
	string cs1(s_cs1 == 0 ? "" : s_cs1);
	string cs2(s_cs2 == 0 ? "" : s_cs2);
	string uv1;
	string uv2;
	if (s_uv1 != 0)
	    uv1 = string((char *)s_uv1, ul1);
	if (s_uv2 != 0)
	    uv2 = string((char *)s_uv2, ul2);

	// Free unused memory
	XtFree(s_text1);
	XtFree(s_text2);
	XtFree(s_cs1);
	XtFree(s_cs2);
	XtFree((char *)s_uv1);
	XtFree((char *)s_uv2);

	if (t1 != t2)
	{
	    goto done;		// Differing tags
	}

	switch (t1)
	{
	case XmSTRING_COMPONENT_CHARSET:
	{
	    if (cs1.empty())	// In LessTif 0.82, XmStringGetNextComponent()
		cs1 = text1;	// swaps CS and TEXT.  Work around this.
	    if (cs2.empty())
		cs2 = text2;

	    if (cs1 != cs2)
		goto done;	// Differing character sets
	    break;
	}

	case XmSTRING_COMPONENT_TEXT:
#if XmVersion >= 1002
	case XmSTRING_COMPONENT_LOCALE_TEXT:
#endif
#if XmVersion >= 2000
	case XmSTRING_COMPONENT_WIDECHAR_TEXT:
#endif
	{
	    if (text1.empty())	// In LessTif 0.82, XmStringGetNextComponent()
		text1 = cs1;	// swaps CS and TEXT.  Work around this.
	    if (text2.empty())
		text2 = cs2;

	    if (!text2.contains(text1, 0))
		goto done;
	    XmStringComponentType next2 = XmStringPeekNextComponent(c2);

	    // In LessTif 0.82, XmStringPeekNextComponent() returns
	    // XmSTRING_COMPONENT_UNKNOWN instead of
	    // XmSTRING_COMPONENT_END.  Work around this.
	    if (next2 != XmSTRING_COMPONENT_END && 
		next2 != XmSTRING_COMPONENT_UNKNOWN)
		goto done;
	    break;
	}

	case XmSTRING_COMPONENT_DIRECTION:
	{
	    if (d1 != d2)
		goto done;
	    break;
	}

	case XmSTRING_COMPONENT_SEPARATOR:
	case XmSTRING_COMPONENT_END:
	{
	    // These are the same by definition
	    break;
	}

	case XmSTRING_COMPONENT_UNKNOWN:
	{
	    if (uv1 != uv2)
		goto done;	// Differing unknown tags
	    break;
	}

	default:
	{
	    break;		// Skip everything else
	}
	}
    }
 done:

    XmStringFreeContext(c2);
    XmStringFreeContext(c1);

    return t1 == XmSTRING_COMPONENT_END;
}
예제 #18
0
ctConfigItem* ctFindReplaceDialog::FindNextItem(ctConfigToolDoc* doc,
                                                      ctConfigItem* item,
                                                      const wxString& text,
                                                      bool matchCase,
                                                      bool matchWordOnly,
                                                      bool wrap,
                                                      bool skipFirst)
{
    ctConfigItem* firstInDoc = NULL;

    wxString text2(text);
    if (!matchCase)
        text2.MakeLower();

    ctConfigItem* found = NULL;
    ctConfigItem* next = item;

    int i = 0;
    do
    {
        // If starting the search from beginning, we can now
        // set the value of 'item' in the 2nd iteration without immediately
        // dropping out of the while loop because card == next
        if (!item && (i > 0))
            item = firstInDoc;

        // We might want to start from this item if skipFirst is false.
        if ((i == 0) && !skipFirst && next)
        {
        }
        else
            next = doc->FindNextItem(next, wrap);

        // Save to be used in iteration 2
        if ((i == 0) && !item)
            firstInDoc = next;

        if (next)
        {
            wxString str(next->GetName());
            wxString description(next->GetPropertyString(wxT("description")));
            wxString notes(next->GetPropertyString(wxT("notes")));
            if (!matchCase)
            {
                str.MakeLower();
                description.MakeLower();
                notes.MakeLower();
            }
            if (ctMatchString(str, text2, matchWordOnly) ||
                ctMatchString(description, text2, matchWordOnly) ||
                ctMatchString(notes, text2, matchWordOnly))
            {
                found = next;
            }
        }
        else
            break; // Didn't find an item at all

        i ++;
    }
    while (!found && item != next);

    if (item == found && !firstInDoc)
        return NULL;
    else
        return found;
}
예제 #19
0
void CheckCapitalization::check_suspicious_capitalization(ustring & text)
/*
Checks on suspicious capitalization, like "bOat" or "BOat".
There are exceptions to this check.
*/
{
  // Load text into buffer.
  ustring text2(text);
  text2.append(" ");
  GtkTextBuffer *textbuffer;
  textbuffer = gtk_text_buffer_new(NULL);
  gtk_text_buffer_set_text(textbuffer, text2.c_str(), -1);
  // Iterators.  
  GtkTextIter startiter, enditer;
  // Check all separate words.
  gtk_text_buffer_get_start_iter(textbuffer, &enditer);
  while (gtk_text_iter_forward_word_end(&enditer)) {
    startiter = enditer;
    gtk_text_iter_backward_word_start(&startiter);
    vector < bool > capspattern;
    unsigned int capscount = 0;
    GtkTextIter iter = startiter;
    while (gtk_text_iter_in_range(&iter, &startiter, &enditer)) {
      bool upper = g_unichar_isupper(gtk_text_iter_get_char(&iter));
      capspattern.push_back(upper);
      if (upper)
        capscount++;
      gtk_text_iter_forward_char(&iter);
    }
    // No further checking if words are too short.
    if (capspattern.size() < 2)
      continue;
    // No further checking if only small letters.
    if (capscount == 0)
      continue;
    // No further checking if all capitals.
    if (capscount == capspattern.size())
      continue;
    // No further checking if first letter capitalized only.
    if ((capspattern[0]) && (capscount == 1))
      continue;
    // Ok, there could be a problem of mixed capitalization.
    // Get the prefix before the first capital, and the suffix after it.
    ustring word = gtk_text_iter_get_text(&startiter, &enditer);
    ustring uncapitalized_prefix;
    ustring capitalized_suffix;
    for (unsigned int i = 1; i < capspattern.size(); i++) {
      if (capspattern[i]) {
        uncapitalized_prefix = word.substr(0, i);
        capitalized_suffix = word.substr(i, word.length() - i);
        break;
      }
    }
    // See whether the suffix is properly capitalized.
    unsigned int suffix_capital_count = 0;
    for (unsigned int i = 0; i < capitalized_suffix.length(); i++) {
      if (g_unichar_isupper(g_utf8_get_char(capitalized_suffix.substr(i, 1).c_str())))
        suffix_capital_count++;
    }
    bool suffix_properly_capitalized = false;
    if (suffix_capital_count == 1)
      suffix_properly_capitalized = true;
    if (suffix_capital_count == capitalized_suffix.length())
      suffix_properly_capitalized = true;
    // Give message and continue if capitalization error in suffix, but only
    // if this so-called wrongly capitalized suffix has not been approved af.
    if (!suffix_properly_capitalized) {
      if (capitalized_suffixes.find(capitalized_suffix) == capitalized_suffixes.end()) {
        mixed_capitalization_message(word);
        continue;
      }
    }
    // No further checking if this uncapitalized prefix is in the list,
    // or any is allowed.
    if (uncapitalized_prefixes.find(uncapitalized_prefix) != uncapitalized_prefixes.end())
      continue;
    if (allow_any_uncapitalized_prefixes)
      continue;
    // Ok, not in the list. Try again with lower case initial.
    ustring initial = uncapitalized_prefix.substr(0, 1);
    initial = initial.casefold();
    uncapitalized_prefix.replace(0, 1, initial);
    if (uncapitalized_prefixes.find(uncapitalized_prefix) != uncapitalized_prefixes.end())
      continue;
    // No further checking if the suffix is in the list of approved suffixes.
    if (capitalized_suffixes.find(capitalized_suffix) != capitalized_suffixes.end())
      continue;
    // Ok, not found, but it could be this suffix is in all capitals. Handle that.
    initial = capitalized_suffix.substr(0, 1);
    capitalized_suffix.erase(0, 1);
    capitalized_suffix = capitalized_suffix.casefold();
    capitalized_suffix.insert(0, initial);
    if (capitalized_suffixes.find(capitalized_suffix) != capitalized_suffixes.end())
      continue;
    // Ok, it appears we've got an error here -> give message.
    mixed_capitalization_message(word);
  }
  // Free memory
  g_object_unref(textbuffer);
}
예제 #20
0
파일: inputdeluxe.cpp 프로젝트: beoran/sge
int main(int argc, char** argv)
{	
	/* Init SDL */
	if ( SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO) < 0 ) {
		fprintf(stderr, "Couldn't load SDL: %s\n", SDL_GetError());
		exit(1);
	}

	/* Clean up on exit */
	atexit(SDL_Quit);

	/* Set window title */
	SDL_WM_SetCaption("Input Deluxe", "input deluxe");
	
	/* Initialize the display */
	SDL_Surface *screen;
	screen = SDL_SetVideoMode(600, 400, 0, SDL_SWSURFACE);
	if ( screen == NULL ) {
		fprintf(stderr, "Couldn't set video mode: %s\n", SDL_GetError());
		exit(1);
	}
	
	sge_Update_OFF();
	SDL_EnableUNICODE(1); //This is VERY important!!
	
	//Init our text sprites
	sge_TextSprite text(screen,"Edit Me!",20,90);
	text.show_cursor(true);
	sge_TextSprite text2(screen,"Hello World!",100,25);
	text.show_cursor(true);
	
	//Set and draw the border box
	SDL_Rect r; r.x=1; r.y=81; r.w=598; r.h=318; 
	text.set_border(r);
	sge_Rect(screen,0,80, 599,399, 255,0,0);   
	
	//Open a TT font
	if(sge_TTF_Init()!=0){fprintf(stderr,"TT error: %s\n",SDL_GetError());exit(1);} 	
	sge_TTFont *font;
	font=sge_TTF_OpenFont("/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf", 25);
	if(font==NULL){fprintf(stderr,"TT error: %s\n",SDL_GetError());exit(1);}

	text.set_ttFont(font,0,255,0);    //Use our font
	text2.set_ttFont(font,50,50,200);
	text.set_pps(60,60);              //set speed (pixels/second)
	text2.set_pps(-170,0);
	text.border_warp(true);           //WARP!
	text2.border_warp(true);
	
	
	SDL_UpdateRect(screen, 0,0,0,0); //Update whole screen
	
	//Keyrepeat
	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL+50);
	
	SDL_Event event;
	do{
		//SDL_Delay(1);
	
		/* Check events */
		if(SDL_PollEvent(&event)==1){
			if(event.type==SDL_QUIT){break;}
			if(event.type==SDL_KEYDOWN && event.key.keysym.sym==SDLK_ESCAPE){break;}
			
			text.check(&event);  //Let our text sprite handle the event (editing the text)
		}
		
		if(text.update()){       //update() calculates the new pos and returns true if we need to redraw
			text.clear(0);       //clear text area
			text.draw();         //draw text at new pos
			sge_Update_ON();     
			text.UpdateRects();  //Update screen (old pos + new pos)
			sge_Update_OFF();
		}	
		if(text2.update()){      //Same thing for the other sprite
			text2.clear(0);
			text2.draw();
			sge_Update_ON();     
			text2.UpdateRects();
			sge_Update_OFF();
		}
		
	}while(true);
	
	
	sge_TTF_CloseFont(font);
	return 0;
}
예제 #21
0
TextCache::Result
TextCache::Get(const Font &font, const char *text)
{
#ifdef ENABLE_OPENGL
  assert(pthread_equal(pthread_self(), OpenGL::thread));
#endif
  assert(font.IsDefined());
  assert(text != nullptr);

  if (StringIsEmpty(text)) {
#ifdef ENABLE_OPENGL
    return nullptr;
#else
    return Result::Null();
#endif
  }

  TextCacheKey key(font, text);

  /* look it up */

#ifndef ENABLE_OPENGL
  const Poco::ScopedLock<Poco::Mutex> protect(text_cache_mutex);
#endif

  const RenderedText *cached = text_cache.Get(key);
  if (cached != nullptr)
    return *cached;

  /* render the text into a OpenGL texture */

#ifdef USE_FREETYPE
#if defined(USE_FREETYPE) && defined(UNICODE)
  UTF8ToWideConverter text2(text);
#else
  const TCHAR* text2 = text;
#endif
  PixelSize size = font.TextSize(text2);
  size_t buffer_size = font.BufferSize(size);
  if (buffer_size == 0) {
#ifdef ENABLE_OPENGL
    return nullptr;
#else
    return Result::Null();
#endif
  }

  uint8_t *buffer = new uint8_t[buffer_size];
  if (buffer == nullptr) {
#ifdef ENABLE_OPENGL
    return nullptr;
#else
    return Result::Null();
#endif
  }

  font.Render(text2, size, buffer);
  RenderedText rt(size.cx, size.cy, buffer);
#ifdef ENABLE_OPENGL
  delete[] buffer;
#endif
#elif defined(ANDROID)
  PixelSize size, allocated_size;
  int texture_id = font.TextTextureGL(text, size, allocated_size);
  if (texture_id == 0)
    return nullptr;

  RenderedText rt(texture_id, size.cx, size.cy,
                  allocated_size.cx, allocated_size.cy);
#else
#error No font renderer
#endif

  Result result = rt;

  key.Allocate();
  text_cache.Put(std::move(key), std::move(rt));

  /* done */

  return result;
}
예제 #22
0
void GraphicTestWindow::onPaint(int width, int height)
{
	glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

	_image.setTextureCoordinate(1, 3);
	_image.setSize(_image.originalSize());
	_image.draw();

	_rect.setColor(QColor(0, 255, 0));
	_rect.setRect(50, 100, 500, 75);
	_rect.draw();

	_rect.setColor(QColor(0, 255, 255));
	_rect.setRect(50, 175, 500, 25);
	_rect.draw();

	int textCount = 1;
	int quadCount = 1;
	QString textContent("Change the text from the settings");

	if(_settings) {
		quadCount = _settings->quadCount();
		textCount = _settings->textCount();
		textContent = _settings->textContent();
	}

	for(int i = 0; i < textCount; i++) {
		PhGraphicText text1(&_font1, textContent);

		text1.setRect(i % 200, i / 200, 500, 100);
		text1.setColor(QColor(128, 255, 0));
		text1.setZ(5);
		text1.draw();
	}

	_font1.setFontFile(_settings->font1File());
	_font1.select();

	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);
	glColor3f(0, 0, 1);

	glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);


	glBegin(GL_QUADS);  //Begining the cube's drawing
	{
		for(int i = 0; i < quadCount; i++) {
			glTexCoord3f(0, 0, 1);  glVertex3i(0, 0, 0);
			glTexCoord3f(1, 0, 1);  glVertex3i(width, 0, 0);
			glTexCoord3f(1, 1, 1);  glVertex3i(width, height, 0);
			glTexCoord3f(0, 1, 1);  glVertex3i(0,  height, 0);
		}
	}
	glEnd();

	glDisable(GL_TEXTURE_2D);
	glDisable(GL_BLEND);

	//	_text.setX(_text.getX() + 4);
	//	if(_text.getX() > this.width())
	//		_text.setX(0);
	//	if((_text.getX()+_text.getWidth()) < 0)
	//		_text.setX(this.width());

	PhGraphicSolidRect rect3(0, 800, 400, 300);
	rect3.setColor(Qt::blue);
	rect3.draw();

	PhGraphicLoop vLoop;
	vLoop.setPosition(100, 500, 3);
	vLoop.setSize(220, 200);
	vLoop.setThickness(30);
	vLoop.setCrossSize(100);
	vLoop.setColor(QColor(255, 0, 255));
	vLoop.draw();

	PhGraphicLoop hLoop;
	hLoop.setHorizontalLoop(true);
	hLoop.setPosition(0, 800, 3);
	hLoop.setSize(300, 50);
	hLoop.setThickness(20);
	hLoop.setCrossSize(60);
	hLoop.setColor(QColor(255, 0, 255));
	hLoop.draw();

	//_yuvRect.draw();

	PhGraphicDisc disc(300, 300, 100);
	disc.setColor(Qt::yellow);
	disc.draw();

	for (int i = 0; i < 5; ++i) {
		PhGraphicDashedLine line(i, 0, 50*i, 300, 30);
		line.setColor(Qt::green);
		line.setZ(4);
		line.draw();
	}

	PhGraphicArrow arrow1(PhGraphicArrow::DownLeftToUpRight, 150, 250, 200, 100);
	arrow1.setColor(Qt::red);
	arrow1.setZ(5);
	arrow1.draw();

	PhGraphicArrow arrow2(PhGraphicArrow::UpLefToDownRight, 150, 400, 200, 100);
	arrow2.setColor(Qt::red);
	arrow2.setZ(5);
	arrow2.draw();

	_yuvRect.draw();
	_rgbRect.draw();

	_font2.setFontFile(_settings->font2File());
	_font2.select();

	PhGraphicText text2(&_font2, "eéaàiîoô");
	int textWidth = 500;
	text2.setRect(_x, 300, textWidth, 100);
	text2.setColor(QColor(255, 0, 0));
	text2.setZ(1);
	text2.draw();

	_x += 4;
	if(_x > width)
		_x = -textWidth;
}
예제 #23
0
QPixmap DItemDelegate::makeDragPixmap(const QStyleOptionViewItem& option,
                                      const QList<QModelIndex>& indexes,
                                      const QPixmap& suggestedPixmap)
{
    QPixmap icon = suggestedPixmap;

    if (icon.isNull())
    {
        icon = QPixmap(DesktopIcon("image-jp2", KIconLoader::SizeMedium));
    }

    if (qMax(icon.width(), icon.height()) > KIconLoader::SizeHuge)
    {
        icon = icon.scaled(KIconLoader::SizeHuge, KIconLoader::SizeHuge,
                           Qt::KeepAspectRatio, Qt::SmoothTransformation);
    }

    int w                 = icon.width();
    int h                 = icon.height();
    const int borderWidth = 6;

    QRect   rect(0, 0, w + borderWidth*2, h + borderWidth*2);
    QRect   pixmapRect(borderWidth, borderWidth, w, h);

    QPixmap pix(rect.size());
    QPainter p(&pix);

/* 
    // border
    p.fillRect(0, 0, pix.width()-1, pix.height()-1, QColor(Qt::white));
    p.setPen(QPen(Qt::black, 1));
    p.drawRect(0, 0, pix.width()-1, pix.height()-1);
*/

    QStyleOption opt(option);
    opt.rect = rect;
    qApp->style()->drawPrimitive(QStyle::PE_PanelTipLabel, &opt, &p);

    p.drawPixmap(pixmapRect.topLeft(), icon);

    QFont f(option.font);
    f.setBold(true);
    p.setFont(f);

    if (indexes.size() > 1)
    {
        QRect   textRect;
        QString text;

        QString text2(i18np("1 Image", "%1 Images", indexes.count()));
        QString text1 = QString::number(indexes.count());
        QRect r1      = p.boundingRect(pixmapRect, Qt::AlignLeft|Qt::AlignTop, text1).adjusted(0,0,1,1);
        QRect r2      = p.boundingRect(pixmapRect, Qt::AlignLeft|Qt::AlignTop, text2).adjusted(0,0,1,1);

        if (r2.width() > pixmapRect.width() || r2.height() > pixmapRect.height())
        {
//            textRect     = r1;
            text         = text1;
            int rectSize = qMax(r1.width(), r1.height());
            textRect     = QRect(0, 0, rectSize, rectSize);
        }
        else
        {
            textRect = QRect(0, 0, r2.width(), r2.height());
            text     = text2;
        }

        textRect.moveLeft((pixmapRect.width() - textRect.width()) / 2 + pixmapRect.x());
        textRect.moveTop((pixmapRect.height() - textRect.height()) * 4 / 5);
        p.fillRect(textRect, QColor(0, 0, 0, 128));
        p.setPen(Qt::white);
        p.drawText(textRect, Qt::AlignCenter, text);
    }

    return pix;
}
예제 #24
0
파일: Game.cpp 프로젝트: gardnerd/SHMUP
//show splash screen (BLOCKING)
bool Game::ShowSplashScreen()
{

    sf::String titleText("Ace SPACE Pilot");
    sf::Text title(titleText, datagoth);
    title.setCharacterSize(50);
    //title.setStyle(sf::Text::Bold);
    title.setColor(sf::Color::White);
    title.setPosition(288-(title.getGlobalBounds().width/2), 280);

    sf::String prompt("Press Enter to Begin");
    sf::Text text(prompt, datagoth);
    text.setCharacterSize(24);
    text.setColor(sf::Color::White);
    text.setPosition(288-text.getGlobalBounds().width/2, 725);

    sf::String fpsString("\nESC to Quit\nP to Pause\nSPACE to Fire\nWASD to Move");
    sf::Text text2(fpsString, datagoth);
    text2.setCharacterSize(20);
    text2.setColor(sf::Color::White);
    text2.setPosition(596, 650);

    music[0].openFromFile("sounds/menu_bgm.ogg");
    music[0].play();

    music[1].openFromFile("sounds/stage_bgm.ogg");
    music[1].setVolume(60);

    sf::Event event;
    while(true)
    {
        while(mainWindow.pollEvent(event))
        {
           if(event.type == sf::Event::Resized)
           {
                float aspectRatio = float(event.size.width)/float(event.size.height);
                float newHeight = (1024.f*event.size.height)/event.size.width;
                float newWidth = (768.f*event.size.width)/event.size.height;
                if(aspectRatio > (4.f/3.f))
                {
                    float displace = (newWidth - 1024.f)/(-2.f);
                    View = sf::View(sf::FloatRect(displace, 0, newWidth, 768));
                }
                else if(aspectRatio < (4.f/3.f))
                {
                    float displace = (newHeight - 768.f)/(-2.f);
                    View = sf::View(sf::FloatRect(0, displace, 1024, newHeight));
                }
                mainWindow.setView(View);
           }
           if((event.type == (sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Return)))
           {
               sounds[1].play();
                return 1;
           }
           if((event.type == (sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)) || event.type == sf::Event::Closed )
           {
             return 0;
           }
        }

        //update paralaxed backgrounds
        if(bgMove1 > (2500-768))
            bgMove1 = 0;
        bgMove1 += 2;
        background1.sprite.setTextureRect(sf::Rect<int>(0,(2500-768)-bgMove1,576,768));

        mainWindow.draw(wholeArea);
        mainWindow.draw(spawnArea);
        background0.Draw(mainWindow);
        background1.Draw(mainWindow);
        mainWindow.draw(rightBound);
        mainWindow.draw(leftBound);
        mainWindow.draw(bottomBound);
        mainWindow.draw(title);
        mainWindow.draw(text);
        mainWindow.draw(text2);
        scoreboard.drawScoreboard(mainWindow, player1.sprite);
        mainWindow.display();
    }
}
예제 #25
0
int compare( const void *arg1, const void *arg2 )
{
	try {

		const I_MapItem *i1 = *reinterpret_cast<I_MapItem**>(const_cast<void*>(arg1));
		const I_MapItem *i2 = *reinterpret_cast<I_MapItem**>(const_cast<void*>(arg2));

		C_TextPtr text1(const_cast<I_MapItem*>(i1));
		C_TextPtr text2(const_cast<I_MapItem*>(i2));

		if (text1 && !text2) {
			return 1;
		}
		else if (text2 && !text1) {
			return -1;
		}

		C_PicturePtr pic1(const_cast<I_MapItem*>(i1));
		C_PicturePtr pic2(const_cast<I_MapItem*>(i2));

		if (pic1 && !pic2) {
			return 1;
		}
		else if (pic2 && !pic1) {
			return -1;
		}

		C_PositionPtr p1(const_cast<I_MapItem*>(i1));
		C_PositionPtr p2(const_cast<I_MapItem*>(i2));

		if (p1 && p2) {

			C_Area area1(p1.GetPoints());
			C_Area area2(p2.GetPoints());

			int n = 0;
			int cnt1 = area1.GetLength();
			int cnt2 = area2.GetLength();

			if (0 == cnt1) {
				return -1;
			}

			if (0 == cnt2) {
				return 1;
			}

			POINT3D *ptr1 = area1[cnt1 - 1];
			POINT3D *ptr2 = area2[cnt2 - 1];

			if (ptr1->x < 0 && ptr2->x > 0) {
				n = -1;
			}
			else if (ptr1->x > 0 && ptr2->x < 0) {
				n = 1;
			}
			else if (ptr1->y < ptr2->y) {
				n = -1;
			}
			else if (ptr1->y > ptr2->y) {
				n = 1;
			}

			if (0 == n) {

				if (cnt1 < cnt2) {
					n = -1;
				}
				else if (cnt1 > cnt2) {
					n = 1;
				}
			}

			if (0 != n) {
				return n;
			}
		}

		C_UniquePtr u1(const_cast<I_MapItem*>(i1));
		C_UniquePtr u2(const_cast<I_MapItem*>(i2));

		if (!u1 && !u2) {
			return 0;
		}
		else if (!u1) {
			return -1;
		}
		else if (!u2) {
			return 1;
		}
		else {

			BSTR bs1 = NULL;
			BSTR bs2 = NULL;

			u1->get_UID(&bs1);
			u2->get_UID(&bs2);

			int n = ::wcscmp(bs1, bs2);

			String::FreeBSTR(&bs1);
			String::FreeBSTR(&bs2);

			return n;
		}
	}
	catch (C_STLNonStackException const &exception) {
		exception.Log(_T("Exception in Items.cpp (compare)"));
	}

	return 0;
}