zengine-gewi/include/GewiContainer.h

116 lines
4.2 KiB
C
Raw Permalink Normal View History

2003-05-19 22:58:01 +00:00
/*******************************************************************************
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
*******************************************************************************/
/*!
2003-05-19 23:53:53 +00:00
\file GewiContainer.h
\brief Definition file for GContainer.
2003-05-19 22:58:01 +00:00
2003-05-19 23:53:53 +00:00
Definition file for GContainer, a barebones widget that can contain child widgets.
2003-07-20 03:21:21 +00:00
<br>$Id: GewiContainer.h,v 1.7 2003/07/20 03:21:21 cozman Exp $<br>
2003-05-19 22:58:01 +00:00
\author James Turk
**/
#ifndef __gewicontainer_h__
#define __gewicontainer_h__
#include "GewiIncludes.h"
#include "GewiWidgetList.h"
#include "GewiWidget.h"
namespace Gewi
{
2003-06-07 05:41:18 +00:00
/*!
\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.
**/
2003-05-19 22:58:01 +00:00
class GContainer : public GWidget
{
2003-06-07 05:41:18 +00:00
/*!
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.)
**/
2003-07-20 03:21:21 +00:00
friend class Gewi::GWidget;
2003-05-19 22:58:01 +00:00
protected:
2003-06-07 05:41:18 +00:00
//! List of child widgets assigned to this container.
2003-05-19 22:58:01 +00:00
WidgetList rChildList;
2003-06-07 05:41:18 +00:00
/*!
\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.
**/
2003-05-19 22:58:01 +00:00
void AddChild(GWidget *widget);
2003-06-07 05:41:18 +00:00
/*!
\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.
**/
2003-05-19 22:58:01 +00:00
void ReleaseChild(GWidget *widget);
2003-06-07 05:41:18 +00:00
/*!
\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.
**/
2003-05-19 22:58:01 +00:00
void InsertWidget(WidgetNode *node);
2003-06-07 05:41:18 +00:00
2003-05-19 22:58:01 +00:00
public:
2003-06-07 05:41:18 +00:00
/*!
\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.
**/
2003-05-19 22:58:01 +00:00
GContainer(GContainer *parent=NULL);
2003-05-21 02:47:56 +00:00
2003-06-09 03:28:43 +00:00
~GContainer();
2003-06-07 05:41:18 +00:00
/*!
\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.
**/
2003-05-21 02:47:56 +00:00
virtual void Move(float x, float y);
2003-06-07 05:41:18 +00:00
/*!
\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.
**/
2003-05-21 02:47:56 +00:00
virtual void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
2003-06-07 05:41:18 +00:00
/*!
\brief Show children.
Draws all children in appropriate back-to-front order.
**/
2003-05-21 02:47:56 +00:00
virtual void Show();
2003-05-19 22:58:01 +00:00
};
}
#endif //__gewicontainer_h__