[Igarden-commit] CommonSource/YAAFExtensions RGTableView.cpp, 1.28.2.34, 1.28.2.35 RGTableView.h, 1
Status: Beta
Brought to you by:
jlbedell
|
From: Jeffrey B. <jlb...@us...> - 2008-04-09 03:36:50
|
Update of /cvsroot/igarden/CommonSource/YAAFExtensions In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv12602/YAAFExtensions Modified Files: Tag: Release_branch_v1 RGTableView.cpp RGTableView.h Log Message: Make columns wide enough to avoid splitting the longest word, and recompute title height with each new font. Index: RGTableView.cpp =================================================================== RCS file: /cvsroot/igarden/CommonSource/YAAFExtensions/RGTableView.cpp,v retrieving revision 1.28.2.34 retrieving revision 1.28.2.35 diff -C2 -d -r1.28.2.34 -r1.28.2.35 *** RGTableView.cpp 9 Apr 2008 03:03:17 -0000 1.28.2.34 --- RGTableView.cpp 9 Apr 2008 03:36:52 -0000 1.28.2.35 *************** *** 63,66 **** --- 63,68 ---- const long kDefaultTableFont = 138; + const short kBorderWidths = 8; // 4 pixels on either side + const short kTitleRows = 4; #pragma mark Construction / Destruction *************** *** 85,89 **** _sizeWidth = false; _setFocus = true; ! _titleHeight = (3+2) * draw.GetFontHeight(); _columnTitles.DeleteAll(); _titleClickMsg = 0; --- 87,91 ---- _sizeWidth = false; _setFocus = true; ! _titleHeight = kTitleRows * draw.GetFontHeight(); _columnTitles.DeleteAll(); _titleClickMsg = 0; *************** *** 144,148 **** _sizeWidth = false; _setFocus = true; ! _titleHeight = (3+2) * draw.GetFontHeight(); _columnTitles.DeleteAll(); _titleClickMsg = 0; --- 146,150 ---- _sizeWidth = false; _setFocus = true; ! _titleHeight = kTitleRows * draw.GetFontHeight(); _columnTitles.DeleteAll(); _titleClickMsg = 0; *************** *** 517,521 **** char oldName[256]; short oldSize; ! long origin, width, n, count; RGTableCell *cell; --- 519,523 ---- char oldName[256]; short oldSize; ! long origin, width, n, count, hdrWidth; RGTableCell *cell; *************** *** 525,531 **** --- 527,538 ---- if((oldSize != fontSize) || (strcmp(name, oldName) != 0)) { + XGDraw draw(this); + _font->SetFontName(name); _font->SetFontSize(fontSize); + draw.SetFontObject(_font); + _titleHeight = kTitleRows * draw.GetFontHeight(); + count = _colArray.Length(); for(n = 0, origin = 0; n < count; n++) *************** *** 550,553 **** --- 557,564 ---- if(width < _colArray[n]->initialWidth) width = _colArray[n]->initialWidth; + hdrWidth = MinHeadingWidth(_colArray[n]->title.c_str(), draw); + if(width < hdrWidth) + width = hdrWidth; + width += kBorderWidths; _colArray[n]->origin = origin; *************** *** 862,867 **** { struct ColRecord *info; ! short n, count, origin, minWidth, initialWidth; RGTableCell *cell; count = _colArray.Length(); --- 873,879 ---- { struct ColRecord *info; ! short n, count, origin, minWidth, initialWidth, hdrWidth; RGTableCell *cell; + XGDraw draw(this); count = _colArray.Length(); *************** *** 882,885 **** --- 894,901 ---- if(width < minWidth) width = minWidth; + hdrWidth = MinHeadingWidth(title, draw); + if(width < hdrWidth) + width = hdrWidth; + width += kBorderWidths; delete cell; *************** *** 899,902 **** --- 915,919 ---- info->menuRef = menuRef; info->client = client; + info->title.SetCString(title); if(client != NULL) { *************** *** 2683,2684 **** --- 2700,2723 ---- } + short RGTableView::MinHeadingWidth(const char *title, XGDraw &draw) + { + char *next; + short maxWidth = 0, oneWidth; + + draw.SetFontObject(_font); + next = strchr(title, ' '); + while(next != NULL) + { + oneWidth = draw.StringWidth(title, next-title); + if(oneWidth > maxWidth) + maxWidth = oneWidth; + + title = next+1; + next = strchr(title, ' '); + } + oneWidth = draw.StringWidth(title, strlen(title)); + if(oneWidth > maxWidth) + maxWidth = oneWidth; + + return maxWidth; + } \ No newline at end of file Index: RGTableView.h =================================================================== RCS file: /cvsroot/igarden/CommonSource/YAAFExtensions/RGTableView.h,v retrieving revision 1.16.2.14 retrieving revision 1.16.2.15 diff -C2 -d -r1.16.2.14 -r1.16.2.15 *** RGTableView.h 9 Apr 2008 03:03:12 -0000 1.16.2.14 --- RGTableView.h 9 Apr 2008 03:36:53 -0000 1.16.2.15 *************** *** 106,109 **** --- 106,110 ---- short cellType; uint32 menuRef; + String title; ClientColumn *client; }; *************** *** 337,340 **** --- 338,342 ---- void DrawHeaderButton(XGDraw &draw, Rect &s, buttonTask_t task, bool isPrinter); short NearDragEdge(Point pt); + short MinHeadingWidth(const char *title, XGDraw &draw); /* |