csws/cslistbx.h
Go to the documentation of this file.00001 /* 00002 Crystal Space Windowing System: list box 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 #ifndef __CS_CSLISTBX_H__ 00021 #define __CS_CSLISTBX_H__ 00022 00031 #include "csextern.h" 00032 00033 #include "cscomp.h" 00034 #include "csscrbar.h" 00035 00039 enum 00040 { 00048 cscmdListBoxStartTracking = 0x00000400, 00056 cscmdListBoxTrack, 00063 cscmdListBoxMakeVisible, 00067 cscmdListBoxClear, 00076 cscmdListBoxItemCheck, 00084 cscmdListBoxItemSet, 00094 cscmdListBoxItemSelected, 00102 cscmdListBoxItemDeselected, 00113 cscmdListBoxItemClicked, 00123 cscmdListBoxItemDoubleClicked, 00133 cscmdListBoxItemFocused, 00143 cscmdListBoxItemScrollVertically, 00150 cscmdListBoxItemSetHorizOffset, 00157 cscmdListBoxQueryFirstSelected, 00165 cscmdListBoxSelectItem 00166 }; 00167 00169 #define CSS_LISTBOXITEM_SELECTED 0x00010000 00170 00172 #define CS_LISTBOXITEMCHECK_SELECTED 0xdeadface 00173 00174 #define CS_LISTBOXITEMCHECK_UNSELECTED 0x0badf00d 00175 00180 enum csListBoxItemStyle 00181 { 00183 cslisNormal, 00185 cslisEmphasized 00186 }; 00187 00189 class CS_CSWS_EXPORT csListBoxItem : public csComponent 00190 { 00192 csListBoxItemStyle ItemStyle; 00194 int deltax; 00196 csPixmap *ItemBitmap; 00198 bool DeleteBitmap; 00200 int hOffset; 00201 00202 public: 00204 csListBoxItem (csComponent *iParent, const char *iText, int iID = 0, 00205 csListBoxItemStyle iStyle = cslisNormal); 00206 00208 virtual ~csListBoxItem (); 00209 00211 virtual bool HandleEvent (iEvent &Event); 00212 00214 virtual void SetState (int mask, bool enable); 00215 00217 virtual void SuggestSize (int &w, int &h); 00218 00220 void SetBitmap (csPixmap *iBitmap, bool iDelete = true); 00221 00223 void SetOffset (int ihOffset) 00224 { hOffset = ihOffset; Invalidate (); } 00225 00227 virtual char *GetSkinName () 00228 { return "ListboxItem"; } 00229 00234 00235 csListBoxItemStyle GetItemStyle() 00236 { return ItemStyle; } 00237 00239 int GetDeltaX() 00240 { return deltax; } 00241 00243 csPixmap *GetItemBitmap() 00244 { return ItemBitmap; } 00245 00247 int GetHOffset() 00248 { return hOffset; } 00249 00250 char *GetText() 00251 { return text; } 00252 }; 00253 00259 00260 #define CSLBS_MULTIPLESEL 0x00000001 00261 00262 #define CSLBS_HSCROLL 0x00000002 00263 00264 #define CSLBS_VSCROLL 0x00000004 00265 00267 #define CSLBS_DEFAULTVALUE CSLBS_VSCROLL 00268 00270 00271 enum csListBoxFrameStyle 00272 { 00274 cslfsNone, 00276 cslfsThinRect, 00278 cslfsThickRect, 00280 cslfsTextured, 00282 cslfsTexturedNoFrame, 00284 cslfsBitmap 00285 }; 00286 00293 class CS_CSWS_EXPORT csListBox : public csComponent 00294 { 00296 int ListBoxStyle; 00298 csListBoxFrameStyle FrameStyle; 00300 int BorderWidth, BorderHeight; 00302 csComponent *first; 00304 csComponent *firstvisible; 00306 bool selstate; 00308 int vertcount; 00310 csScrollBar *hscroll, *vscroll; 00312 csScrollBarStatus hsbstatus, vsbstatus; 00314 int deltax, maxdeltax; 00316 bool fPlaceItems; 00318 csPixmap *FrameBitmap; 00320 bool fDelFrameBitmap; 00322 uint8 FrameAlpha; 00323 00324 public: 00326 csListBox (csComponent *iParent, int iStyle = CSLBS_DEFAULTVALUE, 00327 csListBoxFrameStyle iFrameStyle = cslfsThickRect); 00328 00330 ~csListBox(); 00331 00333 virtual bool HandleEvent (iEvent &Event); 00334 00336 void PlaceItems (bool setscrollbars = true); 00337 00339 virtual bool SetRect (int xmin, int ymin, int xmax, int ymax); 00340 00342 void SuggestSize (int &w, int &h); 00343 00348 csComponent *ForEachItem (bool (*func) (csComponent *child, void *param), 00349 void *param = 0, bool iSelected = true); 00350 00352 virtual void SetState (int mask, bool enable); 00353 00355 virtual bool SetFocused (csComponent *comp); 00356 00358 virtual void Insert (csComponent *comp); 00359 00361 virtual void Delete (csComponent *comp); 00362 00364 void SetFrameBitmap(csPixmap *iFrameBitmap, bool iDelFrameBitmap=false); 00365 00367 void SetTexture(csPixmap *iTexture, bool iDelFrameBitmap=false); 00368 00370 void SetAlpha(uint8 iAlpha); 00371 00373 virtual char *GetSkinName () 00374 { return "Listbox"; } 00375 00381 00382 int GetListBoxStyle() 00383 { return ListBoxStyle; } 00384 00386 csListBoxFrameStyle GetFrameStyle() 00387 { return FrameStyle; } 00388 00390 void GetBorderSize(int *iBorderWidth, int *iBorderHeight); 00391 00393 int VerticalCount() 00394 { return vertcount; } 00395 00397 csScrollBar *GetHScroll() 00398 { return hscroll; } 00399 00401 csScrollBar *GetVScroll() 00402 { return vscroll; } 00403 00405 int GetDeltaX() 00406 { return deltax; } 00407 00409 int GetMaxDeltaX() 00410 { return maxdeltax; } 00411 00413 bool GetPlaceItemsFlag() 00414 { return fPlaceItems; } 00415 00417 csPixmap *GetFrameBitmap() 00418 { return FrameBitmap; } 00419 00421 uint8 GetAlpha() 00422 { return FrameAlpha; } 00423 00424 protected: 00426 void MakeItemVisible (csComponent *item); 00427 }; 00428 00431 #endif // __CS_CSLISTBX_H__
Generated for Crystal Space by doxygen 1.2.18