Planeshift
|
00001 /* 00002 * pawsdndbutton.h - Author: Joe Lyon 00003 * 00004 * Copyright (C) 2013 Atomic Blue ([email protected], http://www.atomicblue.org) 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation (version 2 of the License) 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * 00018 */ 00019 // pawsbutton.h: interface for the pawsDnDButton class. 00020 // 00022 00023 #ifndef PAWS_DND_BUTTON_HEADER 00024 #define PAWS_DND_BUTTON_HEADER 00025 00026 #include "paws/pawswidget.h" 00027 #include "paws/pawsbutton.h" 00028 #include "paws/pawsprogressbar.h" 00029 #include "psslotmgr.h" 00030 00031 //#include "globals.h" 00032 //#include "pscelclient.h" 00033 //#include "net/clientmsghandler.h" 00034 //#include "net/cmdhandler.h" 00035 //#include "paws/pawsnumberpromptwindow.h" 00036 00037 #define DNDBUTTON_DRAGGING 9999 00038 00045 class pawsDnDButton : public pawsButton 00046 { 00047 public: 00048 pawsDnDButton(); 00049 virtual ~pawsDnDButton(); 00050 00051 virtual bool Setup(iDocumentNode* node); 00052 bool SelfPopulate(iDocumentNode* node); 00053 00054 virtual bool OnMouseDown(int button, int modifiers, int x, int y); 00055 virtual bool OnMouseUp(int button, int modifiers, int x, int y); 00056 virtual void MouseOver(bool value); 00057 00058 virtual void Draw(); 00059 void Start(csTicks startTicks, csTicks currentTicks, csTicks duration); 00060 00061 iPawsImage* GetMaskingImage(); 00062 00063 void SetTextOffsetY( int offset ) 00064 { 00065 upTextOffsetY = offset; 00066 downTextOffsetY = offset; 00067 } 00068 int GetTextOffsetY() 00069 { 00070 return upTextOffsetY; 00071 } 00072 void SetTextOffsetX( int offset ) 00073 { 00074 upTextOffsetX = offset; 00075 downTextOffsetX = offset; 00076 } 00077 int GetTextOffsetX() 00078 { 00079 return upTextOffsetX; 00080 } 00081 void SetDrag(int isDragDrop) 00082 { 00083 dragDrop = isDragDrop; 00084 } 00085 bool PlaceItem(const char* imageName, const char* Name, const char* toolTip, const char* action); 00086 00087 csArray<csString>* GetImageNameCallback() 00088 { 00089 return ImageNameCallback; 00090 } 00091 void SetImageNameCallback(csArray<csString>* in) 00092 { 00093 ImageNameCallback=in; 00094 } 00095 00096 csArray<csString>* GetNameCallback() 00097 { 00098 return NameCallback; 00099 } 00100 void SetNameCallback(csArray<csString>* in) 00101 { 00102 NameCallback=in; 00103 } 00104 const char* GetName() 00105 { 00106 if(GetText()) 00107 return GetText(); 00108 return NULL; 00109 } 00110 00111 csArray<csString>* GetActionCallback() 00112 { 00113 return ActionCallback; 00114 } 00115 void SetActionCallback(csArray<csString>* in) 00116 { 00117 ActionCallback=in; 00118 } 00119 00120 void SetIndexBase(int indexBase) 00121 { 00122 this->indexBase=indexBase; 00123 } 00124 int GetIndexBase() 00125 { 00126 return indexBase; 00127 } 00128 00129 void SetMaskingImage(const char* image); 00130 00131 int ContainerID() 00132 { 00133 return containerID; 00134 } 00135 00136 void SetAction(const char* act) 00137 { 00138 if( act!=NULL ) 00139 { 00140 action=new csString( act ); 00141 } 00142 else 00143 { 00144 action=NULL; 00145 } 00146 } 00147 00148 void SetAction(csString* act) 00149 { 00150 if(ActionCallback) 00151 { 00152 ActionCallback->Get(id-indexBase).Replace(act); 00153 } 00154 action = act; 00155 } 00156 00157 const char* GetAction() 00158 { 00159 if(action!=NULL) 00160 { 00161 if(!action->IsEmpty()) 00162 { 00163 return action->GetData(); 00164 } 00165 } 00166 return NULL; 00167 } 00168 00169 const char* GetTooltip() 00170 { 00171 if(baseToolTip) 00172 { 00173 if(!baseToolTip.IsEmpty()) 00174 { 00175 return baseToolTip.GetData(); 00176 } 00177 } 00178 return NULL; 00179 } 00180 00181 void SetIcon( const char* icon ); 00182 const char* GetIcon(); 00183 void ClearIcon(); 00184 00185 void SetDnDLock(bool locked) 00186 { 00187 DnDLock = locked; 00188 } 00189 00190 bool GetDnDLock() 00191 { 00192 return DnDLock; 00193 } 00194 00195 /*** 00196 * Remove all contents of button. 00197 */ 00198 void Clear(); 00199 00200 /*** 00201 * Get Button index number 00202 */ 00203 int GetButtonIndex() 00204 { 00205 return id-indexBase; 00206 } 00207 00208 void SetDragDropInProgress(int val); 00209 int IsDragDropInProgress(); 00210 00211 void DrawMask(); 00212 00216 char const * GetFontName() 00217 { 00218 return fontName; 00219 } 00220 00221 void EnableBackground( bool mode ); 00222 00223 virtual void OnUpdateData(const char* /*dataname*/, PAWSData &value); 00224 00225 void SetToolTip( const char * tooltip ); 00226 00227 virtual void SetRelativeFrame(int x, int y, int width, int height); 00228 00229 void SetWarnLevel( float val, bool low ); 00230 void SetDangerLevel( float val, bool low ); 00231 void SetFlashLevel( float val, bool low ); 00232 void SetWarnMode( int ); 00233 void SetDangerMode( int ); 00234 void SetFlashMode( int ); 00235 00236 protected: 00237 psSlotManager* mgr; 00238 int dragDrop; 00239 int dragDropInProgress; 00240 csString* action; 00241 int containerID; 00242 int indexBase; 00243 int editMode; 00244 pawsWidget* Callback; 00245 csArray<csString>* ImageNameCallback; 00246 csArray<csString>* NameCallback; 00247 csArray<csString>* ActionCallback; 00248 csString backgroundBackup; 00249 csString baseToolTip; 00250 00251 float warnLevel; 00252 bool warnLow; 00253 int warnMode; 00254 00255 float dangerLevel; 00256 bool dangerLow; 00257 int dangerMode; 00258 00259 float flashLevel; 00260 bool flashLow; 00261 int flashMode; 00262 00263 virtual bool CheckKeyHandled(int keyCode); 00264 00265 bool DnDLock; // true = locked, false = enabled. 00266 pawsProgressBar* spellProgress; 00267 csTicks startTime, 00268 castingTime, 00269 lastToolTipTime; 00270 }; 00271 00272 //---------------------------------------------------------------------- 00273 CREATE_PAWS_FACTORY(pawsDnDButton); 00274 00277 #endif