0.2.0 prep

This commit is contained in:
cozman 2003-06-07 05:41:18 +00:00
parent 53ac6d7d9c
commit ba6cc67b62
17 changed files with 819 additions and 82 deletions

View File

@ -13,7 +13,7 @@
\brief Definition file for GButton.
Definition file for GButton, a simple button class.
<br>$Id: GewiButton.h,v 1.3 2003/05/19 23:56:05 cozman Exp $<br>
<br>$Id: GewiButton.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br>
\author James Turk
**/
@ -26,22 +26,91 @@
namespace Gewi
{
/*!
\brief Enumeration for the button types.
Definitions of the two possible button types.
**/
enum GButtonType
{
GBT_PRESS, /*!< Simple button with standard behavior. */
GBT_HOVER /*!< Button which shows itself clicked when hovered over. */
};
/*!
\brief GButton class for basic buttons.
GButton simple button widget, derived from GWidget.
**/
class GButton : public GWidget
{
protected:
//! Boolean holding if button is currently pressed or not.
bool rPressed;
//! Enum for type of button.
GButtonType rType;
//! Resource ID for the non-pressed image.
ResourceID rNormalImage;
//! Resource ID for the pressed (or hover) image.
ResourceID rPressedImage;
public:
/*!
\brief Simple constructor for GButton.
Constructor for GButton, can take a parent.
\param parent Pointer to GContainer derived class to be the parent. Default value is NULL which means no parent.
**/
GButton(GContainer *parent=NULL);
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);
/*!
\brief Draws this button to the screen.
Draws widget to the screen, required overload for all widgets.
**/
virtual void Show();
/*!
\brief Returns button state.
Returns true if buttons is pressed, false otherwise. (GBT_HOVER can only be pressed once, after that they stay down.)
\return button pressed state
**/
bool IsPressed();
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);
};
}

View File

@ -13,7 +13,7 @@
\brief Definition file for GContainer.
Definition file for GContainer, a barebones widget that can contain child widgets.
<br>$Id: GewiContainer.h,v 1.4 2003/05/21 02:47:56 cozman Exp $<br>
<br>$Id: GewiContainer.h,v 1.5 2003/06/07 05:41:18 cozman Exp $<br>
\author James Turk
**/
@ -27,24 +27,91 @@
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
{
//friend here is used simply to allow GWidget proper access to what used to belong to it before
//the class split GWidget needs access to Add/ReleaseChild but to make them public would _reduce_
//encapsulation (for those keeping score, this is to many people the only effective use of friend)
/*!
The usage of friend here is used simply to allow GWidget proper access to what used to belong to
it before the class split GWidget needs access to Add/ReleaseChild but to make them public would
<strong>reduce</strong> encapsulation. (For those keeping score, this is to many people the only effective use of
friend.)
**/
friend GWidget;
protected:
//! List of child widgets assigned to this container.
WidgetList rChildList;
/*!
\brief Adds a child to the child list.
Registers the widget as a child of this container, private because GWidget is a friend.
\param widget Widget to register as a child of this container.
**/
void AddChild(GWidget *widget);
/*!
\brief Removes a child from the child list.
Releases the widget which is a child of this container, private because GWidget is a friend.
\param widget Widget to release from this container.
**/
void ReleaseChild(GWidget *widget);
/*!
\brief Inserts a child to the child list.
Calls needed function of WidgetList class to put widget into the linked list.
\param node WidgetNode to insert into rChildList.
**/
void InsertWidget(WidgetNode *node);
public:
/*!
\brief Simple constructor for GContainer.
Constructor for GContainer, can take a parent (to be contained on a GContainer derived class, allowing nested containers).
\param parent Pointer to GContainer derived class to be the parent. Default value is NULL which means no parent.
**/
GContainer(GContainer *parent=NULL);
/*!
\brief Destroy container and children.
Deletes container and releases children, overloaded to free children.
**/
virtual void Kill();
/*!
\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();
};

View File

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

View File

@ -13,7 +13,7 @@
\brief Include file for Gewi.
Include file for Gewi, contains external includes for Gewi.
<br>$Id: GewiIncludes.h,v 1.3 2003/05/19 23:56:05 cozman Exp $<br>
<br>$id: GewiIncludes.h,v 1.3 2003/05/19 23:56:05 cozman Exp $<br>
\author James Turk
**/
@ -22,14 +22,10 @@
#include <vector>
#include <cmath>
#include <limits>
#include <climits>
#include "ZEngine.h"
typedef unsigned int WidgetID;
typedef unsigned int ResourceID;
enum GewiEvent { GE_LDOWN, GE_LUP, GE_RDOWN, GE_RUP, GE_KDOWN, GE_KUP, GE_GOTFOCUS, GE_LOSTFOCUS };
enum _GewiJustify { GJ_CENTER = 0, GJ_LEFT = 1<<0, GJ_RIGHT = 1<<1, GJ_TOP = 1<<2, GJ_BOTTOM = 1<<3 };
enum GButtonType { G_PRESS, G_HOVER };
typedef unsigned int GewiJustify;
#include "GewiDefines.h"
using namespace std;
using namespace ZE;

View File

@ -13,7 +13,7 @@
\brief Definition file for GSlider, GHorizSlider and GVertSlider.
Definition file for GSlider, GHorizSlider and GVertSlider, the slide-select classes for Gewi.
<br>$Id: GewiSlider.h,v 1.3 2003/05/19 23:56:05 cozman Exp $<br>
<br>$Id: GewiSlider.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br>
\author James Turk
**/
@ -26,35 +26,125 @@
namespace Gewi
{
/*!
\brief GSlider (virtual) slider widget class.
Framework for simple slider widget, virtual (fails to overload Show), derived from GWidget.
**/
class GSlider : public GWidget
{
protected:
//! Boolean value holding if slider is currently 'pressed' or active.
bool rPressed;
//! ID for background image for slider.
ResourceID rBackground;
//! Image ID for the sliding part of the slider.
ResourceID rSlider;
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;
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,
float min, float max, int increment);
/*!
\brief Set position of slider.
Sets position of slider, will snap within bounds.
\param pos Desired position.
**/
void SetPos(float pos);
/*!
\brief Get position of slider.
Access current position of slider.
\return Slider position.
**/
float GetPos();
};
/*!
\brief GHorizSlider, horizontal slider widget class.
Derived from GSlider, overloads message and show to complete the class.
**/
class GHorizSlider : public GSlider
{
public:
/*!
\brief Overload of Message, used to recieve messages.
Recieves and processes a message, required overload for all widgets.
\param rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
\param event GewiEvent enum, description of event recieved.
\param mouseX Mouse x position in event, if not mouse event may be incorrect.
\param mouseY Mouse y position in event, if not mouse event may be incorrect.
\param ch Character pressed in event, may be 0 if not a keypress event.
**/
virtual void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
/*!
\brief Draws this slider to the screen.
Draws widget to the screen, required overload for all widgets.
**/
virtual void Show();
};
/*!
\brief GHorizSlider, horizontal slider widget class
Derived from GSlider, overloads message and show to complete the class.
**/
class GVertSlider : public GSlider
{
public:
/*!
\brief Overload of Message, used to recieve messages.
Recieves and processes a message, required overload for all widgets.
\param rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
\param event GewiEvent enum, description of event recieved.
\param mouseX Mouse x position in event, if not mouse event may be incorrect.
\param mouseY Mouse y position in event, if not mouse event may be incorrect.
\param ch Character pressed in event, may be 0 if not a keypress event.
**/
virtual void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
/*!
\brief Draws this slider to the screen.
Draws widget to the screen, required overload for all widgets.
**/
virtual void Show();
};

View File

@ -13,7 +13,7 @@
\brief Definition file for GStaticText.
Definition file for GStaticText, file to hold static text, labels and such.
<br>$Id: GewiStaticText.h,v 1.3 2003/05/19 23:56:05 cozman Exp $<br>
<br>$Id: GewiStaticText.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br>
\author James Turk
**/
@ -26,24 +26,86 @@
namespace Gewi
{
/*!
\brief GStaticText for stationary labels.
GStaticText, stationary label class, derived from GWidget.
**/
class GStaticText : public GWidget
{
protected:
//! Image for background of label (often no image).
ResourceID rBackgroundImage;
//! Font to use for label.
ResourceID rFont;
//! Current text of label.
string rText;
//! Text buffer ZImage, used internally.
ZImage rTextBuf;
int rXOff,rYOff;
//! 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;
public:
/*!
\brief Simple constructor for GStaticText.
Constructor for GStaticText, can take a parent.
\param parent Pointer to GContainer derived class to be the parent. Default value is NULL which means no parent.
**/
GStaticText(GContainer *parent=NULL);
/*!
\brief GButton's create function, must be called to set up actual button.
Every widget has a create function which must be called to define the button's appearance and settings.
\param x X position of widget within it's container (entire screen if no parent)
\param y Y position of widget within it's container (entire screen if no parent)
\param width Width of widget.
\param height Height of widget.
\param font Font ID for text.
\param text Text for static label. (Defaults to a blank space.)
\param just Justification, see documented _GewiJustify for details. Defaults to GJ_CENTER.
\param backgroundImg Image for background, defaults to GewiEngine::InvalidID.
**/
virtual void Create(float x, float y, float width, float height,
ResourceID font, ResourceID backgroundImg=GewiEngine::InvalidID, string text=" ", GewiJustify just=GJ_CENTER);
ResourceID font, 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);
/*!
\brief Draws static label to the screen.
Draws static label to the screen, required overload for all widgets.
**/
virtual void Show();
/*!
\brief Set text of label.
Sets the current text of the label.
\param text New text for label.
**/
void SetText(string text);
/*!
\brief Get current text in label.
Return text in label.
\return text currently in label.
**/
string GetText();
};

View File

@ -13,7 +13,7 @@
\brief Definition file for GTextButton.
Definition file for GTextButton, a GButton that has a text label.
<br>$Id: GewiTextButton.h,v 1.3 2003/05/19 23:56:05 cozman Exp $<br>
<br>$Id: GewiTextButton.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br>
\author James Turk
**/
@ -26,21 +26,72 @@
namespace Gewi
{
/*!
\brief GTextButton class for button with text label.
GTextButton text label button widget, derived from GButton.
**/
class GTextButton : public GButton
{
protected:
//! Text label for button.
string rText;
//! Text Buffer, used internally.
ZImage rTextBuf;
int rXOff,rYOff;
//! X offset of text.
int rXOff;
//! Y offset of text.
int rYOff;
//! Font ID for text label.
ResourceID rFont;
public:
/*!
\brief Simple constructor for GButton.
Constructor for GButton, can take a parent.
\param parent Pointer to GContainer derived class to be the parent. Default value is NULL which means no parent.
**/
GTextButton(GContainer *parent=NULL);
/*!
\brief GButton's create function, must be called to set up actual button.
Every widget has a create function which must be called to define the button's appearance and settings.
\param x X position of widget within it's container (entire screen if no parent)
\param y Y position of widget within it's container (entire screen if no parent)
\param width Width of widget.
\param height Height of widget.
\param normalImg Image for button when not pressed.
\param pressImg Image for button when pressed (or hovered if type is GBT_HOVER).
\param font Font to draw label with.
\param text Text for button. (default is blank)
\param type GButtonType, either the default, GBT_PRESS (normal button), or GBT_HOVER (a button which responds to the hovering mouse).
**/
virtual void Create(float x, float y, float width, float height, ResourceID normalImg, ResourceID pressImg, ResourceID font,
string text=" ", GButtonType type=G_PRESS);
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();
/*!
\brief Set text of button.
Sets the current text of the button.
\param text New text for button.
**/
void SetText(string text);
/*!
\brief Get current text of button label.
Return text on button label.
\return text currently on button label.
**/
string GetText();
};

View File

@ -13,7 +13,7 @@
\brief Definition file for GTextField.
Definition file for GTextField, text input area widget.
<br>$Id: GewiTextField.h,v 1.4 2003/05/21 02:47:56 cozman Exp $<br>
<br>$Id: GewiTextField.h,v 1.5 2003/06/07 05:41:18 cozman Exp $<br>
\author James Turk
**/
@ -26,24 +26,84 @@
namespace Gewi
{
/*!
\brief GTextField class for basic text input area.
GTextField simple text input area widget, derived from GWidget.
**/
class GTextField : public GWidget
{
protected:
//! Text currently entered.
string rText;
//! Text buffer, used internally.
ZImage rBuffer;
//! Font for text.
ResourceID rFont;
//! Background for text input area.
ResourceID rBackground;
int rMaxChars,rLeftPadding;
public:
GTextField(GContainer *parent=NULL);
~GTextField();
//! Maximum number of characters allowed to be entered.
int rMaxChars;
//! Amount of padding on left hand side.
int rLeftPadding;
virtual void Kill();
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);
/*!
\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);
/*!
\brief Overload of Message, used to recieve messages.
Recieves and processes a message, required overload for all widgets.
\param rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
\param event GewiEvent enum, description of event recieved.
\param mouseX Mouse x position in event, if not mouse event may be incorrect.
\param mouseY Mouse y position in event, if not mouse event may be incorrect.
\param ch Character pressed in event, may be 0 if not a keypress event.
**/
virtual void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
/*!
\brief Draws the text input area & text to the screen.
Draws widget to the screen, required overload for all widgets.
**/
virtual void Show();
/*!
\brief Set text in input area.
Sets the current text of the buffer for input area.
\param text New text for button.
**/
void SetText(string text);
/*!
\brief Get current text of the input box.
Return text in the input buffer.
\return text currently in input buffer.
**/
string GetText();
};

View File

@ -13,7 +13,7 @@
\brief Definition file for GWidget.
Definition file for GWidget, virtual widget base class.
<br>$Id: GewiWidget.h,v 1.3 2003/05/19 23:56:05 cozman Exp $<br>
<br>$Id: GewiWidget.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br>
\author James Turk
**/
@ -25,38 +25,151 @@
namespace Gewi
{
class GewiEngine;
class GContainer;
/*!
\brief GWidget base widget class.
Basic widget class, framework and base class for all other widgets.
**/
class GWidget
{
protected:
//! Pointer to GewiEngine instance.
GewiEngine *rGewi;
//! Pointer to ZEngine instance.
ZEngine *rZE;
//! Rectangle describing area of widget.
ZRect rBoundRect;
//! Pointer to parent container. (NULL means it lays in the global setting).
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;
//! Stores if widget is currently 'alive.'
bool rAlive;
public:
/*!
\brief Simple constructor for GWidget.
Constructor for GWidget, like all widgets this must initialize private data and can take a parent.
\param parent Pointer to GContainer derived class to be the parent. Default value is NULL which means no parent.
**/
GWidget(GContainer *parent=NULL);
/*!
\brief Simple destructor.
Must be virtual so that each derived class can free it's members.
**/
virtual ~GWidget();
void FitParent();
/*!
\brief Toggle the visible flag.
Toggles the visible flag, only visible widgets are drawn.
**/
void ToggleVisible();
/*!
\brief Kill widget, and all data associated with it.
Widget frees itself from parent, and sets it's internal state to dead.
Virtual in case other things need to be freed.
**/
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);
/*!
\brief Change relative position.
Set new relative position for widget.
\param x New relative x position.
\param y New relative y position.
**/
virtual void Move(float x, float y);
/*!
\brief Important function used to recieve messages.
Recieves and processes a message, required overload for all widgets.
\param rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
\param event GewiEvent enum, description of event recieved.
\param mouseX Mouse x position in event, if not mouse event may be incorrect.
\param mouseY Mouse y position in event, if not mouse event may be incorrect.
\param ch Character pressed in event, may be 0 if not a keypress event.
**/
virtual void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch)=0;
/*!
\brief Draws this button to the screen.
Draws widget to the screen, required overload for all widgets.
**/
virtual void Show()=0;
/*!
\brief Get X position of widget.
Get actual (not relative) X position of top left corner of widget.
\return Actual x position of widget.
**/
float X();
/*!
\brief Get Y position of widget.
Get actual (not relative) Y position of top left corner of widget.
\return Actual y position of widget.
**/
float Y();
/*!
\brief Get visible state of widget.
Returns status of internal visible flag.
\return true if visible, false otherwise.
**/
bool Visible();
/*!
\brief Check if mouse is in widget.
Returns status of mouse inside widget.
\return true if mouse pointer inside widget, false otherwise.
**/
bool MouseInWidget();
/*!
\brief Check if the widget contains a point.
Check if the widget contains the point specified.
\param x X value of point to check.
\param y Y value of point to check.
**/
bool Contains(Sint16 x, Sint16 y);
};

View File

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

View File

@ -13,7 +13,7 @@
\brief Definition file for GWindow.
Definition file for GWindow, a basic window class based on GContainer.
<br>$Id: GewiWindow.h,v 1.3 2003/05/19 23:56:05 cozman Exp $<br>
<br>$Id: GewiWindow.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br>
\author James Turk
**/
@ -26,17 +26,61 @@
namespace Gewi
{
/*!
\brief GWindow, a simple window class.
GWindow, basic window class, derived from GContainer.
**/
class GWindow : public GContainer
{
protected:
//! Holds internal state of if mouse is dragging the window or not.
bool rDrag;
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;
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);
/*!
\brief Overload of Message, used to recieve messages.
Recieves and processes a message, required overload for all widgets.
\param rawEvent SDL_Event of original message, may be needed if more information is available on event. (May be NULL).
\param event GewiEvent enum, description of event recieved.
\param mouseX Mouse x position in event, if not mouse event may be incorrect.
\param mouseY Mouse y position in event, if not mouse event may be incorrect.
\param ch Character pressed in event, may be 0 if not a keypress event.
**/
virtual void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
/*!
\brief Draws window & children to the screen.
Draws window & children to the screen, required overload for all widgets.
**/
virtual void Show();
};

View File

@ -13,7 +13,7 @@
\brief Implementation of GButton.
Implementation of GButton, a simple button class.
<br>$Id: GewiButton.cpp,v 1.2 2003/05/20 00:06:10 cozman Exp $<br>
<br>$Id: GewiButton.cpp,v 1.3 2003/06/07 05:42:32 cozman Exp $<br>
\author James Turk
**/
@ -25,7 +25,7 @@ namespace Gewi
GButton::GButton(GContainer *parent) :
GWidget(parent),
rPressed(false),
rType(G_PRESS),
rType(GBT_PRESS),
rNormalImage(GewiEngine::InvalidID),
rPressedImage(GewiEngine::InvalidID)
{
@ -64,14 +64,14 @@ void GButton::Show()
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)
rGewi->Image(rPressedImage)->Draw(x,y);
else
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())
rGewi->Image(rPressedImage)->Draw(x,y);
@ -86,9 +86,9 @@ bool GButton::IsPressed()
return rPressed;
}
void GButton::SetState(bool state)
void GButton::SetState(bool pressed)
{
rPressed = state;
rPressed = pressed;
}
}

View File

@ -13,7 +13,7 @@
\brief Implementation of GewiEngine.
Implementation of GewiEngine, core engine for Gewi GUI control.
<br>$Id: GewiEngine.cpp,v 1.3 2003/05/20 00:08:55 cozman Exp $<br>
<br>$Id: GewiEngine.cpp,v 1.4 2003/06/07 05:42:33 cozman Exp $<br>
\author James Turk
**/
@ -150,18 +150,12 @@ void GewiEngine::FreeResources()
for(ResourceID i=0; i < mImageVec.size(); i++)
{
if(mImageVec[i])
{
mImageVec[i]->Release();
delete mImageVec[i];
}
}
for(ResourceID i=0; i < mFontVec.size(); i++)
{
if(mFontVec[i])
{
mFontVec[i]->Release();
delete mFontVec[i];
}
}
}

View File

@ -13,7 +13,7 @@
\brief Implementation of GSlider, GHorizSlider and GVertSlider.
Implementation of GSlider, GHorizSlider and GVertSlider, the slide-select classes for Gewi.
<br>$Id: GewiSlider.cpp,v 1.3 2003/05/20 00:08:55 cozman Exp $<br>
<br>$Id: GewiSlider.cpp,v 1.4 2003/06/07 05:42:33 cozman Exp $<br>
\author James Turk
**/
@ -22,8 +22,8 @@
namespace Gewi
{
GSlider::GSlider() :
GWidget(),
GSlider::GSlider(GContainer *parent) :
GWidget(parent),
rPressed(false),
rBackground(GewiEngine::InvalidID),
rSlider(GewiEngine::InvalidID),

View File

@ -13,7 +13,7 @@
\brief Implementation of GStaticText.
Implementation of GStaticText, file to hold static text, labels and such.
<br>$Id: GewiStaticText.cpp,v 1.3 2003/05/20 00:08:55 cozman Exp $<br>
<br>$Id: GewiStaticText.cpp,v 1.4 2003/06/07 05:42:33 cozman Exp $<br>
\author James Turk
**/
@ -34,7 +34,7 @@ GStaticText::GStaticText(GContainer *parent) :
void GStaticText::Create(float x, float y, float width, float height,
ResourceID font, ResourceID backgroundImg, string text, GewiJustify justify)
ResourceID font, string text, GewiJustify justify, ResourceID backgroundImg)
{
GWidget::Create(x,y,width,height);
@ -77,26 +77,21 @@ void GStaticText::SetText(string text)
if(rJustify & GJ_LEFT)
{
printf("left");
rXOff = 0;
}
else if(rJustify & GJ_RIGHT)
{
printf("right");
rXOff = static_cast<int>(rBoundRect.Width()-w);
}
if(rJustify & GJ_TOP)
{
printf("top");
rYOff = 0;
}
else if(rJustify & GJ_BOTTOM)
{
printf("bottom");
rYOff = static_cast<int>(rBoundRect.Height()-h);
}
printf("\n");
}
string GStaticText::GetText()

View File

@ -13,7 +13,7 @@
\brief Implementation of GTextField.
Implementation of GTextField, text input area widget.
<br>$Id: GewiTextField.cpp,v 1.3 2003/05/20 00:08:55 cozman Exp $<br>
<br>$Id: GewiTextField.cpp,v 1.4 2003/06/07 05:42:33 cozman Exp $<br>
\author James Turk
**/
@ -30,16 +30,6 @@ GTextField::GTextField(GContainer *parent) :
rLeftPadding(0)
{}
GTextField::~GTextField()
{
}
void GTextField::Kill()
{
rBuffer.Release();
GWidget::Kill();
}
void GTextField::Create(float x, float y, float width, float height, ResourceID font, ResourceID backgroundImg, int maxChars, int leftPad)
{
GWidget::Create(x,y,width,height);

View File

@ -13,7 +13,7 @@
\brief Implementation of GWindow.
Implementation of GWindow, a basic window class based on GContainer.
<br>$Id: GewiWindow.cpp,v 1.3 2003/05/20 00:08:55 cozman Exp $<br>
<br>$Id: GewiWindow.cpp,v 1.4 2003/06/07 05:42:33 cozman Exp $<br>
\author James Turk
**/
@ -22,8 +22,8 @@
namespace Gewi
{
GWindow::GWindow() :
GContainer(),
GWindow::GWindow(GContainer *parent) :
GContainer(parent),
rDrag(false),
rDragX(0),
rDragY(0),