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 "llfontgl.h"
00039 #include "lluistring.h"
00040
00041 class LLUICtrlFactory;
00042
00043
00044 class LLTextBox
00045 : public LLUICtrl
00046 {
00047 public:
00048
00049
00050
00051 LLTextBox(const LLString& name, const LLRect& rect, const LLString& text = LLString::null,
00052 const LLFontGL* font = NULL, BOOL mouse_opaque = TRUE );
00053
00054
00055 LLTextBox(const LLString& name, const LLString& text, F32 max_width = 200,
00056 const LLFontGL* font = NULL, BOOL mouse_opaque = TRUE );
00057
00058 virtual ~LLTextBox();
00059 virtual EWidgetType getWidgetType() const;
00060 virtual LLString getWidgetTag() const;
00061 virtual LLXMLNodePtr getXML(bool save_children = true) const;
00062 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, 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
00070 void setColor( const LLColor4& c ) { mTextColor = c; }
00071 void setDisabledColor( const LLColor4& c) { mDisabledColor = c; }
00072 void setBackgroundColor( const LLColor4& c) { mBackgroundColor = c; }
00073 void setBorderColor( const LLColor4& c) { mBorderColor = c; }
00074 void setText( const LLStringExplicit& text );
00075 void setWrappedText(const LLStringExplicit& text, F32 max_width = -1.0);
00076
00077
00078 void setBackgroundVisible(BOOL visible) { mBackgroundVisible = visible; }
00079 void setBorderVisible(BOOL visible) { mBorderVisible = visible; }
00080 void setFontStyle(U8 style) { mFontStyle = style; }
00081 void setBorderDropshadowVisible(BOOL visible){ mBorderDropShadowVisible = visible; }
00082 void setHPad(S32 pixels) { mHPad = pixels; }
00083 void setVPad(S32 pixels) { mVPad = pixels; }
00084 void setRightAlign() { mHAlign = LLFontGL::RIGHT; }
00085 void setHAlign( LLFontGL::HAlign align ) { mHAlign = align; }
00086 void setClickedCallback( void (*cb)(void *data) ){ mClickedCallback = cb; }
00087 void setCallbackUserData( void* data ) { mCallbackUserData = data; }
00088
00089 const LLFontGL* getFont() const { return mFontGL; }
00090
00091 void reshapeToFitText();
00092
00093 const LLString& getText() const { return mText.getString(); }
00094 S32 getTextPixelWidth();
00095 S32 getTextPixelHeight();
00096
00097
00098 virtual void setValue(const LLSD& value );
00099 virtual LLSD getValue() const;
00100 virtual BOOL setTextArg( const LLString& key, const LLStringExplicit& text );
00101
00102 protected:
00103 void setLineLengths();
00104 void drawText(S32 x, S32 y, const LLColor4& color );
00105
00106 protected:
00107 LLUIString mText;
00108 const LLFontGL* mFontGL;
00109 LLColor4 mTextColor;
00110 LLColor4 mDisabledColor;
00111
00112 LLColor4 mBackgroundColor;
00113 LLColor4 mBorderColor;
00114
00115 BOOL mBackgroundVisible;
00116 BOOL mBorderVisible;
00117
00118 U8 mFontStyle;
00119 BOOL mBorderDropShadowVisible;
00120
00121 S32 mHPad;
00122 S32 mVPad;
00123 LLFontGL::HAlign mHAlign;
00124 LLFontGL::VAlign mVAlign;
00125
00126 std::vector<S32> mLineLengthList;
00127 void (*mClickedCallback)(void* data );
00128 void* mCallbackUserData;
00129 };
00130
00131 #endif