appcmds.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include <precomp.h>
  2. #include "appcmds.h"
  3. #define CBCLASS AppCmdsI
  4. START_DISPATCH;
  5. CB(APPCMDS_GETNUMCMDS, appcmds_getNumCmds);
  6. CB(APPCMDS_ENUMCMD, appcmds_enumCmd);
  7. VCB(APPCMDS_ONCOMMAND, appcmds_onCommand);
  8. END_DISPATCH;
  9. #undef CBCLASS
  10. AppCmdsI::~AppCmdsI()
  11. {
  12. foreach(cmds)
  13. if (cmds.getfor()->autodelete)
  14. delete cmds.getfor();
  15. endfor
  16. }
  17. void AppCmdsI::appcmds_addCmd(CmdRec *cmdrec)
  18. {
  19. cmds.addItem(cmdrec);
  20. }
  21. void AppCmdsI::appcmds_addCmd(const wchar_t *name, int id, int side)
  22. {
  23. cmds.addItem(new CmdRec(name, id, side, TRUE));
  24. }
  25. void AppCmdsI::appcmds_deleteAll()
  26. {
  27. foreach(cmds)
  28. if (cmds.getfor()->autodelete) delete cmds.getfor();
  29. endfor
  30. cmds.removeAll();
  31. }
  32. int AppCmdsI::appcmds_getNumCmds()
  33. {
  34. return cmds.getNumItems();
  35. }
  36. const wchar_t *AppCmdsI::appcmds_enumCmd(int n, int *side, int *id)
  37. {
  38. CmdRec *cr = cmds[n];
  39. if (cr == NULL) return NULL;
  40. if (side != NULL) *side = cr->side;
  41. if (id != NULL) *id = cr->id;
  42. return cr->cmdname;
  43. }
  44. void AppCmdsI::appcmds_onCommand(int id, const RECT *buttonRect, int which_button)
  45. {
  46. foreach(cmds)
  47. if (cmds.getfor()->id == id)
  48. {
  49. cmds.getfor()->onCommand(buttonRect, which_button);
  50. break;
  51. }
  52. endfor
  53. }