void PairsView::CreateGameBoard() { // Show hidden buttons for (int32 i = 0; i < CountChildren(); i++) { BView* child = ChildAt(i); if (child->IsHidden()) child->Show(); } _GenerateCardPos(); }
void PackagesView::Draw(BRect updateRect) { if (CountChildren() > 0) return; be_control_look->DrawLabel(this, B_TRANSLATE("No optional packages available."), Bounds(), updateRect, ViewColor(), BControlLook::B_DISABLED, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE)); }
XMLEntity* XMLEntity::Child(const char *name) { if (name) { for (int i=0; i<CountChildren(); ++i) if (!strcasecmp(Child(i)->Name(), name)) return Child(i); } return NULL; }
void PackagesView::GetTotalSizeAsString(char* string, size_t stringSize) { int32 count = CountChildren(); int32 size = 0; for (int32 i = 0; i < count; i++) { PackageCheckBox* cb = dynamic_cast<PackageCheckBox*>(ChildAt(i)); if (cb && cb->Value()) size += cb->GetPackage()->Size(); } string_for_size(size, string, stringSize); }
float MessageView::ItemTop() { int32 count = CountChildren(); if (count > 0) { BView *tmpChild = ChildAt(count-1); return tmpChild->Frame().bottom+MARGIN_SPACE; } else return MARGIN_SPACE; }
void WrappingTextView::CalculateVerticalOffset() { float offset = 0; int max=CountChildren(); for( int i=0; i<max; ++i) { BView* child = ChildAt(i); child->MoveTo( 0, offset); BRect frame = child->Frame(); offset += frame.Height(); } m_vertical_offset = MAX( offset, 0); ResetTextRect(); }
/** Please be sure to call this should you ever * override the default Draw() method. */ void Window::DrawViews( Rect frame ) { /// \todo Only update the requested frame. lock(); for ( int i = 0; i < CountChildren(); i++ ) { View *view = ChildAt(i); view->Draw( view->Bounds() ); view->DrawChildren( view->Bounds() ); } unlock(); }
XMLEntity* XMLEntity::Child(const char *name, char *attribute, char *value) { if (name) { for (int i=0; i<CountChildren(); ++i) if (!strcasecmp(Child(i)->Name(), name) && !strcasecmp(Child(i)->Attribute(attribute), value)) return Child(i); } return NULL; }
void PackagesView::GetPackagesToInstall(BList* list, int32* size) { int32 count = CountChildren(); *size = 0; for (int32 i = 0; i < count; i++) { PackageCheckBox* cb = dynamic_cast<PackageCheckBox*>(ChildAt(i)); if (cb && cb->Value()) { list->AddItem(cb->GetPackage()); *size += cb->GetPackage()->Size(); } } }
CPUButton::CPUButton(BMessage *message) : BControl(message) { fReplicant = true; /* We remove the dragger if we are in deskbar */ if (CountChildren() > 1) RemoveChild(ChildAt(1)); ResizeTo(CPUBUTTON_WIDTH, CPUBUTTON_HEIGHT); _InitData(); }
View::~View() { while ( CountChildren() > 0 ) { View *sam = RemoveChild(0); delete sam; } if ( m_popupMenu != NULL ) { m_popupMenu->Quit(); } }
void View::DrawChildren( Rect rect ) { if ( GetWindow() == NULL ) return; lock(); for ( int i = 0; i < CountChildren(); i++ ) { View *child = ChildAt(i); child->Draw( rect ); child->DrawChildren( rect ); } unlock(); }
void Container::DetachedFromWindow() { View::DetachedFromWindow(); uint count = CountChildren(); for (int i = 0; i < count; ++i) m_childList[i]->DetachedFromWindow(); AllDetached(); for (int i = 0; i < count; ++i) m_childList[i]->SetWindow(nullptr); }
/*********************************************************** * FocusedView ***********************************************************/ BTextControl* HAddressView::FocusedView() const { int32 count = CountChildren(); BTextControl *child(NULL); for(int32 i = 0;i < count;i++) { child = cast_as(ChildAt(i),BTextControl); if(child && child->TextView()->IsFocus()) return child; } return NULL; }
/** 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()); } }
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; } }
void View::DetachedFromWindow() { lock(); for ( int i = 0; i < CountChildren(); i++ ) { View *view = ChildAt(i); if ( (view->getFlags() & PULSE_NEEDED) != 0 ) if ( view->_window != NULL ) view->_window->RemovePulseChild( view ); view->_window = NULL; view->DetachedFromWindow(); } unlock(); }
void Container::AttachedToWindow() { View::AttachedToWindow(); ::Window* window = Window(); uint count = CountChildren(); for (int i = 0; i < count; ++i) { View* view = m_childList[i]; view->SetWindow(window); view->AttachedToWindow(); } AllAttached(); }
void WrappingTextView::ResetTextRect() { BRect bounds = Bounds(); BRect textRect = bounds; textRect.left = 4.0; textRect.top = m_vertical_offset + 4.0f; if (m_fixed_width) textRect.right = 8.0f + StringWidth( "0") * float(m_fixed_width); else textRect.right -= 4.0f; textRect.bottom -= 4.0f; SetTextRect(textRect); // we have to readjust the scrollbar-proportion, since // the BTextView doesn't do it correctly when we have // fooled in a vertical_offset: float small, big; BScrollBar* bar = ScrollBar( B_VERTICAL); if (!bar) return; bar->GetSteps( &small, &big); float height = TextHeight( 0, TextLength()); if (height+m_vertical_offset) bar->SetProportion( MIN( 1.0f, big/(height+m_vertical_offset))); else bar->SetProportion( 1.0f); if (BeamOnDano) { // circumvent a special feature/bug in Zeta with respect to // the scrollbar not always calling ValueChanged() on a click. // Seemingly, changing the value twice hides the bug: bar->SetValue(1); bar->SetValue(0); } bar = ScrollBar( B_HORIZONTAL); if (!bar) return; float width = bounds.Width(); float maxWidth = MAX( width, textRect.right); int numChildren = IsEditable() ? 0 : CountChildren(); for( int i=0; i<numChildren; ++i) { float w = ChildAt( i)->Frame().Width(); if (w > maxWidth) maxWidth = w; } bar->SetSteps( width/10, width); bar->SetRange( 0, MAX(0, maxWidth-width)); bar->SetProportion( MIN( 1.0f, width/maxWidth)); }
void CInternalSettingsView::FrameResized(float width, float height) { float ypos = dist; for(int32 i=0 ; i<CountChildren() ; i++) { BView *child = ChildAt(i); float childWidth, childHeight; child->GetPreferredSize(&childWidth, &childHeight); child->MoveTo(dist, ypos); child->ResizeTo(width-2*dist, childHeight); ypos += childHeight+dist; } }
View *Window::ChildAt( int x, int y ) { lock(); for ( int i = CountChildren() - 1; i >= 0; i-- ) { View *view = ChildAt(i); if ( view->Frame().Contains( x,y ) ) { unlock(); return view; } } unlock(); return NULL; }
void CInternalSettingsView::GetPreferredSize(float *width, float *height) { float w=0, h=0; for(int32 i=0 ; i<CountChildren() ; i++) { float childWidth, childHeight; ChildAt(i)->GetPreferredSize(&childWidth, &childHeight); w = MAX(w, childWidth+2*dist); h += childHeight+dist; } if(width) *width = w; if(height) *height = (h!=0) ? h+dist : 0; }
void AccountView::AttachedToWindow() { // Once we are attached to window, the GUI is already created // so we can set our window as target for messages for (int32 i = 0; i < CountChildren(); i++) { BView* child = ChildAt(i); BMenu* menu = dynamic_cast<BMenu*>(child); BMenuField* menuField = dynamic_cast<BMenuField*>(child); BTextControl* textControl = dynamic_cast<BTextControl*>(child); NotifyingTextView* textView = dynamic_cast<NotifyingTextView*>(child); BCheckBox* checkBox = dynamic_cast<BCheckBox*>(child); if (menuField) menu = menuField->Menu(); if (menu) { for (int32 j = 0; j < menu->CountItems(); j++) { BMenuItem* item = menu->ItemAt(j); item->SetMessage(new BMessage(kChanged)); item->SetTarget(Window()); } menu->SetTargetForItems(Window()); } if (textControl) { textControl->SetMessage(new BMessage(kChanged)); textControl->SetTarget(Window()); } if (checkBox) { checkBox->SetMessage(new BMessage(kChanged)); checkBox->SetTarget(Window()); } if (textView) { textView->SetMessage(new BMessage(kChanged)); textView->SetTarget(Window()); } } }
// Returns the number of children of this group int CCWTreeCtrl::CountChildren(HTREEITEM hStartItem) const { // Walk the Tree! int num = 0; if (hStartItem != NULL && ItemHasChildren(hStartItem)) { HTREEITEM hChildItem = GetChildItem(hStartItem); while (hChildItem != NULL) { if (ItemHasChildren(hChildItem)) { num += CountChildren(hChildItem); } else { num++; } hChildItem = GetNextSiblingItem(hChildItem); } } return num; }
static int CountChildren(itv_object_t *p_this, int i_type) { int i, i_count = 0; itv_object_t *p_tmp; for(i = 0; i < itv_object_internals(p_this)->i_children; i++) { p_tmp = itv_object_internals(p_this)->pp_children[i]; if(itv_object_internals(p_tmp)->i_object_type == i_type) { i_count++; } i_count += CountChildren(p_tmp, i_type); } return i_count; }
void ArrowedView::GetPreferredSize(float *width, float *height) { fArrowButton->GetPreferredSize(width, height); (*height) ++; if (Value()) { if (CountChildren()==1) { *height += 15; } else { *width = max_c( *width, fMaxWidth ); *height = max_c( *height, fMaxHeight ); (*height) ++; } } }
/** Draws all spliters. */ void SplitView::Draw(BRect update) { BView *child; for (int i = 0; i < CountChildren() -1; i++) { child = ChildAt(i); BRect frame = child->Frame(); if (fLayout.Mode() == B_HORIZONTAL) { frame.left = frame.right+1; frame.right = frame.left + fLayout.Spacing().x-2; } else { frame.top = frame.bottom+1; frame.bottom = frame.top + fLayout.Spacing().y-2; } if (frame.Intersects(update)) DrawSplitter(frame, child == fSelected && fDragged); } }
void View::AttachedToWindow() { lock(); // First, add to the Window's pulse list if this view needs it. if ( (getFlags() & PULSE_NEEDED) != 0 ) if ( GetWindow() != NULL ) GetWindow()->AddPulseChild( this ); // ... for ( int i = 0; i < CountChildren(); i++ ) { View *view = ChildAt(i); view->_window = GetWindow(); view->AttachedToWindow(); } unlock(); }
void BMailProtocolConfigView::GetPreferredSize(float *width, float *height) { float minWidth = 250; if (BView *view = FindView("delete_remote_when_local")) { float ignore; view->GetPreferredSize(&minWidth,&ignore); } if (minWidth < 250) minWidth = 250; *width = minWidth + 10; *height = (CountChildren() * sItemHeight) + 5; if (fBodyDownloadConfig) { float bodyW, bodyH; fBodyDownloadConfig->GetPreferredSize(&bodyW, &bodyH); *height+= bodyH; } }
void ResetTree::PrintMoveOptions() { ResetTree *CurrentNode = Children.First; char mybuffer[20], mybuffer2[20]; int i = 1; printf("There are %d children:\n\n",CountChildren()); while(CurrentNode) { CurrentNode->GetMoveText(mybuffer); //CurrentNode->GetAlgebraicNotation(mybuffer2); //printf("%d. %s (%s)\n",i++,mybuffer,mybuffer2); printf("%d. %s \t",i++,mybuffer); CurrentNode = CurrentNode->NextSibling; if ((i-1) % 5 == 0) printf("\n"); } printf("\n"); }