#ifndef __CmdList__H
#define __CmdList__H

#include "stdbool.h"
#include "WimpLib:Coords.h"
#include "WimpLib:EventSender.h"
#include "WimpLib:Event.h"

typedef uint32_t CmdID;
typedef struct CmdList CmdList;
typedef struct Keymap Keymap;
typedef struct Toolbar Toolbar;

typedef struct
{
	const Event* e;
	HMenu    menu;
	int32_t  item;
	HWind    w;
	HIcon    i;
	int32_t  hit[10];
} CmdContext;

CmdList* /*throw*/CmdList_Get(void);
void CmdList_Release(void);
void throw_CmdList_Parse(CmdList*);

typedef enum
{ ECmdState_Allow = 0x01
, ECmdState_Tick  = 0x02
} ECmdState;

typedef int (*CmdHandler_FCheckCommand)(void* handle, CmdID id);
typedef bool (*CmdHandler_FExecCommand)(void* handle, CmdID id);

typedef struct CmdHandler
{
	CmdHandler_FCheckCommand  FCheckCommand;
	CmdHandler_FExecCommand   FExecCommand;
} CmdHandler;

HWind throw_CmdHandler_CreateToolbar(const CmdHandler* handler, void* handle, const char* name);
void CmdHandler_OpenMenu(const CmdHandler* handler, void* handle, const char* name);
bool CmdHandler_KeyPressed(const CmdHandler* handler, void* handle, const char* kmapname, int key);
bool CmdHandler_ExecCommand(const CmdHandler* handler, void* handle, CmdID id);
const CmdContext* CmdHandler_GetContext(const CmdHandler* handler);
EListenerAction Cmd_Help(const Msg_HelpRequest* pmsg, CmdID sel, CmdID adj);

Toolbar* throw_New_Toolbar(const CmdHandler* handler, void* handle, const char* name);
void Delete_Toolbar(Toolbar*);
HWind Toolbar_GetWindow(const Toolbar*);

#endif
