182afdb09SMichael Pfeiffer /* 282afdb09SMichael Pfeiffer * Copyright 2007, Haiku. All rights reserved. 382afdb09SMichael Pfeiffer * Distributed under the terms of the MIT License. 482afdb09SMichael Pfeiffer * 582afdb09SMichael Pfeiffer * Authors: 682afdb09SMichael Pfeiffer * Michael Pfeiffer 782afdb09SMichael Pfeiffer */ 882afdb09SMichael Pfeiffer 982afdb09SMichael Pfeiffer #include "PictureTestCases.h" 1082afdb09SMichael Pfeiffer 1154730332SMichael Pfeiffer static const rgb_color kBlack = {0, 0, 0}; 1254730332SMichael Pfeiffer static const rgb_color kWhite = {255, 255, 255}; 1354730332SMichael Pfeiffer static const rgb_color kRed = {255, 0, 0}; 1454730332SMichael Pfeiffer static const rgb_color kGreen = {0, 255, 0}; 1554730332SMichael Pfeiffer static const rgb_color kBlue = {0, 0, 255}; 1654730332SMichael Pfeiffer 1754730332SMichael Pfeiffer static BPoint centerPoint(BRect rect) 1854730332SMichael Pfeiffer { 1954730332SMichael Pfeiffer int x = (int)(rect.left + rect.IntegerWidth() / 2); 2054730332SMichael Pfeiffer int y = (int)(rect.top + rect.IntegerHeight() / 2); 2154730332SMichael Pfeiffer return BPoint(x, y); 2254730332SMichael Pfeiffer } 2354730332SMichael Pfeiffer 2454730332SMichael Pfeiffer static void testNoOp(BView *view, BRect frame) 2582afdb09SMichael Pfeiffer { 2682afdb09SMichael Pfeiffer // no op 2782afdb09SMichael Pfeiffer } 2882afdb09SMichael Pfeiffer 2954730332SMichael Pfeiffer static void testDrawChar(BView *view, BRect frame) 3054730332SMichael Pfeiffer { 3154730332SMichael Pfeiffer view->MovePenTo(frame.left, frame.bottom - 5); 3254730332SMichael Pfeiffer view->DrawChar('A'); 3354730332SMichael Pfeiffer 3454730332SMichael Pfeiffer view->DrawChar('B', BPoint(frame.left + 20, frame.bottom - 5)); 3554730332SMichael Pfeiffer } 3654730332SMichael Pfeiffer 3754730332SMichael Pfeiffer static void testDrawString(BView *view, BRect frame) 3882afdb09SMichael Pfeiffer { 3982afdb09SMichael Pfeiffer BFont font; 4082afdb09SMichael Pfeiffer view->GetFont(&font); 4182afdb09SMichael Pfeiffer font_height height; 4282afdb09SMichael Pfeiffer font.GetHeight(&height); 4382afdb09SMichael Pfeiffer float baseline = frame.bottom - height.descent; 4482afdb09SMichael Pfeiffer // draw base line 4554730332SMichael Pfeiffer view->SetHighColor(kGreen); 4682afdb09SMichael Pfeiffer view->StrokeLine(BPoint(frame.left, baseline - 1), BPoint(frame.right, baseline -1)); 4782afdb09SMichael Pfeiffer 4854730332SMichael Pfeiffer view->SetHighColor(kBlack); 4982afdb09SMichael Pfeiffer view->DrawString("Haiku [ÖÜÄöüä]", BPoint(frame.left, baseline)); 5082afdb09SMichael Pfeiffer } 5182afdb09SMichael Pfeiffer 5254730332SMichael Pfeiffer static void testDrawStringWithLength(BView *view, BRect frame) 5354730332SMichael Pfeiffer { 5454730332SMichael Pfeiffer BFont font; 5554730332SMichael Pfeiffer view->GetFont(&font); 5654730332SMichael Pfeiffer font_height height; 5754730332SMichael Pfeiffer font.GetHeight(&height); 5854730332SMichael Pfeiffer float baseline = frame.bottom - height.descent; 5954730332SMichael Pfeiffer // draw base line 6054730332SMichael Pfeiffer view->SetHighColor(kGreen); 6154730332SMichael Pfeiffer view->StrokeLine(BPoint(frame.left, baseline - 1), BPoint(frame.right, baseline -1)); 6254730332SMichael Pfeiffer 6354730332SMichael Pfeiffer view->SetHighColor(kBlack); 6454730332SMichael Pfeiffer view->DrawString("Haiku [ÖÜÄöüä]", 13, BPoint(frame.left, baseline)); 6554730332SMichael Pfeiffer } 6654730332SMichael Pfeiffer 6754730332SMichael Pfeiffer static void testFillArc(BView *view, BRect frame) 6882afdb09SMichael Pfeiffer { 6982afdb09SMichael Pfeiffer frame.InsetBy(2, 2); 7054730332SMichael Pfeiffer view->FillArc(frame, 45, 180); 7154730332SMichael Pfeiffer } 7254730332SMichael Pfeiffer 7354730332SMichael Pfeiffer static void testStrokeArc(BView *view, BRect frame) 7454730332SMichael Pfeiffer { 7554730332SMichael Pfeiffer frame.InsetBy(2, 2); 7654730332SMichael Pfeiffer view->StrokeArc(frame, 45, 180); 7754730332SMichael Pfeiffer } 7854730332SMichael Pfeiffer 7954730332SMichael Pfeiffer static void testFillBezier(BView *view, BRect frame) 8054730332SMichael Pfeiffer { 8154730332SMichael Pfeiffer frame.InsetBy(2, 2); 8254730332SMichael Pfeiffer BPoint points[4]; 8354730332SMichael Pfeiffer points[0] = BPoint(frame.left, frame.bottom); 8454730332SMichael Pfeiffer points[1] = BPoint(frame.left, frame.top); 8554730332SMichael Pfeiffer points[1] = BPoint(frame.left, frame.top); 8654730332SMichael Pfeiffer points[3] = BPoint(frame.right, frame.top); 8754730332SMichael Pfeiffer view->FillBezier(points); 8854730332SMichael Pfeiffer } 8954730332SMichael Pfeiffer 9054730332SMichael Pfeiffer static void testStrokeBezier(BView *view, BRect frame) 9154730332SMichael Pfeiffer { 9254730332SMichael Pfeiffer frame.InsetBy(2, 2); 9354730332SMichael Pfeiffer BPoint points[4]; 9454730332SMichael Pfeiffer points[0] = BPoint(frame.left, frame.bottom); 9554730332SMichael Pfeiffer points[1] = BPoint(frame.left, frame.top); 9654730332SMichael Pfeiffer points[1] = BPoint(frame.left, frame.top); 9754730332SMichael Pfeiffer points[3] = BPoint(frame.right, frame.top); 9854730332SMichael Pfeiffer view->StrokeBezier(points); 9954730332SMichael Pfeiffer } 10054730332SMichael Pfeiffer 10154730332SMichael Pfeiffer static void testFillEllipse(BView *view, BRect frame) 10254730332SMichael Pfeiffer { 10354730332SMichael Pfeiffer frame.InsetBy(2, 2); 10454730332SMichael Pfeiffer view->FillEllipse(frame); 10554730332SMichael Pfeiffer 10654730332SMichael Pfeiffer view->SetHighColor(kRed); 10754730332SMichael Pfeiffer float r = frame.Width() / 3; 10854730332SMichael Pfeiffer float s = frame.Height() / 4; 10954730332SMichael Pfeiffer view->FillEllipse(centerPoint(frame), r, s); 11054730332SMichael Pfeiffer } 11154730332SMichael Pfeiffer 11254730332SMichael Pfeiffer static void testStrokeEllipse(BView *view, BRect frame) 11354730332SMichael Pfeiffer { 11454730332SMichael Pfeiffer frame.InsetBy(2, 2); 11554730332SMichael Pfeiffer view->StrokeEllipse(frame); 11654730332SMichael Pfeiffer 11754730332SMichael Pfeiffer view->SetHighColor(kRed); 11854730332SMichael Pfeiffer float r = frame.Width() / 3; 11954730332SMichael Pfeiffer float s = frame.Height() / 4; 12054730332SMichael Pfeiffer view->StrokeEllipse(centerPoint(frame), r, s); 12154730332SMichael Pfeiffer } 12254730332SMichael Pfeiffer 12354730332SMichael Pfeiffer static void testFillPolygon(BView *view, BRect frame) 12454730332SMichael Pfeiffer { 12554730332SMichael Pfeiffer frame.InsetBy(2, 2); 12654730332SMichael Pfeiffer 12754730332SMichael Pfeiffer BPoint points[4]; 12854730332SMichael Pfeiffer points[0] = BPoint(frame.left, frame.top); 12954730332SMichael Pfeiffer points[1] = BPoint(frame.right, frame.bottom); 13054730332SMichael Pfeiffer points[2] = BPoint(frame.right, frame.top); 13154730332SMichael Pfeiffer points[3] = BPoint(frame.left, frame.bottom); 13254730332SMichael Pfeiffer 13354730332SMichael Pfeiffer view->FillPolygon(points, 4); 13454730332SMichael Pfeiffer } 13554730332SMichael Pfeiffer 13654730332SMichael Pfeiffer static void testStrokePolygon(BView *view, BRect frame) 13754730332SMichael Pfeiffer { 13854730332SMichael Pfeiffer frame.InsetBy(2, 2); 13954730332SMichael Pfeiffer 14054730332SMichael Pfeiffer BPoint points[4]; 14154730332SMichael Pfeiffer points[0] = BPoint(frame.left, frame.top); 14254730332SMichael Pfeiffer points[1] = BPoint(frame.right, frame.bottom); 14354730332SMichael Pfeiffer points[2] = BPoint(frame.right, frame.top); 14454730332SMichael Pfeiffer points[3] = BPoint(frame.left, frame.bottom); 14554730332SMichael Pfeiffer 14654730332SMichael Pfeiffer view->StrokePolygon(points, 4); 14754730332SMichael Pfeiffer } 14854730332SMichael Pfeiffer 14954730332SMichael Pfeiffer static void testFillRect(BView *view, BRect frame) 15054730332SMichael Pfeiffer { 15154730332SMichael Pfeiffer frame.InsetBy(2, 2); 15282afdb09SMichael Pfeiffer view->FillRect(frame); 15382afdb09SMichael Pfeiffer } 15482afdb09SMichael Pfeiffer 15554730332SMichael Pfeiffer static void testStrokeRect(BView *view, BRect frame) 15682afdb09SMichael Pfeiffer { 15782afdb09SMichael Pfeiffer frame.InsetBy(2, 2); 15882afdb09SMichael Pfeiffer view->StrokeRect(frame); 15982afdb09SMichael Pfeiffer } 16082afdb09SMichael Pfeiffer 16154730332SMichael Pfeiffer static void testFillRegion(BView *view, BRect frame) 16282afdb09SMichael Pfeiffer { 16354730332SMichael Pfeiffer frame.InsetBy(2, 2); 16454730332SMichael Pfeiffer BRegion region(frame); 16554730332SMichael Pfeiffer frame.InsetBy(2, 2); 16654730332SMichael Pfeiffer region.Exclude(frame); 16754730332SMichael Pfeiffer view->FillRegion(®ion); 16854730332SMichael Pfeiffer } 16954730332SMichael Pfeiffer 17054730332SMichael Pfeiffer static void testFillRoundRect(BView *view, BRect frame) 17154730332SMichael Pfeiffer { 17254730332SMichael Pfeiffer frame.InsetBy(2, 2); 17354730332SMichael Pfeiffer view->FillRoundRect(frame, 5, 3); 17454730332SMichael Pfeiffer } 17554730332SMichael Pfeiffer 17654730332SMichael Pfeiffer static void testStrokeRoundRect(BView *view, BRect frame) 17754730332SMichael Pfeiffer { 17854730332SMichael Pfeiffer frame.InsetBy(2, 2); 17954730332SMichael Pfeiffer view->StrokeRoundRect(frame, 5, 3); 18054730332SMichael Pfeiffer } 18154730332SMichael Pfeiffer 18254730332SMichael Pfeiffer static void testFillTriangle(BView *view, BRect frame) 18354730332SMichael Pfeiffer { 18454730332SMichael Pfeiffer frame.InsetBy(2, 2); 18554730332SMichael Pfeiffer BPoint points[3]; 18654730332SMichael Pfeiffer points[0] = BPoint(frame.left, frame.bottom); 18754730332SMichael Pfeiffer points[1] = BPoint(centerPoint(frame).x, frame.top); 18854730332SMichael Pfeiffer points[2] = BPoint(frame.right, frame.bottom); 18954730332SMichael Pfeiffer view->FillTriangle(points[0], points[1], points[2]); 19054730332SMichael Pfeiffer } 19154730332SMichael Pfeiffer 19254730332SMichael Pfeiffer static void testStrokeTriangle(BView *view, BRect frame) 19354730332SMichael Pfeiffer { 19454730332SMichael Pfeiffer frame.InsetBy(2, 2); 19554730332SMichael Pfeiffer BPoint points[3]; 19654730332SMichael Pfeiffer points[0] = BPoint(frame.left, frame.bottom); 19754730332SMichael Pfeiffer points[1] = BPoint(centerPoint(frame).x, frame.top); 19854730332SMichael Pfeiffer points[2] = BPoint(frame.right, frame.bottom); 19954730332SMichael Pfeiffer view->StrokeTriangle(points[0], points[1], points[2]); 20054730332SMichael Pfeiffer } 20154730332SMichael Pfeiffer 20254730332SMichael Pfeiffer static void testStrokeLine(BView *view, BRect frame) 20354730332SMichael Pfeiffer { 20454730332SMichael Pfeiffer frame.InsetBy(2, 2); 20554730332SMichael Pfeiffer view->StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.top)); 20654730332SMichael Pfeiffer 20754730332SMichael Pfeiffer frame.top += 2; 20854730332SMichael Pfeiffer frame.bottom -= 2; 20982afdb09SMichael Pfeiffer view->StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.bottom)); 21054730332SMichael Pfeiffer 21154730332SMichael Pfeiffer frame.bottom += 2;; 21254730332SMichael Pfeiffer frame.top = frame.bottom; 21354730332SMichael Pfeiffer view->StrokeLine(BPoint(frame.right, frame.top), BPoint(frame.left, frame.top)); 21482afdb09SMichael Pfeiffer } 21582afdb09SMichael Pfeiffer 21654730332SMichael Pfeiffer static void testFillShape(BView *view, BRect frame) 21782afdb09SMichael Pfeiffer { 21854730332SMichael Pfeiffer frame.InsetBy(2, 2); 21954730332SMichael Pfeiffer BShape shape; 22054730332SMichael Pfeiffer shape.MoveTo(BPoint(frame.left, frame.bottom)); 22154730332SMichael Pfeiffer shape.LineTo(BPoint(frame.right, frame.top)); 22254730332SMichael Pfeiffer shape.LineTo(BPoint(frame.left, frame.top)); 22354730332SMichael Pfeiffer shape.LineTo(BPoint(frame.right, frame.bottom)); 22454730332SMichael Pfeiffer view->FillShape(&shape); 22582afdb09SMichael Pfeiffer } 22682afdb09SMichael Pfeiffer 22754730332SMichael Pfeiffer static void testStrokeShape(BView *view, BRect frame) 22854730332SMichael Pfeiffer { 22954730332SMichael Pfeiffer frame.InsetBy(2, 2); 23054730332SMichael Pfeiffer BShape shape; 23154730332SMichael Pfeiffer shape.MoveTo(BPoint(frame.left, frame.bottom)); 23254730332SMichael Pfeiffer shape.LineTo(BPoint(frame.right, frame.top)); 23354730332SMichael Pfeiffer shape.LineTo(BPoint(frame.left, frame.top)); 23454730332SMichael Pfeiffer shape.LineTo(BPoint(frame.right, frame.bottom)); 23554730332SMichael Pfeiffer view->StrokeShape(&shape); 23654730332SMichael Pfeiffer } 23754730332SMichael Pfeiffer 23854730332SMichael Pfeiffer static void testRecordPicture(BView *view, BRect frame) 23982afdb09SMichael Pfeiffer { 24082afdb09SMichael Pfeiffer BPicture *picture = new BPicture(); 24182afdb09SMichael Pfeiffer view->BeginPicture(picture); 24282afdb09SMichael Pfeiffer view->FillRect(frame); 24382afdb09SMichael Pfeiffer view->EndPicture(); 24482afdb09SMichael Pfeiffer delete picture; 24582afdb09SMichael Pfeiffer } 24682afdb09SMichael Pfeiffer 24754730332SMichael Pfeiffer static void testRecordAndPlayPicture(BView *view, BRect frame) 24882afdb09SMichael Pfeiffer { 24982afdb09SMichael Pfeiffer BPicture *picture = new BPicture(); 25082afdb09SMichael Pfeiffer view->BeginPicture(picture); 25182afdb09SMichael Pfeiffer frame.InsetBy(2, 2); 25282afdb09SMichael Pfeiffer view->FillRect(frame); 25382afdb09SMichael Pfeiffer view->EndPicture(); 25482afdb09SMichael Pfeiffer view->DrawPicture(picture); 25582afdb09SMichael Pfeiffer delete picture; 25682afdb09SMichael Pfeiffer } 25782afdb09SMichael Pfeiffer 25854730332SMichael Pfeiffer static void testRecordAndPlayPictureWithOffset(BView *view, BRect frame) 25982afdb09SMichael Pfeiffer { 26082afdb09SMichael Pfeiffer BPicture *picture = new BPicture(); 26182afdb09SMichael Pfeiffer view->BeginPicture(picture); 26282afdb09SMichael Pfeiffer frame.InsetBy(frame.Width() / 4, frame.Height() / 4); 26382afdb09SMichael Pfeiffer frame.OffsetTo(0, 0); 26482afdb09SMichael Pfeiffer view->FillRect(frame); 26582afdb09SMichael Pfeiffer view->EndPicture(); 26682afdb09SMichael Pfeiffer 26782afdb09SMichael Pfeiffer view->DrawPicture(picture, BPoint(10, 10)); 26882afdb09SMichael Pfeiffer // color of picture should not change 26954730332SMichael Pfeiffer view->SetLowColor(kGreen); 27054730332SMichael Pfeiffer view->SetLowColor(kRed); 27182afdb09SMichael Pfeiffer view->DrawPicture(picture, BPoint(0, 0)); 27282afdb09SMichael Pfeiffer delete picture; 27382afdb09SMichael Pfeiffer } 27482afdb09SMichael Pfeiffer 27554730332SMichael Pfeiffer static void testAppendToPicture(BView *view, BRect frame) 27654730332SMichael Pfeiffer { 27754730332SMichael Pfeiffer frame.InsetBy(2, 2); 27854730332SMichael Pfeiffer view->BeginPicture(new BPicture()); 27954730332SMichael Pfeiffer view->FillRect(frame); 28054730332SMichael Pfeiffer BPicture* picture = view->EndPicture(); 28154730332SMichael Pfeiffer if (picture == NULL) 28254730332SMichael Pfeiffer return; 28354730332SMichael Pfeiffer 28454730332SMichael Pfeiffer frame.InsetBy(2, 2); 28554730332SMichael Pfeiffer view->AppendToPicture(picture); 28654730332SMichael Pfeiffer view->SetHighColor(kRed); 28754730332SMichael Pfeiffer view->FillRect(frame); 28854730332SMichael Pfeiffer if (view->EndPicture() != picture) 28954730332SMichael Pfeiffer return; 29054730332SMichael Pfeiffer 29154730332SMichael Pfeiffer view->DrawPicture(picture); 29254730332SMichael Pfeiffer delete picture; 29354730332SMichael Pfeiffer } 29454730332SMichael Pfeiffer 29554730332SMichael Pfeiffer static void testLineArray(BView *view, BRect frame) 29654730332SMichael Pfeiffer { 29754730332SMichael Pfeiffer frame.InsetBy(2, 2); 29854730332SMichael Pfeiffer view->BeginLineArray(3); 29954730332SMichael Pfeiffer view->AddLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.top), kBlack); 30054730332SMichael Pfeiffer 30154730332SMichael Pfeiffer frame.top += 2; 30254730332SMichael Pfeiffer frame.bottom -= 2; 30354730332SMichael Pfeiffer view->AddLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.bottom), kRed); 30454730332SMichael Pfeiffer 30554730332SMichael Pfeiffer frame.bottom += 2;; 30654730332SMichael Pfeiffer frame.top = frame.bottom; 30754730332SMichael Pfeiffer view->AddLine(BPoint(frame.right, frame.top), BPoint(frame.left, frame.top), kGreen); 30854730332SMichael Pfeiffer 30954730332SMichael Pfeiffer view->EndLineArray(); 31054730332SMichael Pfeiffer } 31154730332SMichael Pfeiffer 31254730332SMichael Pfeiffer static void testInvertRect(BView *view, BRect frame) 31354730332SMichael Pfeiffer { 31454730332SMichael Pfeiffer frame.InsetBy(2, 2); 31554730332SMichael Pfeiffer view->InvertRect(frame); 31654730332SMichael Pfeiffer } 31754730332SMichael Pfeiffer 3184f422578SMichael Pfeiffer static bool isBorder(int32 x, int32 y, int32 width, int32 height) { 3194f422578SMichael Pfeiffer return x == 0 || y == 0 || x == width - 1 || y == height - 1; 3204f422578SMichael Pfeiffer } 3214f422578SMichael Pfeiffer 3224f422578SMichael Pfeiffer static void fillBitmap(BBitmap &bitmap) { 3234f422578SMichael Pfeiffer int32 height = bitmap.Bounds().IntegerHeight()+1; 3244f422578SMichael Pfeiffer int32 width = bitmap.Bounds().IntegerWidth()+1; 3254f422578SMichael Pfeiffer for (int32 y = 0; y < height; y ++) { 3264f422578SMichael Pfeiffer for (int32 x = 0; x < width; x ++) { 32782afdb09SMichael Pfeiffer char *pixel = (char*)bitmap.Bits(); 32882afdb09SMichael Pfeiffer pixel += bitmap.BytesPerRow() * y + 4 * x; 3294f422578SMichael Pfeiffer if (isBorder(x, y, width, height)) { 3304f422578SMichael Pfeiffer // fill with green 3314f422578SMichael Pfeiffer pixel[0] = 255; 3324f422578SMichael Pfeiffer pixel[1] = 0; 3334f422578SMichael Pfeiffer pixel[2] = 255; 3344f422578SMichael Pfeiffer pixel[3] = 0; 3354f422578SMichael Pfeiffer } else { 33682afdb09SMichael Pfeiffer // fill with blue 33782afdb09SMichael Pfeiffer pixel[0] = 255; 33882afdb09SMichael Pfeiffer pixel[1] = 0; 33982afdb09SMichael Pfeiffer pixel[2] = 0; 34082afdb09SMichael Pfeiffer pixel[3] = 255; 34182afdb09SMichael Pfeiffer } 34282afdb09SMichael Pfeiffer } 3434f422578SMichael Pfeiffer } 3444f422578SMichael Pfeiffer } 3454f422578SMichael Pfeiffer 3464f422578SMichael Pfeiffer static void testDrawBitmap(BView *view, BRect frame) { 3474f422578SMichael Pfeiffer BBitmap bitmap(frame, B_RGBA32); 3484f422578SMichael Pfeiffer fillBitmap(bitmap); 34982afdb09SMichael Pfeiffer view->DrawBitmap(&bitmap, BPoint(0, 0)); 35082afdb09SMichael Pfeiffer } 35182afdb09SMichael Pfeiffer 3524f422578SMichael Pfeiffer static void testDrawBitmapAtPoint(BView *view, BRect frame) { 3534f422578SMichael Pfeiffer frame.InsetBy(2, 2); 3544f422578SMichael Pfeiffer 3554f422578SMichael Pfeiffer BRect bounds(frame); 3564f422578SMichael Pfeiffer bounds.OffsetTo(0, 0); 3574f422578SMichael Pfeiffer bounds.right /= 2; 3584f422578SMichael Pfeiffer bounds.bottom /= 2; 3594f422578SMichael Pfeiffer 3604f422578SMichael Pfeiffer BBitmap bitmap(bounds, B_RGBA32); 3614f422578SMichael Pfeiffer fillBitmap(bitmap); 3624f422578SMichael Pfeiffer view->DrawBitmap(&bitmap, centerPoint(frame)); 3634f422578SMichael Pfeiffer } 3644f422578SMichael Pfeiffer 3654f422578SMichael Pfeiffer static void testDrawBitmapAtRect(BView *view, BRect frame) { 3664f422578SMichael Pfeiffer BRect bounds(frame); 3674f422578SMichael Pfeiffer BBitmap bitmap(bounds, B_RGBA32); 3684f422578SMichael Pfeiffer fillBitmap(bitmap); 3694f422578SMichael Pfeiffer frame.InsetBy(2, 2); 3704f422578SMichael Pfeiffer view->DrawBitmap(&bitmap, frame); 3714f422578SMichael Pfeiffer } 3724f422578SMichael Pfeiffer 3734f422578SMichael Pfeiffer static void testDrawLargeBitmap(BView *view, BRect frame) { 3744f422578SMichael Pfeiffer BRect bounds(frame); 3754f422578SMichael Pfeiffer bounds.OffsetTo(0, 0); 3764f422578SMichael Pfeiffer bounds.left = 1024; 3774f422578SMichael Pfeiffer bounds.bottom = 767; 3784f422578SMichael Pfeiffer BBitmap bitmap(bounds, B_RGBA32); 3794f422578SMichael Pfeiffer fillBitmap(bitmap); 3804f422578SMichael Pfeiffer frame.InsetBy(2, 2); 3814f422578SMichael Pfeiffer view->DrawBitmap(&bitmap, frame); 3824f422578SMichael Pfeiffer } 3834f422578SMichael Pfeiffer 384c43f0163SMichael Pfeiffer static void testConstrainClippingRegion(BView *view, BRect frame) 385c43f0163SMichael Pfeiffer { 386c43f0163SMichael Pfeiffer frame.InsetBy(2, 2); 387c43f0163SMichael Pfeiffer // draw background 388c43f0163SMichael Pfeiffer view->SetHighColor(kRed); 389c43f0163SMichael Pfeiffer view->FillRect(frame); 390c43f0163SMichael Pfeiffer 391c43f0163SMichael Pfeiffer frame.InsetBy(1, 1); 392c43f0163SMichael Pfeiffer BRegion region(frame); 393c43f0163SMichael Pfeiffer BRect r(frame); 394c43f0163SMichael Pfeiffer r.InsetBy(r.IntegerWidth() / 4, r.IntegerHeight() / 4); 395c43f0163SMichael Pfeiffer region.Exclude(r); 396c43f0163SMichael Pfeiffer view->ConstrainClippingRegion(®ion); 397c43f0163SMichael Pfeiffer 398c43f0163SMichael Pfeiffer frame.InsetBy(-1, -1); 399c43f0163SMichael Pfeiffer view->SetHighColor(kBlack); 400c43f0163SMichael Pfeiffer view->FillRect(frame); 401c43f0163SMichael Pfeiffer // a filled black rectangle with a red one pixel border 402c43f0163SMichael Pfeiffer // and inside a red rectangle should be drawn. 403c43f0163SMichael Pfeiffer } 404c43f0163SMichael Pfeiffer 405c43f0163SMichael Pfeiffer static void testClipToPicture(BView *view, BRect frame) 406c43f0163SMichael Pfeiffer { 407c43f0163SMichael Pfeiffer frame.InsetBy(2, 2); 408c43f0163SMichael Pfeiffer view->BeginPicture(new BPicture()); 409c43f0163SMichael Pfeiffer view->FillEllipse(frame); 410c43f0163SMichael Pfeiffer BPicture *picture = view->EndPicture(); 411c43f0163SMichael Pfeiffer if (picture == NULL) 412c43f0163SMichael Pfeiffer return; 413c43f0163SMichael Pfeiffer 414c43f0163SMichael Pfeiffer view->ClipToPicture(picture); 415c43f0163SMichael Pfeiffer delete picture; 416c43f0163SMichael Pfeiffer 417c43f0163SMichael Pfeiffer view->FillRect(frame); 418c43f0163SMichael Pfeiffer // black ellipse should be drawn 419c43f0163SMichael Pfeiffer } 420c43f0163SMichael Pfeiffer 421c43f0163SMichael Pfeiffer static void testClipToInversePicture(BView *view, BRect frame) 422c43f0163SMichael Pfeiffer { 423c43f0163SMichael Pfeiffer frame.InsetBy(2, 2); 424c43f0163SMichael Pfeiffer 425c43f0163SMichael Pfeiffer view->BeginPicture(new BPicture()); 426c43f0163SMichael Pfeiffer view->FillEllipse(frame); 427c43f0163SMichael Pfeiffer BPicture *picture = view->EndPicture(); 428c43f0163SMichael Pfeiffer if (picture == NULL) 429c43f0163SMichael Pfeiffer return; 430c43f0163SMichael Pfeiffer 431c43f0163SMichael Pfeiffer view->ClipToInversePicture(picture); 432c43f0163SMichael Pfeiffer delete picture; 433c43f0163SMichael Pfeiffer 434c43f0163SMichael Pfeiffer view->FillRect(frame); 435c43f0163SMichael Pfeiffer // white ellipse inside a black rectangle 436c43f0163SMichael Pfeiffer } 437c43f0163SMichael Pfeiffer 438c43f0163SMichael Pfeiffer static void testSetPenSize(BView *view, BRect frame) 439c43f0163SMichael Pfeiffer { 440c43f0163SMichael Pfeiffer frame.InsetBy(8, 2); 441c43f0163SMichael Pfeiffer float x = centerPoint(frame).x; 442c43f0163SMichael Pfeiffer 443c43f0163SMichael Pfeiffer view->StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.top)); 444c43f0163SMichael Pfeiffer 445c43f0163SMichael Pfeiffer frame.OffsetBy(0, 5); 446c43f0163SMichael Pfeiffer view->SetPenSize(1); 447c43f0163SMichael Pfeiffer view->StrokeLine(BPoint(frame.left, frame.top), BPoint(x, frame.top)); 448c43f0163SMichael Pfeiffer view->SetPenSize(0); 449c43f0163SMichael Pfeiffer view->StrokeLine(BPoint(x+1, frame.top), BPoint(frame.right, frame.top)); 450c43f0163SMichael Pfeiffer 451c43f0163SMichael Pfeiffer frame.OffsetBy(0, 5); 452c43f0163SMichael Pfeiffer view->SetPenSize(1); 453c43f0163SMichael Pfeiffer view->StrokeLine(BPoint(frame.left, frame.top), BPoint(x, frame.top)); 454c43f0163SMichael Pfeiffer view->SetPenSize(2); 455c43f0163SMichael Pfeiffer view->StrokeLine(BPoint(x+1, frame.top), BPoint(frame.right, frame.top)); 456c43f0163SMichael Pfeiffer 457c43f0163SMichael Pfeiffer frame.OffsetBy(0, 5); 458c43f0163SMichael Pfeiffer view->SetPenSize(1); 459c43f0163SMichael Pfeiffer view->StrokeLine(BPoint(frame.left, frame.top), BPoint(x, frame.top)); 460c43f0163SMichael Pfeiffer view->SetPenSize(3); 461c43f0163SMichael Pfeiffer view->StrokeLine(BPoint(x+1, frame.top), BPoint(frame.right, frame.top)); 462c43f0163SMichael Pfeiffer 463c43f0163SMichael Pfeiffer frame.OffsetBy(0, 5); 464c43f0163SMichael Pfeiffer view->SetPenSize(1); 465c43f0163SMichael Pfeiffer view->StrokeLine(BPoint(frame.left, frame.top), BPoint(x, frame.top)); 466c43f0163SMichael Pfeiffer view->SetPenSize(4); 467c43f0163SMichael Pfeiffer view->StrokeLine(BPoint(x+1, frame.top), BPoint(frame.right, frame.top)); 468c43f0163SMichael Pfeiffer } 469c43f0163SMichael Pfeiffer 470c43f0163SMichael Pfeiffer static void testSetPenSize2(BView *view, BRect frame) 471c43f0163SMichael Pfeiffer { 472c43f0163SMichael Pfeiffer // test if pen size is scaled too 473c43f0163SMichael Pfeiffer frame.InsetBy(2, 2); 474c43f0163SMichael Pfeiffer frame.OffsetBy(0, 5); 475c43f0163SMichael Pfeiffer view->SetPenSize(4); 476c43f0163SMichael Pfeiffer view->StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.top)); 477c43f0163SMichael Pfeiffer view->SetScale(0.5); 478c43f0163SMichael Pfeiffer view->StrokeLine(BPoint(frame.left + 2, frame.bottom), BPoint(frame.right + 2, frame.bottom)); 479c43f0163SMichael Pfeiffer 480c43f0163SMichael Pfeiffer // black line from left to right, 4 pixel size 481c43f0163SMichael Pfeiffer // below black line with half the length of the first one 482c43f0163SMichael Pfeiffer // and 2 pixel size 483c43f0163SMichael Pfeiffer } 484c43f0163SMichael Pfeiffer 485c43f0163SMichael Pfeiffer static void testPattern(BView *view, BRect frame) 486c43f0163SMichael Pfeiffer { 487c43f0163SMichael Pfeiffer frame.InsetBy(2, 2); 488c43f0163SMichael Pfeiffer int x = frame.IntegerWidth() / 3; 489c43f0163SMichael Pfeiffer frame.right = frame.left + x - 2; 490c43f0163SMichael Pfeiffer // -2 for an empty pixel row between 491c43f0163SMichael Pfeiffer // filled rectangles 492c43f0163SMichael Pfeiffer 493c43f0163SMichael Pfeiffer view->SetLowColor(kGreen); 494c43f0163SMichael Pfeiffer view->SetHighColor(kRed); 495c43f0163SMichael Pfeiffer 496c43f0163SMichael Pfeiffer view->FillRect(frame, B_SOLID_HIGH); 497c43f0163SMichael Pfeiffer 498c43f0163SMichael Pfeiffer frame.OffsetBy(x, 0); 499c43f0163SMichael Pfeiffer view->FillRect(frame, B_MIXED_COLORS); 500c43f0163SMichael Pfeiffer 501c43f0163SMichael Pfeiffer frame.OffsetBy(x, 0); 502c43f0163SMichael Pfeiffer view->FillRect(frame, B_SOLID_LOW); 503c43f0163SMichael Pfeiffer } 504c43f0163SMichael Pfeiffer 505c43f0163SMichael Pfeiffer static void testSetOrigin(BView *view, BRect frame) 506c43f0163SMichael Pfeiffer { 507c43f0163SMichael Pfeiffer BPoint origin = view->Origin(); 508c43f0163SMichael Pfeiffer BPoint center = centerPoint(frame); 509c43f0163SMichael Pfeiffer view->SetOrigin(center); 510c43f0163SMichael Pfeiffer 511c43f0163SMichael Pfeiffer BRect r(0, 0, center.x, center.y); 512c43f0163SMichael Pfeiffer view->SetHighColor(kBlue); 513c43f0163SMichael Pfeiffer view->FillRect(r); 514c43f0163SMichael Pfeiffer 515c43f0163SMichael Pfeiffer view->SetOrigin(origin); 516c43f0163SMichael Pfeiffer view->SetHighColor(kRed); 517c43f0163SMichael Pfeiffer view->FillRect(r); 518c43f0163SMichael Pfeiffer 519c43f0163SMichael Pfeiffer // red rectangle in left, top corner 520c43f0163SMichael Pfeiffer // blue rectangle in right, bottom corner 521c43f0163SMichael Pfeiffer // the red rectangle overwrites the 522c43f0163SMichael Pfeiffer // top, left pixel of the blue rectangle 523c43f0163SMichael Pfeiffer } 524c43f0163SMichael Pfeiffer 525c43f0163SMichael Pfeiffer static void testSetOrigin2(BView *view, BRect frame) 526c43f0163SMichael Pfeiffer { 527c43f0163SMichael Pfeiffer BPoint center = centerPoint(frame); 528c43f0163SMichael Pfeiffer BRect r(0, 0, center.x, center.y); 529c43f0163SMichael Pfeiffer view->SetOrigin(center); 530c43f0163SMichael Pfeiffer view->PushState(); 531c43f0163SMichael Pfeiffer view->SetOrigin(BPoint(-center.x, 0)); 532c43f0163SMichael Pfeiffer view->FillRect(r); 533c43f0163SMichael Pfeiffer view->PopState(); 534c43f0163SMichael Pfeiffer // black rectangle in left, bottom corner 535c43f0163SMichael Pfeiffer } 536c43f0163SMichael Pfeiffer 537c43f0163SMichael Pfeiffer static void testSetScale(BView *view, BRect frame) 538c43f0163SMichael Pfeiffer { 539c43f0163SMichael Pfeiffer view->SetScale(0.5); 540c43f0163SMichael Pfeiffer view->FillRect(frame); 541c43f0163SMichael Pfeiffer // black rectangle in left, top corner 542c43f0163SMichael Pfeiffer } 543c43f0163SMichael Pfeiffer 544c43f0163SMichael Pfeiffer static void testSetScale2(BView *view, BRect frame) 545c43f0163SMichael Pfeiffer { 546c43f0163SMichael Pfeiffer view->SetScale(0.5); 547c43f0163SMichael Pfeiffer view->PushState(); 548c43f0163SMichael Pfeiffer view->SetScale(0.5); 549c43f0163SMichael Pfeiffer view->FillRect(frame); 550c43f0163SMichael Pfeiffer view->PopState(); 551c43f0163SMichael Pfeiffer // black rectangle in left, top corner 552c43f0163SMichael Pfeiffer // with half the size of the rectangle 553c43f0163SMichael Pfeiffer // from test testSetScaling 554c43f0163SMichael Pfeiffer } 555c43f0163SMichael Pfeiffer 556c43f0163SMichael Pfeiffer static void testSetScale3(BView *view, BRect frame) 557c43f0163SMichael Pfeiffer { 558c43f0163SMichael Pfeiffer view->SetScale(0.5); 559c43f0163SMichael Pfeiffer view->PushState(); 560c43f0163SMichael Pfeiffer // if the second scale value differs slightly 561c43f0163SMichael Pfeiffer // the bug under BeOS R5 in testSetScale2 562c43f0163SMichael Pfeiffer // does not occur 563c43f0163SMichael Pfeiffer view->SetScale(0.5000001); 564c43f0163SMichael Pfeiffer view->FillRect(frame); 565c43f0163SMichael Pfeiffer view->PopState(); 566c43f0163SMichael Pfeiffer // black rectangle in left, top corner 567c43f0163SMichael Pfeiffer // with half the size of the rectangle 568c43f0163SMichael Pfeiffer // from test testSetScaling 569c43f0163SMichael Pfeiffer } 570c43f0163SMichael Pfeiffer 571c9c4a80aSMichael Pfeiffer static void testSetOriginAndScale(BView *view, BRect frame) 572c9c4a80aSMichael Pfeiffer { 573c9c4a80aSMichael Pfeiffer frame.InsetBy(2, 2); 574c9c4a80aSMichael Pfeiffer BPoint center = centerPoint(frame); 575c9c4a80aSMichael Pfeiffer 576c9c4a80aSMichael Pfeiffer BRect r(0, 0, frame.IntegerWidth() / 2, frame.IntegerHeight() / 2); 577c9c4a80aSMichael Pfeiffer view->SetOrigin(center); 578c9c4a80aSMichael Pfeiffer view->FillRect(r); 579c9c4a80aSMichael Pfeiffer 580c9c4a80aSMichael Pfeiffer view->SetScale(0.5); 581c9c4a80aSMichael Pfeiffer view->SetHighColor(kRed); 582c9c4a80aSMichael Pfeiffer view->FillRect(r); 583c9c4a80aSMichael Pfeiffer } 584c9c4a80aSMichael Pfeiffer 5854b05331dSMichael Pfeiffer static void testSetOriginAndScale2(BView *view, BRect frame) 5864b05331dSMichael Pfeiffer { 5874b05331dSMichael Pfeiffer frame.InsetBy(2, 2); 5884b05331dSMichael Pfeiffer BPoint center = centerPoint(frame); 5894b05331dSMichael Pfeiffer 5904b05331dSMichael Pfeiffer BRect r(0, 0, frame.IntegerWidth() / 2, frame.IntegerHeight() / 2); 5914b05331dSMichael Pfeiffer view->SetOrigin(center); 5924b05331dSMichael Pfeiffer view->FillRect(r); 5934b05331dSMichael Pfeiffer 5944b05331dSMichael Pfeiffer view->SetScale(0.5); 5954b05331dSMichael Pfeiffer view->SetHighColor(kRed); 5964b05331dSMichael Pfeiffer view->FillRect(r); 5974b05331dSMichael Pfeiffer 5984b05331dSMichael Pfeiffer view->SetOrigin(0, 0); 5994b05331dSMichael Pfeiffer view->SetHighColor(kGreen); 6004b05331dSMichael Pfeiffer view->FillRect(r); 6014b05331dSMichael Pfeiffer } 6024b05331dSMichael Pfeiffer 6034b05331dSMichael Pfeiffer static void testSetOriginAndScale3(BView *view, BRect frame) 6044b05331dSMichael Pfeiffer { 6054b05331dSMichael Pfeiffer frame.InsetBy(2, 2); 6064b05331dSMichael Pfeiffer BPoint center = centerPoint(frame); 6074b05331dSMichael Pfeiffer 6084b05331dSMichael Pfeiffer BRect r(0, 0, frame.IntegerWidth() / 2, frame.IntegerHeight() / 2); 6094b05331dSMichael Pfeiffer view->SetOrigin(center); 6104b05331dSMichael Pfeiffer view->FillRect(r); 6114b05331dSMichael Pfeiffer 6124b05331dSMichael Pfeiffer view->SetScale(0.5); 6134b05331dSMichael Pfeiffer view->SetHighColor(kRed); 6144b05331dSMichael Pfeiffer view->FillRect(r); 6154b05331dSMichael Pfeiffer 6164b05331dSMichael Pfeiffer view->SetScale(0.25); 6174b05331dSMichael Pfeiffer view->SetHighColor(kGreen); 6184b05331dSMichael Pfeiffer view->FillRect(r); 6194b05331dSMichael Pfeiffer } 6204b05331dSMichael Pfeiffer 6214b05331dSMichael Pfeiffer static void testSetOriginAndScale4(BView *view, BRect frame) 6224b05331dSMichael Pfeiffer { 6234b05331dSMichael Pfeiffer frame.InsetBy(2, 2); 6244b05331dSMichael Pfeiffer BPoint center = centerPoint(frame); 6254b05331dSMichael Pfeiffer 6264b05331dSMichael Pfeiffer BRect r(0, 0, frame.IntegerWidth() / 2, frame.IntegerHeight() / 2); 6274b05331dSMichael Pfeiffer view->SetOrigin(center); 6284b05331dSMichael Pfeiffer view->FillRect(r); 6294b05331dSMichael Pfeiffer 6304b05331dSMichael Pfeiffer view->SetScale(0.5); 6314b05331dSMichael Pfeiffer view->SetHighColor(kRed); 6324b05331dSMichael Pfeiffer view->FillRect(r); 6334b05331dSMichael Pfeiffer 6344b05331dSMichael Pfeiffer view->PushState(); 6354b05331dSMichael Pfeiffer // 6364b05331dSMichael Pfeiffer view->SetOrigin(center.x+1, center.y); 6374b05331dSMichael Pfeiffer // +1 to work around BeOS bug 6384b05331dSMichael Pfeiffer // where setting the origin has no 6394b05331dSMichael Pfeiffer // effect if it is the same as 6404b05331dSMichael Pfeiffer // the previous value althou 6414b05331dSMichael Pfeiffer // it is from the "outer" coordinate 6424b05331dSMichael Pfeiffer // system 6434b05331dSMichael Pfeiffer view->SetHighColor(kGreen); 6444b05331dSMichael Pfeiffer view->FillRect(r); 6454b05331dSMichael Pfeiffer view->PopState(); 6464b05331dSMichael Pfeiffer } 6474b05331dSMichael Pfeiffer 6484b05331dSMichael Pfeiffer static void testSetOriginAndScale5(BView *view, BRect frame) 6494b05331dSMichael Pfeiffer { 6504b05331dSMichael Pfeiffer frame.InsetBy(2, 2); 6514b05331dSMichael Pfeiffer BPoint center = centerPoint(frame); 6524b05331dSMichael Pfeiffer 6534b05331dSMichael Pfeiffer BRect r(0, 0, frame.IntegerWidth() / 2, frame.IntegerHeight() / 2); 6544b05331dSMichael Pfeiffer view->SetOrigin(center); 6554b05331dSMichael Pfeiffer view->FillRect(r); 6564b05331dSMichael Pfeiffer 6574b05331dSMichael Pfeiffer view->SetScale(0.5); 6584b05331dSMichael Pfeiffer view->SetHighColor(kRed); 6594b05331dSMichael Pfeiffer view->FillRect(r); 6604b05331dSMichael Pfeiffer 6614b05331dSMichael Pfeiffer view->PushState(); 6624b05331dSMichael Pfeiffer view->SetScale(0.75); 6634b05331dSMichael Pfeiffer view->SetHighColor(kGreen); 6644b05331dSMichael Pfeiffer view->FillRect(r); 6654b05331dSMichael Pfeiffer view->PopState(); 6664b05331dSMichael Pfeiffer } 6674b05331dSMichael Pfeiffer 668c43f0163SMichael Pfeiffer static void testSetFontSize(BView *view, BRect frame) 669c43f0163SMichael Pfeiffer { 670c43f0163SMichael Pfeiffer frame.InsetBy(2, 2); 671c43f0163SMichael Pfeiffer int size = frame.IntegerHeight() / 3; 672c43f0163SMichael Pfeiffer 673c43f0163SMichael Pfeiffer frame.OffsetBy(0, size); 674c43f0163SMichael Pfeiffer view->MovePenTo(BPoint(frame.left, frame.top)); 675c43f0163SMichael Pfeiffer view->SetFontSize(size); 676c43f0163SMichael Pfeiffer view->DrawString("Haiku"); 677c43f0163SMichael Pfeiffer 678c43f0163SMichael Pfeiffer size *= 2; 679c43f0163SMichael Pfeiffer frame.OffsetBy(0, size); 680c43f0163SMichael Pfeiffer view->MovePenTo(BPoint(frame.left, frame.top)); 681c43f0163SMichael Pfeiffer view->SetFontSize(size); 682c43f0163SMichael Pfeiffer view->DrawString("Haiku"); 683c43f0163SMichael Pfeiffer } 684c43f0163SMichael Pfeiffer 685*2fb98dccSStefano Ceccherini static void testSetFontFamilyAndStyle(BView *view, BRect frame) 686*2fb98dccSStefano Ceccherini { 687*2fb98dccSStefano Ceccherini view->DrawString("This is a test", BPoint(2, 6)); 688*2fb98dccSStefano Ceccherini 689*2fb98dccSStefano Ceccherini BFont font; 690*2fb98dccSStefano Ceccherini view->GetFont(&font); 691*2fb98dccSStefano Ceccherini 692*2fb98dccSStefano Ceccherini int32 families = count_font_families(); 693*2fb98dccSStefano Ceccherini font_family familyName; 694*2fb98dccSStefano Ceccherini get_font_family(families - 1, &familyName); 695*2fb98dccSStefano Ceccherini 696*2fb98dccSStefano Ceccherini int32 styles = count_font_styles(familyName); 697*2fb98dccSStefano Ceccherini font_style styleName; 698*2fb98dccSStefano Ceccherini get_font_style(familyName, styles - 1, &styleName); 699*2fb98dccSStefano Ceccherini font.SetFamilyAndStyle(familyName, styleName); 700*2fb98dccSStefano Ceccherini view->SetFont(&font); 701*2fb98dccSStefano Ceccherini view->DrawString( "This is a test", BPoint(2, 19)); 702*2fb98dccSStefano Ceccherini } 703*2fb98dccSStefano Ceccherini 70415cf50e0SStefano Ceccherini static void testSetDrawingMode(BView *view, BRect frame) 70515cf50e0SStefano Ceccherini { 706ed70c5f3SStefano Ceccherini frame.InsetBy(2, 2); 70715cf50e0SStefano Ceccherini view->StrokeLine(frame.LeftTop(), frame.RightBottom()); 70815cf50e0SStefano Ceccherini view->StrokeLine(frame.LeftBottom(), frame.RightTop()); 70915cf50e0SStefano Ceccherini view->SetDrawingMode(B_OP_ALPHA); 71015cf50e0SStefano Ceccherini rgb_color color = kRed; 71115cf50e0SStefano Ceccherini color.alpha = 127; 71215cf50e0SStefano Ceccherini view->SetHighColor(color); 71315cf50e0SStefano Ceccherini view->FillRect(frame, B_SOLID_HIGH); 71415cf50e0SStefano Ceccherini } 71515cf50e0SStefano Ceccherini 716ed70c5f3SStefano Ceccherini static void testPushPopState(BView *view, BRect frame) 717ed70c5f3SStefano Ceccherini { 718ed70c5f3SStefano Ceccherini frame.InsetBy(2, 2); 719ed70c5f3SStefano Ceccherini view->SetHighColor(kGreen); 720ed70c5f3SStefano Ceccherini view->PushState(); 721ed70c5f3SStefano Ceccherini view->SetHighColor(kRed); 722ed70c5f3SStefano Ceccherini view->PopState(); 723ed70c5f3SStefano Ceccherini 724ed70c5f3SStefano Ceccherini view->FillRect(frame, B_SOLID_HIGH); 725ed70c5f3SStefano Ceccherini } 726ed70c5f3SStefano Ceccherini 72715cf50e0SStefano Ceccherini 728c43f0163SMichael Pfeiffer // TODO 729c43f0163SMichael Pfeiffer // - blending mode 730c43f0163SMichael Pfeiffer // - line mode 731c43f0163SMichael Pfeiffer // - push/pop state 732c43f0163SMichael Pfeiffer // - move pen 733c43f0163SMichael Pfeiffer // - set font 734c43f0163SMichael Pfeiffer 735c43f0163SMichael Pfeiffer 73682afdb09SMichael Pfeiffer TestCase gTestCases[] = { 73754730332SMichael Pfeiffer { "Test No Operation", testNoOp }, 73854730332SMichael Pfeiffer { "Test DrawChar", testDrawChar }, 73982afdb09SMichael Pfeiffer { "Test Draw String", testDrawString }, 74054730332SMichael Pfeiffer { "Test Draw String With Length", testDrawStringWithLength }, 74154730332SMichael Pfeiffer { "Test FillArc", testFillArc }, 74254730332SMichael Pfeiffer { "Test StrokeArc", testStrokeArc }, 743c43f0163SMichael Pfeiffer // testFillBezier fails under BeOS because the 744c43f0163SMichael Pfeiffer // direct draw version is not correct 74554730332SMichael Pfeiffer { "Test FillBezier", testFillBezier }, 74654730332SMichael Pfeiffer { "Test StrokeBezier", testStrokeBezier }, 74754730332SMichael Pfeiffer { "Test FillEllipse", testFillEllipse }, 74854730332SMichael Pfeiffer { "Test StrokeEllipse", testStrokeEllipse }, 74954730332SMichael Pfeiffer { "Test FillPolygon", testFillPolygon }, 75054730332SMichael Pfeiffer { "Test StrokePolygon", testStrokePolygon }, 75154730332SMichael Pfeiffer { "Test FillRect", testFillRect }, 75254730332SMichael Pfeiffer { "Test StrokeRect", testStrokeRect }, 75354730332SMichael Pfeiffer { "Test FillRegion", testFillRegion }, 75454730332SMichael Pfeiffer { "Test FillRoundRect", testFillRoundRect }, 75554730332SMichael Pfeiffer { "Test StrokeRoundRect", testStrokeRoundRect }, 75654730332SMichael Pfeiffer { "Test FillTriangle", testFillTriangle }, 75754730332SMichael Pfeiffer { "Test StrokeTriangle", testStrokeTriangle }, 75854730332SMichael Pfeiffer { "Test StrokeLine", testStrokeLine }, 75954730332SMichael Pfeiffer { "Test FillShape", testFillShape }, 76054730332SMichael Pfeiffer { "Test StrokeShape", testStrokeShape }, 76182afdb09SMichael Pfeiffer { "Test Record Picture", testRecordPicture }, 76282afdb09SMichael Pfeiffer { "Test Record And Play Picture", testRecordAndPlayPicture }, 76382afdb09SMichael Pfeiffer { "Test Record And Play Picture With Offset", testRecordAndPlayPictureWithOffset }, 76454730332SMichael Pfeiffer { "Test AppendToPicture", testAppendToPicture }, 76554730332SMichael Pfeiffer { "Test LineArray", testLineArray }, 76654730332SMichael Pfeiffer { "Test InvertRect", testInvertRect }, 7674f422578SMichael Pfeiffer { "Test DrawBitmap", testDrawBitmap }, 7684f422578SMichael Pfeiffer { "Test DrawBitmapAtPoint", testDrawBitmapAtPoint }, 7694f422578SMichael Pfeiffer { "Test DrawBitmapAtRect", testDrawBitmapAtRect }, 7705f380e34SMichael Pfeiffer { "Test DrawLargeBitmap", testDrawLargeBitmap }, 771c43f0163SMichael Pfeiffer { "Test ConstrainClippingRegion", testConstrainClippingRegion }, 772c43f0163SMichael Pfeiffer { "Test ClipToPicture", testClipToPicture }, 773c43f0163SMichael Pfeiffer { "Test ClipToInversePicture", testClipToInversePicture }, 774c43f0163SMichael Pfeiffer { "Test SetPenSize", testSetPenSize }, 775c43f0163SMichael Pfeiffer { "Test SetPenSize2", testSetPenSize2 }, 776c43f0163SMichael Pfeiffer { "Test Pattern", testPattern }, 777c43f0163SMichael Pfeiffer { "Test SetOrigin", testSetOrigin }, 778c43f0163SMichael Pfeiffer { "Test SetOrigin2", testSetOrigin2 }, 779c43f0163SMichael Pfeiffer { "Test SetScale", testSetScale }, 780c43f0163SMichael Pfeiffer // testSetScale2 fails under BeOS. The picture versions of the 781c43f0163SMichael Pfeiffer // rectangle are twice as large as the direct draw version 782c43f0163SMichael Pfeiffer { "Test SetScale2*", testSetScale2 }, 783c43f0163SMichael Pfeiffer { "Test SetScale3", testSetScale3 }, 784c9c4a80aSMichael Pfeiffer { "Test SetOriginAndScale", testSetOriginAndScale }, 7854b05331dSMichael Pfeiffer { "Test SetOriginAndScale2", testSetOriginAndScale2 }, 7864b05331dSMichael Pfeiffer { "Test SetOriginAndScale3", testSetOriginAndScale3 }, 7874b05331dSMichael Pfeiffer { "Test SetOriginAndScale4", testSetOriginAndScale4 }, 7884b05331dSMichael Pfeiffer { "Test SetOriginAndScale5", testSetOriginAndScale5 }, 789c43f0163SMichael Pfeiffer { "Test SetFontSize", testSetFontSize }, 790*2fb98dccSStefano Ceccherini { "Test SetFontFamilyAndStyle", testSetFontFamilyAndStyle }, 79115cf50e0SStefano Ceccherini { "Test SetDrawingMode", testSetDrawingMode }, 792ed70c5f3SStefano Ceccherini { "Test PushPopState", testPushPopState }, 79382afdb09SMichael Pfeiffer { NULL, NULL } 79482afdb09SMichael Pfeiffer }; 79562c7fd0fSMichael Pfeiffer 796*2fb98dccSStefano Ceccherini 797