2009-04-18 19:00:33 +02:00
|
|
|
/* Copyright (C) 2009 Wildfire Games.
|
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2003-11-24 03:18:41 +01:00
|
|
|
/*
|
2003-12-27 07:26:03 +01:00
|
|
|
GUI Object Base - Button Behavior
|
2003-11-24 03:18:41 +01:00
|
|
|
|
|
|
|
--Overview--
|
|
|
|
|
|
|
|
Interface class that enhance the IGUIObject with
|
|
|
|
buttony behavior (click and release to click a button),
|
|
|
|
and the GUI message GUIM_PRESSED.
|
|
|
|
When creating a class with extended settings and
|
|
|
|
buttony behavior, just do a multiple inheritance.
|
|
|
|
|
|
|
|
--More info--
|
|
|
|
|
|
|
|
Check GUI.h
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2007-05-07 18:33:24 +02:00
|
|
|
#ifndef INCLUDED_IGUIBUTTONBEHAVIOR
|
|
|
|
#define INCLUDED_IGUIBUTTONBEHAVIOR
|
2003-11-24 03:18:41 +01:00
|
|
|
|
|
|
|
//--------------------------------------------------------
|
|
|
|
// Includes / Compiler directives
|
|
|
|
//--------------------------------------------------------
|
|
|
|
#include "GUI.h"
|
|
|
|
|
2004-12-15 22:24:46 +01:00
|
|
|
class CGUISpriteInstance;
|
|
|
|
|
2003-11-24 03:18:41 +01:00
|
|
|
//--------------------------------------------------------
|
|
|
|
// Macros
|
|
|
|
//--------------------------------------------------------
|
|
|
|
|
|
|
|
//--------------------------------------------------------
|
|
|
|
// Types
|
|
|
|
//--------------------------------------------------------
|
|
|
|
|
|
|
|
//--------------------------------------------------------
|
|
|
|
// Declarations
|
|
|
|
//--------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends button behaviours to the IGUIObject.
|
|
|
|
* Can be used with multiple inheritance alongside
|
|
|
|
* IGUISettingsObject and such.
|
|
|
|
*
|
|
|
|
* @see IGUIObject
|
|
|
|
*/
|
|
|
|
class IGUIButtonBehavior : virtual public IGUIObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
IGUIButtonBehavior();
|
|
|
|
virtual ~IGUIButtonBehavior();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see IGUIObject#HandleMessage()
|
|
|
|
*/
|
2003-12-27 07:26:03 +01:00
|
|
|
virtual void HandleMessage(const SGUIMessage &Message);
|
2003-11-24 03:18:41 +01:00
|
|
|
|
2004-05-29 06:06:50 +02:00
|
|
|
/**
|
|
|
|
* This is a function that lets a button being drawn,
|
|
|
|
* it regards if it's over, disabled, pressed and such.
|
|
|
|
* You input sprite names and area and it'll output
|
|
|
|
* it accordingly.
|
|
|
|
*
|
|
|
|
* This class is meant to be used manually in Draw()
|
|
|
|
*
|
|
|
|
* @param rect Rectangle in which the sprite should be drawn
|
|
|
|
* @param z Z-value
|
|
|
|
* @param sprite Sprite drawn when not pressed, hovered or disabled
|
|
|
|
* @param sprite_over Sprite drawn when m_MouseHovering is true
|
|
|
|
* @param sprite_pressed Sprite drawn when m_Pressed is true
|
|
|
|
* @param sprite_disabled Sprite drawn when "enabled" is false
|
2004-12-18 14:32:00 +01:00
|
|
|
* @param cell_id Identifies the icon to be used (if the sprite contains
|
|
|
|
* cell-using images)
|
2004-05-29 06:06:50 +02:00
|
|
|
*/
|
|
|
|
void DrawButton(const CRect &rect,
|
|
|
|
const float &z,
|
2004-12-15 22:24:46 +01:00
|
|
|
CGUISpriteInstance& sprite,
|
|
|
|
CGUISpriteInstance& sprite_over,
|
|
|
|
CGUISpriteInstance& sprite_pressed,
|
2004-12-17 17:20:08 +01:00
|
|
|
CGUISpriteInstance& sprite_disabled,
|
2004-12-18 14:32:00 +01:00
|
|
|
int cell_id);
|
2004-05-29 06:06:50 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Choosing which color of the following according to
|
|
|
|
*/
|
2006-09-30 17:46:40 +02:00
|
|
|
CColor ChooseColor();
|
2004-05-29 06:06:50 +02:00
|
|
|
|
|
|
|
|
2003-11-24 03:18:41 +01:00
|
|
|
protected:
|
2003-11-25 03:47:12 +01:00
|
|
|
virtual void ResetStates()
|
|
|
|
{
|
|
|
|
m_MouseHovering = false;
|
|
|
|
m_Pressed = false;
|
|
|
|
}
|
|
|
|
|
2003-11-24 03:18:41 +01:00
|
|
|
/**
|
|
|
|
* Everybody knows how a button works, you don't simply press it,
|
|
|
|
* you have to first press the button, and then release it...
|
|
|
|
* in between those two steps you can actually leave the button
|
|
|
|
* area, as long as you release it within the button area... Anyway
|
|
|
|
* this lets us know we are done with step one (clicking).
|
|
|
|
*/
|
|
|
|
bool m_Pressed;
|
|
|
|
};
|
|
|
|
|
2003-11-24 18:13:37 +01:00
|
|
|
#endif
|