00001
00032 #ifndef LLUICTRLFACTORY_H
00033 #define LLUICTRLFACTORY_H
00034
00035 #include <iosfwd>
00036 #include <stack>
00037
00038 #include "llcallbackmap.h"
00039 #include "llfloater.h"
00040
00041 class LLControlGroup;
00042 class LLView;
00043 class LLFontGL;
00044
00045 class LLFloater;
00046 class LLPanel;
00047 class LLButton;
00048 class LLCheckBoxCtrl;
00049 class LLComboBox;
00050 class LLIconCtrl;
00051 class LLLineEditor;
00052 class LLMenuGL;
00053 class LLMenuBarGL;
00054 class LLMenuItemCallGL;
00055 class LLNameListCtrl;
00056 class LLPieMenu;
00057 class LLRadioGroup;
00058 class LLSearchEditor;
00059 class LLScrollableContainerView;
00060 class LLScrollListCtrl;
00061 class LLSlider;
00062 class LLSliderCtrl;
00063 class LLSpinCtrl;
00064 class LLTextBox;
00065 class LLTextEditor;
00066 class LLTextureCtrl;
00067 class LLWebBrowserCtrl;
00068 class LLViewBorder;
00069 class LLColorSwatchCtrl;
00070 class LLScrollingPanelList;
00071 class LLCtrlListInterface;
00072 class LLCtrlSelectionInterface;
00073 class LLCtrlScrollInterface;
00074
00075
00076
00077 class LLUICtrlFactory
00078 {
00079 public:
00080 LLUICtrlFactory();
00081
00082 virtual ~LLUICtrlFactory();
00083
00084 void setupPaths();
00085
00086 void buildFloater(LLFloater* floaterp, const LLString &filename,
00087 const LLCallbackMap::map_t* factory_map = NULL, BOOL open = TRUE);
00088
00089 BOOL buildPanel(LLPanel* panelp, const LLString &filename,
00090 const LLCallbackMap::map_t* factory_map = NULL);
00091
00092 LLMenuGL *buildMenu(const LLString &filename, LLView* parentp);
00093
00094 LLPieMenu *buildPieMenu(const LLString &filename, LLView* parentp);
00095
00096
00097
00098 S32 saveToXML(LLView* viewp, const LLString& filename);
00099
00100 void removePanel(LLPanel* panelp);
00101 void removeFloater(LLFloater* floaterp);
00102
00103 void rebuild();
00104
00105 static EWidgetType getWidgetType(const LLString& ctrl_type);
00106 static LLString getWidgetType(EWidgetType ctrl_type);
00107 static BOOL getAttributeColor(LLXMLNodePtr node, const LLString& name, LLColor4& color);
00108
00109
00110 static LLButton* getButtonByName( LLPanel* panelp, const LLString& name);
00111 static LLCheckBoxCtrl* getCheckBoxByName( LLPanel* panelp, const LLString& name);
00112 static LLComboBox* getComboBoxByName( LLPanel* panelp, const LLString& name);
00113 static LLIconCtrl* getIconByName( LLPanel* panelp, const LLString& name);
00114 static LLLineEditor* getLineEditorByName( LLPanel* panelp, const LLString& name);
00115 static LLNameListCtrl* getNameListByName( LLPanel* panelp, const LLString& name);
00116 static LLRadioGroup* getRadioGroupByName( LLPanel* panelp, const LLString& name);
00117 static LLScrollListCtrl* getScrollListByName( LLPanel* panelp, const LLString& name);
00118 static LLSliderCtrl* getSliderByName( LLPanel* panelp, const LLString& name);
00119 static LLSlider* getSliderBarByName( LLPanel* panelp, const LLString& name);
00120 static LLSpinCtrl* getSpinnerByName( LLPanel* panelp, const LLString& name);
00121 static LLTextBox* getTextBoxByName( LLPanel* panelp, const LLString& name);
00122 static LLTextEditor* getTextEditorByName( LLPanel* panelp, const LLString& name);
00123 static LLTabContainerCommon* getTabContainerByName( LLPanel* panelp, const LLString& name);
00124 static LLScrollableContainerView* getScrollableContainerByName(LLPanel* panelp, const LLString& name);
00125 static LLTextureCtrl* getTexturePickerByName( LLPanel* panelp, const LLString& name);
00126 static LLPanel* getPanelByName(LLPanel* panelp, const LLString& name);
00127 static LLColorSwatchCtrl* getColorSwatchByName(LLPanel* panelp, const LLString& name);
00128 static LLWebBrowserCtrl* getWebBrowserCtrlByName(LLPanel* panelp, const LLString& name);
00129 static LLMenuItemCallGL* getMenuItemCallByName(LLPanel* panelp, const LLString& name);
00130 static LLScrollingPanelList* getScrollingPanelList(LLPanel* panelp, const LLString& name);
00131
00132
00133 static LLCtrlListInterface* getListInterfaceByName(LLPanel* panelp, const LLString& name);
00134 static LLCtrlSelectionInterface* getSelectionInterfaceByName(LLPanel* panelp, const LLString& name);
00135 static LLCtrlScrollInterface* getScrollInterfaceByName(LLPanel* panelp, const LLString& name);
00136
00137 LLPanel* createFactoryPanel(LLString name);
00138
00139 virtual LLView* createCtrlWidget(LLPanel *parent, LLXMLNodePtr node);
00140 virtual void createWidget(LLPanel *parent, LLXMLNodePtr node);
00141
00142
00143 typedef LLView* (*creator_function_t)(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00144 void registerCreator(LLString ctrlname, creator_function_t function);
00145
00146 static bool getLayeredXMLNode(const LLString &filename, LLXMLNodePtr& root);
00147
00148 protected:
00149
00150
00151 typedef std::map<LLViewHandle, LLString> built_panel_t;
00152 built_panel_t mBuiltPanels;
00153 typedef std::map<LLViewHandle, LLString> built_floater_t;
00154 built_floater_t mBuiltFloaters;
00155
00156 std::deque<const LLCallbackMap::map_t*> mFactoryStack;
00157
00158 static const LLString sUICtrlNames[];
00159
00160 typedef std::map<LLString, creator_function_t> creator_list_t;
00161 creator_list_t mCreatorFunctions;
00162 static std::vector<LLString> mXUIPaths;
00163 };
00164
00165 template<class T>
00166 class LLUICtrlCreator
00167 {
00168 public:
00169 static void registerCreator(LLString name, LLUICtrlFactory *factory)
00170 {
00171 factory->registerCreator(name, T::fromXML);
00172 }
00173 };
00174
00175 #endif //LL_LLWIDGETFACTORY_H