00001
00002
00003
00004
00005 #ifndef __GLIST_ITEM_CHECKBOX_H
00006 #define __GLIST_ITEM_CHECKBOX_H
00007
00008 #include "GList.h"
00009
00011 class GListItemCheckBox : public GListItemColumn
00012 {
00013 public:
00015 GListItemCheckBox
00016 (
00018 GListItem *host,
00020 int column,
00021
00022 bool value = false
00023 ) : GListItemColumn(host, column)
00024 {
00025 Value(value);
00026 }
00027
00028 void OnPaintColumn(GSurface *pDC, GRect &r, int i, GListColumn *Col)
00029 {
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_TEXT, 24);
00035 pDC->Box(&c);
00036 c.Size(1, 1);
00037 pDC->Colour(LC_WORKSPACE, 24);
00038 pDC->Rectangle(&c);
00039
00040
00041 if (Value())
00042 {
00043 pDC->Colour(LC_TEXT, 24);
00044
00045 pDC->Line(c.x1+1, c.y1+1, c.x2-1, c.y2-1);
00046 pDC->Line(c.x1+1, c.y1+2, c.x2-2, c.y2-1);
00047 pDC->Line(c.x1+2, c.y1+1, c.x2-1, c.y2-2);
00048
00049 pDC->Line(c.x1+1, c.y2-1, c.x2-1, c.y1+1);
00050 pDC->Line(c.x1+1, c.y2-2, c.x2-2, c.y1+1);
00051 pDC->Line(c.x1+2, c.y2-1, c.x2-1, c.y1+2);
00052 }
00053 }
00054
00055 void OnMouseClick(GMouse &m)
00056 {
00057 if (m.Down() AND m.Left())
00058 {
00059 GList *l = GetList();
00060 List<GListItem> Sel;
00061 if (l->GetSelection(Sel) AND Sel.First())
00062 {
00063 bool v = NOT Value();
00064 Sel.Delete(GetItem());
00065
00066 for (GListItem *i=Sel.First(); i; i=Sel.Next())
00067 {
00068 GListItemColumn *c = GetItemCol(i, GetColumn());
00069 if (c)
00070 {
00071 c->Value(v);
00072 }
00073 }
00074
00075 Value(v);
00076 }
00077 }
00078 }
00079 };
00080
00081 #endif