// ---------------------------------------------------------------------------
// 
//   Lily Engine alpha
// 
//   Copyright (c) 2010 Clifford Jolly
//     http://cliffjolly.com
//     cliff@cliffjolly.com
// 
// ---------------------------------------------------------------------------
// 
//   This program 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.
//  
//   This program 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 this program; if not, write to the Free Software
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
//   USA
// -------------------------- END HEADER -------------------------------------

#ifndef WIDGETBUTTON_H
#define WIDGETBUTTON_H

#include "widget.h"

class WidgetText;

/// Basic button class. Responds to buttons the way one would expect
/// for normal mouse usage. Can show different graphics for default,
/// when the mouse button is held down while over it, and when the
/// mouse is simply hovering over it.
///
/// Unique events:
///
///   onClick
///
LUA_WRAP class WidgetButton : public Widget {
	public:
	
		/// Set the text on the button label, if the label object is
		/// still a WidgetText.
		LUA_WRAP void setLabel(const std::string &text);

		/// Get the text on the button label.
		LUA_WRAP std::string getLabel(void);
		
		/// Replace the label Widget with something else, possibly not
		/// text.
		LUA_WRAP void replaceLabelWidget(Widget *newLabel);

		// TODO: setLabelWidget?
		
		/// Set some space for padding the label, affecting calculated
		/// minimum width and height. Defaults to 16 pixels.
		LUA_WRAP void setLabelPadding(float padding);
		
		/// Get padding.
		LUA_WRAP float getLabelPadding(void);

		/// Set the default background image. (Mouse not over or any 
		/// button pressed.)
		LUA_WRAP void setBackgroundDefault(const std::string &fileName);
		
		/// Set the active background image. (Mouse button or key/joy
		/// activation button pressed and held on this widget.)
		LUA_WRAP void setBackgroundActive(const std::string &fileName);
		
		/// Set the background to show when the mouse is over the
		/// Widget or it has focus.
		LUA_WRAP void setBackgroundMouseOver(const std::string &fileName);
		
		/// Get default background.
		LUA_WRAP std::string getBackgroundDefault(void);
		
		/// Get active background.
		LUA_WRAP std::string getBackgroundActive(void);
		
		/// Get mouseover background.
		LUA_WRAP std::string getBackgroundMouseOver(void);

		/// Set toggleable (checkbox behavior).
		LUA_WRAP void setToggleable(bool toggleable);
		
		/// Get toggleable.
		LUA_WRAP bool getToggleable(void);
		
		/// Set toggled value (checkbox checked).
		LUA_WRAP void setToggleValue(bool toggleValue);
		
		/// Get toggled value.
		LUA_WRAP bool getToggleValue(void);

		/// Turn this into a radio button or not.
		LUA_WRAP void setIsRadio(bool isRadio);
		
		/// Get whether this is a radio button or not.
		LUA_WRAP bool getIsRadio(void);

		/// Set label alignment (-1 = left, 0 = center, 1 = right).
		LUA_WRAP void setLabelHAlign(int align);

		// Inherited stuff.
		void draw(void);
		bool handleEvent(const WidgetEvent *event);
		float getMinWidth(void);
		float getMinHeight(void);
		bool isSizeDirty(void);
		
		// Constructors/destructor.
		WidgetButton(void);
		// TODO: XML Constructor.
		virtual ~WidgetButton(void);
	
	protected:
	
		int labelHAlign;
		bool toggleable;
		bool toggleValue;
		bool isRadio;
	
		std::string backgroundDefault;
		std::string backgroundActive;
		std::string backgroundMouseOver;
		float padding;
		
		Widget *label;
};


#endif
