From ce0998ad77a6ef523443514b3e13e91bc1a3291c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 22 Dec 2006 11:05:17 +0000 Subject: [PATCH] * Fixed many style issues, patch by Vasilis Kaoutsis * Fixed some more style issues, removed unneeded class member variables. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19604 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/menu/AutoSettingsMenu.cpp | 17 +++- src/preferences/menu/AutoSettingsMenu.h | 23 ++++-- src/preferences/menu/BitmapMenuItem.cpp | 19 +++-- src/preferences/menu/BitmapMenuItem.h | 36 ++++++--- src/preferences/menu/ColorWindow.cpp | 70 ++++++++-------- src/preferences/menu/ColorWindow.h | 22 ++--- src/preferences/menu/FontMenu.cpp | 14 +++- src/preferences/menu/FontMenu.h | 36 ++++++--- src/preferences/menu/FontSizeMenu.cpp | 11 ++- src/preferences/menu/MenuApp.cpp | 5 +- src/preferences/menu/MenuApp.h | 7 +- src/preferences/menu/MenuBar.cpp | 97 +++++++++++------------ src/preferences/menu/MenuBar.h | 57 ++++++------- src/preferences/menu/MenuSettings.cpp | 9 +++ src/preferences/menu/MenuSettings.h | 38 +++++---- src/preferences/menu/MenuWindow.cpp | 88 ++++++++++---------- src/preferences/menu/MenuWindow.h | 25 +++--- src/preferences/menu/msg.h | 30 +++---- 18 files changed, 339 insertions(+), 265 deletions(-) diff --git a/src/preferences/menu/AutoSettingsMenu.cpp b/src/preferences/menu/AutoSettingsMenu.cpp index dd45bed453..114ddbe585 100644 --- a/src/preferences/menu/AutoSettingsMenu.cpp +++ b/src/preferences/menu/AutoSettingsMenu.cpp @@ -1,9 +1,18 @@ +/* + * Copyright 2002-2006, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * + */ + + #include "AutoSettingsMenu.h" #include "MenuSettings.h" + AutoSettingsMenu::AutoSettingsMenu(const char *name, menu_layout layout) - : - BMenu(name, layout) + : BMenu(name, layout) { } @@ -13,12 +22,12 @@ AutoSettingsMenu::AttachedToWindow() { menu_info info; MenuSettings::GetInstance()->Get(info); - + BFont font; font.SetFamilyAndStyle(info.f_family, info.f_style); font.SetSize(info.font_size); SetFont(&font); SetViewColor(info.background_color); - + BMenu::AttachedToWindow(); } diff --git a/src/preferences/menu/AutoSettingsMenu.h b/src/preferences/menu/AutoSettingsMenu.h index 16ac958c3b..b516f4a86c 100644 --- a/src/preferences/menu/AutoSettingsMenu.h +++ b/src/preferences/menu/AutoSettingsMenu.h @@ -1,13 +1,22 @@ -#ifndef __AUTOSETTINGSMENU_H -#define __AUTOSETTINGSMENU_H +/* + * Copyright 2002-2006, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * + */ +#ifndef AUTO_SETTINGS_MENU_H +#define AUTO_SETTINGS_MENU_H + #include + class AutoSettingsMenu : public BMenu { -public: - AutoSettingsMenu(const char *name, menu_layout layout); - virtual void AttachedToWindow(); + public: + AutoSettingsMenu(const char* name, menu_layout layout); + + virtual void AttachedToWindow(); }; - -#endif +#endif // AUTO_SETTINGS_MENU_H diff --git a/src/preferences/menu/BitmapMenuItem.cpp b/src/preferences/menu/BitmapMenuItem.cpp index 9e05ebedde..68194f3439 100644 --- a/src/preferences/menu/BitmapMenuItem.cpp +++ b/src/preferences/menu/BitmapMenuItem.cpp @@ -1,15 +1,22 @@ +/* + * Copyright 2002-2006, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * + */ + + +#include "BitmapMenuItem.h" + #include #include -// Project Headers -#include "BitmapMenuItem.h" - // BitmapMenuItem class definition BitmapMenuItem::BitmapMenuItem(const char* name, BMessage* message, - BBitmap* bmp, char shortcut, uint32 modifiers) - : - BMenuItem(name, message, shortcut, modifiers), + BBitmap* bmp, char shortcut, uint32 modifiers) + : BMenuItem(name, message, shortcut, modifiers), fBitmap(bmp), fName(name) { diff --git a/src/preferences/menu/BitmapMenuItem.h b/src/preferences/menu/BitmapMenuItem.h index c2269820dc..12af2bea5a 100644 --- a/src/preferences/menu/BitmapMenuItem.h +++ b/src/preferences/menu/BitmapMenuItem.h @@ -1,23 +1,33 @@ -#ifndef _MBitmapMenuItem_h -#define _MBitmapMenuItem_h +/* + * Copyright 2002-2006, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * + */ +#ifndef BITMAP_MENU_ITEM_H +#define BITMAP_MENU_ITEM_H + #include #include class BBitmap; + + class BitmapMenuItem : public BMenuItem { -public: - BitmapMenuItem(const char* name, BMessage* message, BBitmap* bmp, - char shortcut = 0, uint32 modifiers = 0); - ~BitmapMenuItem(); - virtual void DrawContent(); + public: + BitmapMenuItem(const char* name, BMessage* message, BBitmap* bmp, + char shortcut = '\0', uint32 modifiers = 0); + ~BitmapMenuItem(); + virtual void DrawContent(); -protected: - virtual void GetContentSize(float *width, float *height); + protected: + virtual void GetContentSize(float *width, float *height); -private: - BBitmap *fBitmap; - BString fName; + private: + BBitmap* fBitmap; + BString fName; }; -#endif // _MBitmapMenuItem_h +#endif // BITMAP_MENU_ITEM_H diff --git a/src/preferences/menu/ColorWindow.cpp b/src/preferences/menu/ColorWindow.cpp index 89e675b724..b4b6adb73d 100644 --- a/src/preferences/menu/ColorWindow.cpp +++ b/src/preferences/menu/ColorWindow.cpp @@ -1,56 +1,56 @@ /* - * Copyright 2002-2006, Haiku. All rights reserved. + * Copyright 2002-2006, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * - * Authors in chronological order: + * Authors: * * Vasilis Kaoutsis, kaoutsis@sch.gr */ +#include "ColorWindow.h" +#include "msg.h" + #include #include #include #include -#include "ColorWindow.h" -#include "msg.h" - ColorWindow::ColorWindow(BMessenger owner) - : BWindow(BRect(150,150,350,200), "Menu Color Scheme", B_TITLED_WINDOW, + : BWindow(BRect(150, 150, 350, 200), "Menu Color Scheme", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE), fOwner(owner) { // Set and collect the variables for revert - get_menu_info(&info); - get_menu_info(&revert_info); + get_menu_info(&fInfo); + get_menu_info(&fRevertInfo); BView *colView = new BView(BRect(0,0,1000,100), "menuView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE); - colorPicker = new BColorControl(BPoint(10,10), B_CELLS_32x8, - 9, "COLOR", new BMessage(MENU_COLOR), true); - colorPicker->SetValue(info.background_color); + fColorControl = new BColorControl(BPoint(10,10), B_CELLS_32x8, + 9, "COLOR", new BMessage(MENU_COLOR), true); + fColorControl->SetValue(fInfo.background_color); colView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - colView->AddChild(colorPicker); + colView->AddChild(fColorControl); AddChild(colView); ResizeTo(383, 130); // Create the buttons and add them to the view - DefaultButton = new BButton(BRect(10,100,85,110), "Default", "Default", + fDefaultButton = new BButton(BRect(10,100,85,110), "Default", "Default", new BMessage(MENU_COLOR_DEFAULT), B_FOLLOW_LEFT | B_FOLLOW_TOP, - B_WILL_DRAW | B_NAVIGABLE); - RevertButton = new BButton(BRect(95,100,175,20), "REVERT", "Revert", + B_WILL_DRAW | B_NAVIGABLE); + fRevertButton = new BButton(BRect(95,100,175,20), "REVERT", "Revert", new BMessage(MENU_REVERT), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, - B_WILL_DRAW | B_NAVIGABLE); + B_WILL_DRAW | B_NAVIGABLE); - colView->AddChild(DefaultButton); - colView->AddChild(RevertButton); + colView->AddChild(fDefaultButton); + colView->AddChild(fRevertButton); - DefaultButton->SetEnabled(false); - RevertButton->SetEnabled(false); + fDefaultButton->SetEnabled(false); + fRevertButton->SetEnabled(false); } @@ -72,11 +72,11 @@ 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); + fColorControl->SetValue(fRevertInfo.background_color); + fInfo.background_color = fColorControl->ValueAsColor(); + set_menu_info(&fInfo); be_app->PostMessage(UPDATE_WINDOW); - RevertButton->SetEnabled(false); + fRevertButton->SetEnabled(false); break; case MENU_COLOR_DEFAULT: @@ -87,22 +87,22 @@ ColorWindow::MessageReceived(BMessage *msg) color.blue = 216; color.green = 216; color.alpha = 255; - colorPicker->SetValue(color); - DefaultButton->SetEnabled(false); - get_menu_info(&info); - info.background_color = colorPicker->ValueAsColor(); - set_menu_info(&info); + fColorControl->SetValue(color); + fDefaultButton->SetEnabled(false); + get_menu_info(&fInfo); + fInfo.background_color = fColorControl->ValueAsColor(); + set_menu_info(&fInfo); be_app->PostMessage(MENU_COLOR); break; case MENU_COLOR: - get_menu_info(&info); - revert_info.background_color = info.background_color; - info.background_color = colorPicker->ValueAsColor(); - set_menu_info(&info); + get_menu_info(&fInfo); + fRevertInfo.background_color = fInfo.background_color; + fInfo.background_color = fColorControl->ValueAsColor(); + set_menu_info(&fInfo); be_app->PostMessage(MENU_COLOR); - DefaultButton->SetEnabled(true); - RevertButton->SetEnabled(true); + fDefaultButton->SetEnabled(true); + fRevertButton->SetEnabled(true); break; default: diff --git a/src/preferences/menu/ColorWindow.h b/src/preferences/menu/ColorWindow.h index 9552e62e52..84b050c312 100644 --- a/src/preferences/menu/ColorWindow.h +++ b/src/preferences/menu/ColorWindow.h @@ -1,13 +1,13 @@ /* - * Copyright 2002-2006, Haiku. All rights reserved. + * Copyright 2002-2006, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * - * Authors in chronological order: + * Authors: * * Vasilis Kaoutsis, kaoutsis@sch.gr */ -#ifndef __COLORWINDOW_H -#define __COLORWINDOW_H +#ifndef COLOR_WINDOW_H +#define COLOR_WINDOW_H #include @@ -27,12 +27,12 @@ class ColorWindow : public BWindow { virtual void MessageReceived(BMessage* message); private: - BColorControl *colorPicker; - BButton *DefaultButton; - BButton *RevertButton; - menu_info revert_info; - menu_info info; - BMessenger fOwner; + BColorControl* fColorControl; + BButton* fDefaultButton; + BButton* fRevertButton; + menu_info fRevertInfo; + menu_info fInfo; + BMessenger fOwner; }; -#endif // __COLORWINDOW_H +#endif // COLOR_WINDOW_H diff --git a/src/preferences/menu/FontMenu.cpp b/src/preferences/menu/FontMenu.cpp index da8e426f1e..f3c0e3a829 100644 --- a/src/preferences/menu/FontMenu.cpp +++ b/src/preferences/menu/FontMenu.cpp @@ -1,11 +1,21 @@ +/* + * Copyright 2002-2006, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * + */ + + #include "FontMenu.h" #include "MenuSettings.h" #include "msg.h" +#include +#include + #include -#include -#include FontMenu::FontMenu() : AutoSettingsMenu("Font", B_ITEMS_IN_COLUMN) diff --git a/src/preferences/menu/FontMenu.h b/src/preferences/menu/FontMenu.h index 053cff08dc..688203a958 100644 --- a/src/preferences/menu/FontMenu.h +++ b/src/preferences/menu/FontMenu.h @@ -1,23 +1,33 @@ -#ifndef __FONTMENU_H -#define __FONTMENU_H +/* + * Copyright 2002-2006, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * + */ +#ifndef FONT_MENU_H +#define FONT_MENU_H + #include "AutoSettingsMenu.h" + class FontSizeMenu : public AutoSettingsMenu { -public: - FontSizeMenu(); - virtual void AttachedToWindow(); + public: + FontSizeMenu(); + virtual void AttachedToWindow(); }; class FontMenu : public AutoSettingsMenu { -public: - FontMenu(); - virtual void AttachedToWindow(); - void GetFonts(); - - status_t PlaceCheckMarkOnFont(font_family family, font_style style); - void ClearAllMarkedItems(); + public: + FontMenu(); + + virtual void AttachedToWindow(); + void GetFonts(); + + status_t PlaceCheckMarkOnFont(font_family family, font_style style); + void ClearAllMarkedItems(); }; -#endif +#endif // FONT_MENU_H diff --git a/src/preferences/menu/FontSizeMenu.cpp b/src/preferences/menu/FontSizeMenu.cpp index dc3eb329fa..27f3f09644 100644 --- a/src/preferences/menu/FontSizeMenu.cpp +++ b/src/preferences/menu/FontSizeMenu.cpp @@ -1,9 +1,18 @@ +/* + * Copyright 2002-2006, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * + */ + + #include "FontMenu.h" #include "MenuSettings.h" #include "msg.h" -#include #include +#include #include #include diff --git a/src/preferences/menu/MenuApp.cpp b/src/preferences/menu/MenuApp.cpp index eee13ab667..4a0d9fee54 100644 --- a/src/preferences/menu/MenuApp.cpp +++ b/src/preferences/menu/MenuApp.cpp @@ -1,8 +1,8 @@ /* - * Copyright 2002-2006, Haiku. All rights reserved. + * Copyright 2002-2006, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * - * Authors in chronological order: + * Authors: * * Jack Burton * Vasilis Kaoutsis, kaoutsis@sch.gr @@ -54,4 +54,3 @@ main(int, char**) return 0; } - diff --git a/src/preferences/menu/MenuApp.h b/src/preferences/menu/MenuApp.h index d52585e5d4..8d959f6388 100644 --- a/src/preferences/menu/MenuApp.h +++ b/src/preferences/menu/MenuApp.h @@ -1,8 +1,8 @@ /* - * Copyright 2002-2006, Haiku. All rights reserved. + * Copyright 2002-2006, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * - * Authors in chronological order: + * Authors: * * Jack Burton */ @@ -12,12 +12,13 @@ #include - class MenuWindow; + class MenuApp : public BApplication { public: MenuApp(); + virtual void MessageReceived(BMessage* msg); private: diff --git a/src/preferences/menu/MenuBar.cpp b/src/preferences/menu/MenuBar.cpp index 489ca9d05a..1766595db9 100644 --- a/src/preferences/menu/MenuBar.cpp +++ b/src/preferences/menu/MenuBar.cpp @@ -1,8 +1,8 @@ /* - * Copyright 2002-2006, Haiku. All rights reserved. + * Copyright 2002-2006, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * - * Authors in chronological order: + * Authors: * * Vasilis Kaoutsis, kaoutsis@sch.gr */ @@ -22,12 +22,13 @@ #include #include + MenuBar::MenuBar() - :BMenuBar(BRect(40,10,10,10), "menu", B_FOLLOW_TOP|B_FRAME_EVENTS, + : BMenuBar(BRect(40, 10, 10, 10), "menu", B_FOLLOW_TOP | B_FRAME_EVENTS, B_ITEMS_IN_COLUMN, true) { - build_menu(); - set_menu(); + _BuildMenu(); + UpdateMenu(); SetItemMargins(14.0, 2.0, 20.0, 0.0); } @@ -41,27 +42,26 @@ MenuBar::AttachedToWindow() void -MenuBar::build_menu() +MenuBar::_BuildMenu() { // font and font size menus - fontMenu = new FontMenu(); - fontSizeMenu = new FontSizeMenu(); - + BMenu* fontMenu = new FontMenu(); + BMenu* fontSizeMenu = new FontSizeMenu(); + // create the menu items - alwaysShowTriggersItem = new BMenuItem("Always Show Triggers", - new BMessage(ALLWAYS_TRIGGERS_MSG), 0, 0); - separatorStyleItem = new BMenuItem("Separator Style", - new BMessage(DEFAULT_MSG), 0, 0); - ctlAsShortcutItem = new BitmapMenuItem("as Shortcut Key", - new BMessage(CTL_MARKED_MSG), BTranslationUtils::GetBitmap(B_RAW_TYPE, "CTL")); - altAsShortcutItem = new BitmapMenuItem("as Shortcut Key", - new BMessage(ALT_MARKED_MSG), BTranslationUtils::GetBitmap(B_RAW_TYPE, "ALT")); - + fAlwaysShowTriggersItem = new BMenuItem("Always Show Triggers", + new BMessage(ALLWAYS_TRIGGERS_MSG), 0, 0); + fControlAsShortcutItem = new BitmapMenuItem("as Shortcut Key", + new BMessage(CTL_MARKED_MSG), BTranslationUtils::GetBitmap(B_RAW_TYPE, "CTL")); + fAltAsShortcutItem = new BitmapMenuItem("as Shortcut Key", + new BMessage(ALT_MARKED_MSG), BTranslationUtils::GetBitmap(B_RAW_TYPE, "ALT")); + // color menu - colorSchemeItem = new BMenuItem("Color Scheme...", new BMessage(COLOR_SCHEME_OPEN_MSG), 0, 0); + BMenuItem* colorSchemeItem = new BMenuItem("Color Scheme...", + new BMessage(COLOR_SCHEME_OPEN_MSG), 0, 0); // create the separator menu - separatorStyleMenu = new BMenu("Separator Style", B_ITEMS_IN_COLUMN); + BMenu* separatorStyleMenu = new BMenu("Separator Style", B_ITEMS_IN_COLUMN); separatorStyleMenu->SetRadioMode(true); BMessage *msg = new BMessage(MENU_SEP_TYPE); msg->AddInt32("sep", 0); @@ -72,7 +72,7 @@ MenuBar::build_menu() msg = new BMessage(MENU_SEP_TYPE); msg->AddInt32("sep", 2); separatorStyleTwo = new BitmapMenuItem("", msg, BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP2")); - + separatorStyleMenu->AddItem(separatorStyleZero); separatorStyleMenu->AddItem(separatorStyleOne); separatorStyleMenu->AddItem(separatorStyleTwo); @@ -83,35 +83,36 @@ MenuBar::build_menu() AddItem(fontMenu, 0); AddItem(fontSizeMenu, 1); AddSeparatorItem(); - AddItem(alwaysShowTriggersItem); + AddItem(fAlwaysShowTriggersItem); AddSeparatorItem(); AddItem(colorSchemeItem); AddItem(separatorStyleMenu); AddSeparatorItem(); - AddItem(ctlAsShortcutItem); - AddItem(altAsShortcutItem); + AddItem(fControlAsShortcutItem); + AddItem(fAltAsShortcutItem); } + void -MenuBar::set_menu() +MenuBar::UpdateMenu() { - key_map *keys; - char *chars; - bool altAsShortcut; - menu_info info; MenuSettings::GetInstance()->Get(info); - - alwaysShowTriggersItem->SetMarked(info.triggers_always_shown); - + + fAlwaysShowTriggersItem->SetMarked(info.triggers_always_shown); + + key_map *keys; + char* chars; get_key_map(&keys, &chars); - - altAsShortcut = (keys->left_command_key == 0x5d) && (keys->right_command_key == 0x5f); - altAsShortcutItem->SetMarked(altAsShortcut); - ctlAsShortcutItem->SetMarked(!altAsShortcut); - - free(chars); - free(keys); + + bool altAsShortcut = (keys->left_command_key == 0x5d) + && (keys->right_command_key == 0x5f); + + free(chars); + free(keys); + + fAltAsShortcutItem->SetMarked(altAsShortcut); + fControlAsShortcutItem->SetMarked(!altAsShortcut); if (info.separator == 0) separatorStyleZero->SetMarked(true); @@ -125,21 +126,13 @@ MenuBar::set_menu() void MenuBar::Update() { - menu_info info; - MenuSettings::GetInstance()->Get(info); - // this needs to be updated in case the Defaults - // were requested. - if (info.separator == 0) - separatorStyleZero->SetMarked(true); - else if (info.separator == 1) - separatorStyleOne->SetMarked(true); - else if (info.separator == 2) - separatorStyleTwo->SetMarked(true); - - set_menu(); - + UpdateMenu(); + BFont font; if (LockLooper()) { + menu_info info; + MenuSettings::GetInstance()->Get(info); + font.SetFamilyAndStyle(info.f_family, info.f_style); font.SetSize(info.font_size); SetFont(&font); diff --git a/src/preferences/menu/MenuBar.h b/src/preferences/menu/MenuBar.h index 80bc6d710d..cd0ba382f2 100644 --- a/src/preferences/menu/MenuBar.h +++ b/src/preferences/menu/MenuBar.h @@ -1,36 +1,39 @@ -#ifndef __BARMENU_H -#define __BARMENU_H +/* + * Copyright 2002-2006, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * + */ +#ifndef MENU_BAR_H +#define MENU_BAR_H + #include class BMenuItem; -class FontMenu; -class FontSizeMenu; + class MenuBar : public BMenuBar { -public: - MenuBar(); - virtual void AttachedToWindow(); - void set_menu(); - void build_menu(); - void Update(); - virtual void FrameResized(float width, float height); + public: + MenuBar(); -private: - //seperator submenu - BMenu *separatorStyleMenu; - BMenuItem *separatorStyleZero; - BMenuItem *separatorStyleOne; - BMenuItem *separatorStyleTwo; - - //others - FontMenu *fontMenu; - FontSizeMenu *fontSizeMenu; - BMenuItem *alwaysShowTriggersItem; - BMenuItem *colorSchemeItem; - BMenuItem *separatorStyleItem; - BMenuItem *ctlAsShortcutItem; - BMenuItem *altAsShortcutItem; + virtual void AttachedToWindow(); + + void UpdateMenu(); + void Update(); + virtual void FrameResized(float width, float height); + + private: + void _BuildMenu(); + + BMenuItem* separatorStyleZero; + BMenuItem* separatorStyleOne; + BMenuItem* separatorStyleTwo; + + BMenuItem* fAlwaysShowTriggersItem; + BMenuItem* fControlAsShortcutItem; + BMenuItem* fAltAsShortcutItem; }; -#endif +#endif // MENU_BAR_H diff --git a/src/preferences/menu/MenuSettings.cpp b/src/preferences/menu/MenuSettings.cpp index 999e590ca6..7237f44837 100644 --- a/src/preferences/menu/MenuSettings.cpp +++ b/src/preferences/menu/MenuSettings.cpp @@ -1,3 +1,12 @@ +/* + * Copyright 2002-2006, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * + */ + + #include "MenuSettings.h" diff --git a/src/preferences/menu/MenuSettings.h b/src/preferences/menu/MenuSettings.h index 137c6cf2f1..99721d24af 100644 --- a/src/preferences/menu/MenuSettings.h +++ b/src/preferences/menu/MenuSettings.h @@ -1,25 +1,33 @@ -#ifndef __MENUSETTINGS_H -#define __MENUSETTINGS_H +/* + * Copyright 2002-2006, Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * + */ +#ifndef MENU_SETTINGS_H +#define MENU_SETTINGS_H + #include + class MenuSettings { -public: - static MenuSettings *GetInstance(); + public: + static MenuSettings *GetInstance(); - void Get(menu_info &info) const; - void Set(menu_info &info); + void Get(menu_info &info) const; + void Set(menu_info &info); - void Revert(); - void ResetToDefaults(); + void Revert(); + void ResetToDefaults(); -private: - MenuSettings(); - ~MenuSettings(); + private: + MenuSettings(); + ~MenuSettings(); - menu_info fPreviousSettings; - menu_info fDefaultSettings; + menu_info fPreviousSettings; + menu_info fDefaultSettings; }; - -#endif +#endif // MENU_SETTINGS_H diff --git a/src/preferences/menu/MenuWindow.cpp b/src/preferences/menu/MenuWindow.cpp index d8d998ae22..9c7b0e4b84 100644 --- a/src/preferences/menu/MenuWindow.cpp +++ b/src/preferences/menu/MenuWindow.cpp @@ -1,8 +1,8 @@ /* - * Copyright 2002-2006, Haiku. All rights reserved. + * Copyright 2002-2006, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * - * Authors in chronological order: + * Authors: * * Vasilis Kaoutsis, kaoutsis@sch.gr */ @@ -29,34 +29,36 @@ MenuWindow::MenuWindow(BRect rect) : BWindow(rect, "Menu", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE) { - colorWindow = NULL; - revert = false; - - menuView = new BBox(Bounds(), "menuView", B_FOLLOW_ALL_SIDES, - B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER); - AddChild(menuView); + fColorWindow = NULL; + fRevert = false; - menuBar = new MenuBar(); - menuView->AddChild(menuBar); + BView* topView = new BView(Bounds(), "menuView", B_FOLLOW_ALL_SIDES, + B_WILL_DRAW); + topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + AddChild(topView); - // resize the window according to the size of menuBar - ResizeTo((menuBar->Frame().right + 40), (menuBar->Frame().bottom + 45)); + fMenuBar = new MenuBar(); + topView->AddChild(fMenuBar); - BRect menuBarFrame = menuBar->Frame(); + // resize the window according to the size of fMenuBar + ResizeTo(fMenuBar->Frame().right + 40, fMenuBar->Frame().bottom + 45); + + BRect menuBarFrame = fMenuBar->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_H_CENTER | 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_H_CENTER | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE); - revertButton->SetEnabled(false); - menuView->AddChild(revertButton); + BButton* defaultButton = new BButton(buttonFrame, "Default", "Defaults", + new BMessage(MENU_DEFAULT), B_FOLLOW_H_CENTER | B_FOLLOW_BOTTOM, + B_WILL_DRAW | B_NAVIGABLE); + topView->AddChild(defaultButton); - menuView->MakeFocus(); + buttonFrame.OffsetBy(buttonFrame.Width() + 20, 0); + fRevertButton = new BButton(buttonFrame, "Revert", "Revert", new BMessage(MENU_REVERT), + B_FOLLOW_H_CENTER | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE); + fRevertButton->SetEnabled(false); + topView->AddChild(fRevertButton); + + topView->MakeFocus(); Update(); } @@ -75,13 +77,13 @@ MenuWindow::MessageReceived(BMessage *msg) switch (msg->what) { case MENU_REVERT: - revert = false; + fRevert = false; settings->Revert(); Update(); break; case MENU_DEFAULT: - revert = true; + fRevert = true; settings->ResetToDefaults(); Update(); break; @@ -93,7 +95,7 @@ MenuWindow::MessageReceived(BMessage *msg) case MENU_FONT_FAMILY: case MENU_FONT_STYLE: { - revert = true; + fRevert = true; font_family *family; msg->FindPointer("family", (void**)&family); font_style *style; @@ -107,7 +109,7 @@ MenuWindow::MessageReceived(BMessage *msg) } case MENU_FONT_SIZE: - revert = true; + fRevert = true; settings->Get(info); msg->FindFloat("size", &info.font_size); settings->Set(info); @@ -115,7 +117,7 @@ MenuWindow::MessageReceived(BMessage *msg) break; case MENU_SEP_TYPE: - revert = true; + fRevert = true; settings->Get(info); msg->FindInt32("sep", &info.separator); settings->Set(info); @@ -123,16 +125,16 @@ MenuWindow::MessageReceived(BMessage *msg) break; case ALLWAYS_TRIGGERS_MSG: - revert = true; + fRevert = true; settings->Get(info); info.triggers_always_shown = !info.triggers_always_shown; settings->Set(info); - menuBar->set_menu(); + fMenuBar->UpdateMenu(); Update(); break; case CTL_MARKED_MSG: - revert = true; + fRevert = true; // 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); @@ -143,7 +145,7 @@ MenuWindow::MessageReceived(BMessage *msg) break; case ALT_MARKED_MSG: - revert = true; + fRevert = true; // 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); @@ -155,19 +157,19 @@ MenuWindow::MessageReceived(BMessage *msg) break; case COLOR_SCHEME_OPEN_MSG: - if (colorWindow == NULL) { - colorWindow = new ColorWindow(this); - colorWindow->Show(); + if (fColorWindow == NULL) { + fColorWindow = new ColorWindow(this); + fColorWindow->Show(); } else - colorWindow->Activate(); + fColorWindow->Activate(); break; case COLOR_SCHEME_CLOSED_MSG: - colorWindow = NULL; + fColorWindow = NULL; break; case MENU_COLOR: - revert = true; + fRevert = true; Update(); break; @@ -181,9 +183,9 @@ MenuWindow::MessageReceived(BMessage *msg) bool MenuWindow::QuitRequested() { - if (colorWindow != NULL && colorWindow->Lock()) { - colorWindow->Quit(); - colorWindow = NULL; + if (fColorWindow != NULL && fColorWindow->Lock()) { + fColorWindow->Quit(); + fColorWindow = NULL; } return true; @@ -193,9 +195,9 @@ MenuWindow::QuitRequested() void MenuWindow::Update() { - revertButton->SetEnabled(revert); + fRevertButton->SetEnabled(fRevert); // alert the rest of the application to update - menuBar->Update(); + fMenuBar->Update(); } diff --git a/src/preferences/menu/MenuWindow.h b/src/preferences/menu/MenuWindow.h index 611b884a1e..ba18232926 100644 --- a/src/preferences/menu/MenuWindow.h +++ b/src/preferences/menu/MenuWindow.h @@ -1,12 +1,12 @@ /* - * Copyright 2002-2006, Haiku. All rights reserved. + * Copyright 2002-2006, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * - * Authors in chronological order: + * Authors: * */ -#ifndef __MENU_WINDOW_H -#define __MENU_WINDOW_H +#ifndef MENU_WINDOW_H +#define MENU_WINDOW_H #include @@ -14,11 +14,10 @@ class ColorWindow; -class BMenuItem; -class BBox; class BButton; class MenuBar; + class MenuWindow : public BWindow { public: MenuWindow(BRect frame); @@ -31,14 +30,10 @@ class MenuWindow : public BWindow { void Defaults(); private: - bool revert; - ColorWindow *colorWindow; - BMenuItem *toggleItem; - BMenu *menu; - MenuBar *menuBar; - BBox *menuView; - BButton *revertButton; - BButton *defaultButton; + bool fRevert; + ColorWindow* fColorWindow; + MenuBar* fMenuBar; + BButton* fRevertButton; }; -#endif // __MENU_WINDOW_H +#endif // MENU_WINDOW_H diff --git a/src/preferences/menu/msg.h b/src/preferences/menu/msg.h index 8ca3f41f9d..df5ee7338a 100644 --- a/src/preferences/menu/msg.h +++ b/src/preferences/menu/msg.h @@ -1,41 +1,41 @@ /* - * Copyright 2002-2006, Haiku. All rights reserved. + * Copyright 2002-2006, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * - * Authors in chronological order: + * Authors: * * Vasilis Kaoutsis, kaoutsis@sch.gr */ -#ifndef __MESSAGES_H -#define __MESSAGES_H - +#ifndef MESSAGES_H +#define MESSAGES_H + const uint32 MENU_BAR_ARCHIVE = 'mbar'; -//default +// default const uint32 DEFAULT_MSG = 'dmsg'; const uint32 MENU_DEFAULT = 'mede'; const uint32 MENU_REVERT = 'mere'; - -//others + +// others const uint32 UPDATE_WINDOW = 'uwin'; const uint32 ALLWAYS_TRIGGERS_MSG = 'alti'; const uint32 COLOR_SCHEME_OPEN_MSG = 'coso'; const uint32 COLOR_SCHEME_CLOSED_MSG = 'cosc'; const uint32 CTL_MARKED_MSG = 'ctms'; const uint32 ALT_MARKED_MSG = 'alms'; - -//color + +// color const uint32 MENU_COLOR = 'meco'; const uint32 CLICK_OPEN_MSG = 'clop'; const uint32 MENU_COLOR_DEFAULT = 'mcod'; - -//font + +// font const uint32 MENU_FONT_FAMILY = 'mffm'; const uint32 MENU_FONT_STYLE = 'mfst'; const uint32 MENU_FONT_SIZE = 'mfsz'; - -//seperator + +// seperator const uint32 MENU_SEP_TYPE = 'mstp'; -#endif // __MESSAGES_H +#endif // MESSAGES_H