本文整理汇总了C++中BFilePanel类的典型用法代码示例。如果您正苦于以下问题:C++ BFilePanel类的具体用法?C++ BFilePanel怎么用?C++ BFilePanel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BFilePanel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MessageReceived
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);
}
}
示例2: switch
void ReloadedWin::MessageReceived(BMessage* mess)
{
int k;
int m;
switch(mess->what)
{
case B_KEY_DOWN:
case B_UNMAPPED_KEY_DOWN:
m = mess->FindInt32("modifiers");
k = mess->FindInt32("key");
REmulator::getInstance()->PressKey(k,m);
break;
case B_KEY_UP:
case B_UNMAPPED_KEY_UP:
m = mess->FindInt32("modifiers");
k = mess->FindInt32("key");
REmulator::getInstance()->ReleaseKey(k,m);
break;
case 'rfsh':
fBitmapView->Invalidate();
break;
case 'dins':
{
BFilePanel* f = new BFilePanel(B_OPEN_PANEL, &be_app_messenger,
NULL, B_FILE_NODE, false);
f->Show();
break;
}
case 'kymp':
{
KeymapWindow* kwin = new KeymapWindow();
kwin->Show();
break;
}
case 'fled':
{
// Draw FDC LED
bool status;
mess->FindBool("status", &status);
if (status)
fStatusLed->SetViewColor(0xFF,00,00);
else
fStatusLed->SetViewColor(0x77,00,00);
fStatusLed->Invalidate();
break;
}
default:
BWindow::MessageReceived(mess);
break;
}
}
示例3: getMountFolder
// getMountFolder()
//
void getMountFolder()
{
char path[B_PATH_NAME_LENGTH];
entry_ref entryRef;
find_directory(B_USER_DIRECTORY, 0, false, path, sizeof(path));
BEntry entry(path, false);
entry.GetRef(&entryRef);
BFilePanel *filePanel = new BFilePanel(B_OPEN_PANEL, &be_app_messenger, &entryRef, B_DIRECTORY_NODE, false);
filePanel->Show();
filePanel->Window()->SetTitle("Mount Location");
filePanel->SetButtonLabel(B_DEFAULT_BUTTON, "Mount");
}
示例4: message
BFilePanel *
CDocument::CreateSavePanel()
{
BMessage message(B_SAVE_REQUESTED);
message.AddPointer("Document", this);
// Create a new save panel
BMessenger messenger(NULL, MasterWindow());
BFilePanel *panel = new BFilePanel(B_SAVE_PANEL, &messenger,
NULL, B_FILE_NODE, false, &message);
// Set the save panel to point to the directory from where we loaded.
BEntry entry;
if (m_entry.GetParent(&entry) == B_NO_ERROR)
{
panel->SetPanelDirectory(&entry);
}
return panel;
}
示例5: msg
void
ServerWindow::DCCGetDialog (
BString nick,
BString file,
BString size,
BString ip,
BString port)
{
BMessage msg (DCC_ACCEPT), reply;
msg.AddString ("bowser:nick", nick.String());
msg.AddString ("bowser:file", file.String());
msg.AddString ("bowser:size", size.String());
msg.AddString ("bowser:ip", ip.String());
msg.AddString ("bowser:port", port.String());
//bool handled (false);
// ignore this part until some minor details with DCC Prefs are worked out
/*
const char *directory = "/boot/home/";
entry_ref ref;
BEntry entry;
create_directory (directory, 0777);
if (entry.SetTo (directory) == B_NO_ERROR
if (entry.GetRef (&ref) == B_NO_ERROR)
{
BDirectory dir (&ref);
BEntry file_entry;
struct stat s;
if (file_entry.SetTo (&dir, file.String()) == B_NO_ERROR
&& file_entry.GetStat (&s) == B_NO_ERROR
&& S_ISREG (s.st_mode))
{
BString buffer;
BAlert *alert;
int32 which;
buffer << "The file \""
<< file
<< "\" already exists in the specified folder. "
"Do you want to continue the transfer?";
alert = new BAlert (
"DCC Request",
buffer.String(),
"Refuse",
"Get",
"Resume",
B_WIDTH_AS_USUAL,
B_OFFSET_SPACING,
B_WARNING_ALERT);
which = alert->Go();
if (which == 0)
{
return;
}
if (which == 2)
{
BFile file (&file_entry, B_READ_ONLY);
off_t position;
BPath path;
file.GetSize (&position);
file_entry.GetPath (&path);
msg.AddString ("path", path.Path());
msg.AddInt64 ("pos", position);
AddResumeData (&msg);
return;
}
}
msg.AddRef ("directory", &ref);
msg.AddString ("name", file);
sMsgr.SendMessage (&msg);
handled = true;
}
}
*/
BFilePanel *panel;
BString text;
text << nick
<< ": "
<< file
<< " ("
<< size
<< " bytes)";
panel = new BFilePanel (
B_SAVE_PANEL,
&sMsgr,
0,
//.........这里部分代码省略.........
示例6: BFilePanel
/*
open a file panel and ask for a PDF file
the file panel will tell by itself if openning have been cancelled
or not.
*/
void BepdfApplication::OpenSaveFilePanel(BHandler* handler, bool fileMode, BRefFilter* filter, BMessage* msg, const char* name) {
BFilePanel* panel = NULL;
// lazy construct file panel
if (fileMode) {
// file panel for selection of file
if (mSaveFilePanel == NULL) {
mSaveFilePanel = new BFilePanel (B_SAVE_PANEL,
NULL, NULL, B_FILE_NODE, false, NULL, NULL, true);
}
// hide other file panel
if (mSaveToDirectoryFilePanel != NULL && mSaveToDirectoryFilePanel->IsShowing()) {
mSaveToDirectoryFilePanel->Hide();
}
panel = mSaveFilePanel;
} else {
// file panel for selection of directory
if (mSaveToDirectoryFilePanel == NULL) {
mSaveToDirectoryFilePanel = new BFilePanel (B_OPEN_PANEL,
NULL, NULL, B_DIRECTORY_NODE, false, NULL, NULL, true);
}
// hide other file panel
if (mSaveFilePanel != NULL && mSaveFilePanel->IsShowing()) {
mSaveFilePanel->Hide();
}
panel = mSaveToDirectoryFilePanel;
}
// (re)-set to directory of currently opened PDF file
// TODO decide if directory should be independent from PDF file
panel->SetPanelDirectory(mSettings->GetPanelDirectory());
if (name != NULL) {
panel->SetSaveText(name);
}
else if (fileMode) {
panel->SetSaveText("");
}
// set/reset filter
panel->SetRefFilter(filter);
// add kind to message
BMessage message(B_SAVE_REQUESTED);
if (msg == NULL) {
msg = &message;
}
panel->SetMessage(msg);
// set target
BMessenger msgr(handler);
panel->SetTarget(msgr);
panel->Refresh();
panel->Show();
}
示例7: filerequester
SDL_bool filerequester( struct machine *oric, char *title, char *path, char *fname, int type )
{
BFilePanel *panel;
PanelLooper *looper = new PanelLooper();
looper->Run();
SDL_bool ret;
char *pat;
bool dosavemode = false;
switch( type )
{
case FR_DISKSAVE:
dosavemode = true;
case FR_DISKLOAD:
pat = "*.dsk";
break;
// FIXME: Save TAP should be *.tap, save ORT should be *.ort, Load should be *.tap, *.ort, *.wav
case FR_TAPESAVETAP:
case FR_TAPESAVEORT:
dosavemode = true;
case FR_TAPELOAD:
pat = "*.tap";
break;
case FR_ROMS:
pat = "*.rom";
break;
case FR_SNAPSHOTSAVE:
dosavemode = true;
case FR_SNAPSHOTLOAD:
pat = "*.sna";
break;
case FR_KEYMAPPINGSAVE:
dosavemode = true;
case FR_KEYMAPPINGLOAD:
pat = "*.kma";
break;
default:
pat = NULL;
break;
}
//XXX: use RefFilter
panel = new BFilePanel(dosavemode ? B_SAVE_PANEL : B_OPEN_PANEL);
panel->SetTarget(BMessenger(looper));
if (path)
panel->SetPanelDirectory(path);
panel->Show();
looper->Wait();
ret = looper->DoIt();
entry_ref ref;
looper->GetRef(ref);
delete panel;
looper->Lock();
looper->Quit();
if (ret) {
BPath p(&ref);
strncpy( fname, p.Leaf(), 512 ); path[511] = 0;
p.GetParent(&p);
strncpy( path, p.Path(), 4096 ); path[4095] = 0;
}
return ret;
}
示例8: BFilePanel
void MainWindowController::ShowOpenFileDialog()
{
BFilePanel* filePanel = new BFilePanel(B_OPEN_PANEL, &_windowMessenger, NULL, B_DIRECTORY_NODE);
filePanel->Show();
}
示例9: create_sem
BEntry *YabFilePanel::MyFilePanel(const char *name, const char *directory, const char* filename, int mode)
{
BEntry *myEntry = NULL;
entry_ref ref;
sem_id semaphore = create_sem(0, "yabfilepanel");
YabFilePanelLooper *myLooper = new YabFilePanelLooper(semaphore);
myLooper->Run();
if(directory)
{
myEntry=new BEntry(directory);
if(myEntry->GetRef(&ref)!=B_OK)
{
myEntry->Unset();
myEntry->SetTo("/boot/home/");
myEntry->GetRef(&ref);
}
myEntry->Unset();
delete myEntry;
}
BFilePanel *myFilePanel = NULL;
switch(mode)
{
case 0:
myFilePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(myLooper, myLooper), &ref, B_FILE_NODE, false, NULL, NULL, true, true);
break;
case 1:
myFilePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(myLooper, myLooper), &ref, B_FILE_NODE, false, NULL, NULL, true, true);
if (filename) myFilePanel->SetSaveText(filename);
break;
case 2:
myFilePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(myLooper, myLooper), &ref, B_DIRECTORY_NODE, false, NULL, NULL, true, true);
break;
case 3:
myFilePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(myLooper, myLooper), &ref, B_FILE_NODE|B_DIRECTORY_NODE, false, NULL, NULL, true, true);
break;
}
if(name) myFilePanel->Window()->SetTitle(name);
myFilePanel->Show();
bool inloop = true;
while(inloop)
{
while(acquire_sem_etc(semaphore, 1, B_RELATIVE_TIMEOUT, 10000)==B_TIMED_OUT) ;
myEntry = myLooper->GetChosenFile();
inloop = false;
/*
if(mode!=2)
inloop = false;
else
{
if(myEntry->IsDirectory())
inloop = false;
else
{
myFilePanel->Show();
}
}
*/
}
myLooper->Lock();
myLooper->Quit();
delete_sem(semaphore);
delete myFilePanel;
return myEntry;
}
示例10: switch
void
OutputView::MessageReceived(BMessage *message)
{
switch (message->what) {
case kOpenFilePanel:
{
BMessenger target(this);
BFilePanel* filePanel = new BFilePanel(B_SAVE_PANEL,
&target, NULL, 0, false, NULL);
filePanel->Show();
break;
}
case kCheckBoxAreaSelectionChanged:
{
BRect rect = fCustomCaptureRect;
if (fWholeScreen->Value() == B_CONTROL_ON) {
rect = BScreen().Frame();
fSelectArea->SetEnabled(false);
} else {
fSelectArea->SetEnabled(true);
if (fCustomArea->Value() == B_CONTROL_ON) {
fSelectArea->SetLabel("Select Region");
fSelectArea->SetMessage(new BMessage(kSelectArea));
} else if (fWindow->Value() == B_CONTROL_ON) {
fSelectArea->SetLabel("Select Window");
fSelectArea->SetMessage(new BMessage(kSelectWindow));
}
}
fController->SetCaptureArea(rect);
break;
}
case kFileNameChanged:
fController->SetOutputFileName(fFileName->Text());
break;
case kMinimizeOnRecording:
Settings().SetMinimizeOnRecording(fMinimizeOnStart->Value() == B_CONTROL_ON);
break;
case kScaleChanged:
{
int32 value;
message->FindInt32("be:value", &value);
fController->SetScale((float)value);
break;
}
case B_OBSERVER_NOTICE_CHANGE:
{
int32 code;
message->FindInt32("be:observe_change_what", &code);
switch (code) {
case kMsgControllerSourceFrameChanged:
{
BRect rect;
if (message->FindRect("frame", &rect) == B_OK) {
if (rect != BScreen().Frame())
fCustomCaptureRect = rect;
}
_UpdatePreview(&rect);
break;
}
case kMsgControllerSelectionWindowClosed:
{
BRect rect;
BBitmap* bitmap = NULL;
if (message != NULL && message->FindRect("selection", &rect) == B_OK
&& message->FindPointer("bitmap", (void**)&bitmap) == B_OK) {
_UpdatePreview(&rect, bitmap);
delete bitmap;
}
break;
}
case kMsgControllerMediaFileFormatChanged:
_SetFileNameExtension(fController->MediaFileFormat().file_extension);
fController->SetOutputFileName(fFileName->Text());
break;
default:
break;
}
break;
}
case B_SAVE_REQUESTED:
{
entry_ref ref;
const char* name = NULL;
message->FindRef("directory", &ref);
message->FindString("name", &name);
BPath path(&ref);
path.Append(name);
fFileName->SetText(path.Path());
BFilePanel* filePanel = NULL;
if (message->FindPointer("source", (void**)&filePanel) == B_OK)
delete filePanel;
//.........这里部分代码省略.........
示例11: RunPopUpMenu
//.........这里部分代码省略.........
*/
}
}
// comment start
header.ReplaceAll("%COMMS%", commentBlockStart.String());
// comment cont'd
header.ReplaceAll("%COMMC%", commentBlockCont.String());
// comment cont'd lazy (blank if possible)
header.ReplaceAll("%COMML%", commentBlockLazy.String());
// comment end
header.ReplaceAll("%COMME%", commentBlockEnd.String());
// comment line end
commentBlockLineEnd << "\n";
header.ReplaceAll("\n", commentBlockLineEnd.String());
err = B_OK;
break;
}
case 'optf':
{
const char *args[] = {path.Path(), NULL};
err = be_roster->Launch(sTrackerSig, 1, (char **)args);
//printf("err %s\n", strerror(err));
err = B_CANCELED;
break;
}
case 'seta':
{
MimeRefFilter filter("application/x-person");
BPath path;
entry_ref people;
if (find_directory(B_USER_DIRECTORY, &path) == B_OK)
{
path.Append("people");
get_ref_for_path(path.Path(), &people);
}
BFilePanel *panel;
panel = new BFilePanel(B_OPEN_PANEL, NULL, &people,
B_FILE_NODE, false, NULL, &filter);
// trick to synchronously use BFilePanel
PanelHandler *handler = new PanelHandler;
if (panel->Window()->Lock())
{
panel->Window()->AddHandler(handler);
panel->Window()->Unlock();
}
panel->SetTarget(BMessenger(handler));
panel->Show();
if (handler->Wait() < B_OK)
break;
if (!handler->Message())
break;
if (handler->Message()->what == B_CANCEL)
break;
entry_ref ref;
//panel->Message()->PrintToStream();
if (panel->GetNextSelectedRef(&ref) == B_OK)
{
//printf("ref:%s\n", ref.name);
path.SetTo(&ref);
dir.WriteAttr("pe:author_people", B_STRING_TYPE, 0LL,
path.Path(), strlen(path.Path()));
}
delete panel;
delete handler;
err = B_CANCELED;
break;
}
case B_ABOUT_REQUESTED:
{
BString tmpPath("/tmp/Pe-HeaderHeader-About-");
tmpPath << system_time() << "-" << getpid() << ".txt";
entry_ref ref;
get_ref_for_path(tmpPath.String(), &ref);
{
BFile f(&ref, B_CREATE_FILE | B_WRITE_ONLY);
err = f.InitCheck();
if (err < 0)
break;
f.Write(sAboutText, strlen(sAboutText));
f.SetPermissions(0444);
}
BMessage msg(B_REFS_RECEIVED);
msg.AddRef("refs", &ref);
err = be_app_messenger.SendMessage(&msg);
err = B_CANCELED;
break;
}
case 0:
err = B_CANCELED;
break;
default:
break;
}
delete menu;
return err;
}
示例12: result
filter_result
DCCFileFilter::HandleButton (BMessage *)
{
filter_result result (B_DISPATCH_MESSAGE);
BTextControl *paneltext (dynamic_cast<BTextControl *>(
panel->Window()->FindView ("text view")));
if (paneltext)
{
BDirectory dir;
struct stat s;
entry_ref ref;
BEntry entry;
panel->GetPanelDirectory (&ref);
dir.SetTo (&ref);
if (entry.SetTo (&dir, paneltext->Text()) == B_NO_ERROR
&& entry.GetStat (&s) == B_NO_ERROR
&& S_ISREG (s.st_mode))
{
if (vision_app->GetBool ("dccAutoAccept"))
{
BMessage msg (M_FILE_PANEL_ALERT);
msg.AddInt32 ("which", 2);
panel->Window()->PostMessage (&msg);
result = B_SKIP_MESSAGE;
}
else
{
BString buffer;
BAlert *alert;
buffer << "The file \""
<< paneltext->Text()
<< "\" already exists in the specified folder. "
"Do you want to continue the transfer?";
alert = new BAlert (
"DCC Request",
buffer.String(),
"Cancel",
"Replace",
"Resume",
B_WIDTH_AS_USUAL,
B_OFFSET_SPACING,
B_WARNING_ALERT);
alert->Go (new BInvoker (
new BMessage (M_FILE_PANEL_ALERT),
panel->Window()));
result = B_SKIP_MESSAGE;
}
}
}
return result;
}
示例13: dir
filter_result
DCCFileFilter::HandleAlert (BMessage *msg)
{
BTextControl *text (dynamic_cast<BTextControl *>(
panel->Window()->FindView ("text view")));
int32 which;
msg->FindInt32 ("which", &which);
if (which == 0 || text == 0)
{
return B_SKIP_MESSAGE;
}
entry_ref ref;
panel->GetPanelDirectory (&ref);
if (which == 2)
{
BDirectory dir (&ref);
BFile file (&dir, text->Text(), B_READ_ONLY);
BEntry entry (&dir, text->Text());
BPath path;
off_t position;
file.GetSize (&position);
entry.GetPath (&path);
send_msg.AddString ("path", path.Path());
send_msg.AddInt64 ("pos", position);
send_msg.what = M_ADD_RESUME_DATA;
}
else
{
send_msg.AddRef ("directory", &ref);
send_msg.AddString ("name", text->Text());
}
panel->Messenger().SendMessage (&send_msg);
BMessage cmsg (B_CANCEL);
cmsg.AddPointer ("source", panel);
panel->Messenger().SendMessage (&cmsg);
return B_SKIP_MESSAGE;
}
示例14:
void
PackageInstaller::ReadyToRun()
{
// We're ready to run - if no windows are yet visible, this means that
// we should show a open panel
if (fWindowCount == 0)
fOpenPanel->Show();
}
示例15: OpenWindow
void
DiskProbe::MessageReceived(BMessage* message)
{
switch (message->what) {
case kMsgOpenOpenWindow:
if (fOpenWindow == NULL) {
fOpenWindow = new OpenWindow();
fOpenWindow->Show();
fWindowCount++;
} else
fOpenWindow->Activate(true);
break;
case kMsgOpenWindowClosed:
fOpenWindow = NULL;
// supposed to fall through
case kMsgWindowClosed:
if (--fWindowCount == 0 && !fFilePanel->IsShowing())
PostMessage(B_QUIT_REQUESTED);
break;
case kMsgSettingsChanged:
fSettings.UpdateFrom(message);
break;
case kMsgFindWindowClosed:
fFindWindow = NULL;
break;
case kMsgFindTarget:
{
BMessenger target;
if (message->FindMessenger("target", &target) != B_OK)
break;
if (fFindWindow != NULL && fFindWindow->Lock()) {
fFindWindow->SetTarget(target);
fFindWindow->Unlock();
}
break;
}
case kMsgOpenFindWindow:
{
BMessenger target;
if (message->FindMessenger("target", &target) != B_OK)
break;
if (fFindWindow == NULL) {
// open it!
fFindWindow = new FindWindow(fWindowFrame.OffsetByCopy(80, 80),
*message, target, &fSettings.Message());
fFindWindow->Show();
} else
fFindWindow->Activate();
break;
}
case kMsgOpenFilePanel:
fFilePanel->Show();
break;
case B_CANCEL:
if (fWindowCount == 0)
PostMessage(B_QUIT_REQUESTED);
break;
default:
BApplication::MessageReceived(message);
break;
}
}