本文整理匯總了C++中ChildAt函數的典型用法代碼示例。如果您正苦於以下問題:C++ ChildAt函數的具體用法?C++ ChildAt怎麽用?C++ ChildAt使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ChildAt函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: if
status_t
BDragger::_DetermineRelationship()
{
if (fTarget) {
if (fTarget == Parent())
fRelation = TARGET_IS_PARENT;
else if (fTarget == ChildAt(0))
fRelation = TARGET_IS_CHILD;
else
fRelation = TARGET_IS_SIBLING;
} else {
if (fRelation == TARGET_IS_PARENT)
fTarget = Parent();
else if (fRelation == TARGET_IS_CHILD)
fTarget = ChildAt(0);
else
return B_ERROR;
}
if (fRelation == TARGET_IS_PARENT) {
BRect bounds (Frame());
BRect parentBounds (Parent()->Bounds());
if (!parentBounds.Contains(bounds))
MoveTo(parentBounds.right - bounds.Width(),
parentBounds.bottom - bounds.Height());
}
return B_OK;
}
示例2: TRACE
void NavigatorEditor::DetachedFromWindow(void)
{
TRACE();
while (ChildAt(0)!=NULL)
{
RemoveChild(ChildAt(0));
}
}
示例3: switch
void TMediaTabView::MessageReceived(BMessage* message)
{
// Check for messages to switch the view
bool buttonMsg = false;
EChildID newView;
switch (message->what)
{
case MEDIA_TAB_LIST_VIEW_MSG:
newView = kElementsView;
buttonMsg = true;
break;
case MEDIA_TAB_THUMBNAIL_VIEW_MSG:
newView = kThumbnailView;
buttonMsg = true;
break;
case MEDIA_TAB_ICON_VIEW_MSG:
newView = kIconView;
buttonMsg = true;
break;
}
if (buttonMsg) {
if (newView != fCurrentView) {
// Protect this section of code.
Looper()->Lock();
DeactivateView(fCurrentView);
fCurrentView = newView;
ActivateView(fCurrentView);
Looper()->Unlock();
}
return;
}
// Accept messages from the sorter object
switch (message->what)
{
case SORTER_SELECT_MSG:
case SORTER_INVOKE_MSG:
if (fCurrentView == kElementsView)
ChildAt(fCurrentView)->MessageReceived(message);
return;
// Some cue is adding an entry_ref to our browser
// TODO: include the other two views in this. They can
// have a new REF as well.
case ADD_REF_MSG:
if (fCurrentView == kElementsView)
ChildAt(fCurrentView)->MessageReceived(message);
return;
}
// Default handler
BView::MessageReceived(message);
}
示例4: BMailProtocolConfigView
SMTPConfigView::SMTPConfigView(MailAddonSettings& settings,
BMailAccountSettings& accountSettings)
:
BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_AUTH_METHODS
| B_MAIL_PROTOCOL_HAS_USERNAME | B_MAIL_PROTOCOL_HAS_PASSWORD
| B_MAIL_PROTOCOL_HAS_HOSTNAME
#ifdef USE_SSL
| B_MAIL_PROTOCOL_HAS_FLAVORS
#endif
)
{
#if defined(USE_SSL) || defined(B_COLLECTING_CATKEYS)
static const char* kUnencryptedStr = B_TRANSLATE_MARK("Unencrypted");
static const char* kSSLStr = B_TRANSLATE_MARK("SSL");
static const char* kSTARTTLSStr = B_TRANSLATE_MARK("STARTTLS");
#endif
#ifdef USE_SSL
AddFlavor(B_TRANSLATE_NOCOLLECT(kUnencryptedStr));
AddFlavor(B_TRANSLATE(kSSLStr));
AddFlavor(B_TRANSLATE(kSTARTTLSStr));
#endif
AddAuthMethod(B_TRANSLATE("None"), false);
AddAuthMethod(B_TRANSLATE("ESMTP"));
AddAuthMethod(B_TRANSLATE("POP3 before SMTP"), false);
BTextControl *control = (BTextControl *)(FindView("host"));
control->SetLabel(B_TRANSLATE("SMTP server:"));
// Reset the dividers after changing one
float widestLabel = 0;
for (int32 i = CountChildren(); i-- > 0;) {
if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i)))
widestLabel = MAX(widestLabel,text->StringWidth(text->Label()) + 5);
}
for (int32 i = CountChildren(); i-- > 0;) {
if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i)))
text->SetDivider(widestLabel);
}
BMenuField *field = (BMenuField *)(FindView("auth_method"));
field->SetDivider(widestLabel);
SetTo(settings);
fFileView = new BMailFileConfigView(B_TRANSLATE("Destination:"), "path",
false, BPrivate::default_mail_out_directory().Path());
fFileView->SetTo(&settings.Settings(), NULL);
AddChild(fFileView);
float w, h;
BMailProtocolConfigView::GetPreferredSize(&w, &h);
fFileView->MoveBy(0, h - 10);
GetPreferredSize(&w, &h);
ResizeTo(w, h);
}
示例5:
void
ThemeInterfaceView::PopulateThemeList()
{
int i;
BControl *c;
for (i = 0; ChildAt(i); i++) {
c = dynamic_cast<BControl *>(ChildAt(i));
if (c)
c->SetEnabled(false);
}
thread_id tid = spawn_thread(_ThemeListPopulatorTh, "ThemeListPopulator",
B_LOW_PRIORITY, this);
resume_thread(tid);
}
示例6: ClientRect
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;
}
}
示例7: Invalidate
void
PackagesView::FrameResized(float width, float height)
{
if (CountChildren() == 0)
Invalidate();
BScrollBar* scrollBar = ScrollBar(B_VERTICAL);
if (scrollBar == NULL)
return;
float virtualHeight = 0.0;
int32 count = CountChildren();
if (count > 0) {
BView* child = ChildAt(count - 1);
virtualHeight = child->Frame().bottom;
}
if (height > virtualHeight) {
scrollBar->SetRange(0.0f, 0.0f);
scrollBar->SetValue(0.0f);
} else {
scrollBar->SetRange(0.0f, virtualHeight - height);
scrollBar->SetProportion(height / virtualHeight);
}
scrollBar->SetSteps(15, height);
}
示例8: ChildAt
void TMediaTabView::ActivateView(EChildID which)
{
// Give the view the control buttons
BView* view = ChildAt(which);
BPoint pt = view->Bounds().LeftBottom();
// Get the target button position. Slightly different for the
// different view types.
if (which == kElementsView)
pt.y -= kScrollHeight;
else {
pt.x++;
pt.y -= kScrollHeight + 1;
}
for (int i = 0; i < 3; i++) {
view->AddChild(fbuttons[i]);
fbuttons[i]->MoveTo(pt);
pt.x += kScrollHeight;
}
// Make sure it is visible
if (view->IsHidden())
view->Show();
}
示例9: Looper
/*! Since we have set a mouse event mask, we don't want to forward all
mouse downs to the slider - instead, we only invoke it, which causes a
message to our target. Within the VolumeWindow, this will actually
cause the window to close.
Also, we need to mask out the dragger in this case, or else dragging
us will also cause a volume update.
*/
void
VolumeControl::MouseDown(BPoint where)
{
// Ignore clicks on the dragger
int32 viewToken;
if (Bounds().Contains(where) && Looper()->CurrentMessage() != NULL
&& Looper()->CurrentMessage()->FindInt32("_view_token",
&viewToken) == B_OK
&& viewToken != _get_object_token_(this))
return;
// TODO: investigate why this does not work as expected (the dragger
// frame seems to be off)
#if 0
if (BView* dragger = ChildAt(0)) {
if (!dragger->IsHidden() && dragger->Frame().Contains(where))
return;
}
#endif
if (!IsEnabled() || !Bounds().Contains(where)) {
Invoke();
return;
}
BSlider::MouseDown(where);
}
示例10: AddChild
status_t
BBox::SetLabel(BView *viewLabel)
{
if (viewLabel != NULL) {
if (viewLabel == this || viewLabel->Window() != NULL || viewLabel->Parent() != NULL) return B_ERROR;
AddChild(viewLabel, ChildAt(0));
if (viewLabel->Parent() != this) return B_ERROR;
viewLabel->SetResizingMode(B_FOLLOW_NONE);
} else if (fLabelView == NULL) {
return B_OK;
}
if (fLabelView != NULL) {
BView *view = fLabelView;
fLabelView = NULL;
view->RemoveSelf();
delete view;
}
fLabelView = viewLabel;
ReAdjustLabel();
return B_OK;
}
示例11: Bounds
void CollapsableBox::SetValue(int32 new_value)
{
if (new_value != Value()) {
BRect r = Bounds();
if (!new_value)
ResizeTo(r.Width(), m_collapsed_rect.Height());
else
ResizeTo(r.Width(), m_expanded_rect.Height());
BView *child;
child = ChildAt(0);
while (child) {
if (new_value)
child->Show();
else
child->Hide();
child = child->NextSibling();
};
Invalidate();
BControl::SetValue(new_value);
Invoke();
};
}
示例12: DisplayRecord
void MainView::DisplayRecord(Record *record, XFileMode mode)
{
Field * child = NULL;
BString data;
if ( (child = (Field *)ChildAt(0)) != NULL ) {
while ( child ) {
if(mode == DATA_MODE) {
if(child->IsDataField()) {
if(record->GetDataByFieldName(child->GetName(), data)) {
printf("has data\n");
}
child->SetData(data);
}
}
else if(mode == DESIGN_MODE)
{
data.SetTo(child->GetName());
child->SetData(data);
}
child = (Field *) child->NextSibling();
}
}
}
示例13: selectFieldByPoint
void MainView::selectFieldByPoint(const BPoint& point)
{
bool selected = false;
Field * child = NULL;
selected_fields.MakeEmpty();
if ( (child = (Field *)ChildAt(0)) != NULL ) {
while ( child ) {
if(selected == false && child->Frame().Contains(point)) {
child->SetSelected(true);
selected_fields.AddItem(child);
selected = true;
}
else {
child->SetSelected(false);
}
child->Invalidate();
child = (Field *)child->NextSibling();
}
}
if(selected_fields.CountItems() > 0) {
getSelBounds(sel_bounds);
}
}
示例14: switch
void
SetupWindow::MessageReceived(BMessage* msg)
{
bool success;
switch (msg->what) {
case M_OK:
Lock();
success = ((SetupView*)ChildAt(0))->CheckSetup();
Unlock();
if (success) {
fResult = B_NO_ERROR;
release_sem(fExitSem);
}
break;
case M_CANCEL:
fResult = B_ERROR;
release_sem(fExitSem);
break;
default:
BWindow::MessageReceived(msg);
break;
}
}
示例15:
// _FindIcon
IconButton*
IconOptionsControl::_FindIcon(int32 index) const
{
if (BView* view = ChildAt(index))
return dynamic_cast<IconButton*>(view);
return NULL;
}