Add menubar to main window

This commit is contained in:
Jaidyn Ann 2021-05-25 13:57:53 -05:00
parent 3d020c4628
commit 5d9d16459f

View File

@ -10,35 +10,22 @@
#include <Application.h> #include <Application.h>
#include <Alert.h> #include <Alert.h>
#include <Button.h> #include <LayoutBuilder.h>
#include <CardLayout.h> #include <MenuBar.h>
#include <ListView.h>
#include <Box.h>
#include <CheckBox.h>
#include <Entry.h>
#include <GridLayout.h>
#include <GridLayoutBuilder.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <Notification.h> #include <Notification.h>
#include <PopUpMenu.h>
#include <SpaceLayoutItem.h>
#include <ScrollView.h> #include <ScrollView.h>
#include <StringView.h> #include <StringView.h>
#include <TextControl.h> #include <TextControl.h>
#include <TranslationUtils.h> #include <TranslationUtils.h>
#include <libinterface/BitmapUtils.h> #include <libinterface/BitmapUtils.h>
#include <libinterface/ToolButton.h>
#include "AccountManager.h" #include "AccountManager.h"
#include "CayaConstants.h" #include "CayaConstants.h"
#include "CayaMessages.h" #include "CayaMessages.h"
#include "CayaProtocolMessages.h" #include "CayaProtocolMessages.h"
#include "CayaPreferences.h" #include "CayaPreferences.h"
#include "CayaResources.h"
#include "CayaUtils.h"
#include "NotifyMessage.h" #include "NotifyMessage.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "PreferencesDialog.h" #include "PreferencesDialog.h"
@ -69,39 +56,30 @@ MainWindow::MainWindow()
BScrollView* scrollView = new BScrollView("scrollview", fListView, BScrollView* scrollView = new BScrollView("scrollview", fListView,
B_WILL_DRAW, false, true); B_WILL_DRAW, false, true);
// Wrench menu // Menubar
BPopUpMenu* wrenchMenu = new BPopUpMenu("Wrench"); BMenuBar* menuBar = new BMenuBar("MenuBar");
(void)wrenchMenu->AddItem(new BMenuItem("About" B_UTF8_ELLIPSIS,
BMenu* programMenu = new BMenu("Program");
programMenu->AddItem(new BMenuItem("About" B_UTF8_ELLIPSIS,
new BMessage(B_ABOUT_REQUESTED))); new BMessage(B_ABOUT_REQUESTED)));
(void)wrenchMenu->AddItem(new BSeparatorItem()); programMenu->AddItem(new BMenuItem("Preferences" B_UTF8_ELLIPSIS,
(void)wrenchMenu->AddItem(new BMenuItem("Preferences" B_UTF8_ELLIPSIS, new BMessage(CAYA_SHOW_SETTINGS), ',', B_COMMAND_KEY));
new BMessage(CAYA_SHOW_SETTINGS))); programMenu->AddItem(new BSeparatorItem());
(void)wrenchMenu->AddItem(new BSeparatorItem()); programMenu->AddItem(new BMenuItem("Quit",
(void)wrenchMenu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q', B_COMMAND_KEY));
new BMessage(B_QUIT_REQUESTED))); programMenu->SetTargetForItems(this);
wrenchMenu->SetTargetForItems(this);
// Tool icon menuBar->AddItem(programMenu);
BResources* res = CayaResources();
BBitmap* toolIcon = IconFromResources(res, kToolIcon);
delete res;
// Wrench tool button BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f)
ToolButton* wrench = new ToolButton(NULL, NULL); .Add(menuBar)
wrench->SetBitmap(toolIcon); .AddGroup(B_VERTICAL)
wrench->SetMenu(wrenchMenu); .SetInsets(5, 5, 5, 10)
.Add(searchBox)
SetLayout(new BGridLayout(1, 2)); .Add(scrollView)
AddChild(BGridLayoutBuilder(1, 2) .Add(fStatusView)
.Add(searchBox, 0, 0) .End()
.Add(wrench, 1, 0) .End();
.Add(scrollView, 0, 1, 2)
.Add(fStatusView, 0, 2, 2)
.SetInsets(5, 5, 5, 10)
);
AddShortcut('a', B_COMMAND_KEY, new BMessage(B_ABOUT_REQUESTED));
MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2));
// Filter messages using Server // Filter messages using Server
fServer = new Server(); fServer = new Server();