00001
00032
00033
00034
00035 #ifndef LL_LLCOMBOBOX_H
00036 #define LL_LLCOMBOBOX_H
00037
00038 #include "llbutton.h"
00039 #include "lluictrl.h"
00040 #include "llctrlselectioninterface.h"
00041 #include "llimagegl.h"
00042 #include "llrect.h"
00043
00044
00045
00046 class LLFontGL;
00047 class LLButton;
00048 class LLSquareButton;
00049 class LLScrollListCtrl;
00050 class LLLineEditor;
00051 class LLViewBorder;
00052
00053 extern S32 LLCOMBOBOX_HEIGHT;
00054 extern S32 LLCOMBOBOX_WIDTH;
00055
00056 class LLComboBox
00057 : public LLUICtrl, public LLCtrlListInterface
00058 {
00059 public:
00060 typedef enum e_preferred_position
00061 {
00062 ABOVE,
00063 BELOW
00064 } EPreferredPosition;
00065
00066 LLComboBox(
00067 const LLString& name,
00068 const LLRect &rect,
00069 const LLString& label,
00070 void (*commit_callback)(LLUICtrl*, void*) = NULL,
00071 void *callback_userdata = NULL
00072 );
00073 virtual ~LLComboBox();
00074
00075
00076 virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_COMBO_BOX; }
00077 virtual LLString getWidgetTag() const { return LL_COMBO_BOX_TAG; }
00078 virtual LLXMLNodePtr getXML(bool save_children = true) const;
00079 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00080
00081 virtual void draw();
00082 virtual void onFocusLost();
00083
00084 virtual void setEnabled(BOOL enabled);
00085
00086 virtual BOOL handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect);
00087 virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
00088 virtual BOOL handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent);
00089
00090
00091 virtual void clear();
00092 virtual void onCommit();
00093 virtual BOOL acceptsTextInput() const { return mAllowTextEntry; }
00094 virtual BOOL isDirty() const;
00095 virtual void resetDirty();
00096
00097 virtual void setFocus(BOOL b);
00098
00099
00100
00101 virtual void setValue(const LLSD& value );
00102
00103
00104
00105 virtual LLSD getValue() const;
00106
00107 void setAllowTextEntry(BOOL allow, S32 max_chars = 50, BOOL make_tentative = TRUE);
00108 void setTextEntry(const LLStringExplicit& text);
00109
00110 void add(const LLString& name, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE);
00111 void add(const LLString& name, const LLUUID& id, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE);
00112 void add(const LLString& name, void* userdata, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE);
00113 void add(const LLString& name, LLSD value, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE);
00114 BOOL remove( S32 index );
00115 void removeall() { clearRows(); }
00116
00117 void sortByName();
00118
00119
00120 BOOL setSimple(const LLStringExplicit& name);
00121
00122 const LLString& getSimple() const;
00123
00124 const LLString& getSimpleSelectedItem(S32 column = 0) const;
00125
00126
00127
00128 void setLabel(const LLStringExplicit& name);
00129
00130 BOOL remove(const LLString& name);
00131
00132 BOOL setCurrentByIndex( S32 index );
00133 S32 getCurrentIndex() const;
00134
00135
00136 LLCtrlSelectionInterface* getSelectionInterface() { return (LLCtrlSelectionInterface*)this; };
00137 LLCtrlListInterface* getListInterface() { return (LLCtrlListInterface*)this; };
00138
00139
00140
00141 virtual S32 getItemCount() const;
00142
00143 virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM);
00144 virtual void clearColumns();
00145 virtual void setColumnLabel(const LLString& column, const LLString& label);
00146 virtual LLScrollListItem* addElement(const LLSD& value, EAddPosition pos = ADD_BOTTOM, void* userdata = NULL);
00147 virtual LLScrollListItem* addSimpleElement(const LLString& value, EAddPosition pos = ADD_BOTTOM, const LLSD& id = LLSD());
00148 virtual void clearRows();
00149 virtual void sortByColumn(LLString name, BOOL ascending);
00150
00151
00152 virtual BOOL getCanSelect() const { return TRUE; }
00153 virtual BOOL selectFirstItem() { return setCurrentByIndex(0); }
00154 virtual BOOL selectNthItem( S32 index ) { return setCurrentByIndex(index); }
00155 virtual S32 getFirstSelectedIndex() const { return getCurrentIndex(); }
00156 virtual BOOL setCurrentByID( const LLUUID& id );
00157 virtual LLUUID getCurrentID();
00158 virtual BOOL setSelectedByValue(LLSD value, BOOL selected);
00159 virtual LLSD getSimpleSelectedValue();
00160 virtual BOOL isSelected(LLSD value);
00161 virtual BOOL operateOnSelection(EOperation op);
00162 virtual BOOL operateOnAll(EOperation op);
00163
00164
00165
00166 void* getCurrentUserdata();
00167
00168 void setPrearrangeCallback( void (*cb)(LLUICtrl*,void*) ) { mPrearrangeCallback = cb; }
00169 void setTextEntryCallback( void (*cb)(LLLineEditor*, void*) ) { mTextEntryCallback = cb; }
00170
00171 void setButtonVisible(BOOL visible);
00172
00173 static void onButtonDown(void *userdata);
00174 static void onItemSelected(LLUICtrl* item, void *userdata);
00175 static void onListFocusChanged(LLUICtrl* item, void *userdata);
00176 static void onTextEntry(LLLineEditor* line_editor, void* user_data);
00177 static void onTextCommit(LLUICtrl* caller, void* user_data);
00178
00179 void updateSelection();
00180 virtual void showList();
00181 virtual void hideList();
00182
00183 protected:
00184 LLButton* mButton;
00185 LLScrollListCtrl* mList;
00186 LLViewBorder* mBorder;
00187 BOOL mKeyboardFocusOnClick;
00188 BOOL mDrawArrow;
00189 LLLineEditor* mTextEntry;
00190 LLPointer<LLImageGL> mArrowImage;
00191 S32 mArrowImageWidth;
00192 BOOL mAllowTextEntry;
00193 S32 mMaxChars;
00194 BOOL mTextEntryTentative;
00195 EPreferredPosition mListPosition;
00196 void (*mPrearrangeCallback)(LLUICtrl*,void*);
00197 void (*mTextEntryCallback)(LLLineEditor*, void*);
00198 };
00199
00200 #endif