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(GItem::ItemPaintCtx &Ctx, int i, GListColumn *Col)
00029 {
00030 GSurface *pDC = Ctx.pDC;
00031 GRect c(0, 0, 10, 10);
00032 c.Offset(Ctx.x1 + ((Ctx.X()-c.X())/2), Ctx.y1 + ((Ctx.Y()-c.Y())/2));
00033
00034
00035 pDC->Colour(LC_TEXT, 24);
00036 pDC->Box(&c);
00037 c.Size(1, 1);
00038 pDC->Colour(LC_WORKSPACE, 24);
00039 pDC->Rectangle(&c);
00040
00041
00042 if (Value())
00043 {
00044 pDC->Colour(LC_TEXT, 24);
00045
00046 pDC->Line(c.x1+1, c.y1+1, c.x2-1, c.y2-1);
00047 pDC->Line(c.x1+1, c.y1+2, c.x2-2, c.y2-1);
00048 pDC->Line(c.x1+2, c.y1+1, c.x2-1, c.y2-2);
00049
00050 pDC->Line(c.x1+1, c.y2-1, c.x2-1, c.y1+1);
00051 pDC->Line(c.x1+1, c.y2-2, c.x2-2, c.y1+1);
00052 pDC->Line(c.x1+2, c.y2-1, c.x2-1, c.y1+2);
00053 }
00054 }
00055
00056 void OnMouseClick(GMouse &m)
00057 {
00058 if (m.Down() AND m.Left())
00059 {
00060 GList *l = GetList();
00061 List<GListItem> Sel;
00062 if (l->GetSelection(Sel) AND Sel.First())
00063 {
00064 bool v = !Value();
00065 Sel.Delete(GetItem());
00066
00067 for (GListItem *i=Sel.First(); i; i=Sel.Next())
00068 {
00069 GListItemColumn *c = GetItemCol(i, GetColumn());
00070 if (c)
00071 {
00072 c->Value(v);
00073 }
00074 }
00075
00076 Value(v);
00077 }
00078 }
00079 }
00080 };
00081
00082 #endif