From 2d5d385b299d0179b08190d613661dff5ce10902 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Tue, 7 Mar 2006 21:05:49 +0000 Subject: [PATCH] some other minor stuff git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16636 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/menu/MenuBar.cpp | 31 +++++++++++++++++-------- src/preferences/menu/MenuBar.h | 6 ++--- src/preferences/menu/MenuWindow.cpp | 4 ---- src/preferences/menu/msg.h | 36 ++++++++++++++++------------- 4 files changed, 44 insertions(+), 33 deletions(-) diff --git a/src/preferences/menu/MenuBar.cpp b/src/preferences/menu/MenuBar.cpp index cbfa65664f..6ae4f96a4e 100644 --- a/src/preferences/menu/MenuBar.cpp +++ b/src/preferences/menu/MenuBar.cpp @@ -20,6 +20,14 @@ MenuBar::MenuBar() } +void +MenuBar::AttachedToWindow() +{ + BMenuBar::AttachedToWindow(); + SetTargetForItems(Window()); +} + + void MenuBar::build_menu() { @@ -40,27 +48,24 @@ MenuBar::build_menu() colorSchemeItem = new BMenuItem("Color Scheme...", new BMessage(COLOR_SCHEME_MSG), 0, 0); // create the separator menu + // TODO: Use B_ITEMS_IN_MATRIX here separatorStyleMenu = new BMenu("Separator Style", B_ITEMS_IN_COLUMN); separatorStyleMenu->SetRadioMode(true); BMessage *msg = new BMessage(MENU_SEP_TYPE); msg->AddInt32("sep", 0); - separatorStyleZero = new BitmapMenuItem("separator0", msg, + separatorStyleZero = new BitmapMenuItem(" ", msg, BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP0")); msg = new BMessage(MENU_SEP_TYPE); msg->AddInt32("sep", 1); - separatorStyleOne = new BitmapMenuItem("separator1", msg, BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP1")); + separatorStyleOne = new BitmapMenuItem("", msg, BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP1")); msg = new BMessage(MENU_SEP_TYPE); msg->AddInt32("sep", 2); - separatorStyleTwo = new BitmapMenuItem("separator2", msg, BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP2")); - if (info.separator == 0) - separatorStyleZero->SetMarked(true); - if (info.separator == 1) - separatorStyleOne->SetMarked(true); - if (info.separator == 2) - separatorStyleTwo->SetMarked(true); + separatorStyleTwo = new BitmapMenuItem("", msg, BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP2")); + separatorStyleMenu->AddItem(separatorStyleZero); separatorStyleMenu->AddItem(separatorStyleOne); separatorStyleMenu->AddItem(separatorStyleTwo); + separatorStyleMenu->SetRadioMode(true); separatorStyleMenu->SetTargetForItems(Window()); // Add items to menubar @@ -75,7 +80,6 @@ MenuBar::build_menu() AddSeparatorItem(); AddItem(ctlAsShortcutItem); AddItem(altAsShortcutItem); - SetTargetForItems(Window()); } void @@ -100,6 +104,13 @@ MenuBar::set_menu() free(chars); free(keys); + + if (info.separator == 0) + separatorStyleZero->SetMarked(true); + else if (info.separator == 1) + separatorStyleOne->SetMarked(true); + else if (info.separator == 2) + separatorStyleTwo->SetMarked(true); } diff --git a/src/preferences/menu/MenuBar.h b/src/preferences/menu/MenuBar.h index 801af9896d..d4ac992f1a 100644 --- a/src/preferences/menu/MenuBar.h +++ b/src/preferences/menu/MenuBar.h @@ -10,13 +10,13 @@ class FontSizeMenu; class MenuBar : public BMenuBar { public: MenuBar(); + virtual void AttachedToWindow(); void set_menu(); void build_menu(); virtual void Update(); virtual void FrameResized(float width, float height); - - BRect menu_rect; - BRect rect; + +private: menu_info info; //seperator submenu diff --git a/src/preferences/menu/MenuWindow.cpp b/src/preferences/menu/MenuWindow.cpp index e2e937a685..346c26e02f 100644 --- a/src/preferences/menu/MenuWindow.cpp +++ b/src/preferences/menu/MenuWindow.cpp @@ -125,8 +125,6 @@ MenuWindow::MessageReceived(BMessage *msg) case CTL_MARKED_MSG: revert = true; - menuBar->ctlAsShortcutItem->SetMarked(true); - menuBar->altAsShortcutItem->SetMarked(false); // This might not be the same for all keyboards set_modifier_key(B_LEFT_COMMAND_KEY, 0x5c); set_modifier_key(B_RIGHT_COMMAND_KEY, 0x60); @@ -138,8 +136,6 @@ MenuWindow::MessageReceived(BMessage *msg) case ALT_MARKED_MSG: revert = true; - menuBar->altAsShortcutItem->SetMarked(true); - menuBar->ctlAsShortcutItem->SetMarked(false); // This might not be the same for all keyboards set_modifier_key(B_LEFT_COMMAND_KEY, 0x5d); set_modifier_key(B_RIGHT_COMMAND_KEY, 0x5f); diff --git a/src/preferences/menu/msg.h b/src/preferences/menu/msg.h index 151467416d..432f3d4adc 100644 --- a/src/preferences/menu/msg.h +++ b/src/preferences/menu/msg.h @@ -1,27 +1,31 @@ +#ifndef __MESSAGES_H +#define __MESSAGES_H - const uint32 MENU_BAR_ARCHIVE = 'mbar'; +const uint32 MENU_BAR_ARCHIVE = 'mbar'; //default - const uint32 DEFAULT_MSG = 'dmsg'; - const uint32 MENU_DEFAULT = 'mede'; - const uint32 MENU_REVERT = 'mere'; +const uint32 DEFAULT_MSG = 'dmsg'; +const uint32 MENU_DEFAULT = 'mede'; +const uint32 MENU_REVERT = 'mere'; //others - const uint32 UPDATE_WINDOW = 'uwin'; - const uint32 ALLWAYS_TRIGGERS_MSG = 'alti'; - const uint32 COLOR_SCHEME_MSG = 'cosc'; - const uint32 CTL_MARKED_MSG = 'ctms'; - const uint32 ALT_MARKED_MSG = 'alms'; +const uint32 UPDATE_WINDOW = 'uwin'; +const uint32 ALLWAYS_TRIGGERS_MSG = 'alti'; +const uint32 COLOR_SCHEME_MSG = 'cosc'; +const uint32 CTL_MARKED_MSG = 'ctms'; +const uint32 ALT_MARKED_MSG = 'alms'; //color - const uint32 MENU_COLOR = 'meco'; - const uint32 CLICK_OPEN_MSG = 'clop'; - const uint32 MENU_COLOR_DEFAULT = 'mcod'; +const uint32 MENU_COLOR = 'meco'; +const uint32 CLICK_OPEN_MSG = 'clop'; +const uint32 MENU_COLOR_DEFAULT = 'mcod'; //font - const uint32 MENU_FONT_FAMILY = 'mffm'; - const uint32 MENU_FONT_STYLE = 'mfst'; - const uint32 MENU_FONT_SIZE = 'mfsz'; +const uint32 MENU_FONT_FAMILY = 'mffm'; +const uint32 MENU_FONT_STYLE = 'mfst'; +const uint32 MENU_FONT_SIZE = 'mfsz'; //seperator - const uint32 MENU_SEP_TYPE = 'mstp'; +const uint32 MENU_SEP_TYPE = 'mstp'; + +#endif