1 /* 2 * Copyright 2019, Haiku Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Kacper Kasper, kacperkasper@gmail.com 7 */ 8 9 10 #include <Application.h> 11 #include <Bitmap.h> 12 #include <GradientRadial.h> 13 #include <String.h> 14 #include <View.h> 15 #include <Window.h> 16 17 #include <ctype.h> 18 #include <stdio.h> 19 #include <stdlib.h> 20 21 22 class View : public BView { 23 public: 24 View(BRect rect); 25 virtual ~View(); 26 27 virtual void Draw(BRect); 28 BBitmap* fBitmap; 29 }; 30 31 View::View(BRect rect) 32 : BView(rect, "tiledBitmaps", B_FOLLOW_ALL, B_WILL_DRAW) 33 { 34 SetViewColor(make_color(255, 0, 0)); 35 fBitmap = new BBitmap(BRect(0, 0, 5, 5), B_RGBA32); 36 uint32 data[] = { 37 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000, 38 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 39 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 40 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 41 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 42 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000, 43 }; 44 /*uint32 data[] = { 45 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 46 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 47 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 48 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 49 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 50 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 51 };*/ 52 fBitmap->SetBits((void*)data, sizeof(data), 0, B_RGBA32); 53 } 54 55 56 View::~View() 57 { 58 delete fBitmap; 59 } 60 61 62 void 63 View::Draw(BRect) 64 { 65 DrawTiledBitmap(fBitmap, BRect(10, 10, 60, 60), BPoint(1, 1)); 66 DrawTiledBitmap(fBitmap, BRect(10, 60, 60, 110), BPoint(3, 3)); 67 DrawTiledBitmap(fBitmap, BRect(10, 110, 60, 160)); 68 DrawBitmap(fBitmap, fBitmap->Bounds(), BRect(60, 10, 110, 60)); 69 } 70 71 72 // #pragma mark - 73 74 75 class Window : public BWindow { 76 public: 77 Window(); 78 virtual ~Window(); 79 80 virtual bool QuitRequested(); 81 }; 82 83 84 Window::Window() 85 : BWindow(BRect(100, 100, 300, 300), "TiledBitmap-Test", 86 B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) 87 { 88 BView *view = new View(Bounds()); 89 AddChild(view); 90 } 91 92 93 Window::~Window() 94 { 95 } 96 97 98 bool 99 Window::QuitRequested() 100 { 101 be_app->PostMessage(B_QUIT_REQUESTED); 102 return true; 103 } 104 105 106 // #pragma mark - 107 108 109 class Application : public BApplication { 110 public: 111 Application(); 112 113 virtual void ReadyToRun(); 114 }; 115 116 117 Application::Application() 118 : BApplication("application/x-vnd.haiku-tiled_bitmap_test") 119 { 120 } 121 122 123 void 124 Application::ReadyToRun() 125 { 126 Window *window = new Window(); 127 window->Show(); 128 } 129 130 131 // #pragma mark - 132 133 134 int 135 main(int argc, char **argv) 136 { 137 Application app; 138 139 app.Run(); 140 return 0; 141 } 142