1
0

svc_filesel.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef _SVC_FILESEL_H
  2. #define _SVC_FILESEL_H
  3. #include <bfc/dispatch.h>
  4. #include <api/service/services.h>
  5. class ifc_window;
  6. class NOVTABLE svc_fileSelector : public Dispatchable {
  7. public:
  8. static FOURCC getServiceType() { return WaSvc::FILESELECTOR; }
  9. int testPrefix(const wchar_t *prefix) {
  10. return _call(TESTPREFIX, 0, prefix);
  11. }
  12. const wchar_t *getPrefix() {
  13. return _call(GETPREFIX, L"");
  14. }
  15. int setTitle(const wchar_t *title) {
  16. return _call(SETTITLE, 0, title);
  17. }
  18. int setExtList(const wchar_t *ext) {
  19. return _call(SETEXTLIST, 0, ext);
  20. }
  21. int runSelector(ifc_window *parWnd, int type, int allow_multiple, const wchar_t *ident=NULL, const wchar_t *default_dir=NULL) {
  22. return _call(RUNSELECTOR, 0, parWnd, type, allow_multiple, ident, default_dir);
  23. }
  24. int getNumFilesSelected() {
  25. return _call(GETNUMFILESSELECTED, 0);
  26. }
  27. const wchar_t *enumFilename(int n) {
  28. return _call(ENUMFILENAME, L"", n);
  29. }
  30. const wchar_t *getDirectory() {
  31. return _call(GETDIRECTORY, L"");
  32. }
  33. protected:
  34. enum {
  35. TESTPREFIX=0,
  36. GETPREFIX=10,
  37. SETTITLE=20,
  38. SETEXTLIST=30,
  39. RUNSELECTOR=40,
  40. GETNUMFILESSELECTED=50,
  41. ENUMFILENAME=60,
  42. GETDIRECTORY=70,
  43. };
  44. };
  45. namespace FileSel {
  46. enum {
  47. OPEN=1, SAVEAS=2,
  48. };
  49. };
  50. class NOVTABLE svc_fileSelectorI : public svc_fileSelector {
  51. public:
  52. virtual int testPrefix(const wchar_t *prefix)=0;
  53. virtual const wchar_t *getPrefix()=0;
  54. virtual int setTitle(const wchar_t *title) { return 0; }
  55. virtual int setExtList(const wchar_t *ext) { return 0; }
  56. virtual int runSelector(ifc_window *parWnd, int type, int allow_multiple, const wchar_t *ident=NULL, const wchar_t *default_dir=NULL)=0;
  57. virtual int getNumFilesSelected()=0;
  58. virtual const wchar_t *enumFilename(int n)=0;
  59. virtual const wchar_t *getDirectory()=0;
  60. protected:
  61. RECVS_DISPATCH;
  62. };
  63. #include <api/service/svc_enum.h>
  64. #include <bfc/string/StringW.h>
  65. class FileSelectorEnum : public SvcEnumT<svc_fileSelector> {
  66. public:
  67. FileSelectorEnum(const wchar_t *_prefix=L"files") : prefix(_prefix) { }
  68. protected:
  69. virtual int testService(svc_fileSelector *svc) {
  70. return prefix.isempty() || svc->testPrefix(prefix);
  71. }
  72. private:
  73. StringW prefix;
  74. };
  75. #endif