autopopup.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef __AUTOPOPUP_H
  2. #define __AUTOPOPUP_H
  3. #include <bfc/ptrlist.h>
  4. #include <bfc/string/StringW.h>
  5. class AutoPopupEntry;
  6. class AutoPopupEntrySort;
  7. #define SKINPARTID_NONE -1
  8. class AutoPopup {
  9. public:
  10. static int registerGuid(int skinpartid/*SKINPARTID_NONE*/, GUID g, const wchar_t *desc, const wchar_t *prefered_container=NULL, int required=FALSE);
  11. static int registerGroupId(int skinpartid/*SKINPARTID_NONE*/, const wchar_t *groupid, const wchar_t *desc, const wchar_t *prefered_container=NULL, int required=FALSE);
  12. static void unregister(int id);
  13. static int getNumItems();
  14. static AutoPopupEntry *enumItem(int n);
  15. static AutoPopupEntry *getByDesc(const wchar_t *desc);
  16. static void reset();
  17. static void removeSkinPart(int id);
  18. static int allocNid();
  19. static void removeAllAddons();
  20. static int getNumGuids();
  21. static GUID enumGuid(int n);
  22. static int getNumGroups();
  23. static const wchar_t *enumGroup(int n);
  24. static const wchar_t *enumGuidDescription(int n);
  25. static const wchar_t *enumGroupDescription(int n);
  26. static const wchar_t *getDefaultContainerParams(const wchar_t *groupid, GUID g, int *flag);
  27. };
  28. class AutoPopupEntry {
  29. public:
  30. AutoPopupEntry(int skinpartid, GUID g, const wchar_t *grpid, const wchar_t *description, const wchar_t *prefered_container=NULL, int required=TRUE) : guid(g), groupid(grpid), desc(description), container(prefered_container), container_how(required), skinpart(skinpartid) { nid = AutoPopup::allocNid(); }
  31. virtual ~AutoPopupEntry() { }
  32. GUID getGuid() { return guid; }
  33. const wchar_t *getGroupId() { return groupid; }
  34. const wchar_t *getDescription() { return desc; }
  35. int getNid() { return nid; }
  36. const wchar_t *getPreferedContainer() { return container; }
  37. int getContainerHow() { return container_how; }
  38. int getSkinpart() { return skinpart; }
  39. private:
  40. GUID guid;
  41. StringW groupid;
  42. StringW desc;
  43. int nid;
  44. StringW container;
  45. int container_how;
  46. int skinpart;
  47. };
  48. class AutoPopupEntrySort {
  49. public:
  50. static int compareItem(AutoPopupEntry *p1, AutoPopupEntry *p2) {
  51. return WCSICMP(p1->getDescription(), p2->getDescription());
  52. }
  53. static int compareAttrib(const wchar_t *attrib, AutoPopupEntry *item) {
  54. return WCSICMP(attrib, item->getDescription());
  55. }
  56. };
  57. #endif