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 class LLFocusableElement
00042 {
00043 friend class LLFocusMgr;
00044 public:
00045 LLFocusableElement();
00046 virtual ~LLFocusableElement();
00047
00048 virtual void setFocus( BOOL b );
00049 virtual BOOL hasFocus() const;
00050
00051 void setFocusLostCallback(void (*cb)(LLFocusableElement* caller, void*), void* user_data = NULL) { mFocusLostCallback = cb; mFocusCallbackUserData = user_data; }
00052 void setFocusReceivedCallback( void (*cb)(LLFocusableElement*, void*), void* user_data = NULL) { mFocusReceivedCallback = cb; mFocusCallbackUserData = user_data; }
00053 void setFocusChangedCallback( void (*cb)(LLFocusableElement*, void*), void* user_data = NULL ) { mFocusChangedCallback = cb; mFocusCallbackUserData = user_data; }
00054
00055 protected:
00056 virtual void onFocusReceived();
00057 virtual void onFocusLost();
00058 void (*mFocusLostCallback)( LLFocusableElement* caller, void* userdata );
00059 void (*mFocusReceivedCallback)( LLFocusableElement* ctrl, void* userdata );
00060 void (*mFocusChangedCallback)( LLFocusableElement* ctrl, void* userdata );
00061 void* mFocusCallbackUserData;
00062 };
00063
00064 class LLUICtrl
00065 : public LLView, public LLFocusableElement
00066 {
00067 public:
00068 typedef void (*LLUICtrlCallback)(LLUICtrl* ctrl, void* userdata);
00069 typedef BOOL (*LLUICtrlValidate)(LLUICtrl* ctrl, void* userdata);
00070
00071 LLUICtrl();
00072 LLUICtrl( const LLString& name, const LLRect& rect, BOOL mouse_opaque,
00073 LLUICtrlCallback callback,
00074 void* callback_userdata,
00075 U32 reshape=FOLLOWS_NONE);
00076 ~LLUICtrl();
00077
00078
00079 void initFromXML(LLXMLNodePtr node, LLView* parent);
00080 LLXMLNodePtr getXML(bool save_children = true) const;
00081 BOOL setLabelArg( const LLString& key, const LLStringExplicit& text );
00082 void onFocusReceived();
00083 void onFocusLost();
00084 BOOL isCtrl() const;
00085 void setTentative(BOOL b);
00086 BOOL getTentative() const;
00087
00088
00089 void setFocus( BOOL b );
00090 BOOL hasFocus() const;
00091
00092
00093
00094
00095 virtual class LLCtrlSelectionInterface* getSelectionInterface();
00096 virtual class LLCtrlListInterface* getListInterface();
00097 virtual class LLCtrlScrollInterface* getScrollInterface();
00098
00099 virtual LLSD getValue() const;
00100 virtual BOOL setTextArg( const LLString& key, const LLStringExplicit& text );
00101 virtual void setIsChrome(BOOL is_chrome);
00102
00103 virtual BOOL acceptsTextInput() const;
00104
00105
00106
00107 virtual BOOL isDirty() const;
00108 virtual void resetDirty();
00109
00110
00111 virtual void onLostTop();
00112 virtual void onCommit();
00113
00114
00115 virtual void onTabInto();
00116 virtual void clear();
00117 virtual void setDoubleClickCallback( void (*cb)(void*) );
00118 virtual void setColor(const LLColor4& color);
00119 virtual void setMinValue(LLSD min_value);
00120 virtual void setMaxValue(LLSD max_value);
00121
00122 BOOL focusNextItem(BOOL text_entry_only);
00123 BOOL focusPrevItem(BOOL text_entry_only);
00124 BOOL focusFirstItem(BOOL prefer_text_fields = FALSE, BOOL focus_flash = TRUE );
00125 BOOL focusLastItem(BOOL prefer_text_fields = FALSE);
00126
00127
00128 BOOL getIsChrome() const;
00129
00130 void setTabStop( BOOL b );
00131 BOOL hasTabStop() const;
00132
00133
00134 class LLPanel* getParentPanel() const;
00135 class LLUICtrl* getParentUICtrl() const;
00136
00137 void* getCallbackUserData() const { return mCallbackUserData; }
00138 void setCallbackUserData( void* data ) { mCallbackUserData = data; }
00139
00140 void setCommitCallback( void (*cb)(LLUICtrl*, void*) ) { mCommitCallback = cb; }
00141 void setValidateBeforeCommit( BOOL(*cb)(LLUICtrl*, void*) ) { mValidateCallback = cb; }
00142 void setLostTopCallback( void (*cb)(LLUICtrl*, void*) ) { mLostTopCallback = cb; }
00143
00144 static LLView* fromXML(LLXMLNodePtr node, LLView* parent, class LLUICtrlFactory* factory);
00145
00146 LLUICtrl* findRootMostFocusRoot() const;
00147
00148 class LLTextInputFilter : public LLQueryFilter, public LLSingleton<LLTextInputFilter>
00149 {
00150 filterResult_t operator() (const LLView* const view, const viewList_t & children) const
00151 {
00152 return filterResult_t(view->isCtrl() && static_cast<const LLUICtrl *>(view)->acceptsTextInput(), TRUE);
00153 }
00154 };
00155
00156 protected:
00157
00158 void (*mCommitCallback)( LLUICtrl* ctrl, void* userdata );
00159 void (*mLostTopCallback)( LLUICtrl* ctrl, void* userdata );
00160 BOOL (*mValidateCallback)( LLUICtrl* ctrl, void* userdata );
00161
00162 void* mCallbackUserData;
00163
00164 private:
00165
00166 BOOL mTabStop;
00167 BOOL mIsChrome;
00168 BOOL mTentative;
00169
00170 class DefaultTabGroupFirstSorter;
00171 };
00172
00173 #endif // LL_LLUICTRL_H