void onSelect( Gwen::Controls::Base* pControl ) { Gwen::Controls::ComboBox* but = (Gwen::Controls::ComboBox*) pControl; Gwen::String str = Gwen::Utility::UnicodeToString( but->GetSelectedItem()->GetText()); if (m_callback) (*m_callback)(m_buttonId,str.c_str(),m_userPointer); }
virtual void LoadTexture(Gwen::Texture* pTexture) { Gwen::String namestr = pTexture->name.Get(); const char* n = namestr.c_str(); GLint* texIdPtr = m_hashMap[n]; if (texIdPtr) { pTexture->m_intData = *texIdPtr; } }
void onButtonC(Gwen::Controls::Base* pControl) { Gwen::Controls::Label* label = (Gwen::Controls::Label*) pControl; Gwen::UnicodeString la = label->GetText();// node->GetButton()->GetName();// GetText(); Gwen::String laa = Gwen::Utility::UnicodeToString(la); const char* ha = laa.c_str(); // printf("onButtonC ! %s\n", ha); }
void onButtonB(Gwen::Controls::Base* pControl) { Gwen::Controls::Label* label = (Gwen::Controls::Label*) pControl; Gwen::UnicodeString la = label->GetText();// node->GetButton()->GetName();// GetText(); Gwen::String laa = Gwen::Utility::UnicodeToString(la); const char* ha = laa.c_str(); selectDemo(sCurrentHightlighted); saveCurrentDemoEntry(sCurrentDemoIndex, startFileName); }
void onButtonA(Gwen::Controls::Base* pControl) { const Gwen::String& name = pControl->GetName(); Gwen::Controls::TreeNode* node = (Gwen::Controls::TreeNode*)pControl; Gwen::Controls::Label* l = node->GetButton(); Gwen::UnicodeString la = node->GetButton()->GetText();// node->GetButton()->GetName();// GetText(); Gwen::String laa = Gwen::Utility::UnicodeToString(la); const char* ha = laa.c_str(); //printf("selected %s\n", ha); //int dep = but->IsDepressed(); //int tog = but->GetToggleState(); // if (m_data->m_toggleButtonCallback) // (*m_data->m_toggleButtonCallback)(m_buttonId, tog); }
void SDL2Renderer::RenderText(Gwen::Font* pFont, Gwen::Point pos, const Gwen::String& text) { TTF_Font *tfont = static_cast<TTF_Font*>(pFont->data); Translate(pos.x, pos.y); SDL_Surface *surf = TTF_RenderUTF8_Blended(tfont, text.c_str(), m_color); SDL_Texture *texture = SDL_CreateTextureFromSurface(m_renderer, surf); SDL_FreeSurface(surf); int w, h; SDL_QueryTexture(texture, NULL, NULL, &w, &h); const SDL_Rect dest = { pos.x,pos.y, w,h }; SDL_RenderCopy(m_renderer, texture, NULL, &dest); SDL_DestroyTexture(texture); }
Gwen::Point SDL2Renderer::MeasureText(Gwen::Font* pFont, const Gwen::String& text) { TTF_Font *tfont = static_cast<TTF_Font*>(pFont->data); // If the font doesn't exist, or the font size should be changed. if (!tfont || pFont->realsize != pFont->size*Scale()) { FreeFont(pFont); LoadFont(pFont); tfont = static_cast<TTF_Font*>(pFont->data); } if (!tfont) return Gwen::Point(0, 0); int w,h; TTF_SizeUTF8(tfont, text.c_str(), &w,&h); return Point(w,h); }
float Gwen::Utility::Strings::To::Float( const Gwen::String& str ) { if ( str == "" ) return 0.0f; return (float)atof( str.c_str() ); }
int Gwen::Utility::Strings::To::Int( const Gwen::String& str ) { if ( str == "" ) return 0; return atoi( str.c_str() ); }