/*  $Id: display_window_generic.h,v 1.36 2004/03/10 22:30:13 mbn Exp $
**
**  ClanLib Game SDK
**  Copyright (C) 2003  The ClanLib Team
**  For a total list of contributers see the file CREDITS.
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**
**  This library 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
**  Lesser General Public License for more details.
**
**  You should have received a copy of the GNU Lesser General Public
**  License along with this library; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*/

#ifndef header_display_window_generic
#define header_display_window_generic

#if _MSC_VER > 1000
#pragma once
#endif

#include "API/Display/display_window.h"
#include "API/Display/sprite.h"

class CL_DisplayWindowDescription;
class CL_DisplayMode;

class CL_DisplayWindow_Generic
{
//! Construction:
public:
	CL_DisplayWindow_Generic();

	virtual ~CL_DisplayWindow_Generic();

//! Attributes:
public:
	virtual int get_width() const=0;

	virtual int get_height() const=0;

	virtual bool is_fullscreen() const=0;

	virtual bool has_focus() const=0;

	virtual CL_PixelBuffer &get_buffer(int i)=0;

	virtual const CL_PixelBuffer &get_buffer(int i) const=0;

	virtual int get_buffer_count() const=0;

	virtual CL_GraphicContext *get_gc()=0;

	virtual CL_InputContext *get_ic()=0;

	//: CL_Display's 'current window' reference.
	static CL_DisplayWindow *current;

//! Operations:
public:
	void add_ref();

	void release_ref();

	virtual void create_window(const CL_DisplayWindowDescription &desc)=0;

	virtual void set_fullscreen(int width, int height, int bpp, int refresh_rate)=0;

	virtual void set_windowed()=0;

	virtual void set_title(const std::string &title)=0;

	virtual void set_position(const CL_Rect &pos)=0;

	virtual void set_position(int x, int y)=0;

	virtual void set_size(int width, int height)=0;

	virtual void set_buffer_count(int flipping_buffers)=0;

	virtual void update(const CL_Rect &rect)=0;

	virtual void flip(int interval)=0;

	virtual void show_system_cursor()=0;

	virtual void hide_system_cursor()=0;

	void do_flip(int interval);

	void set_cursor(const CL_Sprite &sprite);

	void show_cursor();

	void hide_cursor();

//! Signals:
public:
	CL_Signal_v2<int, int> sig_resize;

	CL_Signal_v1<const CL_Rect &> sig_paint;

	CL_Signal_v0 sig_lost_focus;

	CL_Signal_v0 sig_got_focus;

	CL_Signal_v0 sig_window_close;

//! Implementation:
private:
	virtual void cursor_changed() { return; }

	CL_Sprite cursor;

	bool cursor_visible;

	int ref_count;
};

#endif
