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
00077 virtual LLXMLNodePtr getXML(bool save_children = true) const;
00078 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00079
00080 virtual void draw();
00081 virtual void onFocusLost();
00082 virtual void onLostTop();
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);
00088 virtual BOOL handleUnicodeCharHere(llwchar uni_char);
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 LLScrollListItem* add(const LLString& name, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE);
00111 LLScrollListItem* add(const LLString& name, const LLUUID& id, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE);
00112 LLScrollListItem* add(const LLString& name, void* userdata, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE);
00113 LLScrollListItem* add(const LLString& name, LLSD value, EAddPosition pos = ADD_BOTTOM, BOOL enabled = TRUE);
00114 LLScrollListItem* addSeparator(EAddPosition pos = ADD_BOTTOM);
00115 BOOL remove( S32 index );
00116 void removeall() { clearRows(); }
00117
00118 void sortByName();
00119
00120
00121 BOOL setSimple(const LLStringExplicit& name);
00122
00123 const LLString getSimple() const;
00124
00125 const LLString getSelectedItemLabel(S32 column = 0) const;
00126
00127
00128
00129 void setLabel(const LLStringExplicit& name);
00130
00131 BOOL remove(const LLString& name);
00132
00133 BOOL setCurrentByIndex( S32 index );
00134 S32 getCurrentIndex() const;
00135
00136 virtual void updateLayout();
00137
00138
00139 LLCtrlSelectionInterface* getSelectionInterface() { return (LLCtrlSelectionInterface*)this; };
00140 LLCtrlListInterface* getListInterface() { return (LLCtrlListInterface*)this; };
00141
00142
00143
00144 virtual S32 getItemCount() const;
00145
00146 virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM);
00147 virtual void clearColumns();
00148 virtual void setColumnLabel(const LLString& column, const LLString& label);
00149 virtual LLScrollListItem* addElement(const LLSD& value, EAddPosition pos = ADD_BOTTOM, void* userdata = NULL);
00150 virtual LLScrollListItem* addSimpleElement(const LLString& value, EAddPosition pos = ADD_BOTTOM, const LLSD& id = LLSD());
00151 virtual void clearRows();
00152 virtual void sortByColumn(LLString name, BOOL ascending);
00153
00154
00155 virtual BOOL getCanSelect() const { return TRUE; }
00156 virtual BOOL selectFirstItem() { return setCurrentByIndex(0); }
00157 virtual BOOL selectNthItem( S32 index ) { return setCurrentByIndex(index); }
00158 virtual BOOL selectItemRange( S32 first, S32 last );
00159 virtual S32 getFirstSelectedIndex() const { return getCurrentIndex(); }
00160 virtual BOOL setCurrentByID( const LLUUID& id );
00161 virtual LLUUID getCurrentID() const;
00162 virtual BOOL setSelectedByValue(const LLSD& value, BOOL selected);
00163 virtual LLSD getSelectedValue();
00164 virtual BOOL isSelected(const LLSD& value) const;
00165 virtual BOOL operateOnSelection(EOperation op);
00166 virtual BOOL operateOnAll(EOperation op);
00167
00168
00169
00170 void* getCurrentUserdata();
00171
00172 void setPrearrangeCallback( void (*cb)(LLUICtrl*,void*) ) { mPrearrangeCallback = cb; }
00173 void setTextEntryCallback( void (*cb)(LLLineEditor*, void*) ) { mTextEntryCallback = cb; }
00174
00175 void setButtonVisible(BOOL visible);
00176
00177 static void onButtonDown(void *userdata);
00178 static void onItemSelected(LLUICtrl* item, void *userdata);
00179 static void onTextEntry(LLLineEditor* line_editor, void* user_data);
00180 static void onTextCommit(LLUICtrl* caller, void* user_data);
00181
00182 void updateSelection();
00183 virtual void showList();
00184 virtual void hideList();
00185
00186 protected:
00187 LLButton* mButton;
00188 LLScrollListCtrl* mList;
00189 EPreferredPosition mListPosition;
00190 LLPointer<LLUIImage> mArrowImage;
00191
00192 private:
00193 S32 mButtonPadding;
00194 LLLineEditor* mTextEntry;
00195 BOOL mAllowTextEntry;
00196 S32 mMaxChars;
00197 BOOL mTextEntryTentative;
00198 void (*mPrearrangeCallback)(LLUICtrl*,void*);
00199 void (*mTextEntryCallback)(LLLineEditor*, void*);
00200 };
00201
00202 class LLFlyoutButton : public LLComboBox
00203 {
00204 public:
00205 LLFlyoutButton(
00206 const LLString& name,
00207 const LLRect &rect,
00208 const LLString& label,
00209 void (*commit_callback)(LLUICtrl*, void*) = NULL,
00210 void *callback_userdata = NULL);
00211
00212 virtual void updateLayout();
00213 virtual void draw();
00214 virtual void setEnabled(BOOL enabled);
00215
00216 void setToggleState(BOOL state);
00217
00218 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00219 static void onActionButtonClick(void *userdata);
00220 static void onSelectAction(LLUICtrl* ctrl, void *userdata);
00221
00222 protected:
00223 LLButton* mActionButton;
00224 LLPointer<LLUIImage> mActionButtonImage;
00225 LLPointer<LLUIImage> mExpanderButtonImage;
00226 LLPointer<LLUIImage> mActionButtonImageSelected;
00227 LLPointer<LLUIImage> mExpanderButtonImageSelected;
00228 LLPointer<LLUIImage> mActionButtonImageDisabled;
00229 LLPointer<LLUIImage> mExpanderButtonImageDisabled;
00230 BOOL mToggleState;
00231 };
00232
00233 #endif