* 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:
@@ -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 "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();
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
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
|
||||
|
||||
@@ -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 <NodeInfo.h>
|
||||
|
||||
// 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)
|
||||
{
|
||||
|
||||
@@ -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 <String.h>
|
||||
|
||||
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
|
||||
|
||||
@@ -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:
|
||||
* <unknown, please fill in who knows>
|
||||
* Vasilis Kaoutsis, [email protected]
|
||||
*/
|
||||
|
||||
|
||||
#include "ColorWindow.h"
|
||||
#include "msg.h"
|
||||
|
||||
#include <Application.h>
|
||||
#include <Button.h>
|
||||
#include <ColorControl.h>
|
||||
#include <Menu.h>
|
||||
|
||||
#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:
|
||||
|
||||
@@ -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:
|
||||
* <unknown, please fill in who knows>
|
||||
* Vasilis Kaoutsis, [email protected]
|
||||
*/
|
||||
#ifndef __COLORWINDOW_H
|
||||
#define __COLORWINDOW_H
|
||||
#ifndef COLOR_WINDOW_H
|
||||
#define COLOR_WINDOW_H
|
||||
|
||||
|
||||
#include <Menu.h>
|
||||
@@ -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
|
||||
|
||||
@@ -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 "MenuSettings.h"
|
||||
#include "msg.h"
|
||||
|
||||
#include <MenuItem.h>
|
||||
#include <Message.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <Message.h>
|
||||
#include <MenuItem.h>
|
||||
|
||||
FontMenu::FontMenu()
|
||||
: AutoSettingsMenu("Font", B_ITEMS_IN_COLUMN)
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
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
|
||||
|
||||
@@ -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 "MenuSettings.h"
|
||||
#include "msg.h"
|
||||
|
||||
#include <Message.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Message.h>
|
||||
#include <String.h>
|
||||
#include <Window.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:
|
||||
* <unknown, please fill in who knows>
|
||||
* Jack Burton
|
||||
* Vasilis Kaoutsis, [email protected]
|
||||
@@ -54,4 +54,3 @@ main(int, char**)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -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:
|
||||
* <unknown, please fill in who knows>
|
||||
* Jack Burton
|
||||
*/
|
||||
@@ -12,12 +12,13 @@
|
||||
|
||||
#include <Application.h>
|
||||
|
||||
|
||||
class MenuWindow;
|
||||
|
||||
|
||||
class MenuApp : public BApplication {
|
||||
public:
|
||||
MenuApp();
|
||||
|
||||
virtual void MessageReceived(BMessage* msg);
|
||||
|
||||
private:
|
||||
|
||||
@@ -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:
|
||||
* <unknown, please fill in who knows>
|
||||
* Vasilis Kaoutsis, [email protected]
|
||||
*/
|
||||
@@ -22,12 +22,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
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);
|
||||
|
||||
@@ -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>
|
||||
|
||||
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
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
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
|
||||
|
||||
@@ -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:
|
||||
* <unknown, please fill in who knows>
|
||||
* Vasilis Kaoutsis, [email protected]
|
||||
*/
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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:
|
||||
* <unknown, please fill in who knows>
|
||||
*/
|
||||
#ifndef __MENU_WINDOW_H
|
||||
#define __MENU_WINDOW_H
|
||||
#ifndef MENU_WINDOW_H
|
||||
#define MENU_WINDOW_H
|
||||
|
||||
|
||||
#include <Menu.h>
|
||||
@@ -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
|
||||
|
||||
+15
-15
@@ -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:
|
||||
* <unknown, please fill in who knows>
|
||||
* Vasilis Kaoutsis, [email protected]
|
||||
*/
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user