00001
00002
00003
00004
00005 #ifndef __GLIST_ITEM_RADIO_H
00006 #define __GLIST_ITEM_RADIO_H
00007
00010 class GListItemRadioBtn : public GListItemColumn
00011 {
00012 public:
00014 GListItemRadioBtn
00015 (
00017 GListItem *host,
00019 int column,
00021 bool value = false
00022 ) : GListItemColumn(host, column)
00023 {
00024 GListItemColumn::Value(value);
00025 }
00026
00027 void OnPaintColumn(ItemPaintCtx &r, int i, GListColumn *Col)
00028 {
00029 GSurface *pDC = r.pDC;
00030 GRect c(0, 0, 10, 10);
00031 c.Offset(r.x1 + ((r.X()-c.X())/2), r.y1 + ((r.Y()-c.Y())/2));
00032
00033
00034 pDC->Colour(LC_WORKSPACE, 24);
00035 pDC->FilledCircle(c.x1 + 5, c.y1 + 5, 5);
00036
00037 pDC->Colour(LC_TEXT, 24);
00038 pDC->Circle(c.x1 + 5, c.y1 + 5, 5);
00039
00040
00041 if (Value())
00042 {
00043 pDC->Colour(LC_TEXT, 24);
00044 pDC->FilledCircle(c.x1 + 5, c.y1 + 5, 2);
00045 }
00046 }
00047
00048 void OnMouseClick(GMouse &m)
00049 {
00050 if (m.Down() AND m.Left())
00051 {
00052 Value(!Value());
00053 }
00054 }
00055
00056 int64 Value()
00057 {
00058 return GListItemColumn::Value();
00059 }
00060
00061 void Value(int64 i)
00062 {
00063
00064 GListItemColumn::Value(i);
00065
00066
00067 if (i AND
00068 GetList())
00069 {
00070 List<GListItem>::I Items = GetAllItems()->Start();
00071 for (GListItem *i=*Items; i; i=*++Items)
00072 {
00073 List<GListItemColumn>::I Cols = i->GetItemCols()->Start();
00074 for (GListItemColumn *c=*Cols; c; c=*++Cols)
00075 {
00076 if (c->GetColumn() == GetColumn())
00077 {
00078 GListItemRadioBtn *r = dynamic_cast<GListItemRadioBtn*>(c);
00079 if (r != this)
00080 {
00081 r->Value(0);
00082 break;
00083 }
00084 }
00085 }
00086 }
00087
00088 GetList()->SendNotify(GLIST_NOTIFY_CHANGE);
00089 }
00090 }
00091 };
00092
00093 #endif