/* * Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Pier Luigi Fiorini, pierluigi.fiorini@gmail.com */ #include "TemplateView.h" #include #include #include #include #include #include #include #include #include #include #include #include TemplateView::TemplateView(const char* name) : BView(name, B_WILL_DRAW) { } void TemplateView::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(child); BMenuField* menuField = dynamic_cast(child); BTextControl* textControl = dynamic_cast(child); NotifyingTextView* textView = dynamic_cast(child); BCheckBox* checkBox = dynamic_cast(child); if (menuField) menu = menuField->Menu(); if (menu) { if (i == 0) menu->MakeFocus(true); 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) { if (i == 0) textControl->MakeFocus(true); textControl->SetMessage(new BMessage(kChanged)); textControl->SetTarget(Window()); } if (checkBox) { if (i == 0) checkBox->MakeFocus(true); checkBox->SetMessage(new BMessage(kChanged)); checkBox->SetTarget(Window()); } if (textView) { if (i == 0) textView->MakeFocus(true); textView->SetMessage(new BMessage(kChanged)); textView->SetTarget(Window()); } } }