00001 
00031 #ifndef LL_LLPANELGROUP_H
00032 #define LL_LLPANELGROUP_H
00033 
00034 #include "llgroupmgr.h"
00035 #include "llpanel.h"
00036 #include "lltimer.h"
00037 
00038 struct LLOfferInfo;
00039 
00040 const S32 UPDATE_MEMBERS_PER_FRAME = 500;
00041 
00042 
00043 class LLPanelGroupTab;
00044 class LLTabContainerCommon;
00045 class LLAgent;
00046 
00047 class LLPanelGroupTabObserver
00048 {
00049 public:
00050         LLPanelGroupTabObserver() {};
00051         virtual ~LLPanelGroupTabObserver(){};
00052         virtual void tabChanged() = 0;
00053 };
00054 
00055 class LLPanelGroup : public LLPanel,
00056                                          public LLGroupMgrObserver, 
00057                                          public LLPanelGroupTabObserver
00058 {
00059 public:
00060         LLPanelGroup(const std::string& filename,
00061                                  const std::string& name,
00062                                  const LLUUID& group_id,
00063                                  const std::string& initial_tab_selected = std::string());
00064         virtual ~LLPanelGroup();
00065 
00066         virtual BOOL postBuild();
00067 
00068         static void onBtnOK(void*);
00069         static void onBtnCancel(void*);
00070         static void onBtnApply(void*);
00071         static void onBtnRefresh(void*);
00072         static void onClickTab(void*,bool);
00073         void handleClickTab();
00074 
00075         void setGroupID(const LLUUID& group_id);
00076         void selectTab(std::string tab_name);
00077 
00078         
00079         BOOL canClose();
00080         
00081         
00082         BOOL attemptTransition();
00083         
00084         
00085         void transitionToTab();
00086 
00087         void updateTabVisibility();
00088 
00089         
00090         static void onNotifyCallback(S32 option, void* user_data);
00091         void handleNotifyCallback(S32 option);
00092 
00093         bool apply();
00094         void refreshData();
00095         void close();
00096         void draw();
00097 
00098         
00099         virtual void changed(LLGroupChange gc);
00100 
00101         
00102         virtual void tabChanged();
00103 
00104         void setAllowEdit(BOOL v) { mAllowEdit = v; }
00105 
00106         void showNotice(const char* subject,
00107                                                         const char* message,
00108                                                         const bool& has_inventory,
00109                                                         const char* inventory_name,
00110                                                         LLOfferInfo* inventory_offer);
00111 protected:
00112         LLPanelGroupTab*                mCurrentTab;
00113         LLPanelGroupTab*                mRequestedTab;
00114         LLTabContainerCommon*   mTabContainer;
00115         BOOL mIgnoreTransition;
00116 
00117         LLButton* mApplyBtn;
00118 
00119         LLTimer mRefreshTimer;
00120 
00121         BOOL mForceClose;
00122 
00123         std::string mInitialTab;
00124         std::string mFilename;
00125 
00126         LLString mDefaultNeedsApplyMesg;
00127         LLString mWantApplyMesg;
00128 
00129         BOOL mAllowEdit;
00130         BOOL mShowingNotifyDialog;
00131 };
00132 
00133 class LLPanelGroupTab : public LLPanel
00134 {
00135 public:
00136         LLPanelGroupTab(const std::string& name, const LLUUID& group_id)
00137         : LLPanel(name), mGroupID(group_id), mAllowEdit(TRUE), mHasModal(FALSE) { }
00138         virtual ~LLPanelGroupTab();
00139 
00140         
00141         static void* createTab(void* data);
00142 
00143         
00144         virtual void activate() { }
00145         
00146         
00147         virtual void deactivate() { }
00148 
00149         
00150         
00151         virtual bool needsApply(LLString& mesg) { return false; }
00152 
00153         
00154         virtual BOOL hasModal() { return mHasModal; }
00155 
00156         
00157         
00158         virtual bool apply(LLString& mesg) { return true; }
00159 
00160         
00161         virtual void cancel() { }
00162 
00163         
00164         virtual void update(LLGroupChange gc) { }
00165 
00166         
00167         virtual LLString getHelpText() const { return mHelpText; }
00168 
00169         
00170         static void onClickHelp(void* data);
00171         void handleClickHelp();
00172 
00173         
00174         virtual BOOL postBuild();
00175 
00176         virtual BOOL isVisibleByAgent(LLAgent* agentp);
00177 
00178         void setAllowEdit(BOOL v) { mAllowEdit = v; }
00179 
00180         void addObserver(LLPanelGroupTabObserver *obs);
00181         void removeObserver(LLPanelGroupTabObserver *obs);
00182         void notifyObservers();
00183 
00184 protected:
00185         LLUUID  mGroupID;
00186         LLTabContainerCommon*   mTabContainer;
00187         LLString        mHelpText;
00188 
00189         BOOL mAllowEdit;
00190         BOOL mHasModal;
00191 
00192         typedef std::set<LLPanelGroupTabObserver*> observer_list_t;
00193         observer_list_t mObservers;
00194 };
00195 
00196 #endif // LL_LLPANELGROUP_H