1
0

objdirwnd.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #ifndef _OBJDIRWND_H
  2. #define _OBJDIRWND_H
  3. #include <api/wnd/wndclass/treewnd.h>
  4. #include <api/service/svcs/svc_objectdir.h>
  5. #include <bfc/depview.h>
  6. enum OBJ_type { OBJTYPE_OBJ, OBJTYPE_FOLDER };
  7. class BaseObjItem : public TreeItemParam<OBJ_type> {
  8. protected:
  9. BaseObjItem(OBJ_type type, const wchar_t *label) : TreeItemParam<OBJ_type>(type, label), sortorder(0) { }
  10. public:
  11. int sortorder;
  12. };
  13. class ObjItem : public BaseObjItem {
  14. public:
  15. ObjItem(ObjectHandle _handle, const wchar_t *label=NULL) : hittable(TRUE), handle(_handle), BaseObjItem(OBJTYPE_OBJ, label) {}
  16. ObjectHandle getObjectHandle() const { return handle; }
  17. virtual int onBeginLabelEdit() { return 0; } // allow editing
  18. virtual int isHitTestable() { return hittable; }
  19. int hittable;
  20. private:
  21. ObjectHandle handle;
  22. };
  23. class ObjDirFolderItem : public BaseObjItem {
  24. public:
  25. ObjDirFolderItem(const wchar_t *label) : BaseObjItem(OBJTYPE_FOLDER, label), dying(0) {
  26. setIcon(new SkinBitmap(L"player.button.thinger"));
  27. }
  28. virtual void onChildItemRemove(TreeItem *item) {
  29. if (getNumChildren() == 0) {
  30. dying = 1;
  31. getTree()->delItemDeferred(this);
  32. }
  33. }
  34. int dying;
  35. };
  36. #define OBJDIRWND_PARENT TreeWnd
  37. class ObjDirWnd : public OBJDIRWND_PARENT, DependentViewerTPtr<svc_objectDir> {
  38. public:
  39. ObjDirWnd();
  40. virtual ~ObjDirWnd();
  41. void setTargetDirName(const wchar_t *dirname);
  42. void setActionTarget(const wchar_t *targetname);
  43. void setDisplayTarget(const wchar_t *name);
  44. void setDefaultDisplay(const wchar_t *display);
  45. virtual int onInit();
  46. virtual int onContextMenu(int x, int y);
  47. virtual int onPreItemContextMenu(TreeItem *item, int x, int y);
  48. virtual int compareItem(TreeItem *p1, TreeItem *p2);
  49. virtual int viewer_onEvent(svc_objectDir *item, int event, intptr_t param2, void *ptr, size_t ptrlen);
  50. protected:
  51. ObjItem *createObjItem(ObjectHandle handle);
  52. ObjItem *getObjItemForHandle(ObjectHandle handle);
  53. void folderify(ObjItem *item);
  54. private:
  55. virtual void onItemSelected(TreeItem *item);
  56. virtual void onItemDeselected(TreeItem *item);
  57. svc_objectDir *objdir;
  58. StringW objectDirName, objectDirTarget, displayTarget, defaultDisplay;
  59. ifc_window *displaygroup;
  60. StringW displaygroupname;
  61. };
  62. template <class TREEITEMCLASS>
  63. class ObjDirWndT : public ObjDirWnd {
  64. public:
  65. virtual ObjItem *createObjItem(ObjectHandle handle) { return new TREEITEMCLASS(handle); }
  66. };
  67. #endif