appcmds.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef _APPCMDS_H
  2. #define _APPCMDS_H
  3. #include <bfc/dispatch.h>
  4. #include <bfc/depend.h>
  5. #include <bfc/common.h>
  6. #include <bfc/string/StringW.h>
  7. #include <bfc/ptrlist.h>
  8. class DragItem;
  9. // this will be fully dispatched later on
  10. class AppCmds : public Dispatchable
  11. {
  12. public:
  13. int appcmds_getNumCmds();
  14. const wchar_t *appcmds_enumCmd(int n, int *side, int *id);
  15. enum {
  16. SIDE_LEFT = 0, SIDE_RIGHT = 1
  17. };
  18. enum {
  19. LEFT_CLICK = 0,
  20. RIGHT_CLICK = 1,
  21. };
  22. void appcmds_onCommand(int id, const RECT *buttonRect, int which_button); //onscreen coords
  23. enum {
  24. APPCMDS_GETNUMCMDS = 100,
  25. APPCMDS_ENUMCMD = 200,
  26. APPCMDS_ONCOMMAND = 300,
  27. };
  28. };
  29. inline int AppCmds::appcmds_getNumCmds()
  30. {
  31. return _call(APPCMDS_GETNUMCMDS, 0);
  32. }
  33. inline const wchar_t *AppCmds::appcmds_enumCmd(int n, int *side, int *id)
  34. {
  35. return _call(APPCMDS_ENUMCMD, (const wchar_t *)NULL, n, side, id);
  36. }
  37. inline void AppCmds::appcmds_onCommand(int id, const RECT *buttonRect, int which_button)
  38. {
  39. _voidcall(APPCMDS_ONCOMMAND, id, buttonRect, which_button);
  40. }
  41. class CmdRec
  42. {
  43. public:
  44. CmdRec(const wchar_t *name, int _id, int _side, int _autodelete = 0) : cmdname(name), id(_id), side(_side), autodelete(_autodelete) {}
  45. virtual ~CmdRec() {}
  46. StringW cmdname;
  47. int id, side;
  48. int autodelete;
  49. virtual void onCommand(const RECT *buttonRect, int which_button) {}}
  50. ;
  51. class AppCmdsI : public AppCmds
  52. {
  53. public:
  54. AppCmdsI() { }
  55. virtual ~AppCmdsI();
  56. protected:
  57. void appcmds_addCmd(CmdRec *cmdrec);
  58. void appcmds_addCmd(const wchar_t *name, int id, int side = SIDE_LEFT);
  59. void appcmds_deleteAll(); //calls delete on each one
  60. public:
  61. virtual int appcmds_getNumCmds();
  62. virtual const wchar_t *appcmds_enumCmd(int n, int *side, int *id);
  63. // override this and catch your commands, otherwise it'll call the CmdRec
  64. virtual void appcmds_onCommand(int id, const RECT *buttonRect, int which_button);
  65. protected:
  66. RECVS_DISPATCH;
  67. PtrList<CmdRec> cmds;
  68. };
  69. #endif