本文整理汇总了C++中BTextView::LineWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ BTextView::LineWidth方法的具体用法?C++ BTextView::LineWidth怎么用?C++ BTextView::LineWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTextView
的用法示例。
在下文中一共展示了BTextView::LineWidth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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: labelAlignment
SGIView::SGIView(const char* name, uint32 flags, TranslatorSettings* settings)
:
BView(name, flags, new BGroupLayout(B_VERTICAL)),
fSettings(settings)
{
BPopUpMenu* menu = new BPopUpMenu("pick compression");
uint32 currentCompression =
fSettings->SetGetInt32(SGI_SETTING_COMPRESSION);
// create the menu items with the various compression methods
add_menu_item(menu, SGI_COMP_NONE, B_TRANSLATE("None"),
currentCompression);
//menu->AddSeparatorItem();
add_menu_item(menu, SGI_COMP_RLE, B_TRANSLATE("RLE"), currentCompression);
// DON'T turn this on, it's so slow that I didn't wait long enough
// the one time I tested this. So I don't know if the code even works.
// Supposedly, this would look for an already written scanline, and
// modify the scanline tables so that the current row is not written
// at all...
//add_menu_item(menu, SGI_COMP_ARLE, "Agressive RLE", currentCompression);
fCompressionMF = new BMenuField("compression",
B_TRANSLATE("Use compression:"), menu);
BAlignment labelAlignment(B_ALIGN_LEFT, B_ALIGN_NO_VERTICAL);
BStringView* titleView = new BStringView("title",
B_TRANSLATE("SGI image translator"));
titleView->SetFont(be_bold_font);
titleView->SetExplicitAlignment(labelAlignment);
char detail[100];
sprintf(detail, B_TRANSLATE("Version %d.%d.%d %s"),
static_cast<int>(B_TRANSLATION_MAJOR_VERSION(SGI_TRANSLATOR_VERSION)),
static_cast<int>(B_TRANSLATION_MINOR_VERSION(SGI_TRANSLATOR_VERSION)),
static_cast<int>(B_TRANSLATION_REVISION_VERSION(
SGI_TRANSLATOR_VERSION)), __DATE__);
BStringView* detailView = new BStringView("details", detail);
detailView->SetExplicitAlignment(labelAlignment);
BTextView* infoView = new BTextView("info");
infoView->SetText(BString(B_TRANSLATE("written by:\n"))
.Append(author)
.Append(B_TRANSLATE("\n\nbased on GIMP SGI plugin v1.5:\n"))
.Append(kSGICopyright).String());
infoView->SetExplicitAlignment(labelAlignment);
infoView->SetWordWrap(false);
infoView->MakeEditable(false);
infoView->MakeResizable(true);
infoView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
float padding = 5.0f;
BLayoutBuilder::Group<>(this, B_VERTICAL, padding)
.SetInsets(padding)
.Add(titleView)
.Add(detailView)
.AddGroup(B_HORIZONTAL)
.Add(fCompressionMF)
.AddGlue()
.End()
.Add(infoView)
.AddGlue();
BFont font;
GetFont(&font);
SetExplicitPreferredSize(BSize((font.Size() * 390) / 12,
(font.Size() * 180) / 12));
// TODO: remove this workaround for ticket #4217
infoView->SetExplicitPreferredSize(
BSize(infoView->LineWidth(4), infoView->TextHeight(0, 80)));
infoView->SetExplicitMaxSize(infoView->ExplicitPreferredSize());
infoView->SetExplicitMinSize(infoView->ExplicitPreferredSize());
}
示例4: entry
void
BTextWidget::StartEdit(BRect bounds, BPoseView *view, BPose *pose)
{
if (!IsEditable())
return;
// don't allow editing of the trash directory name
if (pose->TargetModel()->IsTrash())
return;
// don't allow editing of the "Disks" icon name
if (pose->TargetModel()->IsRoot())
return;
BEntry entry(pose->TargetModel()->EntryRef());
if (entry.InitCheck() == B_OK
&& !ConfirmChangeIfWellKnownDirectory(&entry, "rename"))
return;
// get bounds with full text length
BRect rect(bounds);
BRect textRect(bounds);
rect.OffsetBy(-2, -1);
rect.right += 1;
BFont font;
view->GetFont(&font);
BTextView *textView = new BTextView(rect, "WidgetTextView", textRect, &font, 0,
B_FOLLOW_ALL, B_WILL_DRAW);
textView->SetWordWrap(false);
DisallowMetaKeys(textView);
fText->SetUpEditing(textView);
textView->AddFilter(new BMessageFilter(B_KEY_DOWN, TextViewFilter));
rect.right = rect.left + textView->LineWidth() + 3;
// center new width, if necessary
if (view->ViewMode() == kIconMode
|| (view->ViewMode() == kListMode && fAlignment == B_ALIGN_CENTER)) {
rect.OffsetBy(bounds.Width() / 2 - rect.Width() / 2, 0);
}
rect.bottom = rect.top + textView->LineHeight() + 1;
textRect = rect.OffsetToCopy(2, 1);
textRect.right -= 3;
textRect.bottom--;
textView->SetTextRect(textRect);
textRect = view->Bounds();
bool hitBorder = false;
if (rect.left < 1)
rect.left = 1, hitBorder = true;
if (rect.right > textRect.right)
rect.right = textRect.right - 2, hitBorder = true;
textView->MoveTo(rect.LeftTop());
textView->ResizeTo(rect.Width(), rect.Height());
BScrollView *scrollView = new BScrollView("BorderView", textView, 0, 0, false,
false, B_PLAIN_BORDER);
view->AddChild(scrollView);
// configure text view
switch (view->ViewMode()) {
case kIconMode:
textView->SetAlignment(B_ALIGN_CENTER);
break;
case kMiniIconMode:
textView->SetAlignment(B_ALIGN_LEFT);
break;
case kListMode:
textView->SetAlignment(fAlignment);
break;
}
textView->MakeResizable(true, hitBorder ? NULL : scrollView);
view->SetActivePose(pose); // tell view about pose
SetActive(true); // for widget
textView->SelectAll();
textView->MakeFocus();
// make this text widget invisible while we edit it
SetVisible(false);
ASSERT(view->Window()); // how can I not have a Window here???
if (view->Window())
// force immediate redraw so TextView appears instantly
view->Window()->UpdateIfNeeded();
}
示例5: entry
void
BTextWidget::StartEdit(BRect bounds, BPoseView* view, BPose* pose)
{
view->SetTextWidgetToCheck(NULL, this);
if (!IsEditable() || IsActive())
return;
BEntry entry(pose->TargetModel()->EntryRef());
if (entry.InitCheck() == B_OK
&& !ConfirmChangeIfWellKnownDirectory(&entry,
B_TRANSLATE_COMMENT("rename",
"As in 'if you rename this folder...' (en) "
"'Wird dieser Ordner umbenannt...' (de)"),
B_TRANSLATE_COMMENT("rename",
"As in 'to rename this folder...' (en) "
"'Um diesen Ordner umzubenennen...' (de)"),
B_TRANSLATE_COMMENT("Rename",
"Button label, 'Rename' (en), 'Umbenennen' (de)")))
return;
// get bounds with full text length
BRect rect(bounds);
BRect textRect(bounds);
rect.OffsetBy(-2, -1);
rect.right += 1;
BFont font;
view->GetFont(&font);
BTextView* textView = new BTextView(rect, "WidgetTextView", textRect,
&font, 0, B_FOLLOW_ALL, B_WILL_DRAW);
textView->SetWordWrap(false);
DisallowMetaKeys(textView);
fText->SetUpEditing(textView);
textView->AddFilter(new BMessageFilter(B_KEY_DOWN, TextViewFilter));
rect.right = rect.left + textView->LineWidth() + 3;
// center new width, if necessary
if (view->ViewMode() == kIconMode
|| (view->ViewMode() == kListMode && fAlignment == B_ALIGN_CENTER)) {
rect.OffsetBy(bounds.Width() / 2 - rect.Width() / 2, 0);
}
rect.bottom = rect.top + textView->LineHeight() + 1;
textRect = rect.OffsetToCopy(2, 1);
textRect.right -= 3;
textRect.bottom--;
textView->SetTextRect(textRect);
BPoint origin = view->LeftTop();
textRect = view->Bounds();
bool hitBorder = false;
if (rect.left <= origin.x)
rect.left = origin.x + 1, hitBorder = true;
if (rect.right >= textRect.right)
rect.right = textRect.right - 1, hitBorder = true;
textView->MoveTo(rect.LeftTop());
textView->ResizeTo(rect.Width(), rect.Height());
BScrollView* scrollView = new BScrollView("BorderView", textView, 0, 0,
false, false, B_PLAIN_BORDER);
view->AddChild(scrollView);
// configure text view
switch (view->ViewMode()) {
case kIconMode:
textView->SetAlignment(B_ALIGN_CENTER);
break;
case kMiniIconMode:
textView->SetAlignment(B_ALIGN_LEFT);
break;
case kListMode:
textView->SetAlignment(fAlignment);
break;
}
textView->MakeResizable(true, hitBorder ? NULL : scrollView);
view->SetActivePose(pose);
// tell view about pose
SetActive(true);
// for widget
textView->SelectAll();
textView->MakeFocus();
// make this text widget invisible while we edit it
SetVisible(false);
ASSERT(view->Window() != NULL);
// how can I not have a Window here???
if (view->Window()) {
// force immediate redraw so TextView appears instantly
view->Window()->UpdateIfNeeded();
}
//.........这里部分代码省略.........