* 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
This commit is contained in:
Axel Dörfler
2006-12-22 11:05:17 +00:00
parent dace9db1ef
commit ce0998ad77
18 changed files with 339 additions and 265 deletions
+11 -2
View File
@@ -1,9 +1,18 @@
/*
* Copyright 2002-2006, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* <unknown, please fill in who knows>
*/
#include "AutoSettingsMenu.h" #include "AutoSettingsMenu.h"
#include "MenuSettings.h" #include "MenuSettings.h"
AutoSettingsMenu::AutoSettingsMenu(const char *name, menu_layout layout) AutoSettingsMenu::AutoSettingsMenu(const char *name, menu_layout layout)
: : BMenu(name, layout)
BMenu(name, layout)
{ {
} }
+16 -7
View File
@@ -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:
* <unknown, please fill in who knows>
*/
#ifndef AUTO_SETTINGS_MENU_H
#define AUTO_SETTINGS_MENU_H
#include <Menu.h> #include <Menu.h>
class AutoSettingsMenu : public BMenu { class AutoSettingsMenu : public BMenu {
public: public:
AutoSettingsMenu(const char *name, menu_layout layout); AutoSettingsMenu(const char* name, menu_layout layout);
virtual void AttachedToWindow();
virtual void AttachedToWindow();
}; };
#endif // AUTO_SETTINGS_MENU_H
#endif
+13 -6
View File
@@ -1,15 +1,22 @@
/*
* Copyright 2002-2006, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* <unknown, please fill in who knows>
*/
#include "BitmapMenuItem.h"
#include <Bitmap.h> #include <Bitmap.h>
#include <NodeInfo.h> #include <NodeInfo.h>
// Project Headers
#include "BitmapMenuItem.h"
// BitmapMenuItem class definition // BitmapMenuItem class definition
BitmapMenuItem::BitmapMenuItem(const char* name, BMessage* message, BitmapMenuItem::BitmapMenuItem(const char* name, BMessage* message,
BBitmap* bmp, char shortcut, uint32 modifiers) BBitmap* bmp, char shortcut, uint32 modifiers)
: : BMenuItem(name, message, shortcut, modifiers),
BMenuItem(name, message, shortcut, modifiers),
fBitmap(bmp), fBitmap(bmp),
fName(name) fName(name)
{ {
+23 -13
View File
@@ -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:
* <unknown, please fill in who knows>
*/
#ifndef BITMAP_MENU_ITEM_H
#define BITMAP_MENU_ITEM_H
#include <MenuItem.h> #include <MenuItem.h>
#include <String.h> #include <String.h>
class BBitmap; class BBitmap;
class BitmapMenuItem : public BMenuItem { class BitmapMenuItem : public BMenuItem {
public: public:
BitmapMenuItem(const char* name, BMessage* message, BBitmap* bmp, BitmapMenuItem(const char* name, BMessage* message, BBitmap* bmp,
char shortcut = 0, uint32 modifiers = 0); char shortcut = '\0', uint32 modifiers = 0);
~BitmapMenuItem(); ~BitmapMenuItem();
virtual void DrawContent(); virtual void DrawContent();
protected: protected:
virtual void GetContentSize(float *width, float *height); virtual void GetContentSize(float *width, float *height);
private: private:
BBitmap *fBitmap; BBitmap* fBitmap;
BString fName; BString fName;
}; };
#endif // _MBitmapMenuItem_h #endif // BITMAP_MENU_ITEM_H
+35 -35
View File
@@ -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. * Distributed under the terms of the MIT License.
* *
* Authors in chronological order: * Authors:
* <unknown, please fill in who knows> * <unknown, please fill in who knows>
* Vasilis Kaoutsis, [email protected] * Vasilis Kaoutsis, [email protected]
*/ */
#include "ColorWindow.h"
#include "msg.h"
#include <Application.h> #include <Application.h>
#include <Button.h> #include <Button.h>
#include <ColorControl.h> #include <ColorControl.h>
#include <Menu.h> #include <Menu.h>
#include "ColorWindow.h"
#include "msg.h"
ColorWindow::ColorWindow(BMessenger owner) 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), B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
fOwner(owner) fOwner(owner)
{ {
// Set and collect the variables for revert // Set and collect the variables for revert
get_menu_info(&info); get_menu_info(&fInfo);
get_menu_info(&revert_info); get_menu_info(&fRevertInfo);
BView *colView = new BView(BRect(0,0,1000,100), "menuView", BView *colView = new BView(BRect(0,0,1000,100), "menuView",
B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE); B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
colorPicker = new BColorControl(BPoint(10,10), B_CELLS_32x8, fColorControl = new BColorControl(BPoint(10,10), B_CELLS_32x8,
9, "COLOR", new BMessage(MENU_COLOR), true); 9, "COLOR", new BMessage(MENU_COLOR), true);
colorPicker->SetValue(info.background_color); fColorControl->SetValue(fInfo.background_color);
colView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); colView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
colView->AddChild(colorPicker); colView->AddChild(fColorControl);
AddChild(colView); AddChild(colView);
ResizeTo(383, 130); ResizeTo(383, 130);
// Create the buttons and add them to the view // 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, new BMessage(MENU_COLOR_DEFAULT), B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW | B_NAVIGABLE); B_WILL_DRAW | B_NAVIGABLE);
RevertButton = new BButton(BRect(95,100,175,20), "REVERT", "Revert", fRevertButton = new BButton(BRect(95,100,175,20), "REVERT", "Revert",
new BMessage(MENU_REVERT), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, 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(fDefaultButton);
colView->AddChild(RevertButton); colView->AddChild(fRevertButton);
DefaultButton->SetEnabled(false); fDefaultButton->SetEnabled(false);
RevertButton->SetEnabled(false); fRevertButton->SetEnabled(false);
} }
@@ -72,11 +72,11 @@ ColorWindow::MessageReceived(BMessage *msg)
{ {
switch (msg->what) { switch (msg->what) {
case MENU_REVERT: case MENU_REVERT:
colorPicker->SetValue(revert_info.background_color); fColorControl->SetValue(fRevertInfo.background_color);
info.background_color = colorPicker->ValueAsColor(); fInfo.background_color = fColorControl->ValueAsColor();
set_menu_info(&info); set_menu_info(&fInfo);
be_app->PostMessage(UPDATE_WINDOW); be_app->PostMessage(UPDATE_WINDOW);
RevertButton->SetEnabled(false); fRevertButton->SetEnabled(false);
break; break;
case MENU_COLOR_DEFAULT: case MENU_COLOR_DEFAULT:
@@ -87,22 +87,22 @@ ColorWindow::MessageReceived(BMessage *msg)
color.blue = 216; color.blue = 216;
color.green = 216; color.green = 216;
color.alpha = 255; color.alpha = 255;
colorPicker->SetValue(color); fColorControl->SetValue(color);
DefaultButton->SetEnabled(false); fDefaultButton->SetEnabled(false);
get_menu_info(&info); get_menu_info(&fInfo);
info.background_color = colorPicker->ValueAsColor(); fInfo.background_color = fColorControl->ValueAsColor();
set_menu_info(&info); set_menu_info(&fInfo);
be_app->PostMessage(MENU_COLOR); be_app->PostMessage(MENU_COLOR);
break; break;
case MENU_COLOR: case MENU_COLOR:
get_menu_info(&info); get_menu_info(&fInfo);
revert_info.background_color = info.background_color; fRevertInfo.background_color = fInfo.background_color;
info.background_color = colorPicker->ValueAsColor(); fInfo.background_color = fColorControl->ValueAsColor();
set_menu_info(&info); set_menu_info(&fInfo);
be_app->PostMessage(MENU_COLOR); be_app->PostMessage(MENU_COLOR);
DefaultButton->SetEnabled(true); fDefaultButton->SetEnabled(true);
RevertButton->SetEnabled(true); fRevertButton->SetEnabled(true);
break; break;
default: default:
+11 -11
View File
@@ -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. * Distributed under the terms of the MIT License.
* *
* Authors in chronological order: * Authors:
* <unknown, please fill in who knows> * <unknown, please fill in who knows>
* Vasilis Kaoutsis, [email protected] * Vasilis Kaoutsis, [email protected]
*/ */
#ifndef __COLORWINDOW_H #ifndef COLOR_WINDOW_H
#define __COLORWINDOW_H #define COLOR_WINDOW_H
#include <Menu.h> #include <Menu.h>
@@ -27,12 +27,12 @@ class ColorWindow : public BWindow {
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
private: private:
BColorControl *colorPicker; BColorControl* fColorControl;
BButton *DefaultButton; BButton* fDefaultButton;
BButton *RevertButton; BButton* fRevertButton;
menu_info revert_info; menu_info fRevertInfo;
menu_info info; menu_info fInfo;
BMessenger fOwner; BMessenger fOwner;
}; };
#endif // __COLORWINDOW_H #endif // COLOR_WINDOW_H
+12 -2
View File
@@ -1,11 +1,21 @@
/*
* Copyright 2002-2006, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* <unknown, please fill in who knows>
*/
#include "FontMenu.h" #include "FontMenu.h"
#include "MenuSettings.h" #include "MenuSettings.h"
#include "msg.h" #include "msg.h"
#include <MenuItem.h>
#include <Message.h>
#include <stdlib.h> #include <stdlib.h>
#include <Message.h>
#include <MenuItem.h>
FontMenu::FontMenu() FontMenu::FontMenu()
: AutoSettingsMenu("Font", B_ITEMS_IN_COLUMN) : AutoSettingsMenu("Font", B_ITEMS_IN_COLUMN)
+22 -12
View File
@@ -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:
* <unknown, please fill in who knows>
*/
#ifndef FONT_MENU_H
#define FONT_MENU_H
#include "AutoSettingsMenu.h" #include "AutoSettingsMenu.h"
class FontSizeMenu : public AutoSettingsMenu { class FontSizeMenu : public AutoSettingsMenu {
public: public:
FontSizeMenu(); FontSizeMenu();
virtual void AttachedToWindow(); virtual void AttachedToWindow();
}; };
class FontMenu : public AutoSettingsMenu { class FontMenu : public AutoSettingsMenu {
public: public:
FontMenu(); FontMenu();
virtual void AttachedToWindow();
void GetFonts();
status_t PlaceCheckMarkOnFont(font_family family, font_style style); virtual void AttachedToWindow();
void ClearAllMarkedItems(); void GetFonts();
status_t PlaceCheckMarkOnFont(font_family family, font_style style);
void ClearAllMarkedItems();
}; };
#endif #endif // FONT_MENU_H
+10 -1
View File
@@ -1,9 +1,18 @@
/*
* Copyright 2002-2006, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* <unknown, please fill in who knows>
*/
#include "FontMenu.h" #include "FontMenu.h"
#include "MenuSettings.h" #include "MenuSettings.h"
#include "msg.h" #include "msg.h"
#include <Message.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <Message.h>
#include <String.h> #include <String.h>
#include <Window.h> #include <Window.h>
+2 -3
View File
@@ -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. * Distributed under the terms of the MIT License.
* *
* Authors in chronological order: * Authors:
* <unknown, please fill in who knows> * <unknown, please fill in who knows>
* Jack Burton * Jack Burton
* Vasilis Kaoutsis, [email protected] * Vasilis Kaoutsis, [email protected]
@@ -54,4 +54,3 @@ main(int, char**)
return 0; return 0;
} }
+4 -3
View File
@@ -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. * Distributed under the terms of the MIT License.
* *
* Authors in chronological order: * Authors:
* <unknown, please fill in who knows> * <unknown, please fill in who knows>
* Jack Burton * Jack Burton
*/ */
@@ -12,12 +12,13 @@
#include <Application.h> #include <Application.h>
class MenuWindow; class MenuWindow;
class MenuApp : public BApplication { class MenuApp : public BApplication {
public: public:
MenuApp(); MenuApp();
virtual void MessageReceived(BMessage* msg); virtual void MessageReceived(BMessage* msg);
private: private:
+38 -45
View File
@@ -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. * Distributed under the terms of the MIT License.
* *
* Authors in chronological order: * Authors:
* <unknown, please fill in who knows> * <unknown, please fill in who knows>
* Vasilis Kaoutsis, [email protected] * Vasilis Kaoutsis, [email protected]
*/ */
@@ -22,12 +22,13 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
MenuBar::MenuBar() 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) B_ITEMS_IN_COLUMN, true)
{ {
build_menu(); _BuildMenu();
set_menu(); UpdateMenu();
SetItemMargins(14.0, 2.0, 20.0, 0.0); SetItemMargins(14.0, 2.0, 20.0, 0.0);
} }
@@ -41,27 +42,26 @@ MenuBar::AttachedToWindow()
void void
MenuBar::build_menu() MenuBar::_BuildMenu()
{ {
// font and font size menus // font and font size menus
fontMenu = new FontMenu(); BMenu* fontMenu = new FontMenu();
fontSizeMenu = new FontSizeMenu(); BMenu* fontSizeMenu = new FontSizeMenu();
// create the menu items // create the menu items
alwaysShowTriggersItem = new BMenuItem("Always Show Triggers", fAlwaysShowTriggersItem = new BMenuItem("Always Show Triggers",
new BMessage(ALLWAYS_TRIGGERS_MSG), 0, 0); new BMessage(ALLWAYS_TRIGGERS_MSG), 0, 0);
separatorStyleItem = new BMenuItem("Separator Style", fControlAsShortcutItem = new BitmapMenuItem("as Shortcut Key",
new BMessage(DEFAULT_MSG), 0, 0); new BMessage(CTL_MARKED_MSG), BTranslationUtils::GetBitmap(B_RAW_TYPE, "CTL"));
ctlAsShortcutItem = new BitmapMenuItem("as Shortcut Key", fAltAsShortcutItem = new BitmapMenuItem("as Shortcut Key",
new BMessage(CTL_MARKED_MSG), BTranslationUtils::GetBitmap(B_RAW_TYPE, "CTL")); new BMessage(ALT_MARKED_MSG), BTranslationUtils::GetBitmap(B_RAW_TYPE, "ALT"));
altAsShortcutItem = new BitmapMenuItem("as Shortcut Key",
new BMessage(ALT_MARKED_MSG), BTranslationUtils::GetBitmap(B_RAW_TYPE, "ALT"));
// color menu // 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 // 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); separatorStyleMenu->SetRadioMode(true);
BMessage *msg = new BMessage(MENU_SEP_TYPE); BMessage *msg = new BMessage(MENU_SEP_TYPE);
msg->AddInt32("sep", 0); msg->AddInt32("sep", 0);
@@ -83,35 +83,36 @@ MenuBar::build_menu()
AddItem(fontMenu, 0); AddItem(fontMenu, 0);
AddItem(fontSizeMenu, 1); AddItem(fontSizeMenu, 1);
AddSeparatorItem(); AddSeparatorItem();
AddItem(alwaysShowTriggersItem); AddItem(fAlwaysShowTriggersItem);
AddSeparatorItem(); AddSeparatorItem();
AddItem(colorSchemeItem); AddItem(colorSchemeItem);
AddItem(separatorStyleMenu); AddItem(separatorStyleMenu);
AddSeparatorItem(); AddSeparatorItem();
AddItem(ctlAsShortcutItem); AddItem(fControlAsShortcutItem);
AddItem(altAsShortcutItem); AddItem(fAltAsShortcutItem);
} }
void
MenuBar::set_menu()
{
key_map *keys;
char *chars;
bool altAsShortcut;
void
MenuBar::UpdateMenu()
{
menu_info info; menu_info info;
MenuSettings::GetInstance()->Get(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); get_key_map(&keys, &chars);
altAsShortcut = (keys->left_command_key == 0x5d) && (keys->right_command_key == 0x5f); bool altAsShortcut = (keys->left_command_key == 0x5d)
altAsShortcutItem->SetMarked(altAsShortcut); && (keys->right_command_key == 0x5f);
ctlAsShortcutItem->SetMarked(!altAsShortcut);
free(chars); free(chars);
free(keys); free(keys);
fAltAsShortcutItem->SetMarked(altAsShortcut);
fControlAsShortcutItem->SetMarked(!altAsShortcut);
if (info.separator == 0) if (info.separator == 0)
separatorStyleZero->SetMarked(true); separatorStyleZero->SetMarked(true);
@@ -125,21 +126,13 @@ MenuBar::set_menu()
void void
MenuBar::Update() MenuBar::Update()
{ {
menu_info info; UpdateMenu();
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();
BFont font; BFont font;
if (LockLooper()) { if (LockLooper()) {
menu_info info;
MenuSettings::GetInstance()->Get(info);
font.SetFamilyAndStyle(info.f_family, info.f_style); font.SetFamilyAndStyle(info.f_family, info.f_style);
font.SetSize(info.font_size); font.SetSize(info.font_size);
SetFont(&font); SetFont(&font);
+29 -26
View File
@@ -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:
* <unknown, please fill in who knows>
*/
#ifndef MENU_BAR_H
#define MENU_BAR_H
#include <MenuBar.h> #include <MenuBar.h>
class BMenuItem; class BMenuItem;
class FontMenu;
class FontSizeMenu;
class MenuBar : public BMenuBar { class MenuBar : public BMenuBar {
public: public:
MenuBar(); MenuBar();
virtual void AttachedToWindow();
void set_menu();
void build_menu();
void Update();
virtual void FrameResized(float width, float height);
private: virtual void AttachedToWindow();
//seperator submenu
BMenu *separatorStyleMenu;
BMenuItem *separatorStyleZero;
BMenuItem *separatorStyleOne;
BMenuItem *separatorStyleTwo;
//others void UpdateMenu();
FontMenu *fontMenu; void Update();
FontSizeMenu *fontSizeMenu; virtual void FrameResized(float width, float height);
BMenuItem *alwaysShowTriggersItem;
BMenuItem *colorSchemeItem; private:
BMenuItem *separatorStyleItem; void _BuildMenu();
BMenuItem *ctlAsShortcutItem;
BMenuItem *altAsShortcutItem; BMenuItem* separatorStyleZero;
BMenuItem* separatorStyleOne;
BMenuItem* separatorStyleTwo;
BMenuItem* fAlwaysShowTriggersItem;
BMenuItem* fControlAsShortcutItem;
BMenuItem* fAltAsShortcutItem;
}; };
#endif #endif // MENU_BAR_H
+9
View File
@@ -1,3 +1,12 @@
/*
* Copyright 2002-2006, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* <unknown, please fill in who knows>
*/
#include "MenuSettings.h" #include "MenuSettings.h"
+23 -15
View File
@@ -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:
* <unknown, please fill in who knows>
*/
#ifndef MENU_SETTINGS_H
#define MENU_SETTINGS_H
#include <Menu.h> #include <Menu.h>
class MenuSettings { class MenuSettings {
public: public:
static MenuSettings *GetInstance(); static MenuSettings *GetInstance();
void Get(menu_info &info) const; void Get(menu_info &info) const;
void Set(menu_info &info); void Set(menu_info &info);
void Revert(); void Revert();
void ResetToDefaults(); void ResetToDefaults();
private: private:
MenuSettings(); MenuSettings();
~MenuSettings(); ~MenuSettings();
menu_info fPreviousSettings; menu_info fPreviousSettings;
menu_info fDefaultSettings; menu_info fDefaultSettings;
}; };
#endif // MENU_SETTINGS_H
#endif
+41 -39
View File
@@ -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. * Distributed under the terms of the MIT License.
* *
* Authors in chronological order: * Authors:
* <unknown, please fill in who knows> * <unknown, please fill in who knows>
* Vasilis Kaoutsis, kaoutsis@sch.gr * Vasilis Kaoutsis, kaoutsis@sch.gr
*/ */
@@ -29,34 +29,36 @@ MenuWindow::MenuWindow(BRect rect)
: BWindow(rect, "Menu", B_TITLED_WINDOW, : BWindow(rect, "Menu", B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE) B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE)
{ {
colorWindow = NULL; fColorWindow = NULL;
revert = false; fRevert = false;
menuView = new BBox(Bounds(), "menuView", B_FOLLOW_ALL_SIDES, BView* topView = new BView(Bounds(), "menuView", B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER); B_WILL_DRAW);
AddChild(menuView); topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(topView);
menuBar = new MenuBar(); fMenuBar = new MenuBar();
menuView->AddChild(menuBar); topView->AddChild(fMenuBar);
// resize the window according to the size of menuBar // resize the window according to the size of fMenuBar
ResizeTo((menuBar->Frame().right + 40), (menuBar->Frame().bottom + 45)); ResizeTo(fMenuBar->Frame().right + 40, fMenuBar->Frame().bottom + 45);
BRect menuBarFrame = menuBar->Frame(); BRect menuBarFrame = fMenuBar->Frame();
BRect buttonFrame(menuBarFrame.left, menuBarFrame.bottom + 10, BRect buttonFrame(menuBarFrame.left, menuBarFrame.bottom + 10,
menuBarFrame.left + 75, menuBarFrame.bottom + 30); menuBarFrame.left + 75, menuBarFrame.bottom + 30);
defaultButton = new BButton(buttonFrame, "Default", "Defaults", new BMessage(MENU_DEFAULT), BButton* defaultButton = new BButton(buttonFrame, "Default", "Defaults",
B_FOLLOW_H_CENTER | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE); new BMessage(MENU_DEFAULT), B_FOLLOW_H_CENTER | B_FOLLOW_BOTTOM,
menuView->AddChild(defaultButton); B_WILL_DRAW | B_NAVIGABLE);
topView->AddChild(defaultButton);
buttonFrame.OffsetBy(buttonFrame.Width() + 20, 0); buttonFrame.OffsetBy(buttonFrame.Width() + 20, 0);
revertButton = new BButton(buttonFrame, "Revert", "Revert", new BMessage(MENU_REVERT), fRevertButton = new BButton(buttonFrame, "Revert", "Revert", new BMessage(MENU_REVERT),
B_FOLLOW_H_CENTER | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE); B_FOLLOW_H_CENTER | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE);
revertButton->SetEnabled(false); fRevertButton->SetEnabled(false);
menuView->AddChild(revertButton); topView->AddChild(fRevertButton);
menuView->MakeFocus(); topView->MakeFocus();
Update(); Update();
} }
@@ -75,13 +77,13 @@ MenuWindow::MessageReceived(BMessage *msg)
switch (msg->what) { switch (msg->what) {
case MENU_REVERT: case MENU_REVERT:
revert = false; fRevert = false;
settings->Revert(); settings->Revert();
Update(); Update();
break; break;
case MENU_DEFAULT: case MENU_DEFAULT:
revert = true; fRevert = true;
settings->ResetToDefaults(); settings->ResetToDefaults();
Update(); Update();
break; break;
@@ -93,7 +95,7 @@ MenuWindow::MessageReceived(BMessage *msg)
case MENU_FONT_FAMILY: case MENU_FONT_FAMILY:
case MENU_FONT_STYLE: case MENU_FONT_STYLE:
{ {
revert = true; fRevert = true;
font_family *family; font_family *family;
msg->FindPointer("family", (void**)&family); msg->FindPointer("family", (void**)&family);
font_style *style; font_style *style;
@@ -107,7 +109,7 @@ MenuWindow::MessageReceived(BMessage *msg)
} }
case MENU_FONT_SIZE: case MENU_FONT_SIZE:
revert = true; fRevert = true;
settings->Get(info); settings->Get(info);
msg->FindFloat("size", &info.font_size); msg->FindFloat("size", &info.font_size);
settings->Set(info); settings->Set(info);
@@ -115,7 +117,7 @@ MenuWindow::MessageReceived(BMessage *msg)
break; break;
case MENU_SEP_TYPE: case MENU_SEP_TYPE:
revert = true; fRevert = true;
settings->Get(info); settings->Get(info);
msg->FindInt32("sep", &info.separator); msg->FindInt32("sep", &info.separator);
settings->Set(info); settings->Set(info);
@@ -123,16 +125,16 @@ MenuWindow::MessageReceived(BMessage *msg)
break; break;
case ALLWAYS_TRIGGERS_MSG: case ALLWAYS_TRIGGERS_MSG:
revert = true; fRevert = true;
settings->Get(info); settings->Get(info);
info.triggers_always_shown = !info.triggers_always_shown; info.triggers_always_shown = !info.triggers_always_shown;
settings->Set(info); settings->Set(info);
menuBar->set_menu(); fMenuBar->UpdateMenu();
Update(); Update();
break; break;
case CTL_MARKED_MSG: case CTL_MARKED_MSG:
revert = true; fRevert = true;
// This might not be the same for all keyboards // This might not be the same for all keyboards
set_modifier_key(B_LEFT_COMMAND_KEY, 0x5c); set_modifier_key(B_LEFT_COMMAND_KEY, 0x5c);
set_modifier_key(B_RIGHT_COMMAND_KEY, 0x60); set_modifier_key(B_RIGHT_COMMAND_KEY, 0x60);
@@ -143,7 +145,7 @@ MenuWindow::MessageReceived(BMessage *msg)
break; break;
case ALT_MARKED_MSG: case ALT_MARKED_MSG:
revert = true; fRevert = true;
// This might not be the same for all keyboards // This might not be the same for all keyboards
set_modifier_key(B_LEFT_COMMAND_KEY, 0x5d); set_modifier_key(B_LEFT_COMMAND_KEY, 0x5d);
set_modifier_key(B_RIGHT_COMMAND_KEY, 0x5f); set_modifier_key(B_RIGHT_COMMAND_KEY, 0x5f);
@@ -155,19 +157,19 @@ MenuWindow::MessageReceived(BMessage *msg)
break; break;
case COLOR_SCHEME_OPEN_MSG: case COLOR_SCHEME_OPEN_MSG:
if (colorWindow == NULL) { if (fColorWindow == NULL) {
colorWindow = new ColorWindow(this); fColorWindow = new ColorWindow(this);
colorWindow->Show(); fColorWindow->Show();
} else } else
colorWindow->Activate(); fColorWindow->Activate();
break; break;
case COLOR_SCHEME_CLOSED_MSG: case COLOR_SCHEME_CLOSED_MSG:
colorWindow = NULL; fColorWindow = NULL;
break; break;
case MENU_COLOR: case MENU_COLOR:
revert = true; fRevert = true;
Update(); Update();
break; break;
@@ -181,9 +183,9 @@ MenuWindow::MessageReceived(BMessage *msg)
bool bool
MenuWindow::QuitRequested() MenuWindow::QuitRequested()
{ {
if (colorWindow != NULL && colorWindow->Lock()) { if (fColorWindow != NULL && fColorWindow->Lock()) {
colorWindow->Quit(); fColorWindow->Quit();
colorWindow = NULL; fColorWindow = NULL;
} }
return true; return true;
@@ -193,9 +195,9 @@ MenuWindow::QuitRequested()
void void
MenuWindow::Update() MenuWindow::Update()
{ {
revertButton->SetEnabled(revert); fRevertButton->SetEnabled(fRevert);
// alert the rest of the application to update // alert the rest of the application to update
menuBar->Update(); fMenuBar->Update();
} }
+10 -15
View File
@@ -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. * Distributed under the terms of the MIT License.
* *
* Authors in chronological order: * Authors:
* <unknown, please fill in who knows> * <unknown, please fill in who knows>
*/ */
#ifndef __MENU_WINDOW_H #ifndef MENU_WINDOW_H
#define __MENU_WINDOW_H #define MENU_WINDOW_H
#include <Menu.h> #include <Menu.h>
@@ -14,11 +14,10 @@
class ColorWindow; class ColorWindow;
class BMenuItem;
class BBox;
class BButton; class BButton;
class MenuBar; class MenuBar;
class MenuWindow : public BWindow { class MenuWindow : public BWindow {
public: public:
MenuWindow(BRect frame); MenuWindow(BRect frame);
@@ -31,14 +30,10 @@ class MenuWindow : public BWindow {
void Defaults(); void Defaults();
private: private:
bool revert; bool fRevert;
ColorWindow *colorWindow; ColorWindow* fColorWindow;
BMenuItem *toggleItem; MenuBar* fMenuBar;
BMenu *menu; BButton* fRevertButton;
MenuBar *menuBar;
BBox *menuView;
BButton *revertButton;
BButton *defaultButton;
}; };
#endif // __MENU_WINDOW_H #endif // MENU_WINDOW_H
+10 -10
View File
@@ -1,23 +1,23 @@
/* /*
* Copyright 2002-2006, Haiku. All rights reserved. * Copyright 2002-2006, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors in chronological order: * Authors:
* <unknown, please fill in who knows> * <unknown, please fill in who knows>
* Vasilis Kaoutsis, kaoutsis@sch.gr * Vasilis Kaoutsis, kaoutsis@sch.gr
*/ */
#ifndef __MESSAGES_H #ifndef MESSAGES_H
#define __MESSAGES_H #define MESSAGES_H
const uint32 MENU_BAR_ARCHIVE = 'mbar'; const uint32 MENU_BAR_ARCHIVE = 'mbar';
//default // default
const uint32 DEFAULT_MSG = 'dmsg'; const uint32 DEFAULT_MSG = 'dmsg';
const uint32 MENU_DEFAULT = 'mede'; const uint32 MENU_DEFAULT = 'mede';
const uint32 MENU_REVERT = 'mere'; const uint32 MENU_REVERT = 'mere';
//others // others
const uint32 UPDATE_WINDOW = 'uwin'; const uint32 UPDATE_WINDOW = 'uwin';
const uint32 ALLWAYS_TRIGGERS_MSG = 'alti'; const uint32 ALLWAYS_TRIGGERS_MSG = 'alti';
const uint32 COLOR_SCHEME_OPEN_MSG = 'coso'; const uint32 COLOR_SCHEME_OPEN_MSG = 'coso';
@@ -25,17 +25,17 @@ const uint32 COLOR_SCHEME_CLOSED_MSG = 'cosc';
const uint32 CTL_MARKED_MSG = 'ctms'; const uint32 CTL_MARKED_MSG = 'ctms';
const uint32 ALT_MARKED_MSG = 'alms'; const uint32 ALT_MARKED_MSG = 'alms';
//color // color
const uint32 MENU_COLOR = 'meco'; const uint32 MENU_COLOR = 'meco';
const uint32 CLICK_OPEN_MSG = 'clop'; const uint32 CLICK_OPEN_MSG = 'clop';
const uint32 MENU_COLOR_DEFAULT = 'mcod'; const uint32 MENU_COLOR_DEFAULT = 'mcod';
//font // font
const uint32 MENU_FONT_FAMILY = 'mffm'; const uint32 MENU_FONT_FAMILY = 'mffm';
const uint32 MENU_FONT_STYLE = 'mfst'; const uint32 MENU_FONT_STYLE = 'mfst';
const uint32 MENU_FONT_SIZE = 'mfsz'; const uint32 MENU_FONT_SIZE = 'mfsz';
//seperator // seperator
const uint32 MENU_SEP_TYPE = 'mstp'; const uint32 MENU_SEP_TYPE = 'mstp';
#endif // __MESSAGES_H #endif // MESSAGES_H