本文整理汇总了C++中BView::ResizeTo方法的典型用法代码示例。如果您正苦于以下问题:C++ BView::ResizeTo方法的具体用法?C++ BView::ResizeTo怎么用?C++ BView::ResizeTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BView
的用法示例。
在下文中一共展示了BView::ResizeTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
SplitView::Relayout()
{
if (fSplitter)
fSplitter->SetOrientation(Orientation());
float max = _Size();
if (fPosition == -1) {
// set initial default position in the middle
fPosition = max * fProportion;
}
if (fPosition > max)
fPosition = max;
int32 count = CountChildren();
float last = 0;
for (int32 index = 0; index < count; index++) {
BView* child = ChildAt(index);
float size;
if (index == 0)
size = fPosition;
else if (Orientation() == B_VERTICAL)
size = (Bounds().right + 1 - last) / (count - index);
else
size = (Bounds().bottom + 1 - last) / (count - index);
if (index == 1 && fSplitter == NULL) {
// we need to add a splitter
AddChild(fSplitter = NewSplitter(), child);
child = fSplitter;
count++;
}
if (child == fSplitter)
size = SPLITTER_WIDTH;// + (Orientation() == B_VERTICAL ? 0 : 1);
if (Orientation() == B_VERTICAL) {
child->MoveTo(last, 0);
child->ResizeTo(size, Bounds().Height());
} else {
child->MoveTo(0, last);
child->ResizeTo(Bounds().Width(), size);
}
last += size + 1;
}
}
示例2: BOutlineListView
TestWindow::TestWindow(BApplication* myApp)
: BWindow(BRect(20,20,100,100),
"Code Profile", B_TITLED_WINDOW, 0)
{
BRect frm = Bounds();
BView* myview = new BView(BRect(),"testView",0,0);
BOutlineListView* olist =
new BOutlineListView(BRect(),"MyList",
B_SINGLE_SELECTION_LIST,B_FOLLOW_NONE);
if( myview && olist ) {
myview->AddChild(olist);
BView* vw = olist;
vw->SetViewColor(0xc0,0xc0,0xc0);
vw->Invalidate();
vw->SetLowColor(0xc0,0xc0,0xc0);
vw->Invalidate();
vw->SetHighColor(0x00,0x00,0x00);
vw->Invalidate();
vw->SetFont(be_bold_font);
this->AddChild(myview);
BRect frm = vw->Frame();
vw->ResizeTo(1,1);
vw->Draw(vw->Bounds());
vw->ResizeToPreferred();
float w=0,h=0;
vw->GetPreferredSize(&w,&h);
printf("Preferred size = %f x %f\n",w,h);
}
string = new BStringView(BRect(0,0,100,20),"String",
"Ready to profile...");
if( string ) {
string->SetViewColor(0xc0,0xc0,0xc0);
this->AddChild(string);
float w=0, h=0;
string->GetPreferredSize(&w,&h);
MoveTo(30,30);
ResizeTo(w,h);
}
BMenuBar* menu = new BMenuBar(BRect(),"MainMenu",B_FOLLOW_NONE);
if( menu ) {
this->AddChild(menu);
float w=0, h=0;
menu->GetPreferredSize(&w,&h);
printf("Preferred Size = (%f,%f)\n",w,h);
menu->SetFont(be_plain_font);
menu->GetPreferredSize(&w,&h);
printf("Preferred Size = (%f,%f)\n",w,h);
menu->SetFont(be_bold_font);
menu->GetPreferredSize(&w,&h);
printf("Preferred Size = (%f,%f)\n",w,h);
menu->SetFont(be_fixed_font);
menu->GetPreferredSize(&w,&h);
printf("Preferred Size = (%f,%f)\n",w,h);
}
}
示例3: AdjustBottomRightOfAllPanes
BPoint HTabSheet::AdjustBottomRightOfAllPanes()
{
BPoint overallBottomRight(0.0, 0.0);
for(int i=0; i<fPanes.CountItems(); ++i)
{
BView* pane = (BView*)fPanes.ItemAt(i);
if (!pane)
continue;
BPoint paneBottomRight = DetermineBottomRightOfPane(pane);
if (overallBottomRight.x < paneBottomRight.x)
overallBottomRight.x = paneBottomRight.x;
if (overallBottomRight.y < paneBottomRight.y)
overallBottomRight.y = paneBottomRight.y;
}
BPoint paneLeftTop;
for(int i=0; i<fPanes.CountItems(); ++i)
{
BView* pane = (BView*)fPanes.ItemAt(i);
if (!pane)
continue;
if (i == 0)
paneLeftTop = pane->Frame().LeftTop();
pane->ResizeTo(overallBottomRight.x + 1, overallBottomRight.y + 1);
}
return overallBottomRight+paneLeftTop;
}
示例4: FrameResized
void CSettingsGroup::FrameResized(float width, float height)
{
CBox::FrameResized(width, height);
BRect clientRect = ClientRect();
float ypos = clientRect.top+dist;
float columnWidth = (clientRect.Width() - numColumns*dist - dist) / numColumns;
for(int32 i=0 ; i<CountChildren() ; i++) {
BView *child = ChildAt(i);
float childWidth, childHeight;
child->GetPreferredSize(&childWidth, &childHeight);
int32 column = i%numColumns;
child->MoveTo(clientRect.left+column*(columnWidth+dist)+dist, ypos);
child->ResizeTo(columnWidth, childHeight);
if(((i+1)%numColumns) == 0)
ypos += childHeight+dist;
}
}
示例5: ViewForTab
void
TabView::Select(int32 tab)
{
BTabView::Select(tab);
BView *view = ViewForTab(Selection());
if (view != NULL) {
BRect rect = ContainerView()->Bounds();
view->ResizeTo(rect.Width(), rect.Height());
}
}
示例6:
void
CropView::DoLayout()
{
BView::DoLayout();
if (fTarget == NULL)
return;
fTarget->MoveTo(-fCropLeft, -fCropTop);
fTarget->ResizeTo(Bounds().Width() + fCropLeft + fCropRight,
Bounds().Height() + fCropTop + fCropBottom);
}
示例7: AddUIGroup
void AddUIGroup(const char* text, Statement* statement)
{
if (statement->GetChildren() == NULL) return;
DetailsBuilder builder(fParent, GetView(), GetControlBounds(), statement, fSettings);
builder.Visit(statement->GetChildren());
if (IsTop()) {
fBounds.OffsetTo(fBounds.left, builder.GetBounds().top);
} else {
BView* box = GetView();
box->ResizeTo(box->Bounds().Width(), builder.GetBounds().top + kBoxBottomMargin);
}
}
示例8: recalcLayout
/**
* @brief レイアウトを調整します。
*/
void TextDiffView::recalcLayout()
{
BRect bounds = Bounds();
float leftWidth = floor((bounds.Width() + 1 - B_H_SCROLL_BAR_HEIGHT - PANE_SPLITTER_WIDTH) / 2);
float rightWidth = (bounds.Width() + 1 - PANE_SPLITTER_WIDTH) - leftWidth;
// 左ペイン
BView* leftPaneView = FindView(NAME_LEFT_PANE_SCROLLER);
if (NULL != leftPaneView)
{
leftPaneView->MoveTo(bounds.left, bounds.top);
leftPaneView->ResizeTo(leftWidth - 1, bounds.Height());
}
// 右ペイン
BView* rightPaneView = FindView(NAME_RIGHT_PANE_SCROLLER);
if (NULL != rightPaneView)
{
rightPaneView->MoveTo(bounds.left + leftWidth + PANE_SPLITTER_WIDTH, bounds.top);
rightPaneView->ResizeTo(rightWidth - 1, bounds.Height());
}
}
示例9: Arrange
/**
Lays out child views.
*/
void SplitView::Arrange()
{
fLayout.Frame()= Bounds();
fLayout.Reset();
BView *child;
uint32 hint = LAYOUT_HINT_NONE;
for (int32 i = 0; (child = ChildAt(i)); i++) {
if (i == CountChildren() - 1)
hint |= (LAYOUT_HINT_LAST | LAYOUT_HINT_CLIP);
BRect frame = fLayout.Next(child->Frame(), hint);
child->MoveTo(frame.LeftTop());
child->ResizeTo(frame.Width(), frame.Height());
}
}
示例10: app
// ---------------------------------------------------------------
// main
//
// Creates a BWindow for displaying info about the BMPTranslator
//
// Preconditions:
//
// Parameters:
//
// Postconditions:
//
// Returns:
// ---------------------------------------------------------------
int
main()
{
BApplication app("application/x-vnd.obos-bmp-translator");
BMPTranslator *ptranslator = new BMPTranslator;
BView *view = NULL;
BRect rect(0, 0, 225, 175);
if (ptranslator->MakeConfigurationView(NULL, &view, &rect)) {
BAlert *err = new BAlert("Error",
"Unable to create the BMPTranslator view.", "OK");
err->Go();
return 1;
}
// release the translator even though I never really used it anyway
ptranslator->Release();
ptranslator = NULL;
BMPWindow *wnd = new BMPWindow(rect);
view->ResizeTo(rect.Width(), rect.Height());
wnd->AddChild(view);
BPoint wndpt = B_ORIGIN;
{
BScreen scrn;
BRect frame = scrn.Frame();
frame.InsetBy(10, 23);
// if the point is outside of the screen frame,
// use the mouse location to find a better point
if (!frame.Contains(wndpt)) {
uint32 dummy;
view->GetMouse(&wndpt, &dummy, false);
wndpt.x -= rect.Width() / 2;
wndpt.y -= rect.Height() / 2;
// clamp location to screen
if (wndpt.x < frame.left)
wndpt.x = frame.left;
if (wndpt.y < frame.top)
wndpt.y = frame.top;
if (wndpt.x > frame.right)
wndpt.x = frame.right;
if (wndpt.y > frame.bottom)
wndpt.y = frame.bottom;
}
}
wnd->MoveTo(wndpt);
wnd->Show();
app.Run();
return 0;
}
示例11: FrameResized
void MainView::FrameResized(float width, float height) {
BView::ResizeTo(width, height);
/* return;
if (scrollView) {
scrollView->ResizeTo(width-5, height-5);
}
width -= (B_H_SCROLL_BAR_HEIGHT+9);
height -= (B_V_SCROLL_BAR_WIDTH+9);
*/ BView* list = FindView("list");
if (list) {
list->ResizeTo(width, height);
}
// FixupScrollbars();
}
示例12: BAlert
status_t
LaunchTranslatorWindow(BTranslator *translator, const char *title, BRect rect)
{
BView *view = NULL;
if (translator->MakeConfigurationView(NULL, &view, &rect)) {
BAlert *err = new BAlert("Error",
"Unable to create the view.", "OK");
err->Go();
return B_ERROR;
}
// release the translator even though I never really used it anyway
translator->Release();
translator = NULL;
TranslatorWindow *wnd = new TranslatorWindow(rect, title);
view->ResizeTo(rect.Width(), rect.Height());
wnd->AddChild(view);
BPoint wndpt = B_ORIGIN;
{
BScreen scrn;
BRect frame = scrn.Frame();
frame.InsetBy(10, 23);
// if the point is outside of the screen frame,
// use the mouse location to find a better point
if (!frame.Contains(wndpt)) {
uint32 dummy;
view->GetMouse(&wndpt, &dummy, false);
wndpt.x -= rect.Width() / 2;
wndpt.y -= rect.Height() / 2;
// clamp location to screen
if (wndpt.x < frame.left)
wndpt.x = frame.left;
if (wndpt.y < frame.top)
wndpt.y = frame.top;
if (wndpt.x > frame.right)
wndpt.x = frame.right;
if (wndpt.y > frame.bottom)
wndpt.y = frame.bottom;
}
}
wnd->MoveTo(wndpt);
wnd->Show();
return B_OK;
}
示例13: Select
void ArpConfigurePanel::Select(int32 tab)
{
inherited::Select(tab);
if( Parent() ) {
BTab* tabobj = TabAt(tab);
if( tabobj ) {
BView* view = tabobj->View();
BRect frame(Frame());
if( view ) {
view->ResizeTo(frame.Width()-mTabWidth,
frame.Height()-mTabHeight);
}
}
SendSetPanel(tab);
}
}
示例14: FrameResized
void CounterView::FrameResized (float width, float height)
{
BRect BitmapRect (0, 0, width, height);
char TempString [40];
m_BndRect = Bounds ();
m_MovingDotSize = (int) (height / 20);
if (m_MovingDotSize < 1)
m_MovingDotSize = 1;
m_MoveSpeed = m_MovingDotSize / 2.0;
// Resize the offscreen bitmap and its view.
if (m_BackingBitmap != NULL)
{
m_BackingBitmap->RemoveChild (&m_BackingView);
delete m_BackingBitmap;
m_BackingBitmap = NULL;
}
m_BackingView.ResizeTo (width, height);
m_BackingBitmap = new BBitmap (BitmapRect, B_RGBA32, true /* Accepts subviews */);
if (!m_BackingBitmap->IsValid ())
{
delete m_BackingBitmap;
m_BackingBitmap = NULL;
}
else
{
m_BackingBitmap->AddChild (&m_BackingView);
m_BackingBitmap->Lock ();
m_BackingView.SetDrawingMode (B_OP_ALPHA);
m_BackingView.SetFontSize (height * 0.8);
sprintf (TempString, "%d", m_CurrentCount);
m_TextStartPoint.x = width / 2 - m_BackingView.StringWidth (TempString) / 2;
m_TextStartPoint.y = height / 2 + height * 0.25;
m_BackingBitmap->Unlock ();
}
}
示例15: app
int
main()
{
BApplication app("application/x-vnd.Haiku-PPMTranslator");
BView * v = NULL;
BRect r(0, 0, 1, 1);
if (MakeConfig(NULL, &v, &r)) {
BAlert * err = new BAlert("Error",
B_TRANSLATE("Something is wrong with the PPMTranslator!"),
B_TRANSLATE("OK"));
err->Go();
return 1;
}
PPMWindow *w = new PPMWindow(r);
v->ResizeTo(r.Width(), r.Height());
w->AddChild(v);
BPoint o = get_window_origin();
{
BScreen scrn;
BRect f = scrn.Frame();
f.InsetBy(10,23);
/* if not in a good place, start where the cursor is */
if (!f.Contains(o)) {
uint32 i;
v->GetMouse(&o, &i, false);
o.x -= r.Width()/2;
o.y -= r.Height()/2;
/* clamp location to screen */
if (o.x < f.left) o.x = f.left;
if (o.y < f.top) o.y = f.top;
if (o.x > f.right) o.x = f.right;
if (o.y > f.bottom) o.y = f.bottom;
}
}
w->MoveTo(o);
w->Show();
app.Run();
return 0;
}