Compare commits

..

1 Commits

Author SHA1 Message Date
cozman
8a183a1381 initial 2003-05-19 22:58:01 +00:00
38 changed files with 377 additions and 1634 deletions

View File

@ -1,2 +0,0 @@
James Turk james@conceptofzero.net - GewiEngine and all base widgets.
Atani atani@atani-software.net - Revised Linux Build System

View File

@ -1,20 +0,0 @@
Gewi Version Log for Version 0.2.0
$Id: changelog.txt,v 1.4 2003/08/01 19:38:33 cozman Exp $
0.2.0
-Linux build system (by Atani).
-Packaged for release (VC7 only).
-Revision of all source code, cleaned up various areas.
-Fixed a few bugs involving empty containers.
-Faster + smaller container methods.
-Slightly modified event handling (will rely on ZEngine 0.8.4).
-Added ZEngine version check.
-Changed memory handling and resource management usage.
-Wrote all doxygen documentation.
-Fixed bugs, cleaned up interface.
-BSD style license.
-Changed namespaces from ZE to Gewi.
-Sliders, Container.
0.1.0
Release to selected members of ZEngine forums and mailing list.

29
config
View File

@ -1,29 +0,0 @@
#Config file for ZEngine#
#Edit only this file#
BUILD_NAME=gewi-0.2.0
###Cygwin###
#EXE=.exe
#GL_LIB_NAME=OpenGL32
#GL_INC_PATH=-I/usr/include/w32api/GL
#GL_LIB_PATH=-L/lib/w32api
###Linux###
GL_LIB_NAME=GL
##Define compiler commands:
CC=g++
AR=ar rcs
###Define compiler options:
WARN_LEVEL=-W -Wall
ZE_INC_PATH=-I/cygdrive/c/libs/ZEngine-0.8.4/include
SDL_INC_PATH=-I/usr/local/include/SDL
SDL_LIB_PATH=-L/usr/local/lib/ -L/cygdrive/c/libs/ZEngine-0.8.4/lib
LIBS=-lgewiS -lZEngineS -lSDL_mixer -lSDL_image -lSDL_ttf -lSDLmain -lSDL -l$(GL_LIB_NAME)
##Define install location:
INSTALL_INC= /usr/include/$(BUILD_NAME)
INSTALL_LIB= /usr/lib
INSTALL_DOC= /usr/share/doc/$(BUILD_NAME)

View File

@ -1,205 +0,0 @@
# Doxyfile 1.3
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = Gewi
PROJECT_NUMBER = 0.2.0
OUTPUT_DIRECTORY = C:\libs\gewi\doc\
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = YES
EXTRACT_ALL = NO
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = NO
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = C:\libs\gewi
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
SHORT_NAMES = NO
HIDE_SCOPE_NAMES = NO
VERBATIM_HEADERS = YES
SHOW_INCLUDE_FILES = YES
JAVADOC_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = YES
INHERIT_DOCS = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = NO
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 8
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ALIASES =
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE = C:\libs\gewi\doc\Gewi.log
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = C:/libs/gewi/include \
C:/libs/gewi/src
FILE_PATTERNS =
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 1
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_SCHEMA =
XML_DTD =
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = NO
INCLUDED_BY_GRAPH = NO
GRAPHICAL_HIERARCHY = NO
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 0
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO
CGI_NAME = search.cgi
CGI_URL =
DOC_URL =
DOC_ABSPATH =
BIN_ABSPATH = /usr/local/bin/
EXT_DOC_PATHS =

View File

@ -1,62 +0,0 @@
/*!
\file Gewi.h
\brief Header file for Gewi.
Header file for the Gewi GUI lib, an addon for the ZEngine Game Engine, both from Concept of Zero, this is the
file that programs that wish to use should include.
<br>$Id: Gewi.h,v 1.5 2003/08/10 01:43:18 cozman Exp $<br>
\author James Turk
**/
/*!
\mainpage Gewi Documentation
\author James Turk
\version 0.2.0
\date July 12th, 2003
\section Gewi About ZEngine and Gewi
<br>
&nbsp;&nbsp;&nbsp;&nbsp;-ZEngine is designed to provide a powerful yet easy to use 2D game engine in a well designed
Object Oriented manner, and uses cross platform libraries such as SDL and OpenGL. (ZEngine can use SDL_ttf,SDL_image,
SDL_mixer, and PhysFS all of which are cross platform as well as Open Source.) Gewi sits neatly on top of ZEngine and
is written in much the same style, Gewi is designed to be the GUI portion of ZEngine but grew so large it needed to become
a seperate project.<br>
&nbsp;&nbsp;&nbsp;&nbsp;-Both are licensed under a BSD-style license, and anyone is free to suggest or implement changes
to be added to either, as well as modify ZEngine or Gewi to fit their own needs or use it however they like.<br>
&nbsp;&nbsp;&nbsp;&nbsp;-Because Gewi relys so heavily on ZEngine it has no website, if anybody writes a version of Gewi
that does not use the ZEngine backend I'd be glad to see it and even integrate it with the ZEngine/Gewi source. Until
there is some other version, Gewi will always be found right next to ZEngine.<br>
&nbsp;&nbsp;&nbsp;&nbsp;-The ZEngine website : http://zengine.sourceforge.net/.<br>
\section Licensing Licensing
<br>
<pre> This file is Part of the Gewi GUI Library for ZEngine.
Gewi and ZEngine Copyright (C) 2002, 2003 James Turk
Licensed under a BSD-style license. (see licensing.txt)
The maintainer of this library is James Turk (james@conceptofzero.net)
this library is found at the home of ZEngine http://zengine.sourceforge.net
</pre>
\section Authors Contributing Authors
<br>
James Turk <a href="mailto:james@conceptofzero.net">james@conceptofzero.net</a> - Core Engine, Design, Docs, and Classes<br>
Atani <a href="mailto:atani@atani-software.net">atani@atani-software.net</a> - Revised Linux Build System<br>
**/
#ifndef __gewi_h__
#define __gewi_h__
#include "GewiIncludes.h"
#include "GewiDefines.h"
#include "GewiContainer.h"
#include "GewiButton.h"
#include "GewiEngine.h"
#include "GewiSlider.h"
#include "GewiStaticText.h"
#include "GewiTextButton.h"
#include "GewiTextField.h"
#include "GewiWindow.h"
#endif //__zengine_h__

View File

@ -10,10 +10,10 @@
/*!
\file GewiButton.h
\brief Definition file for GButton.
\brief Definition file for GewiButton.
Definition file for GButton, a simple button class.
<br>$Id: GewiButton.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br>
Definition file for GewiButton, a simple button class.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -26,91 +26,22 @@
namespace Gewi
{
/*!
\brief Enumeration for the button types.
Definitions of the two possible button types.
**/
enum GButtonType
{
GBT_PRESS, /*!< Simple button with standard behavior. */
GBT_HOVER /*!< Button which shows itself clicked when hovered over. */
};
/*!
\brief GButton class for basic buttons.
GButton simple button widget, derived from GWidget.
**/
class GButton : public GWidget
{
protected:
//! Boolean holding if button is currently pressed or not.
bool rPressed;
//! Enum for type of button.
GButtonType rType;
//! Resource ID for the non-pressed image.
ResourceID rNormalImage;
//! Resource ID for the pressed (or hover) image.
ResourceID rPressedImage;
public:
/*!
\brief Simple constructor for GButton.
Constructor for GButton, can take a parent.
\param parent Pointer to GContainer derived class to be the parent. Default value is NULL which means no parent.
**/
GButton(GContainer *parent=NULL);
/*!
\brief GButton's create function, must be called to set up actual button.
Every widget has a create function which must be called to define the button's appearance and settings.
\param x X position of widget within it's container (entire screen if no parent)
\param y Y position of widget within it's container (entire screen if no parent)
\param width Width of widget.
\param height Height of widget.
\param normalImg Image for button when not pressed.
\param pressImg Image for button when pressed (or hovered if type is GBT_HOVER).
\param type GButtonType, either the default, GBT_PRESS (normal button), or GBT_HOVER (a button which responds to the hovering mouse).
**/
virtual void Create(float x, float y, float width, float height, ResourceID normalImg, ResourceID pressImg, GButtonType type=GBT_PRESS);
/*!
\brief Overload of Message, used to recieve messages.
Recieves and processes a message, required overload for all widgets.
\param rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
\param event GewiEvent enum, description of event recieved.
\param mouseX Mouse x position in event, if not mouse event may be incorrect.
\param mouseY Mouse y position in event, if not mouse event may be incorrect.
\param ch Character pressed in event, may be 0 if not a keypress event.
**/
virtual void Create(float x, float y, float width, float height, ResourceID normalImg, ResourceID pressImg, GButtonType type=G_PRESS);
virtual void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
/*!
\brief Draws this button to the screen.
Draws widget to the screen, required overload for all widgets.
**/
virtual void Show();
/*!
\brief Returns button state.
Returns true if buttons is pressed, false otherwise. (GBT_HOVER can only be pressed once, after that they stay down.)
\return button pressed state
**/
bool IsPressed();
/*!
\brief Sets button state (pressed/unpressed).
Sets button to pressed (true) or unpressed (false).
\param pressed true means pressed, false means unpressed.
**/
void SetState(bool pressed);
void SetState(bool state);
};
}

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiContainer.h
\brief Definition file for GContainer.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Definition file for GContainer, a barebones widget that can contain child widgets.
<br>$Id: GewiContainer.h,v 1.7 2003/07/20 03:21:21 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -27,87 +27,23 @@
namespace Gewi
{
/*!
\brief GContainer class, definition of a container widget.
GContainer widget which is a standard GWidget that can serve as a parent, contain and manage other widgets.
**/
class GContainer : public GWidget
{
/*!
The usage of friend here is used simply to allow GWidget proper access to what used to belong to
it before the class split GWidget needs access to Add/ReleaseChild but to make them public would
<strong>reduce</strong> encapsulation. (For those keeping score, this is to many people the only effective use of
friend.)
**/
friend class Gewi::GWidget;
//friend here is used simply to allow GWidget proper access to what used to belong to it before
//the class split GWidget needs access to Add/ReleaseChild but to make them public would _reduce_
//encapsulation (for those keeping score, this is to many people the only effective use of friend)
friend GWidget;
protected:
//! List of child widgets assigned to this container.
WidgetList rChildList;
/*!
\brief Adds a child to the child list.
Registers the widget as a child of this container, private because GWidget is a friend.
\param widget Widget to register as a child of this container.
**/
void AddChild(GWidget *widget);
/*!
\brief Removes a child from the child list.
Releases the widget which is a child of this container, private because GWidget is a friend.
\param widget Widget to release from this container.
**/
void ReleaseChild(GWidget *widget);
/*!
\brief Inserts a child to the child list.
Calls needed function of WidgetList class to put widget into the linked list.
\param node WidgetNode to insert into rChildList.
**/
void InsertWidget(WidgetNode *node);
public:
/*!
\brief Simple constructor for GContainer.
Constructor for GContainer, can take a parent (to be contained on a GContainer derived class, allowing nested containers).
\param parent Pointer to GContainer derived class to be the parent. Default value is NULL which means no parent.
**/
GContainer(GContainer *parent=NULL);
~GContainer();
/*!
\brief Move container and children.
Same as GWidget::Move but overloaded to move children.
\param x New x position for container.
\param y New y position for container.
**/
virtual void Move(float x, float y);
/*!
\brief Overload of Message, used to recieve messages.
Recieves and processes a message, required overload for all widgets, overloaded to also account for children.
\param rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
\param event GewiEvent enum, description of event recieved.
\param mouseX Mouse x position in event, if not mouse event may be incorrect.
\param mouseY Mouse y position in event, if not mouse event may be incorrect.
\param ch Character pressed in event, may be 0 if not a keypress event.
**/
virtual void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
/*!
\brief Show children.
Draws all children in appropriate back-to-front order.
**/
virtual void Show();
void Move(float x, float y);
void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
void Show();
};
}

View File

@ -1,67 +0,0 @@
/*******************************************************************************
This file is Part of the Gewi GUI Library for ZEngine.
Gewi and ZEngine Copyright (C) 2002, 2003 James Turk
Licensed under a BSD-style license. (see licensing.txt)
The maintainer of this library is James Turk (james@conceptofzero.net)
this library is found at the home of ZEngine http://zengine.sourceforge.net
*******************************************************************************/
/*!
\file GewiDefines.h
\brief Define file for Gewi where enumerations, typedefs and #define statements are placed.
Definition file, holds enumerations and typedefs which need to be accessed by many files within Gewi.
<br>$id$<br>
\author James Turk
**/
#ifndef __gewidefines_h__
#define __gewidefines_h__
namespace Gewi
{
//! Resources are stored centrally and widgets access them by their ResourceID.
typedef unsigned int ResourceID;
//! GewiJustify is a hack so that members of the _GewiJustify enum can be or'ed (|) together.
typedef unsigned int GewiJustify;
/*!
\brief Enumeration for basic events that a widget can handle.
Defines names for specific events that are filtered and given to widgets.
**/
enum GewiEvent
{
GE_LDOWN, /*!< Left mouse button pressed event. */
GE_LUP, /*!< Left mouse button released event. */
GE_RDOWN, /*!< Right mouse button pressed event. */
GE_RUP, /*!< Right mouse button released event. */
GE_KDOWN, /*!< Key pressed. */
GE_KUP, /*!< Key released. */
GE_GOTFOCUS, /*!< Widget got focus. */
GE_LOSTFOCUS /*!< Widget lost focus. */
};
/*!
\brief Describess justification options in text buttons and static fields.
Justification options in text buttons and static fields, these values can be or'ed
together via the typedef GewiJustify. For example GJ_LEFT|GJ_TOP would position the
label in the upper left corner. GJ_RIGHT|GJ_CENTER would be in the vertical center of
the box, yet justified to the right on the horizontal axis.
**/
enum _GewiJustify
{
GJ_CENTER = 0, /*!< Center text. */
GJ_LEFT = 1<<0, /*!< Align text to the left. */
GJ_RIGHT = 1<<1, /*!< Align text to the right. */
GJ_TOP = 1<<2, /*!< Position text to the top. */
GJ_BOTTOM = 1<<3 /*!< Position text to the bottom. */
};
};
#endif //__gewidefines_h__

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiEngine.h
\brief Definition file for GewiEngine.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Definition file for GewiEngine, core engine for Gewi GUI control.
<br>$Id: GewiEngine.h,v 1.7 2003/06/11 00:19:40 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -23,180 +23,44 @@
#include "GewiIncludes.h"
#include "GewiWidgetList.h"
/*!
\brief Gewi Namespace.
Namespace for all Gewi classes and utility functions.
**/
namespace Gewi
{
/*!
\brief Main GewiEngine Singleton Class
GewiEngine Singleton Class, accessible from anywhere in a program via GetInstance. Contains widgets in global context
(those drawn in relation to screen, with a NULL parent) also handles resource management of fonts and images.
**/
class GewiEngine
{
public:
//! Static version information.
static VersionInfo Version;
//! Required ZEngine version.
static VersionInfo MinZEVersion;
private:
//! Singleton static instance of GewiEngine.
static GewiEngine *sInstance;
//! Vector of pointers to ZImages, used by resource management system.
std::vector<ZE::ZImage*> mImageVec;
//! Vector of pointers to ZFonts, used by resource management system.
std::vector<ZE::ZFont*> mFontVec;
//! List of widgets in global context.
static SDL_EventFilter sOldFilter;
vector<ZImage*> mImageVec;
vector<ZFont*> mFontVec;
WidgetList mWidgetList;
//singleton setup//
private:
/*!
\brief GewiEngine constructor, private due to singleton design.
Initializes GewiEngine instance variables, can only be called once per run of program due to design.
**/
GewiEngine();
public:
//! Static variable used to represent invalid IDs (before an ID has been assigned all resourceIDs should == InvalidID).
static const ResourceID InvalidID = UINT_MAX; //UINT_MAX b/c many compilers don't like numeric_limits
/*!
\brief Get the static instance of GewiEngine.
Important key to the singleton's design, gets the static instance stored within. Creates static instance on first call.
\return Pointer to static instance of GewiEngine.
**/
static GewiEngine* GetInstance();
/*!
\brief Release static instance.
Releases the instance of GewiEngine, basically only called at very end of program.
**/
static void ReleaseInstance();
//utilities//
/*!
\brief Static event filter, defined to SDL specifications.
Replaces SDL default event filter, and filters events into static GewiEngine instance.
\param event SDL_Event to handle.
\return Return values specified by SDL.
**/
static int EventFilter(SDL_Event *event);
/*!
\brief Translate an SDL structure into a character, used by EventFilter.
Converts SDL_keysym into a standard char, only works for certain meaningful keys.
\param key SDL_keysm structure to convert.
\return Converted character.
**/
static char TranslateKey(SDL_keysym key);
/*!
\brief Draw all widgets in the Gewi system.
Draws all top level widgets and containers, container widgets are expected to draw their own children.
**/
void Display();
//resource management//
/*!
\brief Adds an image resource to the private vector.
Add a ZImage to the private vector of images and assign it a ResourceID.
\param image Image to add to resources.
\return ID number of new resource.
**/
ResourceID AddResource(ZE::ZImage *image);
/*!
\brief Adds a font resource to the private vector.
Add a ZFont to the private vector of fonts and assign it a ResourceID.
\param font Font to add to resources.
\return ID number of new resource.
**/
ResourceID AddResource(ZE::ZFont *font);
/*!
\brief Access an image in the resource vector.
Given the images ID get a pointer to an image stored in the image vector.
\param id ID of image to retrieve.
\return Pointer to image or NULL if invalid ID for images.
**/
ZE::ZImage* Image(ResourceID id);
/*!
\brief Access a font in the resource vector.
Given the fonts ID get a pointer to a font stored in the font vector.
\param id ID of font to retrieve.
\return Pointer to font or NULL if invalid ID for fonts.
**/
ZE::ZFont* Font(ResourceID id);
/*!
\brief Free all resources.
Frees memory for all resources.
**/
ResourceID AddResource(ZImage *image);
ResourceID AddResource(ZFont *font);
ZImage* Image(ResourceID id);
ZFont* Font(ResourceID id);
void FreeResources();
//widget management//
private:
/*!
\brief Inserts a child to the child list.
Calls needed function of WidgetList class to put widget into the linked list.
\param node WidgetNode to insert into mWidgetList.
**/
void InsertWidget(WidgetNode *node);
public:
/*!
\brief Register a widget, adding it to the list of widgets.
Add a widget to the list of widgets, all widgets register themselves.
\param widget Widget to register.
**/
void Register(GWidget *widget);
/*!
\brief Send a message to the widgets, this function will decide which widgets the message is relevant to.
Send a message to the widgets, this function will decide which widgets the message is relevant to.
This generally isn't called by the client of GewiEngine, instead the EventFilter hook on events will filter
and process. This can be used to fake an event however.
\param rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
\param event GewiEvent enum, description of event recieved.
\param mouseX Mouse x position in event, if not mouse event may be incorrect.
\param mouseY Mouse y position in event, if not mouse event may be incorrect.
\param ch Character pressed in event, may be 0 if not a keypress event.
**/
void SendMessage(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
/*!
\brief Delete a widget.
This deletes a widget and memory associated with that widget, like register, widgets do this for themselves.
\param widget to delete
**/
void DeleteWidget(GWidget *widget);
};

View File

@ -9,22 +9,28 @@
*******************************************************************************/
/*!
\file GewiIncludes.h
\brief Include file for Gewi.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Include file for Gewi, contains external includes for Gewi.
<br>$id: GewiIncludes.h,v 1.3 2003/05/19 23:56:05 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
#ifndef __gewiincludes_h__
#define __gewiincludes_h__
#include <string>
#include <vector>
#include <cmath>
#include <climits>
#include <limits>
#include "ZEngine.h"
#include "GewiDefines.h"
typedef unsigned int WidgetID;
typedef unsigned int ResourceID;
enum GewiEvent { GE_LDOWN, GE_LUP, GE_RDOWN, GE_RUP, GE_KDOWN, GE_KUP, GE_GOTFOCUS, GE_LOSTFOCUS };
enum _GewiJustify { GJ_CENTER = 0, GJ_LEFT = 1<<0, GJ_RIGHT = 1<<1, GJ_TOP = 1<<2, GJ_BOTTOM = 1<<3 };
enum GButtonType { G_PRESS, G_HOVER };
typedef unsigned int GewiJustify;
using namespace std;
using namespace ZE;
#endif //__gewiincludes_h__

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiSlider.h
\brief Definition file for GSlider, GHorizSlider and GVertSlider.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Definition file for GSlider, GHorizSlider and GVertSlider, the slide-select classes for Gewi.
<br>$Id: GewiSlider.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -26,125 +26,35 @@
namespace Gewi
{
/*!
\brief GSlider (virtual) slider widget class.
Framework for simple slider widget, virtual (fails to overload Show), derived from GWidget.
**/
class GSlider : public GWidget
{
protected:
//! Boolean value holding if slider is currently 'pressed' or active.
bool rPressed;
//! ID for background image for slider.
ResourceID rBackground;
//! Image ID for the sliding part of the slider.
ResourceID rSlider;
//! Minimum position for slider.
float rMin;
//! Maximum position for slider.
float rMax;
//! Current position of slider.
float rPos;
//! Movement snap increment.
float rMin,rMax,rPos;
int rIncrement;
public:
/*!
\brief Simple constructor for GSlider.
GSlider();
Default constructor for GSlider, can take a parent.
\param parent Pointer to GContainer derived class to be the parent. Default value is NULL which means no parent.
**/
GSlider(GContainer *parent=NULL);
/*!
\brief GSlider's create function, must be called to set up actual slider.
Every widget has a create function which must be called to define the button's appearance and settings.
\param x X position of widget within it's container (entire screen if no parent)
\param y Y position of widget within it's container (entire screen if no parent)
\param width Width of widget.
\param height Height of widget.
\param backgroundImg Image for stationary portion of slider.
\param sliderImg Image for moving portion of slider.
\param min Minimum value on slider.
\param max Maximum value on slider.
\param increment Slider snap-to increment.
**/
virtual void Create(float x, float y, float width, float height, ResourceID backgroundImg, ResourceID sliderImg,
float min, float max, int increment);
/*!
\brief Set position of slider.
Sets position of slider, will snap within bounds.
\param pos Desired position.
**/
void SetPos(float pos);
/*!
\brief Get position of slider.
Access current position of slider.
\return Slider position.
**/
float GetPos();
};
/*!
\brief GHorizSlider, horizontal slider widget class.
Derived from GSlider, overloads message and show to complete the class.
**/
class GHorizSlider : public GSlider
{
public:
/*!
\brief Overload of Message, used to recieve messages.
Recieves and processes a message, required overload for all widgets.
\param rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
\param event GewiEvent enum, description of event recieved.
\param mouseX Mouse x position in event, if not mouse event may be incorrect.
\param mouseY Mouse y position in event, if not mouse event may be incorrect.
\param ch Character pressed in event, may be 0 if not a keypress event.
**/
virtual void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
/*!
\brief Draws this slider to the screen.
Draws widget to the screen, required overload for all widgets.
**/
virtual void Show();
};
/*!
\brief GHorizSlider, horizontal slider widget class
Derived from GSlider, overloads message and show to complete the class.
**/
class GVertSlider : public GSlider
{
public:
/*!
\brief Overload of Message, used to recieve messages.
Recieves and processes a message, required overload for all widgets.
\param rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
\param event GewiEvent enum, description of event recieved.
\param mouseX Mouse x position in event, if not mouse event may be incorrect.
\param mouseY Mouse y position in event, if not mouse event may be incorrect.
\param ch Character pressed in event, may be 0 if not a keypress event.
**/
virtual void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
/*!
\brief Draws this slider to the screen.
Draws widget to the screen, required overload for all widgets.
**/
virtual void Show();
};

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiStaticText.h
\brief Definition file for GStaticText.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Definition file for GStaticText, file to hold static text, labels and such.
<br>$Id: GewiStaticText.h,v 1.5 2003/06/11 00:19:40 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -26,87 +26,25 @@
namespace Gewi
{
/*!
\brief GStaticText for stationary labels.
GStaticText, stationary label class, derived from GWidget.
**/
class GStaticText : public GWidget
{
protected:
//! Image for background of label (often no image).
ResourceID rBackgroundImage;
//! Font to use for label.
ResourceID rFont;
//! Current text of label.
std::string rText;
//! Text buffer ZImage, used internally.
ZE::ZImage rTextBuf;
//! Calculated X Offset for text, calculated from justification.
int rXOff;
//! Calculated Y Offset for text, calculated from justification.
int rYOff;
//! Justification, can be or'ed together enums from _GewiJustify, see documentation of that enum for details.
string rText;
ZImage rTextBuf;
int rXOff,rYOff;
GewiJustify rJustify;
public:
/*!
\brief Simple constructor for GStaticText.
Constructor for GStaticText, can take a parent.
\param parent Pointer to GContainer derived class to be the parent. Default value is NULL which means no parent.
**/
GStaticText(GContainer *parent=NULL);
/*!
\brief GButton's create function, must be called to set up actual button.
Every widget has a create function which must be called to define the button's appearance and settings.
\param x X position of widget within it's container (entire screen if no parent)
\param y Y position of widget within it's container (entire screen if no parent)
\param width Width of widget.
\param height Height of widget.
\param font Font ID for text.
\param text Text for static label. (Defaults to a blank space.)
\param just Justification, see documented _GewiJustify for details. Defaults to GJ_CENTER.
\param backgroundImg Image for background, defaults to GewiEngine::InvalidID.
**/
virtual void Create(float x, float y, float width, float height,
ResourceID font, std::string text=" ", GewiJustify just=GJ_CENTER, ResourceID backgroundImg=GewiEngine::InvalidID);
/*!
\brief Overload of Message, used to recieve messages.
Recieves and processes a message, required overload for all widgets.
\param rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
\param event GewiEvent enum, description of event recieved.
\param mouseX Mouse x position in event, if not mouse event may be incorrect.
\param mouseY Mouse y position in event, if not mouse event may be incorrect.
\param ch Character pressed in event, may be 0 if not a keypress event.
**/
ResourceID font, ResourceID backgroundImg=GewiEngine::InvalidID, string text=" ", GewiJustify just=GJ_CENTER);
virtual void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
/*!
\brief Draws static label to the screen.
Draws static label to the screen, required overload for all widgets.
**/
virtual void Show();
/*!
\brief Set text of label.
Sets the current text of the label.
\param text New text for label.
**/
void SetText(std::string text);
/*!
\brief Get current text in label.
Return text in label.
\return text currently in label.
**/
std::string GetText();
void SetText(string text);
string GetText();
};
}

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiTextButton.h
\brief Definition file for GTextButton.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Definition file for GTextButton, a GButton that has a text label.
<br>$Id: GewiTextButton.h,v 1.5 2003/06/11 00:19:40 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -26,73 +26,22 @@
namespace Gewi
{
/*!
\brief GTextButton class for button with text label.
GTextButton text label button widget, derived from GButton.
**/
class GTextButton : public GButton
{
protected:
//! Text label for button.
std::string rText;
//! Text Buffer, used internally.
ZE::ZImage rTextBuf;
//! X offset of text.
int rXOff;
//! Y offset of text.
int rYOff;
//! Font ID for text label.
string rText;
ZImage rTextBuf;
int rXOff,rYOff;
ResourceID rFont;
public:
/*!
\brief Simple constructor for GButton.
Constructor for GButton, can take a parent.
\param parent Pointer to GContainer derived class to be the parent. Default value is NULL which means no parent.
**/
GTextButton(GContainer *parent=NULL);
/*!
\brief GButton's create function, must be called to set up actual button.
Every widget has a create function which must be called to define the button's appearance and settings.
\param x X position of widget within it's container (entire screen if no parent)
\param y Y position of widget within it's container (entire screen if no parent)
\param width Width of widget.
\param height Height of widget.
\param normalImg Image for button when not pressed.
\param pressImg Image for button when pressed (or hovered if type is GBT_HOVER).
\param font Font to draw label with.
\param text Text for button. (default is blank)
\param type GButtonType, either the default, GBT_PRESS (normal button), or GBT_HOVER (a button which responds to the hovering mouse).
**/
virtual void Create(float x, float y, float width, float height, ResourceID normalImg, ResourceID pressImg, ResourceID font,
std::string text=" ", GButtonType type=GBT_PRESS);
/*!
\brief Draws static label to the screen.
Draws static label to the screen, required overload for all widgets.
**/
string text=" ", GButtonType type=G_PRESS);
virtual void Show();
/*!
\brief Set text of button.
Sets the current text of the button.
\param text New text for button.
**/
void SetText(std::string text);
/*!
\brief Get current text of button label.
Return text on button label.
\return text currently on button label.
**/
std::string GetText();
void SetText(string text);
string GetText();
};
}

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiTextField.h
\brief Definition file for GTextField.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Definition file for GTextField, text input area widget.
<br>$Id: GewiTextField.h,v 1.6 2003/06/11 00:19:40 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -26,85 +26,26 @@
namespace Gewi
{
/*!
\brief GTextField class for basic text input area.
GTextField simple text input area widget, derived from GWidget.
**/
class GTextField : public GWidget
{
protected:
//! Text currently entered.
std::string rText;
//! Text buffer, used internally.
ZE::ZImage rBuffer;
//! Font for text.
string rText;
ZImage rBuffer;
ResourceID rFont;
//! Background for text input area.
ResourceID rBackground;
//! Maximum number of characters allowed to be entered.
int rMaxChars;
//! Amount of padding on left hand side.
int rLeftPadding;
int rMaxChars,rLeftPadding;
public:
/*!
\brief Simple constructor for GTextField.
Constructor for GTextField, can take a parent.
\param parent Pointer to GContainer derived class to be the parent. Default value is NULL which means no parent.
**/
GTextField(GContainer *parent=NULL);
~GTextField();
/*!
\brief GButton's create function, must be called to set up actual button.
void Kill();
Every widget has a create function which must be called to define the button's appearance and settings.
\param x X position of widget within it's container (entire screen if no parent)
\param y Y position of widget within it's container (entire screen if no parent)
\param width Width of widget.
\param height Height of widget.
\param font Font for text.
\param backgroundImg Image for text input box.
\param maxChars Maximum number of characters to be entered, defaults to 256.
\param leftPad padding on left side, defaults to zero.
**/
virtual void Create(float x, float y, float width, float height, ResourceID font, ResourceID backgroundImg, int maxChars=256, int leftPad=0);
/*!
\brief Overload of Message, used to recieve messages.
Recieves and processes a message, required overload for all widgets.
\param rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
\param event GewiEvent enum, description of event recieved.
\param mouseX Mouse x position in event, if not mouse event may be incorrect.
\param mouseY Mouse y position in event, if not mouse event may be incorrect.
\param ch Character pressed in event, may be 0 if not a keypress event.
**/
virtual void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
/*!
\brief Draws the text input area & text to the screen.
Draws widget to the screen, required overload for all widgets.
**/
virtual void Show();
/*!
\brief Set text in input area.
Sets the current text of the buffer for input area.
\param text New text for button.
**/
void SetText(std::string text);
/*!
\brief Get current text of the input box.
Return text in the input buffer.
\return text currently in input buffer.
**/
std::string GetText();
void SetText(string text);
string GetText();
};
}

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiWidget.h
\brief Definition file for GWidget.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Definition file for GWidget, virtual widget base class.
<br>$Id: GewiWidget.h,v 1.6 2003/06/11 00:19:40 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -25,141 +25,38 @@
namespace Gewi
{
class GewiEngine;
class GContainer;
/*!
\brief GWidget base widget class.
Basic widget class, framework and base class for all other widgets.
**/
class GWidget
{
protected:
//! Pointer to GewiEngine instance.
GewiEngine *rGewi;
//! Pointer to ZEngine instance.
ZE::ZEngine *rZE;
//! Rectangle describing area of widget.
ZE::ZRect rBoundRect;
//! Pointer to parent container. (NULL means it lays in the global setting).
ZEngine *rZE;
ZRect rBoundRect;
GContainer *rParent;
//! Relative X position, relative to parent, or top corner of screen if in global setting.
float rRelX;
//! Relative Y position, relative to parent, or top corner of screen if in global setting.
float rRelY;
//! Stores if widget is currently visible.
float rRelX,rRelY;
bool rVisible;
bool rAlive;
public:
/*!
\brief Simple constructor for GWidget.
Constructor for GWidget, like all widgets this must initialize private data and can take a parent.
\param parent Pointer to GContainer derived class to be the parent. Default value is NULL which means no parent.
**/
GWidget(GContainer *parent=NULL);
/*!
\brief Simple destructor.
Must be virtual so that each derived class can free it's members.
**/
virtual ~GWidget();
/*!
\brief Toggle the visible flag.
Toggles the visible flag, only visible widgets are drawn.
**/
void FitParent();
void ToggleVisible();
/*!
\brief Reposition widget within parent.
Adjust this widget to be in the correct position in relationship to it's parent. Only containers call this on
their children, it generally shouldn't be called.
**/
void FitParent();
/*!
\brief Sets position and dimensions of widget.
Sets up widget rectangle, most widgets must override this to include their specific settings.
\param x X position of widget within it's container (entire screen if no parent)
\param y Y position of widget within it's container (entire screen if no parent)
\param width Width of widget.
\param height Height of widget.
**/
virtual void Kill();
virtual void Create(float x, float y, float width, float height);
/*!
\brief Change relative position.
Set new relative position for widget.
\param x New relative x position.
\param y New relative y position.
**/
virtual void Move(float x, float y);
/*!
\brief Important function used to recieve messages.
Recieves and processes a message, required overload for all widgets.
\param rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
\param event GewiEvent enum, description of event recieved.
\param mouseX Mouse x position in event, if not mouse event may be incorrect.
\param mouseY Mouse y position in event, if not mouse event may be incorrect.
\param ch Character pressed in event, may be 0 if not a keypress event.
**/
virtual void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch)=0;
/*!
\brief Draws this button to the screen.
Draws widget to the screen, required overload for all widgets.
**/
virtual void Show()=0;
/*!
\brief Get X position of widget.
Get actual (not relative) X position of top left corner of widget.
\return Actual x position of widget.
**/
float X();
/*!
\brief Get Y position of widget.
Get actual (not relative) Y position of top left corner of widget.
\return Actual y position of widget.
**/
float Y();
/*!
\brief Get visible state of widget.
Returns status of internal visible flag.
\return true if visible, false otherwise.
**/
bool Visible();
/*!
\brief Check if mouse is in widget.
Returns status of mouse inside widget.
\return true if mouse pointer inside widget, false otherwise.
**/
bool MouseInWidget();
/*!
\brief Check if the widget contains a point.
Check if the widget contains the point specified.
\param x X value of point to check.
\param y Y value of point to check.
**/
bool Contains(Sint16 x, Sint16 y);
};

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiWidgetList.h
\brief Definition file for WidgetList.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Definition file for WidgetList, a list of widgets used by GewiEngine and GContainers.
<br>$Id: GewiWidgetList.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -27,106 +27,31 @@ namespace Gewi
class GWidget;
/*!
\brief WidgetNode class, node for linked list.
Doubly linked list node containing a widget.
**/
class WidgetNode
{
public:
/*!
\brief Basic constructor.
Simple safety constructor just sets all values to NULL.
**/
WidgetNode();
//! Pointer to widget for this node.
GWidget *widget;
//! Pointer to previous node.
WidgetNode *prev;
//! Pointer to next node.
WidgetNode *next;
};
/*!
\brief Class containing a linked list of widgets.
Linked list of widgets, and various utility functions for containers.
Class is internally used only, GContainer and GewiEngine heavily rely on it.
**/
class WidgetList
{
private:
//! Pointer to head of list.
WidgetNode *mWidgetList;
//! Variable keeping track of where the last click was, to change focus.
WidgetNode *mClick;
/*!
\brief Internal function to delete widget memory.
Deletes the memory used by a widget node, interally used.
\param node Node to delete.
**/
void DeleteWidgetMem(WidgetNode *node);
public:
/*!
\brief Constructor for the linked list.
Simply NULLs pointers for the linked list.
**/
WidgetList();
/*!
\brief Add a WidgetNode to the list.
Adds a WidgetNode to the list, in the 'front'.
\param node Node to add to list.
**/
void AddWidget(WidgetNode *node);
/*!
\brief Delete a widget.
Deletes a widget, it's memory and frees it from it's container or GewiEngine.
\param widget Widget to delete.
**/
void DeleteWidget(GWidget *widget);
/*!
\brief Delete all widgets.
Deletes all widgets and their memory.
**/
void DeleteWidgets();
/*!
\brief Intercepts a message to process.
Intercepts and processes incoming messages, delegating them where they belong.
\param rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
\param event GewiEvent enum, description of event recieved.
\param mouseX Mouse x position in event, if not mouse event may be incorrect.
\param mouseY Mouse y position in event, if not mouse event may be incorrect.
\param ch Character pressed in event, may be 0 if not a keypress event.
**/
void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
/*!
\brief Fit all widgets to the parent.
Fits widgets to parent of which this linked list is a part of.
**/
void FitParent();
/*!
\brief Show widgets.
Calls Show method of widgets in reverse order for proper appearance.
**/
void ShowWidgets();
};

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiWindow.h
\brief Definition file for GWindow.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Definition file for GWindow, a basic window class based on GContainer.
<br>$Id: GewiWindow.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -26,61 +26,17 @@
namespace Gewi
{
/*!
\brief GWindow, a simple window class.
GWindow, basic window class, derived from GContainer.
**/
class GWindow : public GContainer
{
protected:
//! Holds internal state of if mouse is dragging the window or not.
bool rDrag;
//! X value of drag coordinate used for drag calculation.
float rDragX;
//! Y value of drag coordinate used for drag calculation.
float rDragY;
//! Image used for window.
float rDragX,rDragY;
ResourceID rBackground;
public:
/*!
\brief Simple constructor for GWindow.
GWindow();
Default constructor for GWindow, can take a parent.
\param parent Pointer to GContainer derived class to be the parent. Default value is NULL which means no parent.
**/
GWindow(GContainer *parent=NULL);
/*!
\brief GButton's create function, must be called to set up actual button.
Every widget has a create function which must be called to define the button's appearance and settings.
\param x X position of widget within it's container (entire screen if no parent)
\param y Y position of widget within it's container (entire screen if no parent)
\param width Width of widget.
\param height Height of widget.
\param backgroundImg Image for window.
**/
virtual void Create(float x, float y, float width, float height, ResourceID backgroundImg);
/*!
\brief Overload of Message, used to recieve messages.
Recieves and processes a message, required overload for all widgets.
\param rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
\param event GewiEvent enum, description of event recieved.
\param mouseX Mouse x position in event, if not mouse event may be incorrect.
\param mouseY Mouse y position in event, if not mouse event may be incorrect.
\param ch Character pressed in event, may be 0 if not a keypress event.
**/
virtual void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
/*!
\brief Draws window & children to the screen.
Draws window & children to the screen, required overload for all widgets.
**/
virtual void Show();
};

View File

@ -1,48 +0,0 @@
A Note From James:
For an explanation of the licensing simply refer to the files that come with
ZEngine, Gewi is unusable without ZEngine so it is safe to assume you have it
already. If for any reason you have Gewi but not ZEngine you may obtain ZEngine
here: http://zengine.sourceforge.net/.
----------------------------------(begin license)
Copyright (C) 2002, 2003 James Turk
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Concept of Zero nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------(end license)
In this distribution all files which fall under the license are marked as such with
the following notice:
/*******************************************************************************
This file is Part of the Gewi GUI Library for ZEngine.
Gewi and ZEngine Copyright (C) 2002, 2003 James Turk
Licensed under a BSD-style license. (see licensing.txt)
The maintainer of this library is James Turk (james@conceptofzero.net)
this library is found at the home of ZEngine http://zengine.sourceforge.net
*******************************************************************************/

View File

@ -1,52 +0,0 @@
#Makefile for ZEngine
include ./config
#defines the user shouldn't change#
INCLUDES = -I./include $(SDL_INC_PATH) $(GL_INC_PATH) $(ZE_INC_PATH)
LIBRARIES = -L./lib $(SDL_LIB_PATH) $(GL_LIB_PATH)
CFLAGS = $(EXTRA_OPTIONS) $(WARN_LEVEL) $(INCLUDES) $(LIBRARIES)
LIB_OUT = ./lib/libgewiS.a
ALL_TESTS = gewiTest00
SOURCES = $(wildcard src/*.cpp)
#SOURCES with path stripped and .cpp changed to .o
OBJECTS = $(notdir $(SOURCES:.cpp=.o))
#build targets#
$(LIB_OUT): $(SOURCES)
@echo Building $(BUILD_NAME)...
$(CC) $(CFLAGS) -c $(SOURCES)
$(AR) $(LIB_OUT) $(OBJECTS)
@echo Built $(BUILD_NAME).
./test/bin/gewiTest00$(EXE) : $(LIB_OUT) ./test/gewiTest00.cpp
@echo Building gewiTest00...
$(CC) $(CFLAGS) ./test/gewiTest00.cpp -o ./test/bin/gewiTest00$(EXE) $(LIBS)
@echo gewiTest00 compiled.
.PHONY: $(ALL_TESTS) tests all install clean veryclean
gewiTest00: ./test/bin/gewiTest00$(EXE)
tests: $(ALL_TESTS)
all: $(LIB_OUT) $(ALL_TESTS)
install: $(LIB_OUT)
mkdir -p $(INSTALL_INC)
mkdir -p $(INSTALL_LIB)
mkdir -p $(INSTALL_DOC)
cp -r ./include/* $(INSTALL_INC)
cp $(LIB_OUT) $(INSTALL_LIB)
cp -r ./doc/html/* $(INSTALL_DOC)
clean:
rm -f *.o
@echo All object files removed.
veryclean:
rm -f *.o
rm -f ./test/bin/*.exe
rm -f $(LIB_OUT)
@echo All output files removed.

View File

@ -1,61 +0,0 @@
Index
------------------------------------------------------------
I. About Gewi
II. Getting Gewi
III. Building Gewi
IV. Using Gewi
V. Legal Overview
VI. History of Gewi
------------------------------------------------------------
I. About Gewi
Gewi is a GUI library designed for use with ZEngine, information on ZEngine
can be found at http://zengine.sourceforge.net/.
------------------------------------------------------------
II. Getting Gewi:
Gewi is available from the same places that ZEngine is:
Support comes from: http://conceptofzero.net/
The sourceforge page: http://zengine.sourceforge.net/
The project page: http://sourceforge.net/projects/zengine/
The CVS page: http://sourceforge.net/cvs/?group_id=62098
------------------------------------------------------------
III. Building Gewi:
So far, Gewi can be built on any system any system that has SDL and OpenGL
available. If you are in VC++ the folder vc7 contains project files for use,
and if you are in a gcc compiler you can change the config & makefile to meet
your needs.
-If you are using VC++ you will need to add the path to the dependencies (SDL
and others) as well as the path to ZEngine before building.
If you are having a problem building ask at the ZEngine forum.
(Click forum link at http://zengine.sourceforge.net)
------------------------------------------------------------
IV. Using Gewi:
Gewi requires a working copy of ZEngine, if your compiler/environment
supports ZEngine it should support Gewi as well. Gewi tutorials and
documentation is not yet complete if you would like to write any submit
them to james@conceptofzero.net and I'll make sure they get out and you get
proper credit.
------------------------------------------------------------
V. Legal Overview:
See ZEngine's readme.txt for a Legal Overview of using libraries
that are dependent upon LGPL based libraries, using Gewi is the same
since it includes no new LGPL code.
------------------------------------------------------------
History of ZEngine:
Since most of the improvements will just be more widgets I
am much more open to outside help for Gewi than ZEngine which is mostly
my own work, I am going to depend on community support to add new widgets
to Gewi, I can't possibly add every single widget people need while working
on ZEngine and other projects.
0.1 was a basic release, just to show some people how I planned to
do the long promised GUI library for ZEngine. I rewrote this twice using
callbacks one time and a different way of handling child windows another,
but I found a way that seemed easy to use and easy to extend and that is what
has become 0.2.
-James Turk james@conceptofzero.net

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiButton.cpp
\brief Implementation of GButton.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Implementation of GButton, a simple button class.
<br>$Id: GewiButton.cpp,v 1.4 2003/08/10 01:40:56 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -25,7 +25,7 @@ namespace Gewi
GButton::GButton(GContainer *parent) :
GWidget(parent),
rPressed(false),
rType(GBT_PRESS),
rType(G_PRESS),
rNormalImage(GewiEngine::InvalidID),
rPressedImage(GewiEngine::InvalidID)
{
@ -50,28 +50,28 @@ void GButton::Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint1
void GButton::Show()
{
float x,y;
float w,h;
unsigned int w,h;
x = rBoundRect.X();
y = rBoundRect.Y();
//images must be "resized" with each draw, disadvantage to shared resources
//yet luckily the ZImage resize system is only two assignments, not actual stretching code
//if resize is to be rewritten the shared resources system of Gewi should be reconsidered
w = rBoundRect.Width();
h = rBoundRect.Height();
w = static_cast<unsigned int>(rBoundRect.Width());
h = static_cast<unsigned int>(rBoundRect.Height());
rGewi->Image(rPressedImage)->Resize(w,h);
rGewi->Image(rNormalImage)->Resize(w,h);
if(rVisible)
{
if(rType == GBT_PRESS) //G_PRESS: standard press button, down when pressed, up when not
if(rType == G_PRESS) //G_PRESS: standard press button, down when pressed, up when not
{
if(rPressed)
rGewi->Image(rPressedImage)->Draw(x,y);
else
rGewi->Image(rNormalImage)->Draw(x,y);
}
else if(rType == GBT_HOVER) //G_HOVER: button shows as down when hovered over
else if(rType == G_HOVER) //G_HOVER: button shows as down when hovered over
{
if(MouseInWidget())
rGewi->Image(rPressedImage)->Draw(x,y);
@ -86,9 +86,9 @@ bool GButton::IsPressed()
return rPressed;
}
void GButton::SetState(bool pressed)
void GButton::SetState(bool state)
{
rPressed = pressed;
rPressed = state;
}
}

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiContainer.cpp
\brief Implementation of GContainer.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Implementation of GContainer, a barebones widget that can contain child widgets.
<br>$Id: GewiContainer.cpp,v 1.6 2003/06/12 09:32:32 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -22,8 +22,6 @@
namespace Gewi
{
//all the work for GContainer is now done by WidgetList//
void GContainer::AddChild(GWidget *widget)
{
WidgetNode *node = new WidgetNode;
@ -45,11 +43,6 @@ GContainer::GContainer(GContainer *parent)
{
}
GContainer::~GContainer()
{
rChildList.DeleteWidgets();
}
void GContainer::Move(float x, float y)
{
GWidget::Move(x,y);
@ -58,7 +51,7 @@ void GContainer::Move(float x, float y)
void GContainer::Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch)
{
rChildList.Message(rawEvent,event,mouseX,mouseY,ch); //rChildList does the work of passing the event correctly
rChildList.Message(rawEvent,event,mouseX,mouseY,ch);
}
void GContainer::Show()

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiEngine.cpp
\brief Implementation of GewiEngine.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Implementation of GewiEngine, core engine for Gewi GUI control.
<br>$Id: GewiEngine.cpp,v 1.9 2003/06/16 04:47:54 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -23,30 +23,23 @@
namespace Gewi
{
VersionInfo GewiEngine::Version(0,2,0);
VersionInfo GewiEngine::MinZEVersion(0,8,4); //important to keep this accurate
GewiEngine *GewiEngine::sInstance=NULL;
SDL_EventFilter GewiEngine::sOldFilter=NULL;
GewiEngine::GewiEngine()
{
ZE::ZEngine *ze = ZE::ZEngine::GetInstance();
//check version of ZEngine
if(ZE::ZEngine::Version < GewiEngine::MinZEVersion)
ze->WriteLog(ZE::FormatStr("Gewi %s requires ZEngine %s or greater, ZEngine %s in use.",
GewiEngine::Version.GetString().c_str(),
GewiEngine::MinZEVersion.GetString().c_str(),
ZE::ZEngine::Version.GetString().c_str()));
ze->SetEventFilter((SDL_EventFilter)GewiEngine::EventFilter);
sOldFilter = SDL_GetEventFilter(); //store event filter and set the new one
SDL_SetEventFilter((SDL_EventFilter)GewiEngine::EventFilter);
SDL_EnableUNICODE(1); //needed for the key translation
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL); //more like typing, less like game
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
}
GewiEngine* GewiEngine::GetInstance()
{
if(!sInstance)
sInstance = new GewiEngine;
return sInstance;
}
@ -61,17 +54,16 @@ void GewiEngine::ReleaseInstance()
//set everything back to default
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_INTERVAL,SDL_DEFAULT_REPEAT_INTERVAL);
SDL_EnableUNICODE(0);
ZE::ZEngine::GetInstance()->SetEventFilter(NULL);
SDL_SetEventFilter(sOldFilter);
}
}
int GewiEngine::EventFilter(SDL_Event *event)
{
static char noChar = '\0';
static char noChar = static_cast<char>(0);
GewiEngine *gewi = GewiEngine::GetInstance();
char ch;
//called inside ZEngine::CheckEvents
switch(event->type)
{
case SDL_MOUSEBUTTONDOWN:
@ -94,19 +86,28 @@ int GewiEngine::EventFilter(SDL_Event *event)
ch = TranslateKey(event->key.keysym);
gewi->SendMessage(event,GE_KUP,0,0,ch);
break;
case SDL_QUIT:
//.
break;
default:
break;
}
return 1; //pass the event on, allowing ZEngine to do what it needs
return 1; //pass the event on
}
char GewiEngine::TranslateKey(SDL_keysym key)
{
//this is why unicode must be enabled, without this it'd be one massive switch statement
if(key.unicode > 0 && key.unicode <= 255)
return static_cast<char>(key.unicode);
char ch;
if(key.unicode && key.unicode <= 255)
ch = static_cast<char>(key.unicode);
else
return static_cast<char>(127);
ch = static_cast<char>(127);
if(ch >= 'a' && ch <= 'z' && (key.mod & KMOD_SHIFT))
ch -= 20; //capitalize
return ch;
}
void GewiEngine::Display()
@ -114,19 +115,19 @@ void GewiEngine::Display()
mWidgetList.ShowWidgets();
}
ResourceID GewiEngine::AddResource(ZE::ZImage *image)
ResourceID GewiEngine::AddResource(ZImage *image)
{
mImageVec.push_back(image);
return static_cast<ResourceID>(mImageVec.size()-1);
}
ResourceID GewiEngine::AddResource(ZE::ZFont *font)
ResourceID GewiEngine::AddResource(ZFont *font)
{
mFontVec.push_back(font);
return static_cast<ResourceID>(mFontVec.size()-1);
}
ZE::ZImage* GewiEngine::Image(ResourceID id)
ZImage* GewiEngine::Image(ResourceID id)
{
//do range checking
if(id >= 0 && id < mImageVec.size())
@ -135,7 +136,7 @@ ZE::ZImage* GewiEngine::Image(ResourceID id)
return NULL;
}
ZE::ZFont* GewiEngine::Font(ResourceID id)
ZFont* GewiEngine::Font(ResourceID id)
{
//do range checking
if(id >= 0 && id < mFontVec.size())
@ -149,12 +150,18 @@ void GewiEngine::FreeResources()
for(ResourceID i=0; i < mImageVec.size(); i++)
{
if(mImageVec[i])
{
mImageVec[i]->Release();
delete mImageVec[i];
}
}
for(ResourceID i=0; i < mFontVec.size(); i++)
{
if(mFontVec[i])
{
mFontVec[i]->Release();
delete mFontVec[i];
}
}
}

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiSlider.cpp
\brief Implementation of GSlider, GHorizSlider and GVertSlider.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Implementation of GSlider, GHorizSlider and GVertSlider, the slide-select classes for Gewi.
<br>$Id: GewiSlider.cpp,v 1.5 2003/06/12 09:32:33 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -22,8 +22,8 @@
namespace Gewi
{
GSlider::GSlider(GContainer *parent) :
GWidget(parent),
GSlider::GSlider() :
GWidget(),
rPressed(false),
rBackground(GewiEngine::InvalidID),
rSlider(GewiEngine::InvalidID),
@ -58,10 +58,9 @@ void GSlider::SetPos(float pos)
pos = static_cast<float>(rounded-rounded%rIncrement); //snap to a multiple of increment
}
//get within bounds
if(pos < rMin)
pos = rMin;
else if(pos > rMax)
if(pos > rMax)
pos = rMax;
rPos = pos;
}
@ -91,7 +90,7 @@ void GHorizSlider::Show()
if(rPressed && !rZE->LButtonPressed() || !MouseInWidget()) //dont allow them to drag pointer out of box
Message(NULL,GE_LUP,rZE->MouseX(),rZE->MouseY(),static_cast<char>(0)); //fake a message
//the slider is centered about the current position, altered if currently sliding
//the slider is centered about the current position
if(rPressed)
xPos = rZE->MouseX()-rGewi->Image(rSlider)->Width()/2.0f;
else

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiStaticText.cpp
\brief Implementation of GStaticText.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Implementation of GStaticText, file to hold static text, labels and such.
<br>$Id: GewiStaticText.cpp,v 1.7 2003/08/10 01:40:56 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -34,9 +34,10 @@ GStaticText::GStaticText(GContainer *parent) :
void GStaticText::Create(float x, float y, float width, float height,
ResourceID font, std::string text, GewiJustify justify, ResourceID backgroundImg)
ResourceID font, ResourceID backgroundImg, string text, GewiJustify justify)
{
GWidget::Create(x,y,width,height);
rBackgroundImage = backgroundImg;
rFont = font;
rJustify = justify; //must justify pre-SetText
@ -50,19 +51,19 @@ void GStaticText::Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, U
void GStaticText::Show()
{
//images must call Resize with each draw (see shared resources rant)
//images must call Resize with each draw (shared resources)
if(rBackgroundImage != GewiEngine::InvalidID)
rGewi->Image(rBackgroundImage)->Resize(static_cast<unsigned int>(rBoundRect.Width()),static_cast<unsigned int>(rBoundRect.Height()));
if(rBackgroundImage != GewiEngine::InvalidID)
{
rGewi->Image(rBackgroundImage)->Resize(rBoundRect.Width(),rBoundRect.Height());
rGewi->Image(rBackgroundImage)->Draw(rBoundRect.X(),rBoundRect.Y());
}
rTextBuf.Draw(rBoundRect.X()+rXOff,rBoundRect.Y()+rYOff); //draw text shifted by offset
}
void GStaticText::SetText(std::string text)
void GStaticText::SetText(string text)
{
float w,h;
int w,h;
rText = text;
rGewi->Font(rFont)->DrawText(rText,rTextBuf);
@ -70,24 +71,35 @@ void GStaticText::SetText(std::string text)
w=rTextBuf.Width();
h=rTextBuf.Height();
//left,right,center
if(rJustify & GJ_LEFT)
rXOff = 0;
else if(rJustify & GJ_RIGHT)
rXOff = static_cast<int>(rBoundRect.Width()-w);
else
//center each by default
rXOff = static_cast<int>(rBoundRect.Width()-w)/2;
//top,bottom,center
if(rJustify & GJ_TOP)
rYOff = 0;
else if(rJustify & GJ_BOTTOM)
rYOff = static_cast<int>(rBoundRect.Height()-h);
else
rYOff = static_cast<int>(rBoundRect.Height()-h)/2;
if(rJustify & GJ_LEFT)
{
printf("left");
rXOff = 0;
}
else if(rJustify & GJ_RIGHT)
{
printf("right");
rXOff = static_cast<int>(rBoundRect.Width()-w);
}
std::string GStaticText::GetText()
if(rJustify & GJ_TOP)
{
printf("top");
rYOff = 0;
}
else if(rJustify & GJ_BOTTOM)
{
printf("bottom");
rYOff = static_cast<int>(rBoundRect.Height()-h);
}
printf("\n");
}
string GStaticText::GetText()
{
return rText;
}

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiTextButton.cpp
\brief Implementation of GTextButton.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Implementation of GTextButton, a GButton that has a text label.
<br>$Id: GewiTextButton.cpp,v 1.4 2003/06/11 00:19:29 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -31,7 +31,7 @@ GTextButton::GTextButton(GContainer *parent) :
void GTextButton::Create(float x, float y, float width, float height, ResourceID normalImg, ResourceID pressImg, ResourceID font,
std::string text, GButtonType type)
string text, GButtonType type)
{
GButton::Create(x,y,width,height,normalImg,pressImg,type);
rFont = font;
@ -49,7 +49,7 @@ void GTextButton::Show()
rTextBuf.Draw(rBoundRect.X()+rXOff,rBoundRect.Y()+rYOff); //draw text shifted by offset
}
void GTextButton::SetText(std::string text)
void GTextButton::SetText(string text)
{
rText = text;
rGewi->Font(rFont)->DrawText(rText,rTextBuf);
@ -58,7 +58,7 @@ void GTextButton::SetText(std::string text)
rYOff = static_cast<int>(rBoundRect.Height()-rTextBuf.Height())/2;
}
std::string GTextButton::GetText()
string GTextButton::GetText()
{
return rText;
}

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiTextField.cpp
\brief Implementation of GTextField.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Implementation of GTextField, text input area widget.
<br>$Id: GewiTextField.cpp,v 1.7 2003/08/10 01:40:56 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -30,6 +30,16 @@ GTextField::GTextField(GContainer *parent) :
rLeftPadding(0)
{}
GTextField::~GTextField()
{
}
void GTextField::Kill()
{
rBuffer.Release();
GWidget::Kill();
}
void GTextField::Create(float x, float y, float width, float height, ResourceID font, ResourceID backgroundImg, int maxChars, int leftPad)
{
GWidget::Create(x,y,width,height);
@ -55,19 +65,19 @@ void GTextField::Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Ui
void GTextField::Show()
{
rGewi->Image(rBackground)->Resize(rBoundRect.Width(),rBoundRect.Height());
rGewi->Image(rBackground)->Resize(static_cast<unsigned int>(rBoundRect.Width()),static_cast<unsigned int>(rBoundRect.Height()));
rGewi->Image(rBackground)->Draw(rBoundRect.X(),rBoundRect.Y());
if(rBuffer.IsLoaded()) //don't draw empty buffer image
rBuffer.Draw(rLeftPadding+rBoundRect.X(),rBoundRect.Y()+(rBoundRect.Height()-rBuffer.Height())/2);
}
void GTextField::SetText(std::string text)
void GTextField::SetText(string text)
{
rText = text;
rGewi->Font(rFont)->DrawText(rText,rBuffer);
}
std::string GTextField::GetText()
string GTextField::GetText()
{
return rText;
}

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiWidget.cpp
\brief Implementation of GWidget.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Implementation of GWidget, virtual widget base class.
<br>$Id: GewiWidget.cpp,v 1.7 2003/06/12 09:32:33 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -34,13 +34,13 @@ void GWidget::FitParent() //adjust to relative pos + parent pos
GWidget::GWidget(GContainer *parent) :
rGewi(GewiEngine::GetInstance()),
rZE(ZE::ZEngine::GetInstance()),
rZE(ZEngine::GetInstance()),
rParent(parent),
rRelX(0),
rRelY(0),
rVisible(true)
rVisible(true),
rAlive(true)
{
//widgets take care of all registration, making the parent processes virtually hidden
if(rParent)
rParent->AddChild(this);
else
@ -56,6 +56,20 @@ void GWidget::ToggleVisible()
rVisible = !rVisible;
}
void GWidget::Kill()
{
if(rParent)
{
rParent->ReleaseChild(this);
rParent = NULL;
}
else
rGewi->DeleteWidget(this);
//rChildList.DeleteWidgets();
rAlive = rVisible = false;
}
void GWidget::Create(float x, float y, float width, float height)
{
Move(x,y);
@ -85,7 +99,6 @@ bool GWidget::Visible()
return rVisible;
}
//it is important to remember rBoundRect is the actual position
bool GWidget::MouseInWidget()
{
return rZE->MouseInRect(&rBoundRect.SDLrect());

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiWidgetList.cpp
\brief Implementation of WidgetList.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Implementation of WidgetList, a list of widgets used by GewiEngine and GContainers.
<br>$Id: GewiWidgetList.cpp,v 1.5 2003/06/12 09:32:33 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -30,8 +30,6 @@ WidgetNode::WidgetNode() :
{
}
//WidgetList keeps circular list of nodes, backwards traversal is key for proper draw order//
void WidgetList::DeleteWidgetMem(WidgetNode *node)
{
if(node == mWidgetList) //special case if deleting top node
@ -41,7 +39,7 @@ void WidgetList::DeleteWidgetMem(WidgetNode *node)
else
mWidgetList = NULL;
}
//adjust links & delete node
//adjust links and actually delete node
node->prev->next = node->next;
node->next->prev = node->prev;
delete node;
@ -57,11 +55,11 @@ void WidgetList::AddWidget(WidgetNode *node)
{
if(mWidgetList == NULL)
{
node->next = node->prev = node; //first node points to self in both directions
node->next = node->prev = node;
}
else
{
//make front & back connections
//make connections
node->next = mWidgetList;
node->prev = mWidgetList->prev;
mWidgetList->prev->next = node;
@ -82,7 +80,7 @@ void WidgetList::DeleteWidget(GWidget *widget)
if(cur->widget == widget)
found = cur;
cur = cur->next;
} while(cur != mWidgetList && !found); //go through & find node
} while(cur != mWidgetList && !found);
if(found)
DeleteWidgetMem(found);
@ -92,10 +90,10 @@ void WidgetList::DeleteWidget(GWidget *widget)
void WidgetList::DeleteWidgets()
{
WidgetNode *cur = mWidgetList;
while(mWidgetList) //will be set to null on last widget
while(mWidgetList)
{
cur = cur->next;
DeleteWidgetMem(cur->prev);
cur->prev->widget->Kill();
}
}
@ -167,15 +165,12 @@ void WidgetList::FitParent()
void WidgetList::ShowWidgets()
{
WidgetNode *cur = mWidgetList;
if(mWidgetList)
{
do
{
cur = cur->prev; //draw from back to front, through list in reverse
if(cur->widget->Visible()) //visible checked here so each Show() doesn't need to bother
if(cur->widget->Visible())
cur->widget->Show();
}while(cur != mWidgetList);
}
}
}

View File

@ -9,11 +9,11 @@
*******************************************************************************/
/*!
\file GewiWindow.cpp
\brief Implementation of GWindow.
\file ZE_ZConfigFile.h
\brief Definition file for ZConfigFile.
Implementation of GWindow, a basic window class based on GContainer.
<br>$Id: GewiWindow.cpp,v 1.5 2003/08/10 01:40:56 cozman Exp $<br>
Definition file for ZConfigFile, an INI-style config file format.
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
\author James Turk
**/
@ -22,8 +22,8 @@
namespace Gewi
{
GWindow::GWindow(GContainer *parent) :
GContainer(parent),
GWindow::GWindow() :
GContainer(),
rDrag(false),
rDragX(0),
rDragY(0),
@ -67,7 +67,7 @@ void GWindow::Show()
}
//resize (shared resources) and draw
rGewi->Image(rBackground)->Resize(rBoundRect.Width(),rBoundRect.Height());
rGewi->Image(rBackground)->Resize(static_cast<unsigned int>(rBoundRect.Width()),static_cast<unsigned int>(rBoundRect.Height()));
rGewi->Image(rBackground)->Draw(rBoundRect.X(),rBoundRect.Y());
GContainer::Show(); //important that a window draws it's children

Binary file not shown.

View File

@ -1 +0,0 @@
The free fonts in this directory came from http://larabiefonts.com.

View File

@ -7,83 +7,92 @@
The maintainer of this library is James Turk (james@conceptofzero.net)
this library is found at the home of ZEngine http://zengine.sourceforge.net
*******************************************************************************/
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include "ZEngine.h"
#include "Gewi.h"
#include <string>
#include "GewiEngine.h"
#include "GButton.h"
#include "GTextButton.h"
#include "GWindow.h"
#include "GTextField.h"
#include "GSlider.h"
#include "GStaticText.h"
using namespace ZE;
using namespace Gewi;
bool Initialize()
{
ZEngine *engine = ZEngine::GetInstance();
ZConfigFile cfg("tests.zcf");
int w,h,bpp,rate;
bool fs;
std::string title;
w = cfg.GetInt("ZTimerTest","width",800);
h = cfg.GetInt("ZTimerTest","height",600);
bpp = cfg.GetInt("ZTimerTest","bpp",32);
fs = cfg.GetBool("ZTimerTest","fullscreen",false);
title = cfg.GetString("ZTimerTest","title","Gewi Test");
rate = cfg.GetInt("ZTimerTest","framerate",60);
engine->SetupDisplay(w,h,bpp,fs);
engine->SetDesiredFramerate(rate);
return engine->CreateDisplay(title);
}
void Test()
void Init()
{
ZEngine *ze = ZEngine::GetInstance();
GewiEngine *gewi = GewiEngine::GetInstance();
ZImage bg,temp[8];
ZFont font;
ResourceID id[8],fontID;
//all of the widgets//
GWindow window;
GTextButton txtButton;
GTextField txtField,txtField2(&window);
GButton button(&window);
GHorizSlider hSlider;
GVertSlider vSlider;
GButton hoverButton(&window);
GStaticText label;
ZConfigFile cfg("gewiTest.zcf");
int w,h,bpp;
bool fs;
string title;
bg.Open("data/rainbow.bmp");
bg.Resize(static_cast<float>(ze->DisplayWidth()),static_cast<float>(ze->DisplayHeight()));
w = cfg.GetInt("screen","width",800);
h = cfg.GetInt("screen","height",600);
bpp = cfg.GetInt("screen","bpp",32);
fs = cfg.GetBool("screen","fullscreen",false);
title = cfg.GetString("screen","title","Gewi Test");
//opening the images//
temp[0].Open("data/b1.bmp");
temp[1].Open("data/b2.bmp");
temp[2].Open("data/skin1.bmp");
temp[3].Open("data/text.bmp");
temp[4].Open("data/bg3.bmp");
temp[5].Open("data/slider.bmp");
temp[6].Open("data/bg4.bmp");
temp[7].Open("data/slider2.bmp");
font.Open("data/axaxax.ttf",20);
//registering the resources//
for(int i=0; i < 8; ++i)
{
temp[i].SetColorKey(255,0,255);
id[i] = gewi->AddResource(&temp[i]);
ze->SetupDisplay(w,h,bpp,fs);
ze->CreateDisplay(title);
}
fontID = gewi->AddResource(&font);
//each widget must be created//
window.Create(300,300,300,300,id[2]);
button.Create(50,30,10,10,id[0],id[1]);
txtField.Create(100,100,500,50,fontID,id[3],20,20);
txtField2.Create(50,200,200,50,fontID,id[3],20,20);
txtButton.Create(400,200,300,50,id[0],id[1],fontID,"restore window");
hSlider.Create(100,500,200,50,id[4],id[5],0,3,1);
vSlider.Create(700,200,50,200,id[6],id[7],0,200,5);
hoverButton.Create(70,40,100,100,id[0],id[1],GBT_HOVER);
label.Create(100,100,100,100,fontID,"static",GJ_CENTER,GewiEngine::InvalidID);
void Test1()
{
ZEngine *ze = ZEngine::GetInstance();
Gewi *gewi = Gewi::GetInstance();
ZImage bg("rainbow.bmp"),buf;
ResourceID id1,id2,id3,id4,id5,id6,id7,id8,id9;
GWindow w1;
GTextButton tb1;
GTextField t1,t2(&w1);
GButton b1(&w1);
GHorizSlider s1;
GVertSlider s2;
GButton hb1(&w1);
GStaticText st1;
bg.Resize(800,600);
ZImage *temp,*temp2,*temp3,*temp4,*temp5,*temp6,*temp7,*temp8;
ZFont *font;
temp = new ZImage("b1.bmp");
temp2 = new ZImage("b2.bmp");
temp3 = new ZImage("skin1.bmp");
temp4 = new ZImage("text.bmp");
temp5 = new ZImage("bg3.bmp");
temp6 = new ZImage("slider.bmp");
temp7 = new ZImage("bg4.bmp");
temp8 = new ZImage("slider2.bmp");
font = new ZFont("c:\\windows\\fonts\\arial.ttf",20);
temp->SetColorKey(255,0,255);
temp2->SetColorKey(255,0,255);
temp3->SetColorKey(255,0,255);
id1 = gewi->AddResource(temp);
id2 = gewi->AddResource(temp2);
id3 = gewi->AddResource(temp3);
id4 = gewi->AddResource(font);
id5 = gewi->AddResource(temp4);
id6 = gewi->AddResource(temp5);
id7 = gewi->AddResource(temp6);
id8 = gewi->AddResource(temp7);
id9 = gewi->AddResource(temp8);
temp4->SetColorKey(255,0,255);
temp6->SetColorKey(255,0,255);
temp8->SetColorKey(255,0,255);
w1.Create(300,300,300,300,id3);
b1.Create(50,30,10,10,id1,id2);
t1.Create(100,100,500,50,id4,id5,20,20);
t2.Create(50,200,200,50,id4,id5,20,20);
tb1.Create(400,200,300,50,id1,id2,id4,"restore window");
s1.Create(100,500,200,50,id6,id7,0,3,1);
s2.Create(700,200,50,200,id8,id9,0,200,5);
hb1.Create(70,40,100,100,id1,id2,G_HOVER);
st1.Create(100,100,100,100,id4,Gewi::InvalidID,"static",GJ_CENTER);
do
{
@ -91,33 +100,48 @@ void Test()
if(ze->IsActive())
{
if(ze->KeyIsPressed(SDLK_ESCAPE) || hoverButton.IsPressed())
if(ze->KeyIsPressed(SDLK_ESCAPE))
ze->RequestQuit();
if( (button.IsPressed() && window.Visible()) || (txtButton.IsPressed() && !window.Visible()) )
{
window.ToggleVisible();
txtButton.SetState(false);
button.SetState(false);
}
temp[2].SetAlpha(static_cast<Uint8>(63+hSlider.GetPos()*64));
font->DrawText(FormatStr("%f",s1.GetPos()),buf);
bg.Draw(0,0);
gewi->Display(); //draws everything
temp3->SetAlpha(63+s1.GetPos()*64);
gewi->Display();
buf.Draw(0.0f,s2.GetPos());
if(b1.IsPressed() && w1.Visible())
{
w1.ToggleVisible();
tb1.SetState(false);
b1.SetState(false);
}
if(tb1.IsPressed() && !w1.Visible())
{
w1.ToggleVisible();
b1.SetState(false);
tb1.SetState(false);
}
if(hb1.IsPressed())
ze->RequestQuit();
ze->Update();
}
} while(!ze->QuitRequested());
}
Gewi::ReleaseInstance();
}
int main(int argc, char *argv[])
{
if(Initialize())
Test();
// _crtBreakAlloc=163;
Init();
Test1();
GewiEngine::ReleaseInstance();
ZEngine::ReleaseInstance();
_CrtDumpMemoryLeaks();
return 0;
}

View File

@ -1,6 +0,0 @@
Gewi Todo List
-More Widgets
-Other build targets
-More examples.
Feel free to contribute, Gewi is a side project and I will rely on the community for new widget ideas and such.

1
todo_release.txt Executable file
View File

@ -0,0 +1 @@
make source files conform

View File

@ -17,7 +17,6 @@ Global
{F5974221-8DB8-4BC1-B944-EE62F44A9114}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
DPBuild = 5
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection

View File

@ -88,18 +88,12 @@
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc">
<File
RelativePath="..\include\Gewi.h">
</File>
<File
RelativePath="..\include\GewiButton.h">
</File>
<File
RelativePath="..\include\GewiContainer.h">
</File>
<File
RelativePath="..\include\GewiDefines.h">
</File>
<File
RelativePath="..\include\GewiEngine.h">
</File>

View File

@ -21,7 +21,6 @@
Optimization="2"
InlineFunctionExpansion="1"
OmitFramePointers="TRUE"
AdditionalIncludeDirectories="../include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
StringPooling="TRUE"
RuntimeLibrary="2"
@ -38,13 +37,13 @@
SDLmain.lib
OpenGL32.lib
SDL_mixer.lib
SDL_net.lib
SDL_image.lib
SDL_ttf.lib
ZEngineS.lib
gewi.lib"
OutputFile="../test/bin/GewiTest00.exe"
c:\home\src\gewi\Release\gewi.lib"
OutputFile="$(OutDir)/gewitest.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="../lib"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
@ -70,9 +69,6 @@ gewi.lib"
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
<File
RelativePath="..\test\gewiTest00.cpp">
</File>
</Filter>
<Filter
Name="Header Files"