1 /* 2 * Copyright (c) 2004-2007 Marcus Overhagen <marcus@overhagen.de> 3 * 4 * Permission is hereby granted, free of charge, to any person 5 * obtaining a copy of this software and associated documentation 6 * files (the "Software"), to deal in the Software without restriction, 7 * including without limitation the rights to use, copy, modify, 8 * merge, publish, distribute, sublicense, and/or sell copies of 9 * the Software, and to permit persons to whom the Software is 10 * furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be 13 * included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 * OTHER DEALINGS IN THE SOFTWARE. 23 */ 24 25 #include "MainWin.h" 26 #include "MainApp.h" 27 #include "Controller.h" 28 #include "config.h" 29 #include "DeviceRoster.h" 30 31 #include <stdio.h> 32 #include <string.h> 33 34 #include <Application.h> 35 #include <Alert.h> 36 #include <Menu.h> 37 #include <MenuBar.h> 38 #include <MenuItem.h> 39 #include <Messenger.h> 40 #include <PopUpMenu.h> 41 #include <Screen.h> 42 #include <String.h> 43 #include <View.h> 44 45 46 #undef B_TRANSLATE_CONTEXT 47 #define B_TRANSLATE_CONTEXT "MainWin" 48 49 static const char* fLocalizedName = B_TRANSLATE_MARK("TV"); 50 static const char* fLocalizedRevision = B_TRANSLATE_MARK("unknown"); 51 static const char* fLocalizedInfo1 = B_TRANSLATE_MARK("DVB - Digital Video Broadcasting TV"); 52 53 enum 54 { 55 M_DUMMY = 0x100, 56 M_FILE_QUIT, 57 M_SCALE_TO_NATIVE_SIZE, 58 M_TOGGLE_FULLSCREEN, 59 M_TOGGLE_NO_BORDER, 60 M_TOGGLE_NO_MENU, 61 M_TOGGLE_NO_BORDER_NO_MENU, 62 M_TOGGLE_ALWAYS_ON_TOP, 63 M_TOGGLE_KEEP_ASPECT_RATIO, 64 M_PREFERENCES, 65 M_CHANNEL_NEXT, 66 M_CHANNEL_PREV, 67 M_VOLUME_UP, 68 M_VOLUME_DOWN, 69 M_ASPECT_100000_1, 70 M_ASPECT_106666_1, 71 M_ASPECT_109091_1, 72 M_ASPECT_141176_1, 73 M_ASPECT_720_576, 74 M_ASPECT_704_576, 75 M_ASPECT_544_576, 76 M_SELECT_INTERFACE = 0x00000800, 77 M_SELECT_INTERFACE_END = 0x00000fff, 78 M_SELECT_CHANNEL = 0x00010000, 79 M_SELECT_CHANNEL_END = 0x000fffff, 80 // this limits possible channel count to 0xeffff = 983039 81 }; 82 83 //#define printf(a...) 84 85 86 MainWin::MainWin(BRect frame_rect) 87 : 88 BWindow(frame_rect, B_TRANSLATE_SYSTEM_NAME(NAME), B_TITLED_WINDOW, 89 B_ASYNCHRONOUS_CONTROLS /* | B_WILL_ACCEPT_FIRST_CLICK */) 90 , fController(new Controller) 91 , fIsFullscreen(false) 92 , fKeepAspectRatio(true) 93 , fAlwaysOnTop(false) 94 , fNoMenu(false) 95 , fNoBorder(false) 96 , fSourceWidth(720) 97 , fSourceHeight(576) 98 , fWidthScale(1.0) 99 , fHeightScale(1.0) 100 , fMouseDownTracking(false) 101 , fFrameResizedTriggeredAutomatically(false) 102 , fIgnoreFrameResized(false) 103 , fFrameResizedCalled(true) 104 { 105 BRect rect = Bounds(); 106 107 // background 108 fBackground = new BView(rect, "background", B_FOLLOW_ALL, 109 B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE); 110 fBackground->SetViewColor(0,0,0); 111 AddChild(fBackground); 112 113 // menu 114 fMenuBar = new BMenuBar(fBackground->Bounds(), "menu"); 115 CreateMenu(); 116 fBackground->AddChild(fMenuBar); 117 fMenuBar->ResizeToPreferred(); 118 fMenuBarHeight = (int)fMenuBar->Frame().Height() + 1; 119 fMenuBar->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT); 120 121 // video view 122 BRect video_rect = BRect(0, fMenuBarHeight, rect.right, rect.bottom); 123 fVideoView = new VideoView(video_rect, "video display", B_FOLLOW_ALL, 124 B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE); 125 fBackground->AddChild(fVideoView); 126 127 fVideoView->MakeFocus(); 128 129 // SetSizeLimits(fControlViewMinWidth - 1, 32767, 130 // fMenuBarHeight + fControlViewHeight - 1, fMenuBarHeight 131 // + fControlViewHeight - 1); 132 133 // SetSizeLimits(320 - 1, 32767, 240 + fMenuBarHeight - 1, 32767); 134 135 SetSizeLimits(0, 32767, fMenuBarHeight - 1, 32767); 136 137 fController->SetVideoView(fVideoView); 138 fController->SetVideoNode(fVideoView->Node()); 139 140 fVideoView->IsOverlaySupported(); 141 142 SetupInterfaceMenu(); 143 SelectInitialInterface(); 144 SetInterfaceMenuMarker(); 145 SetupChannelMenu(); 146 SetChannelMenuMarker(); 147 148 VideoFormatChange(fSourceWidth, fSourceHeight, fWidthScale, fHeightScale); 149 150 CenterOnScreen(); 151 } 152 153 154 MainWin::~MainWin() 155 { 156 printf("MainWin::~MainWin\n"); 157 fController->DisconnectInterface(); 158 delete fController; 159 } 160 161 162 void 163 MainWin::CreateMenu() 164 { 165 fFileMenu = new BMenu(B_TRANSLATE(NAME)); 166 fChannelMenu = new BMenu(B_TRANSLATE("Channel")); 167 fInterfaceMenu = new BMenu(B_TRANSLATE("Interface")); 168 fSettingsMenu = new BMenu(B_TRANSLATE("Settings")); 169 fDebugMenu = new BMenu(B_TRANSLATE("Debug")); 170 171 fMenuBar->AddItem(fFileMenu); 172 fMenuBar->AddItem(fChannelMenu); 173 fMenuBar->AddItem(fInterfaceMenu); 174 fMenuBar->AddItem(fSettingsMenu); 175 fMenuBar->AddItem(fDebugMenu); 176 177 fFileMenu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), 178 new BMessage(M_FILE_QUIT), 'Q', B_COMMAND_KEY)); 179 180 /* 181 fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Next channel"), 182 new BMessage(M_CHANNEL_NEXT), '+', B_COMMAND_KEY)); 183 fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Previous channel"), 184 new BMessage(M_CHANNEL_PREV), '-', B_COMMAND_KEY)); 185 fChannelMenu->AddSeparatorItem(); 186 fChannelMenu->AddItem(new BMenuItem("RTL", new BMessage(M_DUMMY), '0', 187 B_COMMAND_KEY)); 188 fChannelMenu->AddItem(new BMenuItem("Pro7", new BMessage(M_DUMMY), '1', 189 B_COMMAND_KEY)); 190 191 fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none"), 192 new BMessage(M_DUMMY))); 193 fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none 1"), 194 new BMessage(M_DUMMY))); 195 fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none 2"), 196 new BMessage(M_DUMMY))); 197 */ 198 199 fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Scale to native size"), 200 new BMessage(M_SCALE_TO_NATIVE_SIZE), 'N', B_COMMAND_KEY)); 201 fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Full screen"), 202 new BMessage(M_TOGGLE_FULLSCREEN), 'F', B_COMMAND_KEY)); 203 fSettingsMenu->AddSeparatorItem(); 204 fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("No menu"), 205 new BMessage(M_TOGGLE_NO_MENU), 'M', B_COMMAND_KEY)); 206 fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("No border"), 207 new BMessage(M_TOGGLE_NO_BORDER), 'B', B_COMMAND_KEY)); 208 fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Always on top"), 209 new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T', B_COMMAND_KEY)); 210 fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Keep aspect ratio"), 211 new BMessage(M_TOGGLE_KEEP_ASPECT_RATIO), 'K', B_COMMAND_KEY)); 212 fSettingsMenu->AddSeparatorItem(); 213 fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Settings"B_UTF8_ELLIPSIS) 214 , new BMessage(M_PREFERENCES), 'P', B_COMMAND_KEY)); 215 216 const char* pixel_ratio = B_TRANSLATE("pixel aspect ratio"); 217 BString str1 = pixel_ratio; 218 str1 << " 1.00000:1"; 219 fDebugMenu->AddItem(new BMenuItem(str1.String(), 220 new BMessage(M_ASPECT_100000_1))); 221 BString str2 = pixel_ratio; 222 str2 << " 1.06666:1"; 223 fDebugMenu->AddItem(new BMenuItem(str2.String(), 224 new BMessage(M_ASPECT_106666_1))); 225 BString str3 = pixel_ratio; 226 str3 << " 1.09091:1"; 227 fDebugMenu->AddItem(new BMenuItem(str3.String(), 228 new BMessage(M_ASPECT_109091_1))); 229 BString str4 = pixel_ratio; 230 str4 << " 1.41176:1"; 231 fDebugMenu->AddItem(new BMenuItem(str4.String(), 232 new BMessage(M_ASPECT_141176_1))); 233 fDebugMenu->AddItem(new BMenuItem(B_TRANSLATE( 234 "force 720 x 576, display aspect 4:3"), 235 new BMessage(M_ASPECT_720_576))); 236 fDebugMenu->AddItem(new BMenuItem(B_TRANSLATE( 237 "force 704 x 576, display aspect 4:3"), 238 new BMessage(M_ASPECT_704_576))); 239 fDebugMenu->AddItem(new BMenuItem(B_TRANSLATE( 240 "force 544 x 576, display aspect 4:3"), 241 new BMessage(M_ASPECT_544_576))); 242 243 fSettingsMenu->ItemAt(1)->SetMarked(fIsFullscreen); 244 fSettingsMenu->ItemAt(3)->SetMarked(fNoMenu); 245 fSettingsMenu->ItemAt(4)->SetMarked(fNoBorder); 246 fSettingsMenu->ItemAt(5)->SetMarked(fAlwaysOnTop); 247 fSettingsMenu->ItemAt(6)->SetMarked(fKeepAspectRatio); 248 fSettingsMenu->ItemAt(8)->SetEnabled(false); 249 // XXX disable unused preference menu 250 } 251 252 253 void 254 MainWin::SetupInterfaceMenu() 255 { 256 fInterfaceMenu->RemoveItems(0, fInterfaceMenu->CountItems(), true); 257 258 fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("None"), 259 new BMessage(M_SELECT_INTERFACE))); 260 261 int count = gDeviceRoster->DeviceCount(); 262 263 if (count > 0) 264 fInterfaceMenu->AddSeparatorItem(); 265 266 for (int i = 0; i < count; i++) { 267 // 1 gets subtracted in MessageReceived, so -1 is Interface None, 268 // and 0 == Interface 0 in SelectInterface() 269 fInterfaceMenu->AddItem(new BMenuItem(gDeviceRoster->DeviceName(i), 270 new BMessage(M_SELECT_INTERFACE + i + 1))); 271 } 272 } 273 274 275 void 276 MainWin::SetupChannelMenu() 277 { 278 fChannelMenu->RemoveItems(0, fChannelMenu->CountItems(), true); 279 280 int interface = fController->CurrentInterface(); 281 printf("MainWin::SetupChannelMenu: interface %d\n", interface); 282 283 int channels = fController->ChannelCount(); 284 285 if (channels == 0) { 286 fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("None"), 287 new BMessage(M_DUMMY))); 288 } else { 289 fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Next channel"), 290 new BMessage(M_CHANNEL_NEXT), '+', B_COMMAND_KEY)); 291 fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Previous channel"), 292 new BMessage(M_CHANNEL_PREV), '-', B_COMMAND_KEY)); 293 fChannelMenu->AddSeparatorItem(); 294 } 295 296 for (int i = 0; i < channels; i++) { 297 BString string; 298 string.SetToFormat("%s%d %s", (i < 9) ? " " : "", i + 1, 299 fController->ChannelName(i)); 300 fChannelMenu->AddItem(new BMenuItem(string, 301 new BMessage(M_SELECT_CHANNEL + i))); 302 } 303 } 304 305 306 void 307 MainWin::SetInterfaceMenuMarker() 308 { 309 BMenuItem *item; 310 311 int interface = fController->CurrentInterface(); 312 printf("MainWin::SetInterfaceMenuMarker: interface %d\n", interface); 313 314 // remove old marker 315 item = fInterfaceMenu->FindMarked(); 316 if (item) 317 item->SetMarked(false); 318 319 // set new marker 320 int index = (interface < 0) ? 0 : interface + 2; 321 item = fInterfaceMenu->ItemAt(index); 322 if (item) 323 item->SetMarked(true); 324 } 325 326 327 void 328 MainWin::SetChannelMenuMarker() 329 { 330 BMenuItem *item; 331 332 int channel = fController->CurrentChannel(); 333 printf("MainWin::SetChannelMenuMarker: channel %d\n", channel); 334 335 // remove old marker 336 item = fChannelMenu->FindMarked(); 337 if (item) 338 item->SetMarked(false); 339 340 // set new marker 341 int index = (channel < 0) ? 0 : channel + 3; 342 item = fChannelMenu->ItemAt(index); 343 if (item) 344 item->SetMarked(true); 345 } 346 347 348 void 349 MainWin::SelectChannel(int i) 350 { 351 printf("MainWin::SelectChannel %d\n", i); 352 353 if (B_OK != fController->SelectChannel(i)) 354 return; 355 356 SetChannelMenuMarker(); 357 } 358 359 360 void 361 MainWin::SelectInterface(int i) 362 { 363 printf("MainWin::SelectInterface %d\n", i); 364 printf(" CurrentInterface %d\n", fController->CurrentInterface()); 365 printf(" CurrentChannel %d\n", fController->CurrentChannel()); 366 367 // i = -1 means "None" 368 369 if (i < 0) { 370 fController->DisconnectInterface(); 371 goto done; 372 } 373 374 if (!fController->IsInterfaceAvailable(i)) { 375 BString s; 376 s << B_TRANSLATE("Error, interface is busy:\n\n"); 377 s << gDeviceRoster->DeviceName(i); 378 (new BAlert("error", s.String(), B_TRANSLATE("OK")))->Go(); 379 return; 380 } 381 382 fController->DisconnectInterface(); 383 if (fController->ConnectInterface(i) != B_OK) { 384 BString s; 385 s << B_TRANSLATE("Error, connecting to interface failed:\n\n"); 386 s << gDeviceRoster->DeviceName(i); 387 (new BAlert("error", s.String(), B_TRANSLATE("OK")))->Go(); 388 } 389 390 done: 391 printf("MainWin::SelectInterface done:\n"); 392 printf(" CurrentInterface %d\n", fController->CurrentInterface()); 393 printf(" CurrentChannel %d\n", fController->CurrentChannel()); 394 395 SetInterfaceMenuMarker(); 396 SetupChannelMenu(); 397 SetChannelMenuMarker(); 398 } 399 400 401 void 402 MainWin::SelectInitialInterface() 403 { 404 printf("MainWin::SelectInitialInterface enter\n"); 405 406 int count = gDeviceRoster->DeviceCount(); 407 for (int i = 0; i < count; i++) { 408 if (fController->IsInterfaceAvailable(i) 409 && B_OK == fController->ConnectInterface(i)) { 410 printf("MainWin::SelectInitialInterface connected to interface " 411 "%d\n", i); 412 break; 413 } 414 } 415 416 printf("MainWin::SelectInitialInterface leave\n"); 417 } 418 419 420 bool 421 MainWin::QuitRequested() 422 { 423 be_app->PostMessage(B_QUIT_REQUESTED); 424 return true; 425 } 426 427 428 void 429 MainWin::MouseDown(BMessage *msg) 430 { 431 BPoint screen_where; 432 uint32 buttons = msg->FindInt32("buttons"); 433 434 // On Zeta, only "screen_where" is relyable, "where" and "be:view_where" 435 // seem to be broken 436 if (B_OK != msg->FindPoint("screen_where", &screen_where)) { 437 // Workaround for BeOS R5, it has no "screen_where" 438 fVideoView->GetMouse(&screen_where, &buttons, false); 439 fVideoView->ConvertToScreen(&screen_where); 440 } 441 442 // msg->PrintToStream(); 443 444 // if (1 == msg->FindInt32("buttons") && msg->FindInt32("clicks") == 1) { 445 446 if (1 == buttons && msg->FindInt32("clicks") % 2 == 0) { 447 BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1, 448 screen_where.y + 1); 449 if (r.Contains(fMouseDownMousePos)) { 450 PostMessage(M_TOGGLE_FULLSCREEN); 451 return; 452 } 453 } 454 455 if (2 == buttons && msg->FindInt32("clicks") % 2 == 0) { 456 BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1, 457 screen_where.y + 1); 458 if (r.Contains(fMouseDownMousePos)) { 459 PostMessage(M_TOGGLE_NO_BORDER_NO_MENU); 460 return; 461 } 462 } 463 464 /* 465 // very broken in Zeta: 466 fMouseDownMousePos = fVideoView->ConvertToScreen( 467 msg->FindPoint("where")); 468 */ 469 fMouseDownMousePos = screen_where; 470 fMouseDownWindowPos = Frame().LeftTop(); 471 472 if (buttons == 1 && !fIsFullscreen) { 473 // start mouse tracking 474 fVideoView->SetMouseEventMask(B_POINTER_EVENTS | B_NO_POINTER_HISTORY 475 /* | B_LOCK_WINDOW_FOCUS */); 476 fMouseDownTracking = true; 477 } 478 479 // pop up a context menu if right mouse button is down for 200 ms 480 481 if ((buttons & 2) == 0) 482 return; 483 bigtime_t start = system_time(); 484 bigtime_t delay = 200000; 485 BPoint location; 486 do { 487 fVideoView->GetMouse(&location, &buttons); 488 if ((buttons & 2) == 0) 489 break; 490 snooze(1000); 491 } while (system_time() - start < delay); 492 493 if (buttons & 2) 494 ShowContextMenu(screen_where); 495 } 496 497 498 void 499 MainWin::MouseMoved(BMessage *msg) 500 { 501 // msg->PrintToStream(); 502 503 BPoint mousePos; 504 uint32 buttons = msg->FindInt32("buttons"); 505 506 if (1 == buttons && fMouseDownTracking && !fIsFullscreen) { 507 /* 508 // very broken in Zeta: 509 BPoint mousePos = msg->FindPoint("where"); 510 printf("view where: %.0f, %.0f => ", mousePos.x, mousePos.y); 511 fVideoView->ConvertToScreen(&mousePos); 512 */ 513 // On Zeta, only "screen_where" is relyable, "where" and 514 // "be:view_where" seem to be broken 515 if (B_OK != msg->FindPoint("screen_where", &mousePos)) { 516 // Workaround for BeOS R5, it has no "screen_where" 517 fVideoView->GetMouse(&mousePos, &buttons, false); 518 fVideoView->ConvertToScreen(&mousePos); 519 } 520 // printf("screen where: %.0f, %.0f => ", mousePos.x, mousePos.y); 521 float delta_x = mousePos.x - fMouseDownMousePos.x; 522 float delta_y = mousePos.y - fMouseDownMousePos.y; 523 float x = fMouseDownWindowPos.x + delta_x; 524 float y = fMouseDownWindowPos.y + delta_y; 525 // printf("move window to %.0f, %.0f\n", x, y); 526 MoveTo(x, y); 527 } 528 } 529 530 531 void 532 MainWin::MouseUp(BMessage *msg) 533 { 534 // msg->PrintToStream(); 535 fMouseDownTracking = false; 536 } 537 538 539 void 540 MainWin::ShowContextMenu(const BPoint &screen_point) 541 { 542 printf("Show context menu\n"); 543 BPopUpMenu *menu = new BPopUpMenu("context menu", false, false); 544 BMenuItem *item; 545 menu->AddItem(new BMenuItem(B_TRANSLATE("Scale to native size"), 546 new BMessage(M_SCALE_TO_NATIVE_SIZE), 'N', B_COMMAND_KEY)); 547 menu->AddItem(item = new BMenuItem(B_TRANSLATE("Full screen"), 548 new BMessage(M_TOGGLE_FULLSCREEN), 'F', B_COMMAND_KEY)); 549 item->SetMarked(fIsFullscreen); 550 menu->AddSeparatorItem(); 551 menu->AddItem(item = new BMenuItem(B_TRANSLATE("No menu"), 552 new BMessage(M_TOGGLE_NO_MENU), 'M', B_COMMAND_KEY)); 553 item->SetMarked(fNoMenu); 554 menu->AddItem(item = new BMenuItem(B_TRANSLATE("No border"), 555 new BMessage(M_TOGGLE_NO_BORDER), 'B', B_COMMAND_KEY)); 556 item->SetMarked(fNoBorder); 557 menu->AddItem(item = new BMenuItem(B_TRANSLATE("Always on top"), 558 new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T', B_COMMAND_KEY)); 559 item->SetMarked(fAlwaysOnTop); 560 menu->AddItem(item = new BMenuItem(B_TRANSLATE("Keep aspect ratio"), 561 new BMessage(M_TOGGLE_KEEP_ASPECT_RATIO), 'K', B_COMMAND_KEY)); 562 item->SetMarked(fKeepAspectRatio); 563 menu->AddSeparatorItem(); 564 menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), 565 new BMessage(M_FILE_QUIT), 'Q', B_COMMAND_KEY)); 566 567 menu->AddSeparatorItem(); 568 const char* pixel_aspect = "pixel aspect ratio"; 569 BString str1 = pixel_aspect; 570 str1 << " 1.00000:1"; 571 menu->AddItem(new BMenuItem(str1.String(), 572 new BMessage(M_ASPECT_100000_1))); 573 BString str2 = pixel_aspect; 574 str2 << " 1.06666:1"; 575 menu->AddItem(new BMenuItem(str2.String(), 576 new BMessage(M_ASPECT_106666_1))); 577 BString str3 = pixel_aspect; 578 str3 << " 1.09091:1"; 579 menu->AddItem(new BMenuItem(str3.String(), 580 new BMessage(M_ASPECT_109091_1))); 581 BString str4 = pixel_aspect; 582 str4 << " 1.41176:1"; 583 menu->AddItem(new BMenuItem(str4.String(), 584 new BMessage(M_ASPECT_141176_1))); 585 menu->AddItem(new BMenuItem(B_TRANSLATE( 586 "force 720 x 576, display aspect 4:3"), 587 new BMessage(M_ASPECT_720_576))); 588 menu->AddItem(new BMenuItem(B_TRANSLATE( 589 "force 704 x 576, display aspect 4:3"), 590 new BMessage(M_ASPECT_704_576))); 591 menu->AddItem(new BMenuItem(B_TRANSLATE( 592 "force 544 x 576, display aspect 4:3"), 593 new BMessage(M_ASPECT_544_576))); 594 595 menu->SetTargetForItems(this); 596 BRect r(screen_point.x - 5, screen_point.y - 5, screen_point.x + 5, 597 screen_point.y + 5); 598 menu->Go(screen_point, true, true, r, true); 599 } 600 601 602 void 603 MainWin::VideoFormatChange(int width, int height, float width_scale, 604 float height_scale) 605 { 606 // called when video format or aspect ratio changes 607 608 printf("VideoFormatChange enter: width %d, height %d, width_scale %.6f, " 609 "height_scale %.6f\n", width, height, width_scale, height_scale); 610 611 if (width_scale < 1.0 && height_scale >= 1.0) { 612 width_scale = 1.0 / width_scale; 613 height_scale = 1.0 / height_scale; 614 printf("inverting! new values: width_scale %.6f, height_scale %.6f\n", 615 width_scale, height_scale); 616 } 617 618 fSourceWidth = width; 619 fSourceHeight = height; 620 fWidthScale = width_scale; 621 fHeightScale = height_scale; 622 623 // ResizeWindow(Bounds().Width() + 1, Bounds().Height() + 1, true); 624 625 if (fIsFullscreen) { 626 AdjustFullscreenRenderer(); 627 } else { 628 AdjustWindowedRenderer(false); 629 } 630 631 printf("VideoFormatChange leave\n"); 632 633 } 634 635 636 void 637 MainWin::Zoom(BPoint rec_position, float rec_width, float rec_height) 638 { 639 PostMessage(M_TOGGLE_FULLSCREEN); 640 } 641 642 643 void 644 MainWin::FrameResized(float new_width, float new_height) 645 { 646 // called when the window got resized 647 fFrameResizedCalled = true; 648 649 if (new_width != Bounds().Width() || new_height != Bounds().Height()) { 650 debugger("size wrong\n"); 651 } 652 653 654 printf("FrameResized enter: new_width %.0f, new_height %.0f, bounds width " 655 "%.0f, bounds height %.0f\n", new_width, new_height, Bounds().Width(), 656 Bounds().Height()); 657 658 if (fIsFullscreen) { 659 660 printf("FrameResized in fullscreen mode\n"); 661 662 fIgnoreFrameResized = false; 663 AdjustFullscreenRenderer(); 664 665 } else { 666 667 if (fFrameResizedTriggeredAutomatically) { 668 fFrameResizedTriggeredAutomatically = false; 669 printf("FrameResized triggered automatically\n"); 670 671 fIgnoreFrameResized = false; 672 673 AdjustWindowedRenderer(false); 674 } else { 675 printf("FrameResized by user in window mode\n"); 676 677 if (fIgnoreFrameResized) { 678 fIgnoreFrameResized = false; 679 printf("FrameResized ignored\n"); 680 return; 681 } 682 683 AdjustWindowedRenderer(true); 684 } 685 686 } 687 688 printf("FrameResized leave\n"); 689 } 690 691 692 693 void 694 MainWin::UpdateWindowTitle() 695 { 696 BString title; 697 title.SetToFormat("%s - %d x %d, %.3f:%.3f => %.0f x %.0f", 698 B_TRANSLATE_SYSTEM_NAME(NAME), 699 fSourceWidth, fSourceHeight, fWidthScale, fHeightScale, 700 fVideoView->Bounds().Width() + 1, fVideoView->Bounds().Height() + 1); 701 SetTitle(title); 702 } 703 704 705 void 706 MainWin::AdjustFullscreenRenderer() 707 { 708 // n.b. we don't have a menu in fullscreen mode! 709 710 if (fKeepAspectRatio) { 711 712 // Keep aspect ratio, place render inside 713 // the background area (may create black bars). 714 float max_width = fBackground->Bounds().Width() + 1.0f; 715 float max_height = fBackground->Bounds().Height() + 1.0f; 716 float scaled_width = fSourceWidth * fWidthScale; 717 float scaled_height = fSourceHeight * fHeightScale; 718 float factor = min_c(max_width / scaled_width, max_height 719 / scaled_height); 720 int render_width = int(scaled_width * factor); 721 int render_height = int(scaled_height * factor); 722 int x_ofs = (int(max_width) - render_width) / 2; 723 int y_ofs = (int(max_height) - render_height) / 2; 724 725 printf("AdjustFullscreenRenderer: background %.1f x %.1f, src video " 726 "%d x %d, scaled video %.3f x %.3f, factor %.3f, render %d x %d, " 727 "x-ofs %d, y-ofs %d\n", max_width, max_height, fSourceWidth, 728 fSourceHeight, scaled_width, scaled_height, factor, render_width, 729 render_height, x_ofs, y_ofs); 730 731 fVideoView->MoveTo(x_ofs, y_ofs); 732 fVideoView->ResizeTo(render_width - 1, render_height - 1); 733 734 } else { 735 736 printf("AdjustFullscreenRenderer: using whole background area\n"); 737 738 // no need to keep aspect ratio, make 739 // render cover the whole background 740 fVideoView->MoveTo(0, 0); 741 fVideoView->ResizeTo(fBackground->Bounds().Width(), 742 fBackground->Bounds().Height()); 743 744 } 745 } 746 747 748 void 749 MainWin::AdjustWindowedRenderer(bool user_resized) 750 { 751 printf("AdjustWindowedRenderer enter - user_resized %d\n", user_resized); 752 753 // In windowed mode, the renderer always covers the 754 // whole background, accounting for the menu 755 fVideoView->MoveTo(0, fNoMenu ? 0 : fMenuBarHeight); 756 fVideoView->ResizeTo(fBackground->Bounds().Width(), 757 fBackground->Bounds().Height() - (fNoMenu ? 0 : fMenuBarHeight)); 758 759 if (fKeepAspectRatio) { 760 // To keep the aspect ratio correct, we 761 // do resize the window as required 762 763 float max_width = Bounds().Width() + 1.0f; 764 float max_height = Bounds().Height() + 1.0f - (fNoMenu ? 0 765 : fMenuBarHeight); 766 float scaled_width = fSourceWidth * fWidthScale; 767 float scaled_height = fSourceHeight * fHeightScale; 768 769 if (!user_resized && (scaled_width > max_width 770 || scaled_height > max_height)) { 771 // A format switch occured, and the window was 772 // smaller then the video source. As it was not 773 // initiated by the user resizing the window, we 774 // enlarge the window to fit the video. 775 fIgnoreFrameResized = true; 776 ResizeTo(scaled_width - 1, scaled_height - 1 777 + (fNoMenu ? 0 : fMenuBarHeight)); 778 // Sync(); 779 return; 780 } 781 782 float display_aspect_ratio = scaled_width / scaled_height; 783 int new_width = int(max_width); 784 int new_height = int(max_width / display_aspect_ratio + 0.5); 785 786 printf("AdjustWindowedRenderer: old display %d x %d, src video " 787 "%d x %d, scaled video %.3f x %.3f, aspect ratio %.3f, new " 788 "display %d x %d\n", int(max_width), int(max_height), 789 fSourceWidth, fSourceHeight, scaled_width, scaled_height, 790 display_aspect_ratio, new_width, new_height); 791 792 fIgnoreFrameResized = true; 793 ResizeTo(new_width - 1, new_height - 1 + (fNoMenu ? 0 794 : fMenuBarHeight)); 795 // Sync(); 796 } 797 798 printf("AdjustWindowedRenderer leave\n"); 799 } 800 801 802 void 803 MainWin::ToggleNoBorderNoMenu() 804 { 805 if (!fNoMenu && fNoBorder) { 806 // if no border, switch of menu, too 807 PostMessage(M_TOGGLE_NO_MENU); 808 } else 809 if (fNoMenu && !fNoBorder) { 810 // if no menu, switch of border, too 811 PostMessage(M_TOGGLE_NO_BORDER); 812 } else { 813 // both are either on or off, toggle both 814 PostMessage(M_TOGGLE_NO_MENU); 815 PostMessage(M_TOGGLE_NO_BORDER); 816 } 817 } 818 819 820 void 821 MainWin::ToggleFullscreen() 822 { 823 printf("ToggleFullscreen enter\n"); 824 825 if (!fFrameResizedCalled) { 826 printf("ToggleFullscreen - ignoring, as FrameResized wasn't called " 827 "since last switch\n"); 828 return; 829 } 830 fFrameResizedCalled = false; 831 832 833 fIsFullscreen = !fIsFullscreen; 834 835 if (fIsFullscreen) { 836 // switch to fullscreen 837 838 // Sync here is probably not required 839 // Sync(); 840 841 fSavedFrame = Frame(); 842 printf("saving current frame: %d %d %d %d\n", int(fSavedFrame.left), 843 int(fSavedFrame.top), int(fSavedFrame.right), 844 int(fSavedFrame.bottom)); 845 BScreen screen(this); 846 BRect rect(screen.Frame()); 847 848 Hide(); 849 if (!fNoMenu) { 850 // if we have a menu, remove it now 851 fMenuBar->Hide(); 852 } 853 fFrameResizedTriggeredAutomatically = true; 854 MoveTo(rect.left, rect.top); 855 ResizeTo(rect.Width(), rect.Height()); 856 Show(); 857 858 // Sync(); 859 860 } else { 861 // switch back from full screen mode 862 863 Hide(); 864 // if we need a menu, show it now 865 if (!fNoMenu) { 866 fMenuBar->Show(); 867 } 868 fFrameResizedTriggeredAutomatically = true; 869 MoveTo(fSavedFrame.left, fSavedFrame.top); 870 ResizeTo(fSavedFrame.Width(), fSavedFrame.Height()); 871 Show(); 872 873 // We *must* make sure that the window is at 874 // the correct position before continuing, or 875 // rapid fullscreen switching by holding down 876 // the TAB key will expose strange bugs. 877 // Never remove this Sync! 878 // Sync(); 879 } 880 881 // FrameResized() will do the required adjustments 882 883 printf("ToggleFullscreen leave\n"); 884 } 885 886 887 void 888 MainWin::ToggleNoMenu() 889 { 890 printf("ToggleNoMenu enter\n"); 891 892 fNoMenu = !fNoMenu; 893 894 if (fIsFullscreen) { 895 // fullscreen is always without menu 896 printf("ToggleNoMenu leave, doing nothing, we are fullscreen\n"); 897 return; 898 } 899 900 // fFrameResizedTriggeredAutomatically = true; 901 fIgnoreFrameResized = true; 902 903 if (fNoMenu) { 904 fMenuBar->Hide(); 905 fVideoView->MoveTo(0, 0); 906 fVideoView->ResizeBy(0, fMenuBarHeight); 907 MoveBy(0, fMenuBarHeight); 908 ResizeBy(0, - fMenuBarHeight); 909 // Sync(); 910 } else { 911 fMenuBar->Show(); 912 fVideoView->MoveTo(0, fMenuBarHeight); 913 fVideoView->ResizeBy(0, -fMenuBarHeight); 914 MoveBy(0, - fMenuBarHeight); 915 ResizeBy(0, fMenuBarHeight); 916 // Sync(); 917 } 918 919 printf("ToggleNoMenu leave\n"); 920 } 921 922 923 void 924 MainWin::ToggleNoBorder() 925 { 926 printf("ToggleNoBorder enter\n"); 927 fNoBorder = !fNoBorder; 928 // SetLook(fNoBorder ? B_NO_BORDER_WINDOW_LOOK : B_TITLED_WINDOW_LOOK); 929 SetLook(fNoBorder ? B_BORDERED_WINDOW_LOOK : B_TITLED_WINDOW_LOOK); 930 printf("ToggleNoBorder leave\n"); 931 } 932 933 934 void 935 MainWin::ToggleAlwaysOnTop() 936 { 937 printf("ToggleAlwaysOnTop enter\n"); 938 fAlwaysOnTop = !fAlwaysOnTop; 939 SetFeel(fAlwaysOnTop ? B_FLOATING_ALL_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL); 940 printf("ToggleAlwaysOnTop leave\n"); 941 } 942 943 944 void 945 MainWin::ToggleKeepAspectRatio() 946 { 947 printf("ToggleKeepAspectRatio enter\n"); 948 fKeepAspectRatio = !fKeepAspectRatio; 949 950 fFrameResizedTriggeredAutomatically = true; 951 FrameResized(Bounds().Width(), Bounds().Height()); 952 // if (fIsFullscreen) { 953 // AdjustFullscreenRenderer(); 954 // } else { 955 // AdjustWindowedRenderer(false); 956 // } 957 printf("ToggleKeepAspectRatio leave\n"); 958 } 959 960 961 /* Trap keys that are about to be send to background or renderer view. 962 * Return B_OK if it shouldn't be passed to the view 963 */ 964 status_t 965 MainWin::KeyDown(BMessage *msg) 966 { 967 // msg->PrintToStream(); 968 969 uint32 key = msg->FindInt32("key"); 970 uint32 raw_char = msg->FindInt32("raw_char"); 971 uint32 modifiers = msg->FindInt32("modifiers"); 972 973 printf("key 0x%lx, raw_char 0x%lx, modifiers 0x%lx\n", key, raw_char, 974 modifiers); 975 976 switch (raw_char) { 977 case B_SPACE: 978 PostMessage(M_TOGGLE_NO_BORDER_NO_MENU); 979 return B_OK; 980 981 case B_ESCAPE: 982 if (fIsFullscreen) { 983 PostMessage(M_TOGGLE_FULLSCREEN); 984 return B_OK; 985 } else 986 break; 987 988 case B_ENTER: // Enter / Return 989 if (modifiers & B_COMMAND_KEY) { 990 PostMessage(M_TOGGLE_FULLSCREEN); 991 return B_OK; 992 } else 993 break; 994 995 case B_TAB: 996 if ((modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY 997 | B_MENU_KEY)) == 0) { 998 PostMessage(M_TOGGLE_FULLSCREEN); 999 return B_OK; 1000 } else 1001 break; 1002 1003 case B_UP_ARROW: 1004 if (modifiers & B_COMMAND_KEY) { 1005 PostMessage(M_CHANNEL_NEXT); 1006 } else { 1007 PostMessage(M_VOLUME_UP); 1008 } 1009 return B_OK; 1010 1011 case B_DOWN_ARROW: 1012 if (modifiers & B_COMMAND_KEY) { 1013 PostMessage(M_CHANNEL_PREV); 1014 } else { 1015 PostMessage(M_VOLUME_DOWN); 1016 } 1017 return B_OK; 1018 1019 case B_RIGHT_ARROW: 1020 if (modifiers & B_COMMAND_KEY) { 1021 PostMessage(M_VOLUME_UP); 1022 } else { 1023 PostMessage(M_CHANNEL_NEXT); 1024 } 1025 return B_OK; 1026 1027 case B_LEFT_ARROW: 1028 if (modifiers & B_COMMAND_KEY) { 1029 PostMessage(M_VOLUME_DOWN); 1030 } else { 1031 PostMessage(M_CHANNEL_PREV); 1032 } 1033 return B_OK; 1034 1035 case B_PAGE_UP: 1036 PostMessage(M_CHANNEL_NEXT); 1037 return B_OK; 1038 1039 case B_PAGE_DOWN: 1040 PostMessage(M_CHANNEL_PREV); 1041 return B_OK; 1042 } 1043 1044 switch (key) { 1045 case 0x3a: // numeric keypad + 1046 if ((modifiers & B_COMMAND_KEY) == 0) { 1047 printf("if\n"); 1048 PostMessage(M_VOLUME_UP); 1049 return B_OK; 1050 } else { 1051 printf("else\n"); 1052 break; 1053 } 1054 1055 case 0x25: // numeric keypad - 1056 if ((modifiers & B_COMMAND_KEY) == 0) { 1057 PostMessage(M_VOLUME_DOWN); 1058 return B_OK; 1059 } else { 1060 break; 1061 } 1062 1063 case 0x38: // numeric keypad up arrow 1064 PostMessage(M_VOLUME_UP); 1065 return B_OK; 1066 1067 case 0x59: // numeric keypad down arrow 1068 PostMessage(M_VOLUME_DOWN); 1069 return B_OK; 1070 1071 case 0x39: // numeric keypad page up 1072 case 0x4a: // numeric keypad right arrow 1073 PostMessage(M_CHANNEL_NEXT); 1074 return B_OK; 1075 1076 case 0x5a: // numeric keypad page down 1077 case 0x48: // numeric keypad left arrow 1078 PostMessage(M_CHANNEL_PREV); 1079 return B_OK; 1080 } 1081 1082 return B_ERROR; 1083 } 1084 1085 1086 void 1087 MainWin::DispatchMessage(BMessage *msg, BHandler *handler) 1088 { 1089 if ((msg->what == B_MOUSE_DOWN) && (handler == fBackground 1090 || handler == fVideoView)) 1091 MouseDown(msg); 1092 if ((msg->what == B_MOUSE_MOVED) && (handler == fBackground 1093 || handler == fVideoView)) 1094 MouseMoved(msg); 1095 if ((msg->what == B_MOUSE_UP) && (handler == fBackground 1096 || handler == fVideoView)) 1097 MouseUp(msg); 1098 1099 if ((msg->what == B_KEY_DOWN) && (handler == fBackground 1100 || handler == fVideoView)) { 1101 1102 // special case for PrintScreen key 1103 if (msg->FindInt32("key") == B_PRINT_KEY) { 1104 fVideoView->OverlayScreenshotPrepare(); 1105 BWindow::DispatchMessage(msg, handler); 1106 fVideoView->OverlayScreenshotCleanup(); 1107 return; 1108 } 1109 1110 // every other key gets dispatched to our KeyDown first 1111 if (KeyDown(msg) == B_OK) { 1112 // it got handled, don't pass it on 1113 return; 1114 } 1115 } 1116 1117 BWindow::DispatchMessage(msg, handler); 1118 } 1119 1120 1121 void 1122 MainWin::MessageReceived(BMessage *msg) 1123 { 1124 switch (msg->what) { 1125 case B_ACQUIRE_OVERLAY_LOCK: 1126 printf("B_ACQUIRE_OVERLAY_LOCK\n"); 1127 fVideoView->OverlayLockAcquire(); 1128 break; 1129 1130 case B_RELEASE_OVERLAY_LOCK: 1131 printf("B_RELEASE_OVERLAY_LOCK\n"); 1132 fVideoView->OverlayLockRelease(); 1133 break; 1134 1135 case B_MOUSE_WHEEL_CHANGED: 1136 { 1137 printf("B_MOUSE_WHEEL_CHANGED\n"); 1138 float dx = msg->FindFloat("be:wheel_delta_x"); 1139 float dy = msg->FindFloat("be:wheel_delta_y"); 1140 bool inv = modifiers() & B_COMMAND_KEY; 1141 if (dx > 0.1) PostMessage(inv ? M_VOLUME_DOWN : M_CHANNEL_PREV); 1142 if (dx < -0.1) PostMessage(inv ? M_VOLUME_UP : M_CHANNEL_NEXT); 1143 if (dy > 0.1) PostMessage(inv ? M_CHANNEL_PREV : M_VOLUME_DOWN); 1144 if (dy < -0.1) PostMessage(inv ? M_CHANNEL_NEXT : M_VOLUME_UP); 1145 break; 1146 } 1147 1148 case M_CHANNEL_NEXT: 1149 { 1150 printf("M_CHANNEL_NEXT\n"); 1151 int chan = fController->CurrentChannel(); 1152 if (chan != -1) { 1153 chan++; 1154 if (chan < fController->ChannelCount()) 1155 SelectChannel(chan); 1156 } 1157 break; 1158 } 1159 1160 case M_CHANNEL_PREV: 1161 { 1162 printf("M_CHANNEL_PREV\n"); 1163 int chan = fController->CurrentChannel(); 1164 if (chan != -1) { 1165 chan--; 1166 if (chan >= 0) 1167 SelectChannel(chan); 1168 } 1169 break; 1170 } 1171 1172 case M_VOLUME_UP: 1173 printf("M_VOLUME_UP\n"); 1174 fController->VolumeUp(); 1175 break; 1176 1177 case M_VOLUME_DOWN: 1178 printf("M_VOLUME_DOWN\n"); 1179 fController->VolumeDown(); 1180 break; 1181 1182 case M_ASPECT_100000_1: 1183 VideoFormatChange(fSourceWidth, fSourceHeight, 1.0, 1.0); 1184 break; 1185 1186 case M_ASPECT_106666_1: 1187 VideoFormatChange(fSourceWidth, fSourceHeight, 1.06666, 1.0); 1188 break; 1189 1190 case M_ASPECT_109091_1: 1191 VideoFormatChange(fSourceWidth, fSourceHeight, 1.09091, 1.0); 1192 break; 1193 1194 case M_ASPECT_141176_1: 1195 VideoFormatChange(fSourceWidth, fSourceHeight, 1.41176, 1.0); 1196 break; 1197 1198 case M_ASPECT_720_576: 1199 VideoFormatChange(720, 576, 1.06666, 1.0); 1200 break; 1201 1202 case M_ASPECT_704_576: 1203 VideoFormatChange(704, 576, 1.09091, 1.0); 1204 break; 1205 1206 case M_ASPECT_544_576: 1207 VideoFormatChange(544, 576, 1.41176, 1.0); 1208 break; 1209 1210 case B_REFS_RECEIVED: 1211 printf("MainWin::MessageReceived: B_REFS_RECEIVED\n"); 1212 // RefsReceived(msg); 1213 break; 1214 1215 case B_SIMPLE_DATA: 1216 printf("MainWin::MessageReceived: B_SIMPLE_DATA\n"); 1217 // if (msg->HasRef("refs")) 1218 // RefsReceived(msg); 1219 break; 1220 1221 case M_FILE_QUIT: 1222 // be_app->PostMessage(B_QUIT_REQUESTED); 1223 PostMessage(B_QUIT_REQUESTED); 1224 break; 1225 1226 case M_SCALE_TO_NATIVE_SIZE: 1227 printf("M_SCALE_TO_NATIVE_SIZE\n"); 1228 if (fIsFullscreen) { 1229 ToggleFullscreen(); 1230 } 1231 ResizeTo(int(fSourceWidth * fWidthScale), 1232 int(fSourceHeight * fHeightScale) + (fNoMenu ? 0 1233 : fMenuBarHeight)); 1234 // Sync(); 1235 break; 1236 1237 case M_TOGGLE_FULLSCREEN: 1238 ToggleFullscreen(); 1239 fSettingsMenu->ItemAt(1)->SetMarked(fIsFullscreen); 1240 break; 1241 1242 case M_TOGGLE_NO_MENU: 1243 ToggleNoMenu(); 1244 fSettingsMenu->ItemAt(3)->SetMarked(fNoMenu); 1245 break; 1246 1247 case M_TOGGLE_NO_BORDER: 1248 ToggleNoBorder(); 1249 fSettingsMenu->ItemAt(4)->SetMarked(fNoBorder); 1250 break; 1251 1252 case M_TOGGLE_ALWAYS_ON_TOP: 1253 ToggleAlwaysOnTop(); 1254 fSettingsMenu->ItemAt(5)->SetMarked(fAlwaysOnTop); 1255 break; 1256 1257 case M_TOGGLE_KEEP_ASPECT_RATIO: 1258 ToggleKeepAspectRatio(); 1259 fSettingsMenu->ItemAt(6)->SetMarked(fKeepAspectRatio); 1260 break; 1261 1262 case M_TOGGLE_NO_BORDER_NO_MENU: 1263 ToggleNoBorderNoMenu(); 1264 break; 1265 1266 case M_PREFERENCES: 1267 break; 1268 1269 default: 1270 if (msg->what >= M_SELECT_CHANNEL 1271 && msg->what <= M_SELECT_CHANNEL_END) { 1272 SelectChannel(msg->what - M_SELECT_CHANNEL); 1273 break; 1274 } 1275 if (msg->what >= M_SELECT_INTERFACE 1276 && msg->what <= M_SELECT_INTERFACE_END) { 1277 SelectInterface(msg->what - M_SELECT_INTERFACE - 1); 1278 break; 1279 } 1280 } 1281 } 1282 1283