本文整理汇总了C++中lltextbox::Params::wrap方法的典型用法代码示例。如果您正苦于以下问题:C++ Params::wrap方法的具体用法?C++ Params::wrap怎么用?C++ Params::wrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lltextbox::Params
的用法示例。
在下文中一共展示了Params::wrap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: label_rect
LLSpinCtrl::LLSpinCtrl(const LLSpinCtrl::Params& p)
: LLF32UICtrl(p),
mLabelBox(NULL),
mbHasBeenSet( FALSE ),
mPrecision(p.decimal_digits),
mTextEnabledColor(p.text_enabled_color()),
mTextDisabledColor(p.text_disabled_color())
{
static LLUICachedControl<S32> spinctrl_spacing ("UISpinctrlSpacing", 0);
static LLUICachedControl<S32> spinctrl_btn_width ("UISpinctrlBtnWidth", 0);
static LLUICachedControl<S32> spinctrl_btn_height ("UISpinctrlBtnHeight", 0);
S32 centered_top = getRect().getHeight();
S32 centered_bottom = getRect().getHeight() - 2 * spinctrl_btn_height;
S32 btn_left = 0;
// reserve space for spinner
S32 label_width = llclamp(p.label_width(), 0, llmax(0, getRect().getWidth() - 40));
// Label
if( !p.label().empty() )
{
LLRect label_rect( 0, centered_top, label_width, centered_bottom );
LLTextBox::Params params;
params.wrap(p.label_wrap);
params.name("SpinCtrl Label");
params.rect(label_rect);
params.initial_value(p.label());
if (p.font.isProvided())
{
params.font(p.font);
}
mLabelBox = LLUICtrlFactory::create<LLTextBox> (params);
addChild(mLabelBox);
btn_left += label_rect.mRight + spinctrl_spacing;
}
S32 btn_right = btn_left + spinctrl_btn_width;
// Spin buttons
LLButton::Params up_button_params(p.up_button);
up_button_params.rect = LLRect(btn_left, getRect().getHeight(), btn_right, getRect().getHeight() - spinctrl_btn_height);
up_button_params.click_callback.function(boost::bind(&LLSpinCtrl::onUpBtn, this, _2));
up_button_params.mouse_held_callback.function(boost::bind(&LLSpinCtrl::onUpBtn, this, _2));
mUpBtn = LLUICtrlFactory::create<LLButton>(up_button_params);
addChild(mUpBtn);
LLButton::Params down_button_params(p.down_button);
down_button_params.rect = LLRect(btn_left, getRect().getHeight() - spinctrl_btn_height, btn_right, getRect().getHeight() - 2 * spinctrl_btn_height);
down_button_params.click_callback.function(boost::bind(&LLSpinCtrl::onDownBtn, this, _2));
down_button_params.mouse_held_callback.function(boost::bind(&LLSpinCtrl::onDownBtn, this, _2));
mDownBtn = LLUICtrlFactory::create<LLButton>(down_button_params);
addChild(mDownBtn);
LLRect editor_rect( btn_right + 1, centered_top, getRect().getWidth(), centered_bottom );
LLLineEditor::Params params;
params.name("SpinCtrl Editor");
params.rect(editor_rect);
if (p.font.isProvided())
{
params.font(p.font);
}
params.max_length.bytes(MAX_STRING_LENGTH);
params.commit_callback.function((boost::bind(&LLSpinCtrl::onEditorCommit, this, _2)));
//*NOTE: allow entering of any chars for LLCalc, proper input will be evaluated on commit
params.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM);
mEditor = LLUICtrlFactory::create<LLLineEditor> (params);
mEditor->setFocusReceivedCallback( boost::bind(&LLSpinCtrl::onEditorGainFocus, _1, this ));
//RN: this seems to be a BAD IDEA, as it makes the editor behavior different when it has focus
// than when it doesn't. Instead, if you always have to double click to select all the text,
// it's easier to understand
//mEditor->setSelectAllonFocusReceived(TRUE);
mEditor->setSelectAllonCommit(FALSE);
addChild(mEditor);
updateEditor();
setUseBoundingRect( TRUE );
}
示例2: if
//.........这里部分代码省略.........
ButtonData ok_button;
mButtonData.push_back(ok_button);
mDefaultOption = 0;
}
else
{
options = supplied_options;
}
S32 num_options = options.size();
// Calc total width of buttons
S32 button_width = 0;
S32 sp = font->getWidth(std::string("OO"));
for( S32 i = 0; i < num_options; i++ )
{
S32 w = S32(font->getWidth( options[i].second ) + 0.99f) + sp + 2 * LLBUTTON_H_PAD;
button_width = llmax( w, button_width );
}
S32 btn_total_width = button_width;
if( num_options > 1 )
{
btn_total_width = (num_options * button_width) + ((num_options - 1) * BTN_HPAD);
}
// Message: create text box using raw string, as text has been structure deliberately
// Use size of created text box to generate dialog box size
std::string msg = mNotification->getMessage();
llwarns << "Alert: " << msg << llendl;
LLTextBox::Params params;
params.name("Alert message");
params.font(font);
params.tab_stop(false);
params.wrap(true);
params.follows.flags(FOLLOWS_LEFT | FOLLOWS_TOP);
params.allow_scroll(true);
LLTextBox * msg_box = LLUICtrlFactory::create<LLTextBox> (params);
// Compute max allowable height for the dialog text, so we can allocate
// space before wrapping the text to fit.
S32 max_allowed_msg_height =
gFloaterView->getRect().getHeight()
- LINE_HEIGHT // title bar
- 3*VPAD - BTN_HEIGHT;
// reshape to calculate real text width and height
msg_box->reshape( MAX_ALLOWED_MSG_WIDTH, max_allowed_msg_height );
msg_box->setValue(msg);
S32 pixel_width = msg_box->getTextPixelWidth();
S32 pixel_height = msg_box->getTextPixelHeight();
// We should use some space to prevent set textbox's scroller visible when it is unnecessary.
msg_box->reshape( llmin(MAX_ALLOWED_MSG_WIDTH,pixel_width + 2 * msg_box->getHPad() + HPAD),
llmin(max_allowed_msg_height,pixel_height + 2 * msg_box->getVPad()) ) ;
const LLRect& text_rect = msg_box->getRect();
S32 dialog_width = llmax( btn_total_width, text_rect.getWidth() ) + 2 * HPAD;
S32 dialog_height = text_rect.getHeight() + 3 * VPAD + BTN_HEIGHT;
if (hasTitleBar())
{
dialog_height += LINE_HEIGHT; // room for title bar
}
// it's ok for the edit text body to be empty, but we want the name to exist if we're going to draw it
if (!edit_text_name.empty())