Ticket #1806: TermView.cpp.diff
File TermView.cpp.diff, 5.2 KB (added by , 16 years ago) |
---|
-
TermView.cpp
58 58 {245, 245, 245, 0}, // white 59 59 }; 60 60 61 //Space at the borders of the view 62 #define OFFSET 3 61 63 62 64 #define ROWS_DEFAULT 25 63 65 #define COLUMNS_DEFAULT 80 … … 332 334 TermView::GetPreferredSize(float *width, float *height) 333 335 { 334 336 if (width) 335 *width = fTermColumns * fFontWidth ;337 *width = fTermColumns * fFontWidth + 2 * OFFSET; 336 338 if (height) 337 *height = fTermRows * fFontHeight ;339 *height = fTermRows * fFontHeight + 2 * OFFSET; 338 340 } 339 341 340 342 … … 371 373 fScrTop = 0; 372 374 fScrBot = fTermRows - 1; 373 375 374 BRect rect(0, 0, fTermColumns * fFontWidth , fTermRows * fFontHeight);376 BRect rect(0, 0, fTermColumns * fFontWidth + 2 * OFFSET, fTermRows * fFontHeight + 2 * OFFSET); 375 377 376 378 if (resize) 377 379 ResizeTo(rect.Width(), rect.Height()); … … 941 943 void 942 944 TermView::DrawCursor() 943 945 { 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); 946 950 947 951 uchar buf[4]; 948 952 ushort attr; 949 953 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)); 952 956 if (fTextBuffer->GetChar(fCurPos.y + top, fCurPos.x, buf, &attr) == A_CHAR) { 953 957 int width; 954 958 if (IS_WIDTH(attr)) … … 1110 1114 1111 1115 inView->SetFont(&fHalfFont); 1112 1116 1117 //Move the whole thing to the right 1118 x1 += OFFSET; 1119 y1 += OFFSET; 1120 1113 1121 // Set pen point 1114 1122 int x2 = x1 + fFontWidth * width; 1115 1123 int y2 = y1 + fFontHeight; … … 1325 1333 return; 1326 1334 } 1327 1335 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; 1330 1338 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; 1333 1341 1334 1342 Window()->BeginViewTransaction(); 1335 1343 … … 1354 1362 if (count < 0) { 1355 1363 if (insideSelection) { 1356 1364 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); 1361 1369 1362 1370 SetHighColor(fSelectBackColor); 1363 1371 FillRect(eraseRect); … … 1389 1397 1390 1398 const int numLines =(int)((updateRect.Height()) / fFontHeight); 1391 1399 1392 int y1 =(int) updateRect.top/ fFontHeight;1400 int y1 =(int)(updateRect.top - OFFSET) / fFontHeight; 1393 1401 y1 = y1 -(fScrBufSize - numLines * 2); 1394 1402 if (y1 < 0) 1395 1403 y1 = 0; 1396 1404 1405 1397 1406 const int y2 = y1 + numLines -1; 1398 1407 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; 1401 1410 1402 1411 for (int j = y1; j <= y2; j++) { 1403 1412 // If(x1, y1) Buffer is in string full width character, … … 1590 1599 void 1591 1600 TermView::FrameResized(float width, float height) 1592 1601 { 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; 1595 1604 1596 1605 int offset = 0; 1597 1606 … … 2166 2175 CurPos 2167 2176 TermView::_ConvertToTerminal(const BPoint &p) 2168 2177 { 2169 return CurPos( p.x / fFontWidth, p.y/ fFontHeight);2178 return CurPos((p.x - OFFSET) / fFontWidth, (p.y - OFFSET) / fFontHeight); 2170 2179 } 2171 2180 2172 2181 … … 2174 2183 BPoint 2175 2184 TermView::_ConvertFromTerminal(const CurPos &pos) 2176 2185 { 2177 return BPoint(fFontWidth * pos.x , pos.y * fFontHeight + fTop);2186 return BPoint(fFontWidth * pos.x + OFFSET, pos.y * fFontHeight + fTop + OFFSET); 2178 2187 } 2179 2188 2180 2189 … … 2202 2211 TermView::GetFrameSize(float *width, float *height) 2203 2212 { 2204 2213 if (width != NULL) 2205 *width = fTermColumns * fFontWidth;2214 *width = 2 * OFFSET + fTermColumns * fFontWidth; 2206 2215 2207 2216 if (height == NULL) 2208 2217 return; 2209 2218 2210 2219 if (!fTop) { 2211 *height = fTermRows * fFontHeight;2220 *height = 2 * OFFSET + fTermRows * fFontHeight; 2212 2221 return; 2213 2222 } 2214 2223 2215 2224 if (fTop - fTermRows * fFontHeight > fScrBufSize * fFontHeight) { 2216 2225 2217 *height = fScrBufSize * fFontHeight ;2226 *height = fScrBufSize * fFontHeight + 2 * OFFSET; 2218 2227 return; 2219 2228 } 2220 2229 2221 *height = fTop + fTermRows * fFontHeight;2230 *height = OFFSET + fTop + fTermRows * fFontHeight; 2222 2231 } 2223 2232 2224 2233 … … 2373 2382 inline void 2374 2383 TermView::_Redraw(int x1, int y1, int x2, int y2) 2375 2384 { 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); 2378 2389 2379 2390 if (LockLooper()) { 2380 2391 Invalidate(rect);