rxcategory.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //
  2. //////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Copyright 2015 Autodesk, Inc. All rights reserved.
  5. //
  6. // Use of this software is subject to the terms of the Autodesk license
  7. // agreement provided at the time of installation or download, or which
  8. // otherwise accompanies this software in either electronic or hard copy form.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11. #pragma once
  12. #include "acbasedefs.h"
  13. #include "adesk.h"
  14. #include "acadstrc.h"
  15. #include "pimplapi.h"
  16. /// <summary>
  17. /// Provides hierarchical information about property categorization to UI
  18. /// clients. AcRxCategory instances can be referenced by name from
  19. /// AcRxCategoryAttributes attached to AcRxProperty instances. The position of
  20. /// an AcRxCategory instance in the global AcRxCategory tree can be used by
  21. /// clients to determine the location of the property relative to other
  22. /// properties when realized in a UI (such as a property browser).
  23. /// AcRxAttributes can be attached to application-supplied AcRxCategory
  24. /// instances to provide additional information about the AcRxCategory,
  25. /// including descriptions, localized category names, relative weighting, etc.
  26. /// </summary>
  27. class AcRxCategory : public AcRxMember
  28. {
  29. public:
  30. ACRX_DECLARE_MEMBERS_EXPIMP(AcRxCategory, ACBASE_PORT);
  31. /// <summary>
  32. /// Constructor
  33. /// </summary>
  34. /// <param name="name">
  35. /// The name of the category.
  36. /// </param>
  37. /// <param name="pOwner">
  38. /// A pointer to the owning category, must be non-NULL.
  39. /// </param>
  40. /// <remarks>
  41. /// Child category lifetimes are determined by the lifetime of their owner.
  42. /// When a category is freed all of its children are also freed.
  43. /// </remarks>
  44. ACBASE_PORT AcRxCategory(const ACHAR* name, AcRxCategory* pOwner) throw();
  45. /// <summary>
  46. /// Removes a child category from an owning category.
  47. /// </summary>
  48. /// <param name="pChildCategory>
  49. /// A pointer to the child category to remove.
  50. /// </param>
  51. /// <returns>
  52. /// Returns Acad::eOk if successful. Returns Acad::eKeyNotFound if the
  53. /// child could not be found on this object.
  54. /// </returns>
  55. ACBASE_PORT Acad::ErrorStatus removeChild(AcRxCategory* pChildCategory);
  56. /// <summary>
  57. /// Recursively finds the first descendant category with the specified
  58. /// name.
  59. /// </summary>
  60. /// <param name="name">
  61. /// The name of the descendant category to find.
  62. /// </param>
  63. /// <returns>
  64. /// A pointer to the category. NULL if no matching category was found.
  65. /// </returns>
  66. /// <remarks>
  67. /// The search uses a bread-first recursive traversal of the category tree
  68. /// beneath the referenced category. The first descendant with a matching
  69. /// name is returned to the caller.
  70. /// </remarks>
  71. ACBASE_PORT AcRxCategory* findDescendant(const ACHAR* name) const;
  72. /// <summary>
  73. /// The special, global root category node. All application-supplied
  74. /// categories should be added to the root category or one of its
  75. /// descendants.
  76. /// </summary>
  77. ACBASE_PORT static AcRxCategory* rootCategory();
  78. private:
  79. /// <summary>
  80. /// Destructor.
  81. /// </summary>
  82. /// <remarks>
  83. /// The destructor frees all children categories.
  84. /// <remarks>
  85. ACBASE_PORT virtual ~AcRxCategory();
  86. };
  87. ACBASE_PORT Acad::ErrorStatus
  88. acdbGetLegacyCategoryId(const AcRxCategory* pCategory, int& legacyId);
  89. ACBASE_PORT Acad::ErrorStatus
  90. acdbSetLegacyCategoryId(AcRxCategory* pCategory, int legacyId);