GUIlib: Initial commit of GUIlib 1.2.1

From 6e5b71e304acb0e6e4a8b929db595138c654981d Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 20 Jun 2022 08:11:02 -0700
Subject: [PATCH] Initial commit of GUIlib 1.2.1

---
 CHANGES           |    73 +
 COPYING           |     3 +
 GUI.cpp           |   199 +
 GUI.h             |    72 +
 GUI_C.cpp         |    57 +
 GUI_C.h           |    73 +
 GUI_area.cpp      |   113 +
 GUI_area.h        |    47 +
 GUI_button.cpp    |   364 +
 GUI_button.h      |   107 +
 GUI_font.cpp      |   106 +
 GUI_font.h        |    59 +
 GUI_generic.cpp   |    87 +
 GUI_generic.h     |    42 +
 GUI_image.cpp     |    47 +
 GUI_image.h       |    34 +
 GUI_loadimage.cpp |    50 +
 GUI_loadimage.h   |    33 +
 GUI_menu.cpp      |   234 +
 GUI_menu.h        |   116 +
 GUI_output.cpp    |   368 +
 GUI_output.h      |    79 +
 GUI_scroll.h      |    32 +
 GUI_scrollbar.cpp |   174 +
 GUI_scrollbar.h   |    81 +
 GUI_status.h      |    26 +
 GUI_termwin.cpp   |   267 +
 GUI_termwin.h     |    84 +
 GUI_types.h       |    26 +
 GUI_widget.cpp    |   253 +
 GUI_widget.h      |   133 +
 GUI_widgets.h     |    18 +
 MPWmake.sea.hqx   |   430 +
 Makefile.am       |    70 +
 Makefile.in       |   766 ++
 README            |    29 +
 acinclude.m4      |  6591 +++++++++++++++
 aclocal.m4        |  1021 +++
 autogen.sh        |     8 +
 cancel_img.h      |   102 +
 config.guess      |  1479 ++++
 config.sub        |  1606 ++++
 configure         | 20199 ++++++++++++++++++++++++++++++++++++++++++++
 configure.in      |    68 +
 depcomp           |   529 ++
 genimage.c        |    67 +
 hello.bmp         |   Bin 0 -> 5174 bytes
 hello.cpp         |   159 +
 hello2.bmp        |   Bin 0 -> 2126 bytes
 hello_C.c         |   141 +
 install-sh        |   251 +
 keyboard.cpp      |   112 +
 ltmain.sh         |  6864 +++++++++++++++
 missing           |   190 +
 mkinstalldirs     |    40 +
 okay.c            |    35 +
 okay_img.h        |   102 +
 scroll_dn.bmp     |   Bin 0 -> 822 bytes
 scroll_up.bmp     |   Bin 0 -> 822 bytes
 the_checker.h     |    80 +
 the_font.h        |   214 +
 61 files changed, 44610 insertions(+)
 create mode 100644 CHANGES
 create mode 100644 COPYING
 create mode 100644 GUI.cpp
 create mode 100644 GUI.h
 create mode 100644 GUI_C.cpp
 create mode 100644 GUI_C.h
 create mode 100644 GUI_area.cpp
 create mode 100644 GUI_area.h
 create mode 100644 GUI_button.cpp
 create mode 100644 GUI_button.h
 create mode 100644 GUI_font.cpp
 create mode 100644 GUI_font.h
 create mode 100644 GUI_generic.cpp
 create mode 100644 GUI_generic.h
 create mode 100644 GUI_image.cpp
 create mode 100644 GUI_image.h
 create mode 100644 GUI_loadimage.cpp
 create mode 100644 GUI_loadimage.h
 create mode 100644 GUI_menu.cpp
 create mode 100644 GUI_menu.h
 create mode 100644 GUI_output.cpp
 create mode 100644 GUI_output.h
 create mode 100644 GUI_scroll.h
 create mode 100644 GUI_scrollbar.cpp
 create mode 100644 GUI_scrollbar.h
 create mode 100644 GUI_status.h
 create mode 100644 GUI_termwin.cpp
 create mode 100644 GUI_termwin.h
 create mode 100644 GUI_types.h
 create mode 100644 GUI_widget.cpp
 create mode 100644 GUI_widget.h
 create mode 100644 GUI_widgets.h
 create mode 100644 MPWmake.sea.hqx
 create mode 100644 Makefile.am
 create mode 100644 Makefile.in
 create mode 100644 README
 create mode 100644 acinclude.m4
 create mode 100644 aclocal.m4
 create mode 100755 autogen.sh
 create mode 100644 cancel_img.h
 create mode 100644 config.guess
 create mode 100644 config.sub
 create mode 100755 configure
 create mode 100644 configure.in
 create mode 100755 depcomp
 create mode 100644 genimage.c
 create mode 100644 hello.bmp
 create mode 100644 hello.cpp
 create mode 100644 hello2.bmp
 create mode 100644 hello_C.c
 create mode 100644 install-sh
 create mode 100644 keyboard.cpp
 create mode 100644 ltmain.sh
 create mode 100644 missing
 create mode 100644 mkinstalldirs
 create mode 100644 okay.c
 create mode 100644 okay_img.h
 create mode 100644 scroll_dn.bmp
 create mode 100644 scroll_up.bmp
 create mode 100644 the_checker.h
 create mode 100644 the_font.h

diff --git a/CHANGES b/CHANGES
new file mode 100644
index 0000000..7611f2f
--- /dev/null
+++ b/CHANGES
@@ -0,0 +1,73 @@
+1.2.0:
+Sam Lantinga - Tue Apr  3 10:52:19 PDT 2007
+ * Placed in the public domain
+
+1.1.2:
+Sam Lantinga - Mon May  1 00:42:02 PDT 2006
+ * Updated automake and libtool support
+
+1.1.0:
+Rainer Loritz <rloritz@gwdg.de> - Wed Apr  5 21:17:58 PDT 2000
+- fixed bug in GUI_Image: First constructor called second one, both called
+inherited constructors -> messed up. No more.
+
+- added GUI_Button feature: One may specify a second image for a real click and
+release look and feel which is also reacting when moving the pointer off the
+button.
+
+- added another GUI_Button feature: With Disable() and Enable() one can
+tell a button to be clickable or not. It is then appropiately displayed.
+
+- modified GUI event behaviour: Before, GUI ran with full CPU workload even
+without given an idle procedure. Now it uses the idle-friendly WaitEvent if
+such a flag is given to the Run procedure. The calls to widget-idle
+procedures are sacrificed in this case :-(.
+
+- added GUI_Area feature: With another constructor one may specify a
+frame color and thickness for the edge of the area.
+
+- added GUI_Area feature: With an optional parameter a shape of the area can
+be determined. So far either a rectangular or an elliptic (adjusted to area)
+shape is possible.
+
+- added GUI_TermWin feature: With "SetColoring" one can specify a foreground
+and a background color where the background can be left transparent.
+
+- new GUI_Font object: Given either a BMP name or surface (or nothing), it
+represents a font with possibilities to plot colored text in opaque or
+transparent mode.
+
+- added GUI_button features: An additional constructor provides a way to
+specify a text from which a 3D or 2D  button is generated (in gray colours).
+A new option allows to determine the text alignment.
+
+- added GUI_widget function: Redraw() redisplays ONLY the widget because
+complete GUI_REDRAW consumes much time.
+*** HERE I FOUND AN DOCUM. ERROR: the comments say the surface will be locked
+*** before a call to Display(). This is not true and it should be in no case,
+*** because otherwise inside Display() there wouldn't be allowed any SDL
+*** graphics functions as FillRect etc.
+
+- new GUI_Menu object: Pulldown menus in SDL! Very straightforward menu design,
+but may be a complicated way of internal coding. The GUI_Menu is using the
+GUI_Submenu and GUI_Menuitem classes to control the menu behaviour. It's all
+quite up and down design, but it works. The programmer has contact only with
+GUI_Menu and MUST NOT add the GUI_Submenu/items to the GUI himself.
+Everything is managed by GUI_Menu.
+
+- new button feature: check marks. Originally thought for menus, but should
+work generally.
+
+TO DO:	- menu memory management is bad
+	- graphical functions for ellipse and boundary fill
+	- (improved keyboard functions as input focus, tab order etc.)
+
+TOUCHED FILES:	GUI_image.cpp, GUI_widget.h/cpp, GUI_button.h/cpp,
+		GUI_output.h, GUI.cpp, GUI_area.h/cpp, GUI_TermWin.h/cpp,
+		hello.cpp
+
+NEW FILES:	GUI_font.h/cpp, GUI_menu.h/cpp
+
+1.0.1:
+Sam Lantinga - Wed Apr  5 21:12:17 PDT 2000
+ * Ported GUIlib to MacOS
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..2e5f5ec
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,3 @@
+
+GUIlib is in the public domain and is no longer supported.
+It may be used by anyone for any purpose with no warrantee.
diff --git a/GUI.cpp b/GUI.cpp
new file mode 100644
index 0000000..cd68c5e
--- /dev/null
+++ b/GUI.cpp
@@ -0,0 +1,199 @@
+/*
+    GUILIB:  An example GUI framework library for use with SDL
+*/
+
+/* This is a C++ class for handling a GUI, and associated widgets */
+
+#include <stdlib.h>
+
+#include "GUI.h"
+
+/* Number of widget elements to allocate at once */
+#define WIDGET_ARRAYCHUNK	32
+
+
+GUI:: GUI(SDL_Surface *display)
+{
+	screen = display;
+	numwidgets = 0;
+	maxwidgets = 0;
+	widgets = NULL;
+}
+
+GUI:: ~GUI()
+{
+	if ( widgets != NULL ) {
+		for ( int i=0; i<numwidgets; ++i ) {
+			delete widgets[i];
+		}
+		free(widgets);
+	}
+}
+
+/* Add a widget to the GUI.
+   The widget will be automatically deleted when the GUI is deleted.
+ */
+int
+GUI:: AddWidget(GUI_Widget *widget)
+{
+	int i;
+
+	/* Look for deleted widgets */
+	for ( i=0; i<numwidgets; ++i ) {
+		if ( widgets[i]->Status() == WIDGET_DELETED ) {
+			delete widgets[i];
+			break;
+		}
+	}
+	if ( i == numwidgets ) {
+		/* Expand the widgets array if necessary */
+		if ( numwidgets == maxwidgets ) {
+			GUI_Widget **newarray;
+			int maxarray;
+
+			maxarray = maxwidgets + WIDGET_ARRAYCHUNK;
+			if ( (newarray=(GUI_Widget **)realloc(widgets,
+					maxarray*sizeof(*newarray))) == NULL ) {
+				return(-1);
+			}
+			widgets = newarray;
+			maxwidgets = maxarray;
+		}
+		++numwidgets;
+	}
+	widgets[i] = widget;
+	widget->SetDisplay(screen);
+	return(0);
+}
+
+void
+GUI:: Display(void)
+{
+	int i;
+
+	for ( i=0; i<numwidgets; ++i ) {
+		if ( widgets[i]->Status() == WIDGET_VISIBLE ) {
+			widgets[i]->Display();
+		}
+	}
+	SDL_UpdateRect(screen, 0, 0, 0, 0);
+}
+
+/* Function to handle a GUI status */
+void
+GUI:: HandleStatus(GUI_status status)
+{
+	switch (status) {
+		case GUI_QUIT:
+			running = 0;
+			break;
+		case GUI_REDRAW:
+			display = 1;
+			break;
+		default:
+			break;
+	}
+}
+
+/* Handle an event, passing it to widgets until they return a status */
+void 
+GUI:: HandleEvent(const SDL_Event *event)
+{
+	int i;
+	GUI_status status;
+
+	switch (event->type) {
+		/* SDL_QUIT events quit the GUI */
+		case SDL_QUIT:
+			status = GUI_QUIT;
+			break;
+
+		/* Keyboard and mouse events go to widgets */
+		case SDL_KEYDOWN:
+		case SDL_KEYUP:
+		case SDL_MOUSEMOTION:
+		case SDL_MOUSEBUTTONDOWN:
+		case SDL_MOUSEBUTTONUP:
+			/* Go through widgets, topmost first */
+			status = GUI_PASS;
+			for (i=numwidgets-1; (i>=0)&&(status==GUI_PASS); --i) {
+				if ( widgets[i]->Status() == WIDGET_VISIBLE ) {
+					status = widgets[i]->HandleEvent(event);
+				}
+			}
+			break;
+
+		/* Ignore unhandled events */
+		default:
+			status = GUI_PASS;
+			break;
+	}
+	HandleStatus(status);
+}
+
+/* Run the GUI.
+   This returns when either a widget requests a quit, the idle
+   function requests a quit, or the SDL window has been closed.
+ */
+void
+GUI:: Run(GUI_IdleProc idle, int once, int multitaskfriendly)
+{
+	int i;
+	SDL_Event event;
+
+	/* If there's nothing to do, return immediately */
+	if ( (numwidgets == 0) && (idle == NULL) ) {
+		return;
+	}
+
+	running = 1;
+	if ( ! once ) {
+		display = 1;
+	}
+	do {
+		/* Garbage collection */
+		for ( i=0; i<numwidgets; ++i ) {
+			if ( widgets[i]->Status() == WIDGET_DELETED ) {
+				delete widgets[i];
+				for ( int j=i+1; j<numwidgets; ++j ) {
+					widgets[j-1] = widgets[j];
+				}
+				--numwidgets;
+			}
+		}
+
+		/* Display widgets if necessary */
+		if ( display ) {
+			Display();
+			display = 0;
+		}
+
+///////////////////////////////////////////////////////////////// Polling is time consuming - instead:
+		if (multitaskfriendly && (idle==NULL))
+		{
+		  SDL_WaitEvent(&event);
+		  HandleEvent(&event);
+		}
+		else
+/////////////////////////////////////////////////////////////////
+		/* Handle events, or run idle functions */
+		if ( SDL_PollEvent(&event) )
+		{
+			/* Handle all pending events */
+			do {
+				HandleEvent(&event);
+			} while ( SDL_PollEvent(&event) );
+		}
+		else
+		{
+			if ( idle != NULL )
+			{
+				HandleStatus(idle());
+			}
+			for ( i=numwidgets-1; i>=0; --i ) {
+				HandleStatus(widgets[i]->Idle());
+			}
+		}
+		SDL_Delay(10);
+	} while ( running && ! once );
+}
diff --git a/GUI.h b/GUI.h
new file mode 100644
index 0000000..fdaad9d
--- /dev/null
+++ b/GUI.h
@@ -0,0 +1,72 @@
+/*
+    GUILIB:  An example GUI framework library for use with SDL
+*/
+
+/* This is a C++ class for handling a GUI, and associated widgets */
+
+#ifndef _GUI_h
+#define _GUI_h
+
+#include "SDL.h"
+#include "GUI_status.h"
+#include "GUI_widget.h"
+
+
+class GUI {
+
+public:
+	GUI(SDL_Surface *display);
+	~GUI();
+
+	/* Add a widget to the GUI.
+	   The widget will be automatically deleted when the GUI is deleted.
+	   This function returns 0, or -1 if the function ran out of memory.
+	 */
+	int AddWidget(GUI_Widget *widget);
+
+	/* Display the GUI manually */
+	void Display(void);
+
+	/* Returns will return true if the GUI is still ready to handle
+	   events after a call to Run(), and false if a widget or idle
+	   function requested a quit.
+	 */
+	int Running(void) {
+		return(running);
+	}
+
+	/* Run the GUI.
+	   This returns when either a widget requests a quit, the idle
+	   function requests a quit, or the SDL window has been closed.
+	   If 'once' is non-zero, you need to display the GUI yourself,
+	   and the GUI event loop will run once and then return.
+	   If 'multitaskfriendly' is non-zero AND idle is NULL,
+	   a 'WaitEvent' will be used instead of the CPU time
+	   consuming 'PollEvent'. CAVE: Any widget-'idle'-procs WON'T
+	   be executed then.
+	 */
+	void Run(GUI_IdleProc idle = NULL, int once = 0, int multitaskfriendly = 0);
+
+protected:
+	/* The display surface */
+	SDL_Surface *screen;
+
+	/* Pointers for an array of widgets */
+	int maxwidgets;
+	int numwidgets;
+	GUI_Widget **widgets;
+
+	/* Flag - whether or not the GUI is currently running */
+	int running;
+
+	/* Flag - whether or not the GUI needs to be displayed */
+	int display;
+
+	/* Function to handle a GUI status */
+	void HandleStatus(GUI_status status);
+
+	/* Function to pass an event to the GUI widgets */
+	void HandleEvent(const SDL_Event *event);
+};
+
+#endif /* _GUI_h */
diff --git a/GUI_C.cpp b/GUI_C.cpp
new file mode 100644
index 0000000..97f4c51
--- /dev/null
+++ b/GUI_C.cpp
@@ -0,0 +1,57 @@
+/*
+    GUILIB:  An example GUI framework library for use with SDL
+*/
+
+/* This file provides a simple C interface to the C++ GUI classes */
+
+#include "GUI.h"
+#include "GUI_generic.h"
+
+extern "C" {
+
+/* Create a GUI */
+CGUI *GUI_Create(SDL_Surface *screen)
+{
+	return((CGUI *)new GUI(screen));
+}
+
+/* Create a generic widget */
+CGUI_Widget *GUI_Widget_Create(void *data, int x, int y, int w, int h,
+	GUI_DrawProc drawproc, GUI_EventProc eventproc, GUI_FreeProc freeproc)
+{
+	GUI_Widget *widget;
+
+	widget = new GUI_GenericWidget(data, drawproc, eventproc, freeproc);
+	widget->SetRect(x, y, w, h);
+	return((CGUI_Widget *)widget);
+}
+
+/* Add a widget to a GUI */
+int GUI_AddWidget(CGUI *gui, CGUI_Widget *widget)
+{
+	return(((GUI *)gui)->AddWidget((GUI_Widget *)widget));
+}
+
+/* Move or resize a widget 
+   If any of the parameters are -1, that parameter is not changed. 
+ */
+void GUI_MoveWidget(CGUI_Widget *widget, int x, int y, int w, int h)
+{
+	((GUI_Widget *)widget)->SetRect(x, y, w, h);
+	((GUI_Widget *)widget)->Display();
+}
+
+/* Run a GUI until the widgets request a quit */
+void GUI_Run(CGUI *gui, GUI_IdleProc idle)
+{
+	((GUI *)gui)->Run(idle);
+}
+
+/* Delete a previously created GUI */
+void GUI_Destroy(CGUI *gui)
+{
+	delete (GUI *)gui;
+}
+
+/* End of extern C declaration */
+};
diff --git a/GUI_C.h b/GUI_C.h
new file mode 100644
index 0000000..f4b8b6a
--- /dev/null
+++ b/GUI_C.h
@@ -0,0 +1,73 @@
+/*
+    GUILIB:  An example GUI framework library for use with SDL
+*/
+
+/* This file provides a simple C interface to the C++ GUI classes */
+
+#ifndef _GUI_C_h
+#define _GUI_C_h
+
+#include "SDL.h"
+#include "GUI_status.h"
+
+#include "begin_code.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Definitions for the C versions of the GUI and widget objects */
+struct CGUI;
+typedef struct CGUI CGUI;
+
+struct CGUI_Widget;
+typedef struct CGUI_Widget CGUI_Widget;
+
+typedef struct widget_info {
+	/* A generic pointer to user-specified data for the widget.
+	 */
+	void *widget_data;
+
+	/* The display surface for the widget */
+	SDL_Surface *screen;
+
+	/* The area covered by the widget */
+	SDL_Rect area;
+
+} widget_info;
+
+/* Generic widget callback functions (used by C interface) */
+typedef void (*GUI_DrawProc)(widget_info *info);
+typedef GUI_status (*GUI_EventProc)(widget_info *info, const SDL_Event *event);
+typedef void (*GUI_FreeProc)(widget_info *info);
+
+
+/* Create a GUI */
+extern CGUI *GUI_Create(SDL_Surface *screen);
+
+/* Create a generic widget */
+extern CGUI_Widget *GUI_Widget_Create(void *data, int x, int y, int w, int h,
+	GUI_DrawProc drawproc, GUI_EventProc eventproc, GUI_FreeProc freeproc);
+
+/* Add a widget to a GUI.
+   Once the widget has been added, it doesn't need to be freed.
+   This function returns 0, or -1 if it ran out of memory.
+ */
+extern int GUI_AddWidget(CGUI *gui, CGUI_Widget *widget);
+
+/* Move or resize a widget
+   If any of the parameters are -1, that parameter is not changed.
+ */
+extern void GUI_MoveWidget(CGUI_Widget *widget, int x, int y, int w, int h);
+
+/* Run a GUI until the widgets or idleproc request a quit */
+extern void GUI_Run(CGUI *gui, GUI_IdleProc idle);
+
+/* Delete a previously created GUI */
+extern void GUI_Destroy(CGUI *gui);
+
+#ifdef __cplusplus
+};
+#endif
+#include "close_code.h"
+
+#endif /* _GUI_C_h */
diff --git a/GUI_area.cpp b/GUI_area.cpp
new file mode 100644
index 0000000..4454331
--- /dev/null
+++ b/GUI_area.cpp
@@ -0,0 +1,113 @@
+/*
+    GUILIB:  An example GUI framework library for use with SDL
+*/
+
+#include "GUI_area.h"
+#include "math.h"
+//#include "GUI_utils.h"
+
+GUI_Area:: GUI_Area(int x, int y, int w, int h, Uint8 r, Uint8 g, Uint8 b, int aShape)
+ : GUI_Widget(NULL, x, y, w, h)
+{
+	R = r;
+	G = g;
+	B = b;
+	color = 0;
+	useFrame=0;
+	shape=aShape;
+}
+
+GUI_Area:: GUI_Area(int x, int y, int w, int h, Uint8 r, Uint8 g, Uint8 b,
+			Uint8 fr, Uint8 fg, Uint8 fb, int fthick, int aShape)
+ : GUI_Widget(NULL, x, y, w, h)
+{
+	R = r;
+	G = g;
+	B = b;
+	color = 0;
+	useFrame=1;
+	fR = fr;
+	fG = fg;
+	fB = fb;
+	frameColor=0;
+	frameThickness=fthick;
+	shape=aShape;
+}
+
+/* Map the color to the display */
+void
+GUI_Area:: SetDisplay(SDL_Surface *display)
+{
+	GUI_Widget::SetDisplay(display);
+	color = SDL_MapRGB(screen->format, R, G, B);
+	if (useFrame)
+	  frameColor = SDL_MapRGB(screen->format, fR, fG, fB);
+}
+
+/* Show the widget  */
+void
+GUI_Area:: Display(void)
+{
+	SDL_Rect framerect;
+	int x,dy,r1,r2,x0,y0;
+
+	switch (shape)
+	{
+	case AREA_ROUND:
+
+	  r1=area.w >> 1;
+	  r2=area.h >> 1;
+	  x0=area.x+r1;
+	  y0=area.y+r2;
+	  for (x=area.x;x<area.x+area.w;x++)
+	  {
+	    dy=(int)((double) r2*sin(acos((double) (x-x0)/(double) r1)));
+	    framerect.x=x; framerect.y=y0-dy;
+	    framerect.w=1; framerect.h=dy << 1;
+	    SDL_FillRect(screen,&framerect,color);
+	    if (useFrame)
+	    {
+	      if ((x==area.x) || (x==area.x+area.w-1))
+	      {
+	        SDL_FillRect(screen,&framerect,frameColor);
+	      }
+	      framerect.h=frameThickness;
+	      SDL_FillRect(screen,&framerect,frameColor);
+	      framerect.y=y0+dy-frameThickness;
+	      SDL_FillRect(screen,&framerect,frameColor);
+	    }
+	  }
+/*
+******** GUI_FillEllipse is not ready yet, GUI_BoundaryFill either *****
+	    framerect=area;
+	    if (useFrame)
+	    {
+	      GUI_FillEllipse(screen,&framerect,frameColor);
+	      area.x+=frameThickness; area.w-=frameThickness << 1;
+	      area.y+=frameThickness; area.h-=frameThickness << 1;
+	    }
+	    GUI_FillEllipse(screen,&framerect,color);
+*/
+	  break;
+
+	case AREA_ANGULAR:
+	  SDL_FillRect(screen, &area, color);
+
+	  /* draw frame */
+	  if (useFrame)
+	  {
+	    framerect=area;
+	    framerect.h=frameThickness;
+	    SDL_FillRect(screen, &framerect, frameColor);
+	    framerect.y+=area.h-frameThickness;
+	    SDL_FillRect(screen, &framerect, frameColor);
+	    framerect.y=area.y;
+	    framerect.h=area.h;
+	    framerect.w=frameThickness;
+	    SDL_FillRect(screen, &framerect, frameColor);
+	    framerect.x+=area.w-frameThickness;
+	    SDL_FillRect(screen, &framerect, frameColor);
+	  }
+	  break;
+	}
+}
diff --git a/GUI_area.h b/GUI_area.h
new file mode 100644
index 0000000..8600bb1
--- /dev/null
+++ b/GUI_area.h
@@ -0,0 +1,47 @@
+/*
+    GUILIB:  An example GUI framework library for use with SDL
+*/
+
+/* This is a simple colored area widget -- rectangular or round  */
+
+#ifndef _GUI_area_h
+#define _GUI_area_h
+
+#include "GUI_widget.h"
+
+#define AREA_ROUND 1
+#define AREA_ANGULAR 2
+
+class GUI_Area : public GUI_Widget {
+
+public:
+	/* Passed the area, color and shape */
+	GUI_Area(int x, int y, int w, int h, Uint8 r, Uint8 g, Uint8 b, int aShape = AREA_ANGULAR);
+
+	/* Passed the area, color, frame color, frame thickness and shape */
+	GUI_Area(int x, int y, int w, int h, Uint8 r, Uint8 g, Uint8 b,
+			Uint8 fr, Uint8 fg, Uint8 fb, int fthick, int aShape = AREA_ANGULAR);
+
+	/* Map the color to the display */
+	virtual void SetDisplay(SDL_Surface *display);
+
+	/* Show the widget  */
+	virtual void Display(void);
+
+protected:
+	Uint8 R, G, B;
+	Uint32 color;
+
+	/* flag */
+	int useFrame;
+
+	/* frame color values */
+	Uint8 fR,fG,fB;
+	Uint32 frameColor;
+
+	/* remember me */
+	int frameThickness;
+	int shape;
+};
+
+#endif /* _GUI_area_h */
diff --git a/GUI_button.cpp b/GUI_button.cpp
new file mode 100644
index 0000000..0d746ed
--- /dev/null
+++ b/GUI_button.cpp
@@ -0,0 +1,364 @@
+/*
+    GUILIB:  An example GUI framework library for use with SDL
+*/
+
+#include <string.h>
+
+#include "SDL.h"
+#include "GUI_button.h"
+#include "GUI_loadimage.h"
+
+
+/* the check marks bitmap */
+#include "the_checker.h"
+SDL_Surface *checkmarks=NULL;
+
+
+
+/* The default callback quits the GUI */
+static GUI_status Default_ActiveProc(void *unused)
+{
+	return(GUI_QUIT);
+}
+
+
+GUI_Button:: GUI_Button(void *data, int x, int y, SDL_Surface *image,
+			SDL_Surface *image2,GUI_ActiveProc activeproc)
+ : GUI_Widget(data, x, y, image->w, image->h)
+{
+	if ( activeproc == NULL ) {
+		ActiveProc = Default_ActiveProc;
+	} else {
+		ActiveProc = activeproc;
+	}
+	button = image;
+	button2 = image2;
+	freebutton = 0;
+	for (int i=0;i<3; ++i ) {
+  		pressed[i]=0;
+	}
+	enabled=1;
+	buttonFont=NULL;
+	freefont=0;
+	flatbutton=0;
+	is_checkable=0;
+	checked=0;
+}
+
+GUI_Button:: GUI_Button(void *data, int x, int y, int w, int h,
+			GUI_ActiveProc activeproc)
+ : GUI_Widget(data, x, y, w, h)
+{
+	if ( activeproc == NULL ) {
+		ActiveProc = Default_ActiveProc;
+	} else {
+		ActiveProc = activeproc;
+	}
+	button = NULL;
+	button2 = NULL;
+	freebutton = 0;
+	for (int i=0;i<3; ++i ) {
+  		pressed[i]=0;
+	}
+	enabled=1;
+	buttonFont=NULL;
+	freefont=0;
+	flatbutton=0;
+	is_checkable=0;
+	checked=0;
+}
+
+GUI_Button::GUI_Button(void *data, int x, int y, int w, int h, char *text,
+		       GUI_Font *font, int alignment, int is_checkbutton,
+		       GUI_ActiveProc activeproc, int flat)
+ : GUI_Widget(data,x,y,w,h)
+{
+  if ( activeproc == NULL )
+    ActiveProc = Default_ActiveProc;
+  else
+    ActiveProc = activeproc;
+
+  if (font!=NULL)
+  {
+    buttonFont=font;
+    freefont=0;
+  }
+  else
+  {
+   buttonFont=new GUI_Font();
+   freefont=1;
+  }
+  flatbutton=flat;
+  freebutton=1;
+  button=NULL;
+  button2=NULL;
+
+  is_checkable=is_checkbutton;
+  checked=0;
+  if (is_checkable &&(checkmarks==NULL))
+  {
+    checkmarks=GUI_LoadImage(checker_w,checker_h,checker_pal,checker_data);
+    SDL_SetColorKey(checkmarks,SDL_SRCCOLORKEY,0);
+  }
+  ChangeTextButton(-1,-1,-1,-1,text,alignment);
+
+  for (int i=0;i<3; ++i ) {
+  	pressed[i]=0;
+  }
+  enabled=1;
+}
+
+GUI_Button::~GUI_Button()
+{
+  if (freebutton)
+  {
+    if (button)
+      SDL_FreeSurface(button);
+    if (button2)
+      SDL_FreeSurface(button2);
+  }
+  if (freefont)
+    delete buttonFont;
+}
+
+/* Resize/reposition/change text */
+void GUI_Button::ChangeTextButton(int x, int y, int w, int h, char* text, int alignment)
+{
+  if (x>=0)
+    area.x=x;
+  if (y>=0)
+    area.y=y;
+  if (w>=0)
+    area.w=w;
+  if (h>=0)
+    area.h=h;
+
+  if (freebutton)
+  {
+    if (button)
+      SDL_FreeSurface(button);
+    if (button2)
+      SDL_FreeSurface(button2);
+    if (flatbutton)
+    {
+      button=CreateTextButtonImage(BUTTON2D_UP,text,alignment);
+      button2=CreateTextButtonImage(BUTTON2D_DOWN,text,alignment);
+    }
+    else
+    {
+      button=CreateTextButtonImage(BUTTON3D_UP,text,alignment);
+      button2=CreateTextButtonImage(BUTTON3D_DOWN,text,alignment);
+    }
+  }
+}
+
+/* Show the widget  */
+void GUI_Button:: Display(void)
+{
+	if (button)
+	{
+	  if ((button2!=NULL) && (pressed[0])==1)
+	    SDL_BlitSurface(button2,NULL,screen,&area);
+	  else
+	    SDL_BlitSurface(button,NULL,screen,&area);
+	}
+	if (is_checkable)
+	{
+/*
+**** OLD VERSION WITH TEXT CHECKMARK ****
+	  if (checked)
+	  {
+	    buttonFont->SetTransparency(1);
+	    buttonFont->SetColoring(255,0,0);
+	    buttonFont->TextOut(screen,area.x+4,area.y+4,textmark);
+	  }
+*/
+	  SDL_Rect src,dest=area;
+	  src.x=8-(checked*8); src.y=0;
+	  src.w=8; src.h=10;
+	  dest.x+=4; dest.y+=4;
+	  dest.w=8; dest.h=10;
+	  SDL_BlitSurface(checkmarks,&src,screen,&dest);
+	}
+	if (!enabled)
+	{
+	  Uint8 *pointer;
+	  int pixel=SDL_MapRGB(screen->format,0,0,0);;
+	  Uint8 bytepp=screen->format->BytesPerPixel;
+
+	  if (!SDL_LockSurface(screen))
+	  {
+	    for (int y=0;y<area.h;y+=2)
+	    {
+	      pointer=(Uint8*)screen->pixels+screen->pitch*(area.y+y)+(area.x*bytepp);
+	      for (int x=0;x<area.w>>1;x++)
+	      {
+	        switch (bytepp)
+	        {
+	        case 1:
+		  *((Uint8 *)(pointer)) = (Uint8)pixel;
+		  pointer+=2;
+		  break;
+	        case 2:
+		  *((Uint16 *)(pointer)) = (Uint16)pixel;
+		  pointer+=4;
+		  break;
+	        case 3:  /* Format/endian independent */
+		  Uint8 r, g, b;
+
+		  r = (pixel>>screen->format->Rshift)&0xFF;
+		  g = (pixel>>screen->format->Gshift)&0xFF;
+		  b = (pixel>>screen->format->Bshift)&0xFF;
+		  *((pointer)+screen->format->Rshift/8) = r; 
+		  *((pointer)+screen->format->Gshift/8) = g;
+		  *((pointer)+screen->format->Bshift/8) = b;
+		  pointer+=6;
+		  break;
+	        case 4:
+		  *((Uint32 *)(pointer)) = (Uint32)pixel;
+		  pointer+=8;
+		  break;
+	        }
+	      }
+	    }
+	    SDL_UnlockSurface(screen);
+	  }
+	}
+}
+
+/* Mouse hits activate us */
+GUI_status GUI_Button:: MouseDown(int x, int y, int button)
+{
+	if (enabled &&(button==1))
+	{
+	  pressed[0]=1;
+	  Redraw();
+	}
+	return GUI_PASS;
+}
+
+GUI_status GUI_Button::MouseUp(int x,int y,int button)
+{
+	if ((button==1) && (pressed[0]))
+	{
+	  pressed[0]=0;
+	  if ((x>=0) && (y>=0))
+	    if (ActiveProc(widget_data)==GUI_QUIT)
+	      return GUI_QUIT;
+	  Redraw();
+	}
+	return GUI_PASS;
+}
+
+GUI_status GUI_Button::MouseMotion(int x,int y,Uint8 state)
+{
+	if ((pressed[0]==1) && ((x<0) || (y<0)))
+	{
+	  pressed[0]=2;
+	  Redraw();
+	}
+	if ((pressed[0]==2) && (x>=0) && (y>=0))
+	{
+	  pressed[0]=1;
+	  Redraw();
+	}
+	return GUI_PASS;
+}
+
+void GUI_Button::Disable()
+{
+	enabled=0;
+	Redraw();
+}
+
+void GUI_Button::Enable(int flag)
+{
+	enabled=flag;
+	Redraw();
+}
+
+SDL_Surface* GUI_Button::CreateTextButtonImage(int style, char *text, int alignment)
+{
+  SDL_Rect fillrect;
+  int th,tw,tx,ty;
+  SDL_Surface *img=SDL_AllocSurface(SDL_SWSURFACE,area.w,area.h,
+				    16,31 << 11,63 << 5,31,0);
+  Uint32 color1=SDL_MapRGB(img->format,BL_R,BL_G,BL_B);
+  Uint32 color2=SDL_MapRGB(img->format,BS_R,BS_G,BS_B);
+  Uint32 color3=SDL_MapRGB(img->format,BF_R,BF_G,BF_B);
+  Uint32 color4=SDL_MapRGB(img->format,BI2_R,BI2_G,BI2_B);
+
+  if (img==NULL) return NULL;
+
+  buttonFont->SetColoring(0,0,0);
+  buttonFont->SetTransparency(1);
+  buttonFont->TextExtent(text,&tw,&th);
+  if (tw>(area.w-(4+is_checkable*16)))
+  {
+    text[(area.w-(4+is_checkable*16))/buttonFont->CharWidth()]=0;
+    buttonFont->TextExtent(text,&tw,&th);
+  }
+  if (th>(area.h-4))
+  {
+    text[0]=0;
+  }
+  switch (alignment)
+  {
+  case BUTTON_TEXTALIGN_LEFT:
+    tx=4+(is_checkable*16);
+    break;
+  case BUTTON_TEXTALIGN_CENTER:
+    tx=(area.w-tw) >> 1;
+    break;
+  case BUTTON_TEXTALIGN_RIGHT:
+    tx=area.w-5-tw;
+    break;
+  }
+  ty=(area.h-th) >> 1;
+
+  switch (style)
+  {
+  case BUTTON3D_UP:
+    fillrect.x=0; fillrect.y=0;
+    fillrect.w=area.w; fillrect.h=2;
+    SDL_FillRect(img,&fillrect,color1);
+    fillrect.y=area.h-2;
+    SDL_FillRect(img,&fillrect,color2);
+    fillrect.x=0; fillrect.y=0;
+    fillrect.w=2; fillrect.h=area.h;
+    SDL_FillRect(img,&fillrect,color1);
+    fillrect.x=area.w-2;
+    SDL_FillRect(img,&fillrect,color2);
+    fillrect.h=1; fillrect.w=1;
+    SDL_FillRect(img,&fillrect,color1);
+    fillrect.x=1;
+    fillrect.y=area.h-1;
+    SDL_FillRect(img,&fillrect,color2);
+    fillrect.x=2; fillrect.y=2;
+    fillrect.w=area.w-4; fillrect.h=area.h-4;
+    SDL_FillRect(img,&fillrect,color3);
+    buttonFont->TextOut(img,tx,ty,text);
+    break;
+  case BUTTON3D_DOWN:
+    fillrect.x=0; fillrect.y=0;
+    fillrect.w=area.w; fillrect.h=area.h;
+    SDL_FillRect(img,&fillrect,color3);
+    buttonFont->TextOut(img,tx+1,ty+1,text);
+    break;
+  case BUTTON2D_UP:
+    fillrect.x=0; fillrect.y=0;
+    fillrect.w=area.w; fillrect.h=area.h;
+    SDL_FillRect(img,&fillrect,color3);
+    buttonFont->TextOut(img,tx,ty,text);
+    break;
+  case BUTTON2D_DOWN:
+    fillrect.x=0; fillrect.y=0;
+    fillrect.w=area.w; fillrect.h=area.h;
+    SDL_FillRect(img,&fillrect,color4);
+    buttonFont->SetTransparency(0);
+    buttonFont->SetColoring(BI1_R,BI1_G,BI1_B,BI2_R,BI2_G,BI2_B);
+    buttonFont->TextOut(img,tx,ty,text);
+    break;
+  }
+  return img;
+}
diff --git a/GUI_button.h b/GUI_button.h
new file mode 100644
index 0000000..dcdf540
--- /dev/null
+++ b/GUI_button.h
@@ -0,0 +1,107 @@
+/*
+    GUILIB:  An example GUI framework library for use with SDL
+*/
+
+/* This is a very generic button widget - NOT ANY LONGER*/
+
+#ifndef _GUI_button_h
+#define _GUI_button_h
+
+#include "GUI_widget.h"
+#include "GUI_font.h"
+
+/* design constants */
+#define BUTTON3D_UP 1
+#define BUTTON3D_DOWN 2
+#define BUTTON2D_UP 3
+#define BUTTON2D_DOWN 4
+
+/* alignment constants */
+#define BUTTON_TEXTALIGN_LEFT 1
+#define BUTTON_TEXTALIGN_CENTER 2
+#define BUTTON_TEXTALIGN_RIGHT 3
+
+/* color constants */
+
+// Button face color
+const Uint8 BF_R=180,BF_G=180,BF_B=180;
+// Button light color
+const Uint8 BL_R=220,BL_G=220,BL_B=220;
+// Button shadow color
+const Uint8 BS_R=140,BS_G=140,BS_B=140;
+// 2D Button inverse text color
+const Uint8 BI1_R=255,BI1_G=255,BI1_B=255;
+// 2D Button inverse background color
+const Uint8 BI2_R=0,BI2_G=0,BI2_B=0;
+
+
+/* This is the definition of the "I've been activated" callback */
+typedef GUI_status (*GUI_ActiveProc)(void *data);
+
+class GUI_Button : public GUI_Widget {
+
+public:
+	/* Passed the button data, position, images (pressed/unpressed) and callback */
+	GUI_Button(void *data, int x, int y, SDL_Surface *image,
+		   SDL_Surface *image2, GUI_ActiveProc activeproc = NULL);
+
+	/* I don't know what this one is for */
+	GUI_Button(void *data, int x, int y, int w, int h,
+		   GUI_ActiveProc activeproc = NULL);
+
+	/* Passed the button data, position, width, height, a caption, a font,
+	   an alignment (one of the constants above), if it should be a checkbutton (1/0),
+	   the callback and a flag if it should be 2D (1) or 3D (0) */
+	GUI_Button(void *data, int x, int y, int w, int h, char* text,
+		   GUI_Font *font, int alignment, int is_checkbutton,
+		   GUI_ActiveProc activeproc = NULL, int flat = 0);
+
+	~GUI_Button();
+
+	/* change features of a text button (if one of the dimensions is negativ, it's ignored) */
+	virtual void ChangeTextButton(int x, int y, int w, int h

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