add missing files

This commit is contained in:
thrust26 2020-01-19 20:59:49 +01:00
parent e3f1a0f49f
commit 6c2cbf3fac
4 changed files with 270 additions and 0 deletions

87
src/gui/MessageDialog.cxx Normal file
View File

@ -0,0 +1,87 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "Console.hxx"
#include "EventHandler.hxx"
#include "Font.hxx"
#include "MessageBox.hxx"
#include "StringParser.hxx"
#include "MessageDialog.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MessageDialog::MessageDialog(OSystem& osystem, DialogContainer& parent,
const GUI::Font& font, int max_w, int max_h)
: Dialog(osystem, parent, font)
{
_w = _h = 10; // must not be 0
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MessageDialog::~MessageDialog()
{
delete myMsg; myMsg = nullptr;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MessageDialog::loadConfig()
{
// ugly, but I can't do better
if (myMsg != nullptr)
delete myMsg;
myMsg = new GUI::MessageBox(this, _font, myText,
FBMinimum::Width, FBMinimum::Height, kOKCmd, kCloseCmd,
myYesNo ? "Yes" : "Ok", myYesNo ? "No" : "Cancel",
myTitle, true);
myMsg->show();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MessageDialog::handleCommand(CommandSender* sender, int cmd, int data, int id)
{
switch (cmd)
{
case kOKCmd:
case kCloseCmd:
myConfirmed = cmd == kOKCmd;
instance().eventHandler().handleEvent(Event::ExitMode);
break;
default:
Dialog::handleCommand(sender, cmd, data, 0);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MessageDialog::setMessage(const string& title, const StringList& text, bool yesNo)
{
myTitle = title;
myText = text;
myYesNo = yesNo;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MessageDialog::setMessage(const string& title, const string& text, bool yesNo)
{
setMessage(title, StringParser(text).stringList(), yesNo);
}
string MessageDialog::myTitle = "";
StringList MessageDialog::myText;
bool MessageDialog::myYesNo = false;
bool MessageDialog::myConfirmed = false;

62
src/gui/MessageDialog.hxx Normal file
View File

@ -0,0 +1,62 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#ifndef MESSAGE_DIALOG_HXX
#define MESSAGE_DIALOG_HXX
class Properties;
class CommandSender;
class DialogContainer;
class OSystem;
#include "MessageBox.hxx"
class MessageDialog : public Dialog
{
public:
MessageDialog(OSystem& osystem, DialogContainer& parent,
const GUI::Font& font, int max_w, int max_h);
virtual ~MessageDialog();
// Define the message displayed
void setMessage(const string& title, const string& text, bool yesNo = false);
void setMessage(const string& title, const StringList& text, bool yesNo = false);
bool confirmed() { return myConfirmed; }
protected:
void loadConfig() override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
private:
static string myTitle;
static StringList myText;
static bool myYesNo;
static bool myConfirmed;
// Show a message
GUI::MessageBox* myMsg{nullptr};
private:
// Following constructors and assignment operators not supported
MessageDialog() = delete;
MessageDialog(const MessageDialog&) = delete;
MessageDialog(MessageDialog&&) = delete;
MessageDialog& operator=(const MessageDialog&) = delete;
MessageDialog& operator=(MessageDialog&&) = delete;
};
#endif

64
src/gui/MessageMenu.cxx Normal file
View File

@ -0,0 +1,64 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "Dialog.hxx"
#include "FrameBuffer.hxx"
#include "MessageDialog.hxx"
#include "MessageMenu.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MessageMenu::MessageMenu(OSystem& osystem)
: DialogContainer(osystem)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MessageMenu::~MessageMenu()
{
delete myMessageDialog; myMessageDialog = nullptr;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Dialog* MessageMenu::baseDialog()
{
if (myMessageDialog == nullptr)
myMessageDialog = new MessageDialog(myOSystem, *this, myOSystem.frameBuffer().font(),
FBMinimum::Width, FBMinimum::Height);
return myMessageDialog;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MessageMenu::setMessage(const string& title, const StringList& text, bool yesNo)
{
myMessageDialog->setMessage(title, text, yesNo);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MessageMenu::setMessage(const string& title, const string& text, bool yesNo)
{
myMessageDialog->setMessage(title, text, yesNo);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool MessageMenu::confirmed()
{
if (myMessageDialog != nullptr)
return myMessageDialog->confirmed();
return false;
}

57
src/gui/MessageMenu.hxx Normal file
View File

@ -0,0 +1,57 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#ifndef MESSAGE_MENU_HXX
#define MESSAGE_MENU_HXX
class OSystem;
class MessageDialog;
#include "DialogContainer.hxx"
/**
The base dialog for all message menus in Stella.
@author Thomas Jentzsch
*/
class MessageMenu : public DialogContainer
{
public:
/**
Create a new menu stack
*/
explicit MessageMenu(OSystem& osystem);
virtual ~MessageMenu();
void setMessage(const string& title, const string& text, bool yesNo = false);
void setMessage(const string& title, const StringList& text, bool yesNo = false);
bool confirmed();
private:
Dialog* baseDialog() override;
MessageDialog* myMessageDialog{nullptr};
private:
// Following constructors and assignment operators not supported
MessageMenu() = delete;
MessageMenu(const MessageMenu&) = delete;
MessageMenu(MessageMenu&&) = delete;
MessageMenu& operator=(const MessageMenu&) = delete;
MessageMenu& operator=(MessageMenu&&) = delete;
};
#endif