Ticket #1806: TermView.cpp.diff

File TermView.cpp.diff, 5.2 KB (added by pulkomandy, 16 years ago)

Add a 3 pixel offset both to left, right, top and bottom borders of the view.

  • TermView.cpp

     
    5858    {245, 245, 245, 0}, // white
    5959};
    6060
     61//Space at the borders of the view
     62#define OFFSET 3
    6163
    6264#define ROWS_DEFAULT 25
    6365#define COLUMNS_DEFAULT 80
     
    332334TermView::GetPreferredSize(float *width, float *height)
    333335{
    334336    if (width)
    335         *width = fTermColumns * fFontWidth;
     337        *width = fTermColumns * fFontWidth + 2 * OFFSET;
    336338    if (height)
    337         *height = fTermRows * fFontHeight;
     339        *height = fTermRows * fFontHeight + 2 * OFFSET;
    338340}
    339341
    340342
     
    371373    fScrTop = 0;
    372374    fScrBot = fTermRows - 1;
    373375
    374     BRect rect(0, 0, fTermColumns * fFontWidth, fTermRows * fFontHeight);
     376    BRect rect(0, 0, fTermColumns * fFontWidth + 2 * OFFSET, fTermRows * fFontHeight + 2 * OFFSET);
    375377
    376378    if (resize)
    377379        ResizeTo(rect.Width(), rect.Height());
     
    941943void
    942944TermView::DrawCursor()
    943945{
    944     BRect rect(fFontWidth * fCurPos.x, fFontHeight * fCurPos.y + fTop,
    945         fFontWidth * (fCurPos.x + 1) - 1, fFontHeight * fCurPos.y + fTop + fCursorHeight - 1);
     946    BRect rect(fFontWidth * fCurPos.x + OFFSET,
     947        fFontHeight * fCurPos.y + fTop + OFFSET,
     948        fFontWidth * (fCurPos.x + 1) - 1 + OFFSET,
     949        fFontHeight * fCurPos.y + fTop + fCursorHeight - 1 + OFFSET);
    946950
    947951    uchar buf[4];
    948952    ushort attr;
    949953
    950     int top = fTop / fFontHeight;
    951     bool m_flag = _CheckSelectedRegion(CurPos(fCurPos.x, fCurPos.y + fTop / fFontHeight));
     954    int top = (fTop + OFFSET) / fFontHeight;
     955    bool m_flag = _CheckSelectedRegion(CurPos(fCurPos.x, fCurPos.y + top));
    952956    if (fTextBuffer->GetChar(fCurPos.y + top, fCurPos.x, buf, &attr) == A_CHAR) {
    953957        int width;
    954958        if (IS_WIDTH(attr))
     
    11101114
    11111115    inView->SetFont(&fHalfFont);
    11121116
     1117    //Move the whole thing to the right
     1118    x1 += OFFSET;
     1119    y1 += OFFSET;
     1120
    11131121    // Set pen point
    11141122    int x2 = x1 + fFontWidth * width;
    11151123    int y2 = y1 + fFontHeight;
     
    13251333        return;
    13261334    }
    13271335
    1328     int x1 =(int)updateRect.left / fFontWidth;
    1329     int x2 =(int)updateRect.right / fFontWidth;
     1336    int x1 =(int)(updateRect.left - OFFSET) / fFontWidth;
     1337    int x2 =(int)(updateRect.right - OFFSET) / fFontWidth;
    13301338
    1331     int y1 =(int)updateRect.top / fFontHeight;
    1332     int y2 =(int)updateRect.bottom / fFontHeight;
     1339    int y1 =(int)(updateRect.top - OFFSET) / fFontHeight;
     1340    int y2 =(int)(updateRect.bottom - OFFSET) / fFontHeight;
    13331341
    13341342    Window()->BeginViewTransaction();
    13351343
     
    13541362            if (count < 0) {
    13551363                if (insideSelection) {
    13561364                    BRect eraseRect;
    1357                     eraseRect.Set(fFontWidth * i,
    1358                         fFontHeight * j,
    1359                         fFontWidth * (i - count) -1,
    1360                         fFontHeight * (j + 1) -1);
     1365                    eraseRect.Set(fFontWidth * i + OFFSET,
     1366                        fFontHeight * j + OFFSET,
     1367                        fFontWidth * (i - count) -1 + OFFSET,
     1368                        fFontHeight * (j + 1) -1 + OFFSET);
    13611369
    13621370                    SetHighColor(fSelectBackColor);
    13631371                    FillRect(eraseRect);
     
    13891397
    13901398    const int numLines =(int)((updateRect.Height()) / fFontHeight);
    13911399
    1392     int y1 =(int)updateRect.top / fFontHeight;
     1400    int y1 =(int)(updateRect.top - OFFSET) / fFontHeight;
    13931401    y1 = y1 -(fScrBufSize - numLines * 2);
    13941402    if (y1 < 0)
    13951403        y1 = 0;
    13961404
     1405
    13971406    const int y2 = y1 + numLines -1;
    13981407
    1399     const int x1 =(int)updateRect.left / fFontWidth;
    1400     const int x2 =(int)updateRect.right / fFontWidth;
     1408    const int x1 =(int)(updateRect.left - OFFSET) / fFontWidth;
     1409    const int x2 =(int)(updateRect.right - OFFSET) / fFontWidth;
    14011410
    14021411    for (int j = y1; j <= y2; j++) {
    14031412        // If(x1, y1) Buffer is in string full width character,
     
    15901599void
    15911600TermView::FrameResized(float width, float height)
    15921601{
    1593     const int cols = ((int)width + 1) / fFontWidth;
    1594     const int rows = ((int)height + 1) / fFontHeight;
     1602    const int cols = ((int)width + 1 - 2 * OFFSET) / fFontWidth;
     1603    const int rows = ((int)height + 1 - 2 * OFFSET) / fFontHeight;
    15951604   
    15961605    int offset = 0;
    15971606
     
    21662175CurPos
    21672176TermView::_ConvertToTerminal(const BPoint &p)
    21682177{
    2169     return CurPos(p.x / fFontWidth, p.y / fFontHeight);
     2178    return CurPos((p.x - OFFSET) / fFontWidth, (p.y - OFFSET) / fFontHeight);
    21702179}
    21712180
    21722181
     
    21742183BPoint
    21752184TermView::_ConvertFromTerminal(const CurPos &pos)
    21762185{
    2177     return BPoint(fFontWidth * pos.x, pos.y * fFontHeight + fTop);
     2186    return BPoint(fFontWidth * pos.x + OFFSET, pos.y * fFontHeight + fTop + OFFSET);
    21782187}
    21792188
    21802189
     
    22022211TermView::GetFrameSize(float *width, float *height)
    22032212{
    22042213    if (width != NULL)
    2205         *width = fTermColumns * fFontWidth;
     2214        *width = 2 * OFFSET + fTermColumns * fFontWidth;
    22062215   
    22072216    if (height == NULL)
    22082217        return;
    22092218   
    22102219    if (!fTop) {
    2211         *height = fTermRows * fFontHeight;
     2220        *height = 2 * OFFSET + fTermRows * fFontHeight;
    22122221        return;
    22132222    }
    22142223   
    22152224    if (fTop - fTermRows * fFontHeight > fScrBufSize * fFontHeight) {
    22162225       
    2217         *height = fScrBufSize * fFontHeight;
     2226        *height = fScrBufSize * fFontHeight + 2 * OFFSET;
    22182227        return;
    22192228    }
    22202229   
    2221     *height = fTop + fTermRows * fFontHeight;
     2230    *height = OFFSET + fTop + fTermRows * fFontHeight;
    22222231}
    22232232
    22242233
     
    23732382inline void
    23742383TermView::_Redraw(int x1, int y1, int x2, int y2)
    23752384{
    2376     BRect rect(x1 * fFontWidth, y1 * fFontHeight,
    2377         (x2 + 1) * fFontWidth -1, (y2 + 1) * fFontHeight -1);
     2385    BRect rect(x1 * fFontWidth + OFFSET,
     2386        y1 * fFontHeight + OFFSET,
     2387        (x2 + 1) * fFontWidth + OFFSET - 1,
     2388        (y2 + 1) * fFontHeight -1 + OFFSET);
    23782389
    23792390    if (LockLooper()) {
    23802391        Invalidate(rect);