/** \mainpage gui::tk - framework-agnostic C++ GUI toolkit
*
* \section i Introduction
*
* gui::tk is a simple one-file C++ GUI toolkit for use with arbitrary
* memory framebuffers.
*
* \section f Features
*
* \li small source and binary code size
* \li reasonable performance and memory usage
* \li comfortable usage
* \li suitable for embedded usage: integer math only
* \li extensibility via OO
* \li non-intrusive: can be integrated with any event mechanism of your liking
* \li no dependencies apart from standards-conformant ANSI C++ (including a little STL)
* \li support for different encodings, single- and multibyte
* \li flexible font support
*
* \section o Overview
*
* The toolkit draws on a surface you provide, using any size or pixel format.
* Create a GUI::Screen with the buffer to draw on, then pass that object
* (or a GUI::Window created from it) to all other widgets' constructors.
*
* It doesn't provide an own event loop. Instead, it relies on you passing events
* and updating the screen regularly. This way, it can easily be integrated with
* any event loop available (SDL, Qt, glib, X11, Win32, selfmade, ...)
*
* Many functions and concepts were taken from other well-known toolkits, so if you
* know Qt, Java or wxWindows, you may encounter (intentional) similarities. However,
* simplicity of code has been given priority over maximum optimization and pixel-exact
* replication of their appearance.
*
* A note about font support and encodings: All text-related functions use templates to
* support any encoding. Fonts define the charset.
*
* \section g Getting Started
*
* gui::tk contains an SDL adapter, so if your program is already using SDL,
* things are really easy. The rough sequence to get up and running is:
*
* \code
* // setup a suitable video mode with SDL
* SDL_surface *screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
*
* // add a default font, you will most probably need it
* GUI::Font::addFont("default",new GUI::BitmapFont(testfont,14,10));
*
* // create the root-level screen object, the parent of all top-level windows
* GUI::ScreenSDL guiscreen(screen);
*
* // create any amount of toplevel windows you like
* GUI::ToplevelWindow *frame = new GUI::ToplevelWindow(&guiscreen, 205, 100, 380, 250, "gui::tk example");
*
* // add some GUI elements to the toplevel window
* GUI::Button *b = new GUI::Button(frame,8,20,"Quit");
*
* // Define and add an event handler
* struct quit : public GUI::ActionEventSource_Callback {
* void actionExecuted(GUI::ActionEventSource *b, const GUI::String &arg) {
* exit(0);
* }
* } ex;
* b->addActionHandler(&ex);
*
* // Enter an event loop, calling update() regularly.
* SDL_Event event;
* while (1) {
* while (SDL_PollEvent(&event)) {
* if (!guiscreen.event(event)) { // gui::tk didn't handle that event
* if (event.type == SDL_QUIT) exit(0);
* }
* }
*
* guiscreen.update(4); // 4 ticks = 40ms
* SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
*
* SDL_Delay(40); // wait 40ms
* }
* \endcode
*
* Look at gui_tk.h for more detailed documentation and reference of all classes.
*
* A test program that shows off the capabilities of gui::tk is available as part of gui_tk.cpp.
*
* \section l License
*
* Copyright (C) 2005-2007 Jörg Walter
*
* gui::tk 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 3 of the License, or
* (at your option) any later version.
*
* gui::tk 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, see
*/
/* $Id: gui_tk.h,v 1.6 2009-05-17 15:28:05 c2woody Exp $ */
#ifndef GUI__TOOLKIT_H
#define GUI__TOOLKIT_H
#define imin(x,y) ((x)<(y)?(x):(y))
#define imax(x,y) ((x)>(y)?(x):(y))
#define isign(x) (((x)<0?-1:1))
/** \file
* \brief Header file for gui::tk.
*
* All you need to do is to include "gui_tk.h". If you want SDL support, then include \c SDL.h first.
*/
#ifdef _MSC_VER
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
#else
#include
#endif
#include
#include