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; }
void NavigatorEditor::DetachedFromWindow(void) { TRACE(); while (ChildAt(0)!=NULL) { RemoveChild(ChildAt(0)); } }
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); }
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); }
void WorkspacesWindow::SetAutoRaise(bool enable) { fSettings->SetAutoRaising(enable); if (enable) ChildAt(0)->SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY); else ChildAt(0)->SetEventMask(0); }
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); }
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; } }
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); }
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(); }
/*! 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); }
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; }
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(); }; }
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(); } } }
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); } }
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; } }
// _FindIcon IconButton* IconOptionsControl::_FindIcon(int32 index) const { if (BView* view = ChildAt(index)) return dynamic_cast<IconButton*>(view); return NULL; }
virtual void MessageReceived(BMessage* message) { switch (message->what) { case MSG_TEST_OPEN_FILE_PANEL: { BFilePanel* panel = new BFilePanel(); panel->Show(); } break; case MSG_TEST_SAVE_FILE_PANEL: { BFilePanel* panel = new BFilePanel(B_SAVE_PANEL); panel->Show(); } break; case MSG_TOGGLE_LOOK: { BControlLook* temp = fControlLook; fControlLook = be_control_look; be_control_look = temp; _InvalidateChildrenAndView(ChildAt(0)); } break; default: BWindow::MessageReceived(message); } }
void TTextControl::AttachedToWindow(void) { const char *string; BTextView *text; SetHighColor(0, 0, 0); BTextControl::AttachedToWindow(); SetFontName("Erich"); SetDivider(StringWidth(fLabel) + 6); text = (BTextView *)ChildAt(0); text->SetFontName("Erich"); if (fRecord) { if (fIncoming) SetEnabled(FALSE); switch (fCommand) { case SUBJECT_FIELD: string = fRecord->FindString("Subject"); if (fRecord->Error() == B_NO_ERROR) SetText(string); break; case TO_FIELD: string = fRecord->FindString("Name"); if (fRecord->Error() == B_NO_ERROR) SetText(string); break; } } }
void TScrollViewComponent::FrameMoved(BPoint screenPoint) { printf("TScrollViewComponent::FrameMoved....\n"); Invalidate(); BView *child; if ( child = ChildAt(0) ) { child->Invalidate(); child->FrameResized(0,0); BRect AFrame = this->Frame(); BRect AFrame2 = child->Frame(); printf("TScrollViewComponent::FrameMoved Getting ScrollBar\n"); BScrollBar *truc = this->ScrollBar(B_HORIZONTAL); AFrame2 = truc->Frame(); FPropertyList->SetPropertyValue(PROP_BOTTOM,FloatToStr(AFrame.bottom -2 -((AFrame2.bottom - AFrame2.top)))); truc = this->ScrollBar(B_VERTICAL); AFrame2 = truc->Frame(); FPropertyList->SetPropertyValue(PROP_RIGHT,FloatToStr(AFrame.right -2 - ((AFrame2.right-AFrame2.left)))); FPropertyList->SetPropertyValue(PROP_TOP,FloatToStr(AFrame.top + 2)); FPropertyList->SetPropertyValue(PROP_LEFT,FloatToStr(AFrame.left + 2)); } BScrollView::FrameMoved(screenPoint); // FrameMovedComponent(FInternalComponent); // FInternalComponent->FrameMovedComponent(FInternalComponent); }
void BScrollView::SetTarget(BView *target) { if (fTarget == target) return; if (fTarget != NULL) { fTarget->TargetedByScrollView(NULL); RemoveChild(fTarget); // we are not supposed to delete the view } fTarget = target; if (fHorizontalScrollBar != NULL) fHorizontalScrollBar->SetTarget(target); if (fVerticalScrollBar != NULL) fVerticalScrollBar->SetTarget(target); if (target != NULL) { target->MoveTo(BorderSize(fBorder), BorderSize(fBorder)); target->TargetedByScrollView(this); AddChild(target, ChildAt(0)); // This way, we are making sure that the target will // be added top most in the list (which is important // for unarchiving) } }
void IppSetupDlg::MessageReceived(BMessage *msg) { bool success; switch (msg->what) { case M_OK: Lock(); success = ((IppSetupView *)ChildAt(0))->UpdateViewData(); Unlock(); if (success) { result = B_NO_ERROR; release_sem(semaphore); } break; case M_CANCEL: result = B_ERROR; release_sem(semaphore); break; default: BWindow::MessageReceived(msg); break; } }
void TTextControl::MessageReceived(BMessage *msg) { bool handled = FALSE; char separator[4] = ", "; const char* address; long item = 0; long len; long result; BRecord *record; BTextView *text_view; record_ref ref; switch (msg->what) { case B_SIMPLE_DATA: if (fCommand != SUBJECT_FIELD) { if ((!fIncoming) && (msg->HasRef("refs"))) { do { ref = msg->FindRef("refs", item++); if ((result = msg->Error()) == B_NO_ERROR) { record = new BRecord(ref); if (strcmp(record->Table()->Name(), "Person") == 0) { address = record->FindString("E-mail"); if (strlen(address)) { text_view = (BTextView *)ChildAt(0); if (len = text_view->TextLength()) { text_view->Select(len, len); text_view->Insert(separator); } text_view->Insert(address); } } delete record; } } while (result == B_NO_ERROR); } } break; case M_SELECT: text_view = (BTextView *)ChildAt(0); text_view->Select(0, text_view->TextLength()); break; default: BTextControl::MessageReceived(msg); } }
void CInternalSettingsView::WriteToPrefs(CPreferences *prefs) { for(int32 i=0 ; i<CountChildren() ; i++) { CPrefPersistent *child = dynamic_cast<CPrefPersistent *>(ChildAt(i)); if(child) child->WriteToPrefs(prefs); } }
void CSettingsGroup::ReadFromPrefs(CPreferences *prefs) { for(int32 i=0 ; i<CountChildren() ; i++) { CPrefPersistent *child = dynamic_cast<CPrefPersistent *>(ChildAt(i)); if(child) child->ReadFromPrefs(prefs); } }
/*------------------------------------------------------------------------------*\ ( ) - \*------------------------------------------------------------------------------*/ BmTextControl::BmTextControl( const char* label, BmMenuControllerBase* menu, int32 fixedTextLen, int32 minTextLen) : inherited( BRect(0,0,0,0), NULL, "", NULL, NULL, B_FOLLOW_NONE) , mLabelIsMenu( true) , mTextView( static_cast<BTextView*>( ChildAt( 0))) { InitSize( label, fixedTextLen, minTextLen, menu); }
nsIContent* nsAttrAndChildArray::GetSafeChildAt(uint32_t aPos) const { if (aPos < ChildCount()) { return ChildAt(aPos); } return nullptr; }
nsIContent* nsAttrAndChildArray::GetSafeChildAt(PRUint32 aPos) const { if (aPos < ChildCount()) { return ChildAt(aPos); } return nsnull; }
/*------------------------------------------------------------------------------*\ ( ) - \*------------------------------------------------------------------------------*/ BmTextControl::BmTextControl( const char* label, bool labelIsMenu, int32 fixedTextLen, int32 minTextLen) : inherited( BRect(0,0,0,0), NULL, labelIsMenu ? "" : label, NULL, NULL, B_FOLLOW_NONE) , mLabelIsMenu( labelIsMenu) , mTextView( static_cast<BTextView*>( ChildAt( 0))) { InitSize( label, fixedTextLen, minTextLen, NULL); }
ArpKnobControl* ArpKnobPanel::KnobControl() const { BView* view; for( view = ChildAt(0); view; view = view->NextSibling() ) { ArpKnobControl* knob = dynamic_cast<ArpKnobControl*>( view ); if( knob ) return knob; } return 0; }
NumberControl(BRect frame, float divider, const char *name, const char *label, long value, BMessage *message) : BTextControl(frame, name, label, NULL, message, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE) { SetDivider(divider); for (int c=0; c<256; c++) if (!isdigit(c) && c != B_BACKSPACE && c != B_LEFT_ARROW && c != B_RIGHT_ARROW) ((BTextView *)ChildAt(0))->DisallowChar(c); SetValue(value); }