lluictrl.h

Go to the documentation of this file.
00001 
00033 #ifndef LL_LLUICTRL_H
00034 #define LL_LLUICTRL_H
00035 
00036 #include "llview.h"
00037 #include "llrect.h"
00038 #include "llsd.h"
00039 
00040 //
00041 // Classes
00042 //
00043 class LLFontGL;
00044 class LLButton;
00045 class LLTextBox;
00046 class LLLineEditor;
00047 class LLUICtrl;
00048 class LLPanel;
00049 class LLCtrlSelectionInterface;
00050 class LLCtrlListInterface;
00051 class LLCtrlScrollInterface;
00052 
00053 typedef void (*LLUICtrlCallback)(LLUICtrl* ctrl, void* userdata);
00054 typedef BOOL (*LLUICtrlValidate)(LLUICtrl* ctrl, void* userdata);
00055 
00056 class LLUICtrl
00057 : public LLView
00058 {
00059 public:
00060         LLUICtrl();
00061         LLUICtrl( const LLString& name, const LLRect& rect, BOOL mouse_opaque,
00062                 LLUICtrlCallback callback,
00063                 void* callback_userdata,
00064                 U32 reshape=FOLLOWS_NONE);
00065         virtual ~LLUICtrl();
00066 
00067         // LLView interface
00068         //virtual BOOL  handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect);
00069         virtual void    initFromXML(LLXMLNodePtr node, LLView* parent);
00070         virtual LLXMLNodePtr getXML(bool save_children = true) const;
00071 
00072         virtual LLSD    getValue() const { return LLSD(); }
00073 
00074         // Defaults to no-op
00075         virtual BOOL    setTextArg( const LLString& key, const LLStringExplicit& text );
00076 
00077         // Defaults to no-op
00078         virtual BOOL    setLabelArg( const LLString& key, const LLStringExplicit& text );
00079 
00080         // Defaults to return NULL
00081         virtual LLCtrlSelectionInterface* getSelectionInterface();
00082         virtual LLCtrlListInterface* getListInterface();
00083         virtual LLCtrlScrollInterface* getScrollInterface();
00084 
00085         virtual void    setFocus( BOOL b );
00086         virtual BOOL    hasFocus() const;
00087 
00088         virtual void    setTabStop( BOOL b );
00089         virtual BOOL    hasTabStop() const;
00090 
00091         // Defaults to false
00092         virtual BOOL    acceptsTextInput() const;
00093 
00094         // Default to no-op
00095         virtual void    onTabInto();
00096         virtual void    clear();
00097 
00098         virtual void    setIsChrome(BOOL is_chrome);
00099         virtual BOOL    getIsChrome() const;
00100 
00101         virtual void    onCommit();
00102 
00103         virtual BOOL    isCtrl() const  { return TRUE; }
00104         // "Tentative" controls have a proposed value, but haven't committed
00105         // it yet.  This is used when multiple objects are selected and we
00106         // want to display a parameter that differs between the objects.
00107         virtual void    setTentative(BOOL b);
00108         virtual BOOL    getTentative() const;
00109 
00110         // Returns containing panel/floater or NULL if none found.
00111         LLPanel*                getParentPanel() const;
00112 
00113         void*                   getCallbackUserData() const                                                             { return mCallbackUserData; }
00114         void                    setCallbackUserData( void* data )                                               { mCallbackUserData = data; }
00115         
00116         void                    setCommitCallback( void (*cb)(LLUICtrl*, void*) )               { mCommitCallback = cb; }
00117         void                    setValidateBeforeCommit( BOOL(*cb)(LLUICtrl*, void*) )  { mValidateCallback = cb; }
00118 
00119         // Defaults to no-op!
00120         virtual void    setDoubleClickCallback( void (*cb)(void*) );
00121 
00122         // Defaults to no-op
00123         virtual void    setColor(const LLColor4& color);
00124 
00125         // Defaults to no-op
00126         virtual void    setMinValue(LLSD min_value);
00127         virtual void    setMaxValue(LLSD max_value);
00128 
00129         // In general, only LLPanel uses these.
00130         void                    setFocusLostCallback(void (*cb)(LLUICtrl* caller, void* user_data)) { mFocusLostCallback = cb; }
00131         void                    setFocusReceivedCallback( void (*cb)(LLUICtrl*, void*) )        { mFocusReceivedCallback = cb; }
00132         void                    setFocusChangedCallback( void (*cb)(LLUICtrl*, void*) )         { mFocusChangedCallback = cb; }
00133 
00134         static void             onFocusLostCallback(LLUICtrl* old_focus);
00135 
00136         /*virtual*/ BOOL focusFirstItem(BOOL prefer_text_fields = FALSE );
00137 
00138         class LLTabStopPostFilter : public LLQueryFilter, public LLSingleton<LLTabStopPostFilter>
00139         {
00140                 /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const 
00141                 {
00142                         return filterResult_t(view->isCtrl() && static_cast<const LLUICtrl *>(view)->hasTabStop() && children.size() == 0, TRUE);
00143                 }
00144         };
00145 
00146         class LLTextInputFilter : public LLQueryFilter, public LLSingleton<LLTextInputFilter>
00147         {
00148                 /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const 
00149                 {
00150                         return filterResult_t(view->isCtrl() && static_cast<const LLUICtrl *>(view)->acceptsTextInput(), TRUE);
00151                 }
00152         };
00153 
00154         // Returns TRUE if the user has modified this control.   Editable controls should override this.
00155         virtual BOOL    isDirty() const                 { return FALSE;         };
00156         // Clear the dirty state
00157         virtual void    resetDirty()                    {};
00158 
00159 protected:
00160         virtual void    onFocusReceived();
00161         virtual void    onFocusLost();
00162         void                    onChangeFocus( S32 direction );
00163 
00164 protected:
00165 
00166         void                    (*mCommitCallback)( LLUICtrl* ctrl, void* userdata );
00167         void                    (*mFocusLostCallback)( LLUICtrl* caller, void* userdata );
00168         void                    (*mFocusReceivedCallback)( LLUICtrl* ctrl, void* userdata );
00169         void                    (*mFocusChangedCallback)( LLUICtrl* ctrl, void* userdata );
00170         BOOL                    (*mValidateCallback)( LLUICtrl* ctrl, void* userdata );
00171 
00172         void*                   mCallbackUserData;
00173         BOOL                    mTentative;
00174         BOOL                    mTabStop;
00175 
00176 private:
00177         BOOL                    mIsChrome;
00178 
00179 
00180 };
00181 
00182 #endif  // LL_LLUICTRL_H

Generated on Thu Jul 1 06:09:24 2010 for Second Life Viewer by  doxygen 1.4.7