本文整理汇总了C++中setRect函数的典型用法代码示例。如果您正苦于以下问题:C++ setRect函数的具体用法?C++ setRect怎么用?C++ setRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setRect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Element
LinkElement::LinkElement(const ref_ptr<Element>& parent) :
Element(parent),
state(LinkState::INACTIVE)
{
setRect(vector4f());
}
示例2: setRect
Rect& Rect::operator= (const Rect& other)
{
setRect(other.origin.x, other.origin.y, other.size.width, other.size.height);
return *this;
}
示例3: setLabel
void Label::setLabel(const std::string &string)
{
setLabel(sf::String(string));
setRect(getVirtualRect());
m_text.setOrigin(sf::Vector2f(0, 0));
}
示例4: void
//---------------------------------------------------------------------------
// Public methods
//---------------------------------------------------------------------------
LLPanelLogin::LLPanelLogin(const LLRect &rect,
BOOL show_server,
void (*callback)(S32 option, void* user_data),
void *cb_data)
: LLPanel(std::string("panel_login"), LLRect(0,600,800,0), FALSE), // not bordered
mLogoImage(),
mCallback(callback),
mCallbackData(cb_data),
mHtmlAvailable( TRUE )
{
setFocusRoot(TRUE);
setBackgroundVisible(FALSE);
setBackgroundOpaque(TRUE);
// instance management
if (LLPanelLogin::sInstance)
{
llwarns << "Duplicate instance of login view deleted" << llendl;
delete LLPanelLogin::sInstance;
// Don't leave bad pointer in gFocusMgr
gFocusMgr.setDefaultKeyboardFocus(NULL);
}
LLPanelLogin::sInstance = this;
// add to front so we are the bottom-most child
gViewerWindow->getRootView()->addChildAtEnd(this);
// Logo
mLogoImage = LLUI::getUIImage("startup_logo.j2c");
LLUICtrlFactory::getInstance()->buildPanel(this, "panel_login.xml");
#if USE_VIEWER_AUTH
//leave room for the login menu bar
setRect(LLRect(0, rect.getHeight()-18, rect.getWidth(), 0));
#endif
reshape(rect.getWidth(), rect.getHeight());
#if !USE_VIEWER_AUTH
childSetPrevalidate("first_name_edit", LLLineEditor::prevalidatePrintableNoSpace);
childSetPrevalidate("last_name_edit", LLLineEditor::prevalidatePrintableNoSpace);
childSetCommitCallback("password_edit", mungePassword);
childSetKeystrokeCallback("password_edit", onPassKey, this);
childSetUserData("password_edit", this);
// change z sort of clickable text to be behind buttons
sendChildToBack(getChildView("channel_text"));
sendChildToBack(getChildView("forgot_password_text"));
LLLineEditor* edit = getChild<LLLineEditor>("password_edit");
if (edit) edit->setDrawAsterixes(TRUE);
LLComboBox* combo = getChild<LLComboBox>("start_location_combo");
combo->setAllowTextEntry(TRUE, 128, FALSE);
// The XML file loads the combo with the following labels:
// 0 - "My Home"
// 1 - "My Last Location"
// 2 - "<Type region name>"
BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation");
std::string sim_string = LLURLSimString::sInstance.mSimString;
if (!sim_string.empty())
{
// Replace "<Type region name>" with this region name
combo->remove(2);
combo->add( sim_string );
combo->setTextEntry(sim_string);
combo->setCurrentByIndex( 2 );
}
else if (login_last)
{
combo->setCurrentByIndex( 1 );
}
else
{
combo->setCurrentByIndex( 0 );
}
LLComboBox* server_choice_combo = sInstance->getChild<LLComboBox>("server_combo");
server_choice_combo->setCommitCallback(onSelectServer);
//server_choice_combo->setFocusLostCallback(onServerComboLostFocus);
childSetAction("connect_btn", onClickConnect, this);
childSetAction("grid_btn", onClickGrid, this);
setDefaultBtn("connect_btn");
// childSetAction("quit_btn", onClickQuit, this);
std::string imp_channel = gSavedSettings.getString("VersionChannelName");
std::string imp_version = llformat("%d.%d.%d %s",
//.........这里部分代码省略.........
示例5: setRect
void QElipseItem::SetTop(qreal nTop) //set the rect top
{
QRectF nrect=rect(); //get the current rect position
nrect.setTop(nTop);
setRect(nrect);
}
示例6: setRect
void Rect::startDraw(QGraphicsSceneMouseEvent * event)
{
setRect(QRectF(event->scenePos(), QSizeF(0, 0)));
}
示例7: setRect
void NodeItem::setRadius(qreal radius)
{
m_radius = radius;
setRect(-m_radius, -m_radius, 2 * m_radius, 2 * m_radius);
update();
}
示例8: sceneTransform
void UBGraphicsTriangle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (!mResizing1 && !mResizing2 && !mRotating)
{
QGraphicsItem::mouseMoveEvent(event);
}
else
{
QPoint currPos = sceneTransform().inverted().map(event->screenPos());
if (mResizing1)
{
if (mOrientation == TopLeft || mOrientation == BottomLeft)
{
int deltaX = currPos.x() - lastPos.x();
if (lastRect.width() + deltaX < sMinWidth)
deltaX = sMinWidth - lastRect.width();
setRect(QRectF(lastRect.left(), lastRect.top(),
lastRect.width() + deltaX, lastRect.height()), mOrientation);
}
else
{
int deltaX = lastPos.x() - currPos.x();
if (lastRect.width() + deltaX < sMinWidth)
deltaX = sMinWidth - lastRect.width();
setRect(QRectF(lastRect.left() - deltaX, lastRect.top(),
lastRect.width() + deltaX, lastRect.height()), mOrientation);
}
}
//-----------------------------------------------//
if (mResizing2)
{
if (mOrientation == BottomRight || mOrientation == BottomLeft)
{
int deltaY = lastPos.y() - currPos.y();
if (lastRect.height() + deltaY < sMinHeight)
deltaY = sMinHeight - lastRect.height();
setRect(QRectF(lastRect.left(), lastRect.top() - deltaY,
lastRect.width(), lastRect.height() + deltaY), mOrientation);
}
else
{
int deltaY = currPos.y() - lastPos.y();
if (lastRect.height() + deltaY < sMinHeight)
deltaY = sMinHeight - lastRect.height();
setRect(QRectF(lastRect.left(), lastRect.top(),
lastRect.width(), lastRect.height() + deltaY), mOrientation);
}
}
//-----------------------------------------------//
if (mRotating)
{
QLineF currentLine(rotationCenter(), event->pos());
QLineF lastLine(rotationCenter(), event->lastPos());
rotateAroundCenter(currentLine.angleTo(lastLine));
}
//-----------------------------------------------//
event->accept();
}
}
示例9: void
//---------------------------------------------------------------------------
// Public methods
//---------------------------------------------------------------------------
LLPanelLogin::LLPanelLogin(const LLRect &rect,
void (*callback)(S32 option, void* user_data),
void *cb_data)
: LLPanel(std::string("panel_login"), LLRect(0,600,800,0), FALSE), // not bordered
mLogoImage(),
mCallback(callback),
mCallbackData(cb_data),
mHtmlAvailable( TRUE )
{
setFocusRoot(TRUE);
setBackgroundVisible(FALSE);
setBackgroundOpaque(TRUE);
// instance management
if (LLPanelLogin::sInstance)
{
llwarns << "Duplicate instance of login view deleted" << llendl;
delete LLPanelLogin::sInstance;
// Don't leave bad pointer in gFocusMgr
gFocusMgr.setDefaultKeyboardFocus(NULL);
}
LLPanelLogin::sInstance = this;
// add to front so we are the bottom-most child
gViewerWindow->getRootView()->addChildInBack(this);
// Logo
mLogoImage = LLUI::getUIImage("startup_logo.j2c");
LLUICtrlFactory::getInstance()->buildPanel(this, "panel_login.xml");
#if USE_VIEWER_AUTH
//leave room for the login menu bar
setRect(LLRect(0, rect.getHeight()-18, rect.getWidth(), 0));
#endif
reshape(rect.getWidth(), rect.getHeight());
#if !USE_VIEWER_AUTH
LLComboBox* name_combo = sInstance->getChild<LLComboBox>("name_combo");
name_combo->setCommitCallback(onSelectLoginEntry);
name_combo->setFocusLostCallback(boost::bind(&LLPanelLogin::onLoginComboLostFocus, this, name_combo));
name_combo->setPrevalidate(LLLineEditor::prevalidatePrintableNotPipe);
name_combo->setSuppressTentative(true);
name_combo->setSuppressAutoComplete(true);
childSetCommitCallback("remember_name_check", onNameCheckChanged);
childSetCommitCallback("password_edit", mungePassword);
childSetKeystrokeCallback("password_edit", onPassKey, this);
childSetUserData("password_edit", this);
// change z sort of clickable text to be behind buttons
sendChildToBack(getChildView("channel_text"));
sendChildToBack(getChildView("forgot_password_text"));
LLLineEditor* edit = getChild<LLLineEditor>("password_edit");
if (edit) edit->setDrawAsterixes(TRUE);
//OGPX : This keeps the uris in a history file
//OGPX TODO: should this be inside an OGP only check?
LLComboBox* regioncombo = getChild<LLComboBox>("regionuri_edit");
regioncombo->setAllowTextEntry(TRUE, 256, FALSE);
std::string current_regionuri = gSavedSettings.getString("CmdLineRegionURI");
// iterate on uri list adding to combobox (couldn't figure out how to add them all in one call)
// ... and also append the command line value we might have gotten to the URLHistory
LLSD regionuri_history = LLURLHistory::getURLHistory("regionuri");
LLSD::array_iterator iter_history = regionuri_history.beginArray();
LLSD::array_iterator iter_end = regionuri_history.endArray();
for (; iter_history != iter_end; ++iter_history)
{
regioncombo->addSimpleElement((*iter_history).asString());
}
if ( LLURLHistory::appendToURLCollection("regionuri",current_regionuri))
{
// since we are in login, another read of urlhistory file is going to happen
// so we need to persist the new value we just added (or maybe we should do it in startup.cpp?)
// since URL history only populated on create of sInstance, add to combo list directly
regioncombo->addSimpleElement(current_regionuri);
}
// select which is displayed if we have a current URL.
regioncombo->setSelectedByValue(LLSD(current_regionuri),TRUE);
//llinfos << " url history: " << LLSDOStreamer<LLSDXMLFormatter>(LLURLHistory::getURLHistory("regionuri")) << llendl;
LLComboBox* combo = getChild<LLComboBox>("start_location_combo");
combo->setAllowTextEntry(TRUE, 128, FALSE);
// The XML file loads the combo with the following labels:
// 0 - "My Home"
// 1 - "My Last Location"
// 2 - "<Type region name>"
//.........这里部分代码省略.........
示例10: m_impl
Rect::Rect(int blX, int blY, int trX ,int trY):
m_impl(new Implementation)
{
setRect(blX,blY,trX,trY);
}
示例11: setRect
Power::Power(){
this->setBrush(QBrush(Qt::green, Qt::SolidPattern));
setRect(0,0,20,20);
}
示例12: LLPanel
//---------------------------------------------------------------------------
LLNotifyBox::LLNotifyBox(LLNotificationPtr notification,
BOOL layout_script_dialog)
: LLPanel(notification->getName(), LLRect(), BORDER_NO),
LLEventTimer(notification->getExpiration() == LLDate()
? LLDate(LLDate::now().secondsSinceEpoch() + (F64)gSavedSettings.getF32("NotifyTipDuration"))
: notification->getExpiration()),
LLInstanceTracker<LLNotifyBox, LLUUID>(notification->getID()),
mNotification(notification),
mIsTip(notification->getType() == "notifytip"),
mAnimating(TRUE),
mNextBtn(NULL),
mNumOptions(0),
mNumButtons(0),
mAddedDefaultBtn(FALSE),
mLayoutScriptDialog(layout_script_dialog),
mUserInputBox(NULL)
{
std::string edit_text_name;
std::string edit_text_contents;
// class init
{
sFont = LLFontGL::getFontSansSerif();
sFontSmall = LLFontGL::getFontSansSerifSmall();
}
// setup paramaters
mMessage = notification->getMessage();
// initialize
setFocusRoot(!mIsTip);
// caution flag can be set explicitly by specifying it in the
// notification payload, or it can be set implicitly if the
// notify xml template specifies that it is a caution
//
// tip-style notification handle 'caution' differently -
// they display the tip in a different color
mIsCaution = notification->getPriority() >= NOTIFICATION_PRIORITY_HIGH;
// Only animate first window
if( gNotifyBoxView->getChildCount() > 0 )
mAnimating = FALSE;
else
mAnimating = TRUE;
LLNotificationFormPtr form(notification->getForm());
mNumOptions = form->getNumElements();
bool is_textbox = form->getElement("message").isDefined();
LLRect rect = mIsTip ? getNotifyTipRect(mMessage)
: getNotifyRect(is_textbox ? 10 : mNumOptions, layout_script_dialog, mIsCaution);
setRect(rect);
setFollows(mIsTip ? (FOLLOWS_BOTTOM|FOLLOWS_RIGHT) : (FOLLOWS_TOP|FOLLOWS_RIGHT));
setBackgroundVisible(FALSE);
setBackgroundOpaque(TRUE);
LLIconCtrl* icon;
LLTextEditor* text;
const S32 TOP = getRect().getHeight() - (mIsTip ? (S32)sFont->getLineHeight() : 32);
const S32 BOTTOM = (S32)sFont->getLineHeight();
S32 x = HPAD + HPAD;
S32 y = TOP;
if (mIsTip)
{
// use the tip notification icon
icon = new LLIconCtrl(std::string("icon"), LLRect(x, y, x+32, TOP-32), std::string("notify_tip_icon.tga"));
}
else if (mIsCaution)
{
// use the caution notification icon
icon = new LLIconCtrl(std::string("icon"), LLRect(x, y, x+32, TOP-32), std::string("notify_caution_icon.tga"));
}
else
{
// use the default notification icon
icon = new LLIconCtrl(std::string("icon"), LLRect(x, y, x+32, TOP-32), std::string("notify_box_icon.tga"));
}
icon->setMouseOpaque(FALSE);
addChild(icon);
x += HPAD + HPAD + 32;
// add a caution textbox at the top of a caution notification
LLTextBox* caution_box = NULL;
if (mIsCaution && !mIsTip)
{
S32 caution_height = ((S32)sFont->getLineHeight() * 2) + VPAD;
caution_box = new LLTextBox(
std::string("caution_box"),
LLRect(x, y, getRect().getWidth() - 2, caution_height),
LLStringUtil::null,
sFont,
FALSE);
//.........这里部分代码省略.........
示例13: setRect
RectDrawing::RectDrawing(const QRect &r)
{
_fm = 0;
_dp = 0;
setRect(r);
}
示例14: getLastHoverObject
//.........这里部分代码省略.........
F32 alpha;
if (mHoverActive)
{
alpha = 1.f;
if (isHoveringObject())
{
// look at object
LLViewerObject *hover_object = getLastHoverObject();
if (hover_object->isAvatar())
{
gAgent.setLookAt(LOOKAT_TARGET_HOVER, getLastHoverObject(), LLVector3::zero);
}
else
{
gAgent.setLookAt(LOOKAT_TARGET_HOVER, getLastHoverObject(), mHoverOffset);
}
}
}
else
{
alpha = llmax(0.f, MAX_ALPHA - mHoverTimer.getElapsedTimeF32()*2.f);
}
// Bail out if no text to display
if (mText.empty())
{
return;
}
// Don't draw if no alpha
if (alpha <= 0.f)
{
return;
}
LLUIImagePtr box_imagep = LLUI::getUIImage("rounded_square.tga");
LLUIImagePtr shadow_imagep = LLUI::getUIImage("rounded_square_soft.tga");
const LLFontGL* fontp = LLResMgr::getInstance()->getRes(LLFONT_SANSSERIF_SMALL);
// Render text.
LLColor4 text_color = gColors.getColor("ToolTipTextColor");
// LLColor4 border_color = gColors.getColor("ToolTipBorderColor");
LLColor4 bg_color = gColors.getColor("ToolTipBgColor");
LLColor4 shadow_color = gColors.getColor("ColorDropShadow");
// Could decrease the alpha here. JC
//text_color.mV[VALPHA] = alpha;
//border_color.mV[VALPHA] = alpha;
//bg_color.mV[VALPHA] = alpha;
S32 max_width = 0;
S32 num_lines = mText.size();
for (text_list_t::iterator iter = mText.begin(); iter != mText.end(); ++iter)
{
max_width = llmax(max_width, (S32)fontp->getWidth(*iter));
}
S32 left = mHoverPos.mX + 10;
S32 top = mHoverPos.mY - 16;
S32 right = mHoverPos.mX + max_width + 30;
S32 bottom = mHoverPos.mY - 24 - llfloor(num_lines*fontp->getLineHeight());
// Push down if there's a one-click icon
if (mHoverActive
&& isHoveringObject()
&& mLastHoverObject->getClickAction() != CLICK_ACTION_NONE)
{
const S32 CLICK_OFFSET = 10;
top -= CLICK_OFFSET;
bottom -= CLICK_OFFSET;
}
// Make sure the rect is completely visible
LLRect old_rect = getRect();
setRect( LLRect(left, top, right, bottom ) );
translateIntoRect( gViewerWindow->getVirtualWindowRect(), FALSE );
left = getRect().mLeft;
top = getRect().mTop;
right = getRect().mRight;
bottom = getRect().mBottom;
setRect(old_rect);
LLGLSUIDefault gls_ui;
shadow_color.mV[VALPHA] = 0.7f * alpha;
S32 shadow_offset = gSavedSettings.getS32("DropShadowTooltip");
shadow_imagep->draw(LLRect(left + shadow_offset, top - shadow_offset, right + shadow_offset, bottom - shadow_offset), shadow_color);
bg_color.mV[VALPHA] = alpha;
box_imagep->draw(LLRect(left, top, right, bottom), bg_color);
S32 cur_offset = top - 4;
for (text_list_t::iterator iter = mText.begin(); iter != mText.end(); ++iter)
{
fontp->renderUTF8(*iter, 0, left + 10, cur_offset, text_color, LLFontGL::LEFT, LLFontGL::TOP);
cur_offset -= llfloor(fontp->getLineHeight());
}
}
示例15: pane
void VideoRecordDialog::makeGUI() {
pane()->addCheckBox("Record GUI (Surface2D)", &m_captureGUI);
pane()->addLabel(GuiText("Video", shared_ptr<GFont>(), 12));
GuiPane* moviePane = pane()->addPane("", GuiTheme::ORNATE_PANE_STYLE);
GuiLabel* label = NULL;
GuiDropDownList* formatList = moviePane->addDropDownList("Format", m_formatList, &m_templateIndex);
const float width = 300.0f;
// Increase caption size to line up with the motion blur box
const float captionSize = 90.0f;
formatList->setWidth(width);
formatList->setCaptionWidth(captionSize);
moviePane->addNumberBox("Quality", &m_quality, "", GuiTheme::LOG_SLIDER, 0.1f, 25.0f);
if (false) {
// For future expansion
GuiCheckBox* motionCheck = moviePane->addCheckBox("Motion Blur", &m_enableMotionBlur);
m_framesBox = moviePane->addNumberBox("", &m_motionBlurFrames, "frames", GuiTheme::LINEAR_SLIDER, 2, 20);
m_framesBox->setUnitsSize(46);
m_framesBox->moveRightOf(motionCheck);
m_framesBox->setWidth(210);
}
GuiNumberBox<float>* recordBox = moviePane->addNumberBox("Record as if", &m_recordFPS, "fps", GuiTheme::NO_SLIDER, 1.0f, 120.0f, 0.1f);
recordBox->setCaptionWidth(captionSize);
GuiNumberBox<float>* playbackBox = moviePane->addNumberBox("Playback at", &m_playbackFPS, "fps", GuiTheme::NO_SLIDER, 1.0f, 120.0f, 0.1f);
playbackBox->setCaptionWidth(captionSize);
const OSWindow* window = OSWindow::current();
int w = window->width() / 2;
int h = window->height() / 2;
moviePane->addCheckBox(format("Half-size (%d x %d)", w, h), &m_halfSize);
if (false) {
// For future expansion
moviePane->addCheckBox("Show cursor", &m_showCursor);
}
label = moviePane->addLabel("Hot key:");
label->setWidth(captionSize);
moviePane->addLabel(m_hotKeyString)->moveRightOf(label);
// Add record on the same line as previous hotkey box
m_recordButton = moviePane->addButton("Record Now (" + m_hotKeyString + ")");
m_recordButton->moveBy(moviePane->rect().width() - m_recordButton->rect().width() - 5, -27);
moviePane->pack();
moviePane->setWidth(pane()->rect().width());
///////////////////////////////////////////////////////////////////////////////////
pane()->addLabel(GuiText("Screenshot", shared_ptr<GFont>(), 12));
GuiPane* ssPane = pane()->addPane("", GuiTheme::ORNATE_PANE_STYLE);
m_ssFormatList.append("JPG", "PNG", "BMP", "TGA");
GuiDropDownList* ssFormatList = ssPane->addDropDownList("Format", m_ssFormatList, &m_ssFormatIndex);
m_ssFormatIndex = 0;
ssFormatList->setWidth(width);
ssFormatList->setCaptionWidth(captionSize);
label = ssPane->addLabel("Hot key:");
label->setWidth(captionSize);
ssPane->addLabel(m_ssHotKeyString)->moveRightOf(label);
ssPane->pack();
ssPane->setWidth(pane()->rect().width());
///////////////////////////////////////////////////////////////////////////////////
pack();
setRect(Rect2D::xywh(rect().x0(), rect().y0(), rect().width() + 5, rect().height() + 2));
}