https://github.com/libsdl-org/Maelstrom/commit/cb21b9c7ead9d4b376569e32a2e947172f779ce1
From cb21b9c7ead9d4b376569e32a2e947172f779ce1 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 31 Oct 2011 18:16:47 -0400
Subject: [PATCH] Added a dialog delegate that's the same as a panel delegate,
but it gets a nice accessor to the dialog.
---
screenlib/UIDialog.cpp | 11 +++++++++++
screenlib/UIDialog.h | 9 +++++++++
2 files changed, 20 insertions(+)
diff --git a/screenlib/UIDialog.cpp b/screenlib/UIDialog.cpp
index 46789f68..93882e34 100644
--- a/screenlib/UIDialog.cpp
+++ b/screenlib/UIDialog.cpp
@@ -75,6 +75,17 @@ UIDialog::HandleEvent(const SDL_Event &event)
return false;
}
+UIDialogDelegate::UIDialogDelegate(UIPanel *panel) :
+ UIPanelDelegate(panel)
+{
+ if (panel->IsA(UIDialog::GetType())) {
+ m_dialog = static_cast<UIDialog*>(panel);
+ } else {
+ m_dialog = NULL;
+ }
+ assert(m_dialog);
+}
+
UIDialogLauncher::UIDialogLauncher(UIManager *ui, const char *name, UIDialogInitHandler handleInit, UIDialogDoneHandler handleDone)
{
m_ui = ui;
diff --git a/screenlib/UIDialog.h b/screenlib/UIDialog.h
index 6d87c4f5..36c762a2 100644
--- a/screenlib/UIDialog.h
+++ b/screenlib/UIDialog.h
@@ -27,6 +27,15 @@
class UIDialog;
+class UIDialogDelegate : public UIPanelDelegate
+{
+public:
+ UIDialogDelegate(UIPanel *panel);
+
+protected:
+ UIDialog *m_dialog;
+};
+
/* This function gets called when the dialog is shown.
*/
typedef void (*UIDialogInitHandler)(UIDialog *dialog);