//prepare info text void CImageInfo::InitInfoText(const std::string& text) { //get window body object CComponentsForm *winbody = cc_win->getBodyObject(); int h_body = winbody->getHeight(); int w_body = winbody->getWidth(); //add a caption for info contents Font * caption_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]; int caption_height = caption_font->getHeight(); if (cc_sub_caption == NULL) cc_sub_caption = new CComponentsLabel(cc_info->getXPos(), CC_APPEND, cc_info->getWidth(), caption_height, g_Locale->getText(LOCALE_IMAGEINFO_LICENSE), CTextBox::AUTO_WIDTH, item_font); if (!cc_sub_caption->isAdded()) cc_win->addWindowItem(cc_sub_caption); //add info text box int h_txt = h_body - item_offset - cc_info->getHeight() - cc_sub_caption->getHeight() - item_offset; if (cc_lic == NULL) cc_lic = new CComponentsInfoBox(CC_CENTERED, CC_APPEND, w_body-2*item_offset, h_txt); cc_lic->setSpaceOffset(1); cc_lic->setText(text, CTextBox::TOP | CTextBox::AUTO_WIDTH | CTextBox::SCROLL, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]); cc_lic->doPaintTextBoxBg(true); //add text to container if (!cc_lic->isAdded()) cc_win->addWindowItem(cc_lic); }
int CLuaInstCCText::CCTextNew(lua_State *L) { lua_assert(lua_istable(L,1)); CLuaCCWindow* parent = NULL; lua_Integer x=10, y=10, dx=-1, dy=-1; std::string text = ""; std::string tmpMode = ""; lua_Integer mode = CTextBox::AUTO_WIDTH; lua_Integer font_text = SNeutrinoSettings::FONT_TYPE_MENU; lua_Unsigned color_text = (lua_Unsigned)COL_MENUCONTENT_TEXT; lua_Unsigned color_frame = (lua_Unsigned)COL_FRAME_PLUS_0; lua_Unsigned color_body = (lua_Unsigned)COL_MENUCONTENT_PLUS_0; lua_Unsigned color_shadow = (lua_Unsigned)COL_SHADOW_PLUS_0; tableLookup(L, "parent", (void**)&parent); tableLookup(L, "x", x); tableLookup(L, "y", y); tableLookup(L, "dx", dx); tableLookup(L, "dy", dy); tableLookup(L, "text", text); tableLookup(L, "mode", tmpMode); tableLookup(L, "font_text", font_text); if (font_text >= SNeutrinoSettings::FONT_TYPE_COUNT || font_text < 0) font_text = SNeutrinoSettings::FONT_TYPE_MENU; lua_Integer shadow_mode = CC_SHADOW_OFF; if (!tableLookup(L, "has_shadow", shadow_mode)) { std::string tmp1 = "false"; if (tableLookup(L, "has_shadow", tmp1)) paramBoolDeprecated(L, tmp1.c_str()); shadow_mode = (tmp1 == "true" || tmp1 == "1" || tmp1 == "yes"); } tableLookup(L, "color_text", color_text); tableLookup(L, "color_frame", color_frame); tableLookup(L, "color_body", color_body); tableLookup(L, "color_shadow", color_shadow); color_text = checkMagicMask(color_text); color_frame = checkMagicMask(color_frame); color_body = checkMagicMask(color_body); color_shadow = checkMagicMask(color_shadow); if (!tmpMode.empty()) { table_key txt_align[] = { { "ALIGN_AUTO_WIDTH", CTextBox::AUTO_WIDTH }, { "ALIGN_AUTO_HIGH", CTextBox::AUTO_HIGH }, { "ALIGN_SCROLL", CTextBox::SCROLL }, { "ALIGN_CENTER", CTextBox::CENTER }, { "ALIGN_RIGHT", CTextBox::RIGHT }, { "ALIGN_TOP", CTextBox::TOP }, { "ALIGN_BOTTOM", CTextBox::BOTTOM }, { "ALIGN_NO_AUTO_LINEBREAK", CTextBox::NO_AUTO_LINEBREAK }, { "DECODE_HTML", 0 }, { NULL, 0 } }; mode = 0; for (int i = 0; txt_align[i].name; i++) { if (tmpMode.find(txt_align[i].name) != std::string::npos) mode |= txt_align[i].code; } if (tmpMode.find("DECODE_HTML") != std::string::npos) htmlEntityDecode(text); } CComponentsForm* pw = (parent && parent->w) ? parent->w->getBodyObject() : NULL; if(pw){ if(dy < 1) dy = pw->getHeight(); if(dx < 1) dx = pw->getWidth(); } if(dx < 1) dx = 100; if(dy < 1) dy = 100; CLuaCCText **udata = (CLuaCCText **) lua_newuserdata(L, sizeof(CLuaCCText *)); *udata = new CLuaCCText(); (*udata)->ct = new CComponentsText(x, y, dx, dy, text, mode, g_Font[font_text], 0 /*TODO: style not passed*/, pw, shadow_mode, (fb_pixel_t)color_text, (fb_pixel_t)color_frame, (fb_pixel_t)color_body, (fb_pixel_t)color_shadow); (*udata)->parent = pw; (*udata)->mode = mode; (*udata)->font_text = font_text; luaL_getmetatable(L, "ctext"); lua_setmetatable(L, -2); return 1; }