Maelstrom: Work in progress on a new simpler, more flexible, UI system.

https://github.com/libsdl-org/Maelstrom/commit/2c207303f1b891aa8e4248ec097abd1c4d690ad6

From 2c207303f1b891aa8e4248ec097abd1c4d690ad6 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 2 Nov 2011 00:17:15 -0400
Subject: [PATCH] Work in progress on a new simpler, more flexible, UI system.

---
 MacDialog.cpp                   | 246 ++++++++++++++-
 MacDialog.h                     |  60 ++++
 MacDialogButton.cpp             | 159 ----------
 MacDialogButton.h               |  49 ---
 MacDialogCheckbox.cpp           |  66 ----
 MacDialogCheckbox.h             |  44 ---
 MacDialogEditbox.cpp            |  90 ------
 MacDialogEditbox.h              |  47 ---
 MacDialogLabel.cpp              |  35 ---
 MacDialogLabel.h                |  35 ---
 MacDialogRadioButton.cpp        |  91 ------
 MacDialogRadioButton.h          |  44 ---
 MaelstromUI.cpp                 | 149 ++++++---
 MaelstromUI.h                   |  30 ++
 Makefile.am                     |  24 +-
 Makefile.in                     |  45 +--
 UIElementIcon.cpp               |  57 ----
 UIElementIcon.h                 |  38 ---
 UIElementKeyButton.cpp          |  55 ----
 UIElementKeyButton.h            |  38 ---
 UIElementSprite.cpp             |  76 -----
 UIElementSprite.h               |  38 ---
 UIElementTitle.cpp              |  57 ----
 UIElementTitle.h                |  38 ---
 controls.cpp                    |   4 +-
 controls.h                      |   4 +-
 main.cpp                        |  53 ++--
 netlogic/game.cpp               |  47 ++-
 netlogic/game.h                 |  18 +-
 screenlib/Makefile.am           |  12 +-
 screenlib/Makefile.in           |  30 +-
 screenlib/UIArea.cpp            |  63 ++--
 screenlib/UIArea.h              |  30 +-
 screenlib/UIBaseElement.cpp     |  10 +-
 screenlib/UIBaseElement.h       |  16 +
 screenlib/UIDialog.h            |   4 +-
 screenlib/UIDialogButton.cpp    |   5 +-
 screenlib/UIDialogButton.h      |   6 +-
 screenlib/UIDrawEngine.cpp      | 237 ++++++++++++++
 screenlib/UIDrawEngine.h        | 115 +++++++
 screenlib/UIElement.cpp         | 539 +++++++++++++++++++++++++++++++-
 screenlib/UIElement.h           | 127 +++++++-
 screenlib/UIElementButton.cpp   | 135 +-------
 screenlib/UIElementButton.h     |  28 +-
 screenlib/UIElementCheckbox.cpp |  17 +-
 screenlib/UIElementCheckbox.h   |   2 +-
 screenlib/UIElementEditbox.cpp  |  21 +-
 screenlib/UIElementEditbox.h    |   3 +-
 screenlib/UIElementImage.cpp    |  68 ----
 screenlib/UIElementImage.h      |  38 ---
 screenlib/UIElementLabel.cpp    | 151 ---------
 screenlib/UIElementLabel.h      |  56 ----
 screenlib/UIElementLine.cpp     |  50 ---
 screenlib/UIElementLine.h       |  46 ---
 screenlib/UIElementRadio.cpp    |   8 +-
 screenlib/UIElementRadio.h      |   4 +-
 screenlib/UIElementRect.cpp     |  56 ----
 screenlib/UIElementRect.h       |  47 ---
 screenlib/UIElementTexture.cpp  |  58 ----
 screenlib/UIElementTexture.h    |  43 ---
 screenlib/UIManager.cpp         |   8 +-
 screenlib/UIManager.h           |   1 +
 screenlib/UIPanel.cpp           |   4 +-
 63 files changed, 1652 insertions(+), 2123 deletions(-)
 delete mode 100644 MacDialogButton.cpp
 delete mode 100644 MacDialogButton.h
 delete mode 100644 MacDialogCheckbox.cpp
 delete mode 100644 MacDialogCheckbox.h
 delete mode 100644 MacDialogEditbox.cpp
 delete mode 100644 MacDialogEditbox.h
 delete mode 100644 MacDialogLabel.cpp
 delete mode 100644 MacDialogLabel.h
 delete mode 100644 MacDialogRadioButton.cpp
 delete mode 100644 MacDialogRadioButton.h
 delete mode 100644 UIElementIcon.cpp
 delete mode 100644 UIElementIcon.h
 delete mode 100644 UIElementKeyButton.cpp
 delete mode 100644 UIElementKeyButton.h
 delete mode 100644 UIElementSprite.cpp
 delete mode 100644 UIElementSprite.h
 delete mode 100644 UIElementTitle.cpp
 delete mode 100644 UIElementTitle.h
 create mode 100644 screenlib/UIDrawEngine.cpp
 create mode 100644 screenlib/UIDrawEngine.h
 delete mode 100644 screenlib/UIElementImage.cpp
 delete mode 100644 screenlib/UIElementImage.h
 delete mode 100644 screenlib/UIElementLabel.cpp
 delete mode 100644 screenlib/UIElementLabel.h
 delete mode 100644 screenlib/UIElementLine.cpp
 delete mode 100644 screenlib/UIElementLine.h
 delete mode 100644 screenlib/UIElementRect.cpp
 delete mode 100644 screenlib/UIElementRect.h
 delete mode 100644 screenlib/UIElementTexture.cpp
 delete mode 100644 screenlib/UIElementTexture.h

diff --git a/MacDialog.cpp b/MacDialog.cpp
index 411c907f..638162df 100644
--- a/MacDialog.cpp
+++ b/MacDialog.cpp
@@ -21,11 +21,20 @@
 */
 
 #include "screenlib/SDL_FrameBuf.h"
+#include "screenlib/UIDialogButton.h"
+#include "screenlib/UIElementCheckbox.h"
+#include "screenlib/UIElementRadio.h"
 
 #include "MacDialog.h"
 
-#define EXPAND_STEPS 30
+#define EXPAND_STEPS	30
 
+#define BUTTON_WIDTH	75
+#define BUTTON_HEIGHT	19
+
+#define CHECKBOX_SIZE	12
+
+#define RADIOBUTTON_SIZE	20
 
 UIElementType MacDialog::s_elementType;
 
@@ -117,3 +126,238 @@ MacDialog::Draw()
 
 	UIDialog::Draw();
 }
+
+//////////////////////////////////////////////////////////////////////////////
+
+void
+MacDialogDrawEngine::Init(UIElement *element)
+{
+	UIDrawEngine::Init(element);
+
+	// Set the default colors and font for dialog elements
+	m_element->SetFillColor(0xFF, 0xFF, 0xFF);
+	m_element->SetColor(0x00, 0x00, 0x00);
+	m_element->SetFont("Chicago", 12, UIFONT_STYLE_NORMAL);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+void
+MacDialogButton::Init(UIElement *element)
+{
+	MacDialogDrawEngine::Init(element);
+
+	m_element->SetFill(true);
+	m_element->SetSize(BUTTON_WIDTH, BUTTON_HEIGHT);
+}
+
+void
+MacDialogButton::OnLoad()
+{
+	MacDialogDrawEngine::OnLoad();
+
+	m_colors[0] = m_element->GetFillColor();
+	m_colors[1] = m_element->GetColor();
+}
+
+void
+MacDialogButton::OnDraw()
+{
+	Uint32 color;
+	int x, y, maxx, maxy;
+
+	// Do the normal drawing
+	MacDialogDrawEngine::OnDraw();
+
+	color = m_element->GetColor();
+
+	// Draw the beveled edge
+	x = m_element->X();
+	maxx = x+m_element->Width()-1;
+	y = m_element->Y();
+	maxy = y+m_element->Height()-1;
+
+	// Top and upper corners
+	m_screen->DrawLine(x+3, y, maxx-3, y, color);
+	m_screen->DrawLine(x+1, y+1, x+2, y+1, color);
+	m_screen->DrawLine(maxx-2, y+1, maxx-1, y+1, color);
+	m_screen->DrawLine(x+1, y+2, x+1, y+2, color);
+	m_screen->DrawLine(maxx-1, y+2, maxx-1, y+2, color);
+
+	// Sides
+	m_screen->DrawLine(x, y+3, x, maxy-3, color);
+	m_screen->DrawLine(maxx, y+3, maxx, maxy-3, color);
+
+	// Bottom and lower corners
+	m_screen->DrawLine(x+1, maxy-2, x+1, maxy-2, color);
+	m_screen->DrawLine(maxx-1, maxy-2, maxx-1, maxy-2, color);
+	m_screen->DrawLine(x+1, maxy-1, x+2, maxy-1, color);
+	m_screen->DrawLine(maxx-2, maxy-1, maxx-1, maxy-1, color);
+	m_screen->DrawLine(x+3, maxy, maxx-3, maxy, color);
+
+	if (m_element->IsA(UIDialogButton::GetType()) &&
+	    static_cast<UIDialogButton*>(m_element)->IsDefault()) {
+		// Show the thick edge
+		x = m_element->X()-4;
+		maxx = x+4+m_element->Width()+4-1;
+		y = m_element->Y()-4;
+		maxy = y+4+m_element->Height()+4-1;
+
+		// The edge always uses the real foreground color
+		color = m_colors[1];
+
+		m_screen->DrawLine(x+5, y, maxx-5, y, color);
+		m_screen->DrawLine(x+3, y+1, maxx-3, y+1, color);
+		m_screen->DrawLine(x+2, y+2, maxx-2, y+2, color);
+		m_screen->DrawLine(x+1, y+3, x+5, y+3, color);
+		m_screen->DrawLine(maxx-5, y+3, maxx-1, y+3, color);
+		m_screen->DrawLine(x+1, y+4, x+3, y+4, color);
+		m_screen->DrawLine(maxx-3, y+4, maxx-1, y+4, color);
+		m_screen->DrawLine(x, y+5, x+3, y+5, color);
+		m_screen->DrawLine(maxx-3, y+5, maxx, y+5, color);
+
+		m_screen->DrawLine(x, y+6, x, maxy-6, color);
+		m_screen->DrawLine(maxx, y+6, maxx, maxy-6, color);
+		m_screen->DrawLine(x+1, y+6, x+1, maxy-6, color);
+		m_screen->DrawLine(maxx-1, y+6, maxx-1, maxy-6, color);
+		m_screen->DrawLine(x+2, y+6, x+2, maxy-6, color);
+		m_screen->DrawLine(maxx-2, y+6, maxx-2, maxy-6, color);
+
+		m_screen->DrawLine(x, maxy-5, x+3, maxy-5, color);
+		m_screen->DrawLine(maxx-3, maxy-5, maxx, maxy-5, color);
+		m_screen->DrawLine(x+1, maxy-4, x+3, maxy-4, color);
+		m_screen->DrawLine(maxx-3, maxy-4, maxx-1, maxy-4, color);
+		m_screen->DrawLine(x+1, maxy-3, x+5, maxy-3, color);
+		m_screen->DrawLine(maxx-5, maxy-3, maxx-1, maxy-3, color);
+		m_screen->DrawLine(x+2, maxy-2, maxx-2, maxy-2, color);
+		m_screen->DrawLine(x+3, maxy-1, maxx-3, maxy-1, color);
+		m_screen->DrawLine(x+5, maxy, maxx-5, maxy, color);
+	}
+}
+
+void
+MacDialogButton::OnMouseDown()
+{
+	MacDialogDrawEngine::OnMouseDown();
+
+	// Invert the colors
+	m_element->SetFillColor(m_colors[1]);
+	m_element->SetColor(m_colors[0]);
+}
+
+void
+MacDialogButton::OnMouseUp()
+{
+	MacDialogDrawEngine::OnMouseUp();
+
+	// Restore the colors
+	m_element->SetFillColor(m_colors[0]);
+	m_element->SetColor(m_colors[1]);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+void
+MacDialogCheckbox::Init(UIElement *element)
+{
+	MacDialogDrawEngine::Init(element);
+
+	m_element->SetSize(CHECKBOX_SIZE, CHECKBOX_SIZE);
+
+	UIArea *area = m_element->GetTextArea();
+	area->SetAnchor(TOPLEFT, TOPLEFT, m_element, CHECKBOX_SIZE+3, -2);
+}
+
+void
+MacDialogCheckbox::OnDraw()
+{
+	Uint32 color;
+	int x, y;
+
+	MacDialogDrawEngine::OnDraw();
+
+	color = m_element->GetColor();
+	x = m_element->X();
+	y = m_element->Y();
+
+	m_screen->DrawRect(x, y, CHECKBOX_SIZE, CHECKBOX_SIZE, color);
+
+	if (m_element->IsA(UIElementCheckbox::GetType()) &&
+	    static_cast<UIElementCheckbox*>(m_element)->IsChecked()) {
+		m_screen->DrawLine(x, y, x+CHECKBOX_SIZE-1,
+					y+CHECKBOX_SIZE-1, color);
+		m_screen->DrawLine(x, y+CHECKBOX_SIZE-1,
+					x+CHECKBOX_SIZE-1, y, color);
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+void
+MacDialogRadioButton::Init(UIElement *element)
+{
+	MacDialogDrawEngine::Init(element);
+
+	m_element->SetSize(RADIOBUTTON_SIZE, RADIOBUTTON_SIZE);
+
+	UIArea *area = m_element->GetTextArea();
+	area->SetAnchor(TOPLEFT, TOPLEFT, m_element, RADIOBUTTON_SIZE+1, 3);
+}
+
+void
+MacDialogRadioButton::OnDraw()
+{
+	Uint32 color;
+	int x, y;
+
+	MacDialogDrawEngine::OnDraw();
+
+	color = m_element->GetColor();
+	x = m_element->X() + 5;
+	y = m_element->Y() + 5;
+
+	/* Draw the circle */
+	m_screen->DrawLine(x+4, y, x+7, y, color);
+	m_screen->DrawLine(x+2, y+1, x+3, y+1, color);
+	m_screen->DrawLine(x+8, y+1, x+9, y+1, color);
+	m_screen->DrawLine(x+1, y+2, x+1, y+3, color);
+	m_screen->DrawLine(x+10, y+2, x+10, y+3, color);
+	m_screen->DrawLine(x, y+4, x, y+7, color);
+	m_screen->DrawLine(x+11, y+4, x+11, y+7, color);
+	m_screen->DrawLine(x+1, y+8, x+1, y+9, color);
+	m_screen->DrawLine(x+10, y+8, x+10, y+9, color);
+	m_screen->DrawLine(x+2, y+10, x+3, y+10, color);
+	m_screen->DrawLine(x+8, y+10, x+9, y+10, color);
+	m_screen->DrawLine(x+4, y+11, x+7, y+11, color);
+
+	if (m_element->IsA(UIElementRadioButton::GetType()) &&
+	    static_cast<UIElementRadioButton*>(m_element)->IsChecked()) {
+		/* Draw the spot in the center */
+		x += 3;
+		y += 3;
+
+		m_screen->DrawLine(x+1, y, x+4, y, color);
+		++y;
+		m_screen->DrawLine(x, y, x+5, y, color);
+		++y;
+		m_screen->DrawLine(x, y, x+5, y, color);
+		++y;
+		m_screen->DrawLine(x, y, x+5, y, color);
+		++y;
+		m_screen->DrawLine(x, y, x+5, y, color);
+		++y;
+		m_screen->DrawLine(x+1, y, x+4, y, color);
+	}
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+void
+MacDialogEditbox::Init(UIElement *element)
+{
+	MacDialogDrawEngine::Init(element);
+
+	m_element->SetBorder(true);
+}
+
+//////////////////////////////////////////////////////////////////////////////
diff --git a/MacDialog.h b/MacDialog.h
index 6b9f5d97..983d9bb8 100644
--- a/MacDialog.h
+++ b/MacDialog.h
@@ -24,6 +24,7 @@
 #define _MacDialog_h
 
 #include "screenlib/UIDialog.h"
+#include "screenlib/UIDrawEngine.h"
 
 class MacDialog : public UIDialog
 {
@@ -50,4 +51,63 @@ DECLARE_TYPESAFE_CLASS(UIDialog)
 	int m_step;
 };
 
+//////////////////////////////////////////////////////////////////////////////
+
+class MacDialogDrawEngine : public UIDrawEngine
+{
+public:
+	override void Init(UIElement *element);
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+class MacDialogButton : public MacDialogDrawEngine
+{
+public:
+	MacDialogButton() : MacDialogDrawEngine() { }
+
+	override void Init(UIElement *element);
+	override void OnLoad();
+	override void OnDraw();
+	override void OnMouseDown();
+	override void OnMouseUp();
+
+protected:
+	Uint32 m_colors[2];
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+class MacDialogCheckbox : public MacDialogDrawEngine
+{
+public:
+	MacDialogCheckbox() : MacDialogDrawEngine() { }
+
+	override void Init(UIElement *element);
+	override void OnDraw();
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+class MacDialogRadioButton : public MacDialogDrawEngine
+{
+public:
+	MacDialogRadioButton() : MacDialogDrawEngine() { }
+
+	override void Init(UIElement *element);
+	override void OnDraw();
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+class MacDialogEditbox : public MacDialogDrawEngine
+{
+public:
+	MacDialogEditbox() : MacDialogDrawEngine() { }
+
+	override void Init(UIElement *element);
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
 #endif // _MacDialog_h
diff --git a/MacDialogButton.cpp b/MacDialogButton.cpp
deleted file mode 100644
index d1af8a2c..00000000
--- a/MacDialogButton.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
-    Maelstrom: Open Source version of the classic game by Ambrosia Software
-    Copyright (C) 1997-2011  Sam Lantinga
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-
-#include "screenlib/SDL_FrameBuf.h"
-#include "MacDialogButton.h"
-#include "MacDialogLabel.h"
-
-/* Default dialog button size */
-#define BUTTON_WIDTH	75
-#define BUTTON_HEIGHT	19
-
-
-UIElementType MacDialogButton::s_elementType;
-
-
-MacDialogButton::MacDialogButton(UIBaseElement *parent, const char *name) :
-	UIDialogButton(parent, name)
-{
-	m_colors[0] = m_screen->MapRGB(0xFF, 0xFF, 0xFF);
-	m_colors[1] = m_screen->MapRGB(0x00, 0x00, 0x00);
-
-	SetSize(BUTTON_WIDTH, BUTTON_HEIGHT);
-}
-
-UIElementLabel *
-MacDialogButton::CreateLabel()
-{
-	MacDialogLabel *label;
-
-	label = new MacDialogLabel(this, "label");
-	label->SetTextColor(m_colors[1]);
-	return label;
-}
-
-void
-MacDialogButton::Draw()
-{
-	Uint32 bg, fg;
-	int x, y, maxx, maxy;
-
-	/* The colors are inverted when the mouse is pressed */
-	bg = m_colors[m_mousePressed];
-	fg = m_colors[!m_mousePressed];
-
-	/* First draw the background */
-	m_screen->FillRect(X(), Y(), Width(), Height(), bg);
-
-	/* Draw the beveled edge */
-	x = X();
-	maxx = x+Width()-1;
-	y = Y();
-	maxy = y+Height()-1;
-
-	/* Top and upper corners */
-	m_screen->DrawLine(x+3, y, maxx-3, y, fg);
-	m_screen->DrawLine(x+1, y+1, x+2, y+1, fg);
-	m_screen->DrawLine(maxx-2, y+1, maxx-1, y+1, fg);
-	m_screen->DrawLine(x+1, y+2, x+1, y+2, fg);
-	m_screen->DrawLine(maxx-1, y+2, maxx-1, y+2, fg);
-
-	/* Sides */
-	m_screen->DrawLine(x, y+3, x, maxy-3, fg);
-	m_screen->DrawLine(maxx, y+3, maxx, maxy-3, fg);
-
-	/* Bottom and lower corners */
-	m_screen->DrawLine(x+1, maxy-2, x+1, maxy-2, fg);
-	m_screen->DrawLine(maxx-1, maxy-2, maxx-1, maxy-2, fg);
-	m_screen->DrawLine(x+1, maxy-1, x+2, maxy-1, fg);
-	m_screen->DrawLine(maxx-2, maxy-1, maxx-1, maxy-1, fg);
-	m_screen->DrawLine(x+3, maxy, maxx-3, maxy, fg);
-
-	if (m_default) {
-		/* Show the thick edge */
-		x = X()-4;
-		maxx = x+4+Width()+4-1;
-		y = Y()-4;
-		maxy = y+4+Height()+4-1;
-
-		/* The edge always uses the real foreground color */
-		fg = m_colors[1];
-
-		m_screen->DrawLine(x+5, y, maxx-5, y, fg);
-		m_screen->DrawLine(x+3, y+1, maxx-3, y+1, fg);
-		m_screen->DrawLine(x+2, y+2, maxx-2, y+2, fg);
-		m_screen->DrawLine(x+1, y+3, x+5, y+3, fg);
-		m_screen->DrawLine(maxx-5, y+3, maxx-1, y+3, fg);
-		m_screen->DrawLine(x+1, y+4, x+3, y+4, fg);
-		m_screen->DrawLine(maxx-3, y+4, maxx-1, y+4, fg);
-		m_screen->DrawLine(x, y+5, x+3, y+5, fg);
-		m_screen->DrawLine(maxx-3, y+5, maxx, y+5, fg);
-
-		m_screen->DrawLine(x, y+6, x, maxy-6, fg);
-		m_screen->DrawLine(maxx, y+6, maxx, maxy-6, fg);
-		m_screen->DrawLine(x+1, y+6, x+1, maxy-6, fg);
-		m_screen->DrawLine(maxx-1, y+6, maxx-1, maxy-6, fg);
-		m_screen->DrawLine(x+2, y+6, x+2, maxy-6, fg);
-		m_screen->DrawLine(maxx-2, y+6, maxx-2, maxy-6, fg);
-
-		m_screen->DrawLine(x, maxy-5, x+3, maxy-5, fg);
-		m_screen->DrawLine(maxx-3, maxy-5, maxx, maxy-5, fg);
-		m_screen->DrawLine(x+1, maxy-4, x+3, maxy-4, fg);
-		m_screen->DrawLine(maxx-3, maxy-4, maxx-1, maxy-4, fg);
-		m_screen->DrawLine(x+1, maxy-3, x+5, maxy-3, fg);
-		m_screen->DrawLine(maxx-5, maxy-3, maxx-1, maxy-3, fg);
-		m_screen->DrawLine(x+2, maxy-2, maxx-2, maxy-2, fg);
-		m_screen->DrawLine(x+3, maxy-1, maxx-3, maxy-1, fg);
-		m_screen->DrawLine(x+5, maxy, maxx-5, maxy, fg);
-	}
-
-	UIDialogButton::Draw();
-}
-
-void
-MacDialogButton::OnMouseDown()
-{
-	SetElementColor(m_colors[0]);
-
-	UIDialogButton::OnMouseDown();
-}
-
-void
-MacDialogButton::OnMouseUp()
-{
-	SetElementColor(m_colors[1]);
-
-	UIDialogButton::OnMouseUp();
-}
-
-void
-MacDialogButton::SetElementColor(Uint32 color)
-{
-	array<UIElementLabel*> labels;
-	Uint8 R, G, B;
-
-	m_screen->GetRGB(color, &R, &G, &B);
-	FindElements<UIElementLabel>(labels);
-	for (unsigned i = 0; i < labels.length(); ++i) {
-		labels[i]->SetTextColor(R, G, B);
-	}
-}
diff --git a/MacDialogButton.h b/MacDialogButton.h
deleted file mode 100644
index aa4cb1b6..00000000
--- a/MacDialogButton.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-    Maelstrom: Open Source version of the classic game by Ambrosia Software
-    Copyright (C) 1997-2011  Sam Lantinga
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-
-#ifndef _MacDialogButton_h
-#define _MacDialogButton_h
-
-#include "screenlib/UIDialogButton.h"
-
-
-class MacDialogButton : public UIDialogButton
-{
-DECLARE_TYPESAFE_CLASS(UIDialogButton)
-public:
-	MacDialogButton(UIBaseElement *parent, const char *name = "");
-
-	override void Draw();
-
-	override void OnMouseDown();
-	override void OnMouseUp();
-
-protected:
-	override UIElementLabel *CreateLabel();
-
-	void SetElementColor(Uint32 color);
-
-protected:
-	Uint32 m_colors[2];
-};
-
-#endif // _MacDialogButton_h
diff --git a/MacDialogCheckbox.cpp b/MacDialogCheckbox.cpp
deleted file mode 100644
index 4b9a44c7..00000000
--- a/MacDialogCheckbox.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-    Maelstrom: Open Source version of the classic game by Ambrosia Software
-    Copyright (C) 1997-2011  Sam Lantinga
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-
-#include "screenlib/SDL_FrameBuf.h"
-#include "MacDialogCheckbox.h"
-#include "MacDialogLabel.h"
-
-/* Default checkbox size */
-#define CHECKBOX_SIZE	12
-
-
-UIElementType MacDialogCheckbox::s_elementType;
-
-
-MacDialogCheckbox::MacDialogCheckbox(UIBaseElement *parent, const char *name) :
-	UIElementCheckbox(parent, name)
-{
-	m_color = m_screen->MapRGB(0x00, 0x00, 0x00);
-
-	SetSize(CHECKBOX_SIZE, CHECKBOX_SIZE);
-}
-
-UIElementLabel *
-MacDialogCheckbox::CreateLabel()
-{
-	MacDialogLabel *label;
-
-	label = new MacDialogLabel(this, "label");
-	label->SetTextColor(m_color);
-	label->SetAnchor(TOPLEFT, TOPLEFT, this, CHECKBOX_SIZE+3, -2);
-	return label;
-}
-
-void
-MacDialogCheckbox::Draw()
-{
-	m_screen->DrawRect(X(), Y(), CHECKBOX_SIZE, CHECKBOX_SIZE, m_color);
-
-	if ( IsChecked() ) {
-		m_screen->DrawLine(X(), Y(), X()+CHECKBOX_SIZE-1,
-					Y()+CHECKBOX_SIZE-1, m_color);
-		m_screen->DrawLine(X(), Y()+CHECKBOX_SIZE-1,
-					X()+CHECKBOX_SIZE-1, Y(), m_color);
-	}
-
-	UIElementButton::Draw();
-}
diff --git a/MacDialogCheckbox.h b/MacDialogCheckbox.h
deleted file mode 100644
index 232a45d7..00000000
--- a/MacDialogCheckbox.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-    Maelstrom: Open Source version of the classic game by Ambrosia Software
-    Copyright (C) 1997-2011  Sam Lantinga
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-
-#ifndef _MacDialogCheckbox_h
-#define _MacDialogCheckbox_h
-
-#include "screenlib/UIElementCheckbox.h"
-
-
-class MacDialogCheckbox : public UIElementCheckbox
-{
-DECLARE_TYPESAFE_CLASS(UIElementCheckbox)
-public:
-	MacDialogCheckbox(UIBaseElement *parent, const char *name = "");
-
-	override void Draw();
-
-protected:
-	override UIElementLabel *CreateLabel();
-
-protected:
-	Uint32 m_color;
-};
-
-#endif // _MacDialogCheckbox_h
diff --git a/MacDialogEditbox.cpp b/MacDialogEditbox.cpp
deleted file mode 100644
index c4234d76..00000000
--- a/MacDialogEditbox.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-    Maelstrom: Open Source version of the classic game by Ambrosia Software
-    Copyright (C) 1997-2011  Sam Lantinga
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-
-#include "screenlib/SDL_FrameBuf.h"
-#include "MacDialogEditbox.h"
-#include "MacDialogLabel.h"
-
-UIElementType MacDialogEditbox::s_elementType;
-
-
-MacDialogEditbox::MacDialogEditbox(UIBaseElement *parent, const char *name) :
-	UIElementEditbox(parent, name)
-{
-	m_colors[0] = m_screen->MapRGB(0xFF, 0xFF, 0xFF);
-	m_colors[1] = m_screen->MapRGB(0x00, 0x00, 0x00);
-}
-
-UIElementLabel *
-MacDialogEditbox::CreateLabel()
-{
-	MacDialogLabel *label;
-
-	label = new MacDialogLabel(this, "label");
-	label->SetTextColor(m_colors[1]);
-	label->SetAnchor(LEFT, LEFT, this, 3, 0);
-	return label;
-}
-
-void
-MacDialogEditbox::OnHighlightChanged()
-{
-	SetElementColor(m_colors[!m_highlight]);
-}
-
-void
-MacDialogEditbox::Draw()
-{
-	Uint32 bg, fg;
-
-	/* The colors are inverted when the editbox is highlighted */
-	bg = m_colors[m_highlight];
-	fg = m_colors[!m_highlight];
-
-	// Draw the outline, always in the real foreground color
-	m_screen->DrawRect(X(), Y(), Width(), Height(), m_colors[1]);
-
-	if (m_highlight) {
-		// Draw the highlight
-		m_screen->FillRect(X()+3, Y()+3, Width()-6, Height()-6, bg);
-	} else if (m_focus) {
-		// Draw the cursor
-		int x = m_label->X() + m_label->Width();
-
-		m_screen->DrawLine(x, Y()+3, x, Y()+3+Height()-6-1, fg);
-	}
-
-	UIElementEditbox::Draw();
-}
-
-void
-MacDialogEditbox::SetElementColor(Uint32 color)
-{
-	array<UIElementLabel*> labels;
-	Uint8 R, G, B;
-
-	m_screen->GetRGB(color, &R, &G, &B);
-	FindElements<UIElementLabel>(labels);
-	for (unsigned i = 0; i < labels.length(); ++i) {
-		labels[i]->SetTextColor(R, G, B);
-	}
-}
diff --git a/MacDialogEditbox.h b/MacDialogEditbox.h
deleted file mode 100644
index d9687511..00000000
--- a/MacDialogEditbox.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-    Maelstrom: Open Source version of the classic game by Ambrosia Software
-    Copyright (C) 1997-2011  Sam Lantinga
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-
-#ifndef _MacDialogEditbox_h
-#define _MacDialogEditbox_h
-
-#include "screenlib/UIElementEditbox.h"
-
-
-class MacDialogEditbox : public UIElementEditbox
-{
-DECLARE_TYPESAFE_CLASS(UIElementEditbox)
-public:
-	MacDialogEditbox(UIBaseElement *parent, const char *name = "");
-
-	override void Draw();
-
-protected:
-	override UIElementLabel *CreateLabel();
-	override void OnHighlightChanged();
-
-	void SetElementColor(Uint32 color);
-
-protected:
-	Uint32 m_colors[2];
-};
-
-#endif // _MacDialogEditbox_h
diff --git a/MacDialogLabel.cpp b/MacDialogLabel.cpp
deleted file mode 100644
index a305b138..00000000
--- a/MacDialogLabel.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-    Maelstrom: Open Source version of the classic game by Ambrosia Software
-    Copyright (C) 1997-2011  Sam Lantinga
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-
-#include "MacDialogLabel.h"
-#include "Maelstrom_Globals.h"
-
-UIElementType MacDialogLabel::s_elementType;
-
-
-MacDialogLabel::MacDialogLabel(UIBaseElement *parent, const char *name) :
-	UIElementLabel(parent, name)
-{
-	m_fontName = SDL_strdup("Chicago");
-	m_fontSize = 12;
-	m_color = m_screen->MapRGB(0x00, 0x00, 0x00);
-}
diff --git a/MacDialogLabel.h b/MacDialogLabel.h
deleted file mode 100644
index 0a45c3c9..00000000
--- a/MacDialogLabel.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-    Maelstrom: Open Source version of the classic game by Ambrosia Software
-    Copyright (C) 1997-2011  Sam Lantinga
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-
-#ifndef _MacDialogLabel_h
-#define _MacDialogLabel_h
-
-#include "screenlib/UIElementLabel.h"
-
-class MacDialogLabel : public UIElementLabel
-{
-DECLARE_TYPESAFE_CLASS(UIElementLabel)
-public:
-	MacDialogLabel(UIBaseElement *parent, const char *name = "");
-};
-
-#endif // _MacDialogLabel_h
diff --git a/MacDialogRadioButton.cpp b/MacDialogRadioButton.cpp
deleted file mode 100644
index 20b66520..00000000
--- a/MacDialogRadioButton.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-    Maelstrom: Open Source version of the classic game by Ambrosia Software
-    Copyright (C) 1997-2011  Sam Lantinga
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-
-#include "screenlib/SDL_FrameBuf.h"
-#include "MacDialogRadioButton.h"
-#include "MacDialogLabel.h"
-
-/* Default checkbox size

(Patch may be truncated, please check the link at the top of this post.)