////////////////////////////////////////////////////////////////////////////////
// GLContextMenu.h
// Copyright Björn Ganster
// Developed since 2005
////////////////////////////////////////////////////////////////////////////////

#ifndef GLContextMenu__H
#define GLContextMenu__H

#include "GLWindow.h"
#include "BGCPString.h"
#include "BGBase.h"

#include <vector>

class Texture;

////////////////////////////////////////////////////////////////////////////////
// Class for storing context menu entries

struct GLContextMenuEntry: public VirtualClass {
	GLContextMenuEntry()
	: VirtualClass("GLContextMenuEntry", GLContextMenuEntryID),
	  listener(nullptr),
	  ID(0)
	{
	}

	BGCPString name;
	MessageListener* listener;
	int ID;
};

////////////////////////////////////////////////////////////////////////////////
// Context menu class

class GLContextMenu: public GLWindow {
public:
   // Constructor
   GLContextMenu (GLWindow* _parent, int left, int top);

   // Destructor
   ~GLContextMenu() OVERRIDE;

   // Add an entry, name and texture should persist until menu deletion
   bool addMenuItem (const BGCPString& name, MessageListener* listener, int ID);

   // Events
   void keypressed (BGKey /*key*/, bool /*shiftHeld*/, bool /*ctrlHeld*/, bool /*down*/, bool /*repeat*/) OVERRIDE;
   GLWindow* buttonStateChanged (int /*button*/, bool down, 
                                    int /*x*/, int /*y*/) OVERRIDE;
   
   void mouseMoved (int x, int y) OVERRIDE;

   // Render
   void render(int x, int y, int w, int h) OVERRIDE;

   // Event: widget looses focus
   void loseFocus () OVERRIDE
   { delete this; }

private:
   std::vector <GLContextMenuEntry> entries;
};

#endif
