本文整理汇总了C++中BTextView::CountLines方法的典型用法代码示例。如果您正苦于以下问题:C++ BTextView::CountLines方法的具体用法?C++ BTextView::CountLines怎么用?C++ BTextView::CountLines使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTextView
的用法示例。
在下文中一共展示了BTextView::CountLines方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PointForTip
void
DTipWatcherView::ShowTip(BPoint pt, const char *text)
{
if (!text)
return;
Window()->SetWorkspaces(B_CURRENT_WORKSPACE);
fTipView->SetText(text);
// Figure the size of the tip. We do have a maximum width of 200 and a maximum height of 400, but
// we only want to use the maximum size if it's necessary.
fTipView->ResizeTo(200,400);
fTipView->SetTextRect(BRect(2,2,198,398));
int32 lineCount = fTipView->CountLines();
float width = 200.0;
if (lineCount == 1)
width = fTipView->LineWidth() + 4;
float height = fTipView->TextHeight(0,lineCount);
height = (height < 400) ? height : 400;
Window()->ResizeTo(width,height);
fTipView->SetTextRect(BRect(2,2, width - 4, height - 4));
BPoint winpt = PointForTip(pt);
Window()->MoveTo(winpt.x,winpt.y);
Window()->Show();
}
示例2: getAuthentication
bool AuthenticationPanel::getAuthentication(const BString& text,
const BString& previousUser, const BString& previousPass,
bool previousRememberCredentials, bool badPassword,
BString& user, BString& pass, bool* rememberCredentials)
{
// Configure panel and layout controls.
rgb_color infoColor = ui_color(B_PANEL_TEXT_COLOR);
BRect textBounds(0, 0, 250, 200);
BTextView* textView = new BTextView(textBounds, "text", textBounds,
be_plain_font, &infoColor, B_FOLLOW_NONE, B_WILL_DRAW | B_SUPPORTS_LAYOUT);
textView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
textView->SetText(text.String());
textView->MakeEditable(false);
textView->MakeSelectable(false);
m_usernameTextControl->SetText(previousUser.String());
m_passwordTextControl->TextView()->HideTyping(true);
// Ignore the previous password, if it didn't work.
if (!badPassword)
m_passwordTextControl->SetText(previousPass.String());
m_hidePasswordCheckBox->SetValue(B_CONTROL_ON);
m_rememberCredentialsCheckBox->SetValue(previousRememberCredentials);
// create layout
SetLayout(new BGroupLayout(B_VERTICAL, 0.0));
float spacing = be_control_look->DefaultItemSpacing();
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0.0)
.Add(BGridLayoutBuilder(0, spacing)
.Add(textView, 0, 0, 2)
.Add(m_usernameTextControl->CreateLabelLayoutItem(), 0, 1)
.Add(m_usernameTextControl->CreateTextViewLayoutItem(), 1, 1)
.Add(m_passwordTextControl->CreateLabelLayoutItem(), 0, 2)
.Add(m_passwordTextControl->CreateTextViewLayoutItem(), 1, 2)
.Add(BSpaceLayoutItem::CreateGlue(), 0, 3)
.Add(m_hidePasswordCheckBox, 1, 3)
.Add(m_rememberCredentialsCheckBox, 0, 4, 2)
.SetInsets(spacing, spacing, spacing, spacing)
)
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
.Add(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
.AddGlue()
.Add(m_cancelButton)
.Add(m_okButton)
.SetInsets(spacing, spacing, spacing, spacing)
)
);
float textHeight = textView->LineHeight(0) * textView->CountLines();
textView->SetExplicitMinSize(BSize(B_SIZE_UNSET, textHeight));
SetDefaultButton(m_okButton);
if (badPassword && previousUser.Length())
m_passwordTextControl->MakeFocus(true);
else
m_usernameTextControl->MakeFocus(true);
if (m_parentWindowFrame.IsValid())
CenterIn(m_parentWindowFrame);
else
CenterOnScreen();
// Start AuthenticationPanel window thread
Show();
// Let the window jitter, if the previous password was invalid
if (badPassword)
PostMessage(kMsgJitter);
// Block calling thread
// Get the originating window, if it exists, to let it redraw itself.
BWindow* window = dynamic_cast<BWindow*>(BLooper::LooperForThread(find_thread(NULL)));
if (window) {
status_t err;
for (;;) {
do {
err = acquire_sem_etc(m_exitSemaphore, 1, B_RELATIVE_TIMEOUT, 10000);
// We've (probably) had our time slice taken away from us
} while (err == B_INTERRUPTED);
if (err != B_TIMED_OUT) {
// Semaphore was finally released or nuked.
break;
}
window->UpdateIfNeeded();
}
} else {
// No window to update, so just hang out until we're done.
while (acquire_sem(m_exitSemaphore) == B_INTERRUPTED) {
}
}
// AuthenticationPanel wants to quit.
Lock();
user = m_usernameTextControl->Text();
pass = m_passwordTextControl->Text();
if (rememberCredentials)
*rememberCredentials = m_rememberCredentialsCheckBox->Value() == B_CONTROL_ON;
bool canceled = m_cancelled;
//.........这里部分代码省略.........
示例3: str
status_t
PTextView::GetProperty(const char *name, PValue *value, const int32 &index) const
{
if (!name || !value)
return B_ERROR;
BString str(name);
PProperty *prop = FindProperty(name,index);
if (!prop)
return B_NAME_NOT_FOUND;
BTextView *backend = (BTextView*)fView;
if (backend->Window())
backend->Window()->Lock();
if (str.ICompare("LineCount") == 0)
((IntProperty*)prop)->SetValue(backend->CountLines());
else if (str.ICompare("Selectable") == 0)
((BoolProperty*)prop)->SetValue(backend->IsSelectable());
else if (str.ICompare("CurrentLine") == 0)
((IntProperty*)prop)->SetValue(backend->CurrentLine());
else if (str.ICompare("TabWidth") == 0)
((FloatProperty*)prop)->SetValue(backend->TabWidth());
else if (str.ICompare("TextRect") == 0)
((RectProperty*)prop)->SetValue(backend->TextRect());
else if (str.ICompare("MaxBytes") == 0)
((IntProperty*)prop)->SetValue(backend->MaxBytes());
else if (str.ICompare("UseWordWrap") == 0)
((BoolProperty*)prop)->SetValue(backend->DoesWordWrap());
else if (str.ICompare("HideTyping") == 0)
((BoolProperty*)prop)->SetValue(backend->IsTypingHidden());
else if (str.ICompare("Editable") == 0)
((BoolProperty*)prop)->SetValue(backend->IsEditable());
else if (str.ICompare("ColorSpace") == 0)
((IntProperty*)prop)->SetValue(backend->ColorSpace());
else if (str.ICompare("TextLength") == 0)
((IntProperty*)prop)->SetValue(backend->TextLength());
else if (str.ICompare("Text") == 0)
((StringProperty*)prop)->SetValue(backend->Text());
else if (str.ICompare("Resizable") == 0)
((BoolProperty*)prop)->SetValue(backend->IsResizable());
else if (str.ICompare("Alignment") == 0)
((EnumProperty*)prop)->SetValue(backend->Alignment());
else if (str.ICompare("Undoable") == 0)
((BoolProperty*)prop)->SetValue(backend->DoesUndo());
else if (str.ICompare("AutoIndent") == 0)
((BoolProperty*)prop)->SetValue(backend->DoesAutoindent());
else if (str.ICompare("Stylable") == 0)
((BoolProperty*)prop)->SetValue(backend->IsStylable());
else
{
if (backend->Window())
backend->Window()->Unlock();
return PView::GetProperty(name, value, index);
}
if (backend->Window())
backend->Window()->Unlock();
return prop->GetValue(value);
}