00001 #ifndef _GDATAGRID_H_
00002 #define _GDATAGRID_H_
00003
00004 #include "GList.h"
00005 #include "GDragAndDrop.h"
00006
00007 class GDataGrid : public GList, public GDragDropSource, public GDragDropTarget
00008 {
00009 struct GDataGridPriv *d;
00010
00011 public:
00012 enum GDataGridFlags
00013 {
00014 GDG_READONLY = 0x1,
00015 GDG_INTEGER = 0x2,
00016 };
00017
00018 typedef GListItem *(*ItemFactory)(void *userdata);
00019 typedef GArray<GListItem*> ItemArray;
00020 typedef GArray<int> IndexArray;
00021
00022 GDataGrid(int CtrlId, ItemFactory Func = 0, void *userdata = 0);
00023 ~GDataGrid();
00024
00025
00026 bool CanAddRecord();
00027 void CanAddRecord(bool b);
00028 void SetFactory(ItemFactory Func = 0, void *userdata = 0);
00029 GListItem *NewItem();
00030 void SetColFlag(int Col, GDataGridFlags Flags, GVariant *Arg = 0);
00031 IndexArray *GetDeletedItems();
00032
00033
00034 void OnItemSelect(GArray<GListItem*> &Items);
00035 void OnItemClick(GListItem *Item, GMouse &m);
00036 void OnCreate();
00037 int OnEvent(GMessage *Msg);
00038 int OnNotify(GViewI *c, int f);
00039 void OnMouseWheel(double Lines);
00040 void OnPaint(GSurface *pDC);
00041 bool OnLayout(GViewLayoutInfo &Inf);
00042 bool Remove(GListItem *Obj);
00043 void Empty();
00044
00045
00046 void SetDndFormats(char *SrcFmt, char *AcceptFmt);
00047 void OnItemBeginDrag(GListItem *Item, GMouse &m);
00048 bool GetData(GVariant *Data, char *Format);
00049 bool GetFormats(List<char> &Formats);
00050 int WillAccept(List<char> &Formats, GdcPt2 Pt, int KeyState);
00051 int OnDrop(char *Format, GVariant *Data, GdcPt2 Pt, int KeyState);
00052 ItemArray *GetDroppedItems();
00053 };
00054
00055 #endif