本文整理汇总了C++中BView::MessageReceived方法的典型用法代码示例。如果您正苦于以下问题:C++ BView::MessageReceived方法的具体用法?C++ BView::MessageReceived怎么用?C++ BView::MessageReceived使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BView
的用法示例。
在下文中一共展示了BView::MessageReceived方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CurrentFocus
void
TeamWindow::DispatchMessage(BMessage* message, BHandler* handler)
{
// Handle function key shortcuts for stepping
switch (message->what) {
case B_KEY_DOWN:
if (fActiveThread != NULL && fTraceUpdateRunner == NULL) {
int32 key;
uint32 modifiers;
if (message->FindInt32("key", &key) == B_OK
&& message->FindInt32("modifiers", (int32*)&modifiers)
== B_OK) {
switch (key) {
case B_F5_KEY:
fListener->ThreadActionRequested(
fActiveThread->ID(), MSG_THREAD_RUN);
break;
case B_F10_KEY:
fListener->ThreadActionRequested(
fActiveThread->ID(), MSG_THREAD_STEP_OVER);
break;
case B_F11_KEY:
if ((modifiers & B_SHIFT_KEY) != 0) {
fListener->ThreadActionRequested(
fActiveThread->ID(), MSG_THREAD_STEP_OUT);
} else {
fListener->ThreadActionRequested(
fActiveThread->ID(), MSG_THREAD_STEP_INTO);
}
break;
default:
break;
}
}
}
break;
case B_COPY:
case B_SELECT_ALL:
BView* focusView = CurrentFocus();
if (focusView != NULL) {
focusView->MessageReceived(message);
return;
}
break;
}
BWindow::DispatchMessage(message, handler);
}
示例2: MessageReceived
/*! \brief Main function of the class.
* \param[in] in BMessage to respond to.
*/
void EventEditorMainWindow::MessageReceived( BMessage *in )
{
BView* view;
BEntry entry;
BFile file;
BString tempString;
BDirectory directory;
BMessage saveMessage( kSaveRequested );
entry_ref ref;
switch( in->what )
{
case B_SELECT_ALL:
case B_COPY:
case B_CUT:
case B_PASTE:
case B_UNDO:
view = CurrentFocus();
if ( view )
view->MessageReceived( in );
break;
case kFileOpen:
fOpenFile->Show();
break;
case kFileSaveAs:
fSaveFile->Show();
break;
case kFileRevert: // Intentional fall-through
case kFileOpenConfirmed:
if ( in->what == kFileRevert ) {
if ( fData.GetRef() != NULL )
{
// ...Prepare it for usage
ref = *( fData.GetRef() );
} else {
// Ask the user what to do
fOpenFile->Show();
break;
}
} else {
if ( B_OK != in->FindRef( "refs", &ref ) ||
B_OK != entry.SetTo( &ref, true ) ||
B_OK != entry.GetRef( &ref ) )
{
entry.Unset();
break;
}
}
fData.InitFromFile( ref );
if ( Looper()->Lock() ) {
// fData.Revert();
MainView->RemoveSelf();
delete MainView;
InitUI();
Looper()->Unlock();
}
entry.Unset();
break;
case kFileSave: // Intentional fall-through
case kFileSaveConfirmed:
// Save user's changes
if ( genView ) genView->MessageReceived( &saveMessage );
if ( remView ) remView->MessageReceived( &saveMessage );
if ( actView ) actView->SaveData();
if ( noteView ) noteView->SaveText();
fData.SetEventActivityFired( false );
fData.SetReminderActivityFired( false );
// If we have the reference to file...
if ( in->what == kFileSave ) {
if ( fData.GetRef() != NULL )
{
// ...Prepare it for usage
ref = *( fData.GetRef() );
} else {
// Ask the user what to do
fSaveFile->Show();
break;
}
} else {
if ( B_OK != in->FindRef( "directory", &ref ) ||
B_OK != in->FindString( "name", &tempString ) ||
B_OK != directory.SetTo( &ref ) ||
B_OK != directory.CreateFile( tempString.String(), NULL, false ) ||
B_OK != directory.FindEntry( tempString.String(), &entry, true ) ||
B_OK != entry.GetRef( &ref ) )
{
break;
}
//.........这里部分代码省略.........
示例3: volume
void
PersonWindow::MessageReceived(BMessage* msg)
{
msg->PrintToStream();
char str[256];
BDirectory directory;
BEntry entry;
BFile file;
// BNodeInfo *node;
switch (msg->what) {
case M_SAVE:
if (!fRef) {
SaveAs();
break;
}
// supposed to fall through
case M_REVERT:
case M_SELECT:
fView->MessageReceived(msg);
break;
case M_SAVE_AS:
int32 format;
if (msg->FindInt32("format", &format) == B_OK)
SaveAs(format);
break;
case M_ADD_FIELD:
case M_SHOW_LOCATIONS:
case M_SHOW_GROUPS:
fView->MessageReceived(msg);
break;
case B_UNDO: // fall through
case B_CUT:
case B_COPY:
case B_PASTE:
{
BView* view = CurrentFocus();
if (view != NULL)
view->MessageReceived(msg);
break;
}
case B_SAVE_REQUESTED:
{
entry_ref dir;
if (msg->FindRef("directory", &dir) == B_OK) {
const char* name = NULL;
msg->FindString("name", &name);
directory.SetTo(&dir);
if (directory.InitCheck() == B_NO_ERROR) {
directory.CreateFile(name, &file);
if (file.InitCheck() == B_NO_ERROR) {
int32 format;
if (msg->FindInt32("format", &format) == B_OK) {
directory.FindEntry(name, &entry);
entry.GetRef(&dir);
_SetToRef(new entry_ref(dir));
SetTitle(fRef->name);
fView->CreateFile(fRef, format);
}
}
else {
sprintf(str, B_TRANSLATE("Could not create %s."), name);
(new BAlert("", str, B_TRANSLATE("Sorry")))->Go();
}
}
}
break;
}
case B_CONTACT_REMOVED:
// We lost our file. Close the window.
PostMessage(B_QUIT_REQUESTED);
break;
case B_CONTACT_MOVED:
{
// We may have renamed our entry. Obtain relevant data
// from message.
BString name;
msg->FindString("name", &name);
int64 directory;
msg->FindInt64("to directory", &directory);
int32 device;
msg->FindInt32("device", &device);
// Update our file
fRef = new entry_ref(device,
directory, name.String());
fWatcher->SetRef(fRef);
fView->Reload(fRef);
// And our window title.
SetTitle(name);
// If moved to Trash, close window.
//.........这里部分代码省略.........
示例4: volume
void
PersonWindow::MessageReceived(BMessage* msg)
{
char str[256];
BDirectory directory;
BEntry entry;
BFile file;
BNodeInfo *node;
switch (msg->what) {
case M_SAVE:
if (!fRef) {
SaveAs();
break;
}
// supposed to fall through
case M_REVERT:
case M_SELECT:
fView->MessageReceived(msg);
break;
case M_SAVE_AS:
SaveAs();
break;
case B_UNDO: // fall through
case B_CUT:
case B_COPY:
case B_PASTE:
{
BView* view = CurrentFocus();
if (view != NULL)
view->MessageReceived(msg);
break;
}
case B_SAVE_REQUESTED:
{
entry_ref dir;
if (msg->FindRef("directory", &dir) == B_OK) {
const char* name = NULL;
msg->FindString("name", &name);
directory.SetTo(&dir);
if (directory.InitCheck() == B_NO_ERROR) {
directory.CreateFile(name, &file);
if (file.InitCheck() == B_NO_ERROR) {
node = new BNodeInfo(&file);
node->SetType("application/x-person");
delete node;
directory.FindEntry(name, &entry);
entry.GetRef(&dir);
_SetToRef(new entry_ref(dir));
SetTitle(fRef->name);
fView->CreateFile(fRef);
}
else {
sprintf(str, B_TRANSLATE("Could not create %s."), name);
BAlert* alert = new BAlert("", str, B_TRANSLATE("Sorry"));
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go();
}
}
}
break;
}
case B_NODE_MONITOR:
{
int32 opcode;
if (msg->FindInt32("opcode", &opcode) == B_OK) {
switch (opcode) {
case B_ENTRY_REMOVED:
// We lost our file. Close the window.
PostMessage(B_QUIT_REQUESTED);
break;
case B_ENTRY_MOVED:
{
// We may have renamed our entry. Obtain relevant data
// from message.
BString name;
msg->FindString("name", &name);
int64 directory;
msg->FindInt64("to directory", &directory);
int32 device;
msg->FindInt32("device", &device);
// Update our ref.
delete fRef;
fRef = new entry_ref(device, directory, name.String());
// And our window title.
SetTitle(name);
// If moved to Trash, close window.
BVolume volume(device);
BPath trash;
//.........这里部分代码省略.........
示例5: entry
void
AppWindow::MessageReceived(BMessage* message)
{
//PRINT(("AppWindow::MessageReceived(BMessage*)\n"));
switch(message->what)
{
case MSG_FILE_OPEN:
{
fOpenPanel->Show();
break;
}
case B_ABOUT_REQUESTED:
AboutRequested();
break;
case MSG_EDITOR_MODE:
m_app_view->SelectView(0);
break;
case MSG_TA_MODE:
m_app_view->SelectView(1);
break;
case MSG_NA_MODE:
m_app_view->SelectView(2);
break;
case MSG_MPEG_MODE:
m_app_view->SelectView(3);
break;
#ifdef _TTE_
case MSG_TT_INFO_MODE:
m_app_view->SelectView(4);
break;
#endif
case MSG_PREVIOUS_MODE:
m_app_view->SetPreviousMode();
break;
case MSG_NEXT_MODE:
m_app_view->SetNextMode();
break;
case MSG_RESET:
m_app_view->Reset();
break;
case MSG_CLEAR_LIST:
m_app_view->ClearList();
break;
case MSG_PREVIOUS_FILE:
m_app_view->SelectPreviousFile();
break;
case MSG_NEXT_FILE:
m_app_view->SelectNextFile();
break;
case MSG_FIRST_FILE:
m_app_view->SelectFirstFile();
break;
case MSG_LAST_FILE:
m_app_view->SelectLastFile();
break;
case B_REFS_RECEIVED:
m_app_view->MessageReceived(message);
break;
case MSG_MAKE_APPLY_BUTTON_DEFAULT:
m_app_view->m_apply_button->MakeDefault(true);
break;
case MSG_MAKE_APPLY_BUTTON_NOT_DEFAULT:
m_app_view->m_apply_button->MakeDefault(false);
break;
case MSG_EDIT_CUT:
{
message->what = B_CUT;
BView *view = CurrentFocus();
if (view)
view->MessageReceived(message);
}
break;
case MSG_EDIT_COPY:
{
message->what = B_COPY;
BView *view = CurrentFocus();
if (view)
view->MessageReceived(message);
}
break;
case MSG_EDIT_PASTE:
{
message->what = B_PASTE;
BView *view = CurrentFocus();
if (view)
view->MessageReceived(message);
}
break;
//.........这里部分代码省略.........