00001
00033 #ifndef LL_LLPANEL_H
00034 #define LL_LLPANEL_H
00035
00036
00037 #include "llcallbackmap.h"
00038 #include "lluictrl.h"
00039 #include "llbutton.h"
00040 #include "lllineeditor.h"
00041 #include "llviewborder.h"
00042 #include "lluistring.h"
00043 #include "v4color.h"
00044 #include <list>
00045 #include <queue>
00046
00047 const S32 LLPANEL_BORDER_WIDTH = 1;
00048 const BOOL BORDER_YES = TRUE;
00049 const BOOL BORDER_NO = FALSE;
00050
00051
00052 struct LLAlertInfo
00053 {
00054 LLString mLabel;
00055 LLString::format_map_t mArgs;
00056
00057 LLAlertInfo(LLString label, LLString::format_map_t args) : mLabel(label), mArgs(args) { }
00058 LLAlertInfo(){}
00059 };
00060
00061
00062
00063
00064
00065
00066
00067
00068 class LLPanel : public LLUICtrl
00069 {
00070 public:
00071
00072
00073 LLPanel();
00074 LLPanel(const LLString& name);
00075
00076
00077 LLPanel(const LLString& name, const LLRect& rect, BOOL bordered = TRUE);
00078
00079
00080 LLPanel(const LLString& name, const LLString& rect_control, BOOL bordered = TRUE);
00081
00082 ~LLPanel();
00083
00084
00085 BOOL isPanel() const;
00086 void draw();
00087 BOOL handleKeyHere( KEY key, MASK mask );
00088 LLXMLNodePtr getXML(bool save_children = true) const;
00089
00090 virtual LLView* getChildView(const LLString& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const;
00091
00092
00093 void setFocus( BOOL b );
00094
00095
00096 virtual void refresh();
00097 virtual BOOL postBuild();
00098 virtual void clearCtrls();
00099
00100
00101 void addBorder( LLViewBorder::EBevel border_bevel = LLViewBorder::BEVEL_OUT,
00102 LLViewBorder::EStyle border_style = LLViewBorder::STYLE_LINE,
00103 S32 border_thickness = LLPANEL_BORDER_WIDTH );
00104 void removeBorder();
00105 BOOL hasBorder() const { return mBorder != NULL; }
00106 void setBorderVisible( BOOL b );
00107
00108 template <class T> void requires(LLString name)
00109 {
00110
00111 if (LLView::getChild<T>(name) == NULL)
00112 {
00113 mRequirementsError += name + "\n";
00114 }
00115 }
00116
00117
00118 void requires(LLString name)
00119 {
00120 requires<LLView>(name);
00121 }
00122 BOOL checkRequirements();
00123
00124 void setBackgroundColor( const LLColor4& color ) { mBgColorOpaque = color; }
00125 const LLColor4& getBackgroundColor() const { return mBgColorOpaque; }
00126 void setTransparentColor(const LLColor4& color) { mBgColorAlpha = color; }
00127 const LLColor4& getTransparentColor() const { return mBgColorAlpha; }
00128 void setBackgroundVisible( BOOL b ) { mBgVisible = b; }
00129 BOOL isBackgroundVisible() const { return mBgVisible; }
00130 void setBackgroundOpaque(BOOL b) { mBgOpaque = b; }
00131 BOOL isBackgroundOpaque() const { return mBgOpaque; }
00132 void setDefaultBtn(LLButton* btn = NULL);
00133 void setDefaultBtn(const LLString& id);
00134 void updateDefaultBtn();
00135 void setLabel(const LLStringExplicit& label) { mLabel = label; }
00136 LLString getLabel() const { return mLabel; }
00137
00138 void setRectControl(const LLString& rect_control) { mRectControl.assign(rect_control); }
00139 const LLString& getRectControl() const { return mRectControl; }
00140 void storeRectControl();
00141
00142 void setCtrlsEnabled(BOOL b);
00143
00144 LLHandle<LLPanel> getHandle() const { return mPanelHandle; }
00145
00146 S32 getLastTabGroup() const { return mLastTabGroup; }
00147
00148 const LLCallbackMap::map_t& getFactoryMap() const { return mFactoryMap; }
00149
00150 BOOL initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00151 void initChildrenXML(LLXMLNodePtr node, LLUICtrlFactory* factory);
00152 void setPanelParameters(LLXMLNodePtr node, LLView *parentp);
00153
00154 LLString getString(const LLString& name, const LLString::format_map_t& args = LLUIString::sNullArgs) const;
00155 LLUIString getUIString(const LLString& name) const;
00156
00157
00158
00159
00160 void childSetVisible(const LLString& name, bool visible);
00161 void childShow(const LLString& name) { childSetVisible(name, true); }
00162 void childHide(const LLString& name) { childSetVisible(name, false); }
00163 bool childIsVisible(const LLString& id) const;
00164 void childSetTentative(const LLString& name, bool tentative);
00165
00166 void childSetEnabled(const LLString& name, bool enabled);
00167 void childEnable(const LLString& name) { childSetEnabled(name, true); }
00168 void childDisable(const LLString& name) { childSetEnabled(name, false); };
00169 bool childIsEnabled(const LLString& id) const;
00170
00171 void childSetToolTip(const LLString& id, const LLString& msg);
00172 void childSetRect(const LLString& id, const LLRect &rect);
00173 bool childGetRect(const LLString& id, LLRect& rect) const;
00174
00175
00176 void childSetFocus(const LLString& id, BOOL focus = TRUE);
00177 BOOL childHasFocus(const LLString& id);
00178 void childSetFocusChangedCallback(const LLString& id, void (*cb)(LLFocusableElement*, void*), void* user_data = NULL);
00179
00180 void childSetCommitCallback(const LLString& id, void (*cb)(LLUICtrl*, void*), void* userdata = NULL );
00181 void childSetDoubleClickCallback(const LLString& id, void (*cb)(void*), void* userdata = NULL );
00182 void childSetValidate(const LLString& id, BOOL (*cb)(LLUICtrl*, void*) );
00183 void childSetUserData(const LLString& id, void* userdata);
00184
00185 void childSetColor(const LLString& id, const LLColor4& color);
00186
00187 LLCtrlSelectionInterface* childGetSelectionInterface(const LLString& id) const;
00188 LLCtrlListInterface* childGetListInterface(const LLString& id) const;
00189 LLCtrlScrollInterface* childGetScrollInterface(const LLString& id) const;
00190
00191
00192 void childSetValue(const LLString& id, LLSD value);
00193 LLSD childGetValue(const LLString& id) const;
00194
00195
00196
00197 BOOL childSetTextArg(const LLString& id, const LLString& key, const LLStringExplicit& text);
00198 BOOL childSetLabelArg(const LLString& id, const LLString& key, const LLStringExplicit& text);
00199 BOOL childSetToolTipArg(const LLString& id, const LLString& key, const LLStringExplicit& text);
00200
00201
00202 void childSetMinValue(const LLString& id, LLSD min_value);
00203 void childSetMaxValue(const LLString& id, LLSD max_value);
00204
00205
00206 void childShowTab(const LLString& id, const LLString& tabname, bool visible = true);
00207 LLPanel *childGetVisibleTab(const LLString& id) const;
00208 void childSetTabChangeCallback(const LLString& id, const LLString& tabname, void (*on_tab_clicked)(void*, bool), void *userdata);
00209
00210
00211 void childSetWrappedText(const LLString& id, const LLString& text, bool visible = true);
00212
00213
00214 void childSetText(const LLString& id, const LLStringExplicit& text) { childSetValue(id, LLSD(text)); }
00215 LLString childGetText(const LLString& id) const { return childGetValue(id).asString(); }
00216
00217
00218 void childSetKeystrokeCallback(const LLString& id, void (*keystroke_callback)(LLLineEditor* caller, void* user_data), void *user_data);
00219 void childSetPrevalidate(const LLString& id, BOOL (*func)(const LLWString &) );
00220
00221
00222 void childSetAction(const LLString& id, void(*function)(void*), void* value);
00223 void childSetActionTextbox(const LLString& id, void(*function)(void*));
00224 void childSetControlName(const LLString& id, const LLString& control_name);
00225
00226
00227 void childNotFound(const LLString& id) const;
00228 void childDisplayNotFound();
00229
00230 static void alertXml(LLString label, LLString::format_map_t args = LLString::format_map_t());
00231 static BOOL nextAlert(LLAlertInfo &alert);
00232 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00233
00234 protected:
00235
00236 LLButton* getDefaultButton() { return mDefaultBtn; }
00237 LLCallbackMap::map_t mFactoryMap;
00238
00239 private:
00240
00241 void init();
00242
00243
00244 virtual void addCtrl( LLUICtrl* ctrl, S32 tab_group );
00245 virtual void addCtrlAtEnd( LLUICtrl* ctrl, S32 tab_group);
00246
00247
00248 typedef std::set<LLString> expected_members_list_t;
00249 mutable expected_members_list_t mExpectedMembers;
00250 mutable expected_members_list_t mNewExpectedMembers;
00251
00252 LLString mRectControl;
00253 LLColor4 mBgColorAlpha;
00254 LLColor4 mBgColorOpaque;
00255 LLColor4 mDefaultBtnHighlight;
00256 BOOL mBgVisible;
00257 BOOL mBgOpaque;
00258 LLViewBorder* mBorder;
00259 LLButton* mDefaultBtn;
00260 LLString mLabel;
00261 S32 mLastTabGroup;
00262 LLRootHandle<LLPanel> mPanelHandle;
00263
00264 typedef std::map<LLString, LLUIString> ui_string_map_t;
00265 ui_string_map_t mUIStrings;
00266
00267 LLString mRequirementsError;
00268
00269 typedef std::queue<LLAlertInfo> alert_queue_t;
00270 static alert_queue_t sAlertQueue;
00271 };
00272
00273
00274 class LLLayoutStack : public LLView
00275 {
00276 public:
00277 typedef enum e_layout_orientation
00278 {
00279 HORIZONTAL,
00280 VERTICAL
00281 } eLayoutOrientation;
00282
00283 LLLayoutStack(eLayoutOrientation orientation);
00284 virtual ~LLLayoutStack();
00285
00286 void draw();
00287 LLXMLNodePtr getXML(bool save_children = true) const;
00288 void removeCtrl(LLUICtrl* ctrl);
00289
00290 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
00291
00292 S32 getMinWidth() const { return mMinWidth; }
00293 S32 getMinHeight() const { return mMinHeight; }
00294
00295 void addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL auto_resize, BOOL user_resize, S32 index = S32_MAX);
00296 void removePanel(LLPanel* panel);
00297
00298 private:
00299 struct LLEmbeddedPanel;
00300
00301 void updateLayout(BOOL force_resize = FALSE);
00302 void calcMinExtents();
00303 S32 getDefaultHeight(S32 cur_height);
00304 S32 getDefaultWidth(S32 cur_width);
00305
00306 const eLayoutOrientation mOrientation;
00307
00308 typedef std::vector<LLEmbeddedPanel*> e_panel_list_t;
00309 e_panel_list_t mPanels;
00310 LLEmbeddedPanel* findEmbeddedPanel(LLPanel* panelp) const;
00311
00312 S32 mMinWidth;
00313 S32 mMinHeight;
00314 S32 mPanelSpacing;
00315 };
00316
00317 #endif