lltextbox.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLTEXTBOX_H
00033 #define LL_LLTEXTBOX_H
00034 
00035 #include "lluictrl.h"
00036 #include "v4color.h"
00037 #include "llstring.h"
00038 #include "lluistring.h"
00039 
00040 
00041 class LLTextBox
00042 :       public LLUICtrl
00043 {
00044 public:
00045         // By default, follows top and left and is mouse-opaque.
00046         // If no text, text = name.
00047         // If no font, uses default system font.
00048         LLTextBox(const LLString& name, const LLRect& rect, const LLString& text,
00049                           const LLFontGL* font = NULL, BOOL mouse_opaque = TRUE );
00050 
00051         // Construct a textbox which handles word wrapping for us.
00052         LLTextBox(const LLString& name, const LLString& text, F32 max_width = 200,
00053                           const LLFontGL* font = NULL, BOOL mouse_opaque = TRUE );
00054 
00055         // "Simple" constructors for text boxes that have the same name and label *TO BE DEPRECATED*
00056         LLTextBox(const LLString& name_and_label, const LLRect& rect);
00057         LLTextBox(const LLString& name_and_label);
00058 
00059         virtual ~LLTextBox() {}
00060 
00061         virtual LLXMLNodePtr getXML(bool save_children = true) const;
00062         static LLView* fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory);
00063 
00064         virtual void    draw();
00065         virtual void    reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
00066 
00067         virtual BOOL    handleMouseDown(S32 x, S32 y, MASK mask);
00068         virtual BOOL    handleMouseUp(S32 x, S32 y, MASK mask);
00069         virtual BOOL    handleHover(S32 x, S32 y, MASK mask);
00070 
00071         void                    setColor( const LLColor4& c )                   { mTextColor = c; }
00072         void                    setDisabledColor( const LLColor4& c)    { mDisabledColor = c; }
00073         void                    setBackgroundColor( const LLColor4& c)  { mBackgroundColor = c; }       
00074         void                    setBorderColor( const LLColor4& c)              { mBorderColor = c; }   
00075 
00076         void                    setHoverColor( const LLColor4& c )              { mHoverColor = c; }
00077         void                    setHoverActive( BOOL active )                   { mHoverActive = active; }
00078 
00079         void                    setText( const LLStringExplicit& text );
00080         void                    setWrappedText(const LLStringExplicit& text, F32 max_width = -1.0); // -1 means use existing control width
00081         void                    setUseEllipses( BOOL use_ellipses )             { mUseEllipses = use_ellipses; }
00082         
00083         void                    setBackgroundVisible(BOOL visible)              { mBackgroundVisible = visible; }
00084         void                    setBorderVisible(BOOL visible)                  { mBorderVisible = visible; }
00085         void                    setFontStyle(U8 style)                                  { mFontStyle = style; }
00086         void                    setBorderDropshadowVisible(BOOL visible){ mBorderDropShadowVisible = visible; }
00087         void                    setHPad(S32 pixels)                                             { mHPad = pixels; }
00088         void                    setVPad(S32 pixels)                                             { mVPad = pixels; }
00089         void                    setRightAlign()                                                 { mHAlign = LLFontGL::RIGHT; }
00090         void                    setHAlign( LLFontGL::HAlign align )             { mHAlign = align; }
00091         void                    setClickedCallback( void (*cb)(void *data) ){ mClickedCallback = cb; }          // mouse down and up within button
00092         void                    setCallbackUserData( void* data )               { mCallbackUserData = data; }
00093 
00094         const LLFontGL* getFont() const                                                 { return mFontGL; }
00095 
00096         void                    reshapeToFitText();
00097 
00098         const LLString& getText() const                                                 { return mText.getString(); }
00099         S32                             getTextPixelWidth();
00100         S32                             getTextPixelHeight();
00101 
00102         virtual void    setValue(const LLSD& value )                    { setText(value.asString()); }
00103         virtual LLSD    getValue() const                                                { return LLSD(getText()); }
00104         virtual BOOL    setTextArg( const LLString& key, const LLStringExplicit& text );
00105 
00106 private:
00107         void                    setLineLengths();
00108         void                    drawText(S32 x, S32 y, const LLColor4& color );
00109 
00110         LLUIString              mText;
00111         const LLFontGL* mFontGL;
00112         LLColor4                mTextColor;
00113         LLColor4                mDisabledColor;
00114         LLColor4                mBackgroundColor;
00115         LLColor4                mBorderColor;
00116         LLColor4                mHoverColor;
00117 
00118         BOOL                    mHoverActive;   
00119         BOOL                    mHasHover;
00120         BOOL                    mBackgroundVisible;
00121         BOOL                    mBorderVisible;
00122         
00123         U8                              mFontStyle; // style bit flags for font
00124         BOOL                    mBorderDropShadowVisible;
00125         BOOL                    mUseEllipses;
00126 
00127         S32                             mHPad;
00128         S32                             mVPad;
00129         LLFontGL::HAlign mHAlign;
00130         LLFontGL::VAlign mVAlign;
00131 
00132         std::vector<S32> mLineLengthList;
00133         void                    (*mClickedCallback)(void* data );
00134         void*                   mCallbackUserData;
00135 };
00136 
00137 #endif

Generated on Fri May 16 08:32:58 2008 for SecondLife by  doxygen 1.5.5