1 /* 2 * Copyright 2001-2008, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Marc Flerackers (mflerackers@androme.be) 7 * Bill Hayden (haydentech@users.sourceforge.net) 8 * Stefano Ceccherini (stefano.ceccherini@gmail.com) 9 * Olivier Milla 10 */ 11 12 //! Display item for BMenu class 13 14 #include <ctype.h> 15 #include <stdlib.h> 16 #include <string.h> 17 18 #include <Bitmap.h> 19 #include <ControlLook.h> 20 #include <MenuItem.h> 21 #include <Shape.h> 22 #include <String.h> 23 #include <Window.h> 24 25 #include <MenuPrivate.h> 26 27 #include "utf8_functions.h" 28 29 30 const float kLightBGTint = (B_LIGHTEN_1_TINT + B_LIGHTEN_1_TINT + B_NO_TINT) / 3.0; 31 32 // map control key shortcuts to drawable Unicode characters 33 // cf. http://unicode.org/charts/PDF/U2190.pdf 34 const char *kUTF8ControlMap[] = { 35 NULL, 36 "\xe2\x86\xb8", /* B_HOME U+21B8 */ 37 NULL, NULL, 38 NULL, /* B_END */ 39 NULL, /* B_INSERT */ 40 NULL, NULL, 41 NULL, /* B_BACKSPACE */ 42 "\xe2\x86\xb9", /* B_TAB U+21B9 */ 43 "\xe2\x86\xb5", /* B_ENTER, U+21B5 */ 44 //"\xe2\x8f\x8e", /* B_ENTER, U+23CE it's the official one */ 45 NULL, /* B_PAGE_UP */ 46 NULL, /* B_PAGE_DOWN */ 47 NULL, NULL, NULL, 48 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 49 NULL, NULL, NULL, NULL, 50 "\xe2\x86\x90", /* B_LEFT_ARROW */ 51 "\xe2\x86\x92", /* B_RIGHT_ARROW */ 52 "\xe2\x86\x91", /* B_UP_ARROW */ 53 "\xe2\x86\x93", /* B_DOWN_ARROW */ 54 }; 55 56 using BPrivate::MenuPrivate; 57 58 BMenuItem::BMenuItem(const char *label, BMessage *message, char shortcut, 59 uint32 modifiers) 60 { 61 _InitData(); 62 if (label != NULL) 63 fLabel = strdup(label); 64 65 SetMessage(message); 66 67 fShortcutChar = shortcut; 68 69 if (shortcut != 0) 70 fModifiers = modifiers | B_COMMAND_KEY; 71 else 72 fModifiers = 0; 73 } 74 75 76 BMenuItem::BMenuItem(BMenu *menu, BMessage *message) 77 { 78 _InitData(); 79 SetMessage(message); 80 _InitMenuData(menu); 81 } 82 83 84 BMenuItem::BMenuItem(BMessage *data) 85 { 86 _InitData(); 87 88 if (data->HasString("_label")) { 89 const char *string; 90 91 data->FindString("_label", &string); 92 SetLabel(string); 93 } 94 95 bool disable; 96 if (data->FindBool("_disable", &disable) == B_OK) 97 SetEnabled(!disable); 98 99 bool marked; 100 if (data->FindBool("_marked", &marked) == B_OK) 101 SetMarked(marked); 102 103 int32 userTrigger; 104 if (data->FindInt32("_user_trig", &userTrigger) == B_OK) 105 SetTrigger(userTrigger); 106 107 if (data->HasInt32("_shortcut")) { 108 int32 shortcut, mods; 109 110 data->FindInt32("_shortcut", &shortcut); 111 data->FindInt32("_mods", &mods); 112 113 SetShortcut(shortcut, mods); 114 } 115 116 if (data->HasMessage("_msg")) { 117 BMessage *msg = new BMessage; 118 data->FindMessage("_msg", msg); 119 SetMessage(msg); 120 } 121 122 BMessage subMessage; 123 if (data->FindMessage("_submenu", &subMessage) == B_OK) { 124 BArchivable *object = instantiate_object(&subMessage); 125 if (object != NULL) { 126 BMenu *menu = dynamic_cast<BMenu *>(object); 127 if (menu != NULL) 128 _InitMenuData(menu); 129 } 130 } 131 } 132 133 134 BArchivable * 135 BMenuItem::Instantiate(BMessage *data) 136 { 137 if (validate_instantiation(data, "BMenuItem")) 138 return new BMenuItem(data); 139 140 return NULL; 141 } 142 143 144 status_t 145 BMenuItem::Archive(BMessage *data, bool deep) const 146 { 147 status_t ret = BArchivable::Archive(data, deep); 148 149 if (ret == B_OK && fLabel) 150 ret = data->AddString("_label", Label()); 151 152 if (ret == B_OK && !IsEnabled()) 153 ret = data->AddBool("_disable", true); 154 155 if (ret == B_OK && IsMarked()) 156 ret = data->AddBool("_marked", true); 157 158 if (ret == B_OK && fUserTrigger) 159 ret = data->AddInt32("_user_trig", fUserTrigger); 160 161 if (ret == B_OK && fShortcutChar) { 162 ret = data->AddInt32("_shortcut", fShortcutChar); 163 if (ret == B_OK) 164 ret = data->AddInt32("_mods", fModifiers); 165 } 166 167 if (ret == B_OK && Message()) 168 ret = data->AddMessage("_msg", Message()); 169 170 if (ret == B_OK && deep && fSubmenu) { 171 BMessage submenu; 172 if (fSubmenu->Archive(&submenu, true) == B_OK) 173 ret = data->AddMessage("_submenu", &submenu); 174 } 175 176 return ret; 177 } 178 179 180 BMenuItem::~BMenuItem() 181 { 182 free(fLabel); 183 delete fSubmenu; 184 } 185 186 187 void 188 BMenuItem::SetLabel(const char *string) 189 { 190 if (fLabel != NULL) { 191 free(fLabel); 192 fLabel = NULL; 193 } 194 195 if (string != NULL) 196 fLabel = strdup(string); 197 198 if (fSuper != NULL) { 199 fSuper->InvalidateLayout(); 200 201 if (fSuper->LockLooper()) { 202 fSuper->Invalidate(); 203 fSuper->UnlockLooper(); 204 } 205 } 206 } 207 208 209 void 210 BMenuItem::SetEnabled(bool state) 211 { 212 if (fEnabled == state) 213 return; 214 215 fEnabled = state; 216 217 if (fSubmenu != NULL) 218 fSubmenu->SetEnabled(state); 219 220 BMenu *menu = Menu(); 221 if (menu != NULL && menu->LockLooper()) { 222 menu->Invalidate(fBounds); 223 menu->UnlockLooper(); 224 } 225 } 226 227 228 void 229 BMenuItem::SetMarked(bool state) 230 { 231 fMark = state; 232 233 if (state && Menu() != NULL) { 234 MenuPrivate priv(Menu()); 235 priv.ItemMarked(this); 236 } 237 } 238 239 240 void 241 BMenuItem::SetTrigger(char trigger) 242 { 243 fUserTrigger = trigger; 244 245 // try uppercase letters first 246 247 const char* pos = strchr(Label(), toupper(trigger)); 248 if (pos == NULL) { 249 // take lowercase, too 250 pos = strchr(Label(), trigger); 251 } 252 if (pos != NULL) { 253 fTriggerIndex = UTF8CountChars(Label(), pos - Label()); 254 fTrigger = tolower(UTF8ToCharCode(&pos)); 255 } else { 256 fTrigger = 0; 257 fTriggerIndex = -1; 258 } 259 260 if (fSuper != NULL) 261 fSuper->InvalidateLayout(); 262 } 263 264 265 void 266 BMenuItem::SetShortcut(char ch, uint32 modifiers) 267 { 268 if (fShortcutChar != 0 && (fModifiers & B_COMMAND_KEY) && fWindow) 269 fWindow->RemoveShortcut(fShortcutChar, fModifiers); 270 271 fShortcutChar = ch; 272 273 if (ch != 0) 274 fModifiers = modifiers | B_COMMAND_KEY; 275 else 276 fModifiers = 0; 277 278 if (fShortcutChar != 0 && (fModifiers & B_COMMAND_KEY) && fWindow) 279 fWindow->AddShortcut(fShortcutChar, fModifiers, this); 280 281 if (fSuper) { 282 fSuper->InvalidateLayout(); 283 284 if (fSuper->LockLooper()) { 285 fSuper->Invalidate(); 286 fSuper->UnlockLooper(); 287 } 288 } 289 } 290 291 292 const char * 293 BMenuItem::Label() const 294 { 295 return fLabel; 296 } 297 298 299 bool 300 BMenuItem::IsEnabled() const 301 { 302 if (fSubmenu) 303 return fSubmenu->IsEnabled(); 304 305 if (!fEnabled) 306 return false; 307 308 return fSuper ? fSuper->IsEnabled() : true; 309 } 310 311 312 bool 313 BMenuItem::IsMarked() const 314 { 315 return fMark; 316 } 317 318 319 char 320 BMenuItem::Trigger() const 321 { 322 return fUserTrigger; 323 } 324 325 326 char 327 BMenuItem::Shortcut(uint32 *modifiers) const 328 { 329 if (modifiers) 330 *modifiers = fModifiers; 331 332 return fShortcutChar; 333 } 334 335 336 BMenu * 337 BMenuItem::Submenu() const 338 { 339 return fSubmenu; 340 } 341 342 343 BMenu * 344 BMenuItem::Menu() const 345 { 346 return fSuper; 347 } 348 349 350 BRect 351 BMenuItem::Frame() const 352 { 353 return fBounds; 354 } 355 356 357 void 358 BMenuItem::GetContentSize(float *width, float *height) 359 { 360 // TODO: Get rid of this. BMenu should handle this 361 // automatically. Maybe it's not even needed, since our 362 // BFont::Height() caches the value locally 363 MenuPrivate(fSuper).CacheFontInfo(); 364 365 fCachedWidth = fSuper->StringWidth(fLabel); 366 367 if (width) 368 *width = (float)ceil(fCachedWidth); 369 if (height) { 370 *height = MenuPrivate(fSuper).FontHeight(); 371 } 372 } 373 374 375 void 376 BMenuItem::TruncateLabel(float maxWidth, char *newLabel) 377 { 378 BFont font; 379 BString string(fLabel); 380 381 font.TruncateString(&string, B_TRUNCATE_MIDDLE, maxWidth); 382 383 string.CopyInto(newLabel, 0, string.Length()); 384 newLabel[string.Length()] = '\0'; 385 } 386 387 388 void 389 BMenuItem::DrawContent() 390 { 391 MenuPrivate menuPrivate(fSuper); 392 menuPrivate.CacheFontInfo(); 393 394 fSuper->MovePenBy(0, menuPrivate.Ascent()); 395 BPoint lineStart = fSuper->PenLocation(); 396 397 float labelWidth, labelHeight; 398 GetContentSize(&labelWidth, &labelHeight); 399 400 fSuper->SetDrawingMode(B_OP_OVER); 401 402 float frameWidth = fBounds.Width(); 403 if (menuPrivate.State() == MENU_STATE_CLOSED) { 404 float rightMargin, leftMargin; 405 menuPrivate.GetItemMargins(&leftMargin, NULL, &rightMargin, NULL); 406 frameWidth = fSuper->Frame().Width() - (rightMargin + leftMargin); 407 } 408 409 // truncate if needed 410 if (frameWidth > labelWidth) 411 fSuper->DrawString(fLabel); 412 else { 413 char *truncatedLabel = new char[strlen(fLabel) + 4]; 414 TruncateLabel(frameWidth, truncatedLabel); 415 fSuper->DrawString(truncatedLabel); 416 delete[] truncatedLabel; 417 } 418 419 if (fSuper->AreTriggersEnabled() && fTriggerIndex != -1) { 420 float escapements[fTriggerIndex + 1]; 421 BFont font; 422 fSuper->GetFont(&font); 423 424 font.GetEscapements(fLabel, fTriggerIndex + 1, escapements); 425 426 for (int32 i = 0; i < fTriggerIndex; i++) 427 lineStart.x += escapements[i] * font.Size(); 428 429 lineStart.x--; 430 lineStart.y++; 431 432 BPoint lineEnd(lineStart); 433 lineEnd.x += escapements[fTriggerIndex] * font.Size(); 434 435 fSuper->StrokeLine(lineStart, lineEnd); 436 } 437 } 438 439 440 void 441 BMenuItem::Draw() 442 { 443 bool enabled = IsEnabled(); 444 bool selected = IsSelected(); 445 446 rgb_color noTint = fSuper->LowColor(); 447 rgb_color bgColor = noTint; 448 449 // set low color and fill background if selected 450 bool activated = selected && (enabled || Submenu()) 451 /*&& fSuper->fRedrawAfterSticky*/; 452 if (activated) { 453 bgColor = tint_color(bgColor, B_DARKEN_3_TINT); 454 if (be_control_look != NULL) { 455 BRect rect = Frame(); 456 be_control_look->DrawMenuItemBackground(fSuper, rect, rect, 457 noTint, BControlLook::B_ACTIVATED); 458 } else { 459 fSuper->SetLowColor(bgColor); 460 fSuper->FillRect(Frame(), B_SOLID_LOW); 461 } 462 } else { 463 fSuper->SetLowColor(bgColor); 464 } 465 466 // set high color 467 if (be_control_look != NULL) { 468 if (enabled) { 469 fSuper->SetHighColor(tint_color(fSuper->LowColor(), 470 B_DARKEN_MAX_TINT)); 471 } else { 472 fSuper->SetHighColor(tint_color(fSuper->LowColor(), 473 B_DISABLED_LABEL_TINT)); 474 } 475 } else { 476 if (enabled) 477 fSuper->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR)); 478 else 479 fSuper->SetHighColor(tint_color(bgColor, B_DISABLED_LABEL_TINT)); 480 } 481 482 // draw content 483 fSuper->MovePenTo(ContentLocation()); 484 DrawContent(); 485 486 // draw extra symbols 487 const menu_layout layout = MenuPrivate(fSuper).Layout(); 488 if (layout == B_ITEMS_IN_COLUMN) { 489 if (IsMarked()) 490 _DrawMarkSymbol(bgColor); 491 492 if (fShortcutChar) 493 _DrawShortcutSymbol(); 494 495 if (Submenu()) 496 _DrawSubmenuSymbol(bgColor); 497 } 498 499 fSuper->SetLowColor(noTint); 500 } 501 502 503 void 504 BMenuItem::Highlight(bool flag) 505 { 506 Menu()->Invalidate(Frame()); 507 } 508 509 510 bool 511 BMenuItem::IsSelected() const 512 { 513 return fSelected; 514 } 515 516 517 BPoint 518 BMenuItem::ContentLocation() const 519 { 520 const BRect &padding = MenuPrivate(fSuper).Padding(); 521 522 return BPoint(fBounds.left + padding.left, 523 fBounds.top + padding.top); 524 } 525 526 527 void BMenuItem::_ReservedMenuItem1() {} 528 void BMenuItem::_ReservedMenuItem2() {} 529 void BMenuItem::_ReservedMenuItem3() {} 530 void BMenuItem::_ReservedMenuItem4() {} 531 532 533 BMenuItem::BMenuItem(const BMenuItem &) 534 { 535 } 536 537 538 BMenuItem & 539 BMenuItem::operator=(const BMenuItem &) 540 { 541 return *this; 542 } 543 544 545 void 546 BMenuItem::_InitData() 547 { 548 fLabel = NULL; 549 fSubmenu = NULL; 550 fWindow = NULL; 551 fSuper = NULL; 552 fModifiers = 0; 553 fCachedWidth = 0; 554 fTriggerIndex = -1; 555 fUserTrigger = 0; 556 fTrigger = 0; 557 fShortcutChar = 0; 558 fMark = false; 559 fEnabled = true; 560 fSelected = false; 561 } 562 563 564 void 565 BMenuItem::_InitMenuData(BMenu *menu) 566 { 567 fSubmenu = menu; 568 569 MenuPrivate(fSubmenu).SetSuperItem(this); 570 571 BMenuItem *item = menu->FindMarked(); 572 573 if (menu->IsRadioMode() && menu->IsLabelFromMarked() && item != NULL) 574 SetLabel(item->Label()); 575 else 576 SetLabel(menu->Name()); 577 } 578 579 580 void 581 BMenuItem::Install(BWindow *window) 582 { 583 if (fSubmenu) { 584 MenuPrivate(fSubmenu).Install(window); 585 } 586 587 fWindow = window; 588 589 if (fShortcutChar != 0 && (fModifiers & B_COMMAND_KEY) && fWindow) 590 window->AddShortcut(fShortcutChar, fModifiers, this); 591 592 if (!Messenger().IsValid()) 593 SetTarget(window); 594 } 595 596 597 status_t 598 BMenuItem::Invoke(BMessage *message) 599 { 600 if (!IsEnabled()) 601 return B_ERROR; 602 603 if (fSuper->IsRadioMode()) 604 SetMarked(true); 605 606 bool notify = false; 607 uint32 kind = InvokeKind(¬ify); 608 609 BMessage clone(kind); 610 status_t err = B_BAD_VALUE; 611 612 if (!message && !notify) 613 message = Message(); 614 615 if (!message) { 616 if (!fSuper->IsWatched()) 617 return err; 618 } else 619 clone = *message; 620 621 clone.AddInt32("index", Menu()->IndexOf(this)); 622 clone.AddInt64("when", (int64)system_time()); 623 clone.AddPointer("source", this); 624 clone.AddMessenger("be:sender", BMessenger(fSuper)); 625 626 if (message) 627 err = BInvoker::Invoke(&clone); 628 629 // TODO: assynchronous messaging 630 // SendNotices(kind, &clone); 631 632 return err; 633 } 634 635 636 void 637 BMenuItem::Uninstall() 638 { 639 if (fSubmenu != NULL) { 640 MenuPrivate(fSubmenu).Uninstall(); 641 } 642 643 if (Target() == fWindow) 644 SetTarget(BMessenger()); 645 646 if (fShortcutChar != 0 && (fModifiers & B_COMMAND_KEY) != 0 647 && fWindow != NULL) 648 fWindow->RemoveShortcut(fShortcutChar, fModifiers); 649 650 fWindow = NULL; 651 } 652 653 654 void 655 BMenuItem::SetSuper(BMenu *super) 656 { 657 if (fSuper != NULL && super != NULL) 658 debugger("Error - can't add menu or menu item to more than 1 container (either menu or menubar)."); 659 660 if (fSubmenu != NULL) { 661 MenuPrivate(fSubmenu).SetSuper(super); 662 } 663 664 fSuper = super; 665 } 666 667 668 void 669 BMenuItem::Select(bool selected) 670 { 671 if (fSelected == selected) 672 return; 673 674 if (Submenu() || IsEnabled()) { 675 fSelected = selected; 676 Highlight(selected); 677 } 678 } 679 680 681 void 682 BMenuItem::_DrawMarkSymbol(rgb_color bgColor) 683 { 684 fSuper->PushState(); 685 686 BRect r(fBounds); 687 float leftMargin; 688 MenuPrivate(fSuper).GetItemMargins(&leftMargin, NULL, NULL, NULL); 689 r.right = r.left + leftMargin - 3; 690 r.left += 1; 691 692 BPoint center(floorf((r.left + r.right) / 2.0), 693 floorf((r.top + r.bottom) / 2.0)); 694 695 float size = min_c(r.Height() - 2, r.Width()); 696 r.top = floorf(center.y - size / 2 + 0.5); 697 r.bottom = floorf(center.y + size / 2 + 0.5); 698 r.left = floorf(center.x - size / 2 + 0.5); 699 r.right = floorf(center.x + size / 2 + 0.5); 700 701 BShape arrowShape; 702 center.x += 0.5; 703 center.y += 0.5; 704 size *= 0.3; 705 arrowShape.MoveTo(BPoint(center.x - size, center.y - size * 0.25)); 706 arrowShape.LineTo(BPoint(center.x - size * 0.25, center.y + size)); 707 arrowShape.LineTo(BPoint(center.x + size, center.y - size)); 708 709 fSuper->SetDrawingMode(B_OP_OVER); 710 fSuper->SetHighColor(tint_color(bgColor, B_DARKEN_MAX_TINT)); 711 fSuper->SetPenSize(2.0); 712 // NOTE: StrokeShape() offsets the shape by the current pen position, 713 // it is not documented in the BeBook, but it is true! 714 fSuper->MovePenTo(B_ORIGIN); 715 fSuper->StrokeShape(&arrowShape); 716 717 fSuper->PopState(); 718 } 719 720 721 void 722 BMenuItem::_DrawShortcutSymbol() 723 { 724 BMenu *menu = Menu(); 725 BFont font; 726 menu->GetFont(&font); 727 BPoint where = ContentLocation(); 728 where.x = fBounds.right - font.Size(); 729 730 if (fSubmenu) 731 where.x -= fBounds.Height() - 3; 732 733 const float ascent = MenuPrivate(fSuper).Ascent(); 734 if (fShortcutChar < B_SPACE && kUTF8ControlMap[(int)fShortcutChar]) 735 _DrawControlChar(fShortcutChar, where + BPoint(0, ascent)); 736 else 737 fSuper->DrawChar(fShortcutChar, where + BPoint(0, ascent)); 738 739 where.y += (fBounds.Height() - 11) / 2 - 1; 740 where.x -= 4; 741 742 if (fModifiers & B_COMMAND_KEY) { 743 const BBitmap *command = MenuPrivate::MenuItemCommand(); 744 const BRect &rect = command->Bounds(); 745 where.x -= rect.Width() + 1; 746 fSuper->DrawBitmap(command, where); 747 } 748 749 if (fModifiers & B_CONTROL_KEY) { 750 const BBitmap *control = MenuPrivate::MenuItemControl(); 751 const BRect &rect = control->Bounds(); 752 where.x -= rect.Width() + 1; 753 fSuper->DrawBitmap(control, where); 754 } 755 756 if (fModifiers & B_OPTION_KEY) { 757 const BBitmap *option = MenuPrivate::MenuItemOption(); 758 const BRect &rect = option->Bounds(); 759 where.x -= rect.Width() + 1; 760 fSuper->DrawBitmap(option, where); 761 } 762 763 if (fModifiers & B_SHIFT_KEY) { 764 const BBitmap *shift = MenuPrivate::MenuItemShift(); 765 const BRect &rect = shift->Bounds(); 766 where.x -= rect.Width() + 1; 767 fSuper->DrawBitmap(shift, where); 768 } 769 } 770 771 772 void 773 BMenuItem::_DrawSubmenuSymbol(rgb_color bgColor) 774 { 775 fSuper->PushState(); 776 777 BRect r(fBounds); 778 float rightMargin; 779 MenuPrivate(fSuper).GetItemMargins(NULL, NULL, &rightMargin, NULL); 780 r.left = r.right - rightMargin + 3; 781 r.right -= 1; 782 783 BPoint center(floorf((r.left + r.right) / 2.0), 784 floorf((r.top + r.bottom) / 2.0)); 785 786 float size = min_c(r.Height() - 2, r.Width()); 787 r.top = floorf(center.y - size / 2 + 0.5); 788 r.bottom = floorf(center.y + size / 2 + 0.5); 789 r.left = floorf(center.x - size / 2 + 0.5); 790 r.right = floorf(center.x + size / 2 + 0.5); 791 792 BShape arrowShape; 793 center.x += 0.5; 794 center.y += 0.5; 795 size *= 0.25; 796 float hSize = size * 0.7; 797 arrowShape.MoveTo(BPoint(center.x - hSize, center.y - size)); 798 arrowShape.LineTo(BPoint(center.x + hSize, center.y)); 799 arrowShape.LineTo(BPoint(center.x - hSize, center.y + size)); 800 801 fSuper->SetDrawingMode(B_OP_OVER); 802 fSuper->SetHighColor(tint_color(bgColor, B_DARKEN_MAX_TINT)); 803 fSuper->SetPenSize(ceilf(size * 0.4)); 804 // NOTE: StrokeShape() offsets the shape by the current pen position, 805 // it is not documented in the BeBook, but it is true! 806 fSuper->MovePenTo(B_ORIGIN); 807 fSuper->StrokeShape(&arrowShape); 808 809 fSuper->PopState(); 810 } 811 812 813 void 814 BMenuItem::_DrawControlChar(char shortcut, BPoint where) 815 { 816 // TODO: If needed, take another font for the control characters 817 // (or have font overlays in the app_server!) 818 const char* symbol = " "; 819 if (kUTF8ControlMap[(int)fShortcutChar]) 820 symbol = kUTF8ControlMap[(int)fShortcutChar]; 821 822 fSuper->DrawString(symbol, where); 823 } 824 825 826 void 827 BMenuItem::SetAutomaticTrigger(int32 index, uint32 trigger) 828 { 829 fTriggerIndex = index; 830 fTrigger = trigger; 831 } 832