The complete source code of IdealIRC http://www.idealirc.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
idealirc/Script/Dialog.h

102 lines
2.4 KiB

/*
* IdealIRC Script Engine - Scripting tailored for IRC clients.
* Copyright (C) 2021 Tom-Andre Barstad.
* This software is licensed under the Software Attribution License.
* See LICENSE for more information.
*/
#ifndef DIALOG_H
#define DIALOG_H
#include "ValueHolder.h"
#include "Tokens.h"
#include <string>
#include <memory>
#include <optional>
#include <vector>
#include <stdexcept>
/** @class DialogWidget
* Abstract representation of a dialog widget
*/
struct DialogWidgetPriv;
class DialogWidget
{
public:
enum class Type {
Label,
Button,
Textline,
Textbox,
Spinbox,
Listbox,
Combobox,
Table,
Tree,
Groupbox,
Tab,
Radio,
Checkbox,
Vscroll,
Hscroll,
Canvas
};
static std::optional<Type> strToType(const std::string& stype);
DialogWidget() = delete;
DialogWidget(const std::string& name, Type type);
DialogWidget(DialogWidget&& other);
DialogWidget(DialogWidget&) = delete;
~DialogWidget();
DialogWidget& operator=(DialogWidget&& other);
DialogWidget& operator=(DialogWidget&) = delete;
void setDefaultAttr(const std::string& key, ValueHolder value);
ValueHolder defaultAttr(const std::string& key) const;
const std::string& name() const;
Type type() const;
Scope& addHook(const std::string& hookname, Scope&& scope);
std::optional<ScopeRef> hook(const std::string& hookname) const;
private:
std::unique_ptr<DialogWidgetPriv> mp;
};
using DialogWidgetRef = std::reference_wrapper<DialogWidget>;
/**
* @class Dialog
* @brief Abstract representation of a dialog
*/
struct DialogPriv;
class Dialog
{
public:
Dialog() = delete;
explicit Dialog(const std::string& name);
Dialog(Dialog&& other);
Dialog(const Dialog&) = delete;
~Dialog();
Dialog& operator=(Dialog&& other);
Dialog& operator=(Dialog&) = delete;
void setDefaultAttr(const std::string& key, ValueHolder value);
ValueHolder defaultAttr(const std::string& key) const;
const std::string& name() const;
DialogWidget& addWidget(const std::string& name, DialogWidget::Type type);
DialogWidget& widget(const std::string& name);
std::vector<DialogWidgetRef> allWidgets() const;
Scope& addHook(const std::string& hookname, Scope&& scope);
std::optional<ScopeRef> hook(const std::string& hookname) const;
private:
std::unique_ptr<DialogPriv> mp;
};
#endif // DIALOG_H