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 "cscomp.h" 00032 #include "csscrbar.h" 00033 00037 enum 00038 { 00046 cscmdListBoxStartTracking = 0x00000400, 00054 cscmdListBoxTrack, 00061 cscmdListBoxMakeVisible, 00065 cscmdListBoxClear, 00074 cscmdListBoxItemCheck, 00082 cscmdListBoxItemSet, 00092 cscmdListBoxItemSelected, 00100 cscmdListBoxItemDeselected, 00111 cscmdListBoxItemClicked, 00121 cscmdListBoxItemDoubleClicked, 00131 cscmdListBoxItemFocused, 00141 cscmdListBoxItemScrollVertically, 00148 cscmdListBoxItemSetHorizOffset, 00155 cscmdListBoxQueryFirstSelected, 00163 cscmdListBoxSelectItem 00164 }; 00165 00167 #define CSS_LISTBOXITEM_SELECTED 0x00010000 00168 00170 #define CS_LISTBOXITEMCHECK_SELECTED 0xdeadface 00171 00172 #define CS_LISTBOXITEMCHECK_UNSELECTED 0x0badf00d 00173 00178 enum csListBoxItemStyle 00179 { 00181 cslisNormal, 00183 cslisEmphasized 00184 }; 00185 00187 class csListBoxItem : public csComponent 00188 { 00190 csListBoxItemStyle ItemStyle; 00192 int deltax; 00194 csPixmap *ItemBitmap; 00196 bool DeleteBitmap; 00198 int hOffset; 00199 00200 public: 00202 csListBoxItem (csComponent *iParent, const char *iText, int iID = 0, 00203 csListBoxItemStyle iStyle = cslisNormal); 00204 00206 virtual ~csListBoxItem (); 00207 00209 virtual bool HandleEvent (iEvent &Event); 00210 00212 virtual void SetState (int mask, bool enable); 00213 00215 virtual void SuggestSize (int &w, int &h); 00216 00218 void SetBitmap (csPixmap *iBitmap, bool iDelete = true); 00219 00221 void SetOffset (int ihOffset) 00222 { hOffset = ihOffset; Invalidate (); } 00223 00225 virtual char *GetSkinName () 00226 { return "ListboxItem"; } 00227 00232 00233 csListBoxItemStyle GetItemStyle() 00234 { return ItemStyle; } 00235 00237 int GetDeltaX() 00238 { return deltax; } 00239 00241 csPixmap *GetItemBitmap() 00242 { return ItemBitmap; } 00243 00245 int GetHOffset() 00246 { return hOffset; } 00247 00248 char *GetText() 00249 { return text; } 00250 }; 00251 00257 00258 #define CSLBS_MULTIPLESEL 0x00000001 00259 00260 #define CSLBS_HSCROLL 0x00000002 00261 00262 #define CSLBS_VSCROLL 0x00000004 00263 00265 #define CSLBS_DEFAULTVALUE CSLBS_VSCROLL 00266 00268 00269 enum csListBoxFrameStyle 00270 { 00272 cslfsNone, 00274 cslfsThinRect, 00276 cslfsThickRect, 00278 cslfsTextured, 00280 cslfsTexturedNoFrame, 00282 cslfsBitmap 00283 }; 00284 00291 class csListBox : public csComponent 00292 { 00294 int ListBoxStyle; 00296 csListBoxFrameStyle FrameStyle; 00298 int BorderWidth, BorderHeight; 00300 csComponent *first; 00302 csComponent *firstvisible; 00304 bool selstate; 00306 int vertcount; 00308 csScrollBar *hscroll, *vscroll; 00310 csScrollBarStatus hsbstatus, vsbstatus; 00312 int deltax, maxdeltax; 00314 bool fPlaceItems; 00316 csPixmap *FrameBitmap; 00318 bool fDelFrameBitmap; 00320 uint8 FrameAlpha; 00321 00322 public: 00324 csListBox (csComponent *iParent, int iStyle = CSLBS_DEFAULTVALUE, 00325 csListBoxFrameStyle iFrameStyle = cslfsThickRect); 00326 00328 ~csListBox(); 00329 00331 virtual bool HandleEvent (iEvent &Event); 00332 00334 void PlaceItems (bool setscrollbars = true); 00335 00337 virtual bool SetRect (int xmin, int ymin, int xmax, int ymax); 00338 00340 void SuggestSize (int &w, int &h); 00341 00346 csComponent *ForEachItem (bool (*func) (csComponent *child, void *param), 00347 void *param = 0, bool iSelected = true); 00348 00350 virtual void SetState (int mask, bool enable); 00351 00353 virtual bool SetFocused (csComponent *comp); 00354 00356 virtual void Insert (csComponent *comp); 00357 00359 virtual void Delete (csComponent *comp); 00360 00362 void SetFrameBitmap(csPixmap *iFrameBitmap, bool iDelFrameBitmap=false); 00363 00365 void SetTexture(csPixmap *iTexture, bool iDelFrameBitmap=false); 00366 00368 void SetAlpha(uint8 iAlpha); 00369 00371 virtual char *GetSkinName () 00372 { return "Listbox"; } 00373 00379 00380 int GetListBoxStyle() 00381 { return ListBoxStyle; } 00382 00384 csListBoxFrameStyle GetFrameStyle() 00385 { return FrameStyle; } 00386 00388 void GetBorderSize(int *iBorderWidth, int *iBorderHeight); 00389 00391 int VerticalCount() 00392 { return vertcount; } 00393 00395 csScrollBar *GetHScroll() 00396 { return hscroll; } 00397 00399 csScrollBar *GetVScroll() 00400 { return vscroll; } 00401 00403 int GetDeltaX() 00404 { return deltax; } 00405 00407 int GetMaxDeltaX() 00408 { return maxdeltax; } 00409 00411 bool GetPlaceItemsFlag() 00412 { return fPlaceItems; } 00413 00415 csPixmap *GetFrameBitmap() 00416 { return FrameBitmap; } 00417 00419 uint8 GetAlpha() 00420 { return FrameAlpha; } 00421 00422 protected: 00424 void MakeItemVisible (csComponent *item); 00425 }; 00426 00429 #endif // __CS_CSLISTBX_H__
Generated for Crystal Space by doxygen 1.2.18