#ifndef TOPLEVEL_H
#define TOPLEVEL_H

#include <kapplication.h>
#include <kmainwindow.h>

class PlayCanvas;
class Playground;
class KPopupMenu;

#if (((KDE_VERSION_MAJOR == 3) && ((KDE_VERSION_MINOR == 1) && (KDE_VERSION_RELEASE > 90)) || (KDE_VERSION_MINOR > 1)) || (KDE_VERSION_MAJOR > 3))
#define HAVE_SPEEDBAR
class KFileDialog;
#endif

class TopLevel : public KMainWindow
{
	Q_OBJECT
	public:
		TopLevel();
		~TopLevel();

		void setTheme(QString theme);

	public slots:
		void key(int keycode);
		void slotMenu(int id);

#ifdef HAVE_SPEEDBAR
		void slotOpenLevel();
		void slotSaveLevel();
#endif

	protected:
		void keyPressEvent(QKeyEvent *e);
		void mousePressEvent(QMouseEvent *e);

	private:
		void scale(int difference);
		void newlevel(QString file);

		void createlevel();
		void savelevel(QString fn);
		void sharelevel();

		void setupDialog(bool savemode, bool usermode);
		void setupMenus(bool save_enabled, bool share_enabled);

		enum MenuItems
		{
			file_new,
			file_open,
			file_save,
			file_share,
			file_exit,

			display_larger,
			display_smaller,
			display_fullscreen,

			element_ground,
			element_wall,
			element_bridge,
			element_space,
			element_scree,
			element_bomb,
			element_live,
			element_power,
			element_grail,
			element_speed,
			element_invisible,
			element_flash,

			file_menu,
			element_menu,
			display_menu,
			help_menu
		};

		PlayCanvas *canvas;
		Playground *playground;
		KPopupMenu *filemenu, *displaymenu, *elementmenu;
		bool m_isfullscreen;
		QRect m_geometry;
		int m_tilesize;

		int m_element;
		QString m_currentlevel;
		bool m_levelmodified;
		bool m_delayedsharing;

#ifdef HAVE_SPEEDBAR
		KFileDialog *dialog;
#endif
};

#endif

