00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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__