Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

cslistbx.h

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 __CSLISTBX_H__
00021 #define __CSLISTBX_H__
00022 
00023 #include "cscomp.h"
00024 #include "csscrbar.h"
00025 
00029 enum
00030 {
00038   cscmdListBoxStartTracking = 0x00000400,
00046   cscmdListBoxTrack,
00053   cscmdListBoxMakeVisible,
00057   cscmdListBoxClear,
00066   cscmdListBoxItemCheck,
00074   cscmdListBoxItemSet,
00084   cscmdListBoxItemSelected,
00092   cscmdListBoxItemDeselected,
00103   cscmdListBoxItemClicked,
00113   cscmdListBoxItemDoubleClicked,
00123   cscmdListBoxItemFocused,
00133   cscmdListBoxItemScrollVertically,
00140   cscmdListBoxItemSetHorizOffset,
00147   cscmdListBoxQueryFirstSelected,
00155   cscmdListBoxSelectItem
00156 };
00157 
00159 #define CSS_LISTBOXITEM_SELECTED        0x00010000
00160 
00162 #define CS_LISTBOXITEMCHECK_SELECTED    0xdeadface
00163 
00164 #define CS_LISTBOXITEMCHECK_UNSELECTED  0x0badf00d
00165 
00170 enum csListBoxItemStyle
00171 {
00173   cslisNormal,
00175   cslisEmphasized
00176 };
00177 
00179 class csListBoxItem : public csComponent
00180 {
00182   csListBoxItemStyle ItemStyle;
00184   int deltax;
00186   csPixmap *ItemBitmap;
00188   bool DeleteBitmap;
00190   int hOffset;
00191 
00192 public:
00194   csListBoxItem (csComponent *iParent, const char *iText, int iID = 0,
00195     csListBoxItemStyle iStyle = cslisNormal);
00196 
00198   virtual ~csListBoxItem ();
00199 
00201   virtual bool HandleEvent (iEvent &Event);
00202 
00204   virtual void SetState (int mask, bool enable);
00205 
00207   virtual void SuggestSize (int &w, int &h);
00208 
00210   void SetBitmap (csPixmap *iBitmap, bool iDelete = true);
00211 
00213   void SetOffset (int ihOffset)
00214   { hOffset = ihOffset; Invalidate (); }
00215 
00217   virtual char *GetSkinName ()
00218   { return "ListboxItem"; }
00219 
00224 
00225    csListBoxItemStyle GetItemStyle()
00226    { return ItemStyle; }
00227 
00229   int GetDeltaX()
00230   { return deltax; }
00231 
00233   csPixmap *GetItemBitmap()
00234   { return ItemBitmap; }
00235 
00237   int GetHOffset()
00238   { return hOffset; }
00239 
00240   char *GetText()
00241   { return text; }
00242  };
00243 
00248 
00249 #define CSLBS_MULTIPLESEL       0x00000001
00250 
00251 #define CSLBS_HSCROLL           0x00000002
00252 
00253 #define CSLBS_VSCROLL           0x00000004
00254 
00256 #define CSLBS_DEFAULTVALUE      CSLBS_VSCROLL
00257 
00259 enum csListBoxFrameStyle
00260 {
00262   cslfsNone,
00264   cslfsThinRect,
00266   cslfsThickRect,
00268   cslfsTextured,
00270   cslfsTexturedNoFrame,
00272   cslfsBitmap
00273 };
00274 
00281 class csListBox : public csComponent
00282 {
00284   int ListBoxStyle;
00286   csListBoxFrameStyle FrameStyle;
00288   int BorderWidth, BorderHeight;
00290   csComponent *first;
00292   csComponent *firstvisible;
00294   bool selstate;
00296   int vertcount;
00298   csScrollBar *hscroll, *vscroll;
00300   csScrollBarStatus hsbstatus, vsbstatus;
00302   int deltax, maxdeltax;
00304   bool fPlaceItems;
00306   csPixmap *FrameBitmap;
00308   bool fDelFrameBitmap;
00310   uint8 FrameAlpha;
00311 
00312 public:
00314   csListBox (csComponent *iParent, int iStyle = CSLBS_DEFAULTVALUE,
00315     csListBoxFrameStyle iFrameStyle = cslfsThickRect);
00316 
00318  ~csListBox();
00319 
00321   virtual bool HandleEvent (iEvent &Event);
00322 
00324   void PlaceItems (bool setscrollbars = true);
00325 
00327   virtual bool SetRect (int xmin, int ymin, int xmax, int ymax);
00328 
00330   void SuggestSize (int &w, int &h);
00331 
00336   csComponent *ForEachItem (bool (*func) (csComponent *child, void *param),
00337     void *param = NULL, bool iSelected = true);
00338 
00340   virtual void SetState (int mask, bool enable);
00341 
00343   virtual bool SetFocused (csComponent *comp);
00344 
00346   virtual void Insert (csComponent *comp);
00347 
00349   virtual void Delete (csComponent *comp);
00350 
00352  void SetFrameBitmap(csPixmap *iFrameBitmap, bool iDelFrameBitmap=false);
00353 
00355  void SetTexture(csPixmap *iTexture, bool iDelFrameBitmap=false);
00356 
00358  void SetAlpha(uint8 iAlpha);
00359 
00361  virtual char *GetSkinName ()
00362  { return "Listbox"; }
00363 
00369 
00370   int GetListBoxStyle()
00371   { return ListBoxStyle; }
00372 
00374   csListBoxFrameStyle GetFrameStyle()
00375   { return FrameStyle; }
00376 
00378   void GetBorderSize(int *iBorderWidth,  int *iBorderHeight);
00379 
00381   int VerticalCount()
00382   { return vertcount; }
00383 
00385   csScrollBar *GetHScroll()
00386   { return hscroll; }
00387 
00389   csScrollBar *GetVScroll()
00390   { return vscroll; }
00391 
00393   int GetDeltaX()
00394   { return deltax; }
00395 
00397   int GetMaxDeltaX()
00398   { return maxdeltax; }
00399 
00401   bool GetPlaceItemsFlag()
00402   { return fPlaceItems; }
00403 
00405  csPixmap *GetFrameBitmap()
00406  { return FrameBitmap; }
00407 
00409  uint8 GetAlpha()
00410  { return FrameAlpha; }
00411 
00412 protected:
00414   void MakeItemVisible (csComponent *item);
00415 };
00416 
00417 #endif // __CSLISTBX_H__

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000