1/* 2 * Copyright 2006, Haiku Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Axel Dörfler, axeld@pinc-software.de 7 */ 8 9 10#include <Application.h> 11#include <Cursor.h> 12#include <String.h> 13#include <View.h> 14#include <Window.h> 15 16#include <ctype.h> 17#include <stdio.h> 18#include <stdlib.h> 19 20 21class View : public BView { 22 public: 23 View(BRect rect); 24 virtual ~View(); 25 26 virtual void AttachedToWindow(); 27}; 28 29 30const uint8 kCursorData[68] = { 31 16, 1, 8, 8, 32 33 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 34 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 35 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 36 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 37 38 0xff, 0xff, 0x80, 0x01, 0x80, 0x01, 0x8f, 0xf1, 39 0x88, 0x11, 0x88, 0x11, 0x88, 0x11, 0x89, 0x91, 40 0x89, 0x91, 0x88, 0x11, 0x88, 0x11, 0x88, 0x11, 41 0x8f, 0xf1, 0x80, 0x01, 0x80, 0x01, 0xff, 0xff, 42}; 43 44bool gHide = false; 45 46 47View::View(BRect rect) 48 : BView(rect, "desktop view", B_FOLLOW_ALL, B_WILL_DRAW) 49{ 50 SetViewColor(0, 150, 0); 51} 52 53 54View::~View() 55{ 56} 57 58 59void 60View::AttachedToWindow() 61{ 62 BCursor cursor(kCursorData); 63 SetViewCursor(&cursor); 64} 65 66 67// #pragma mark - 68 69 70class Window : public BWindow { 71 public: 72 Window(); 73 virtual ~Window(); 74 75 virtual bool QuitRequested(); 76}; 77 78 79Window::Window() 80 : BWindow(BRect(100, 100, 400, 400), "Cursor-Test", 81 B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) 82{ 83 BView *view = new View(Bounds().InsetByCopy(30, 30)); 84 AddChild(view); 85} 86 87 88Window::~Window() 89{ 90} 91 92 93bool 94Window::QuitRequested() 95{ 96 be_app->PostMessage(B_QUIT_REQUESTED); 97 return true; 98} 99 100 101// #pragma mark - 102 103 104class Application : public BApplication { 105 public: 106 Application(); 107 108 virtual void ReadyToRun(); 109}; 110 111 112Application::Application() 113 : BApplication("application/x-vnd.haiku-cursor_test") 114{ 115} 116 117 118void 119Application::ReadyToRun() 120{ 121 Window *window = new Window(); 122 window->Show(); 123 124 if (gHide) 125 HideCursor(); 126 else 127 SetCursor(B_I_BEAM_CURSOR); 128} 129 130 131// #pragma mark - 132 133 134int 135main(int argc, char **argv) 136{ 137 if (argc > 1 && !strcmp(argv[1], "hide")) 138 gHide = true; 139 140 Application app; 141 142 app.Run(); 143 return 0; 144} 145