csws/csbutton.h
Go to the documentation of this file.00001 /* 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 __CS_CSBUTTON_H__ 00022 #define __CS_CSBUTTON_H__ 00023 00032 #include "cscomp.h" 00033 00037 00038 #define CSBS_SHIFT 0x00000001 00039 00040 #define CSBS_DEFAULT 0x00000002 00041 00042 #define CSBS_NODEFAULTBORDER 0x00000004 00043 00044 #define CSBS_SELECTABLE 0x00000008 00045 00046 #define CSBS_NOMOUSEFOCUS 0x00000010 00047 00048 #define CSBS_NOKEYBOARDFOCUS 0x00000020 00049 00055 #define CSBS_MULTICHOOSE 0x00000040 00056 00057 #define CSBS_DISMISS 0x00000080 00058 00059 #define CSBS_TEXTPLACEMENT 0x00030000 00060 00061 #define CSBS_TEXTABOVE 0x00000000 00062 00063 #define CSBS_TEXTBELOW 0x00010000 00064 00065 #define CSBS_TEXTONTOP 0x00020000 00066 00068 #define CSBS_DEFAULTVALUE \ 00069 (CSBS_SHIFT | CSBS_SELECTABLE | CSBS_TEXTBELOW) 00070 00073 00074 enum 00075 { 00084 cscmdButtonDown = 0x00000500, 00093 cscmdButtonUp, 00102 cscmdButtonRightClick, 00111 cscmdButtonDeselect 00112 }; 00113 00115 enum csButtonFrameStyle 00116 { 00118 csbfsNone, 00120 csbfsOblique, 00122 csbfsThickRect, 00124 csbfsThinRect, 00126 csbfsVeryThinRect, 00128 csbfsTextured, 00130 csbfsBitmap 00131 }; 00132 00137 class csButton : public csComponent 00138 { 00139 protected: 00141 csPixmap *ImageNormal, *ImagePressed; 00142 00147 csPixmap *FrameNormal, *FramePressed, *FrameHighlighted; 00148 00150 bool delImages; 00152 bool delFrameImages; 00154 int CommandCode; 00156 int underline_pos; 00158 int ButtonStyle; 00160 csButtonFrameStyle FrameStyle; 00162 int TexOrgX, TexOrgY; 00164 uint8 ButtonAlpha; 00166 bool DrawTextOnHighlightOnly; 00167 00168 public: 00170 bool Pressed; 00172 bool Highlighted; 00174 csButton (csComponent *iParent, int iCommandCode, int iButtonStyle = 00175 CSBS_DEFAULTVALUE, csButtonFrameStyle iFrameStyle = csbfsOblique); 00177 virtual ~csButton (); 00178 00180 virtual void SetText (const char *iText) 00181 { PrepareLabel (iText, text, underline_pos); Invalidate (); } 00182 00184 void SetDrawTextOnHighlightOnly(bool iTOHO) 00185 { DrawTextOnHighlightOnly = iTOHO; } 00186 00188 bool GetDrawTextOnHighlightOnly() 00189 { return DrawTextOnHighlightOnly; } 00190 00196 void SetBitmap (csPixmap *iNormal, csPixmap *iPressed, bool iDelete = true); 00197 00203 void SetFrameBitmaps (csPixmap *iNormal, csPixmap *iPressed, csPixmap *iHighlighted, bool iDelete = true); 00204 00210 void SetButtonTexture (csPixmap *iNormal, csPixmap *iPressed, bool iDelete = true); 00211 00212 00214 void GetBitmap (csPixmap **iNormal, csPixmap **iPressed); 00215 00217 void GetFrameBitmaps (csPixmap **iNormal, csPixmap **iPressed, csPixmap **iHighlighted); 00218 00220 void FreeBitmaps (); 00221 00223 void FreeFrameBitmaps (); 00224 00226 virtual bool HandleEvent (iEvent &Event); 00227 00229 virtual bool PostHandleEvent (iEvent &Event); 00230 00232 virtual void SetState (int mask, bool enable); 00233 00235 virtual void SuggestSize (int &w, int &h); 00236 00238 void SetCommandCode (int iCommandCode) 00239 { CommandCode = iCommandCode; } 00240 00242 int GetCommandCode () 00243 { return CommandCode; } 00244 00246 virtual void SetPressed (bool state); 00247 00249 inline int GetButtonStyle () 00250 { return ButtonStyle; } 00251 00253 inline csButtonFrameStyle GetFrameStyle () 00254 { return FrameStyle; } 00255 00257 inline int GetUnderlinePos () 00258 { return underline_pos; } 00259 00261 inline uint8 GetAlpha() 00262 { return ButtonAlpha; } 00263 00265 void SetAlpha(uint8 iAlpha); 00266 00268 void SetTextureOrigin(int iOrgX, int iOrgy); 00269 00271 void GetTextureOrigin(int *iOrgx, int *iOrgy); 00272 00274 virtual char *GetSkinName () 00275 { return "Button"; } 00276 00277 protected: 00279 virtual void Press (); 00280 00282 bool HandleKeyPress (iEvent &Event); 00283 00285 void DeselectNeighbours (); 00286 }; 00287 00290 #endif // __CS_CSBUTTON_H__
Generated for Crystal Space by doxygen 1.2.18