本文整理汇总了C++中setWidth函数的典型用法代码示例。如果您正苦于以下问题:C++ setWidth函数的具体用法?C++ setWidth怎么用?C++ setWidth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setWidth函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dlg
// -----------------------------------------------------------------------------
// Static function to check if an archive has sufficient texture related
// entries, and if not, prompts the user to either create or import them.
// Returns true if the entries exist, false otherwise
// -----------------------------------------------------------------------------
bool TextureXEditor::setupTextureEntries(Archive* archive)
{
using Format = TextureXList::Format;
// Check any archive was given
if (!archive)
return false;
// Search archive for any ZDoom TEXTURES entries
Archive::SearchOptions options;
options.match_type = EntryType::fromId("zdtextures");
auto entry_tx = archive->findFirst(options); // Find any TEXTURES entry
// If it's found, we're done
if (entry_tx)
return true;
// Search archive for any texture-related entries
options.match_type = EntryType::fromId("texturex");
entry_tx = archive->findFirst(options); // Find any TEXTUREx entry
options.match_type = EntryType::fromId("pnames");
auto entry_pnames = archive->findFirst(options); // Find any PNAMES entry
// If both exist, we're done
if (entry_tx && entry_pnames)
return true;
// Todo: accept entry_tx without pnames if the textures are in Jaguar mode
// If no TEXTUREx entry exists
if (!entry_tx)
{
// No TEXTUREx entries found, so ask if the user wishes to create one
wxMessageDialog dlg(
nullptr,
"The archive does not contain any texture definitions (TEXTURE1/2 or TEXTURES). "
"Do you wish to create or import a texture definition list?",
"No Texture Definitions Found",
wxYES_NO);
if (dlg.ShowModal() == wxID_YES)
{
CreateTextureXDialog ctxd(nullptr);
while (true)
{
// Check if cancelled
if (ctxd.ShowModal() == wxID_CANCEL)
return false;
if (ctxd.createNewSelected())
{
// User selected to create a new TEXTUREx list
ArchiveEntry* texturex = nullptr;
// Doom or Strife TEXTUREx
if (ctxd.getSelectedFormat() == Format::Normal || ctxd.getSelectedFormat() == Format::Strife11)
{
// Create texture list
TextureXList txlist;
txlist.setFormat(ctxd.getSelectedFormat());
// Create patch table
PatchTable ptt;
// Create dummy patch
auto dpatch = App::archiveManager().programResourceArchive()->entryAtPath("s3dummy.lmp");
archive->addEntry(dpatch, "patches", true);
ptt.addPatch("S3DUMMY");
// Create dummy texture
auto dummytex = std::make_unique<CTexture>();
dummytex->setName("S3DUMMY");
dummytex->addPatch("S3DUMMY", 0, 0);
dummytex->setWidth(128);
dummytex->setHeight(128);
dummytex->setScale({ 0., 0. });
// Add dummy texture to list
// (this serves two purposes - supplies the special 'invalid' texture by default,
// and allows the texturex format to be detected)
txlist.addTexture(std::move(dummytex));
// Add empty PNAMES entry to archive
entry_pnames = archive->addNewEntry("PNAMES");
ptt.writePNAMES(entry_pnames);
entry_pnames->setType(EntryType::fromId("pnames"));
entry_pnames->setExtensionByType();
// Add empty TEXTURE1 entry to archive
texturex = archive->addNewEntry("TEXTURE1");
txlist.writeTEXTUREXData(texturex, ptt);
texturex->setType(EntryType::fromId("texturex"));
texturex->setExtensionByType();
//.........这里部分代码省略.........
示例2: getWidth
void Block::switchWidthAndHeight(void) {
int temp = getWidth();
setWidth(getHeight());
setHeight(temp);
}
示例3: setWidth
void VideoPlayer::parse(QVariantMap qMap)
{
setWidth(qMap["width"].toInt());
setEmbedCode(qMap["embed_code"].toString());
}
示例4: Widget
WidgetToggle::WidgetToggle(std::string name, bool initState) : Widget(),state(initState), name(name), listener(NULL) {
setListenToMouse(true);
setWidth(1);
setHeight(1);
}
示例5: setWidth
void Button::adjustSize()
{
setWidth(getFont()->getWidth(mCaption) + 2*mSpacing);
setHeight(getFont()->getHeight() + 2*mSpacing);
}
示例6: setFullscreen
void Movie::init()
{
if (_initialized) return;
State::init();
setFullscreen(true);
setModal(true);
Game::getInstance()->mouse()->pushState(Input::Mouse::Cursor::NONE);
auto renderer = Game::getInstance()->renderer();
setPosition((renderer->size() - Point(640, 320)) / 2);
auto lst = ResourceManager::getInstance()->lstFileType("data/movies.lst");
std::string movie = "art/cuts/" + lst->strings()->at(_id);
auto cfglst = ResourceManager::getInstance()->lstFileType("data/moviecfgs.lst");
std::string moviecfgfile = "art/cuts/" + cfglst->strings()->at(_id);
_effects.push_back({0,1, 0, 0, 0, 1});
if (cfglst->strings()->at(_id)!="reserved.cfg")
{
auto moviecfg = ResourceManager::getInstance()->datFileItem(moviecfgfile);
//parse ini
moviecfg->setPosition(0);
std::istream str(moviecfg);
auto inifile = new Ini::Parser(str);
auto ini = inifile->parse();
int total_effects = ini->section("info")->propertyInt("total_effects",0);
auto effect_frames = ini->section("info")->propertyArray("effect_frames");
for (int i =0;i<total_effects;i++)
{
unsigned int effect_frame = effect_frames.at(i).intValue();
std::string effect_section = effect_frames.at(i).value();
int dir = (ini->section(effect_section)->propertyString("fade_type","in") == "in" ? -1 : 1);
int steps = ini->section(effect_section)->propertyInt("fade_steps",0);
auto colors = ini->section(effect_section)->propertyArray("fade_color");
int r = colors[0].intValue()*4;
int g = colors[1].intValue()*4;
int b = colors[2].intValue()*4;
_effects.push_back({effect_frame, dir, r, g, b, steps/15*1000});
}
}
else
{
_effects.push_back({1,-1, 0, 0, 0, 1});
}
auto sublst = ResourceManager::getInstance()->lstFileType("data/subtitles.lst");
std::string subfile = "text/english/cuts/" + sublst->strings()->at(_id);
if (sublst->strings()->at(_id)!="reserved.sve")
{
_subs = ResourceManager::getInstance()->sveFileType(subfile);
if (_subs) _hasSubs = true;
}
addUI("movie", new UI::MvePlayer(ResourceManager::getInstance()->mveFileType(movie)));
auto font0_ffffffff = ResourceManager::getInstance()->font("font1.aaf");
auto subLabel = new UI::TextArea("", 0, 320+35);
subLabel->setFont(font0_ffffffff, {0xFF, 0xFF, 0xFF, 0xFF});
subLabel->setWidth(640);
subLabel->setHorizontalAlign(UI::TextArea::HorizontalAlign::CENTER);
addUI("subs",subLabel);
if (_hasSubs)
_nextSubLine = _subs->getSubLine(0);
else
_nextSubLine = std::pair<int,std::string>(999999,"");
}
示例7: GetPageSize
QSize TextDocumentAdapter::GetPageSize (int) const
{
auto size = Doc_->pageSize ();
size.setWidth (std::ceil (size.width ()));
return size.toSize ();
}
示例8: getFont
void BrowserBox::addRow(const std::string &row)
{
std::string tmp = row;
std::string newRow;
BROWSER_LINK bLink;
std::string::size_type idx1, idx2, idx3;
gcn::Font *font = getFont();
// Use links and user defined colors
if (mUseLinksAndUserColors)
{
// Check for links in format "@@link|[email protected]@"
idx1 = tmp.find("@@");
while (idx1 != std::string::npos)
{
idx2 = tmp.find("|", idx1);
idx3 = tmp.find("@@", idx2);
if (idx2 == std::string::npos || idx3 == std::string::npos)
break;
bLink.link = tmp.substr(idx1 + 2, idx2 - (idx1 + 2));
bLink.caption = tmp.substr(idx2 + 1, idx3 - (idx2 + 1));
bLink.y1 = mTextRows.size() * font->getHeight();
bLink.y2 = bLink.y1 + font->getHeight();
newRow += tmp.substr(0, idx1);
std::string tmp2 = newRow;
idx1 = tmp2.find("##");
while (idx1 != std::string::npos)
{
tmp2.erase(idx1, 3);
idx1 = tmp2.find("##");
}
bLink.x1 = font->getWidth(tmp2) - 1;
bLink.x2 = bLink.x1 + font->getWidth(bLink.caption) + 1;
mLinks.push_back(bLink);
newRow += "##<" + bLink.caption;
tmp.erase(0, idx3 + 2);
if (!tmp.empty())
{
newRow += "##>";
}
idx1 = tmp.find("@@");
}
newRow += tmp;
}
// Don't use links and user defined colors
else
{
newRow = row;
}
mTextRows.push_back(newRow);
//discard older rows when a row limit has been set
if (mMaxRows > 0)
{
while (mTextRows.size() > mMaxRows)
{
mTextRows.pop_front();
for (unsigned int i = 0; i < mLinks.size(); i++)
{
mLinks[i].y1 -= font->getHeight();
mLinks[i].y2 -= font->getHeight();
if (mLinks[i].y1 < 0)
mLinks.erase(mLinks.begin() + i);
}
}
}
// Auto size mode
if (mMode == AUTO_SIZE)
{
std::string plain = newRow;
for (idx1 = plain.find("##"); idx1 != std::string::npos; idx1 = plain.find("##"))
plain.erase(idx1, 3);
// Adjust the BrowserBox size
int w = font->getWidth(plain);
if (w > getWidth())
setWidth(w);
}
if (mMode == AUTO_WRAP)
{
unsigned int y = 0;
unsigned int nextChar;
const char *hyphen = "~";
int hyphenWidth = font->getWidth(hyphen);
int x = 0;
for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); i++)
{
std::string row = *i;
//.........这里部分代码省略.........
示例9: setWidth
/*!
Sets the size of the rectangle to size.
Changes x2 and y2 only.
*/
void QwtDoubleRect::setSize(const QwtDoubleSize &size)
{
setWidth(size.width());
setHeight(size.height());
}
示例10: setWidth
void Image::setSize(Size size) {
setWidth(size.getWidth());
setHeight(size.getHeight());
}
示例11: setWidth
Shape::Shape(int width, int height){
setWidth(width);
setHeight(height);
}
示例12: setPosition
void FFContainer::setDimension(const gcn::Rectangle &dimension)
{
setPosition(dimension.x, dimension.y);
setWidth(dimension.width);
setHeight(dimension.height);
}
示例13: setWidth
void SpriteSheet::updateSizeInfo()
{
m_frameWidth = m_pixMap->width() / m_frames;
setWidth(m_frameWidth);
setHeight(m_pixMap->height());
}
示例14: prePaint
void ExploreLiveView::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget * widget)
{
if(!isReady) return;
prePaint(painter);
postPaint(painter);
auto glwidget = (Viewer*)widget;
if (glwidget && meshes.size())
{
QRectF parentRect = parentItem()->sceneBoundingRect();
if (isCacheImage && cachedImage.isNull())
{
QOpenGLContext context;
context.setShareContext(glwidget->context());
context.setFormat(glwidget->format());
context.create();
QOffscreenSurface m_offscreenSurface;
m_offscreenSurface.setFormat(context.format());
m_offscreenSurface.create();
context.makeCurrent(&m_offscreenSurface);
QOpenGLFramebufferObjectFormat fboformat;
fboformat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
QOpenGLFramebufferObject renderFbo(cacheImageSize*1.5, cacheImageSize, fboformat);
renderFbo.bind();
glwidget->glEnable(GL_DEPTH_TEST);
glwidget->glEnable(GL_BLEND);
glwidget->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glwidget->glCullFace(GL_BACK);
glwidget->glClearColor(0,0,0,0);
glwidget->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glwidget->glViewport(0, 0, cacheImageSize*1.5, cacheImageSize);
// XXX Fix
// glwidget->glPointSize(10);
// Draw aux meshes
for (auto mesh : meshes)
{
if (mesh.isPoints)
glwidget->drawOrientedPoints(mesh.points, mesh.normals, mesh.color, glwidget->pvm);
else
glwidget->drawTriangles(mesh.color, mesh.points, mesh.normals, glwidget->pvm);
}
glwidget->glDisable(GL_DEPTH_TEST);
glwidget->glFlush();
renderFbo.release();
cachedImage = renderFbo.toImage();
isReady = true;
// Thanks for sharing!
glwidget->makeCurrent();
}
// Draw as image
if(isCacheImage)
{
int w = shapeRect.width();
painter->drawImage(w * -0.5, w * -0.5, cachedImage.scaledToWidth(w));
}
if(!isCacheImage)
{
auto r = shapeRect;
// scale view
double s = 1.5;
r.setWidth(r.width() * s);
r.setHeight(r.height() * s);
r.moveCenter(this->mapToScene(boundingRect().center()));
painter->beginNativePainting();
auto v = scene()->views().first();
QPoint viewDelta = v->mapFromScene(r.topLeft());
if (viewDelta.manhattanLength() > 5) r.moveTopLeft(viewDelta);
auto camera = ExploreProcess::defaultCamera(document->extent().length());
glwidget->eyePos = camera.first;
glwidget->pvm = camera.second;
glwidget->glViewport(r.left(), v->height() - r.height() - r.top(), r.width(), r.height());
// Clipping OpenGL
glwidget->glEnable(GL_SCISSOR_TEST);
glwidget->glScissor(parentRect.x(), v->height() - parentRect.height() - parentRect.top(), parentRect.width(), parentRect.height());
glwidget->glClear(GL_DEPTH_BUFFER_BIT);
//.........这里部分代码省略.........
示例15: checkMemoryAllocation
//.........这里部分代码省略.........
continue;
}
else if (character == UNICODE_SPACE) // space
{
// Just leave a gap, no tris
left += mSpaceWidth;
// Also reduce tri count
mRenderOp.vertexData->vertexCount -= 6;
continue;
}
Real horiz_height = mpFont->getGlyphAspectRatio(character) * mViewportAspectCoef ;
const Font::UVRect& uvRect = mpFont->getGlyphTexCoords(character);
// each vert is (x, y, z, u, v)
//-------------------------------------------------------------------------------------
// First tri
//
// Upper left
*pVert++ = left;
*pVert++ = top;
*pVert++ = -1.0;
*pVert++ = uvRect.left;
*pVert++ = uvRect.top;
top -= mCharHeight * 2.0f;
// Bottom left
*pVert++ = left;
*pVert++ = top;
*pVert++ = -1.0;
*pVert++ = uvRect.left;
*pVert++ = uvRect.bottom;
top += mCharHeight * 2.0f;
left += horiz_height * mCharHeight * 2.0f;
// Top right
*pVert++ = left;
*pVert++ = top;
*pVert++ = -1.0;
*pVert++ = uvRect.right;
*pVert++ = uvRect.top;
//-------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------
// Second tri
//
// Top right (again)
*pVert++ = left;
*pVert++ = top;
*pVert++ = -1.0;
*pVert++ = uvRect.right;
*pVert++ = uvRect.top;
top -= mCharHeight * 2.0f;
left -= horiz_height * mCharHeight * 2.0f;
// Bottom left (again)
*pVert++ = left;
*pVert++ = top;
*pVert++ = -1.0;
*pVert++ = uvRect.left;
*pVert++ = uvRect.bottom;
left += horiz_height * mCharHeight * 2.0f;
// Bottom right
*pVert++ = left;
*pVert++ = top;
*pVert++ = -1.0;
*pVert++ = uvRect.right;
*pVert++ = uvRect.bottom;
//-------------------------------------------------------------------------------------
// Go back up with top
top += mCharHeight * 2.0f;
float currentWidth = (left + 1)/2 - _getDerivedLeft();
if (currentWidth > largestWidth)
{
largestWidth = currentWidth;
}
}
// Unlock vertex buffer
vbuf->unlock();
if (mMetricsMode == GMM_PIXELS)
{
// Derive parametric version of dimensions
Real vpWidth;
vpWidth = (Real) (OverlayManager::getSingleton().getViewportWidth());
largestWidth *= vpWidth;
};
if (getWidth() < largestWidth)
setWidth(largestWidth);
}