Restyled Menu preflet, it's still very ugly but at least I can

understand where's things.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16611 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2006-03-06 17:15:16 +00:00
parent 9f6376a0c7
commit b820da1a25
13 changed files with 750 additions and 740 deletions
-20
View File
@@ -1,20 +0,0 @@
#include "MenuApp.h"
ColorPicker::ColorPicker()
:BColorControl(BPoint(10,10), B_CELLS_32x8,
9, "COLOR", new BMessage(MENU_COLOR), true)
{
menu_info info;
get_menu_info(&info);
SetValue(info.background_color);
}
ColorPicker::~ColorPicker()
{}
void
ColorPicker::MessageReceived(BMessage *msg){
switch(msg->what) {
}
}
+9 -4
View File
@@ -1,5 +1,10 @@
#include <Application.h>
#include <Button.h>
#include <ColorControl.h>
#include <Menu.h>
#include "MenuApp.h"
#include "ColorWindow.h"
#include "msg.h"
ColorWindow::ColorWindow()
: BWindow(BRect(150,150,350,200), "Menu Color Scheme", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
@@ -11,7 +16,9 @@
BView *colView = new BView(BRect(0,0,1000,100), "menuView",
B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
colorPicker = new ColorPicker();
colorPicker = new BColorControl(BPoint(10,10), B_CELLS_32x8,
9, "COLOR", new BMessage(MENU_COLOR), true);
colorPicker->SetValue(info.background_color);
colView->SetViewColor(219,219,219,255);
colView->AddChild(colorPicker);
AddChild(colView);
@@ -28,8 +35,6 @@
colView->AddChild(RevertButton);
}
ColorWindow::~ColorWindow()
{}
void
ColorWindow::MessageReceived(BMessage *msg)
+21
View File
@@ -0,0 +1,21 @@
#ifndef __COLORWINDOW_H
#define __COLORWINDOW_H
#include <Menu.h>
#include <Window.h>
class BColorControl;
class BButton;
class ColorWindow : public BWindow {
public:
ColorWindow();
virtual void MessageReceived(BMessage *msg);
BColorControl *colorPicker;
BButton *DefaultButton;
BButton *RevertButton;
menu_info revert_info;
menu_info info;
};
#endif
+6 -9
View File
@@ -1,7 +1,11 @@
#include "FontMenu.h"
#include "msg.h"
#include "MenuApp.h"
#include <stdlib.h>
#include <Message.h>
#include <MenuItem.h>
FontMenu::FontMenu()
: BMenu("Font", B_ITEMS_IN_COLUMN)
{
@@ -10,9 +14,6 @@
GetFonts();
}
FontMenu::~FontMenu()
{ /*nothing to clean up*/}
void
FontMenu::GetFonts()
{
@@ -62,7 +63,6 @@
SetFont(&font);
SetViewColor(info.background_color);
InvalidateLayout();
// font style menus
for (int i = 0; i < CountItems(); i++) {
ItemAt(i)->Submenu()->SetFont(&font);
@@ -80,7 +80,6 @@
BMenu *styleMenu;
fontFamilyItem = FindItem(family);
if ((fontFamilyItem != NULL) && (family != NULL))
{
fontFamilyItem->SetMarked(true);
@@ -89,7 +88,6 @@
if ((styleMenu != NULL) && (style != NULL))
{
fontStyleItem = styleMenu->FindItem(style);
if (fontStyleItem != NULL)
{
fontStyleItem->SetMarked(true);
@@ -102,10 +100,10 @@
else
return B_ERROR;
return B_OK;
}
void
FontMenu::ClearAllMarkedItems()
{
@@ -118,5 +116,4 @@
submenu->ItemAt(j)->SetMarked(false);
}
}
}
+37
View File
@@ -0,0 +1,37 @@
#ifndef __FONTMENU_H
#define __FONTMENU_H
#include <Menu.h>
class FontSizeMenu : public BMenu {
public:
FontSizeMenu();
virtual void Update();
private:
menu_info info;
BMenuItem *fontSizeNine;
BMenuItem *fontSizeTen;
BMenuItem *fontSizeEleven;
BMenuItem *fontSizeTwelve;
BMenuItem *fontSizeFourteen;
BMenuItem *fontSizeEighteen;
};
class FontMenu : public BMenu {
public:
FontMenu();
virtual void GetFonts();
virtual void Update();
virtual status_t PlaceCheckMarkOnFont(font_family family, font_style style);
virtual void ClearAllMarkedItems();
private:
menu_info info;
BMenuItem *fontFamily;
BMenu *fontStyleMenu;
BMenuItem *fontStyleItem;
};
#endif
+5 -3
View File
@@ -1,5 +1,9 @@
#include "FontMenu.h"
#include "msg.h"
#include "MenuApp.h"
#include <Message.h>
#include <MenuItem.h>
#include <Window.h>
FontSizeMenu::FontSizeMenu()
:BMenu("Font Size", B_ITEMS_IN_COLUMN)
@@ -46,8 +50,6 @@
SetRadioMode(true);
}
FontSizeMenu::~FontSizeMenu()
{ }
void
FontSizeMenu::Update()
-1
View File
@@ -2,7 +2,6 @@ SubDir HAIKU_TOP src preferences menu ;
Preference Menu :
BitmapMenuItem.cpp
ColorPicker.cpp
ColorWindow.cpp
FontMenu.cpp
FontSizeMenu.cpp
+14 -17
View File
@@ -1,5 +1,6 @@
#include "MenuApp.h"
#include "MenuWindow.h"
#include "msg.h"
MenuApp::MenuApp()
: BApplication("application/x-vnd.Be-GGUI")
@@ -11,14 +12,6 @@
menuWindow->Show();
}
MenuApp::~MenuApp()
{/*nothing to clean up*/}
bool
MenuApp::QuitRequested()
{
return true;
}
void
MenuApp::Update()
@@ -26,15 +19,10 @@
menuWindow->Update();
}
int main()
{
new MenuApp();
be_app -> Run();
delete be_app;
}
void
MenuApp::MessageReceived(BMessage *msg){
MenuApp::MessageReceived(BMessage *msg)
{
switch(msg->what) {
//others
@@ -49,7 +37,16 @@
break;
default:
BMessage(msg);
BApplication::MessageReceived(msg);
break;
}
}
int main()
{
new MenuApp();
be_app->Run();
delete be_app;
}
+5 -118
View File
@@ -1,130 +1,17 @@
#ifndef __MENU_APP_H
#define __MENU_APP_H
#include <Application.h>
#include <Button.h>
#include <ColorControl.h>
#include <Window.h>
#include <Box.h>
#include <Alert.h>
#include <Menu.h>
#include <MenuBar.h>
#include <MenuItem.h>
#include "BitmapMenuItem.h"
#ifndef MENU_H
#define MENU_H
#include "msg.h"
class FontSizeMenu : public BMenu {
public:
FontSizeMenu();
virtual ~FontSizeMenu();
virtual void Update();
menu_info info;
BMenuItem *fontSizeNine;
BMenuItem *fontSizeTen;
BMenuItem *fontSizeEleven;
BMenuItem *fontSizeTwelve;
BMenuItem *fontSizeFourteen;
BMenuItem *fontSizeEighteen;
};
class FontMenu : public BMenu {
public:
FontMenu();
virtual ~FontMenu();
virtual void GetFonts();
virtual void Update();
virtual status_t PlaceCheckMarkOnFont(font_family family, font_style style);
virtual void ClearAllMarkedItems();
menu_info info;
BMenuItem *fontFamily;
BMenu *fontStyleMenu;
BMenuItem *fontStyleItem;
};
class MenuBar : public BMenuBar {
public:
MenuBar();
void set_menu();
void build_menu();
virtual void Update();
virtual void FrameResized(float width, float height);
BRect menu_rect;
BRect rect;
menu_info info;
//seperator submenu
BMenu *separatorStyleMenu;
BMenuItem *separatorStyleZero;
BMenuItem *separatorStyleOne;
BMenuItem *separatorStyleTwo;
//others
FontMenu *fontMenu;
FontSizeMenu *fontSizeMenu;
BMenuItem *clickToOpenItem;
BMenuItem *alwaysShowTriggersItem;
BMenuItem *colorSchemeItem;
BMenuItem *separatorStyleItem;
BMenuItem *ctlAsShortcutItem;
BMenuItem *altAsShortcutItem;
};
class ColorPicker : public BColorControl {
public:
ColorPicker();
virtual ~ColorPicker();
virtual void MessageReceived(BMessage *msg);
};
class ColorWindow : public BWindow {
public:
ColorWindow();
virtual ~ColorWindow();
virtual void MessageReceived(BMessage *msg);
ColorPicker *colorPicker;
BButton *DefaultButton;
BButton *RevertButton;
menu_info revert_info;
menu_info info;
};
class MenuWindow : public BWindow {
public:
MenuWindow();
virtual ~MenuWindow();
virtual void MessageReceived(BMessage *msg);
virtual bool QuitRequested();
virtual void Update();
void Defaults();
bool revert;
ColorWindow *colorWindow;
BMenuItem *toggleItem;
menu_info info;
menu_info revert_info;
BRect rect;
BMenu *menu;
MenuBar *menuBar;
BBox *menuView;
BButton *revertButton;
BButton *defaultButton;
};
class MenuWindow;
class MenuApp : public BApplication {
public:
MenuApp();
virtual ~MenuApp();
virtual void Update();
virtual void MessageReceived(BMessage *msg);
virtual bool QuitRequested();
//main
private:
MenuWindow *menuWindow;
BRect rect;
menu_info info;
+9 -6
View File
@@ -1,8 +1,12 @@
#include "MenuApp.h"
#include "BitmapMenuItem.h"
#include "FontMenu.h"
#include "MenuBar.h"
#include "msg.h"
#include <Application.h>
#include <Resources.h>
#include <TranslationUtils.h>
#include <Window.h>
#include <stdio.h>
#include <stdlib.h>
@@ -85,7 +89,6 @@
get_menu_info(&info);
alwaysShowTriggersItem->SetMarked(info.triggers_always_shown);
clickToOpenItem->SetMarked(info.click_to_open);
alwaysShowTriggersItem->SetEnabled(info.click_to_open);
@@ -99,16 +102,15 @@
free(keys);
}
void
MenuBar::Update()
{
// get up-to-date menu info
get_menu_info(&info);
// update submenus
fontMenu->Update();
fontSizeMenu->Update();
// this needs to be updated in case the Defaults
// were requested.
if (info.separator == 0)
@@ -117,7 +119,6 @@
separatorStyleOne->SetMarked(true);
else if (info.separator == 2)
separatorStyleTwo->SetMarked(true);
set_menu();
BFont font;
@@ -132,7 +133,9 @@
InvalidateLayout();
}
void MenuBar::FrameResized(float width, float height)
void
MenuBar::FrameResized(float width, float height)
{
Window()->PostMessage(UPDATE_WINDOW);
}
+39
View File
@@ -0,0 +1,39 @@
#ifndef __BARMENU_H
#define __BARMENU_H
#include <MenuBar.h>
class BMenuItem;
class FontMenu;
class FontSizeMenu;
class MenuBar : public BMenuBar {
public:
MenuBar();
void set_menu();
void build_menu();
virtual void Update();
virtual void FrameResized(float width, float height);
BRect menu_rect;
BRect rect;
menu_info info;
//seperator submenu
BMenu *separatorStyleMenu;
BMenuItem *separatorStyleZero;
BMenuItem *separatorStyleOne;
BMenuItem *separatorStyleTwo;
//others
FontMenu *fontMenu;
FontSizeMenu *fontSizeMenu;
BMenuItem *clickToOpenItem;
BMenuItem *alwaysShowTriggersItem;
BMenuItem *colorSchemeItem;
BMenuItem *separatorStyleItem;
BMenuItem *ctlAsShortcutItem;
BMenuItem *altAsShortcutItem;
};
#endif
+14 -5
View File
@@ -1,6 +1,16 @@
#include "ColorWindow.h"
#include "MenuApp.h"
#include "MenuBar.h"
#include "MenuWindow.h"
#include "msg.h"
#include <stdio.h>
#include <string.h>
#include <Alert.h>
#include <Box.h>
#include <Button.h>
#include <MenuItem.h>
#include <Roster.h>
MenuWindow::MenuWindow()
@@ -12,7 +22,6 @@
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);
AddChild(menuView);
@@ -34,8 +43,6 @@
}
MenuWindow::~MenuWindow()
{/*nothing to delete;*/}
void
MenuWindow::MessageReceived(BMessage *msg)
@@ -119,7 +126,6 @@
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;
@@ -154,13 +160,15 @@
}
}
bool
MenuWindow::QuitRequested()
{
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
return BWindow::QuitRequested();
}
void
MenuWindow::Update()
{
@@ -173,6 +181,7 @@
ResizeTo((menuBar->Frame().right + 35), (menuBar->Frame().bottom + 45));
}
void
MenuWindow::Defaults()
{
+34
View File
@@ -0,0 +1,34 @@
#ifndef __MENU_WINDOW_H
#define __MENU_WINDOW_H
#include <Window.h>
class ColorWindow;
class BMenuItem;
class BMenu;
class BBox;
class BButton;
class MenuBar;
class MenuWindow : public BWindow {
public:
MenuWindow();
virtual void MessageReceived(BMessage *msg);
virtual bool QuitRequested();
virtual void Update();
void Defaults();
private:
bool revert;
ColorWindow *colorWindow;
BMenuItem *toggleItem;
menu_info info;
menu_info revert_info;
BRect rect;
BMenu *menu;
MenuBar *menuBar;
BBox *menuView;
BButton *revertButton;
BButton *defaultButton;
};
#endif