zengine-gewi/include/GewiWidgetList.h

136 lines
4.0 KiB
C
Raw 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 GewiWidgetList.h
\brief Definition file for WidgetList.
2003-05-19 22:58:01 +00:00
2003-05-19 23:53:53 +00:00
Definition file for WidgetList, a list of widgets used by GewiEngine and GContainers.
2003-06-07 05:41:18 +00:00
<br>$Id: GewiWidgetList.h,v 1.4 2003/06/07 05:41:18 cozman Exp $<br>
2003-05-19 22:58:01 +00:00
\author James Turk
**/
#ifndef __gewiwidgetlist_h__
#define __gewiwidgetlist_h__
#include "GewiIncludes.h"
namespace Gewi
{
class GWidget;
2003-06-07 05:41:18 +00:00
/*!
\brief WidgetNode class, node for linked list.
Doubly linked list node containing a widget.
**/
2003-05-19 22:58:01 +00:00
class WidgetNode
{
public:
2003-06-07 05:41:18 +00:00
/*!
\brief Basic constructor.
Simple safety constructor just sets all values to NULL.
**/
2003-05-19 22:58:01 +00:00
WidgetNode();
2003-06-07 05:41:18 +00:00
//! Pointer to widget for this node.
2003-05-19 22:58:01 +00:00
GWidget *widget;
2003-06-07 05:41:18 +00:00
//! Pointer to previous node.
2003-05-19 22:58:01 +00:00
WidgetNode *prev;
2003-06-07 05:41:18 +00:00
//! Pointer to next node.
2003-05-19 22:58:01 +00:00
WidgetNode *next;
};
2003-06-07 05:41:18 +00:00
/*!
\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.
**/
2003-05-19 22:58:01 +00:00
class WidgetList
{
private:
2003-06-07 05:41:18 +00:00
//! Pointer to head of list.
2003-05-19 22:58:01 +00:00
WidgetNode *mWidgetList;
2003-06-07 05:41:18 +00:00
//! Variable keeping track of where the last click was, to change focus.
2003-05-19 22:58:01 +00:00
WidgetNode *mClick;
2003-06-07 05:41:18 +00:00
/*!
\brief Internal function to delete widget memory.
Deletes the memory used by a widget node, interally used.
\param node Node to delete.
**/
2003-05-19 22:58:01 +00:00
void DeleteWidgetMem(WidgetNode *node);
public:
2003-06-07 05:41:18 +00:00
/*!
\brief Constructor for the linked list.
Simply NULLs pointers for the linked list.
**/
2003-05-19 22:58:01 +00:00
WidgetList();
2003-06-07 05:41:18 +00:00
/*!
\brief Add a WidgetNode to the list.
Adds a WidgetNode to the list, in the 'front'.
\param node Node to add to list.
**/
2003-05-19 22:58:01 +00:00
void AddWidget(WidgetNode *node);
2003-06-07 05:41:18 +00:00
/*!
\brief Delete a widget.
Deletes a widget, it's memory and frees it from it's container or GewiEngine.
\param widget Widget to delete.
**/
2003-05-19 22:58:01 +00:00
void DeleteWidget(GWidget *widget);
2003-06-07 05:41:18 +00:00
/*!
\brief Delete all widgets.
Deletes all widgets and their memory.
**/
2003-05-19 22:58:01 +00:00
void DeleteWidgets();
2003-06-07 05:41:18 +00:00
/*!
\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.
**/
2003-05-19 22:58:01 +00:00
void Message(SDL_Event *rawEvent, GewiEvent event, Uint16 mouseX, Uint16 mouseY, char ch);
2003-06-07 05:41:18 +00:00
/*!
\brief Fit all widgets to the parent.
Fits widgets to parent of which this linked list is a part of.
**/
2003-05-19 22:58:01 +00:00
void FitParent();
2003-06-07 05:41:18 +00:00
/*!
\brief Show widgets.
Calls Show method of widgets in reverse order for proper appearance.
**/
void ShowWidgets();
2003-05-19 22:58:01 +00:00
};
}
#endif //__gewiwidgetlist_h__