本文整理汇总了C++中BTextView::TextRect方法的典型用法代码示例。如果您正苦于以下问题:C++ BTextView::TextRect方法的具体用法?C++ BTextView::TextRect怎么用?C++ BTextView::TextRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTextView
的用法示例。
在下文中一共展示了BTextView::TextRect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BTextView
/***********************************************************
* HardWrap
***********************************************************/
void
HWrapTextView::GetHardWrapedText(BString &out)
{
MakeEditable(false);
BTextView *offview = new BTextView(Bounds(),NULL,TextRect(),B_FOLLOW_ALL);
offview->SetText(Text());
BFont font;
uint32 propa;
GetFontAndColor(&font,&propa);
out = "";
offview->SetFontAndColor(&font,B_FONT_ALL);
BString line;
int32 length = offview->TextLength();
float view_width = offview->TextRect().Width();
char c=0;
bool inserted;
for(int32 i=0;i < length;i++)
{
c = offview->ByteAt(i);
if(c == '\n')
{
line = "";
continue;
}
line += c;
if(font.StringWidth(line.String())>=view_width)
{
// Back 1 charactor.
i--;
line.Truncate(line.Length()-1);
// Insert line break.
inserted = false;
int32 len = line.Length();
for(int32 k = 0;k<len;k++)
{
if(offview->CanEndLine(i-k))
{
offview->Insert(i-k,"\n",1);
inserted=true;
i = i-k;
break;
}
}
// If could not find proper position, add line break to end.
if(!inserted)
offview->Insert(i,"\n",1);
line = "";
}
}
out = offview->Text();
delete offview;
MakeEditable(true);
}
示例2: FrameResized
void ArpTextControl::FrameResized(float new_width, float new_height)
{
ArpD(cdb << ADH << "ArpTextControl: FrameResized(" << new_width
<< ", " << new_height << ")" << endl);
BTextView* text = dynamic_cast<BTextView*>(ChildAt(0));
if( !text ) ArpD(cdb << ADH << "!!! No BTextView !!!" << endl);
if( text ) {
ArpD(cdb << ADH << "BTextView: Initial Bounds=" << text->Bounds()
<< ", TextRect=" << text->TextRect() << endl);
}
BTextControl::FrameResized(new_width, new_height);
BRect textBounds(text->Bounds());
BRect textRect(text->TextRect());
textRect.right = textRect.left + text->LineWidth(0)-1;
if( textRect.Width() < textBounds.Width() ) {
textRect.right = textRect.left + textBounds.Width()-1;
}
text->SetTextRect(textRect);
if( text ) {
ArpD(cdb << ADH << "BTextView: Finish Bounds=" << text->Bounds()
<< ", TextRect=" << text->TextRect() << endl);
}
}
示例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);
}