lluictrlfactory.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /**
  2. * @file lluictrlfactory.h
  3. * @brief Factory class for creating UI controls
  4. *
  5. * $LicenseInfo:firstyear=2003&license=viewergpl$
  6. *
  7. * Copyright (c) 2003-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LLUICTRLFACTORY_H
  33. #define LLUICTRLFACTORY_H
  34. #include <deque>
  35. #include <string>
  36. #include <vector>
  37. #include "llcallbackmap.h"
  38. #include "llfloater.h"
  39. class LLView;
  40. class LLPanel;
  41. class LLUICtrlFactory : public LLSingleton<LLUICtrlFactory>
  42. {
  43. friend class LLSingleton<LLUICtrlFactory>;
  44. protected:
  45. LOG_CLASS(LLUICtrlFactory);
  46. public:
  47. LLUICtrlFactory();
  48. // do not call! needs to be public so run-time can clean up the singleton
  49. ~LLUICtrlFactory() override;
  50. void setupPaths();
  51. bool buildFloater(LLFloater* floaterp, const std::string& filename,
  52. const LLCallbackMap::map_t* factory_map = NULL,
  53. bool open = true);
  54. bool buildPanel(LLPanel* panelp, const std::string& filename,
  55. const LLCallbackMap::map_t* factory_map = NULL);
  56. void removePanel(LLPanel* panelp) { mBuiltPanels.erase(panelp->getHandle()); }
  57. void removeFloater(LLFloater* floaterp) { mBuiltFloaters.erase(floaterp->getHandle()); }
  58. class LLMenuGL* buildMenu(const std::string& filename, LLView* parentp);
  59. class LLPieMenu* buildPieMenu(const std::string& filename, LLView* parentp);
  60. // Does what you want for LLFloaters and LLPanels
  61. // Returns 0 on success
  62. S32 saveToXML(LLView* viewp, const std::string& filename);
  63. // Rebuilds all currently built panels.
  64. void rebuild();
  65. static bool getAttributeColor(LLXMLNodePtr node, const std::string& name,
  66. LLColor4& color);
  67. LLPanel* createFactoryPanel(const std::string& name);
  68. virtual LLView* createCtrlWidget(LLPanel* parent, LLXMLNodePtr node);
  69. virtual LLView* createWidget(LLPanel* parent, LLXMLNodePtr node);
  70. static bool getLayeredXMLNode(const std::string& filename, LLXMLNodePtr& root);
  71. static const std::vector<std::string>& getXUIPaths();
  72. private:
  73. bool getLayeredXMLNodeImpl(const std::string& filename, LLXMLNodePtr& root);
  74. typedef std::map<LLHandle<LLPanel>, std::string> built_panel_t;
  75. built_panel_t mBuiltPanels;
  76. typedef std::map<LLHandle<LLFloater>, std::string> built_floater_t;
  77. built_floater_t mBuiltFloaters;
  78. std::deque<const LLCallbackMap::map_t*> mFactoryStack;
  79. static std::vector<std::string> sXUIPaths;
  80. LLPanel* mDummyPanel;
  81. };
  82. #endif //LLUICTRLFACTORY_H