Planeshift
|
00001 /* 00002 * pawsbutton.h - Author: Andrew Craig 00003 * 00004 * Copyright (C) 2003 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 pawsButton class. 00020 // 00022 00023 #ifndef PAWS_BUTTON_HEADER 00024 #define PAWS_BUTTON_HEADER 00025 00026 #include "pawswidget.h" 00027 00032 /* Types of flash buttons, used in chat window */ 00033 enum FLASH_STATE 00034 { 00035 FLASH_REGULAR = 0, 00036 FLASH_HIGHLIGHT, 00037 FLASH_SPECIAL 00038 }; 00039 00040 00043 class pawsButton : public pawsWidget 00044 { 00045 public: 00046 pawsButton(); 00047 pawsButton(const pawsButton &pb); 00048 virtual ~pawsButton(); 00049 00050 virtual bool Setup(iDocumentNode* node); 00051 bool SelfPopulate(iDocumentNode* node); 00052 00053 void SetUpImage(const csString &image); 00054 void SetDownImage(const csString &image); 00055 void SetGreyUpImage(const csString &greyUpImage); 00056 void SetGreyDownImage(const csString &greyDownImage); 00057 00058 /* Specify the image to use for special flashing in chat window */ 00059 void SetOnSpecialImage(const csString &image); 00060 00061 void SetSound(const char* sound); 00062 00063 virtual void Draw(); 00064 00065 virtual bool OnMouseEnter(); 00066 virtual bool OnMouseExit(); 00067 virtual bool OnMouseDown(int button, int modifiers, int x, int y); 00068 virtual bool OnMouseUp(int button, int modifiers, int x, int y); 00069 virtual bool OnKeyDown(utf32_char keyCode, utf32_char key, int modifiers); 00070 00071 virtual bool IsDown() 00072 { 00073 return down; 00074 } 00075 virtual void SetState(bool isDown, bool publish=true); 00076 virtual bool GetState() 00077 { 00078 return down; 00079 } 00081 virtual void SetToggle(bool t) 00082 { 00083 toggle = t; 00084 } 00085 virtual void SetEnabled(bool enabled); 00086 virtual bool IsEnabled() const; 00087 virtual void SetNotify(pawsWidget* widget); 00088 00089 void SetText(const char* text); 00090 const char* GetText() 00091 { 00092 return buttonLabel.GetData(); 00093 } 00094 00095 /* Button flashing used mainly in chatwindow */ 00096 virtual void Flash(bool state, FLASH_STATE type = FLASH_REGULAR) 00097 { 00098 if(state && !down) 00099 { 00100 flash = 1; 00101 } 00102 else 00103 { 00104 flash = 0; 00105 if(flashtype == FLASH_HIGHLIGHT) 00106 SetColour(originalFontColour); 00107 } 00108 flashtype = type; 00109 } 00110 00111 00112 protected: 00113 00114 virtual bool CheckKeyHandled(int keyCode); 00115 00117 bool down; 00118 00120 csRef<iPawsImage> pressedImage; 00121 00123 csRef<iPawsImage> releasedImage; 00124 00125 csRef<iPawsImage> greyUpImage; 00126 csRef<iPawsImage> greyDownImage; 00127 00129 csRef<iPawsImage> specialFlashImage; 00130 00132 bool toggle; 00133 00135 csString buttonLabel; 00136 00138 char keybinding; 00139 00141 pawsWidget* notify; 00142 00144 int style; 00145 00146 bool enabled; 00147 00149 int flash; 00150 00152 FLASH_STATE flashtype; 00153 00155 csString sound_click; 00156 int upTextOffsetX; 00157 int upTextOffsetY; 00158 int downTextOffsetX; 00159 int downTextOffsetY; 00160 00162 int originalFontColour; 00163 00165 bool changeOnMouseOver; 00166 }; 00167 00168 //---------------------------------------------------------------------- 00169 CREATE_PAWS_FACTORY(pawsButton); 00170 00173 #endif