00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GUIFLOWMENU_H
00023 #define GUIFLOWMENU_H
00024
00025 #include <map>
00026 #include "guibackground.h"
00027
00034 class GuiFlowMenuItem;
00035
00044 class GuiFlowMenu: public GuiFlowWindow
00045 {
00046 public:
00061 DECLSPEC GuiFlowMenu(TiXmlElement *el, GuiElement *p);
00062 virtual DECLSPEC ~GuiFlowMenu();
00063
00064 virtual const char *getClassName() { return "GuiFlowMenu"; }
00066 long getActiveItemID() {return nID;}
00068 GuiFlowMenuItem *getActiveItem() {return mapMenues[nID];}
00073 void setFlyTime(Uint32 t) {nTime = t;}
00079 void setShowRect(const SDL_Rect &r) {rShow = r;}
00085 void setDisappearRect(const SDL_Rect &r) {rDisappear = r;}
00087 DECLSPEC void appear();
00089 DECLSPEC void disappear();
00098 void setChooseNextCallback(const BasicObject::FunctionData &fd) {cbChooseNext = fd;}
00109 void setNoNextCallback(const BasicObject::FunctionData &fd) {cbNoNext = fd;}
00117 void setFlewInCallback(const BasicObject::FunctionData &fd) {cbFlewIn = fd;}
00123 void setBackCallback(const BasicObject::FunctionData &fd) {cbBack = fd;}
00124
00125 static void newguiobject(void *presult, BasicObject *o, void *xmldata)
00126 {
00127 GuiElement *r = new GuiFlowMenu((TiXmlElement*)xmldata, (GuiElement*)o);
00128 *(GuiElement**)presult = r;
00129 }
00130 static void flyout_back(void *sender, BasicObject *aim, void *)
00131 {
00132 ((GuiFlowMenu*)aim)->fly('b');
00133 }
00134 static void flyout_next(void *sender, BasicObject *aim, void *)
00135 {
00136 ((GuiFlowMenu*)aim)->fly('n', sender);
00137 }
00138 static void flyout_disappear(void *sender, BasicObject *aim, void *)
00139 {
00140 ((GuiFlowMenu*)aim)->fly('d');
00141 }
00142 static void flyin(void *sender, BasicObject *aim, void *)
00143 {
00144 ((GuiFlowMenu*)aim)->fly('s');
00145 }
00146
00148 static const long ID_INVALID;
00149
00150 protected:
00151 virtual DECLSPEC void onInit();
00152 virtual DECLSPEC Uint32 onPosReached();
00153
00154 private:
00162 DECLSPEC bool registerItem(long id, GuiFlowMenuItem * el);
00168 DECLSPEC void unregisterItem(long id);
00169
00170
00171 DECLSPEC void fly(char where_to, void *param = NULL);
00172 void createItemsByFile();
00173 bool showItem(long id, bool savehistory);
00174 long getIDbySender( BasicObject *sender );
00175
00176 char *strXmlFilename;
00177 TiXmlDocument xmlFile;
00178 BasicObject::FunctionData cbFlewIn, cbDisappear, cbBack,
00179 cbChooseNext,
00180 cbNoNext;
00181
00182 SDL_Rect rShow, rDisappear;
00183
00184 std::map<long, GuiFlowMenuItem*> mapMenues;
00185 long nID, nIDnext;
00186 GuiFlowMenuItem *pCurr;
00187
00188 std::list<long> lLastItemIDs;
00189
00190 enum MenuState{sNone = '-', sShow = 's', sBack = 'b', sNext = 'n', sDisappeared = 'd'} state;
00191
00192 friend class GuiFlowMenuItem;
00193 };
00194
00199 class GuiFlowMenuItem : public GuiElement
00200 {
00201 public:
00208 GuiFlowMenuItem( TiXmlElement *el, GuiFlowMenu *parent );
00215 GuiFlowMenuItem( const SDL_Rect &r, GuiFlowMenu *parent, const char *name, long id );
00216 virtual ~GuiFlowMenuItem();
00218 long getID() {return nID;}
00222 bool activatorCompare( BasicObject *obj );
00228 void setBackRect(const SDL_Rect &r) {rBack = r;}
00234 void setNextRect(const SDL_Rect &r) {rNext = r;}
00238 const SDL_Rect &getRectNext() {return rNext;}
00242 const SDL_Rect &getRectBack() {return rBack;}
00243
00244
00245 static void newguiobject(void *presult, BasicObject *o, void *xmldata)
00246 {
00247 GuiElement *r = new GuiFlowMenuItem((TiXmlElement*)xmldata, (GuiFlowMenu*)o);
00248 *(GuiElement**)presult = r;
00249 }
00250
00251 protected:
00252 virtual void onInit();
00253
00254 private:
00255 long nID;
00256 bool bFailed;
00257 char *strActivator;
00258 SDL_Rect rNext, rBack;
00259 };
00260
00261
00262 #endif