llpanel.h

Go to the documentation of this file.
00001 
00033 #ifndef LL_LLPANEL_H
00034 #define LL_LLPANEL_H
00035 
00036 // Opaque view with a background and a border.  Can contain LLUICtrls.
00037 
00038 #include "llcallbackmap.h"
00039 #include "lluictrl.h"
00040 #include "llviewborder.h"
00041 #include "lluistring.h"
00042 #include "v4color.h"
00043 #include <list>
00044 #include <queue>
00045 
00046 const S32 LLPANEL_BORDER_WIDTH = 1;
00047 const BOOL BORDER_YES = TRUE;
00048 const BOOL BORDER_NO = FALSE;
00049 
00050 class LLViewerImage;
00051 class LLUUID;
00052 class LLCheckBoxCtrl;
00053 class LLComboBox;
00054 class LLIconCtrl;
00055 class LLLineEditor;
00056 class LLRadioGroup;
00057 class LLScrollListCtrl;
00058 class LLSliderCtrl;
00059 class LLSpinCtrl;
00060 class LLTextBox;
00061 class LLTextEditor;
00062 
00063 class LLAlertInfo
00064 {
00065 public:
00066         LLString mLabel;
00067         LLString::format_map_t mArgs;
00068 
00069         LLAlertInfo(LLString label, LLString::format_map_t args)
00070                 : mLabel(label), mArgs(args) { }
00071 
00072                 LLAlertInfo() { }
00073 };
00074 
00075 class LLPanel : public LLUICtrl
00076 {
00077 public:
00078         virtual EWidgetType getWidgetType() const;
00079         virtual LLString getWidgetTag() const;
00080 
00081         // defaults to TRUE
00082         virtual BOOL isPanel();
00083 
00084         // minimal constructor for data-driven initialization
00085         LLPanel();
00086         LLPanel(const LLString& name);
00087 
00088         // Position and size not saved
00089         LLPanel(const LLString& name, const LLRect& rect, BOOL bordered = TRUE);
00090 
00091         // Position and size are saved to rect_control
00092         LLPanel(const LLString& name, const LLString& rect_control, BOOL bordered = TRUE);
00093 
00094         void addBorder( LLViewBorder::EBevel border_bevel = LLViewBorder::BEVEL_OUT,
00095                                         LLViewBorder::EStyle border_style = LLViewBorder::STYLE_LINE,
00096                                         S32 border_thickness = LLPANEL_BORDER_WIDTH );
00097 
00098         void removeBorder();
00099 
00100         virtual ~LLPanel();
00101         virtual void    draw(); 
00102         virtual void    refresh();      // called in setFocus()
00103         virtual void    setFocus( BOOL b );
00104         void                    setFocusRoot(BOOL b) { mIsFocusRoot = b; }
00105         virtual BOOL    handleKeyHere( KEY key, MASK mask, BOOL called_from_parent );
00106         virtual BOOL    handleKey( KEY key, MASK mask, BOOL called_from_parent );
00107         virtual BOOL    postBuild();
00108 
00109         void                    requires(LLString name, EWidgetType type = WIDGET_TYPE_DONTCARE);
00110         BOOL                    checkRequirements();
00111 
00112         static void             alertXml(LLString label, LLString::format_map_t args = LLString::format_map_t());
00113         static BOOL             nextAlert(LLAlertInfo &alert);
00114 
00115         void                    setBackgroundColor( const LLColor4& color );
00116         LLColor4                getBackgroundColor(); 
00117         void                    setTransparentColor(const LLColor4& color);
00118         void                    setBackgroundVisible( BOOL b )  { mBgVisible = b; }
00119         void                    setBackgroundOpaque(BOOL b)             { mBgOpaque = b; }
00120         void                    setDefaultBtn(LLButton* btn = NULL);
00121         void                    setDefaultBtn(const LLString& id);
00122         void                    setLabel(const LLStringExplicit& label) { mLabel = label; }
00123         LLString                getLabel() const { return mLabel; }
00124         
00125         void            setRectControl(const LLString& rect_control) { mRectControl.assign(rect_control); }
00126         void                    storeRectControl();
00127         
00128         void                    setBorderVisible( BOOL b );
00129 
00130         void                    setCtrlsEnabled(BOOL b);
00131         virtual void    clearCtrls();
00132 
00133         LLViewHandle    getHandle() { return mViewHandle; }
00134 
00135         S32                             getLastTabGroup() { return mLastTabGroup; }
00136 
00137         LLView*                 getCtrlByNameAndType(const LLString& name, EWidgetType type);
00138 
00139         static LLPanel* getPanelByHandle(LLViewHandle handle);
00140 
00141         virtual const LLCallbackMap::map_t& getFactoryMap() const { return mFactoryMap; }
00142 
00143         virtual LLXMLNodePtr getXML(bool save_children = true) const;
00144         static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00145         BOOL initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00146         void initChildrenXML(LLXMLNodePtr node, LLUICtrlFactory* factory);
00147         void setPanelParameters(LLXMLNodePtr node, LLView *parentp);
00148 
00149         LLString getFormattedUIString(const LLString& name, const LLString::format_map_t& args = LLUIString::sNullArgs) const;
00150         LLUIString getUIString(const LLString& name) const;
00151 
00152         // ** Wrappers for setting child properties by name ** -TomY
00153 
00154         // Override to set not found list
00155         virtual LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const;
00156         
00157         // LLView
00158         void childSetVisible(const LLString& name, bool visible);
00159         void childShow(const LLString& name) { childSetVisible(name, true); }
00160         void childHide(const LLString& name) { childSetVisible(name, false); }
00161         bool childIsVisible(const LLString& id) const;
00162         void childSetTentative(const LLString& name, bool tentative);
00163 
00164         void childSetEnabled(const LLString& name, bool enabled);
00165         void childEnable(const LLString& name)  { childSetEnabled(name, true); }
00166         void childDisable(const LLString& name) { childSetEnabled(name, false); };
00167         bool childIsEnabled(const LLString& id) const;
00168 
00169         void childSetToolTip(const LLString& id, const LLString& msg);
00170         void childSetRect(const LLString& id, const LLRect &rect);
00171         bool childGetRect(const LLString& id, LLRect& rect) const;
00172 
00173         // LLUICtrl
00174         void childSetFocus(const LLString& id, BOOL focus = TRUE);
00175         BOOL childHasFocus(const LLString& id);
00176         void childSetFocusChangedCallback(const LLString& id, void (*cb)(LLUICtrl*, void*));
00177         
00178         void childSetCommitCallback(const LLString& id, void (*cb)(LLUICtrl*, void*), void* userdata = NULL );
00179         void childSetDoubleClickCallback(const LLString& id, void (*cb)(void*), void* userdata = NULL );
00180         void childSetValidate(const LLString& id, BOOL (*cb)(LLUICtrl*, void*) );
00181         void childSetUserData(const LLString& id, void* userdata);
00182 
00183         void childSetColor(const LLString& id, const LLColor4& color);
00184 
00185         LLCtrlSelectionInterface* childGetSelectionInterface(const LLString& id);
00186         LLCtrlListInterface* childGetListInterface(const LLString& id);
00187         LLCtrlScrollInterface* childGetScrollInterface(const LLString& id);
00188 
00189         // This is the magic bullet for data-driven UI
00190         void childSetValue(const LLString& id, LLSD value);
00191         LLSD childGetValue(const LLString& id) const;
00192 
00193         // For setting text / label replacement params, e.g. "Hello [NAME]"
00194         // Not implemented for all types, defaults to noop, returns FALSE if not applicaple
00195         BOOL childSetTextArg(const LLString& id, const LLString& key, const LLStringExplicit& text);
00196         BOOL childSetLabelArg(const LLString& id, const LLString& key, const LLStringExplicit& text);
00197         
00198         // LLSlider / LLSpinCtrl
00199         void childSetMinValue(const LLString& id, LLSD min_value);
00200         void childSetMaxValue(const LLString& id, LLSD max_value);
00201 
00202         // LLTabContainer
00203         void childShowTab(const LLString& id, const LLString& tabname, bool visible = true);
00204         LLPanel *childGetVisibleTab(const LLString& id);
00205         void childSetTabChangeCallback(const LLString& id, const LLString& tabname, void (*on_tab_clicked)(void*, bool), void *userdata);
00206 
00207         // LLTextBox
00208         void childSetWrappedText(const LLString& id, const LLString& text, bool visible = true);
00209 
00210         // LLTextBox/LLTextEditor/LLLineEditor
00211         void childSetText(const LLString& id, const LLStringExplicit& text);
00212         LLString childGetText(const LLString& id);
00213 
00214         // LLLineEditor
00215         void childSetKeystrokeCallback(const LLString& id, void (*keystroke_callback)(LLLineEditor* caller, void* user_data), void *user_data);
00216         void childSetPrevalidate(const LLString& id, BOOL (*func)(const LLWString &) );
00217 
00218         // LLButton
00219         void childSetAction(const LLString& id, void(*function)(void*), void* value);
00220         void childSetActionTextbox(const LLString& id, void(*function)(void*));
00221         void childSetControlName(const LLString& id, const LLString& control_name);
00222 
00223         // Error reporting
00224         void childNotFound(const LLString& id) const;
00225         void childDisplayNotFound();
00226 
00227         typedef std::queue<LLAlertInfo> alert_queue_t;
00228         static alert_queue_t sAlertQueue;
00229 
00230         typedef std::map<LLString, LLUIString> ui_string_map_t;
00231 
00232 private:
00233         // common constructor
00234         void init();
00235         
00236 protected:
00237         virtual void    addCtrl( LLUICtrl* ctrl, S32 tab_group );
00238         virtual void    addCtrlAtEnd( LLUICtrl* ctrl, S32 tab_group);
00239 
00240         // Unified error reporting for the child* functions
00241         typedef std::set<LLString> expected_members_list_t;
00242         mutable expected_members_list_t mExpectedMembers;
00243         mutable expected_members_list_t mNewExpectedMembers;
00244 
00245         LLString                mRectControl;
00246         LLColor4                mBgColorAlpha;
00247         LLColor4                mBgColorOpaque;
00248         LLColor4                mDefaultBtnHighlight;
00249         BOOL                    mBgVisible;
00250         BOOL                    mBgOpaque;
00251         LLViewBorder*   mBorder;
00252         LLButton*               mDefaultBtn;
00253         LLCallbackMap::map_t mFactoryMap;
00254         LLString                mLabel;
00255         S32                             mLastTabGroup;
00256 
00257         ui_string_map_t mUIStrings;
00258 
00259         typedef std::map<LLString, EWidgetType> requirements_map_t;
00260         requirements_map_t mRequirements;
00261 
00262         typedef std::map<LLViewHandle, LLPanel*> panel_map_t;
00263         static panel_map_t sPanelMap;
00264 };
00265 
00266 class LLLayoutStack : public LLView
00267 {
00268 public:
00269         typedef enum e_layout_orientation
00270         {
00271                 HORIZONTAL,
00272                 VERTICAL
00273         } eLayoutOrientation;
00274 
00275         LLLayoutStack(eLayoutOrientation orientation);
00276         virtual ~LLLayoutStack();
00277 
00278         /*virtual*/ void draw();
00279         /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent);
00280         /*virtual*/ LLXMLNodePtr getXML(bool save_children = true) const;
00281         /*virtual*/ void removeCtrl(LLUICtrl* ctrl);
00282         virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_LAYOUT_STACK; }
00283         virtual LLString getWidgetTag() const { return LL_LAYOUT_STACK_TAG; }
00284 
00285         static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00286 
00287         S32 getMinWidth();
00288         S32 getMinHeight();
00289         
00290         void addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL auto_resize, S32 index = S32_MAX);
00291         void removePanel(LLPanel* panel);
00292         void updateLayout(BOOL force_resize = FALSE);
00293 
00294 protected:
00295         struct LLEmbeddedPanel;
00296 
00297         LLEmbeddedPanel* findEmbeddedPanel(LLPanel* panelp);
00298         void calcMinExtents();
00299         S32 getMinStackSize();
00300         S32 getCurStackSize();
00301 
00302 protected:
00303         eLayoutOrientation mOrientation;
00304 
00305         typedef std::vector<LLEmbeddedPanel*> e_panel_list_t;
00306         e_panel_list_t mPanels;
00307 
00308         S32 mMinWidth;
00309         S32 mMinHeight;
00310 };
00311 
00312 #endif

Generated on Thu Jul 1 06:08:55 2010 for Second Life Viewer by  doxygen 1.4.7