diff --git a/src/preferences/menu/BitmapMenuItem.h b/src/preferences/menu/BitmapMenuItem.h index ab2dd0845d..37ddde848c 100644 --- a/src/preferences/menu/BitmapMenuItem.h +++ b/src/preferences/menu/BitmapMenuItem.h @@ -5,8 +5,6 @@ #include class BBitmap; - -// MBitmapMenuItem class declaration class BitmapMenuItem : public BMenuItem { public: BitmapMenuItem(const char* name, BMessage* message, BBitmap* bmp, diff --git a/src/preferences/menu/ColorWindow.cpp b/src/preferences/menu/ColorWindow.cpp index 87623e1d60..24ca11b5f0 100644 --- a/src/preferences/menu/ColorWindow.cpp +++ b/src/preferences/menu/ColorWindow.cpp @@ -40,34 +40,33 @@ void ColorWindow::MessageReceived(BMessage *msg) { switch(msg->what) { - - case MENU_REVERT: - colorPicker->SetValue(revert_info.background_color); - info.background_color = colorPicker->ValueAsColor(); - set_menu_info(&info); - be_app->PostMessage(UPDATE_WINDOW); - break; + case MENU_REVERT: + colorPicker->SetValue(revert_info.background_color); + info.background_color = colorPicker->ValueAsColor(); + set_menu_info(&info); + be_app->PostMessage(UPDATE_WINDOW); + break; - case MENU_COLOR_DEFAULT: - // change to system color for system wide - // compatability - rgb_color color; - color.red = 219; - color.blue = 219; - color.green = 219; - color.alpha = 255; - colorPicker->SetValue(color); - - case MENU_COLOR:{ - get_menu_info(&info); - info.background_color = colorPicker->ValueAsColor(); - set_menu_info(&info); - be_app->PostMessage(UPDATE_WINDOW); - break;} - - default: - be_app->PostMessage(UPDATE_WINDOW); - BMessage(msg); - break; + case MENU_COLOR_DEFAULT: + // change to system color for system wide + // compatability + rgb_color color; + color.red = 219; + color.blue = 219; + color.green = 219; + color.alpha = 255; + colorPicker->SetValue(color); + + case MENU_COLOR: + get_menu_info(&info); + info.background_color = colorPicker->ValueAsColor(); + set_menu_info(&info); + be_app->PostMessage(UPDATE_WINDOW); + break; + + default: + be_app->PostMessage(UPDATE_WINDOW); + BWindow::MessageReceived(msg); + break; } -} +} diff --git a/src/preferences/menu/ColorWindow.h b/src/preferences/menu/ColorWindow.h index c7a686e73d..8d7b1c4ca7 100644 --- a/src/preferences/menu/ColorWindow.h +++ b/src/preferences/menu/ColorWindow.h @@ -7,10 +7,11 @@ class BColorControl; class BButton; class ColorWindow : public BWindow { - public: +public: ColorWindow(); virtual void MessageReceived(BMessage *msg); - + +private: BColorControl *colorPicker; BButton *DefaultButton; BButton *RevertButton; diff --git a/src/preferences/menu/MenuApp.cpp b/src/preferences/menu/MenuApp.cpp index f9c4ff7f6c..739e317a5a 100644 --- a/src/preferences/menu/MenuApp.cpp +++ b/src/preferences/menu/MenuApp.cpp @@ -5,18 +5,8 @@ MenuApp::MenuApp() : BApplication("application/x-vnd.Be-GGUI") { - get_menu_info(&info); - - menuWindow = new MenuWindow(); - Update(); - menuWindow->Show(); -} - - -void -MenuApp::Update() -{ - menuWindow->Update(); + fMenuWindow = new MenuWindow(BRect(100, 100, 400, 300)); + fMenuWindow->Show(); } @@ -24,7 +14,6 @@ void MenuApp::MessageReceived(BMessage *msg) { switch(msg->what) { - //others case UPDATE_WINDOW: case CLICK_OPEN_MSG: @@ -33,7 +22,7 @@ MenuApp::MessageReceived(BMessage *msg) case ALT_MARKED_MSG: case COLOR_SCHEME_MSG: case MENU_COLOR: - menuWindow->PostMessage(msg); + fMenuWindow->PostMessage(msg); break; default: diff --git a/src/preferences/menu/MenuApp.h b/src/preferences/menu/MenuApp.h index a1069e7647..9e6d468623 100644 --- a/src/preferences/menu/MenuApp.h +++ b/src/preferences/menu/MenuApp.h @@ -2,20 +2,15 @@ #define __MENU_APP_H #include -#include class MenuWindow; class MenuApp : public BApplication { public: MenuApp(); - virtual void Update(); virtual void MessageReceived(BMessage *msg); private: - MenuWindow *menuWindow; - BRect rect; - menu_info info; - BMenu *menu; + MenuWindow *fMenuWindow; }; #endif diff --git a/src/preferences/menu/MenuBar.cpp b/src/preferences/menu/MenuBar.cpp index 492a7d7cd8..cbfa65664f 100644 --- a/src/preferences/menu/MenuBar.cpp +++ b/src/preferences/menu/MenuBar.cpp @@ -44,14 +44,14 @@ MenuBar::build_menu() separatorStyleMenu->SetRadioMode(true); BMessage *msg = new BMessage(MENU_SEP_TYPE); msg->AddInt32("sep", 0); - separatorStyleZero = new BitmapMenuItem(" ", msg, + separatorStyleZero = new BitmapMenuItem("separator0", msg, BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP0")); msg = new BMessage(MENU_SEP_TYPE); msg->AddInt32("sep", 1); - separatorStyleOne = new BitmapMenuItem("", msg, BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP1")); + separatorStyleOne = new BitmapMenuItem("separator1", msg, BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP1")); msg = new BMessage(MENU_SEP_TYPE); msg->AddInt32("sep", 2); - separatorStyleTwo = new BitmapMenuItem("", msg, BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP2")); + separatorStyleTwo = new BitmapMenuItem("separator2", msg, BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP2")); if (info.separator == 0) separatorStyleZero->SetMarked(true); if (info.separator == 1) @@ -119,7 +119,8 @@ MenuBar::Update() separatorStyleOne->SetMarked(true); else if (info.separator == 2) separatorStyleTwo->SetMarked(true); - set_menu(); + + set_menu(); BFont font; Window()->Lock(); diff --git a/src/preferences/menu/MenuWindow.cpp b/src/preferences/menu/MenuWindow.cpp index 86acd969b5..e2e937a685 100644 --- a/src/preferences/menu/MenuWindow.cpp +++ b/src/preferences/menu/MenuWindow.cpp @@ -13,34 +13,41 @@ #include #include -MenuWindow::MenuWindow() - : BWindow(rect, "Menu", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE) +MenuWindow::MenuWindow(BRect rect) + : BWindow(rect, "Menu", B_TITLED_WINDOW, + B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE) { get_menu_info(&revert_info); get_menu_info(&info); revert = false; - MoveTo((rect.left += 100),(rect.top += 100)); - menuView = new BBox(Bounds(), "menuView", B_FOLLOW_ALL_SIDES, - B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER); + menuView = new BBox(Bounds(), "menuView", B_FOLLOW_ALL_SIDES, + B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER); AddChild(menuView); menuBar = new MenuBar(); menuView->AddChild(menuBar); - defaultButton = new BButton(BRect(10,0,85,20), "Default", "Defaults", - new BMessage(MENU_DEFAULT), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE); - revertButton = new BButton(BRect(95,0,175,20), "Revert", "Revert", - new BMessage(MENU_REVERT), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE); - revertButton->SetEnabled(false); + + // resize the window according to the size of menuBar + ResizeTo((menuBar->Frame().right + 35), (menuBar->Frame().bottom + 45)); + BRect menuBarFrame = menuBar->Frame(); + BRect buttonFrame(menuBarFrame.left, menuBarFrame.bottom + 10, menuBarFrame.left + 75, menuBarFrame.bottom + 30); + + defaultButton = new BButton(buttonFrame, "Default", "Defaults", new BMessage(MENU_DEFAULT), + B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE); menuView->AddChild(defaultButton); + + buttonFrame.OffsetBy(buttonFrame.Width() + 20, 0); + revertButton = new BButton(buttonFrame, "Revert", "Revert", new BMessage(MENU_REVERT), + B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE); + revertButton->SetEnabled(false); menuView->AddChild(revertButton); menuView->MakeFocus(); - - Update(); + Update(); } @@ -48,124 +55,115 @@ void MenuWindow::MessageReceived(BMessage *msg) { switch(msg->what) { - - case MENU_REVERT: - set_menu_info(&revert_info); - revert = false; - Update(); - break; + case MENU_REVERT: + set_menu_info(&revert_info); + revert = false; + Update(); + break; + + case MENU_DEFAULT: + Defaults(); + break; + + case UPDATE_WINDOW: + Update(); + break; - case MENU_DEFAULT: - Defaults(); - break; + case MENU_FONT_FAMILY: + case MENU_FONT_STYLE: + { + font_family *family; + msg->FindPointer("family", (void**)&family); + font_style *style; + msg->FindPointer("style", (void**)&style); + memcpy(info.f_family, family, sizeof(info.f_family)); + memcpy(info.f_style, style, sizeof(info.f_style)); + set_menu_info(&info); + Update(); + break; + } - case UPDATE_WINDOW: - Update(); - break; - - case MENU_FONT_FAMILY: - case MENU_FONT_STYLE: - { - font_family *family; - msg->FindPointer("family", (void**)&family); - font_style *style; - msg->FindPointer("style", (void**)&style); - memcpy(info.f_family, family, sizeof(info.f_family)); - memcpy(info.f_style, style, sizeof(info.f_style)); - set_menu_info(&info); - Update(); - break; + case MENU_FONT_SIZE: + revert = true; + float fontSize; + msg->FindFloat("size", &fontSize); + info.font_size = fontSize; + set_menu_info(&info); + Update(); + break; + + case MENU_SEP_TYPE: + revert = true; + int32 i; + msg->FindInt32("sep", &i); + info.separator = i; + set_menu_info(&info); + Update(); + break; + + case CLICK_OPEN_MSG: + revert = true; + if (info.click_to_open != true) + info.click_to_open = true; + else + info.click_to_open = false; + set_menu_info(&info); + menuBar->set_menu(); + Update(); + break; + + case ALLWAYS_TRIGGERS_MSG: + revert = true; + if (info.triggers_always_shown != true) + info.triggers_always_shown = true; + else + info.triggers_always_shown = false; + set_menu_info(&info); + menuBar->set_menu(); + Update(); + break; + + 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); + set_modifier_key(B_LEFT_CONTROL_KEY, 0x5d); + set_modifier_key(B_RIGHT_OPTION_KEY, 0x5f); + be_roster->Broadcast(new BMessage(B_MODIFIERS_CHANGED)); + Update(); + break; + + 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); + set_modifier_key(B_LEFT_CONTROL_KEY, 0x5c); + set_modifier_key(B_RIGHT_OPTION_KEY, 0x60); + + be_roster->Broadcast(new BMessage(B_MODIFIERS_CHANGED)); + Update(); + break; + + case COLOR_SCHEME_MSG: + colorWindow = new ColorWindow(); + colorWindow->Show(); + break; + + case MENU_COLOR: + set_menu_info(&info); + (new BAlert("test","we made it","cool"))->Go(); + break; + + default: + BWindow::MessageReceived(msg); + break; } - - case MENU_FONT_SIZE: - revert = true; - float f; - msg->FindFloat("size", &f); - info.font_size = f; - set_menu_info(&info); - Update(); - break; - - case MENU_SEP_TYPE: - revert = true; - int32 i; - msg->FindInt32("sep", &i); - info.separator = i; - set_menu_info(&info); - Update(); - break; - - case CLICK_OPEN_MSG: - revert = true; - if (info.click_to_open != true) - info.click_to_open = true; - else - info.click_to_open = false; - set_menu_info(&info); - menuBar->set_menu(); - Update(); - break; - - case ALLWAYS_TRIGGERS_MSG: - revert = true; - if (info.triggers_always_shown != true) - info.triggers_always_shown = true; - else - info.triggers_always_shown = false; - set_menu_info(&info); - menuBar->set_menu(); - Update(); - break; - - 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); - set_modifier_key(B_LEFT_CONTROL_KEY, 0x5d); - set_modifier_key(B_RIGHT_OPTION_KEY, 0x5f); - be_roster->Broadcast(new BMessage(B_MODIFIERS_CHANGED)); - Update(); - break; - - 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); - set_modifier_key(B_LEFT_CONTROL_KEY, 0x5c); - set_modifier_key(B_RIGHT_OPTION_KEY, 0x60); - - be_roster->Broadcast(new BMessage(B_MODIFIERS_CHANGED)); - Update(); - break; - - case COLOR_SCHEME_MSG: - colorWindow = new ColorWindow(); - colorWindow->Show(); - break; - - case MENU_COLOR: - set_menu_info(&info); - (new BAlert("test","we made it","cool"))->Go(); - break; - - default: - BMessage(msg); - break; - } -} - - -bool -MenuWindow::QuitRequested() -{ - be_app->PostMessage(B_QUIT_REQUESTED); - return BWindow::QuitRequested(); } @@ -176,9 +174,6 @@ MenuWindow::Update() // alert the rest of the application to update menuBar->Update(); - - // resize the window according to the size of menuBar - ResizeTo((menuBar->Frame().right + 35), (menuBar->Frame().bottom + 45)); } diff --git a/src/preferences/menu/MenuWindow.h b/src/preferences/menu/MenuWindow.h index d2c49d42c7..aeaaea6e84 100644 --- a/src/preferences/menu/MenuWindow.h +++ b/src/preferences/menu/MenuWindow.h @@ -1,19 +1,18 @@ #ifndef __MENU_WINDOW_H #define __MENU_WINDOW_H +#include #include class ColorWindow; class BMenuItem; -class BMenu; class BBox; class BButton; class MenuBar; class MenuWindow : public BWindow { public: - MenuWindow(); + MenuWindow(BRect frame); virtual void MessageReceived(BMessage *msg); - virtual bool QuitRequested(); virtual void Update(); void Defaults(); @@ -23,7 +22,6 @@ private: BMenuItem *toggleItem; menu_info info; menu_info revert_info; - BRect rect; BMenu *menu; MenuBar *menuBar; BBox *menuView;