本文整理汇总了C++中BView::FindView方法的典型用法代码示例。如果您正苦于以下问题:C++ BView::FindView方法的具体用法?C++ BView::FindView怎么用?C++ BView::FindView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BView
的用法示例。
在下文中一共展示了BView::FindView方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BStringView
void
ServerSettingsView::_GetAuthEncrMenu(entry_ref protocol,
BMenuField*& authField, BMenuField*& sslField)
{
BMailAccountSettings dummySettings;
BView *view = new BStringView("", "Not here!");//CreateConfigView(protocol, dummySettings.InboundSettings(),
// dummySettings, fImageId);
authField = (BMenuField*)view->FindView("auth_method");
sslField = (BMenuField*)view->FindView("flavor");
view->RemoveChild(authField);
view->RemoveChild(sslField);
delete view;
}
示例2:
static filter_result
TextViewFilter(BMessage* message, BHandler**, BMessageFilter* filter)
{
uchar key;
if (message->FindInt8("byte", (int8*)&key) != B_OK)
return B_DISPATCH_MESSAGE;
ThrowOnAssert(filter != NULL);
BContainerWindow* window = dynamic_cast<BContainerWindow*>(
filter->Looper());
ThrowOnAssert(window != NULL);
BPoseView* poseView = window->PoseView();
ThrowOnAssert(poseView != NULL);
if (key == B_RETURN || key == B_ESCAPE) {
poseView->CommitActivePose(key == B_RETURN);
return B_SKIP_MESSAGE;
}
if (key == B_TAB) {
if (poseView->ActivePose()) {
if (message->FindInt32("modifiers") & B_SHIFT_KEY)
poseView->ActivePose()->EditPreviousWidget(poseView);
else
poseView->ActivePose()->EditNextWidget(poseView);
}
return B_SKIP_MESSAGE;
}
// the BTextView doesn't respect window borders when resizing itself;
// we try to work-around this "bug" here.
// find the text editing view
BView* scrollView = poseView->FindView("BorderView");
if (scrollView != NULL) {
BTextView* textView = dynamic_cast<BTextView*>(
scrollView->FindView("WidgetTextView"));
if (textView != NULL) {
BRect rect = scrollView->Frame();
if (rect.right + 3 > poseView->Bounds().right
|| rect.left - 3 < 0)
textView->MakeResizable(true, NULL);
}
}
return B_DISPATCH_MESSAGE;
}
示例3: index
void
PBox::GetData(BMessage* data){
BView * panel = fPrefView;
BMessage cur;
for (int i = 0; fTemplate.FindMessage("setting", i, &cur) == B_OK; i++) {
const char *name = cur.FindString("name");
int32 type = -1;
cur.FindInt32("type", &type);
if ( dynamic_cast<BTextControl*>(panel->FindView(name))) {
// Free text
BTextControl * ctrl = (BTextControl*)panel->FindView(name);
switch (type) {
case B_STRING_TYPE: {
data->AddString(name, ctrl->Text() );
} break;
case B_INT32_TYPE: {
data->AddInt32(name, atoi(ctrl->Text()) );
} break;
default: {
return;
};
};
} else if (dynamic_cast<BMenuField*>(panel->FindView(name))) {
// Provided option
BMenuField * ctrl = (BMenuField*)panel->FindView(name);
BMenuItem * item = ctrl->Menu()->FindMarked();
if (!item) return;
switch (type) {
case B_STRING_TYPE: {
data->AddString(name, item->Label() );
BString index(name);
index << "_index";
data->AddInt32(index.String(), ctrl->Menu()->IndexOf(item)); //index
} break;
case B_INT32_TYPE: {
data->AddInt32(name, atoi(item->Label()) );
BString index(name);
index << "_index";
data->AddInt32(index.String(), ctrl->Menu()->IndexOf(item)); //index
} break;
default: {
return;
};
}
} else
if (dynamic_cast<BCheckBox*>(panel->FindView(name))) {
// Boolean setting
BCheckBox * box = (BCheckBox*)panel->FindView(name);
if ( box->Value() == B_CONTROL_ON ) {
data->AddBool(name,true);
} else {
data->AddBool(name,false);
}
} else if (dynamic_cast<BTextView *>(panel->FindView(name))) {
BTextView *view = (BTextView *)panel->FindView(name);
data->AddString(name, view->Text());
};
};
}
示例4: rect
void
ImageFilePanel::Show()
{
if (fImageView == NULL) {
Window()->Lock();
BView* background = Window()->ChildAt(0);
uint32 poseViewResizingMode
= background->FindView("PoseView")->ResizingMode();
uint32 countVwResizingMode
= background->FindView("CountVw")->ResizingMode();
uint32 vScrollBarResizingMode
= background->FindView("VScrollBar")->ResizingMode();
uint32 hScrollBarResizingMode
= background->FindView("HScrollBar")->ResizingMode();
background->FindView("PoseView")
->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
background->FindView("CountVw")
->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
background->FindView("VScrollBar")
->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
background->FindView("HScrollBar")
->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_TOP);
Window()->ResizeBy(0, 70);
background->FindView("PoseView")->SetResizingMode(poseViewResizingMode);
background->FindView("CountVw")->SetResizingMode(countVwResizingMode);
background->FindView("VScrollBar")
->SetResizingMode(vScrollBarResizingMode);
background->FindView("HScrollBar")
->SetResizingMode(hScrollBarResizingMode);
BRect rect(background->Bounds().left + 15,
background->Bounds().bottom - 94, background->Bounds().left + 122,
background->Bounds().bottom - 15);
fImageView = new BView(rect, "ImageView",
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_SUBPIXEL_PRECISE);
fImageView->SetViewColor(background->ViewColor());
background->AddChild(fImageView);
rect = BRect(background->Bounds().left + 132,
background->Bounds().bottom - 85, background->Bounds().right,
background->Bounds().bottom - 65);
fResolutionView = new BStringView(rect, "ResolutionView", NULL,
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
background->AddChild(fResolutionView);
rect.OffsetBy(0, -16);
fImageTypeView = new BStringView(rect, "ImageTypeView", NULL,
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
background->AddChild(fImageTypeView);
Window()->Unlock();
}
BFilePanel::Show();
}
示例5: r
int32
LibraryWindow::ScanThread(void *data)
{
LibraryWindow *win = (LibraryWindow *)data;
float maxwidth;
BRect r(5,5,105,20);
BView *systemheader = win->AddHeader(r.LeftTop(),TR("System Libraries:"));
win->Lock();
r = systemheader->Frame();
win->Unlock();
maxwidth = r.right;
r.OffsetBy(0,r.Height() + 10);
DPath sysPath = GetSystemPath(B_USER_DEVELOP_DIRECTORY);
sysPath << "lib/x86";
BRect out = win->ScanFolder(r.LeftTop(),sysPath.GetFullPath(),&maxwidth);
if (out != BRect(0,0,-1,-1))
{
r = out;
r.OffsetBy(0,10);
}
if (gPlatform == PLATFORM_HAIKU || gPlatform == PLATFORM_HAIKU_GCC4)
{
BView *commonheader = win->AddHeader(r.LeftTop(),TR("Common Libraries:"));
win->Lock();
r = commonheader->Frame();
win->Unlock();
maxwidth = MAX(r.right,maxwidth);
r.OffsetBy(0,r.Height() + 10);
out = win->ScanFolder(r.LeftTop(),GetSystemPath(B_USER_LIB_DIRECTORY).GetFullPath(),
&maxwidth);
if (out != BRect(0,0,-1,-1))
{
r = out;
r.OffsetBy(0,10);
}
}
BView *userheader = win->AddHeader(r.LeftTop(),TR("User Libraries:"));
win->Lock();
r = userheader->Frame();
win->Unlock();
maxwidth = MAX(r.right,maxwidth);
r.OffsetBy(0,r.Height() + 10);
out = win->ScanFolder(r.LeftTop(),GetSystemPath(B_USER_LIB_DIRECTORY).GetFullPath(),
&maxwidth);
if (out.IsValid())
{
r = out;
r.OffsetBy(0,10);
}
win->Lock();
BView *top = win->GetBackgroundView();
BScrollView *scrollView = (BScrollView*)top->FindView("scrollView");
BScrollBar *vbar = scrollView->ScrollBar(B_VERTICAL);
vbar->SetRange(0, r.bottom - scrollView->Bounds().Height());
vbar->SetSteps(r.Height() * 2.0,r.Height() * 8.0);
gSettings.Lock();
BRect savedframe;
if (gSettings.FindRect("libwin_frame",&savedframe) == B_OK)
win->ResizeTo(savedframe.Width(),savedframe.Height());
gSettings.Unlock();
BStringView *label = (BStringView*)top->FindView("label");
label->SetText(TR("Choose the system libraries for your project."));
float minw = label->Frame().right + 10;
win->SetSizeLimits(minw,30000,200,30000);
if (win->Bounds().Width() < minw)
win->ResizeTo(minw,win->Bounds().Height());
win->fScanThread = -1;
win->Unlock();
return 0;
}
示例6: BMessage
// SavePanel class
SavePanel::SavePanel(const char* name,
BMessenger* target,
entry_ref* startDirectory,
uint32 nodeFlavors,
bool allowMultipleSelection,
BMessage* message,
BRefFilter* filter,
bool modal,
bool hideWhenDone)
: BFilePanel(B_SAVE_PANEL, target, startDirectory,
nodeFlavors, allowMultipleSelection,
message, filter, modal, hideWhenDone),
BHandler(name),
fConfigWindow(NULL),
fFormatM(NULL),
fExportMode(EXPORT_MODE_ICON_RDEF)
{
BWindow* window = Window();
if (!window || !window->Lock())
return;
window->SetTitle(B_TRANSLATE("Save image"));
// add this instance as BHandler to the window's looper
window->AddHandler(this);
// find a couple of important views and mess with their layout
BView* background = Window()->ChildAt(0);
BButton* cancel = dynamic_cast<BButton*>(background->FindView("cancel button"));
BView* textview = background->FindView("text view");
BScrollBar* hscrollbar = dynamic_cast<BScrollBar*>(background->FindView("HScrollBar"));
if (!background || !cancel || !textview || !hscrollbar) {
printf("SavePanel::SavePanel() - couldn't find necessary controls.\n");
return;
}
_BuildMenu();
BRect rect = textview->Frame();
rect.top = cancel->Frame().top;
font_height fh;
be_plain_font->GetHeight(&fh);
rect.bottom = rect.top + fh.ascent + fh.descent + 5.0;
fFormatMF = new BMenuField(rect, "format popup", B_TRANSLATE("Format"),
fFormatM, true,
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
B_WILL_DRAW | B_NAVIGABLE);
fFormatMF->SetDivider(be_plain_font->StringWidth(
B_TRANSLATE("Format")) + 7);
fFormatMF->MenuBar()->ResizeToPreferred();
fFormatMF->ResizeToPreferred();
float height = fFormatMF->Bounds().Height() + 8.0;
// find all the views that are in the way and
// move up them up the height of the menu field
BView *poseview = background->FindView("PoseView");
if (poseview) poseview->ResizeBy(0, -height);
BButton *insert = (BButton *)background->FindView("default button");
if (hscrollbar) hscrollbar->MoveBy(0, -height);
BScrollBar *vscrollbar = (BScrollBar *)background->FindView("VScrollBar");
if (vscrollbar) vscrollbar->ResizeBy(0, -height);
BView *countvw = (BView *)background->FindView("CountVw");
if (countvw) countvw->MoveBy(0, -height);
textview->MoveBy(0, -height);
#if HAIKU_TARGET_PLATFORM_DANO
fFormatMF->MoveTo(textview->Frame().left, fFormatMF->Frame().top + 2);
#else
fFormatMF->MoveTo(textview->Frame().left, fFormatMF->Frame().top);
#endif
background->AddChild(fFormatMF);
// Build the "Settings" button relative to the format menu
rect = cancel->Frame();
rect.OffsetTo(fFormatMF->Frame().right + 5.0, rect.top);
fSettingsB = new BButton(rect, "settings",
B_TRANSLATE("Settings"B_UTF8_ELLIPSIS),
new BMessage(MSG_SETTINGS),
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
B_WILL_DRAW | B_NAVIGABLE);
fSettingsB->ResizeToPreferred();
background->AddChild(fSettingsB);
fSettingsB->SetTarget(this);
textview->ResizeTo(fSettingsB->Frame().right - fFormatMF->Frame().left,
textview->Frame().Height());
// Make sure the smallest window won't draw the "Settings" button over anything else
float minWindowWidth = textview->Bounds().Width()
+ cancel->Bounds().Width()
+ (insert ? insert->Bounds().Width() : 0.0)
+ 90;
Window()->SetSizeLimits(minWindowWidth, 10000, 250, 10000);
if (Window()->Bounds().IntegerWidth() + 1 < minWindowWidth)
Window()->ResizeTo(minWindowWidth, Window()->Bounds().Height());
//.........这里部分代码省略.........
示例7: MessageReceived
void PrefsWindow::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case MSG_OK: { // "Start" button clicked
read_volumes_prefs();
read_memory_prefs();
read_graphics_prefs();
SavePrefs();
send_quit_on_close = false;
PostMessage(B_QUIT_REQUESTED);
be_app->PostMessage(ok_message);
break;
}
case MSG_CANCEL: // "Quit" button clicked
send_quit_on_close = false;
PostMessage(B_QUIT_REQUESTED);
be_app->PostMessage(B_QUIT_REQUESTED);
break;
case B_ABOUT_REQUESTED: { // "About" menu item selected
ShowAboutWindow();
break;
}
case MSG_ZAP_PRAM: // "Zap PRAM File" menu item selected
ZapPRAM();
break;
case MSG_VOLUME_INVOKED: { // Double-clicked on volume name, toggle read-only flag
int selected = volume_list->CurrentSelection();
if (selected >= 0) {
const char *str = PrefsFindString("disk", selected);
BStringItem *item = (BStringItem *)volume_list->RemoveItem(selected);
delete item;
char newstr[256];
if (str[0] == '*')
strcpy(newstr, str+1);
else {
strcpy(newstr, "*");
strcat(newstr, str);
}
PrefsReplaceString("disk", newstr, selected);
volume_list->AddItem(new BStringItem(newstr), selected);
volume_list->Select(selected);
}
break;
}
case MSG_ADD_VOLUME:
add_volume_panel->Show();
break;
case MSG_CREATE_VOLUME:
create_volume_panel->Show();
break;
case MSG_ADD_VOLUME_PANEL: {
entry_ref ref;
if (msg->FindRef("refs", &ref) == B_NO_ERROR) {
BEntry entry(&ref, true);
BPath path;
entry.GetPath(&path);
if (entry.IsFile()) {
PrefsAddString("disk", path.Path());
volume_list->AddItem(new BStringItem(path.Path()));
} else if (entry.IsDirectory()) {
BVolume volume;
if (path.Path()[0] == '/' && strchr(path.Path()+1, '/') == NULL && entry.GetVolume(&volume) == B_NO_ERROR) {
int32 i = 0;
dev_t d;
fs_info info;
while ((d = next_dev(&i)) >= 0) {
fs_stat_dev(d, &info);
if (volume.Device() == info.dev) {
PrefsAddString("disk", info.device_name);
volume_list->AddItem(new BStringItem(info.device_name));
}
}
}
}
}
break;
}
case MSG_CREATE_VOLUME_PANEL: {
entry_ref dir;
if (msg->FindRef("directory", &dir) == B_NO_ERROR) {
BEntry entry(&dir, true);
BPath path;
entry.GetPath(&path);
path.Append(msg->FindString("name"));
create_volume_panel->Window()->Lock();
BView *background = create_volume_panel->Window()->ChildAt(0);
NumberControl *v = (NumberControl *)background->FindView("hardfile_size");
int size = v->Value();
char cmd[1024];
sprintf(cmd, "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", path.Path(), size);
//.........这里部分代码省略.........
示例8: fnr
PrefsWindow::PrefsWindow(uint32 msg) : BWindow(BRect(0, 0, 400, 289), GetString(STR_PREFS_TITLE), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS), this_messenger(this)
{
int i;
ok_message = msg;
send_quit_on_close = true;
get_system_info(&sys_info);
// Move window to right position
Lock();
MoveTo(80, 80);
// Set up menus
BMenuBar *bar = new BMenuBar(Bounds(), "menu");
BMenu *menu = new BMenu(GetString(STR_PREFS_MENU));
menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_ABOUT), new BMessage(B_ABOUT_REQUESTED)));
menu->AddItem(new BSeparatorItem);
menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_START), new BMessage(MSG_OK)));
menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_ZAP_PRAM), new BMessage(MSG_ZAP_PRAM)));
menu->AddItem(new BSeparatorItem);
menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_QUIT), new BMessage(MSG_CANCEL), 'Q'));
bar->AddItem(menu);
AddChild(bar);
SetKeyMenuBar(bar);
int mbar_height = int(bar->Bounds().bottom) + 1;
// Resize window to fit menu bar
ResizeBy(0, mbar_height);
// Light gray background
BRect b = Bounds();
top = new BView(BRect(0, mbar_height, b.right, b.bottom), "top", B_FOLLOW_NONE, B_WILL_DRAW);
AddChild(top);
top->SetViewColor(fill_color);
top_frame = top->Bounds();
// Create panes
panes[0] = create_volumes_pane();
panes[1] = create_graphics_pane();
panes[2] = create_serial_pane();
panes[3] = create_memory_pane();
// Prefs item tab view
pane_tabs = new BTabView(BRect(10, 10, top_frame.right-10, top_frame.bottom-50), "items", B_WIDTH_FROM_LABEL);
for (i=0; i<NUM_PANES; i++)
pane_tabs->AddTab(panes[i]);
top->AddChild(pane_tabs);
volume_list->Select(0);
// Create volume file panels
add_volume_panel = new BFilePanel(B_OPEN_PANEL, &this_messenger, NULL, B_FILE_NODE | B_DIRECTORY_NODE, false, new BMessage(MSG_ADD_VOLUME_PANEL));
add_volume_panel->SetButtonLabel(B_DEFAULT_BUTTON, GetString(STR_ADD_VOLUME_PANEL_BUTTON));
add_volume_panel->Window()->SetTitle(GetString(STR_ADD_VOLUME_TITLE));
create_volume_panel = new BFilePanel(B_SAVE_PANEL, &this_messenger, NULL, B_FILE_NODE | B_DIRECTORY_NODE, false, new BMessage(MSG_CREATE_VOLUME_PANEL));
create_volume_panel->SetButtonLabel(B_DEFAULT_BUTTON, GetString(STR_CREATE_VOLUME_PANEL_BUTTON));
create_volume_panel->Window()->SetTitle(GetString(STR_CREATE_VOLUME_TITLE));
create_volume_panel->Window()->Lock();
BView *background = create_volume_panel->Window()->ChildAt(0);
background->FindView("PoseView")->ResizeBy(0, -30);
background->FindView("VScrollBar")->ResizeBy(0, -30);
background->FindView("CountVw")->MoveBy(0, -30);
BView *v = background->FindView("HScrollBar");
if (v)
v->MoveBy(0, -30);
else {
i = 0;
while ((v = background->ChildAt(i++)) != NULL) {
if (v->Name() == NULL || v->Name()[0] == 0) {
v->MoveBy(0, -30); // unnamed horizontal scroll bar
break;
}
}
}
BView *filename = background->FindView("text view");
BRect fnr(filename->Frame());
fnr.OffsetBy(0, -30);
NumberControl *nc = new NumberControl(fnr, 80, "hardfile_size", GetString(STR_HARDFILE_SIZE_CTRL), 40, NULL);
background->AddChild(nc);
create_volume_panel->Window()->Unlock();
// "Start" button
BButton *button = new BButton(BRect(20, top_frame.bottom-35, 90, top_frame.bottom-10), "start", GetString(STR_START_BUTTON), new BMessage(MSG_OK));
top->AddChild(button);
SetDefaultButton(button);
// "Quit" button
top->AddChild(new BButton(BRect(top_frame.right-90, top_frame.bottom-35, top_frame.right-20, top_frame.bottom-10), "cancel", GetString(STR_QUIT_BUTTON), new BMessage(MSG_CANCEL)));
Unlock();
Show();
}