mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
RichText::GetWidth now supports tables
git-svn-id: svn://ultimatepp.org/upp/trunk@7361 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
612aab8425
commit
6d19d6a002
3 changed files with 27 additions and 2 deletions
|
|
@ -185,6 +185,8 @@ private:
|
|||
int GetVertMove(int pos, int gx, RichContext rc, int dir) const;
|
||||
RichHotPos GetHotPos(int x, PageY y, int tolerance, RichContext rc) const;
|
||||
void AdjustSel(Rect& sel) const;
|
||||
|
||||
int GetWidth(const RichStyles& st) const;
|
||||
|
||||
void GatherValPos(Vector<RichValPos>& f, RichContext rc, int pos, int type) const;
|
||||
void ClearSpelling();
|
||||
|
|
@ -206,7 +208,7 @@ public:
|
|||
const RichTxt& Get(int i, int j) const { return cell[i][j].text; }
|
||||
void SetQTF(int i, int j, const char *qtf);
|
||||
void SetFormat(int i, int j, const RichCell::Format& fmt);
|
||||
const RichCell::Format& GetFormat(int i, int j) { return cell[i][j].format; }
|
||||
const RichCell::Format& GetFormat(int i, int j) const { return cell[i][j].format; }
|
||||
bool operator()(int i, int j) const { return ci[i][j].valid; }
|
||||
void SetSpan(int i, int j, int vspan, int hspan);
|
||||
Size GetSpan(int i, int j) const;
|
||||
|
|
|
|||
|
|
@ -172,6 +172,29 @@ void RichTable::Paint(PageDraw& pw, RichContext rc, const PaintInfo& _pi) const
|
|||
pw.tracer->EndTable(rc.py);
|
||||
}
|
||||
|
||||
int RichTable::GetWidth(const RichStyles& st) const
|
||||
{
|
||||
Size sz = GetSize();
|
||||
Buffer<int> col(sz.cx, 0);
|
||||
|
||||
for(int x = 0; x < sz.cx; x++)
|
||||
for(int y = 0; y < sz.cy; y++) {
|
||||
const RichCell::Format& fmt = GetFormat(y, x);
|
||||
col[x] = max(col[x], Get(y, x).GetWidth(st)
|
||||
+ fmt.border.left + fmt.border.right + fmt.margin.left + fmt.margin.right);
|
||||
}
|
||||
|
||||
int sum = 0;
|
||||
for(int i = 0; i < sz.cx; i++)
|
||||
sum += format.column[i];
|
||||
|
||||
int maxcx = 0;
|
||||
for(int i = 0; i < sz.cx; i++)
|
||||
maxcx = max(maxcx, (col[i] * sum + format.column[i] - 1) / format.column[i]);
|
||||
|
||||
return maxcx + (sz.cx + 1) * format.grid + format.lm + format.rm;
|
||||
}
|
||||
|
||||
PageY RichTable::GetHeight(RichContext rc) const
|
||||
{
|
||||
PageY pyy = Realize(rc).pyy;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ int RichTxt::GetWidth(const RichStyles& st) const
|
|||
cx = max(cx, ccx);
|
||||
}
|
||||
else
|
||||
return 10000;
|
||||
return GetTable(i).GetWidth(st);
|
||||
}
|
||||
return cx;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue