#ifndef _GridCtrl_GridCtrl_h_ #define _GridCtrl_GridCtrl_h_ NAMESPACE_UPP #include "GridBase.h" #include "GridUtils.h" #define IMAGECLASS GridImg #define IMAGEFILE #include #define BIT(x) (1 << x) #define FOREACH_ROW(x) for(x.First(); !x.IsEnd(); x.Next()) #ifdef flagDEBUG #define LG Log #else #define LG #endif #define LGR Log extern LineEdit *dlog; extern DropList *dlev; void Log(const char *fmt, ...); void Log(int level, const char *fmt, ...); class FindEditString : public EditString { public: Callback WhenEnter; virtual bool Key(dword key, int count) { if(key == K_ENTER && WhenEnter) { WhenEnter(); return true; } return EditString::Key(key, count); } }; class GridPopUpHeader : public Ctrl { private: bool open; public: GridDisplay * display; Value val; int sortmode; int sortcol; int sortcnt; bool chameleon; GridPopUpHeader() : open(false) {} virtual void Paint(Draw &w); void PopUp(Ctrl *owner, int x, int y, int width, int height); void Close(); }; class GridPopUp : public Ctrl { public: bool open; String text; GridPopUp() { open = false; } virtual void Paint(Draw &w); void PopUp(Ctrl *owner, int x, int y, int width, int height); void Close(); }; class CtrlsHolder : public Ctrl { private: Ctrl &parent; Point offset; public: CtrlsHolder(Ctrl &p) : parent(p) { Transparent(); } virtual void LeftUp(Point p, dword flags) { parent.LeftUp(p + offset, flags); } virtual void LeftDown(Point p, dword flags) { parent.LeftDown(p + offset, flags); } virtual void LeftDouble(Point p, dword flags) { parent.LeftDouble(p + offset, flags); } virtual void RightUp(Point p, dword flags) { parent.RightUp(p + offset, flags); } virtual void RightDown(Point p, dword flags) { parent.RightDown(p + offset, flags); } virtual void RightDouble(Point p, dword flags) { parent.RightDouble(p + offset, flags); } virtual void MouseMove(Point p, dword flags) { parent.MouseMove(p + offset, flags); } virtual void MouseLeave() { parent.MouseLeave(); } virtual Image CursorImage(Point p, dword flags) { return parent.CursorImage(p + offset, flags); } virtual void Paint(Draw &w) { //DrawFrame(w, GetSize(), Red); } virtual void MouseWheel(Point p, int zdelta, dword keyflags) { parent.MouseWheel(p + offset, zdelta, keyflags); } void SetOffset(Point p) { offset = p; } }; class GridClipboard : Moveable { public: struct ClipboardData : Moveable { int col, row; Value v; virtual void Serialize(Stream &s) { s % col % row; s % v; } }; Vector data; Point minpos, maxpos; bool shiftmode; virtual void Serialize(Stream &s) { s % shiftmode; s % minpos % maxpos; s % data; } }; class GridCtrl : public Ctrl { private: enum { GO_PREV, GO_NEXT, GO_LEFT, GO_RIGHT, GO_BEGIN, GO_END, GO_PAGEUP, GO_PAGEDN }; enum { UC_SHOW = BIT(0), UC_HIDE = BIT(1), UC_FOCUS = BIT(2), UC_GOFIRST = BIT(3), UC_SCROLL = BIT(4), UC_NEXT = BIT(5), UC_CTRLS = BIT(6), UC_CURSOR = BIT(7), UC_CHECK_VIS = BIT(8), UC_MOUSE = BIT(9), UC_CTRLS_OFF = BIT(10) }; enum GridState { GS_UP = 0, GS_MOVE = 1, GS_DOWN = 2, GS_BORDER = 3, GS_POPUP = 4 }; static int GD_COL_WIDTH; static int GD_ROW_HEIGHT; static int GD_HDR_HEIGHT; static int GD_IND_WIDTH; typedef GridCtrl CLASSNAME; Items items; HItems hitems; VItems vitems; VectorMap aliases; Edits edits; CtrlsHolder holder; ScrollBar sbx; ScrollBar sby; ToolBar bar; GridPopUp popup; FrameLeft findimg; FrameRight