Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

GListItemRadioBtn.h

Go to the documentation of this file.
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(GSurface *pDC, GRect &r, int i, GListColumn *Col)
00028     {
00029         GRect c(0, 0, 10, 10);
00030         c.Offset(r.x1 + ((r.X()-c.X())/2), r.y1 + ((r.Y()-c.Y())/2));
00031 
00032         // Box
00033         pDC->Colour(LC_WORKSPACE, 24);
00034         pDC->FilledCircle(c.x1 + 5, c.y1 + 5, 5);
00035 
00036         pDC->Colour(LC_TEXT, 24);
00037         pDC->Circle(c.x1 + 5, c.y1 + 5, 5);
00038 
00039         // Value
00040         if (Value())
00041         {
00042             pDC->Colour(LC_TEXT, 24);
00043             pDC->FilledCircle(c.x1 + 5, c.y1 + 5, 2);
00044         }
00045     }
00046 
00047     void OnMouseClick(GMouse &m)
00048     {
00049         if (m.Down() AND m.Left())
00050         {
00051             Value(NOT Value());
00052         }
00053     }
00054 
00055     int Value()
00056     {
00057         return GListItemColumn::Value();
00058     }
00059 
00060     void Value(int i)
00061     {
00062         // Set me
00063         GListItemColumn::Value(i);
00064 
00065         // Switch off any other controls in the list...
00066         if (i AND
00067             GetList())
00068         {
00069             Iterator<GListItem> Items(GetAllItems());
00070             for (GListItem *i=Items.First(); i; i=Items.Next())
00071             {
00072                 Iterator<GListItemColumn> Cols(i->GetItemCols());
00073                 for (GListItemColumn *c=Cols.First(); c; c=Cols.Next())
00074                 {
00075                     if (c->GetColumn() == GetColumn())
00076                     {
00077                         GListItemRadioBtn *r = dynamic_cast<GListItemRadioBtn*>(c);
00078                         if (r != this)
00079                         {
00080                             r->Value(0);
00081                             break;
00082                         }
00083                     }
00084                 }
00085             }
00086 
00087             GetList()->SendNotify(GLIST_NOTIFY_CHANGE);
00088         }
00089     }
00090 };
00091 
00092 #endif

Generated on Wed Oct 26 14:46:49 2005 for Lgi by  doxygen 1.4.1