|
csbutton.h00001 /* 00002 Crystal Space Windowing System: button class 00003 Copyright (C) 1998,1999 by Andrew Zabolotny <bit@eltech.ru> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library 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 GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 00019 */ 00020 00021 #ifndef __CSBUTTON_H__ 00022 #define __CSBUTTON_H__ 00023 00024 #include "cscomp.h" 00025 00027 #define CSBS_SHIFT 0x00000001 00028 00029 #define CSBS_DEFAULT 0x00000002 00030 00031 #define CSBS_NODEFAULTBORDER 0x00000004 00032 00033 #define CSBS_SELECTABLE 0x00000008 00034 00035 #define CSBS_NOMOUSEFOCUS 0x00000010 00036 00037 #define CSBS_NOKEYBOARDFOCUS 0x00000020 00038 00044 #define CSBS_MULTICHOOSE 0x00000040 00045 00046 #define CSBS_DISMISS 0x00000080 00047 00048 #define CSBS_TEXTPLACEMENT 0x00030000 00049 00050 #define CSBS_TEXTABOVE 0x00000000 00051 00052 #define CSBS_TEXTBELOW 0x00010000 00053 00054 #define CSBS_TEXTONTOP 0x00020000 00055 00057 #define CSBS_DEFAULTVALUE (CSBS_SHIFT | CSBS_SELECTABLE | \ 00058 CSBS_TEXTBELOW) 00059 00060 enum 00061 { 00070 cscmdButtonDown = 0x00000500, 00079 cscmdButtonUp, 00088 cscmdButtonRightClick, 00097 cscmdButtonDeselect 00098 }; 00099 00101 enum csButtonFrameStyle 00102 { 00104 csbfsNone, 00106 csbfsOblique, 00108 csbfsThickRect, 00110 csbfsThinRect, 00112 csbfsVeryThinRect, 00114 csbfsTextured, 00116 csbfsBitmap 00117 }; 00118 00123 class csButton : public csComponent 00124 { 00125 protected: 00127 csPixmap *ImageNormal, *ImagePressed; 00128 00133 csPixmap *FrameNormal, *FramePressed, *FrameHighlighted; 00134 00136 bool delImages; 00138 bool delFrameImages; 00140 int CommandCode; 00142 int underline_pos; 00144 int ButtonStyle; 00146 csButtonFrameStyle FrameStyle; 00148 int TexOrgX, TexOrgY; 00150 uint8 ButtonAlpha; 00152 bool DrawTextOnHighlightOnly; 00153 00154 public: 00156 bool Pressed; 00158 bool Highlighted; 00160 csButton (csComponent *iParent, int iCommandCode, int iButtonStyle = 00161 CSBS_DEFAULTVALUE, csButtonFrameStyle iFrameStyle = csbfsOblique); 00163 virtual ~csButton (); 00164 00166 virtual void SetText (const char *iText) 00167 { PrepareLabel (iText, text, underline_pos); Invalidate (); } 00168 00170 void SetDrawTextOnHighlightOnly(bool iTOHO) 00171 { DrawTextOnHighlightOnly = iTOHO; } 00172 00174 bool GetDrawTextOnHighlightOnly() 00175 { return DrawTextOnHighlightOnly; } 00176 00182 void SetBitmap (csPixmap *iNormal, csPixmap *iPressed, bool iDelete = true); 00183 00189 void SetFrameBitmaps (csPixmap *iNormal, csPixmap *iPressed, csPixmap *iHighlighted, bool iDelete = true); 00190 00196 void SetButtonTexture (csPixmap *iNormal, csPixmap *iPressed, bool iDelete = true); 00197 00198 00200 void GetBitmap (csPixmap **iNormal, csPixmap **iPressed); 00201 00203 void GetFrameBitmaps (csPixmap **iNormal, csPixmap **iPressed, csPixmap **iHighlighted); 00204 00206 void FreeBitmaps (); 00207 00209 void FreeFrameBitmaps (); 00210 00212 virtual bool HandleEvent (iEvent &Event); 00213 00215 virtual bool PostHandleEvent (iEvent &Event); 00216 00218 virtual void SetState (int mask, bool enable); 00219 00221 virtual void SuggestSize (int &w, int &h); 00222 00224 void SetCommandCode (int iCommandCode) 00225 { CommandCode = iCommandCode; } 00226 00228 int GetCommandCode () 00229 { return CommandCode; } 00230 00232 virtual void SetPressed (bool state); 00233 00235 inline int GetButtonStyle () 00236 { return ButtonStyle; } 00237 00239 inline csButtonFrameStyle GetFrameStyle () 00240 { return FrameStyle; } 00241 00243 inline int GetUnderlinePos () 00244 { return underline_pos; } 00245 00247 inline uint8 GetAlpha() 00248 { return ButtonAlpha; } 00249 00251 void SetAlpha(uint8 iAlpha); 00252 00254 void SetTextureOrigin(int iOrgX, int iOrgy); 00255 00257 void GetTextureOrigin(int *iOrgx, int *iOrgy); 00258 00260 virtual char *GetSkinName () 00261 { return "Button"; } 00262 00263 protected: 00265 virtual void Press (); 00266 00268 bool HandleKeyPress (iEvent &Event); 00269 00271 void DeselectNeighbours (); 00272 }; 00273 00274 #endif // __CSBUTTON_H__ Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000 |