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:
@@ -5,8 +5,6 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
class BBitmap;
|
class BBitmap;
|
||||||
|
|
||||||
// MBitmapMenuItem class declaration
|
|
||||||
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,
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ void
|
|||||||
ColorWindow::MessageReceived(BMessage *msg)
|
ColorWindow::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
switch(msg->what) {
|
switch(msg->what) {
|
||||||
|
|
||||||
case MENU_REVERT:
|
case MENU_REVERT:
|
||||||
colorPicker->SetValue(revert_info.background_color);
|
colorPicker->SetValue(revert_info.background_color);
|
||||||
info.background_color = colorPicker->ValueAsColor();
|
info.background_color = colorPicker->ValueAsColor();
|
||||||
@@ -58,16 +57,16 @@ ColorWindow::MessageReceived(BMessage *msg)
|
|||||||
color.alpha = 255;
|
color.alpha = 255;
|
||||||
colorPicker->SetValue(color);
|
colorPicker->SetValue(color);
|
||||||
|
|
||||||
case MENU_COLOR:{
|
case MENU_COLOR:
|
||||||
get_menu_info(&info);
|
get_menu_info(&info);
|
||||||
info.background_color = colorPicker->ValueAsColor();
|
info.background_color = colorPicker->ValueAsColor();
|
||||||
set_menu_info(&info);
|
set_menu_info(&info);
|
||||||
be_app->PostMessage(UPDATE_WINDOW);
|
be_app->PostMessage(UPDATE_WINDOW);
|
||||||
break;}
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
be_app->PostMessage(UPDATE_WINDOW);
|
be_app->PostMessage(UPDATE_WINDOW);
|
||||||
BMessage(msg);
|
BWindow::MessageReceived(msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,11 @@
|
|||||||
class BColorControl;
|
class BColorControl;
|
||||||
class BButton;
|
class BButton;
|
||||||
class ColorWindow : public BWindow {
|
class ColorWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
ColorWindow();
|
ColorWindow();
|
||||||
virtual void MessageReceived(BMessage *msg);
|
virtual void MessageReceived(BMessage *msg);
|
||||||
|
|
||||||
|
private:
|
||||||
BColorControl *colorPicker;
|
BColorControl *colorPicker;
|
||||||
BButton *DefaultButton;
|
BButton *DefaultButton;
|
||||||
BButton *RevertButton;
|
BButton *RevertButton;
|
||||||
|
|||||||
@@ -5,18 +5,8 @@
|
|||||||
MenuApp::MenuApp()
|
MenuApp::MenuApp()
|
||||||
: BApplication("application/x-vnd.Be-GGUI")
|
: BApplication("application/x-vnd.Be-GGUI")
|
||||||
{
|
{
|
||||||
get_menu_info(&info);
|
fMenuWindow = new MenuWindow(BRect(100, 100, 400, 300));
|
||||||
|
fMenuWindow->Show();
|
||||||
menuWindow = new MenuWindow();
|
|
||||||
Update();
|
|
||||||
menuWindow->Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
MenuApp::Update()
|
|
||||||
{
|
|
||||||
menuWindow->Update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -24,7 +14,6 @@ void
|
|||||||
MenuApp::MessageReceived(BMessage *msg)
|
MenuApp::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
switch(msg->what) {
|
switch(msg->what) {
|
||||||
|
|
||||||
//others
|
//others
|
||||||
case UPDATE_WINDOW:
|
case UPDATE_WINDOW:
|
||||||
case CLICK_OPEN_MSG:
|
case CLICK_OPEN_MSG:
|
||||||
@@ -33,7 +22,7 @@ MenuApp::MessageReceived(BMessage *msg)
|
|||||||
case ALT_MARKED_MSG:
|
case ALT_MARKED_MSG:
|
||||||
case COLOR_SCHEME_MSG:
|
case COLOR_SCHEME_MSG:
|
||||||
case MENU_COLOR:
|
case MENU_COLOR:
|
||||||
menuWindow->PostMessage(msg);
|
fMenuWindow->PostMessage(msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -2,20 +2,15 @@
|
|||||||
#define __MENU_APP_H
|
#define __MENU_APP_H
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Menu.h>
|
|
||||||
|
|
||||||
class MenuWindow;
|
class MenuWindow;
|
||||||
class MenuApp : public BApplication {
|
class MenuApp : public BApplication {
|
||||||
public:
|
public:
|
||||||
MenuApp();
|
MenuApp();
|
||||||
virtual void Update();
|
|
||||||
virtual void MessageReceived(BMessage *msg);
|
virtual void MessageReceived(BMessage *msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MenuWindow *menuWindow;
|
MenuWindow *fMenuWindow;
|
||||||
BRect rect;
|
|
||||||
menu_info info;
|
|
||||||
BMenu *menu;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -44,14 +44,14 @@ MenuBar::build_menu()
|
|||||||
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);
|
||||||
separatorStyleZero = new BitmapMenuItem(" ", msg,
|
separatorStyleZero = new BitmapMenuItem("separator0", msg,
|
||||||
BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP0"));
|
BTranslationUtils::GetBitmap(B_RAW_TYPE, "SEP0"));
|
||||||
msg = new BMessage(MENU_SEP_TYPE);
|
msg = new BMessage(MENU_SEP_TYPE);
|
||||||
msg->AddInt32("sep", 1);
|
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 = new BMessage(MENU_SEP_TYPE);
|
||||||
msg->AddInt32("sep", 2);
|
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)
|
if (info.separator == 0)
|
||||||
separatorStyleZero->SetMarked(true);
|
separatorStyleZero->SetMarked(true);
|
||||||
if (info.separator == 1)
|
if (info.separator == 1)
|
||||||
@@ -119,6 +119,7 @@ MenuBar::Update()
|
|||||||
separatorStyleOne->SetMarked(true);
|
separatorStyleOne->SetMarked(true);
|
||||||
else if (info.separator == 2)
|
else if (info.separator == 2)
|
||||||
separatorStyleTwo->SetMarked(true);
|
separatorStyleTwo->SetMarked(true);
|
||||||
|
|
||||||
set_menu();
|
set_menu();
|
||||||
|
|
||||||
BFont font;
|
BFont font;
|
||||||
|
|||||||
@@ -13,34 +13,41 @@
|
|||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
|
|
||||||
MenuWindow::MenuWindow()
|
MenuWindow::MenuWindow(BRect rect)
|
||||||
: BWindow(rect, "Menu", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
|
: 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(&revert_info);
|
||||||
get_menu_info(&info);
|
get_menu_info(&info);
|
||||||
|
|
||||||
revert = false;
|
revert = false;
|
||||||
|
|
||||||
MoveTo((rect.left += 100),(rect.top += 100));
|
|
||||||
menuView = new BBox(Bounds(), "menuView", B_FOLLOW_ALL_SIDES,
|
menuView = new BBox(Bounds(), "menuView", B_FOLLOW_ALL_SIDES,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
|
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
|
||||||
AddChild(menuView);
|
AddChild(menuView);
|
||||||
|
|
||||||
menuBar = new MenuBar();
|
menuBar = new MenuBar();
|
||||||
menuView->AddChild(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);
|
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->AddChild(revertButton);
|
||||||
|
|
||||||
menuView->MakeFocus();
|
menuView->MakeFocus();
|
||||||
|
|
||||||
Update();
|
Update();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -48,7 +55,6 @@ void
|
|||||||
MenuWindow::MessageReceived(BMessage *msg)
|
MenuWindow::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
switch(msg->what) {
|
switch(msg->what) {
|
||||||
|
|
||||||
case MENU_REVERT:
|
case MENU_REVERT:
|
||||||
set_menu_info(&revert_info);
|
set_menu_info(&revert_info);
|
||||||
revert = false;
|
revert = false;
|
||||||
@@ -79,9 +85,9 @@ MenuWindow::MessageReceived(BMessage *msg)
|
|||||||
|
|
||||||
case MENU_FONT_SIZE:
|
case MENU_FONT_SIZE:
|
||||||
revert = true;
|
revert = true;
|
||||||
float f;
|
float fontSize;
|
||||||
msg->FindFloat("size", &f);
|
msg->FindFloat("size", &fontSize);
|
||||||
info.font_size = f;
|
info.font_size = fontSize;
|
||||||
set_menu_info(&info);
|
set_menu_info(&info);
|
||||||
Update();
|
Update();
|
||||||
break;
|
break;
|
||||||
@@ -155,20 +161,12 @@ MenuWindow::MessageReceived(BMessage *msg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BMessage(msg);
|
BWindow::MessageReceived(msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
MenuWindow::QuitRequested()
|
|
||||||
{
|
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
|
||||||
return BWindow::QuitRequested();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MenuWindow::Update()
|
MenuWindow::Update()
|
||||||
{
|
{
|
||||||
@@ -176,9 +174,6 @@ MenuWindow::Update()
|
|||||||
|
|
||||||
// alert the rest of the application to update
|
// alert the rest of the application to update
|
||||||
menuBar->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
|
#ifndef __MENU_WINDOW_H
|
||||||
#define __MENU_WINDOW_H
|
#define __MENU_WINDOW_H
|
||||||
|
|
||||||
|
#include <Menu.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
class ColorWindow;
|
class ColorWindow;
|
||||||
class BMenuItem;
|
class BMenuItem;
|
||||||
class BMenu;
|
|
||||||
class BBox;
|
class BBox;
|
||||||
class BButton;
|
class BButton;
|
||||||
class MenuBar;
|
class MenuBar;
|
||||||
class MenuWindow : public BWindow {
|
class MenuWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
MenuWindow();
|
MenuWindow(BRect frame);
|
||||||
virtual void MessageReceived(BMessage *msg);
|
virtual void MessageReceived(BMessage *msg);
|
||||||
virtual bool QuitRequested();
|
|
||||||
virtual void Update();
|
virtual void Update();
|
||||||
void Defaults();
|
void Defaults();
|
||||||
|
|
||||||
@@ -23,7 +22,6 @@ private:
|
|||||||
BMenuItem *toggleItem;
|
BMenuItem *toggleItem;
|
||||||
menu_info info;
|
menu_info info;
|
||||||
menu_info revert_info;
|
menu_info revert_info;
|
||||||
BRect rect;
|
|
||||||
BMenu *menu;
|
BMenu *menu;
|
||||||
MenuBar *menuBar;
|
MenuBar *menuBar;
|
||||||
BBox *menuView;
|
BBox *menuView;
|
||||||
|
|||||||
Reference in New Issue
Block a user