2010-05-09 01:27:48 -05:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2021-06-18 01:13:02 -05:00
|
|
|
#include "TemplateView.h"
|
|
|
|
|
2010-05-09 01:27:48 -05:00
|
|
|
#include <Button.h>
|
|
|
|
#include <ControlLook.h>
|
|
|
|
#include <CheckBox.h>
|
|
|
|
#include <GroupLayout.h>
|
|
|
|
#include <GroupLayoutBuilder.h>
|
|
|
|
#include <PopUpMenu.h>
|
|
|
|
#include <MenuField.h>
|
|
|
|
#include <MenuItem.h>
|
|
|
|
#include <ScrollView.h>
|
|
|
|
#include <TextControl.h>
|
|
|
|
#include <Window.h>
|
|
|
|
|
|
|
|
|
2021-06-18 01:13:02 -05:00
|
|
|
TemplateView::TemplateView(const char* name)
|
2010-05-09 01:27:48 -05:00
|
|
|
: BView(name, B_WILL_DRAW)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2021-06-18 01:13:02 -05:00
|
|
|
TemplateView::AttachedToWindow()
|
2010-05-09 01:27:48 -05:00
|
|
|
{
|
|
|
|
// 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);
|
2021-07-29 22:47:30 -05:00
|
|
|
BTextView* textView = dynamic_cast<BTextView*>(child);
|
2010-05-09 01:27:48 -05:00
|
|
|
BCheckBox* checkBox = dynamic_cast<BCheckBox*>(child);
|
|
|
|
|
|
|
|
if (menuField)
|
|
|
|
menu = menuField->Menu();
|
|
|
|
|
|
|
|
if (menu) {
|
2021-06-18 14:18:45 -05:00
|
|
|
if (i == 0)
|
|
|
|
menu->MakeFocus(true);
|
2010-05-09 01:27:48 -05:00
|
|
|
menu->SetTargetForItems(Window());
|
|
|
|
}
|
|
|
|
|
2021-07-29 22:47:30 -05:00
|
|
|
if (textControl)
|
2021-06-18 14:18:45 -05:00
|
|
|
if (i == 0)
|
|
|
|
textControl->MakeFocus(true);
|
2010-05-09 01:27:48 -05:00
|
|
|
|
2021-07-29 22:47:30 -05:00
|
|
|
if (checkBox)
|
2021-06-18 14:18:45 -05:00
|
|
|
if (i == 0)
|
|
|
|
checkBox->MakeFocus(true);
|
2010-05-09 01:27:48 -05:00
|
|
|
|
2021-07-29 22:47:30 -05:00
|
|
|
if (textView)
|
2021-06-18 14:18:45 -05:00
|
|
|
if (i == 0)
|
|
|
|
textView->MakeFocus(true);
|
2010-05-09 01:27:48 -05:00
|
|
|
}
|
|
|
|
}
|