| 97 | |
| 98 | static void CallOpenFileCallback(const char* path); |
| 99 | void CC_BApp::DispatchMessage(BMessage* msg, BHandler* handler) { |
| 100 | CCEvent event = { 0 }; |
| 101 | const char* filename; |
| 102 | entry_ref fileRef; |
| 103 | |
| 104 | switch (msg->what) |
| 105 | { |
| 106 | case B_QUIT_REQUESTED: |
| 107 | Platform_LogConst("APP QUIT"); |
| 108 | event.type = CC_WIN_QUIT; |
| 109 | break; |
| 110 | case B_REFS_RECEIVED: |
| 111 | // TODO do we need to support more than 1 ref? |
| 112 | if (msg->FindRef("refs", 0, &fileRef) == B_OK) { |
| 113 | BPath path(&fileRef); |
| 114 | CallOpenFileCallback(path.Path()); |
| 115 | } |
| 116 | break; |
| 117 | case B_SAVE_REQUESTED: |
| 118 | // TODO do we need to support more than 1 ref? |
| 119 | if (msg->FindRef("directory", 0, &fileRef) == B_OK && |
| 120 | msg->FindString("name", &filename) == B_OK) { |
| 121 | BDirectory folder(&fileRef); |
| 122 | BPath path(&folder, filename); |
| 123 | // TODO add default file extension |
| 124 | CallOpenFileCallback(path.Path()); |
| 125 | } |
| 126 | break; |
| 127 | default: |
| 128 | //Platform_LogConst("UNHANDLED APP MESSAGE:"); |
| 129 | //msg->PrintToStream(); |
| 130 | break; |
| 131 | } |
| 132 | if (event.type) Events_Push(&event); |
| 133 | BApplication::DispatchMessage(msg, handler); |
| 134 | } |
| 135 | |
| 136 | // BWindow implementation |
| 137 | class CC_BWindow : public BWindow |
nothing calls this directly
no test coverage detected