added some files
This commit is contained in:
parent
dbfee4dcdd
commit
6be1aad043
9 changed files with 390 additions and 0 deletions
120
MainWindow.cpp
Normal file
120
MainWindow.cpp
Normal file
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* Copyright 2024, My Name <my@email.address>
|
||||
* All rights reserved. Distributed under the terms of the MIT license.
|
||||
*/
|
||||
|
||||
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include <Application.h>
|
||||
#include <Catalog.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuBar.h>
|
||||
#include <View.h>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "Window"
|
||||
|
||||
static const uint32 kMsgNewFile = 'fnew';
|
||||
static const uint32 kMsgOpenFile = 'fopn';
|
||||
static const uint32 kMsgSaveFile = 'fsav';
|
||||
|
||||
static const uint32 kSendPrompt = 'kspt';
|
||||
|
||||
|
||||
MainWindow::MainWindow()
|
||||
:
|
||||
BWindow(BRect(100, 100, 500, 400), B_TRANSLATE("BeDumb"), B_TITLED_WINDOW,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE)
|
||||
{
|
||||
BMenuBar* menuBar = _BuildMenu();
|
||||
|
||||
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
|
||||
.Add(menuBar)
|
||||
.AddGlue()
|
||||
.End();
|
||||
|
||||
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
|
||||
.AddGroup(B_HORIZONTAL, 0)
|
||||
// .Add(new BTextControl("Input 1", "Label 1", "Default text"))
|
||||
// .Add(new BButton("Go", new BMessage(kSendPrompt))
|
||||
.End()
|
||||
// .Add(new BTextView("Text View", new BRect(0, 0, 10, 10), B_FOLLOW_ALL_SIDES, B_WILL_DRAW))
|
||||
.SetInsets(5, 5, 5, 5)
|
||||
.End();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case kMsgNewFile:
|
||||
{
|
||||
fSaveMenuItem->SetEnabled(false);
|
||||
printf("New\n");
|
||||
} break;
|
||||
|
||||
case kMsgOpenFile:
|
||||
{
|
||||
fSaveMenuItem->SetEnabled(true);
|
||||
printf("Open\n");
|
||||
} break;
|
||||
|
||||
case kMsgSaveFile:
|
||||
{
|
||||
printf("Save\n");
|
||||
} break;
|
||||
|
||||
default:
|
||||
{
|
||||
BWindow::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BMenuBar*
|
||||
MainWindow::_BuildMenu()
|
||||
{
|
||||
BMenuBar* menuBar = new BMenuBar("menubar");
|
||||
BMenu* menu;
|
||||
BMenuItem* item;
|
||||
|
||||
// menu 'File'
|
||||
menu = new BMenu(B_TRANSLATE("File"));
|
||||
|
||||
item = new BMenuItem(B_TRANSLATE("New"), new BMessage(kMsgNewFile), 'N');
|
||||
menu->AddItem(item);
|
||||
|
||||
item = new BMenuItem(B_TRANSLATE("Open" B_UTF8_ELLIPSIS), new BMessage(kMsgOpenFile), 'O');
|
||||
menu->AddItem(item);
|
||||
|
||||
fSaveMenuItem = new BMenuItem(B_TRANSLATE("Save"), new BMessage(kMsgSaveFile), 'S');
|
||||
fSaveMenuItem->SetEnabled(false);
|
||||
menu->AddItem(fSaveMenuItem);
|
||||
|
||||
menu->AddSeparatorItem();
|
||||
|
||||
item = new BMenuItem(B_TRANSLATE("About" B_UTF8_ELLIPSIS), new BMessage(B_ABOUT_REQUESTED));
|
||||
item->SetTarget(be_app);
|
||||
menu->AddItem(item);
|
||||
|
||||
item = new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED), 'Q');
|
||||
menu->AddItem(item);
|
||||
|
||||
menuBar->AddItem(menu);
|
||||
|
||||
return menuBar;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue