htable.h 873 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef H_TABLE_H
  2. #define H_TABLE_H
  3. #include <map>
  4. class HTableCell{
  5. public:
  6. HTableCell(){r1=r2=c1=c2=0;}
  7. HTableCell(int r1, int r2, int c1, int c2){
  8. this->r1 = r1;
  9. this->r2 = r2;
  10. this->c1 = c1;
  11. this->c2 = c2;
  12. }
  13. int rowspan() {return r2 - r1 + 1;}
  14. int colspan() {return c2 - c1 + 1;}
  15. int span() {return rowspan() * colspan();}
  16. bool contain(HTableCell cell){
  17. if (cell.r1 >= r1 && cell.r2 <= r2 &&
  18. cell.c1 >= c1 && cell.c2 <= c2)
  19. return true;
  20. return false;
  21. }
  22. int r1,r2,c1,c2;
  23. };
  24. class HTable
  25. {
  26. public:
  27. HTable();
  28. void init(int row, int col);
  29. bool getTableCell(int id, HTableCell& rst);
  30. HTableCell merge(int lt, int rb);
  31. public:
  32. int row;
  33. int col;
  34. std::map<int, HTableCell> m_mapCells; // id => HTabelCell
  35. };
  36. #endif // H_TABLE_H