Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
82d5879949 | ||
![]() |
21decba405 | ||
![]() |
e01980fb2d | ||
![]() |
1a4f57e603 | ||
![]() |
ce7a367449 | ||
![]() |
47136decb1 | ||
![]() |
7912cca801 | ||
![]() |
86753457fc | ||
![]() |
dc48b0dbef | ||
![]() |
2203a2e7b2 | ||
![]() |
484ff0e456 | ||
![]() |
0ae3482088 | ||
![]() |
2bdaf33337 | ||
![]() |
2581f5e471 | ||
![]() |
a44d42aff7 | ||
![]() |
4bf838ff0b | ||
![]() |
3849f459c4 | ||
![]() |
54a765d809 | ||
![]() |
1166ec33c1 | ||
![]() |
560e916eae | ||
![]() |
6c8ef078ab | ||
![]() |
859c67d997 | ||
![]() |
15fcacda56 | ||
![]() |
69ce38cb2d | ||
![]() |
57539b3210 | ||
![]() |
ba6cc67b62 | ||
![]() |
53ac6d7d9c | ||
![]() |
34068b8b1d | ||
![]() |
b0047499e9 | ||
![]() |
acb812219a | ||
![]() |
03841b7e31 | ||
![]() |
c94dc60e35 | ||
![]() |
d12e57abd4 |
2
authors.txt
Executable file
2
authors.txt
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
James Turk james@conceptofzero.net - GewiEngine and all base widgets.
|
||||||
|
Atani atani@atani-software.net - Revised Linux Build System
|
20
changelog.txt
Executable file
20
changelog.txt
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
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
Executable file
29
config
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#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)
|
205
doc/gewi.win32.doxygen
Executable file
205
doc/gewi.win32.doxygen
Executable file
@ -0,0 +1,205 @@
|
|||||||
|
# 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 =
|
62
include/Gewi.h
Executable file
62
include/Gewi.h
Executable file
@ -0,0 +1,62 @@
|
|||||||
|
/*!
|
||||||
|
\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>
|
||||||
|
-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>
|
||||||
|
-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>
|
||||||
|
-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>
|
||||||
|
-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__
|
@ -10,10 +10,10 @@
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file GewiButton.h
|
\file GewiButton.h
|
||||||
\brief Definition file for GewiButton.
|
\brief Definition file for GButton.
|
||||||
|
|
||||||
Definition file for GewiButton, a simple button class.
|
Definition file for GButton, a simple button class.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiButton.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -26,22 +26,91 @@
|
|||||||
namespace Gewi
|
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
|
class GButton : public GWidget
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
//! Boolean holding if button is currently pressed or not.
|
||||||
bool rPressed;
|
bool rPressed;
|
||||||
|
//! Enum for type of button.
|
||||||
GButtonType rType;
|
GButtonType rType;
|
||||||
|
//! Resource ID for the non-pressed image.
|
||||||
ResourceID rNormalImage;
|
ResourceID rNormalImage;
|
||||||
|
//! Resource ID for the pressed (or hover) image.
|
||||||
ResourceID rPressedImage;
|
ResourceID rPressedImage;
|
||||||
|
|
||||||
public:
|
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);
|
GButton(GContainer *parent=NULL);
|
||||||
|
|
||||||
virtual void Create(float x, float y, float width, float height, ResourceID normalImg, ResourceID pressImg, GButtonType type=G_PRESS);
|
/*!
|
||||||
|
\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 Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
|
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();
|
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();
|
bool IsPressed();
|
||||||
void SetState(bool state);
|
|
||||||
|
/*!
|
||||||
|
\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);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiContainer.h
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Definition file for GContainer.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Definition file for GContainer, a barebones widget that can contain child widgets.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiContainer.h,v 1.7 2003/07/20 03:21:21 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -27,23 +27,87 @@
|
|||||||
namespace Gewi
|
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
|
class GContainer : public 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_
|
The usage of friend here is used simply to allow GWidget proper access to what used to belong to
|
||||||
//encapsulation (for those keeping score, this is to many people the only effective use of friend)
|
it before the class split GWidget needs access to Add/ReleaseChild but to make them public would
|
||||||
friend GWidget;
|
<strong>reduce</strong> encapsulation. (For those keeping score, this is to many people the only effective use of
|
||||||
|
friend.)
|
||||||
|
**/
|
||||||
|
friend class Gewi::GWidget;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
//! List of child widgets assigned to this container.
|
||||||
WidgetList rChildList;
|
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);
|
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);
|
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);
|
void InsertWidget(WidgetNode *node);
|
||||||
|
|
||||||
public:
|
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(GContainer *parent=NULL);
|
||||||
void Move(float x, float y);
|
|
||||||
void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
|
~GContainer();
|
||||||
void Show();
|
|
||||||
|
/*!
|
||||||
|
\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();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
67
include/GewiDefines.h
Executable file
67
include/GewiDefines.h
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
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__
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiEngine.h
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Definition file for GewiEngine.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Definition file for GewiEngine, core engine for Gewi GUI control.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiEngine.h,v 1.7 2003/06/11 00:19:40 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -23,44 +23,180 @@
|
|||||||
#include "GewiIncludes.h"
|
#include "GewiIncludes.h"
|
||||||
#include "GewiWidgetList.h"
|
#include "GewiWidgetList.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Gewi Namespace.
|
||||||
|
|
||||||
|
Namespace for all Gewi classes and utility functions.
|
||||||
|
**/
|
||||||
namespace Gewi
|
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
|
class GewiEngine
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
//! Static version information.
|
||||||
|
static VersionInfo Version;
|
||||||
|
//! Required ZEngine version.
|
||||||
|
static VersionInfo MinZEVersion;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//! Singleton static instance of GewiEngine.
|
||||||
static GewiEngine *sInstance;
|
static GewiEngine *sInstance;
|
||||||
static SDL_EventFilter sOldFilter;
|
//! Vector of pointers to ZImages, used by resource management system.
|
||||||
vector<ZImage*> mImageVec;
|
std::vector<ZE::ZImage*> mImageVec;
|
||||||
vector<ZFont*> mFontVec;
|
//! Vector of pointers to ZFonts, used by resource management system.
|
||||||
|
std::vector<ZE::ZFont*> mFontVec;
|
||||||
|
//! List of widgets in global context.
|
||||||
WidgetList mWidgetList;
|
WidgetList mWidgetList;
|
||||||
|
|
||||||
//singleton setup//
|
//singleton setup//
|
||||||
private:
|
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();
|
GewiEngine();
|
||||||
|
|
||||||
public:
|
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
|
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();
|
static GewiEngine* GetInstance();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Release static instance.
|
||||||
|
|
||||||
|
Releases the instance of GewiEngine, basically only called at very end of program.
|
||||||
|
**/
|
||||||
static void ReleaseInstance();
|
static void ReleaseInstance();
|
||||||
|
|
||||||
//utilities//
|
//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);
|
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);
|
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();
|
void Display();
|
||||||
|
|
||||||
//resource management//
|
//resource management//
|
||||||
ResourceID AddResource(ZImage *image);
|
|
||||||
ResourceID AddResource(ZFont *font);
|
/*!
|
||||||
ZImage* Image(ResourceID id);
|
\brief Adds an image resource to the private vector.
|
||||||
ZFont* Font(ResourceID id);
|
|
||||||
|
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.
|
||||||
|
**/
|
||||||
void FreeResources();
|
void FreeResources();
|
||||||
|
|
||||||
//widget management//
|
//widget management//
|
||||||
private:
|
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);
|
void InsertWidget(WidgetNode *node);
|
||||||
|
|
||||||
public:
|
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);
|
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);
|
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);
|
void DeleteWidget(GWidget *widget);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,28 +9,22 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiIncludes.h
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Include file for Gewi.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Include file for Gewi, contains external includes for Gewi.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$id: GewiIncludes.h,v 1.3 2003/05/19 23:56:05 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef __gewiincludes_h__
|
#ifndef __gewiincludes_h__
|
||||||
#define __gewiincludes_h__
|
#define __gewiincludes_h__
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <limits>
|
#include <climits>
|
||||||
#include "ZEngine.h"
|
#include "ZEngine.h"
|
||||||
typedef unsigned int WidgetID;
|
#include "GewiDefines.h"
|
||||||
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__
|
#endif //__gewiincludes_h__
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiSlider.h
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Definition file for GSlider, GHorizSlider and GVertSlider.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Definition file for GSlider, GHorizSlider and GVertSlider, the slide-select classes for Gewi.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiSlider.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -26,35 +26,125 @@
|
|||||||
namespace Gewi
|
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
|
class GSlider : public GWidget
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
//! Boolean value holding if slider is currently 'pressed' or active.
|
||||||
bool rPressed;
|
bool rPressed;
|
||||||
|
//! ID for background image for slider.
|
||||||
ResourceID rBackground;
|
ResourceID rBackground;
|
||||||
|
//! Image ID for the sliding part of the slider.
|
||||||
ResourceID rSlider;
|
ResourceID rSlider;
|
||||||
float rMin,rMax,rPos;
|
//! Minimum position for slider.
|
||||||
|
float rMin;
|
||||||
|
//! Maximum position for slider.
|
||||||
|
float rMax;
|
||||||
|
//! Current position of slider.
|
||||||
|
float rPos;
|
||||||
|
//! Movement snap increment.
|
||||||
int rIncrement;
|
int rIncrement;
|
||||||
public:
|
|
||||||
GSlider();
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
\brief Simple constructor for 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,
|
virtual void Create(float x, float y, float width, float height, ResourceID backgroundImg, ResourceID sliderImg,
|
||||||
float min, float max, int increment);
|
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);
|
void SetPos(float pos);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Get position of slider.
|
||||||
|
|
||||||
|
Access current position of slider.
|
||||||
|
\return Slider position.
|
||||||
|
**/
|
||||||
float GetPos();
|
float GetPos();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief GHorizSlider, horizontal slider widget class.
|
||||||
|
|
||||||
|
Derived from GSlider, overloads message and show to complete the class.
|
||||||
|
**/
|
||||||
class GHorizSlider : public GSlider
|
class GHorizSlider : public GSlider
|
||||||
{
|
{
|
||||||
public:
|
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);
|
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();
|
virtual void Show();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief GHorizSlider, horizontal slider widget class
|
||||||
|
|
||||||
|
Derived from GSlider, overloads message and show to complete the class.
|
||||||
|
**/
|
||||||
class GVertSlider : public GSlider
|
class GVertSlider : public GSlider
|
||||||
{
|
{
|
||||||
public:
|
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);
|
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();
|
virtual void Show();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiStaticText.h
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Definition file for GStaticText.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Definition file for GStaticText, file to hold static text, labels and such.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiStaticText.h,v 1.5 2003/06/11 00:19:40 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -26,25 +26,87 @@
|
|||||||
namespace Gewi
|
namespace Gewi
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief GStaticText for stationary labels.
|
||||||
|
|
||||||
|
GStaticText, stationary label class, derived from GWidget.
|
||||||
|
**/
|
||||||
class GStaticText : public GWidget
|
class GStaticText : public GWidget
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
//! Image for background of label (often no image).
|
||||||
ResourceID rBackgroundImage;
|
ResourceID rBackgroundImage;
|
||||||
|
//! Font to use for label.
|
||||||
ResourceID rFont;
|
ResourceID rFont;
|
||||||
string rText;
|
//! Current text of label.
|
||||||
ZImage rTextBuf;
|
std::string rText;
|
||||||
int rXOff,rYOff;
|
//! 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.
|
||||||
GewiJustify rJustify;
|
GewiJustify rJustify;
|
||||||
public:
|
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);
|
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,
|
virtual void Create(float x, float y, float width, float height,
|
||||||
ResourceID font, ResourceID backgroundImg=GewiEngine::InvalidID, string text=" ", GewiJustify just=GJ_CENTER);
|
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.
|
||||||
|
**/
|
||||||
virtual void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
|
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();
|
virtual void Show();
|
||||||
|
|
||||||
void SetText(string text);
|
/*!
|
||||||
string GetText();
|
\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();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiTextButton.h
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Definition file for GTextButton.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Definition file for GTextButton, a GButton that has a text label.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiTextButton.h,v 1.5 2003/06/11 00:19:40 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -26,22 +26,73 @@
|
|||||||
namespace Gewi
|
namespace Gewi
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief GTextButton class for button with text label.
|
||||||
|
|
||||||
|
GTextButton text label button widget, derived from GButton.
|
||||||
|
**/
|
||||||
class GTextButton : public GButton
|
class GTextButton : public GButton
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
string rText;
|
//! Text label for button.
|
||||||
ZImage rTextBuf;
|
std::string rText;
|
||||||
int rXOff,rYOff;
|
//! Text Buffer, used internally.
|
||||||
|
ZE::ZImage rTextBuf;
|
||||||
|
//! X offset of text.
|
||||||
|
int rXOff;
|
||||||
|
//! Y offset of text.
|
||||||
|
int rYOff;
|
||||||
|
//! Font ID for text label.
|
||||||
ResourceID rFont;
|
ResourceID rFont;
|
||||||
|
|
||||||
public:
|
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);
|
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,
|
virtual void Create(float x, float y, float width, float height, ResourceID normalImg, ResourceID pressImg, ResourceID font,
|
||||||
string text=" ", GButtonType type=G_PRESS);
|
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.
|
||||||
|
**/
|
||||||
virtual void Show();
|
virtual void Show();
|
||||||
|
|
||||||
void SetText(string text);
|
/*!
|
||||||
string GetText();
|
\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();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiTextField.h
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Definition file for GTextField.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Definition file for GTextField, text input area widget.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiTextField.h,v 1.6 2003/06/11 00:19:40 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -26,26 +26,85 @@
|
|||||||
namespace Gewi
|
namespace Gewi
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief GTextField class for basic text input area.
|
||||||
|
|
||||||
|
GTextField simple text input area widget, derived from GWidget.
|
||||||
|
**/
|
||||||
class GTextField : public GWidget
|
class GTextField : public GWidget
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
string rText;
|
//! Text currently entered.
|
||||||
ZImage rBuffer;
|
std::string rText;
|
||||||
|
//! Text buffer, used internally.
|
||||||
|
ZE::ZImage rBuffer;
|
||||||
|
//! Font for text.
|
||||||
ResourceID rFont;
|
ResourceID rFont;
|
||||||
|
//! Background for text input area.
|
||||||
ResourceID rBackground;
|
ResourceID rBackground;
|
||||||
int rMaxChars,rLeftPadding;
|
//! Maximum number of characters allowed to be entered.
|
||||||
|
int rMaxChars;
|
||||||
|
//! Amount of padding on left hand side.
|
||||||
|
int rLeftPadding;
|
||||||
|
|
||||||
public:
|
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(GContainer *parent=NULL);
|
||||||
~GTextField();
|
|
||||||
|
|
||||||
void Kill();
|
/*!
|
||||||
|
\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 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);
|
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);
|
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();
|
virtual void Show();
|
||||||
|
|
||||||
void SetText(string text);
|
/*!
|
||||||
string GetText();
|
\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();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiWidget.h
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Definition file for GWidget.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Definition file for GWidget, virtual widget base class.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiWidget.h,v 1.6 2003/06/11 00:19:40 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -25,38 +25,141 @@
|
|||||||
namespace Gewi
|
namespace Gewi
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class GewiEngine;
|
class GewiEngine;
|
||||||
class GContainer;
|
class GContainer;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief GWidget base widget class.
|
||||||
|
|
||||||
|
Basic widget class, framework and base class for all other widgets.
|
||||||
|
**/
|
||||||
class GWidget
|
class GWidget
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
//! Pointer to GewiEngine instance.
|
||||||
GewiEngine *rGewi;
|
GewiEngine *rGewi;
|
||||||
ZEngine *rZE;
|
//! Pointer to ZEngine instance.
|
||||||
ZRect rBoundRect;
|
ZE::ZEngine *rZE;
|
||||||
|
//! Rectangle describing area of widget.
|
||||||
|
ZE::ZRect rBoundRect;
|
||||||
|
//! Pointer to parent container. (NULL means it lays in the global setting).
|
||||||
GContainer *rParent;
|
GContainer *rParent;
|
||||||
float rRelX,rRelY;
|
//! 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.
|
||||||
bool rVisible;
|
bool rVisible;
|
||||||
bool rAlive;
|
|
||||||
|
|
||||||
public:
|
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);
|
GWidget(GContainer *parent=NULL);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Simple destructor.
|
||||||
|
|
||||||
|
Must be virtual so that each derived class can free it's members.
|
||||||
|
**/
|
||||||
virtual ~GWidget();
|
virtual ~GWidget();
|
||||||
|
|
||||||
void FitParent();
|
/*!
|
||||||
|
\brief Toggle the visible flag.
|
||||||
|
|
||||||
|
Toggles the visible flag, only visible widgets are drawn.
|
||||||
|
**/
|
||||||
void ToggleVisible();
|
void ToggleVisible();
|
||||||
|
|
||||||
virtual void Kill();
|
/*!
|
||||||
|
\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 Create(float x, float y, float width, float height);
|
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);
|
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;
|
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;
|
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();
|
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();
|
float Y();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Get visible state of widget.
|
||||||
|
|
||||||
|
Returns status of internal visible flag.
|
||||||
|
\return true if visible, false otherwise.
|
||||||
|
**/
|
||||||
bool Visible();
|
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();
|
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);
|
bool Contains(Sint16 x, Sint16 y);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiWidgetList.h
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Definition file for WidgetList.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Definition file for WidgetList, a list of widgets used by GewiEngine and GContainers.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiWidgetList.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -27,32 +27,107 @@ namespace Gewi
|
|||||||
|
|
||||||
class GWidget;
|
class GWidget;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief WidgetNode class, node for linked list.
|
||||||
|
|
||||||
|
Doubly linked list node containing a widget.
|
||||||
|
**/
|
||||||
class WidgetNode
|
class WidgetNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/*!
|
||||||
|
\brief Basic constructor.
|
||||||
|
|
||||||
|
Simple safety constructor just sets all values to NULL.
|
||||||
|
**/
|
||||||
WidgetNode();
|
WidgetNode();
|
||||||
|
|
||||||
|
//! Pointer to widget for this node.
|
||||||
GWidget *widget;
|
GWidget *widget;
|
||||||
|
//! Pointer to previous node.
|
||||||
WidgetNode *prev;
|
WidgetNode *prev;
|
||||||
|
//! Pointer to next node.
|
||||||
WidgetNode *next;
|
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
|
class WidgetList
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
//! Pointer to head of list.
|
||||||
WidgetNode *mWidgetList;
|
WidgetNode *mWidgetList;
|
||||||
|
//! Variable keeping track of where the last click was, to change focus.
|
||||||
WidgetNode *mClick;
|
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);
|
void DeleteWidgetMem(WidgetNode *node);
|
||||||
public:
|
public:
|
||||||
|
/*!
|
||||||
|
\brief Constructor for the linked list.
|
||||||
|
|
||||||
|
Simply NULLs pointers for the linked list.
|
||||||
|
**/
|
||||||
WidgetList();
|
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);
|
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);
|
void DeleteWidget(GWidget *widget);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Delete all widgets.
|
||||||
|
|
||||||
|
Deletes all widgets and their memory.
|
||||||
|
**/
|
||||||
void DeleteWidgets();
|
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);
|
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();
|
void FitParent();
|
||||||
void ShowWidgets();
|
|
||||||
|
/*!
|
||||||
|
\brief Show widgets.
|
||||||
|
|
||||||
|
Calls Show method of widgets in reverse order for proper appearance.
|
||||||
|
**/
|
||||||
|
void ShowWidgets();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiWindow.h
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Definition file for GWindow.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Definition file for GWindow, a basic window class based on GContainer.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiWindow.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -26,17 +26,61 @@
|
|||||||
namespace Gewi
|
namespace Gewi
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief GWindow, a simple window class.
|
||||||
|
|
||||||
|
GWindow, basic window class, derived from GContainer.
|
||||||
|
**/
|
||||||
class GWindow : public GContainer
|
class GWindow : public GContainer
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
//! Holds internal state of if mouse is dragging the window or not.
|
||||||
bool rDrag;
|
bool rDrag;
|
||||||
float rDragX,rDragY;
|
//! 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.
|
||||||
ResourceID rBackground;
|
ResourceID rBackground;
|
||||||
public:
|
|
||||||
GWindow();
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
\brief Simple constructor for 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);
|
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);
|
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();
|
virtual void Show();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
48
licensing.txt
Executable file
48
licensing.txt
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
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
|
||||||
|
*******************************************************************************/
|
52
makefile
Executable file
52
makefile
Executable file
@ -0,0 +1,52 @@
|
|||||||
|
#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.
|
61
readme.txt
Executable file
61
readme.txt
Executable file
@ -0,0 +1,61 @@
|
|||||||
|
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
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiButton.cpp
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Implementation of GButton.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Implementation of GButton, a simple button class.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiButton.cpp,v 1.4 2003/08/10 01:40:56 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ namespace Gewi
|
|||||||
GButton::GButton(GContainer *parent) :
|
GButton::GButton(GContainer *parent) :
|
||||||
GWidget(parent),
|
GWidget(parent),
|
||||||
rPressed(false),
|
rPressed(false),
|
||||||
rType(G_PRESS),
|
rType(GBT_PRESS),
|
||||||
rNormalImage(GewiEngine::InvalidID),
|
rNormalImage(GewiEngine::InvalidID),
|
||||||
rPressedImage(GewiEngine::InvalidID)
|
rPressedImage(GewiEngine::InvalidID)
|
||||||
{
|
{
|
||||||
@ -50,28 +50,28 @@ void GButton::Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint1
|
|||||||
void GButton::Show()
|
void GButton::Show()
|
||||||
{
|
{
|
||||||
float x,y;
|
float x,y;
|
||||||
unsigned int w,h;
|
float w,h;
|
||||||
x = rBoundRect.X();
|
x = rBoundRect.X();
|
||||||
y = rBoundRect.Y();
|
y = rBoundRect.Y();
|
||||||
|
|
||||||
//images must be "resized" with each draw, disadvantage to shared resources
|
//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
|
//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
|
//if resize is to be rewritten the shared resources system of Gewi should be reconsidered
|
||||||
w = static_cast<unsigned int>(rBoundRect.Width());
|
w = rBoundRect.Width();
|
||||||
h = static_cast<unsigned int>(rBoundRect.Height());
|
h = rBoundRect.Height();
|
||||||
rGewi->Image(rPressedImage)->Resize(w,h);
|
rGewi->Image(rPressedImage)->Resize(w,h);
|
||||||
rGewi->Image(rNormalImage)->Resize(w,h);
|
rGewi->Image(rNormalImage)->Resize(w,h);
|
||||||
|
|
||||||
if(rVisible)
|
if(rVisible)
|
||||||
{
|
{
|
||||||
if(rType == G_PRESS) //G_PRESS: standard press button, down when pressed, up when not
|
if(rType == GBT_PRESS) //G_PRESS: standard press button, down when pressed, up when not
|
||||||
{
|
{
|
||||||
if(rPressed)
|
if(rPressed)
|
||||||
rGewi->Image(rPressedImage)->Draw(x,y);
|
rGewi->Image(rPressedImage)->Draw(x,y);
|
||||||
else
|
else
|
||||||
rGewi->Image(rNormalImage)->Draw(x,y);
|
rGewi->Image(rNormalImage)->Draw(x,y);
|
||||||
}
|
}
|
||||||
else if(rType == G_HOVER) //G_HOVER: button shows as down when hovered over
|
else if(rType == GBT_HOVER) //G_HOVER: button shows as down when hovered over
|
||||||
{
|
{
|
||||||
if(MouseInWidget())
|
if(MouseInWidget())
|
||||||
rGewi->Image(rPressedImage)->Draw(x,y);
|
rGewi->Image(rPressedImage)->Draw(x,y);
|
||||||
@ -86,9 +86,9 @@ bool GButton::IsPressed()
|
|||||||
return rPressed;
|
return rPressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GButton::SetState(bool state)
|
void GButton::SetState(bool pressed)
|
||||||
{
|
{
|
||||||
rPressed = state;
|
rPressed = pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiContainer.cpp
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Implementation of GContainer.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Implementation of GContainer, a barebones widget that can contain child widgets.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiContainer.cpp,v 1.6 2003/06/12 09:32:32 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -22,6 +22,8 @@
|
|||||||
namespace Gewi
|
namespace Gewi
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//all the work for GContainer is now done by WidgetList//
|
||||||
|
|
||||||
void GContainer::AddChild(GWidget *widget)
|
void GContainer::AddChild(GWidget *widget)
|
||||||
{
|
{
|
||||||
WidgetNode *node = new WidgetNode;
|
WidgetNode *node = new WidgetNode;
|
||||||
@ -43,6 +45,11 @@ GContainer::GContainer(GContainer *parent)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GContainer::~GContainer()
|
||||||
|
{
|
||||||
|
rChildList.DeleteWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
void GContainer::Move(float x, float y)
|
void GContainer::Move(float x, float y)
|
||||||
{
|
{
|
||||||
GWidget::Move(x,y);
|
GWidget::Move(x,y);
|
||||||
@ -51,7 +58,7 @@ void GContainer::Move(float x, float y)
|
|||||||
|
|
||||||
void GContainer::Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch)
|
void GContainer::Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch)
|
||||||
{
|
{
|
||||||
rChildList.Message(rawEvent,event,mouseX,mouseY,ch);
|
rChildList.Message(rawEvent,event,mouseX,mouseY,ch); //rChildList does the work of passing the event correctly
|
||||||
}
|
}
|
||||||
|
|
||||||
void GContainer::Show()
|
void GContainer::Show()
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiEngine.cpp
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Implementation of GewiEngine.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Implementation of GewiEngine, core engine for Gewi GUI control.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiEngine.cpp,v 1.9 2003/06/16 04:47:54 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -23,23 +23,30 @@
|
|||||||
namespace Gewi
|
namespace Gewi
|
||||||
{
|
{
|
||||||
|
|
||||||
|
VersionInfo GewiEngine::Version(0,2,0);
|
||||||
|
VersionInfo GewiEngine::MinZEVersion(0,8,4); //important to keep this accurate
|
||||||
GewiEngine *GewiEngine::sInstance=NULL;
|
GewiEngine *GewiEngine::sInstance=NULL;
|
||||||
SDL_EventFilter GewiEngine::sOldFilter=NULL;
|
|
||||||
|
|
||||||
GewiEngine::GewiEngine()
|
GewiEngine::GewiEngine()
|
||||||
{
|
{
|
||||||
sOldFilter = SDL_GetEventFilter(); //store event filter and set the new one
|
ZE::ZEngine *ze = ZE::ZEngine::GetInstance();
|
||||||
SDL_SetEventFilter((SDL_EventFilter)GewiEngine::EventFilter);
|
|
||||||
SDL_EnableUNICODE(1); //needed for the key translation
|
|
||||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//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);
|
||||||
|
SDL_EnableUNICODE(1); //needed for the key translation
|
||||||
|
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL); //more like typing, less like game
|
||||||
|
}
|
||||||
|
|
||||||
GewiEngine* GewiEngine::GetInstance()
|
GewiEngine* GewiEngine::GetInstance()
|
||||||
{
|
{
|
||||||
if(!sInstance)
|
if(!sInstance)
|
||||||
sInstance = new GewiEngine;
|
sInstance = new GewiEngine;
|
||||||
|
|
||||||
return sInstance;
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,16 +61,17 @@ void GewiEngine::ReleaseInstance()
|
|||||||
//set everything back to default
|
//set everything back to default
|
||||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_INTERVAL,SDL_DEFAULT_REPEAT_INTERVAL);
|
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_INTERVAL,SDL_DEFAULT_REPEAT_INTERVAL);
|
||||||
SDL_EnableUNICODE(0);
|
SDL_EnableUNICODE(0);
|
||||||
SDL_SetEventFilter(sOldFilter);
|
ZE::ZEngine::GetInstance()->SetEventFilter(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int GewiEngine::EventFilter(SDL_Event *event)
|
int GewiEngine::EventFilter(SDL_Event *event)
|
||||||
{
|
{
|
||||||
static char noChar = static_cast<char>(0);
|
static char noChar = '\0';
|
||||||
GewiEngine *gewi = GewiEngine::GetInstance();
|
GewiEngine *gewi = GewiEngine::GetInstance();
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
|
//called inside ZEngine::CheckEvents
|
||||||
switch(event->type)
|
switch(event->type)
|
||||||
{
|
{
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
@ -86,28 +94,19 @@ int GewiEngine::EventFilter(SDL_Event *event)
|
|||||||
ch = TranslateKey(event->key.keysym);
|
ch = TranslateKey(event->key.keysym);
|
||||||
gewi->SendMessage(event,GE_KUP,0,0,ch);
|
gewi->SendMessage(event,GE_KUP,0,0,ch);
|
||||||
break;
|
break;
|
||||||
case SDL_QUIT:
|
|
||||||
//.
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 1; //pass the event on
|
return 1; //pass the event on, allowing ZEngine to do what it needs
|
||||||
}
|
}
|
||||||
|
|
||||||
char GewiEngine::TranslateKey(SDL_keysym key)
|
char GewiEngine::TranslateKey(SDL_keysym key)
|
||||||
{
|
{
|
||||||
char ch;
|
//this is why unicode must be enabled, without this it'd be one massive switch statement
|
||||||
|
if(key.unicode > 0 && key.unicode <= 255)
|
||||||
if(key.unicode && key.unicode <= 255)
|
return static_cast<char>(key.unicode);
|
||||||
ch = static_cast<char>(key.unicode);
|
|
||||||
else
|
else
|
||||||
ch = static_cast<char>(127);
|
return static_cast<char>(127);
|
||||||
|
|
||||||
if(ch >= 'a' && ch <= 'z' && (key.mod & KMOD_SHIFT))
|
|
||||||
ch -= 20; //capitalize
|
|
||||||
|
|
||||||
return ch;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GewiEngine::Display()
|
void GewiEngine::Display()
|
||||||
@ -115,19 +114,19 @@ void GewiEngine::Display()
|
|||||||
mWidgetList.ShowWidgets();
|
mWidgetList.ShowWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceID GewiEngine::AddResource(ZImage *image)
|
ResourceID GewiEngine::AddResource(ZE::ZImage *image)
|
||||||
{
|
{
|
||||||
mImageVec.push_back(image);
|
mImageVec.push_back(image);
|
||||||
return static_cast<ResourceID>(mImageVec.size()-1);
|
return static_cast<ResourceID>(mImageVec.size()-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceID GewiEngine::AddResource(ZFont *font)
|
ResourceID GewiEngine::AddResource(ZE::ZFont *font)
|
||||||
{
|
{
|
||||||
mFontVec.push_back(font);
|
mFontVec.push_back(font);
|
||||||
return static_cast<ResourceID>(mFontVec.size()-1);
|
return static_cast<ResourceID>(mFontVec.size()-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZImage* GewiEngine::Image(ResourceID id)
|
ZE::ZImage* GewiEngine::Image(ResourceID id)
|
||||||
{
|
{
|
||||||
//do range checking
|
//do range checking
|
||||||
if(id >= 0 && id < mImageVec.size())
|
if(id >= 0 && id < mImageVec.size())
|
||||||
@ -136,7 +135,7 @@ ZImage* GewiEngine::Image(ResourceID id)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZFont* GewiEngine::Font(ResourceID id)
|
ZE::ZFont* GewiEngine::Font(ResourceID id)
|
||||||
{
|
{
|
||||||
//do range checking
|
//do range checking
|
||||||
if(id >= 0 && id < mFontVec.size())
|
if(id >= 0 && id < mFontVec.size())
|
||||||
@ -150,18 +149,12 @@ void GewiEngine::FreeResources()
|
|||||||
for(ResourceID i=0; i < mImageVec.size(); i++)
|
for(ResourceID i=0; i < mImageVec.size(); i++)
|
||||||
{
|
{
|
||||||
if(mImageVec[i])
|
if(mImageVec[i])
|
||||||
{
|
|
||||||
mImageVec[i]->Release();
|
mImageVec[i]->Release();
|
||||||
delete mImageVec[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for(ResourceID i=0; i < mFontVec.size(); i++)
|
for(ResourceID i=0; i < mFontVec.size(); i++)
|
||||||
{
|
{
|
||||||
if(mFontVec[i])
|
if(mFontVec[i])
|
||||||
{
|
|
||||||
mFontVec[i]->Release();
|
mFontVec[i]->Release();
|
||||||
delete mFontVec[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiSlider.cpp
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Implementation of GSlider, GHorizSlider and GVertSlider.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Implementation of GSlider, GHorizSlider and GVertSlider, the slide-select classes for Gewi.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiSlider.cpp,v 1.5 2003/06/12 09:32:33 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -22,8 +22,8 @@
|
|||||||
namespace Gewi
|
namespace Gewi
|
||||||
{
|
{
|
||||||
|
|
||||||
GSlider::GSlider() :
|
GSlider::GSlider(GContainer *parent) :
|
||||||
GWidget(),
|
GWidget(parent),
|
||||||
rPressed(false),
|
rPressed(false),
|
||||||
rBackground(GewiEngine::InvalidID),
|
rBackground(GewiEngine::InvalidID),
|
||||||
rSlider(GewiEngine::InvalidID),
|
rSlider(GewiEngine::InvalidID),
|
||||||
@ -58,9 +58,10 @@ void GSlider::SetPos(float pos)
|
|||||||
pos = static_cast<float>(rounded-rounded%rIncrement); //snap to a multiple of increment
|
pos = static_cast<float>(rounded-rounded%rIncrement); //snap to a multiple of increment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get within bounds
|
||||||
if(pos < rMin)
|
if(pos < rMin)
|
||||||
pos = rMin;
|
pos = rMin;
|
||||||
if(pos > rMax)
|
else if(pos > rMax)
|
||||||
pos = rMax;
|
pos = rMax;
|
||||||
rPos = pos;
|
rPos = pos;
|
||||||
}
|
}
|
||||||
@ -90,7 +91,7 @@ void GHorizSlider::Show()
|
|||||||
if(rPressed && !rZE->LButtonPressed() || !MouseInWidget()) //dont allow them to drag pointer out of box
|
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
|
Message(NULL,GE_LUP,rZE->MouseX(),rZE->MouseY(),static_cast<char>(0)); //fake a message
|
||||||
|
|
||||||
//the slider is centered about the current position
|
//the slider is centered about the current position, altered if currently sliding
|
||||||
if(rPressed)
|
if(rPressed)
|
||||||
xPos = rZE->MouseX()-rGewi->Image(rSlider)->Width()/2.0f;
|
xPos = rZE->MouseX()-rGewi->Image(rSlider)->Width()/2.0f;
|
||||||
else
|
else
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiStaticText.cpp
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Implementation of GStaticText.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Implementation of GStaticText, file to hold static text, labels and such.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiStaticText.cpp,v 1.7 2003/08/10 01:40:56 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -34,10 +34,9 @@ GStaticText::GStaticText(GContainer *parent) :
|
|||||||
|
|
||||||
|
|
||||||
void GStaticText::Create(float x, float y, float width, float height,
|
void GStaticText::Create(float x, float y, float width, float height,
|
||||||
ResourceID font, ResourceID backgroundImg, string text, GewiJustify justify)
|
ResourceID font, std::string text, GewiJustify justify, ResourceID backgroundImg)
|
||||||
{
|
{
|
||||||
GWidget::Create(x,y,width,height);
|
GWidget::Create(x,y,width,height);
|
||||||
|
|
||||||
rBackgroundImage = backgroundImg;
|
rBackgroundImage = backgroundImg;
|
||||||
rFont = font;
|
rFont = font;
|
||||||
rJustify = justify; //must justify pre-SetText
|
rJustify = justify; //must justify pre-SetText
|
||||||
@ -51,19 +50,19 @@ void GStaticText::Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, U
|
|||||||
|
|
||||||
void GStaticText::Show()
|
void GStaticText::Show()
|
||||||
{
|
{
|
||||||
//images must call Resize with each draw (shared resources)
|
//images must call Resize with each draw (see shared resources rant)
|
||||||
if(rBackgroundImage != GewiEngine::InvalidID)
|
|
||||||
rGewi->Image(rBackgroundImage)->Resize(static_cast<unsigned int>(rBoundRect.Width()),static_cast<unsigned int>(rBoundRect.Height()));
|
|
||||||
|
|
||||||
if(rBackgroundImage != GewiEngine::InvalidID)
|
if(rBackgroundImage != GewiEngine::InvalidID)
|
||||||
|
{
|
||||||
|
rGewi->Image(rBackgroundImage)->Resize(rBoundRect.Width(),rBoundRect.Height());
|
||||||
rGewi->Image(rBackgroundImage)->Draw(rBoundRect.X(),rBoundRect.Y());
|
rGewi->Image(rBackgroundImage)->Draw(rBoundRect.X(),rBoundRect.Y());
|
||||||
|
}
|
||||||
rTextBuf.Draw(rBoundRect.X()+rXOff,rBoundRect.Y()+rYOff); //draw text shifted by offset
|
rTextBuf.Draw(rBoundRect.X()+rXOff,rBoundRect.Y()+rYOff); //draw text shifted by offset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GStaticText::SetText(string text)
|
void GStaticText::SetText(std::string text)
|
||||||
{
|
{
|
||||||
int w,h;
|
float w,h;
|
||||||
|
|
||||||
rText = text;
|
rText = text;
|
||||||
rGewi->Font(rFont)->DrawText(rText,rTextBuf);
|
rGewi->Font(rFont)->DrawText(rText,rTextBuf);
|
||||||
@ -71,35 +70,24 @@ void GStaticText::SetText(string text)
|
|||||||
w=rTextBuf.Width();
|
w=rTextBuf.Width();
|
||||||
h=rTextBuf.Height();
|
h=rTextBuf.Height();
|
||||||
|
|
||||||
//center each by default
|
//left,right,center
|
||||||
rXOff = static_cast<int>(rBoundRect.Width()-w)/2;
|
|
||||||
rYOff = static_cast<int>(rBoundRect.Height()-h)/2;
|
|
||||||
|
|
||||||
if(rJustify & GJ_LEFT)
|
if(rJustify & GJ_LEFT)
|
||||||
{
|
|
||||||
printf("left");
|
|
||||||
rXOff = 0;
|
rXOff = 0;
|
||||||
}
|
|
||||||
else if(rJustify & GJ_RIGHT)
|
else if(rJustify & GJ_RIGHT)
|
||||||
{
|
|
||||||
printf("right");
|
|
||||||
rXOff = static_cast<int>(rBoundRect.Width()-w);
|
rXOff = static_cast<int>(rBoundRect.Width()-w);
|
||||||
}
|
else
|
||||||
|
rXOff = static_cast<int>(rBoundRect.Width()-w)/2;
|
||||||
|
|
||||||
|
//top,bottom,center
|
||||||
if(rJustify & GJ_TOP)
|
if(rJustify & GJ_TOP)
|
||||||
{
|
|
||||||
printf("top");
|
|
||||||
rYOff = 0;
|
rYOff = 0;
|
||||||
}
|
|
||||||
else if(rJustify & GJ_BOTTOM)
|
else if(rJustify & GJ_BOTTOM)
|
||||||
{
|
|
||||||
printf("bottom");
|
|
||||||
rYOff = static_cast<int>(rBoundRect.Height()-h);
|
rYOff = static_cast<int>(rBoundRect.Height()-h);
|
||||||
}
|
else
|
||||||
printf("\n");
|
rYOff = static_cast<int>(rBoundRect.Height()-h)/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
string GStaticText::GetText()
|
std::string GStaticText::GetText()
|
||||||
{
|
{
|
||||||
return rText;
|
return rText;
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiTextButton.cpp
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Implementation of GTextButton.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Implementation of GTextButton, a GButton that has a text label.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiTextButton.cpp,v 1.4 2003/06/11 00:19:29 cozman Exp $<br>
|
||||||
\author James Turk
|
\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,
|
void GTextButton::Create(float x, float y, float width, float height, ResourceID normalImg, ResourceID pressImg, ResourceID font,
|
||||||
string text, GButtonType type)
|
std::string text, GButtonType type)
|
||||||
{
|
{
|
||||||
GButton::Create(x,y,width,height,normalImg,pressImg,type);
|
GButton::Create(x,y,width,height,normalImg,pressImg,type);
|
||||||
rFont = font;
|
rFont = font;
|
||||||
@ -49,7 +49,7 @@ void GTextButton::Show()
|
|||||||
rTextBuf.Draw(rBoundRect.X()+rXOff,rBoundRect.Y()+rYOff); //draw text shifted by offset
|
rTextBuf.Draw(rBoundRect.X()+rXOff,rBoundRect.Y()+rYOff); //draw text shifted by offset
|
||||||
}
|
}
|
||||||
|
|
||||||
void GTextButton::SetText(string text)
|
void GTextButton::SetText(std::string text)
|
||||||
{
|
{
|
||||||
rText = text;
|
rText = text;
|
||||||
rGewi->Font(rFont)->DrawText(rText,rTextBuf);
|
rGewi->Font(rFont)->DrawText(rText,rTextBuf);
|
||||||
@ -58,7 +58,7 @@ void GTextButton::SetText(string text)
|
|||||||
rYOff = static_cast<int>(rBoundRect.Height()-rTextBuf.Height())/2;
|
rYOff = static_cast<int>(rBoundRect.Height()-rTextBuf.Height())/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
string GTextButton::GetText()
|
std::string GTextButton::GetText()
|
||||||
{
|
{
|
||||||
return rText;
|
return rText;
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiTextField.cpp
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Implementation of GTextField.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Implementation of GTextField, text input area widget.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiTextField.cpp,v 1.7 2003/08/10 01:40:56 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -30,16 +30,6 @@ GTextField::GTextField(GContainer *parent) :
|
|||||||
rLeftPadding(0)
|
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)
|
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);
|
GWidget::Create(x,y,width,height);
|
||||||
@ -59,25 +49,25 @@ void GTextField::Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Ui
|
|||||||
else if(ch == '\b')
|
else if(ch == '\b')
|
||||||
rText = rText.length() ? rText.substr(0,rText.length()-1) : ""; //go back one character
|
rText = rText.length() ? rText.substr(0,rText.length()-1) : ""; //go back one character
|
||||||
|
|
||||||
rGewi->Font(rFont)->DrawText(rText.length() ? rText : " ",rBuffer);
|
rGewi->Font(rFont)->DrawText(rText.length() ? rText : "",rBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GTextField::Show()
|
void GTextField::Show()
|
||||||
{
|
{
|
||||||
rGewi->Image(rBackground)->Resize(static_cast<unsigned int>(rBoundRect.Width()),static_cast<unsigned int>(rBoundRect.Height()));
|
rGewi->Image(rBackground)->Resize(rBoundRect.Width(),rBoundRect.Height());
|
||||||
rGewi->Image(rBackground)->Draw(rBoundRect.X(),rBoundRect.Y());
|
rGewi->Image(rBackground)->Draw(rBoundRect.X(),rBoundRect.Y());
|
||||||
if(rBuffer.IsLoaded()) //don't draw empty buffer image
|
if(rBuffer.IsLoaded()) //don't draw empty buffer image
|
||||||
rBuffer.Draw(rLeftPadding+rBoundRect.X(),rBoundRect.Y()+(rBoundRect.Height()-rBuffer.Height())/2);
|
rBuffer.Draw(rLeftPadding+rBoundRect.X(),rBoundRect.Y()+(rBoundRect.Height()-rBuffer.Height())/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GTextField::SetText(string text)
|
void GTextField::SetText(std::string text)
|
||||||
{
|
{
|
||||||
rText = text;
|
rText = text;
|
||||||
rGewi->Font(rFont)->DrawText(rText,rBuffer);
|
rGewi->Font(rFont)->DrawText(rText,rBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
string GTextField::GetText()
|
std::string GTextField::GetText()
|
||||||
{
|
{
|
||||||
return rText;
|
return rText;
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiWidget.cpp
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Implementation of GWidget.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Implementation of GWidget, virtual widget base class.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiWidget.cpp,v 1.7 2003/06/12 09:32:33 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -34,13 +34,13 @@ void GWidget::FitParent() //adjust to relative pos + parent pos
|
|||||||
|
|
||||||
GWidget::GWidget(GContainer *parent) :
|
GWidget::GWidget(GContainer *parent) :
|
||||||
rGewi(GewiEngine::GetInstance()),
|
rGewi(GewiEngine::GetInstance()),
|
||||||
rZE(ZEngine::GetInstance()),
|
rZE(ZE::ZEngine::GetInstance()),
|
||||||
rParent(parent),
|
rParent(parent),
|
||||||
rRelX(0),
|
rRelX(0),
|
||||||
rRelY(0),
|
rRelY(0),
|
||||||
rVisible(true),
|
rVisible(true)
|
||||||
rAlive(true)
|
|
||||||
{
|
{
|
||||||
|
//widgets take care of all registration, making the parent processes virtually hidden
|
||||||
if(rParent)
|
if(rParent)
|
||||||
rParent->AddChild(this);
|
rParent->AddChild(this);
|
||||||
else
|
else
|
||||||
@ -56,20 +56,6 @@ void GWidget::ToggleVisible()
|
|||||||
rVisible = !rVisible;
|
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)
|
void GWidget::Create(float x, float y, float width, float height)
|
||||||
{
|
{
|
||||||
Move(x,y);
|
Move(x,y);
|
||||||
@ -99,6 +85,7 @@ bool GWidget::Visible()
|
|||||||
return rVisible;
|
return rVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//it is important to remember rBoundRect is the actual position
|
||||||
bool GWidget::MouseInWidget()
|
bool GWidget::MouseInWidget()
|
||||||
{
|
{
|
||||||
return rZE->MouseInRect(&rBoundRect.SDLrect());
|
return rZE->MouseInRect(&rBoundRect.SDLrect());
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiWidgetList.cpp
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Implementation of WidgetList.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Implementation of WidgetList, a list of widgets used by GewiEngine and GContainers.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiWidgetList.cpp,v 1.5 2003/06/12 09:32:33 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -30,6 +30,8 @@ WidgetNode::WidgetNode() :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//WidgetList keeps circular list of nodes, backwards traversal is key for proper draw order//
|
||||||
|
|
||||||
void WidgetList::DeleteWidgetMem(WidgetNode *node)
|
void WidgetList::DeleteWidgetMem(WidgetNode *node)
|
||||||
{
|
{
|
||||||
if(node == mWidgetList) //special case if deleting top node
|
if(node == mWidgetList) //special case if deleting top node
|
||||||
@ -39,7 +41,7 @@ void WidgetList::DeleteWidgetMem(WidgetNode *node)
|
|||||||
else
|
else
|
||||||
mWidgetList = NULL;
|
mWidgetList = NULL;
|
||||||
}
|
}
|
||||||
//adjust links and actually delete node
|
//adjust links & delete node
|
||||||
node->prev->next = node->next;
|
node->prev->next = node->next;
|
||||||
node->next->prev = node->prev;
|
node->next->prev = node->prev;
|
||||||
delete node;
|
delete node;
|
||||||
@ -55,11 +57,11 @@ void WidgetList::AddWidget(WidgetNode *node)
|
|||||||
{
|
{
|
||||||
if(mWidgetList == NULL)
|
if(mWidgetList == NULL)
|
||||||
{
|
{
|
||||||
node->next = node->prev = node;
|
node->next = node->prev = node; //first node points to self in both directions
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//make connections
|
//make front & back connections
|
||||||
node->next = mWidgetList;
|
node->next = mWidgetList;
|
||||||
node->prev = mWidgetList->prev;
|
node->prev = mWidgetList->prev;
|
||||||
mWidgetList->prev->next = node;
|
mWidgetList->prev->next = node;
|
||||||
@ -80,7 +82,7 @@ void WidgetList::DeleteWidget(GWidget *widget)
|
|||||||
if(cur->widget == widget)
|
if(cur->widget == widget)
|
||||||
found = cur;
|
found = cur;
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
} while(cur != mWidgetList && !found);
|
} while(cur != mWidgetList && !found); //go through & find node
|
||||||
|
|
||||||
if(found)
|
if(found)
|
||||||
DeleteWidgetMem(found);
|
DeleteWidgetMem(found);
|
||||||
@ -90,10 +92,10 @@ void WidgetList::DeleteWidget(GWidget *widget)
|
|||||||
void WidgetList::DeleteWidgets()
|
void WidgetList::DeleteWidgets()
|
||||||
{
|
{
|
||||||
WidgetNode *cur = mWidgetList;
|
WidgetNode *cur = mWidgetList;
|
||||||
while(mWidgetList)
|
while(mWidgetList) //will be set to null on last widget
|
||||||
{
|
{
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
cur->prev->widget->Kill();
|
DeleteWidgetMem(cur->prev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,12 +167,15 @@ void WidgetList::FitParent()
|
|||||||
void WidgetList::ShowWidgets()
|
void WidgetList::ShowWidgets()
|
||||||
{
|
{
|
||||||
WidgetNode *cur = mWidgetList;
|
WidgetNode *cur = mWidgetList;
|
||||||
do
|
if(mWidgetList)
|
||||||
{
|
{
|
||||||
cur = cur->prev; //draw from back to front, through list in reverse
|
do
|
||||||
if(cur->widget->Visible())
|
{
|
||||||
cur->widget->Show();
|
cur = cur->prev; //draw from back to front, through list in reverse
|
||||||
}while(cur != mWidgetList);
|
if(cur->widget->Visible()) //visible checked here so each Show() doesn't need to bother
|
||||||
|
cur->widget->Show();
|
||||||
|
}while(cur != mWidgetList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file ZE_ZConfigFile.h
|
\file GewiWindow.cpp
|
||||||
\brief Definition file for ZConfigFile.
|
\brief Implementation of GWindow.
|
||||||
|
|
||||||
Definition file for ZConfigFile, an INI-style config file format.
|
Implementation of GWindow, a basic window class based on GContainer.
|
||||||
<br>$ id: ZE_ZConfigFile.h,v 1.9 2003/02/10 04:40:16 cozman Exp $<br>
|
<br>$Id: GewiWindow.cpp,v 1.5 2003/08/10 01:40:56 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -22,8 +22,8 @@
|
|||||||
namespace Gewi
|
namespace Gewi
|
||||||
{
|
{
|
||||||
|
|
||||||
GWindow::GWindow() :
|
GWindow::GWindow(GContainer *parent) :
|
||||||
GContainer(),
|
GContainer(parent),
|
||||||
rDrag(false),
|
rDrag(false),
|
||||||
rDragX(0),
|
rDragX(0),
|
||||||
rDragY(0),
|
rDragY(0),
|
||||||
@ -67,7 +67,7 @@ void GWindow::Show()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//resize (shared resources) and draw
|
//resize (shared resources) and draw
|
||||||
rGewi->Image(rBackground)->Resize(static_cast<unsigned int>(rBoundRect.Width()),static_cast<unsigned int>(rBoundRect.Height()));
|
rGewi->Image(rBackground)->Resize(rBoundRect.Width(),rBoundRect.Height());
|
||||||
rGewi->Image(rBackground)->Draw(rBoundRect.X(),rBoundRect.Y());
|
rGewi->Image(rBackground)->Draw(rBoundRect.X(),rBoundRect.Y());
|
||||||
|
|
||||||
GContainer::Show(); //important that a window draws it's children
|
GContainer::Show(); //important that a window draws it's children
|
||||||
|
BIN
test/bin/data/axaxax.ttf
Executable file
BIN
test/bin/data/axaxax.ttf
Executable file
Binary file not shown.
1
test/bin/data/thanks.txt
Executable file
1
test/bin/data/thanks.txt
Executable file
@ -0,0 +1 @@
|
|||||||
|
The free fonts in this directory came from http://larabiefonts.com.
|
@ -7,92 +7,83 @@
|
|||||||
The maintainer of this library is James Turk (james@conceptofzero.net)
|
The maintainer of this library is James Turk (james@conceptofzero.net)
|
||||||
this library is found at the home of ZEngine http://zengine.sourceforge.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 "ZEngine.h"
|
||||||
#include "GewiEngine.h"
|
#include "Gewi.h"
|
||||||
#include "GButton.h"
|
#include <string>
|
||||||
#include "GTextButton.h"
|
|
||||||
#include "GWindow.h"
|
|
||||||
#include "GTextField.h"
|
|
||||||
#include "GSlider.h"
|
|
||||||
#include "GStaticText.h"
|
|
||||||
using namespace ZE;
|
using namespace ZE;
|
||||||
|
using namespace Gewi;
|
||||||
|
|
||||||
void Init()
|
bool Initialize()
|
||||||
{
|
{
|
||||||
ZEngine *ze = ZEngine::GetInstance();
|
ZEngine *engine = ZEngine::GetInstance();
|
||||||
|
ZConfigFile cfg("tests.zcf");
|
||||||
ZConfigFile cfg("gewiTest.zcf");
|
int w,h,bpp,rate;
|
||||||
int w,h,bpp;
|
bool fs;
|
||||||
bool fs;
|
std::string title;
|
||||||
string title;
|
|
||||||
|
w = cfg.GetInt("ZTimerTest","width",800);
|
||||||
w = cfg.GetInt("screen","width",800);
|
h = cfg.GetInt("ZTimerTest","height",600);
|
||||||
h = cfg.GetInt("screen","height",600);
|
bpp = cfg.GetInt("ZTimerTest","bpp",32);
|
||||||
bpp = cfg.GetInt("screen","bpp",32);
|
fs = cfg.GetBool("ZTimerTest","fullscreen",false);
|
||||||
fs = cfg.GetBool("screen","fullscreen",false);
|
title = cfg.GetString("ZTimerTest","title","Gewi Test");
|
||||||
title = cfg.GetString("screen","title","Gewi Test");
|
rate = cfg.GetInt("ZTimerTest","framerate",60);
|
||||||
|
|
||||||
ze->SetupDisplay(w,h,bpp,fs);
|
engine->SetupDisplay(w,h,bpp,fs);
|
||||||
ze->CreateDisplay(title);
|
engine->SetDesiredFramerate(rate);
|
||||||
|
return engine->CreateDisplay(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test1()
|
void Test()
|
||||||
{
|
{
|
||||||
ZEngine *ze = ZEngine::GetInstance();
|
ZEngine *ze = ZEngine::GetInstance();
|
||||||
Gewi *gewi = Gewi::GetInstance();
|
GewiEngine *gewi = GewiEngine::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 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;
|
||||||
|
|
||||||
|
bg.Open("data/rainbow.bmp");
|
||||||
|
bg.Resize(static_cast<float>(ze->DisplayWidth()),static_cast<float>(ze->DisplayHeight()));
|
||||||
|
|
||||||
ZImage *temp,*temp2,*temp3,*temp4,*temp5,*temp6,*temp7,*temp8;
|
//opening the images//
|
||||||
ZFont *font;
|
temp[0].Open("data/b1.bmp");
|
||||||
temp = new ZImage("b1.bmp");
|
temp[1].Open("data/b2.bmp");
|
||||||
temp2 = new ZImage("b2.bmp");
|
temp[2].Open("data/skin1.bmp");
|
||||||
temp3 = new ZImage("skin1.bmp");
|
temp[3].Open("data/text.bmp");
|
||||||
temp4 = new ZImage("text.bmp");
|
temp[4].Open("data/bg3.bmp");
|
||||||
temp5 = new ZImage("bg3.bmp");
|
temp[5].Open("data/slider.bmp");
|
||||||
temp6 = new ZImage("slider.bmp");
|
temp[6].Open("data/bg4.bmp");
|
||||||
temp7 = new ZImage("bg4.bmp");
|
temp[7].Open("data/slider2.bmp");
|
||||||
temp8 = new ZImage("slider2.bmp");
|
font.Open("data/axaxax.ttf",20);
|
||||||
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);
|
//registering the resources//
|
||||||
b1.Create(50,30,10,10,id1,id2);
|
for(int i=0; i < 8; ++i)
|
||||||
t1.Create(100,100,500,50,id4,id5,20,20);
|
{
|
||||||
t2.Create(50,200,200,50,id4,id5,20,20);
|
temp[i].SetColorKey(255,0,255);
|
||||||
tb1.Create(400,200,300,50,id1,id2,id4,"restore window");
|
id[i] = gewi->AddResource(&temp[i]);
|
||||||
s1.Create(100,500,200,50,id6,id7,0,3,1);
|
}
|
||||||
s2.Create(700,200,50,200,id8,id9,0,200,5);
|
fontID = gewi->AddResource(&font);
|
||||||
hb1.Create(70,40,100,100,id1,id2,G_HOVER);
|
|
||||||
st1.Create(100,100,100,100,id4,Gewi::InvalidID,"static",GJ_CENTER);
|
//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);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -100,48 +91,33 @@ void Test1()
|
|||||||
|
|
||||||
if(ze->IsActive())
|
if(ze->IsActive())
|
||||||
{
|
{
|
||||||
if(ze->KeyIsPressed(SDLK_ESCAPE))
|
if(ze->KeyIsPressed(SDLK_ESCAPE) || hoverButton.IsPressed())
|
||||||
ze->RequestQuit();
|
ze->RequestQuit();
|
||||||
|
|
||||||
font->DrawText(FormatStr("%f",s1.GetPos()),buf);
|
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));
|
||||||
|
|
||||||
bg.Draw(0,0);
|
bg.Draw(0,0);
|
||||||
temp3->SetAlpha(63+s1.GetPos()*64);
|
gewi->Display(); //draws everything
|
||||||
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();
|
ze->Update();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} while(!ze->QuitRequested());
|
} while(!ze->QuitRequested());
|
||||||
|
|
||||||
Gewi::ReleaseInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// _crtBreakAlloc=163;
|
if(Initialize())
|
||||||
Init();
|
Test();
|
||||||
|
|
||||||
Test1();
|
GewiEngine::ReleaseInstance();
|
||||||
|
|
||||||
ZEngine::ReleaseInstance();
|
ZEngine::ReleaseInstance();
|
||||||
_CrtDumpMemoryLeaks();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
6
todo.txt
Executable file
6
todo.txt
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
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 +0,0 @@
|
|||||||
make source files conform
|
|
@ -17,6 +17,7 @@ Global
|
|||||||
{F5974221-8DB8-4BC1-B944-EE62F44A9114}.Release.Build.0 = Release|Win32
|
{F5974221-8DB8-4BC1-B944-EE62F44A9114}.Release.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
DPBuild = 5
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
@ -88,12 +88,18 @@
|
|||||||
<Filter
|
<Filter
|
||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
Filter="h;hpp;hxx;hm;inl;inc">
|
Filter="h;hpp;hxx;hm;inl;inc">
|
||||||
|
<File
|
||||||
|
RelativePath="..\include\Gewi.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\include\GewiButton.h">
|
RelativePath="..\include\GewiButton.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\include\GewiContainer.h">
|
RelativePath="..\include\GewiContainer.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\include\GewiDefines.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\include\GewiEngine.h">
|
RelativePath="..\include\GewiEngine.h">
|
||||||
</File>
|
</File>
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
Optimization="2"
|
Optimization="2"
|
||||||
InlineFunctionExpansion="1"
|
InlineFunctionExpansion="1"
|
||||||
OmitFramePointers="TRUE"
|
OmitFramePointers="TRUE"
|
||||||
|
AdditionalIncludeDirectories="../include"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||||
StringPooling="TRUE"
|
StringPooling="TRUE"
|
||||||
RuntimeLibrary="2"
|
RuntimeLibrary="2"
|
||||||
@ -37,13 +38,13 @@
|
|||||||
SDLmain.lib
|
SDLmain.lib
|
||||||
OpenGL32.lib
|
OpenGL32.lib
|
||||||
SDL_mixer.lib
|
SDL_mixer.lib
|
||||||
SDL_net.lib
|
|
||||||
SDL_image.lib
|
SDL_image.lib
|
||||||
SDL_ttf.lib
|
SDL_ttf.lib
|
||||||
ZEngineS.lib
|
ZEngineS.lib
|
||||||
c:\home\src\gewi\Release\gewi.lib"
|
gewi.lib"
|
||||||
OutputFile="$(OutDir)/gewitest.exe"
|
OutputFile="../test/bin/GewiTest00.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../lib"
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="TRUE"
|
||||||
SubSystem="2"
|
SubSystem="2"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
@ -69,6 +70,9 @@ c:\home\src\gewi\Release\gewi.lib"
|
|||||||
<Filter
|
<Filter
|
||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
|
||||||
|
<File
|
||||||
|
RelativePath="..\test\gewiTest00.cpp">
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
|
Loading…
Reference in New Issue
Block a user