1 #ifndef _GridCtrl_GridCtrl_h_ 2 #define _GridCtrl_GridCtrl_h_ 3 #include <CtrlLib/CtrlLib.h> 4 #ifdef flagGRIDSQL 5 #include <Sql/Sql.h> 6 #endif 7 8 namespace Upp { 9 10 #include "GridUtils.h" 11 #include "GridDisplay.h" 12 13 #define FOREACH_ROW(x) for(x.Begin(); x.IsEnd(); x.Next()) 14 #define FOREACH_SELECTED_ROW(x) FOREACH_ROW(x) if(x.IsSelected()) 15 #define FOREACH_MODIFIED_ROW(x) FOREACH_ROW(x) if(x.IsUpdatedRow()) 16 #define FOREACH_ROW_NOT_CURRENT(x) FOREACH_ROW(x) if(!x.IsCurrentRow()) 17 18 namespace GF 19 { 20 enum { 21 SKIP_CURRENT_ROW = BIT(0), 22 SKIP_HIDDEN = BIT(1) 23 }; 24 }; 25 26 class GridFind : public EditString 27 { 28 private: 29 MultiButtonFrame button; 30 public: 31 32 GridFind(); 33 34 Event<> WhenEnter; 35 Callback1<Bar &> WhenBar; 36 37 virtual bool Key(dword key, int count); 38 virtual Size GetMinSize() const; 39 void Push(); 40 41 typedef GridFind CLASSNAME; 42 43 }; 44 45 class GridPopUpHeader : public Ctrl 46 { 47 private: 48 bool open; 49 public: 50 51 GridDisplay *display; 52 Value val; 53 int sortmode; 54 int sortcol; 55 int sortcnt; 56 bool chameleon; 57 GridPopUpHeader()58 GridPopUpHeader() : open(false) {} 59 60 virtual void Paint(Draw &w); 61 void PopUp(Ctrl *owner, int x, int y, int width, int height); 62 virtual void Close(); 63 }; 64 65 class GridButton : public Ctrl 66 { 67 private: 68 int img; 69 int n; 70 71 public: 72 typedef GridButton CLASSNAME; 73 GridButton(); 74 virtual void Paint(Draw& w); 75 virtual void LeftDown(Point p, dword flags); 76 virtual void LeftUp(Point p, dword flags); 77 virtual void MouseEnter(Point p, dword flags); 78 virtual void MouseLeave(); 79 virtual void State(int reason); 80 virtual Size GetStdSize() const; 81 void SetButton(int n); 82 }; 83 84 class GridResizePanel : public FrameBottom<Ctrl> 85 { 86 private: 87 GridButton close; 88 Point pos; 89 Rect r; 90 Size minsize; 91 public: 92 93 typedef GridResizePanel CLASSNAME; 94 GridResizePanel(); 95 virtual void Paint(Draw& w); 96 virtual Image CursorImage(Point p, dword flags); 97 virtual void LeftDown(Point p, dword flags); 98 virtual void LeftUp(Point p, dword flags); 99 virtual void MouseMove(Point p, dword flags); 100 bool MouseOnGrip(const Point &p); 101 void SetMinSize(Size sz); 102 103 Event<> WhenClose; 104 }; 105 106 class GridPopUp : public Ctrl 107 { 108 public: 109 110 bool open; 111 Value val; 112 Ctrl* ctrl; 113 GridDisplay* gd; 114 Color fg, bg; 115 Font fnt; 116 dword style; 117 GridPopUp()118 GridPopUp() : open(false) {} 119 Point Offset(Point p); 120 121 virtual void Paint(Draw &w); 122 virtual void LeftDown(Point p, dword flags); 123 virtual void LeftDrag(Point p, dword flags); 124 virtual void LeftDouble(Point p, dword flags); 125 virtual void RightDown(Point p, dword flags); 126 virtual void LeftUp(Point p, dword flags); 127 virtual void MouseWheel(Point p, int zdelta, dword flags); 128 virtual void MouseLeave(); 129 virtual void MouseEnter(Point p, dword flags); 130 virtual void MouseMove(Point p, dword flags); 131 virtual Image CursorImage(Point p, dword flags); 132 virtual void LostFocus(); 133 void PopUp(Ctrl *owner, int x, int y, int width, int height); 134 virtual void Close(); 135 }; 136 137 class GridOperation 138 { 139 public: 140 141 enum 142 { 143 INSERT, 144 UPDATE, 145 REMOVE, 146 NONE 147 }; 148 149 private: 150 151 int operation; 152 int version; 153 154 public: 155 GridOperation()156 GridOperation() : operation(NONE), version(1) {} 157 SetOperation(int op)158 void SetOperation(int op) 159 { 160 switch(operation) 161 { 162 case NONE: operation = op; ++version; break; 163 case UPDATE: 164 if(op == REMOVE || op == NONE) 165 Clear(); 166 break; 167 case INSERT: 168 if(op == REMOVE || op == NONE) 169 Clear(); 170 break; 171 } 172 } 173 Clear()174 void Clear() { operation = NONE; } ClearVersion()175 void ClearVersion() { version = 0; } GetVersion()176 int GetVersion() { return version; } 177 178 GridOperation& operator=(const int op) 179 { 180 SetOperation(op); 181 return *this; 182 } 183 184 operator int() { return operation; } 185 bool operator!=(int op) { return operation != op; } 186 bool operator==(int op) { return operation == op; } 187 }; 188 189 190 class CtrlsHolder : public Ctrl 191 { 192 private: 193 Ctrl &parent; 194 Point offset; 195 public: CtrlsHolder(Ctrl & p)196 CtrlsHolder(Ctrl &p) : parent(p) 197 { 198 Transparent(); 199 WantFocus(false); 200 } LeftUp(Point p,dword flags)201 virtual void LeftUp(Point p, dword flags) { parent.LeftUp(p + offset, flags); } LeftDown(Point p,dword flags)202 virtual void LeftDown(Point p, dword flags) { parent.LeftDown(p + offset, flags); } LeftDouble(Point p,dword flags)203 virtual void LeftDouble(Point p, dword flags) { parent.LeftDouble(p + offset, flags); } RightUp(Point p,dword flags)204 virtual void RightUp(Point p, dword flags) { parent.RightUp(p + offset, flags); } RightDown(Point p,dword flags)205 virtual void RightDown(Point p, dword flags) { parent.RightDown(p + offset, flags); } RightDouble(Point p,dword flags)206 virtual void RightDouble(Point p, dword flags) { parent.RightDouble(p + offset, flags); } MouseMove(Point p,dword flags)207 virtual void MouseMove(Point p, dword flags) { parent.MouseMove(p + offset, flags); } MouseLeave()208 virtual void MouseLeave() { parent.MouseLeave(); } CursorImage(Point p,dword flags)209 virtual Image CursorImage(Point p, dword flags) { return parent.CursorImage(p + offset, flags); } 210 ChildMouseEvent(Ctrl * child,int event,Point p,int zdelta,dword keyflags)211 virtual void ChildMouseEvent(Ctrl *child, int event, Point p, int zdelta, dword keyflags) 212 { 213 Ctrl::ChildMouseEvent(child, event, p, zdelta, keyflags); 214 } Paint(Draw & w)215 virtual void Paint(Draw &w) 216 { 217 //DrawFrame(w, GetSize(), Red); 218 } 219 MouseWheel(Point p,int zdelta,dword keyflags)220 virtual void MouseWheel(Point p, int zdelta, dword keyflags) 221 { 222 parent.MouseWheel(p + offset, zdelta, keyflags); 223 } 224 SetOffset(Point p)225 void SetOffset(Point p) 226 { 227 offset = p; 228 } 229 }; 230 231 class GridClipboard : Moveable<GridClipboard> 232 { 233 public: 234 rval_default(GridClipboard); GridClipboard()235 GridClipboard() {} 236 237 struct ClipboardData : Moveable<ClipboardData> 238 { 239 int col, row; 240 Value v; 241 SerializeAttrTextClipboardData242 void SerializeAttrText(Stream& s, AttrText& a) 243 { 244 s % a.text; 245 s % a.font; 246 s % a.ink; 247 s % a.normalink; 248 s % a.paper; 249 s % a.align; 250 s % a.img; 251 s % a.imgspc; 252 } 253 SerializeClipboardData254 void Serialize(Stream &s) 255 { 256 s % col % row; 257 dword type = IsType<AttrText>(v) ? 1 : 0; 258 s / type; 259 if(type == 1) 260 { 261 if(s.IsStoring()) 262 { 263 SerializeAttrText(s, (AttrText&) ValueTo<AttrText>(v)); 264 } 265 else 266 { 267 AttrText a; 268 SerializeAttrText(s, a); 269 v = RawToValue<AttrText>(a); 270 } 271 } 272 else 273 s % v; 274 } 275 }; 276 277 Vector<ClipboardData> data; 278 Point minpos, maxpos; 279 bool shiftmode; 280 Serialize(Stream & s)281 virtual void Serialize(Stream &s) 282 { 283 s % shiftmode; 284 s % minpos % maxpos; 285 s % data; 286 } 287 }; 288 289 class GridCtrl : public Ctrl 290 { 291 friend class DropGrid; 292 293 public: 294 295 int GD_COL_WIDTH; 296 int GD_ROW_HEIGHT; 297 int GD_HDR_HEIGHT; 298 int GD_IND_WIDTH; 299 300 enum GridOrder 301 { 302 SORT_ID = 0, 303 SORT_UP = 1, 304 SORT_DOWN = 2 305 }; 306 307 private: 308 309 enum GridCursor 310 { 311 GO_PREV, 312 GO_NEXT, 313 GO_LEFT, 314 GO_RIGHT, 315 GO_BEGIN, 316 GO_END, 317 GO_PAGEUP, 318 GO_PAGEDN 319 }; 320 321 enum GridControlState 322 { 323 UC_SHOW = BIT(0), 324 UC_HIDE = BIT(1), 325 UC_FOCUS = BIT(2), 326 UC_NOFOCUS = BIT(3), 327 UC_GOFIRST = BIT(4), 328 UC_SCROLL = BIT(5), 329 UC_NEXT = BIT(6), 330 UC_CTRLS = BIT(7), 331 UC_CURSOR = BIT(8), 332 UC_CHECK_VIS = BIT(9), 333 UC_MOUSE = BIT(10), 334 UC_CTRLS_OFF = BIT(11), 335 UC_UPDATES = BIT(12), 336 UC_OLDCUR = BIT(13) 337 }; 338 339 enum GridRepaintOpts 340 { 341 RP_TOOLBAR = BIT(0), 342 RP_UPDCTRLS = BIT(1), 343 RP_ALL = BIT_ALL 344 }; 345 346 enum GridCursorState 347 { 348 CU_MOUSE = BIT(0), 349 CU_HIGHLIGHT = BIT(1), 350 CU_CTRLMODE = BIT(2), 351 CU_HIDECTRLS = BIT(3) 352 }; 353 354 enum GridSummaryOperation 355 { 356 SOP_NONE = 0, 357 SOP_MIN = 1, 358 SOP_MAX = 2, 359 SOP_SUM = 3, 360 SOP_CNT = 4, 361 SOP_AVG = 5, 362 }; 363 364 enum GridState 365 { 366 GS_UP = 0, 367 GS_MOVE = 1, 368 GS_DOWN = 2, 369 GS_BORDER = 3, 370 GS_POPUP = 4 371 }; 372 373 enum GridEdit 374 { 375 GE_ROW = 0, 376 GE_CELL = 1 377 }; 378 379 enum GridItemCtrl 380 { 381 IC_INIT = BIT(1), 382 IC_MANUAL = BIT(2), 383 IC_FACTORY = BIT(3), 384 IC_OWNED = BIT(4) 385 }; 386 387 struct CurState 388 { 389 bool newx; 390 bool newy; 391 bool accepted; 392 bool valid; 393 CurStateCurState394 CurState() { Clear(); } IsNewRowCurState395 bool IsNewRow() { return newy; } IsNewColCurState396 bool IsNewCol() { return newx; } IsNewCurState397 bool IsNew() { return newx || newy; } IsAcceptedCurState398 bool IsAccepted() { return accepted; } IsValidCurState399 bool IsValid() { return valid; } 400 ClearCurState401 void Clear() 402 { 403 newx = newy = false; 404 accepted = false; 405 valid = true; 406 } 407 408 operator bool() { return IsNew() && IsAccepted(); } 409 }; 410 411 struct Edit : Moveable<Edit> 412 { 413 Ptr<Ctrl> ctrl; 414 Convert * convert; 415 Callback1<One<Ctrl>&> factory; 416 EditEdit417 Edit() 418 { 419 ctrl = NULL; 420 convert = NULL; 421 } 422 }; 423 424 class Item : Moveable<Item> 425 { 426 public: 427 friend class ItemRect; 428 friend class GridCtrl; 429 Item()430 Item() 431 { 432 ctrl = NULL; 433 convert = NULL; 434 display = NULL; 435 436 fs = fe = 0; 437 style = 0; 438 editable = true; 439 clickable = true; 440 idx = 0; 441 idy = 0; 442 cx = 0; 443 cy = 0; 444 group = -1; 445 isjoined = false; 446 447 rcx = 0; 448 rcy = 0; 449 450 modified = false; 451 sync_flag = -1; 452 paint_flag = -1; 453 ctrl_flag = 0; 454 } ~Item()455 ~Item() 456 { 457 if(ctrl_flag & IC_OWNED) 458 delete ctrl; 459 } 460 461 void SetCtrl(Ctrl& ctrl, bool owned); 462 void ClearCtrl(); 463 464 void SetDisplay(GridDisplay& display); 465 void NoDisplay(); 466 467 private: 468 InvertSelect()469 bool InvertSelect() { return BitInverse(style, GD::SELECT); } IsSelect()470 bool IsSelect() { return style & GD::SELECT; } IsLive()471 bool IsLive() { return style & GD::LIVE; } IsCursor()472 bool IsCursor() { return style & GD::CURSOR; } IsFound()473 bool IsFound() { return style & GD::FOUND; } 474 Select(bool s)475 void Select(bool s) { BitSet(style, GD::SELECT, s); } Cursor(bool s)476 void Cursor(bool s) { BitSet(style, GD::CURSOR, s); } Live(bool s)477 void Live(bool s) { BitSet(style, GD::LIVE, s); } Found(bool s)478 void Found(bool s) { BitSet(style, GD::FOUND, s); } 479 IsJoined()480 bool IsJoined() { return isjoined; } 481 482 int idx, idy, cx, cy, group; 483 int rcx, rcy; 484 bool isjoined:1; 485 int fs, fe; 486 dword style; 487 bool editable:1; 488 bool clickable:1; 489 bool modified:1; 490 int sync_flag; 491 int paint_flag; 492 int ctrl_flag; 493 494 Ptr<Ctrl> ctrl; 495 496 Convert *convert; 497 GridDisplay *display; 498 499 public: 500 Value val; 501 502 Item& Editable(bool b); 503 Item& NoEditable(); 504 Clickable(bool b)505 Item& Clickable(bool b) { clickable = b; return *this; } NoClickable()506 Item& NoClickable() { clickable = false; return *this; } 507 }; 508 509 typedef Vector< Vector<Item> > Items; 510 typedef Vector< Edit > Edits; 511 512 struct JoinRect : Moveable<JoinRect> 513 { 514 Rect r; 515 int group; 516 int idx, idy; 517 }; 518 519 public: class ItemRect : public Moveable<ItemRect> 520 { 521 friend class GridCtrl; 522 523 public: ItemRect()524 ItemRect() 525 { 526 min = 5; max = 1000000; 527 pos = npos = 0; 528 id = uid = n = 0; 529 prop = 1; 530 size = nsize = 0; 531 tsize = 0; 532 sortmode = 0; 533 hidden = false; 534 index = false; 535 convertion = true; 536 editable = true; 537 edit_insert = true; 538 edit_update = true; 539 sortable = true; 540 clickable = true; 541 locked = false; 542 skip = false; 543 ignore_display = false; 544 style = 0; 545 546 calign = 0; 547 sl = sr = st = sb = 0; 548 sx = sy = 0; 549 join = 0; 550 551 ismin = false; 552 ismax = false; 553 554 fnt = Null; 555 hfnt = Null; 556 balign = halign = GD::LEFT | GD::VCENTER; 557 wrap = false; 558 fg = Null; 559 bg = Null; 560 561 ctrl = NULL; 562 convert = NULL; 563 display = NULL; 564 565 found = false; 566 567 level = 0; 568 sop = SOP_NONE; 569 570 operation = GridOperation::NONE; 571 } 572 573 private: 574 575 Items *items; 576 GridCtrl *parent; 577 Edits *edits; 578 579 int level; 580 581 Ptr<Ctrl> ctrl; 582 Convert *convert; 583 GridDisplay *display; 584 585 Callback1<One<Ctrl>&> factory; 586 587 static VectorMap<Id, int> *aliases; 588 589 double pos, size, prop; 590 int npos, nsize; 591 int min, max; 592 int id, uid, n; 593 int sl, sr, st, sb, sx, sy; 594 595 double tsize; 596 int join; 597 598 int sop; 599 String sopfrm; 600 601 bool hidden; 602 bool index; 603 bool convertion; 604 bool editable; 605 bool sortable; 606 bool clickable; 607 bool locked; 608 bool found:1; 609 bool skip:1; 610 bool edit_insert:1; 611 bool edit_update:1; 612 613 Value defval; 614 615 dword style; 616 617 bool ismin; 618 bool ismax; 619 620 /* operatory typu friend moga odwolywac sie tylko do zmiennych statycznych klasy */ 621 622 static int sortCol; 623 static int sortMode; 624 625 int sortcol; 626 int sortmode; 627 628 int balign, halign, calign; 629 bool wrap; 630 Font fnt, hfnt; 631 Color fg, bg; 632 Image img; 633 634 GridOperation operation; 635 636 bool ignore_display:1; 637 638 double Left(int scroll = 0) { return pos - scroll; } 639 double Right(int scroll = 0) { return pos + size - scroll; } 640 double Top(int scroll = 0) { return pos - scroll; } 641 double Bottom(int scroll = 0) { return pos + size - scroll; } Width()642 double Width() { return size; } Height()643 double Height() { return size; } 644 InvertSelect()645 bool InvertSelect() { return BitInverse(style, GD::SELECT); } IsSelect()646 bool IsSelect() { return style & GD::SELECT; } IsLive()647 bool IsLive() { return style & GD::LIVE; } IsCursor()648 bool IsCursor() { return style & GD::CURSOR; } IsHighlight()649 bool IsHighlight() { return style & GD::HIGHLIGHT; } 650 IsFound()651 bool IsFound() { return found; } 652 Select(bool s)653 void Select(bool s) { BitSet(style, GD::SELECT, s); } Cursor(bool s)654 void Cursor(bool s) { BitSet(style, GD::CURSOR, s); } Live(bool s)655 void Live(bool s) { BitSet(style, GD::LIVE, s); } Highlight(bool s)656 void Highlight(bool s) { BitSet(style, GD::HIGHLIGHT, s); } 657 658 int nLeft(int scroll = 0) { return npos - scroll; } 659 int nRight(int scroll = 0) { return npos + nsize - scroll; } 660 int nTop(int scroll = 0) { return npos - scroll; } 661 int nBottom(int scroll = 0) { return npos + nsize - scroll; } nWidth()662 int nWidth() { return nsize; } nHeight()663 int nHeight() { return nsize; } 664 665 ItemRect& Size(int n, bool hv = false); 666 IsMin()667 bool IsMin() { return ismin; } IsMax()668 bool IsMax() { return ismax; } IsFixed()669 bool IsFixed() { return ismin && ismax; } 670 671 void ChangeSortMode(bool idsort = true); 672 673 friend bool operator<(const ItemRect& a, const ItemRect& b) 674 { 675 if(sortMode) 676 return (StdValueCompare(a.ExtractValue(a.id, sortCol), b.ExtractValue(b.id, sortCol), 0) < 0); 677 else 678 return a.id < b.id; 679 } 680 friend bool operator>(const ItemRect& a, const ItemRect& b) 681 { 682 if(sortMode) 683 return (StdValueCompare(a.ExtractValue(a.id, sortCol), b.ExtractValue(b.id, sortCol), 0) > 0); 684 else 685 return a.id > b.id; 686 } 687 688 Callback1<int> SyncCtrls; 689 690 public: 691 692 ItemRect& Alias(Id id); 693 ItemRect& Alias(const char * s); 694 ItemRect& Name(String &s); 695 ItemRect& Name(const char * s); 696 ItemRect& Hidden(bool b = true); 697 ItemRect& Width(int n); 698 ItemRect& Height(int n); 699 ItemRect& Min(int n); 700 ItemRect& Max(int n); 701 ItemRect& Fixed(int n); 702 ItemRect& FixedAuto(); 703 ItemRect& Edit(Ctrl &ctrl, bool b = true); 704 template<typename T> 705 ItemRect& EditConvert(T &ctrl, bool b = true) { return Edit(ctrl, b).SetConvert(ctrl); } 706 template<typename T> EditConvertDisplay(T & ctrl)707 ItemRect& EditConvertDisplay(T &ctrl) { return Edit(ctrl).SetConvert(ctrl).SetDisplay(ctrl); } 708 ItemRect& EditInsert(bool b = true); 709 ItemRect& EditUpdate(bool b = true); 710 ItemRect& SetConvert(Convert &c); 711 ItemRect& NoConvert(); 712 ItemRect& SetFormat(const char *fmt); 713 ItemRect& SetDisplay(GridDisplay &gd); 714 ItemRect& IgnoreDisplay(); 715 ItemRect& NoConvertion(); 716 ItemRect& Default(Value v); 717 ItemRect& Index(bool b = true); 718 719 String GetName() const; 720 Id GetAlias() const; 721 AlignTop()722 ItemRect& AlignTop() { balign = GD::TOP | GD::LEFT; return *this; } AlignBottom()723 ItemRect& AlignBottom() { balign = GD::BOTTOM | GD::LEFT; return *this; } AlignLeft()724 ItemRect& AlignLeft() { balign = GD::LEFT | GD::VCENTER; return *this; } AlignRight()725 ItemRect& AlignRight() { balign = GD::RIGHT | GD::VCENTER; return *this; } AlignTopLeft()726 ItemRect& AlignTopLeft() { balign = GD::LEFT | GD::TOP; return *this; } AlignTopRight()727 ItemRect& AlignTopRight() { balign = GD::RIGHT | GD::TOP; return *this; } AlignTopCenter()728 ItemRect& AlignTopCenter() { balign = GD::HCENTER | GD::TOP; return *this; } AlignCenterLeft()729 ItemRect& AlignCenterLeft() { balign = GD::VCENTER | GD::LEFT; return *this; } AlignCenterRight()730 ItemRect& AlignCenterRight() { balign = GD::VCENTER | GD::RIGHT; return *this; } AlignCenter()731 ItemRect& AlignCenter() { balign = GD::HCENTER | GD::VCENTER; return *this; } AlignBottomLeft()732 ItemRect& AlignBottomLeft() { balign = GD::LEFT | GD::BOTTOM; return *this; } AlignBottomRight()733 ItemRect& AlignBottomRight() { balign = GD::RIGHT | GD::BOTTOM; return *this; } AlignBottomCenter()734 ItemRect& AlignBottomCenter() { balign = GD::HCENTER | GD::BOTTOM; return *this; } 735 HeaderAlignTop()736 ItemRect& HeaderAlignTop() { halign = GD::TOP | GD::LEFT; return *this; } HeaderAlignBottom()737 ItemRect& HeaderAlignBottom() { halign = GD::BOTTOM | GD::LEFT; return *this; } HeaderAlignLeft()738 ItemRect& HeaderAlignLeft() { halign = GD::LEFT | GD::VCENTER; return *this; } HeaderAlignRight()739 ItemRect& HeaderAlignRight() { halign = GD::RIGHT | GD::VCENTER; return *this; } HeaderAlignTopLeft()740 ItemRect& HeaderAlignTopLeft() { halign = GD::LEFT | GD::TOP; return *this; } HeaderAlignTopRight()741 ItemRect& HeaderAlignTopRight() { halign = GD::RIGHT | GD::TOP; return *this; } HeaderAlignTopCenter()742 ItemRect& HeaderAlignTopCenter() { halign = GD::HCENTER | GD::TOP; return *this; } HeaderAlignCenterLeft()743 ItemRect& HeaderAlignCenterLeft() { halign = GD::VCENTER | GD::LEFT; return *this; } HeaderAlignCenterRight()744 ItemRect& HeaderAlignCenterRight() { halign = GD::VCENTER | GD::RIGHT; return *this; } HeaderAlignCenter()745 ItemRect& HeaderAlignCenter() { halign = GD::HCENTER | GD::VCENTER; return *this; } HeaderAlignBottomLeft()746 ItemRect& HeaderAlignBottomLeft() { halign = GD::LEFT | GD::BOTTOM; return *this; } HeaderAlignBottomRight()747 ItemRect& HeaderAlignBottomRight() { halign = GD::RIGHT | GD::BOTTOM; return *this; } HeaderAlignBottomCenter()748 ItemRect& HeaderAlignBottomCenter() { halign = GD::HCENTER | GD::BOTTOM; return *this; } 749 750 ItemRect& CtrlAlignTop(int t = 0, int s = 0) { calign |= GD::TOP; st = t; sy = s; return *this; } 751 ItemRect& CtrlAlignBottom(int b = 0, int s = 0) { calign |= GD::BOTTOM; sb = b; sy = s; return *this; } 752 ItemRect& CtrlAlignLeft(int l = 0, int s = 0) { calign |= GD::LEFT; sl = l; sx = s; return *this; } 753 ItemRect& CtrlAlignRight(int r = 0, int s = 0) { calign |= GD::RIGHT; sr = r; sx = s; return *this; } 754 ItemRect& CtrlAlignHorzCenter(int s = 0) { calign |= GD::HCENTER; sx = s; return *this; } 755 ItemRect& CtrlAlignVertCenter(int s = 0) { calign |= GD::VCENTER; sy = s; return *this; } 756 ItemRect& CtrlAlignCenter(int s = 0, int d = 0) { calign |= GD::VCENTER | GD::HCENTER; sx = s; sy = d; return *this; } 757 ItemRect& CtrlAlignHorzPos(int l = 0, int r = 0) { calign |= GD::HPOS; sl = l; sr = r; sx = 1; return *this; } 758 ItemRect& CtrlAlignVertPos(int t = 0, int b = 0) { calign |= GD::VPOS; st = t; sb = b; sy = 1; return *this; } 759 GetAlign()760 int GetAlign() const { return balign; } GetHeaderAlign()761 int GetHeaderAlign() const { return halign; } GetCtrlAlign()762 int GetCtrlAlign() const { return calign; } 763 WrapText()764 ItemRect& WrapText() { wrap = true; return *this; } 765 SetFont(Font & f)766 ItemRect& SetFont(Font& f) { fnt = f; return *this; } SetHeaderFont(Font & f)767 ItemRect& SetHeaderFont(Font& f) { hfnt = f; return *this; } Bg(Color c)768 ItemRect& Bg(Color c) { bg = c; return *this; } Fg(Color c)769 ItemRect& Fg(Color c) { fg = c; return *this; } SetImage(const Image & i)770 ItemRect& SetImage(const Image& i) { img = i; return *this; } ClearImage()771 ItemRect& ClearImage() { img = Null; return *this; } 772 ItemRect& Ctrls(Callback1<One<Ctrl>&> _factory); Ctrls(void (* factory)(One<Ctrl> &))773 ItemRect& Ctrls(void (*factory)(One<Ctrl>&)) { return Ctrls(callback(factory)); } Ctrls()774 template<class T> ItemRect& Ctrls() { return Ctrls(DefaultCtrlFactory<T>()); } 775 ItemRect& NoCtrls(); 776 ItemRect& Option(); 777 ItemRect& ThreeStateOption(); 778 779 ItemRect& Editable(bool b); 780 ItemRect& NoEditable(); 781 Sortable(bool b)782 ItemRect& Sortable(bool b) { sortable = b; return *this; } NoSortable()783 ItemRect& NoSortable() { sortable = false; return *this; } 784 Clickable(bool b)785 ItemRect& Clickable(bool b) { clickable = b; return *this; } NoClickable()786 ItemRect& NoClickable() { clickable = false; return *this; } 787 Locked(bool b)788 ItemRect& Locked(bool b) { locked = b; return *this; } NoLocked(bool b)789 ItemRect& NoLocked(bool b) { locked = false; return *this; } 790 Skip(bool b)791 ItemRect& Skip(bool b) { skip = b; return *this; } 792 793 ItemRect& DoAvg(const char *s = "") { sop = SOP_AVG; sopfrm = s; return *this; } 794 ItemRect& DoSum(const char *s = "") { sop = SOP_SUM; sopfrm = s; return *this; } 795 ItemRect& DoMin(const char *s = "") { sop = SOP_MIN; sopfrm = s; return *this; } 796 ItemRect& DoMax(const char *s = "") { sop = SOP_MAX; sopfrm = s; return *this; } 797 ItemRect& DoCount(const char *s = "") { sop = SOP_CNT; sopfrm = s; return *this; } 798 GetId()799 int GetId() { return id; } GetNumber()800 int GetNumber() { return id - parent->fixed_cols; } 801 IsConvertion()802 bool IsConvertion() const { return convertion; } IsHidden()803 bool IsHidden() const { return hidden; } 804 IsSortOrg()805 bool IsSortOrg() const { return sortmode == 0; } IsSortAsc()806 bool IsSortAsc() const { return sortmode == 1; } IsSortDsc()807 bool IsSortDsc() const { return sortmode == 2; } 808 809 Value ExtractValue(int r, int c) const; 810 811 void Serialize(Stream &s); 812 void Clear(); 813 }; 814 815 typedef Vector<ItemRect> RectItems; 816 typedef Vector<ItemRect> VItems; 817 typedef Vector<ItemRect> HItems; 818 typedef Vector<JoinRect> JItems; 819 820 typedef GridCtrl CLASSNAME; 821 822 Items items; 823 HItems hitems; 824 VItems vitems; 825 JItems joins; 826 827 Vector<Item> summary; 828 Vector<Value> rowbkp; 829 830 VectorMap<Id, int> aliases; 831 Edits edits; 832 833 CtrlsHolder holder; 834 835 ScrollBar sbx; 836 ScrollBar sby; 837 ToolBar bar; 838 839 GridResizePanel resize_panel; 840 GridPopUp popup; 841 842 bool resize_panel_open:1; 843 844 GridFind find; 845 Label info; 846 Button close; 847 848 GridDisplay *display; 849 GridDisplay *orgdisp; 850 851 /* Properties */ 852 853 bool select_row:1; 854 bool multi_select:1; 855 bool indicator:1; 856 bool resizing_cols:1; 857 bool resizing_rows:1; 858 bool moving_cols:1; 859 bool moving_rows:1; 860 bool resizing_fixed_cols:1; 861 bool resizing_fixed_rows:1; 862 bool dragging:1; 863 bool horz_grid:1; 864 bool vert_grid:1; 865 bool draw_last_horz_line:1; 866 bool draw_last_vert_line:1; 867 bool sorting:1; 868 bool sorting_multicol:1; 869 bool header:1; 870 bool live_cursor:1; 871 bool row_changing:1; 872 int coloring_mode; 873 874 int resize_paint_mode; 875 int resize_col_mode; 876 int resize_row_mode; 877 int edit_mode; 878 bool one_click_edit:1; 879 bool goto_first_edit:1; 880 881 bool inserting:1; 882 bool appending:1; 883 bool duplicating:1; 884 bool removing:1; 885 bool accepting:1; 886 bool canceling:1; 887 bool moving:1; 888 bool navigating:1; 889 bool searching:1; 890 bool closing:1; 891 bool editing:1; 892 bool edits_in_new_row:1; 893 bool hiding:1; 894 bool clipboard:1; 895 bool extra_paste:1; 896 bool fixed_paste:1; 897 bool copy_allowed:1; 898 bool cut_allowed:1; 899 bool paste_allowed:1; 900 bool copy_column_names:1; 901 bool draw_focus:1; 902 bool cancel_all:1; 903 bool ask_remove:1; 904 905 bool reject_null_row:1; 906 bool tab_changes_row:1; 907 bool tab_adds_row:1; 908 bool enter_like_tab:1; 909 bool keep_last_row:1; 910 bool remove_hides:1; 911 912 bool full_col_resizing:1; 913 bool full_row_resizing:1; 914 915 bool chameleon:1; 916 bool summary_row:1; 917 bool update_summary:1; 918 bool popups:1; 919 bool focus_lost_accepting:1; 920 921 bool search_hide:1; 922 bool search_highlight:1; 923 bool search_highlight_first:1; 924 bool search_immediate:1; 925 bool search_case:1; 926 bool search_move_cursor:1; 927 bool search_display:1; 928 int find_offset; 929 930 static bool index_as_column; 931 static bool reverse_sort_icon; 932 933 /* States */ 934 935 bool newrow_inserted:1; 936 bool newrow_appended:1; 937 int row_modified; 938 bool row_removed:1; 939 bool sel_begin:1; 940 bool sel_end:1; 941 bool moving_header:1; 942 bool moving_body:1; 943 bool moving_allowed:1; 944 bool row_order:1; 945 bool row_data:1; 946 bool scrollLeftRight:1; 947 bool doscroll:1; 948 bool ready:1; 949 bool isedit:1; 950 int genr_ctrls; 951 bool edit_ctrls:1; 952 bool shiftmode:1; 953 bool recalc_cols; 954 bool recalc_rows; 955 bool cancel_update_cell:1; 956 bool cancel_update:1; 957 bool cancel_insert:1; 958 bool cancel_remove:1; 959 bool cancel_accept:1; 960 bool cancel_duplicate:1; 961 bool cancel_cursor:1; 962 bool cancel_move:1; 963 bool mouse_move:1; 964 bool is_clipboard:1; 965 bool selecting:1; 966 bool enabled:1; 967 968 bool call_whenchangecol:1; 969 bool call_whenchangerow:1; 970 bool call_whenremoverow:1; 971 bool call_whenupdaterow:1; 972 bool call_wheninsertrow:1; 973 974 bool resizing; 975 bool fixed_click; 976 bool fixed_top_click; 977 bool fixed_left_click; 978 bool size_changed; 979 bool top_click; 980 bool just_clicked; 981 bool synced; 982 983 bool valid_cursor; 984 985 986 /* Values */ 987 988 int curSplitCol, curSplitRow; 989 int firstRow, lastRow; 990 int firstCol, lastCol; 991 int firstVisCol, lastVisCol; 992 int firstVisRow, lastVisRow; 993 int moveCol, oldMoveCol; 994 int moveRow, oldMoveRow; 995 int total_cols, total_rows; 996 int fixed_cols, fixed_rows; 997 int total_width, total_height; 998 int fixed_width, fixed_height; 999 int summary_height; 1000 1001 int oldSplitCol, oldSplitRow; 1002 1003 int selected_rows; 1004 int selected_items; 1005 int colidx; 1006 int rowidx; 1007 int bains; 1008 int coluid; 1009 int rowuid; 1010 int rowfnd; 1011 1012 int bkp_rowidx; 1013 1014 int minRowSelected; 1015 int maxRowSelected; 1016 1017 int sc_fr; 1018 int sc_lr; 1019 1020 int join_group; 1021 1022 int sync_flag; 1023 int paint_flag; 1024 1025 /* Points */ 1026 1027 Point oldpos; 1028 Point curpos; 1029 Point oldcur; 1030 Point curid; 1031 Point livecur; 1032 Point ctrlpos; 1033 Point ctrlid; 1034 Point shiftpos; 1035 Point leftpnt; 1036 Size osz; 1037 1038 /* Others */ 1039 1040 Ctrl * focused_ctrl; 1041 int focused_ctrl_id; 1042 Value focused_ctrl_val; 1043 int focused_col; 1044 1045 WString search_string; 1046 1047 bool curResizeCol; 1048 bool curResizeRow; 1049 1050 bool resizeCol; 1051 bool resizeRow; 1052 1053 int splitCol, splitRow; 1054 int firstColPos, firstRowPos; 1055 int hcol, hrow; 1056 int dx, dy; 1057 1058 GridPopUpHeader pophdr; 1059 FrameRight<StaticRect> scrollbox; 1060 1061 int sortCol; 1062 Vector<int> sortOrder; 1063 1064 public: 1065 1066 struct SortOrder : Moveable<SortOrder> 1067 { 1068 int id; 1069 Id name; 1070 bool ascending; 1071 bool descending; 1072 }; 1073 1074 public: 1075 1076 /* Colors */ 1077 1078 Color fg_focus, bg_focus; 1079 Color fg_select, bg_select; 1080 Color fg_live, bg_live; 1081 Color fg_found, bg_found; 1082 Color fg_even, bg_even; 1083 Color fg_odd, bg_odd; 1084 Color fg_grid; 1085 1086 1087 public: 1088 GridCtrl(); 1089 ~GridCtrl(); 1090 1091 /* Properties */ 1092 GridCtrl& HorzGrid(bool b = true) { horz_grid = b; return *this; } 1093 GridCtrl& VertGrid(bool b = true) { vert_grid = b; return *this; } 1094 GridCtrl& DrawLastHorzLine(bool b = true) { draw_last_horz_line = b; return *this; } 1095 GridCtrl& DrawLastVertLine(bool b = true) { draw_last_vert_line = b; return *this; } 1096 GridCtrl& MultiSelect(bool b = true) { multi_select = b; return *this; } 1097 GridCtrl& ResizingCols(bool b = true) { resizing_cols = b; return *this; } 1098 GridCtrl& ResizingRows(bool b = true) { resizing_rows = b; return *this; } 1099 GridCtrl& MovingCols(bool b = true) { moving_cols = b; return *this; } 1100 GridCtrl& MovingRows(bool b = true) { moving_rows = b; return *this; } 1101 GridCtrl& Dragging(bool b = true) { dragging = b; return *this; } 1102 GridCtrl& ResizePaintMode(int m = 0) { resize_paint_mode = m; return *this; } 1103 GridCtrl& LiveCursor(bool b = true) { live_cursor = b; return *this; } 1104 GridCtrl& Sorting(bool b = true) { sorting = b; return *this; } 1105 GridCtrl& MultiSorting(bool b = true) { sorting_multicol = b; return *this; } 1106 GridCtrl& Header(bool b = true) { header = b; return *this; } EditMode(int m)1107 GridCtrl& EditMode(int m) { edit_mode = m; return *this; } EditRow()1108 GridCtrl& EditRow() { edit_mode = GE_ROW; return *this; } EditCell()1109 GridCtrl& EditCell() { edit_mode = GE_CELL; return *this; } 1110 GridCtrl& OneClickEdit(bool b = true) { one_click_edit = b; return *this; } 1111 GridCtrl& GotoFirstEdit(bool b = true) { goto_first_edit = b; return *this; } Absolute()1112 GridCtrl& Absolute() { return ResizeColMode(0); } Proportional()1113 GridCtrl& Proportional() { return ResizeColMode(1); } 1114 GridCtrl& SelectRow(bool b = true) { select_row = b; return *this; } 1115 GridCtrl& AutoHideHorzSb(bool b = true) { sbx.AutoHide(b); return *this; } 1116 GridCtrl& AutoHideVertSb(bool b = true) { sby.AutoHide(b); return *this; } 1117 GridCtrl& AutoHideSb(bool b = true) { sbx.AutoHide(b); 1118 sby.AutoHide(b); return *this; } 1119 1120 GridCtrl& ResizeColMode(int m = 0); 1121 GridCtrl& ResizeRowMode(int m = 0); 1122 1123 GridCtrl& Indicator(bool b = true, int size = -1); 1124 1125 GridCtrl& GridColor(Color fg = SColorShadow); 1126 GridCtrl& FocusColor(Color fg = SColorHighlightText, Color bg = SColorHighlight); 1127 GridCtrl& LiveColor(Color fg = SColorText, Color bg = SColorHighlight); 1128 GridCtrl& OddColor(Color fg = SColorText, Color bg = SColorInfo); 1129 GridCtrl& EvenColor(Color fg = SColorText, Color bg = Blend(SColorHighlight, SColorPaper, 220)); 1130 GridCtrl& ColoringMode(int m); 1131 1132 GridCtrl& ColorRows(bool b = true) { return ColoringMode(2 * b).EvenColor(); } 1133 GridCtrl& ColorCols(bool b = true) { return ColoringMode(1 * b).EvenColor(); } 1134 1135 SetDefaultRowHeight(int h)1136 GridCtrl& SetDefaultRowHeight(int h) { GD_ROW_HEIGHT = h; sby.SetLine(h); return *this; } 1137 GridCtrl& SetColWidth(int n, int width, bool recalc = true); 1138 GridCtrl& SetRowHeight(int n, int height, bool recalc = true); 1139 GridCtrl& SetColsMin(int size); 1140 GridCtrl& SetColsMax(int size); 1141 GetDefaultRowHeight()1142 int GetDefaultRowHeight() { return GD_ROW_HEIGHT; } 1143 1144 GridCtrl& Inserting(bool b = true) { inserting = b; return *this; } 1145 GridCtrl& Appending(bool b = true) { appending = b; return *this; } 1146 GridCtrl& Duplicating(bool b = true) { duplicating = b; return *this; } 1147 GridCtrl& Moving(bool b = true) { moving = b; return *this; } 1148 GridCtrl& Removing(bool b = true) { removing = b; return *this; } 1149 GridCtrl& Accepting(bool b = true) { accepting = b; return *this; } 1150 GridCtrl& Canceling(bool b = true) { canceling = b; return *this; } 1151 GridCtrl& Navigating(bool b = true) { navigating = b; return *this; } 1152 GridCtrl& Searching(bool b = true) { searching = b; return *this; } 1153 GridCtrl& Closing(bool b = true) { closing = b; return *this; } 1154 GridCtrl& Editing(bool b = true) { editing = b; return *this; } 1155 GridCtrl& EditsInNewRow(bool b = true) { edits_in_new_row = b; return *this; } 1156 GridCtrl& Hiding(bool b = true) { hiding = b; return *this; } 1157 GridCtrl& Clipboard(bool b = true) { clipboard = b; return *this; } 1158 GridCtrl& ExtraPaste(bool b = true) { extra_paste = b; return *this; } 1159 GridCtrl& FixedPaste(bool b = true) { fixed_paste = b; return *this; } 1160 GridCtrl& ClipboardCopy(bool b = true) { copy_allowed = b; return *this; } 1161 GridCtrl& ClipboardCut(bool b = true) { cut_allowed = b; return *this; } 1162 GridCtrl& ClipboardPaste(bool b = true) { paste_allowed = b; return *this; } 1163 GridCtrl& CopyColumnNames(bool b = true) { copy_column_names = b; return *this; } 1164 GridCtrl& AskRemove(bool b = true) { ask_remove = b; return *this; } 1165 GridCtrl& RowChanging(bool b = true) { row_changing = b; return *this; } 1166 1167 GridCtrl& DrawFocus(bool b = true) { draw_focus = b; return *this; } 1168 1169 GridCtrl& RejectNullRow(bool b = true) { reject_null_row = b; return *this; } 1170 GridCtrl& KeepLastRow(bool b = true) { keep_last_row = b; return *this; } 1171 GridCtrl& RemoveHides(bool b = true) { remove_hides = b; return *this; } 1172 GridCtrl& TabChangesRow(bool b = true) { tab_changes_row = b; return *this; } 1173 GridCtrl& TabAddsRow(bool b = true) { tab_adds_row = b; return *this; } 1174 GridCtrl& EnterLikeTab(bool b = true) { enter_like_tab = b; return *this; } 1175 GridCtrl& FullColResizing(bool b = true) { full_col_resizing = b; return *this; } 1176 GridCtrl& FullRowResizing(bool b = true) { full_row_resizing = b; return *this; } 1177 GridCtrl& Chameleon(bool b = true) { chameleon = b; return *this; } 1178 GridCtrl& SummaryRow(bool b = true) { summary_row = b; return *this; } 1179 GridCtrl& Popups(bool b = true) { popups = b; return *this; } 1180 GridCtrl& FocusLostAccepting(bool b = true) { focus_lost_accepting = b; return *this; } 1181 SearchOffset(int offset)1182 GridCtrl& SearchOffset(int offset) { find_offset = offset; return *this; } 1183 GridCtrl& SearchMoveCursor(bool b = true) { search_move_cursor = b; return *this; } 1184 GridCtrl& SearchImmediate(bool b = true) { search_immediate = b; return *this; } 1185 GridCtrl& SearchHideRows(bool b = true) { search_hide = b; return *this; } 1186 GridCtrl& SearchDisplay(bool b = true) { search_display = b; return *this; } 1187 static void IndexAsColumn(bool b = true) { index_as_column = b; } 1188 static void ReverseSortIcon(bool b = true) { reverse_sort_icon = b; } 1189 1190 GridCtrl& SetToolBar(bool b = true, int align = BarCtrl::BAR_BOTTOM, int frame = 1); GetToolBar()1191 ToolBar& GetToolBar() { return bar; } 1192 1193 GridCtrl& ResizePanel(bool b = true); 1194 BeforeAfterInserting()1195 GridCtrl& BeforeAfterInserting() { bains = 1; return *this; } AfterBeforeInserting()1196 GridCtrl& AfterBeforeInserting() { bains = 2; return *this; } 1197 1198 GridCtrl& HideColumn(int n = -1, bool refresh = true); 1199 GridCtrl& ShowColumn(int n, bool refresh = true); 1200 1201 GridCtrl& HideRow(int n = -1, bool refresh = true); 1202 GridCtrl& ShowRow(int n, bool refresh = true); 1203 1204 void MenuHideColumn(int n); 1205 1206 void HideRows(bool repaint = false); 1207 void ShowRows(bool repaint = false); 1208 1209 /* Virutals */ 1210 1211 virtual void Paint(Draw &w); 1212 virtual void MouseMove(Point p, dword keyflags); 1213 virtual void LeftDown(Point p, dword keyflags); 1214 virtual void LeftUp(Point p, dword keyflags); 1215 virtual void LeftDouble(Point p, dword keyflags); 1216 virtual void LeftRepeat(Point p, dword keyflags); 1217 virtual void RightDown(Point p, dword keyflags); 1218 virtual void Layout(); 1219 virtual void MouseLeave(); 1220 virtual bool Key(dword key, int); 1221 virtual void GotFocus(); 1222 virtual void LostFocus(); 1223 virtual void ChildGotFocus(); 1224 virtual void ChildLostFocus(); 1225 virtual void MouseWheel(Point p, int zdelta, dword keyflags); 1226 virtual Image CursorImage(Point p, dword); 1227 virtual void State(int reason); 1228 virtual void ChildMouseEvent(Ctrl *child, int event, Point p, int zdelta, dword keyflags); 1229 virtual void ChildFrameMouseEvent(Ctrl *child, int event, Point p, int zdelta, dword keyflags); 1230 virtual bool Accept(); 1231 virtual void Reject(); 1232 1233 virtual void DragAndDrop(Point p, PasteClip& d); 1234 1235 void ChildAction(Ctrl *child, int event); 1236 void RestoreFocus(); 1237 1238 /* Methods */ 1239 1240 ItemRect& InsertColumn(int pos, const char *name = "", int size = -1, bool idx = false); 1241 ItemRect& AddColumn(const Id id, const char *name = "", int size = -1, bool idx = false); 1242 ItemRect& AddColumn(const String& name, int size = -1, bool idx = false); 1243 ItemRect& AddColumn(const char *name = "", int size = -1, bool idx = false); 1244 1245 void RemoveColumn(int n, int count = 1); 1246 AddHiddenColumn()1247 ItemRect& AddHiddenColumn() { return AddColumn(0, 0); } AddHiddenColumn(const char * name)1248 ItemRect& AddHiddenColumn(const char *name) { return AddColumn(name, 0); } AddHiddenColumn(String & name)1249 ItemRect& AddHiddenColumn(String &name) { return AddColumn(name, 0); } 1250 AddIndex()1251 ItemRect& AddIndex() { return AddColumn("", 0, true); } AddIndex(Id id)1252 ItemRect& AddIndex(Id id) { return AddColumn(id, ~id, 0, true); } AddIndex(const char * name)1253 ItemRect& AddIndex(const char *name) { return AddColumn(name, 0, true); } AddIndex(String & name)1254 ItemRect& AddIndex(String &name) { return AddColumn(name, 0, true); } 1255 1256 ItemRect& AddRow(int n = 1, int size = -1); Add()1257 GridCtrl& Add() { AddRow(); return *this; } 1258 1259 //$-GridCtrl& Add(const Value& [, const Value& ]...); 1260 #define E__Add(I) GridCtrl& Add(__List##I(E__Value)); 1261 __Expand(E__Add) 1262 #undef E__Add 1263 //$+ 1264 1265 //$-ItemRect& AddRow(const Value& [, const Value& ]...); 1266 #define E__Add(I) ItemRect& AddRow(__List##I(E__Value)); 1267 __Expand(E__Add) 1268 #undef E__Add 1269 //$+ 1270 1271 GridCtrl& AddSeparator(Color c); 1272 GetColumnCount()1273 int GetColumnCount() const { return total_cols - fixed_cols; } GetFixedColumnCount()1274 int GetFixedColumnCount() const { return fixed_cols; } 1275 1276 ItemRect& GetColumn(int n); 1277 ItemRect& GetColumn(); 1278 ItemRect& GetRow(int n); 1279 ItemRect& GetRow(); 1280 Item& GetCell(int n, int m); 1281 Item& GetCell(int n, Id id); 1282 1283 bool IsColumn(const Id& id); 1284 1285 int GetCurrentRow() const; 1286 bool IsCurrentRow() const; 1287 void RestoreCurrentRow(); 1288 1289 int GetWidth(int n = -1); 1290 int GetHeight(int n = -1); 1291 int GetFixedWidth(); 1292 int GetFixedHeight(); 1293 1294 void Set(int r, int c, const Value &val); 1295 void Set(int r, Id id, const Value &val); 1296 void Set(int r, const char *s, const Value &val); 1297 void Set(int c, const Value &val); 1298 void Set(Id id, const Value &val); 1299 void Set(int r, const Vector<Value> &v, int data_offset = 0, int column_offset = 0); 1300 void Set(const Vector<Value> &v, int data_offset = 0, int column_offset = 0); 1301 void SetAny(int r, int c, const Value &val); 1302 void SetRaw(int r, int c, const Value &val); 1303 void SetIndicator(int r, const Value &val); 1304 1305 void SetCtrl(int r, int c, Ctrl& ctrl); 1306 void SetCtrl(int r, int c, Ctrl* ctrl); 1307 void SetCtrl(int c, Ctrl& ctrl); 1308 void SetCtrl(int c, Ctrl* ctrl); 1309 1310 void ClearCtrl(int r, int c); 1311 void SetCtrlValue(int r, int c, const Value &val); 1312 void SetCtrlValue(int c, const Value &val); 1313 1314 void SetLast(int c, const Value &val); 1315 void SetFixed(int r, int c, const Value &val); 1316 Value GetFixed(int r, int c) const; 1317 Value GetFixed(int c) const; 1318 Value Get(int r, int c) const; 1319 Value Get(int c) const; 1320 Value Get(Id id) const; 1321 Value Get(int r, Id id) const; 1322 Value Get() const; 1323 Value Get(const char * alias) const; 1324 Value Get(int r, const char * alias) const; 1325 Value GetRaw(int r, int c) const; 1326 Value GetNew(int c) const; 1327 Value GetFirst(int c) const; 1328 Value GetLast(int c) const; 1329 Value GetPrev(Id id) const; 1330 Value GetPrev(int c) const; 1331 Value& operator() (int r, int c); 1332 Value& operator() (int c); 1333 Value& operator() (Id id); 1334 Value& operator() (int r, Id id); 1335 Value& operator() (const char * alias); 1336 Value& operator() (int r, const char * alias); 1337 void SetSummary(int c, const Value& val); 1338 void SetSummary(Id id, const Value& val); 1339 Value GetSummary(int c); 1340 Value GetSummary(Id id); 1341 1342 Vector< Vector<Value> > GetValues(); 1343 void SetValues(const Vector< Vector<Value> >& v); 1344 1345 using Ctrl::IsModified; 1346 1347 bool IsModified(int r, int c); 1348 bool IsModified(int c); 1349 bool IsModified(int r, Id id); 1350 bool IsModified(Id id); 1351 1352 /* valid only in callbacks */ 1353 IsNewRow()1354 bool IsNewRow() { return newrow_inserted || newrow_appended; } IsNewRowInserted()1355 bool IsNewRowInserted() { return newrow_inserted; } IsNewRowAppended()1356 bool IsNewRowAppended() { return newrow_appended; } IsModifiedRow()1357 bool IsModifiedRow() { return row_modified > 0; } CommitNewRow()1358 void CommitNewRow() { newrow_inserted = newrow_appended = false; } 1359 IsUpdatedRow()1360 bool IsUpdatedRow() { return vitems[rowidx].operation == GridOperation::UPDATE; } IsInsertedRow()1361 bool IsInsertedRow() { return vitems[rowidx].operation == GridOperation::INSERT; } IsRemovedRow()1362 bool IsRemovedRow() { return vitems[rowidx].operation == GridOperation::REMOVE; } IsChangedRow()1363 bool IsChangedRow() { return IsUpdatedRow() || IsInsertedRow(); } IsVersionedRow()1364 bool IsVersionedRow() { return vitems[rowidx].operation.GetVersion() > 0; } GetRowOperation()1365 int GetRowOperation() { return vitems[rowidx].operation; } 1366 1367 Vector<Value> ReadCol(int n = -1, int start_row = -1, int end_row = -1) const; 1368 Vector<Value> ReadRow(int n = -1, int start_col = -1, int end_col = -1) const; 1369 GridCtrl& Add(const Vector<Value> &v, int offset = 0, int count = -1, bool hidden = false); 1370 1371 void SetFixedRows(int n = 1); 1372 void SetFixedCols(int n = 1); 1373 GetStdRowHeight()1374 int GetStdRowHeight() { return GD_ROW_HEIGHT; } 1375 1376 void RefreshRow(int n = -1, bool relative = true, bool fixed = false); 1377 void RefreshCol(int n = -1, bool relative = true, bool fixed = false); 1378 void RefreshRows(int from, int to, bool relative = true, bool fixed = false); 1379 void RefreshItem(int r, int c, bool relative = true); 1380 void RefreshNewRow(); 1381 void RefreshFrom(int from); 1382 1383 void RefreshTop(); 1384 void RefreshLeft(); 1385 void RefreshSummary(); 1386 1387 void Repaint(bool recalc_cols = false, bool recalc_rows = false, int opt = RP_ALL); 1388 void Ready(bool b); 1389 1390 int GetMouseRow(Point &p, bool relative = true, bool fixed = false, bool full = true); 1391 int GetMouseCol(Point &p, bool relative = true, bool fixed = false, bool full = true); 1392 1393 void UpdateCursor(); 1394 1395 int Find(const Value &v, int col = 0, int start_from = 0, int opt = 0) const; 1396 int Find(const Value &v, Id id, int opt = 0) const; 1397 int Find(const Value &v0, Id id0, const Value &v1, Id id1, int opt = 0) const; 1398 int FindCurrent(Id id, int opt = GF::SKIP_CURRENT_ROW) const; 1399 int FindCurrent(Id id0, Id id1, int opt = GF::SKIP_CURRENT_ROW) const; 1400 1401 int FindInRow(const Value& v, int row = 0, int start_from = 0) const; 1402 GetDisplay()1403 GridDisplay& GetDisplay() { return *display; } SetDisplay(GridDisplay & gd)1404 GridCtrl& SetDisplay(GridDisplay &gd) { display = &gd; return *this; } 1405 1406 void SetDisplay(int r, int c, GridDisplay& gd); 1407 IsEdit()1408 bool IsEdit() { return isedit; } 1409 bool StartEdit(); 1410 bool SwitchEdit(); 1411 bool EndEdit(bool accept = true, bool doall = false, bool remove_row = true); 1412 bool CancelEdit(bool remove_row = true) { return EndEdit(false, false, remove_row); } 1413 1414 int Append(int cnt = 1, bool refresh = true, int height = -1); 1415 void Insert(int i, int cnt = 1); 1416 void Remove(int i = -1, int cnt = 1); 1417 void RemoveFirst(int cnt = 1); 1418 void RemoveLast(int cnt = 1); 1419 void Duplicate(int i, int cnt = 1); 1420 CancelRemove()1421 void CancelRemove() { cancel_remove = true; } CancelUpdate()1422 void CancelUpdate() { cancel_update = true; } CancelInsert()1423 void CancelInsert() { cancel_insert = true; } CancelUpdateCell()1424 void CancelUpdateCell() { cancel_update_cell = true; } CancelAccept()1425 void CancelAccept() { cancel_accept = true; } CancelDuplicate()1426 void CancelDuplicate() { cancel_duplicate = true; } CancelCursor()1427 void CancelCursor() { cancel_cursor = true; } CancelMove()1428 void CancelMove() { cancel_move = true; } 1429 1430 void ClearCursor(bool remove = false); 1431 void ClearRow(int r = -1, int column_offset = 0); 1432 void Clear(bool columns = false); 1433 void Reset(); 1434 1435 void ClearOperations(); 1436 void ClearVersions(); 1437 1438 void Begin(); 1439 void Next(); 1440 void Prev(); 1441 void End(); 1442 void Move(int r); 1443 bool IsEnd(); 1444 1445 bool IsFirst(); 1446 bool IsLast(); 1447 bool IsNext(); 1448 bool IsPrev(); 1449 1450 int SetCursor(int n); 1451 void SetCursor(const Point& p); 1452 int SetCursorId(int n); 1453 int GetCursor(bool rel = false) const; 1454 int GetPrevCursor(bool rel = false) const; 1455 int GetCursor(int uid) const; 1456 Point GetCursorPos() const; 1457 void CenterCursor(); IsCursor()1458 bool IsCursor() const { return valid_cursor; } IsCursorBegin()1459 bool IsCursorBegin() const { return curpos.y == fixed_rows; } IsCursorEnd()1460 bool IsCursorEnd() const { return curpos.y == total_rows - 1; } 1461 1462 int GetNewRowPos(); 1463 int GetNewRowId(); 1464 int GetRemovedRowPos(); 1465 GetCursorId()1466 int GetCursorId() const { return GetCursor(true); } GetPrevCursorId()1467 int GetPrevCursorId() const { return GetPrevCursor(true); } 1468 int GetColId() const; 1469 int GetRowId() const; 1470 int GetColId(int n) const; 1471 int GetRowId(int n) const; 1472 int GetColUId() const; 1473 int GetRowUId() const; 1474 int FindCol(int id) const; 1475 int FindCol(const Id& id) const; 1476 int FindCol(const String& s) const; 1477 int FindRow(int id) const; 1478 1479 int GetNextRow(int n); 1480 int GetPrevRow(int n); 1481 1482 bool GoBegin(bool scroll = true); 1483 bool GoEnd(bool scroll = true, bool goleft = false); 1484 bool GoNext(bool scroll = true); 1485 bool GoPrev(bool scroll = true); 1486 bool GoLeft(bool scroll = true, bool ctrlmode = false); 1487 bool GoRight(bool scroll = true, bool ctrlmode = false); 1488 bool GoPageUp(bool scroll = true); 1489 bool GoPageDn(bool scroll = true); 1490 bool GoFirstVisible(bool scroll = true); 1491 void GoTo(int r, bool setcursor = true, bool scroll = true); 1492 void GoTo(int r, int c, bool setcursor = true, bool scroll = true); GoTop()1493 bool GoTop() { return GoBegin(); } 1494 1495 void SwapCols(int n, int m); 1496 bool SwapRows(int n, int m, bool repaint = true); 1497 1498 void SwapUp(int cnt = 1); 1499 void SwapDown(int cnt = 1); 1500 1501 bool CanMoveCol(int n, int m); 1502 1503 void MoveCol(int n, int m); 1504 bool MoveRow(int n, int m, bool repaint = true); 1505 1506 void MoveRows(int n, bool onerow = false); 1507 1508 int GetCount() const; GetRowCount()1509 int GetRowCount() const { return GetCount(); } 1510 int GetVisibleCount() const; 1511 int GetFixedCount() const; 1512 int GetTotalCount() const; 1513 1514 void SetRowCount(int n, int size = -1); 1515 void SetColCount(int n, int size = 100); 1516 1517 void Select(int n, int cnt = 1); 1518 void ClearSelection(); IsSelection()1519 bool IsSelection() { return selected_rows > 0; } IsSelectionBegin()1520 bool IsSelectionBegin() { return sel_begin; } IsSelectionEnd()1521 bool IsSelectionEnd() { return sel_end; } GetSelectedCount()1522 int GetSelectedCount() { return selected_rows; } GetSelectedItemsCount()1523 int GetSelectedItemsCount() { return selected_items; } 1524 bool IsSelected(int n, bool relative = true); 1525 bool IsSelected(int n, int m, bool relative = true); 1526 bool IsSelected(); 1527 1528 void Copy(bool all = false) { SetClipboard(all, true); } CopyAll()1529 void CopyAll() { Copy(true); } 1530 1531 void DoInsert0(bool edit, bool after); 1532 void DoInsertBefore0(bool edit); 1533 void DoInsertBefore(); 1534 void DoInsertBeforeNoEdit(); 1535 void DoInsertAfter0(bool edit); 1536 void DoInsertAfter(); 1537 void DoInsertAfterNoEdit(); 1538 void DoRemove(); 1539 void DoAppend0(bool edit); 1540 void DoAppend(); 1541 void DoAppendNoEdit(); 1542 void DoDuplicate0(); 1543 void DoDuplicate(); 1544 void DoEdit(); 1545 void DoEndEdit(); 1546 void DoCancelEdit(); 1547 void DoSelectAll(); 1548 void DoSwapUp(); 1549 void DoSwapDown(); 1550 void DoShiftSelect(); 1551 void DoCtrlSelect(); 1552 void DoGoBegin(); 1553 void DoGoEnd(); 1554 void DoGoNext(); 1555 void DoGoPrev(); 1556 void DoGoLeft(); 1557 void DoGoRight(); 1558 void DoGoPageUp(); 1559 void DoGoPageDn(); 1560 void DoFind(); 1561 1562 void StdMenuBar(Bar &bar); 1563 void StdToolBar(Bar &bar); 1564 void FindOptsBar(Bar &bar); 1565 void FindBar(Bar &bar, int cx); 1566 void InfoBar(Bar &bar, int cx); 1567 void NavigatingBar(Bar &bar); 1568 void RemovingMenu(Bar &bar); 1569 void MovingMenu(Bar &bar); 1570 void SelectMenu(Bar &bar); 1571 void ColumnsMenu(Bar &bar); 1572 void ColumnList(Bar &bar); 1573 void ClipboardMenu(Bar &bar); 1574 void PasteAsMenu(Bar &bar); 1575 RebuildToolBar()1576 void RebuildToolBar() { bar.Set(WhenToolBar); } 1577 void SetToolBarInfo(String inf); 1578 1579 void ClearFound(bool showrows = true, bool clear_string = true); 1580 IsEmpty()1581 bool IsEmpty() { return total_rows <= fixed_rows; } IsFilled()1582 bool IsFilled() { return total_rows > fixed_rows; } IsOrderChanged()1583 bool IsOrderChanged() { return row_order; } IsDataChanged()1584 bool IsDataChanged() { return row_data; } IsChanged()1585 bool IsChanged() { return row_order || row_data; } ClearChanged()1586 void ClearChanged() { row_order = row_data = false; ClearModify(); } 1587 1588 bool IsRowEditable(int r = -1); 1589 bool IsRowClickable(int r = -1); 1590 1591 void Serialize(Stream &s); 1592 1593 Ctrl * GetCtrl(int r, int c); // checks visibility - if widget is out of view, returns NULL 1594 Ctrl * GetCtrlAt(int r, int c); // does not check visibility 1595 Ctrl * GetCtrl(int c); // checks visibility - if widget is out of view, returns NULL 1596 GetStdHeight()1597 static int GetStdHeight() { return Draw::GetStdFontCy() + 4; } 1598 1599 void Debug(int n = 0); UpdateScrollbars()1600 void UpdateScrollbars() { UpdateSb(); } 1601 1602 void JoinCells(int left, int top, int right, int bottom, bool relative = true); 1603 void JoinFixedCells(int left, int top, int right, int bottom); 1604 void JoinRow(int n, int left, int right); 1605 void JoinRow(int left = -1, int right = -1); 1606 void UpdateJoins(int row, int col, int cnt = 1); 1607 1608 GridCtrl& Sort(int sort_col, int sort_mode = SORT_UP, bool multisort = false, bool repaint = true); 1609 GridCtrl& Sort(Id id, int sort_mode = SORT_UP, bool multisort = false, bool repaint = true); 1610 GridCtrl& MultiSort(int sort_col, int sort_mode = SORT_UP); 1611 GridCtrl& MultiSort(Id id, int sort_mode = SORT_UP); 1612 void ClearSort(); 1613 void ReSort(); 1614 void MarkSort(int col, int sort_mode); 1615 void MarkSort(Id id, int sort_mode); 1616 1617 Vector<SortOrder> GetSortOrder() const; 1618 Vector<Id> GetSortOrderId() const; 1619 HorzScroll()1620 ScrollBar& HorzScroll() { return sbx; } VertScroll()1621 ScrollBar& VertScroll() { return sby; } 1622 1623 Value GetStdConvertedValue(const Value& v) const; 1624 Value GetConvertedColumn(int col, const Value& v) const; 1625 Value GetStdConvertedColumn(int col, const Value& v) const; 1626 String GetString(Id id) const; 1627 1628 bool Search(dword key); 1629 int GetResizePanelHeight() const; 1630 String GetColumnName(int n) const; 1631 Id GetColumnId(int n) const; 1632 1633 void SetCtrlFocus(int col); 1634 void SetCtrlFocus(Id id); 1635 1636 String GetColumnWidths(); 1637 void ColumnWidths(const char* s); 1638 #ifdef flagGRIDSQL 1639 void FieldLayout(FieldOperator& f); Fields()1640 operator Fields() { return THISBACK(FieldLayout); } SqlSet()1641 operator SqlSet() const { return GetColumnList(); } 1642 SqlSet GetColumnList(bool skip_hidden = false) const; 1643 #endif 1644 1645 void UpdateSummary(bool b = true); 1646 1647 private: 1648 1649 bool TabKey(bool enter_mode); 1650 1651 bool Go0(int jump, bool scroll = true, bool goleft = false, bool ctrlmode = false); 1652 1653 CurState SetCursor0(Point p, int opt = 0, int dirx = 0, int diry = 0); 1654 CurState SetCursor0(int x, int y, int opt = 0, int dirx = 0, int diry = 0); 1655 int SetCursor0(int n); 1656 1657 bool IsValidCursor(const Point &p, int fc, int lc, int fr, int lr) const; 1658 bool IsValidCursorVis(const Point &p) const; 1659 bool IsValidCursorAll(const Point &p) const; 1660 bool IsValidCursor(const Point &p) const; 1661 bool IsValidCursor(int c) const; 1662 1663 void SetItemCursor(Point p, bool b, bool highlight); 1664 1665 void Insert0(int row, int cnt = 1, bool recalc = true, bool refresh = true, int size = -1); 1666 bool Remove0(int row, int cnt = 1, bool recalc = true, bool refresh = true, bool whens = true); 1667 bool Duplicate0(int row, int cnt = 1, bool recalc = true, bool refresh = true); 1668 int Append0(int cnt = 1, int size = -1, bool refresh = true); 1669 1670 void GoCursorLeftRight(); 1671 1672 void UpdateSb(bool horz = true, bool vert = true); 1673 void UpdateHolder(bool force = false); 1674 bool UpdateCols(bool force = false); 1675 bool UpdateRows(bool force = false); 1676 bool UpdateSizes(); 1677 void UpdateHighlighting(int mode, Point p = Null); 1678 void UpdateVisColRow(bool col); 1679 1680 bool HasCtrls(); 1681 bool ShowNextCtrl(); 1682 bool ShowPrevCtrl(); 1683 public: 1684 void SyncCtrls(int r = -1, int c = -1); 1685 private: 1686 void UpdateCtrls(int opt = UC_CHECK_VIS | UC_SHOW | UC_CURSOR | UC_FOCUS); 1687 void SyncSummary(); 1688 void SyncPopup(); 1689 1690 void SetCtrlsData(); 1691 bool GetCtrlsData(bool samerow = false, bool doall = false, bool updates = true); 1692 bool CancelCtrlsData(bool all = false); 1693 void UpdateDefaults(int ri); 1694 1695 int GetFocusedCtrlIndex(); 1696 Point GetCtrlPos(Ctrl * ctrl); 1697 1698 void Split(int state = 0, bool sync = false); 1699 void Scroll(); 1700 IsTopHeader()1701 bool IsTopHeader() { return fixed_rows > 0; } IsLeftHeader()1702 bool IsLeftHeader() { return fixed_cols > 1 || indicator; } 1703 1704 bool IsMouseBody(Point &p); 1705 1706 void DrawLine(bool iniLine, bool delLine); 1707 1708 Rect GetItemRect(int r, int c, bool hgrid = false, bool vgrid = false, bool hrel = false, bool vrel = false); 1709 1710 bool Match(const WString &f, const WString &s, int &fs, int &fe); 1711 int ShowMatchedRows(const WString &f); 1712 1713 void SelectCount(int i, int cnt = 1, bool sel = true); 1714 void SelectRange(int from, int to, bool sel = true); 1715 void SelectRange(Point from, Point to, bool sel = true, bool fullrow = false); 1716 void ShiftSelect(int from, int to); 1717 void ShiftSelect(Point from, Point to); 1718 void SelectInverse(int from, int to); 1719 int GetMinRowSelected(); 1720 int GetMaxRowSelected(); 1721 1722 void CloseGrid(); 1723 String RowFormat(const char *s); 1724 1725 void SetFindOpts(int n); 1726 GetItem(const Point & p)1727 Item& GetItem(const Point &p) { return GetItem(p.y, p.x); } GetItem(int n,int m)1728 Item& GetItem(int n, int m) { return items[vitems[n].id][hitems[m].id]; } 1729 1730 void Set0(int r, int c, const Value &val, bool paste = false); 1731 Value Get0(int r, int c) const; 1732 1733 int GetSplitCol(const Point &p, int splitSize = 5, bool full = false); 1734 int GetSplitRow(const Point &p, int splitSize = 5, bool full = false); 1735 1736 int GetFirst0(Vector<ItemRect> &its, int total, int sb, int diff); 1737 int GetFirstVisCol(int diff); 1738 int GetFirstVisRow(int diff); 1739 1740 bool SetDiffItemSize(bool horizontal, RectItems &its, int n, int diff, bool newsize = true); 1741 void Recalc(bool horizontal, RectItems &its, int n, double size, double diff); 1742 bool Recalc(bool horizontal, RectItems &its, int mode = -1); 1743 bool RecalcCols(int mode = -1); 1744 bool RecalcRows(int mode = -1); 1745 void CalcIntPos(RectItems &its, int n, int maxsize, int cnt, int resize_mode, bool renumber = false); 1746 1747 Rect& AlignRect(Rect &r, int i); 1748 1749 void MouseAccel(const Point &p, bool horz, bool vert, dword keyflags); 1750 1751 void GSort(int scol = -1); 1752 void GSort(int col, int order, int from, int count = -1); 1753 void Multisort(); 1754 int InMultisort(int col); 1755 void ClearMultisort(int n = 0); 1756 bool IsSorted(); 1757 void MarkSort(int col, int sort_mode, bool refresh); 1758 1759 void DrawHorzDragLine(Draw &w, int pos, int cx, int size, Color c); 1760 void DrawVertDragLine(Draw &w, int pos, int size, int dx, Color c); 1761 1762 void SetOrder(); 1763 1764 void Nothing(); 1765 void Init(); 1766 1767 Ctrl * GetCtrl(int x, int y, bool check_visibility, bool hrel = false, bool vrel = false, bool check_edits = true); 1768 Ctrl * GetCtrl(const Point &p, bool check_visibility, bool hrel = false, bool vrel = false, bool check_edits = true); 1769 bool IsCtrl(Point &p, bool check_visibility = true); 1770 1771 GridClipboard GetClipboard(); 1772 void SetClipboard(bool all = false, bool silent = false); 1773 bool IsClipboardAvailable(); 1774 void PasteCallbacks(bool new_row); 1775 void Paste(int mode = 0); 1776 void DoCopy(); 1777 void DoPaste(); 1778 void DoPasteInsertedRows(); 1779 void DoPasteAppendedRows(); 1780 1781 Point GetBarOffset(); 1782 void ClearModified(); 1783 1784 int GetIdCol(int id, bool checkall = false) const; 1785 int GetIdRow(int id, bool checkall = false) const; 1786 Value GetItemValue(const Item& it, int id, const ItemRect& hi, const ItemRect& vi); 1787 void GetItemAttrs(const Item& it, const Value& val, int r, int c, const ItemRect& vi, const ItemRect& hi, dword& style, GridDisplay*& gd, Color& fg, Color& bg, Font& fnt); 1788 Item& GetItemSize(int &r, int &c, int &x, int &y, int &cx, int &cy, bool &skip, bool relx = true, bool rely = true); 1789 Value GetAttrTextVal(const Value& val); 1790 1791 Image HorzPosImage(); 1792 Image VertPosImage(); 1793 1794 private: 1795 bool WhenInsertRow0(); 1796 1797 public: 1798 1799 Event<Bar&> WhenMenuBar; 1800 Event<Bar&> WhenToolBar; 1801 1802 Event<> WhenLeftDouble; 1803 Event<> WhenLeftClick; 1804 Event<> WhenEnter; 1805 Event<> WhenEscape; 1806 1807 Event<> WhenStartEdit; 1808 Event<> WhenEndEdit; 1809 1810 Event<> WhenCreateRow; 1811 1812 Event<> WhenAcceptRow; 1813 Event<> WhenAcceptedRow; 1814 1815 Event<> WhenInsertRow; 1816 Event<> WhenUpdateRow; 1817 Event<> WhenRemoveRow; 1818 Event<> WhenRemovedRow; 1819 Event<> WhenDuplicateRow; 1820 1821 Callback2<int, int> WhenMoveRow; 1822 1823 Event<> WhenCancelNewRow; 1824 1825 Event<> WhenUpdateCell; 1826 1827 Event<> WhenUpdateSummary; 1828 1829 Event<> WhenNewRow; 1830 Event<> WhenChangeCol; 1831 Event<> WhenBeforeChangeCol; 1832 Event<> WhenChangeRow; 1833 Event<> WhenBeforeChangeRow; 1834 Event<> WhenCursor; 1835 Event<> WhenEmpty; 1836 1837 Event<> WhenCtrlAction; 1838 Event<> WhenCtrlsAction; 1839 1840 Event<> WhenSearchCursor; 1841 Event<> WhenClose; 1842 Event<> WhenChangeOrder; 1843 1844 Event<> StdInsert; 1845 Event<> StdAppend; 1846 Event<> StdRemove; 1847 Event<> StdDuplicate; 1848 Event<> StdEdit; 1849 1850 Event<> WhenSort; 1851 Event<> WhenSorted; 1852 1853 Event<Value&> ProcessSummaryValue; 1854 1855 Event<int, int, Value&> WhenPasteCell; 1856 Event<> WhenPaste; 1857 }; 1858 1859 class GridText : Ctrl 1860 { 1861 private: 1862 GridDisplay display; 1863 GridCtrl* parent; 1864 const Id* column; 1865 Color fg, bg; 1866 Font fnt; 1867 1868 public: 1869 GridText()1870 GridText() {} 1871 Paint(Draw & w)1872 virtual void Paint(Draw& w) 1873 { 1874 Rect r = GetRect(); 1875 display.Paint(w, r.left, r.top, r.Width(), r.Height(), parent->Get(*column), 0, fg, bg, fnt); 1876 } 1877 Ink(Color c)1878 void Ink(Color c) { fg = c; } Paper(Color c)1879 void Paper(Color c) { bg = c; } SetFont(Font f)1880 void SetFont(Font f) { fnt = f; } Column(const Id & c)1881 void Column(const Id& c) { column = &c; } 1882 }; 1883 1884 template<> void Xmlize(XmlIO& xml, GridCtrl& g); 1885 template<> void Jsonize(JsonIO& json, GridCtrl& g); 1886 1887 } 1888 1889 #endif 1890