The menu window's rect was never initialized, it worked by pure luck if launched from the terminal. Fixes bug 263. Other changes. Not yet finished
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16634 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
33cec98da1
commit
8edede9f83
@ -5,8 +5,6 @@
|
||||
#include <String.h>
|
||||
|
||||
class BBitmap;
|
||||
|
||||
// MBitmapMenuItem class declaration
|
||||
class BitmapMenuItem : public BMenuItem {
|
||||
public:
|
||||
BitmapMenuItem(const char* name, BMessage* message, BBitmap* bmp,
|
||||
|
@ -40,34 +40,33 @@ void
|
||||
ColorWindow::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch(msg->what) {
|
||||
|
||||
case MENU_REVERT:
|
||||
colorPicker->SetValue(revert_info.background_color);
|
||||
info.background_color = colorPicker->ValueAsColor();
|
||||
set_menu_info(&info);
|
||||
be_app->PostMessage(UPDATE_WINDOW);
|
||||
break;
|
||||
case MENU_REVERT:
|
||||
colorPicker->SetValue(revert_info.background_color);
|
||||
info.background_color = colorPicker->ValueAsColor();
|
||||
set_menu_info(&info);
|
||||
be_app->PostMessage(UPDATE_WINDOW);
|
||||
break;
|
||||
|
||||
case MENU_COLOR_DEFAULT:
|
||||
// change to system color for system wide
|
||||
// compatability
|
||||
rgb_color color;
|
||||
color.red = 219;
|
||||
color.blue = 219;
|
||||
color.green = 219;
|
||||
color.alpha = 255;
|
||||
colorPicker->SetValue(color);
|
||||
|
||||
case MENU_COLOR:{
|
||||
get_menu_info(&info);
|
||||
info.background_color = colorPicker->ValueAsColor();
|
||||
set_menu_info(&info);
|
||||
be_app->PostMessage(UPDATE_WINDOW);
|
||||
break;}
|
||||
|
||||
default:
|
||||
be_app->PostMessage(UPDATE_WINDOW);
|
||||
BMessage(msg);
|
||||
break;
|
||||
case MENU_COLOR_DEFAULT:
|
||||
// change to system color for system wide
|
||||
// compatability
|
||||
rgb_color color;
|
||||
color.red = 219;
|
||||
color.blue = 219;
|
||||
color.green = 219;
|
||||
color.alpha = 255;
|
||||
colorPicker->SetValue(color);
|
||||
|
||||
case MENU_COLOR:
|
||||
get_menu_info(&info);
|
||||
info.background_color = colorPicker->ValueAsColor();
|
||||
set_menu_info(&info);
|
||||
be_app->PostMessage(UPDATE_WINDOW);
|
||||
break;
|
||||
|
||||
default:
|
||||
be_app->PostMessage(UPDATE_WINDOW);
|
||||
BWindow::MessageReceived(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,11 @@
|
||||
class BColorControl;
|
||||
class BButton;
|
||||
class ColorWindow : public BWindow {
|
||||
public:
|
||||
public:
|
||||
ColorWindow();
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
|
||||
|
||||
private:
|
||||
BColorControl *colorPicker;
|
||||
BButton *DefaultButton;
|
||||
BButton *RevertButton;
|
||||
|
@ -5,18 +5,8 @@
|
||||
MenuApp::MenuApp()
|
||||
: BApplication("application/x-vnd.Be-GGUI")
|
||||
{
|
||||
get_menu_info(&info);
|
||||
|
||||
menuWindow = new MenuWindow();
|
||||
Update();
|
||||
menuWindow->Show();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MenuApp::Update()
|
||||
{
|
||||
menuWindow->Update();
|
||||
fMenuWindow = new MenuWindow(BRect(100, 100, 400, 300));
|
||||
fMenuWindow->Show();
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +14,6 @@ void
|
||||
MenuApp::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch(msg->what) {
|
||||
|
||||
//others
|
||||
case UPDATE_WINDOW:
|
||||
case CLICK_OPEN_MSG:
|
||||
@ -33,7 +22,7 @@ MenuApp::MessageReceived(BMessage *msg)
|
||||
case ALT_MARKED_MSG:
|
||||
case COLOR_SCHEME_MSG:
|
||||
case MENU_COLOR:
|
||||
menuWindow->PostMessage(msg);
|
||||
fMenuWindow->PostMessage(msg);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -2,20 +2,15 @@
|
||||
#define __MENU_APP_H
|
||||
|
||||
#include <Application.h>
|
||||
#include <Menu.h>
|
||||
|
||||
class MenuWindow;
|
||||
class MenuApp : public BApplication {
|
||||
public:
|
||||
MenuApp();
|
||||
virtual void Update();
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
|
||||
private:
|
||||
MenuWindow *menuWindow;
|
||||
BRect rect;
|
||||
menu_info info;
|
||||
BMenu *menu;
|
||||
MenuWindow *fMenuWindow;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -44,14 +44,14 @@ MenuBar::build_menu()
|
||||
separatorStyleMenu->SetRadioMode(true);
|
||||
BMessage *msg = new BMessage(MENU_SEP_TYPE);
|
||||
msg->AddInt32("sep", 0);
|
||||
separatorStyleZero = new BitmapMenuItem(" ", msg,
|
||||
separatorStyleZero = new BitmapMenuItem("separator0", msg,
|
||||
BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP0"));
|
||||
msg = new BMessage(MENU_SEP_TYPE);
|
||||
msg->AddInt32("sep", 1);
|
||||
separatorStyleOne = new BitmapMenuItem("", msg, BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP1"));
|
||||
separatorStyleOne = new BitmapMenuItem("separator1", msg, BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP1"));
|
||||
msg = new BMessage(MENU_SEP_TYPE);
|
||||
msg->AddInt32("sep", 2);
|
||||
separatorStyleTwo = new BitmapMenuItem("", msg, BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP2"));
|
||||
separatorStyleTwo = new BitmapMenuItem("separator2", msg, BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP2"));
|
||||
if (info.separator == 0)
|
||||
separatorStyleZero->SetMarked(true);
|
||||
if (info.separator == 1)
|
||||
@ -119,7 +119,8 @@ MenuBar::Update()
|
||||
separatorStyleOne->SetMarked(true);
|
||||
else if (info.separator == 2)
|
||||
separatorStyleTwo->SetMarked(true);
|
||||
set_menu();
|
||||
|
||||
set_menu();
|
||||
|
||||
BFont font;
|
||||
Window()->Lock();
|
||||
|
@ -13,34 +13,41 @@
|
||||
#include <MenuItem.h>
|
||||
#include <Roster.h>
|
||||
|
||||
MenuWindow::MenuWindow()
|
||||
: BWindow(rect, "Menu", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
|
||||
MenuWindow::MenuWindow(BRect rect)
|
||||
: BWindow(rect, "Menu", B_TITLED_WINDOW,
|
||||
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE)
|
||||
{
|
||||
get_menu_info(&revert_info);
|
||||
get_menu_info(&info);
|
||||
|
||||
revert = false;
|
||||
|
||||
MoveTo((rect.left += 100),(rect.top += 100));
|
||||
menuView = new BBox(Bounds(), "menuView", B_FOLLOW_ALL_SIDES,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
|
||||
menuView = new BBox(Bounds(), "menuView", B_FOLLOW_ALL_SIDES,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
|
||||
AddChild(menuView);
|
||||
|
||||
menuBar = new MenuBar();
|
||||
menuView->AddChild(menuBar);
|
||||
defaultButton = new BButton(BRect(10,0,85,20), "Default", "Defaults",
|
||||
new BMessage(MENU_DEFAULT), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE);
|
||||
revertButton = new BButton(BRect(95,0,175,20), "Revert", "Revert",
|
||||
new BMessage(MENU_REVERT), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE);
|
||||
revertButton->SetEnabled(false);
|
||||
|
||||
// resize the window according to the size of menuBar
|
||||
ResizeTo((menuBar->Frame().right + 35), (menuBar->Frame().bottom + 45));
|
||||
|
||||
BRect menuBarFrame = menuBar->Frame();
|
||||
BRect buttonFrame(menuBarFrame.left, menuBarFrame.bottom + 10, menuBarFrame.left + 75, menuBarFrame.bottom + 30);
|
||||
|
||||
defaultButton = new BButton(buttonFrame, "Default", "Defaults", new BMessage(MENU_DEFAULT),
|
||||
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE);
|
||||
menuView->AddChild(defaultButton);
|
||||
|
||||
buttonFrame.OffsetBy(buttonFrame.Width() + 20, 0);
|
||||
revertButton = new BButton(buttonFrame, "Revert", "Revert", new BMessage(MENU_REVERT),
|
||||
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_NAVIGABLE);
|
||||
revertButton->SetEnabled(false);
|
||||
menuView->AddChild(revertButton);
|
||||
|
||||
menuView->MakeFocus();
|
||||
|
||||
Update();
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
@ -48,124 +55,115 @@ void
|
||||
MenuWindow::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch(msg->what) {
|
||||
|
||||
case MENU_REVERT:
|
||||
set_menu_info(&revert_info);
|
||||
revert = false;
|
||||
Update();
|
||||
break;
|
||||
case MENU_REVERT:
|
||||
set_menu_info(&revert_info);
|
||||
revert = false;
|
||||
Update();
|
||||
break;
|
||||
|
||||
case MENU_DEFAULT:
|
||||
Defaults();
|
||||
break;
|
||||
|
||||
case UPDATE_WINDOW:
|
||||
Update();
|
||||
break;
|
||||
|
||||
case MENU_DEFAULT:
|
||||
Defaults();
|
||||
break;
|
||||
case MENU_FONT_FAMILY:
|
||||
case MENU_FONT_STYLE:
|
||||
{
|
||||
font_family *family;
|
||||
msg->FindPointer("family", (void**)&family);
|
||||
font_style *style;
|
||||
msg->FindPointer("style", (void**)&style);
|
||||
memcpy(info.f_family, family, sizeof(info.f_family));
|
||||
memcpy(info.f_style, style, sizeof(info.f_style));
|
||||
set_menu_info(&info);
|
||||
Update();
|
||||
break;
|
||||
}
|
||||
|
||||
case UPDATE_WINDOW:
|
||||
Update();
|
||||
break;
|
||||
|
||||
case MENU_FONT_FAMILY:
|
||||
case MENU_FONT_STYLE:
|
||||
{
|
||||
font_family *family;
|
||||
msg->FindPointer("family", (void**)&family);
|
||||
font_style *style;
|
||||
msg->FindPointer("style", (void**)&style);
|
||||
memcpy(info.f_family, family, sizeof(info.f_family));
|
||||
memcpy(info.f_style, style, sizeof(info.f_style));
|
||||
set_menu_info(&info);
|
||||
Update();
|
||||
break;
|
||||
case MENU_FONT_SIZE:
|
||||
revert = true;
|
||||
float fontSize;
|
||||
msg->FindFloat("size", &fontSize);
|
||||
info.font_size = fontSize;
|
||||
set_menu_info(&info);
|
||||
Update();
|
||||
break;
|
||||
|
||||
case MENU_SEP_TYPE:
|
||||
revert = true;
|
||||
int32 i;
|
||||
msg->FindInt32("sep", &i);
|
||||
info.separator = i;
|
||||
set_menu_info(&info);
|
||||
Update();
|
||||
break;
|
||||
|
||||
case CLICK_OPEN_MSG:
|
||||
revert = true;
|
||||
if (info.click_to_open != true)
|
||||
info.click_to_open = true;
|
||||
else
|
||||
info.click_to_open = false;
|
||||
set_menu_info(&info);
|
||||
menuBar->set_menu();
|
||||
Update();
|
||||
break;
|
||||
|
||||
case ALLWAYS_TRIGGERS_MSG:
|
||||
revert = true;
|
||||
if (info.triggers_always_shown != true)
|
||||
info.triggers_always_shown = true;
|
||||
else
|
||||
info.triggers_always_shown = false;
|
||||
set_menu_info(&info);
|
||||
menuBar->set_menu();
|
||||
Update();
|
||||
break;
|
||||
|
||||
case CTL_MARKED_MSG:
|
||||
revert = true;
|
||||
menuBar->ctlAsShortcutItem->SetMarked(true);
|
||||
menuBar->altAsShortcutItem->SetMarked(false);
|
||||
// This might not be the same for all keyboards
|
||||
set_modifier_key(B_LEFT_COMMAND_KEY, 0x5c);
|
||||
set_modifier_key(B_RIGHT_COMMAND_KEY, 0x60);
|
||||
set_modifier_key(B_LEFT_CONTROL_KEY, 0x5d);
|
||||
set_modifier_key(B_RIGHT_OPTION_KEY, 0x5f);
|
||||
be_roster->Broadcast(new BMessage(B_MODIFIERS_CHANGED));
|
||||
Update();
|
||||
break;
|
||||
|
||||
case ALT_MARKED_MSG:
|
||||
revert = true;
|
||||
menuBar->altAsShortcutItem->SetMarked(true);
|
||||
menuBar->ctlAsShortcutItem->SetMarked(false);
|
||||
// This might not be the same for all keyboards
|
||||
set_modifier_key(B_LEFT_COMMAND_KEY, 0x5d);
|
||||
set_modifier_key(B_RIGHT_COMMAND_KEY, 0x5f);
|
||||
set_modifier_key(B_LEFT_CONTROL_KEY, 0x5c);
|
||||
set_modifier_key(B_RIGHT_OPTION_KEY, 0x60);
|
||||
|
||||
be_roster->Broadcast(new BMessage(B_MODIFIERS_CHANGED));
|
||||
Update();
|
||||
break;
|
||||
|
||||
case COLOR_SCHEME_MSG:
|
||||
colorWindow = new ColorWindow();
|
||||
colorWindow->Show();
|
||||
break;
|
||||
|
||||
case MENU_COLOR:
|
||||
set_menu_info(&info);
|
||||
(new BAlert("test","we made it","cool"))->Go();
|
||||
break;
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
case MENU_FONT_SIZE:
|
||||
revert = true;
|
||||
float f;
|
||||
msg->FindFloat("size", &f);
|
||||
info.font_size = f;
|
||||
set_menu_info(&info);
|
||||
Update();
|
||||
break;
|
||||
|
||||
case MENU_SEP_TYPE:
|
||||
revert = true;
|
||||
int32 i;
|
||||
msg->FindInt32("sep", &i);
|
||||
info.separator = i;
|
||||
set_menu_info(&info);
|
||||
Update();
|
||||
break;
|
||||
|
||||
case CLICK_OPEN_MSG:
|
||||
revert = true;
|
||||
if (info.click_to_open != true)
|
||||
info.click_to_open = true;
|
||||
else
|
||||
info.click_to_open = false;
|
||||
set_menu_info(&info);
|
||||
menuBar->set_menu();
|
||||
Update();
|
||||
break;
|
||||
|
||||
case ALLWAYS_TRIGGERS_MSG:
|
||||
revert = true;
|
||||
if (info.triggers_always_shown != true)
|
||||
info.triggers_always_shown = true;
|
||||
else
|
||||
info.triggers_always_shown = false;
|
||||
set_menu_info(&info);
|
||||
menuBar->set_menu();
|
||||
Update();
|
||||
break;
|
||||
|
||||
case CTL_MARKED_MSG:
|
||||
revert = true;
|
||||
menuBar->ctlAsShortcutItem->SetMarked(true);
|
||||
menuBar->altAsShortcutItem->SetMarked(false);
|
||||
// This might not be the same for all keyboards
|
||||
set_modifier_key(B_LEFT_COMMAND_KEY, 0x5c);
|
||||
set_modifier_key(B_RIGHT_COMMAND_KEY, 0x60);
|
||||
set_modifier_key(B_LEFT_CONTROL_KEY, 0x5d);
|
||||
set_modifier_key(B_RIGHT_OPTION_KEY, 0x5f);
|
||||
be_roster->Broadcast(new BMessage(B_MODIFIERS_CHANGED));
|
||||
Update();
|
||||
break;
|
||||
|
||||
case ALT_MARKED_MSG:
|
||||
revert = true;
|
||||
menuBar->altAsShortcutItem->SetMarked(true);
|
||||
menuBar->ctlAsShortcutItem->SetMarked(false);
|
||||
// This might not be the same for all keyboards
|
||||
set_modifier_key(B_LEFT_COMMAND_KEY, 0x5d);
|
||||
set_modifier_key(B_RIGHT_COMMAND_KEY, 0x5f);
|
||||
set_modifier_key(B_LEFT_CONTROL_KEY, 0x5c);
|
||||
set_modifier_key(B_RIGHT_OPTION_KEY, 0x60);
|
||||
|
||||
be_roster->Broadcast(new BMessage(B_MODIFIERS_CHANGED));
|
||||
Update();
|
||||
break;
|
||||
|
||||
case COLOR_SCHEME_MSG:
|
||||
colorWindow = new ColorWindow();
|
||||
colorWindow->Show();
|
||||
break;
|
||||
|
||||
case MENU_COLOR:
|
||||
set_menu_info(&info);
|
||||
(new BAlert("test","we made it","cool"))->Go();
|
||||
break;
|
||||
|
||||
default:
|
||||
BMessage(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
MenuWindow::QuitRequested()
|
||||
{
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return BWindow::QuitRequested();
|
||||
}
|
||||
|
||||
|
||||
@ -176,9 +174,6 @@ MenuWindow::Update()
|
||||
|
||||
// alert the rest of the application to update
|
||||
menuBar->Update();
|
||||
|
||||
// resize the window according to the size of menuBar
|
||||
ResizeTo((menuBar->Frame().right + 35), (menuBar->Frame().bottom + 45));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,19 +1,18 @@
|
||||
#ifndef __MENU_WINDOW_H
|
||||
#define __MENU_WINDOW_H
|
||||
|
||||
#include <Menu.h>
|
||||
#include <Window.h>
|
||||
|
||||
class ColorWindow;
|
||||
class BMenuItem;
|
||||
class BMenu;
|
||||
class BBox;
|
||||
class BButton;
|
||||
class MenuBar;
|
||||
class MenuWindow : public BWindow {
|
||||
public:
|
||||
MenuWindow();
|
||||
MenuWindow(BRect frame);
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
virtual bool QuitRequested();
|
||||
virtual void Update();
|
||||
void Defaults();
|
||||
|
||||
@ -23,7 +22,6 @@ private:
|
||||
BMenuItem *toggleItem;
|
||||
menu_info info;
|
||||
menu_info revert_info;
|
||||
BRect rect;
|
||||
BMenu *menu;
|
||||
MenuBar *menuBar;
|
||||
BBox *menuView;
|
||||
|
Loading…
Reference in New Issue
Block a user