本文整理汇总了C++中THRenderTarget::getWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ THRenderTarget::getWidth方法的具体用法?C++ THRenderTarget::getWidth怎么用?C++ THRenderTarget::getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THRenderTarget
的用法示例。
在下文中一共展示了THRenderTarget::getWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: l_font_draw_tooltip
static int l_font_draw_tooltip(lua_State *L)
{
THFont* pFont = luaT_testuserdata<THFont>(L);
THRenderTarget* pCanvas = luaT_testuserdata<THRenderTarget>(L, 2);
size_t iMsgLen;
const char* sMsg = luaT_checkstring(L, 3, &iMsgLen);
int iX = static_cast<int>(luaL_checkinteger(L, 4));
int iY = static_cast<int>(luaL_checkinteger(L, 5));
int iScreenWidth = pCanvas->getWidth();
int iW = 200; // (for now) hardcoded width of tooltips
uint32_t iBlack = pCanvas->mapColour(0x00, 0x00, 0x00);
uint32_t iWhite = pCanvas->mapColour(0xFF, 0xFF, 0xFF);
THFontDrawArea oArea = pFont->drawTextWrapped(nullptr, sMsg, iMsgLen, iX + 2, iY + 1, iW - 4, INT_MAX, 0);
int iLastX = iX + oArea.iWidth + 3;
int iFirstY = iY - (oArea.iEndY - iY) - 1;
int iXOffset = iLastX > iScreenWidth ? iScreenWidth - iLastX : 0;
int iYOffset = iFirstY < 0 ? -iFirstY : 0;
pCanvas->fillRect(iBlack, iX + iXOffset, iFirstY + iYOffset, oArea.iWidth + 3, oArea.iEndY - iY + 2);
pCanvas->fillRect(iWhite, iX + iXOffset + 1, iFirstY + 1 + iYOffset, oArea.iWidth + 1, oArea.iEndY - iY);
pFont->drawTextWrapped(pCanvas, sMsg, iMsgLen, iX + 2 + iXOffset, iFirstY + 1 + iYOffset, iW - 4);
lua_pushinteger(L, oArea.iEndY);
return 1;
}