vfs: check userland buffers before reading them.
[haiku.git] / src / tests / servers / app / cursor_test / CursorTest.cpp
blobec22fc4f0dc3e0f6414bce4924b02da00c2ccbcb
1 /*
2 * Copyright 2006, Haiku Inc.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Axel Dörfler, axeld@pinc-software.de
7 */
10 #include <Application.h>
11 #include <Cursor.h>
12 #include <String.h>
13 #include <View.h>
14 #include <Window.h>
16 #include <ctype.h>
17 #include <stdio.h>
18 #include <stdlib.h>
21 class View : public BView {
22 public:
23 View(BRect rect);
24 virtual ~View();
26 virtual void AttachedToWindow();
30 const uint8 kCursorData[68] = {
31 16, 1, 8, 8,
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,
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,
44 bool gHide = false;
47 View::View(BRect rect)
48 : BView(rect, "desktop view", B_FOLLOW_ALL, B_WILL_DRAW)
50 SetViewColor(0, 150, 0);
54 View::~View()
59 void
60 View::AttachedToWindow()
62 BCursor cursor(kCursorData);
63 SetViewCursor(&cursor);
67 // #pragma mark -
70 class Window : public BWindow {
71 public:
72 Window();
73 virtual ~Window();
75 virtual bool QuitRequested();
79 Window::Window()
80 : BWindow(BRect(100, 100, 400, 400), "Cursor-Test",
81 B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
83 BView *view = new View(Bounds().InsetByCopy(30, 30));
84 AddChild(view);
88 Window::~Window()
93 bool
94 Window::QuitRequested()
96 be_app->PostMessage(B_QUIT_REQUESTED);
97 return true;
101 // #pragma mark -
104 class Application : public BApplication {
105 public:
106 Application();
108 virtual void ReadyToRun();
112 Application::Application()
113 : BApplication("application/x-vnd.haiku-cursor_test")
118 void
119 Application::ReadyToRun()
121 Window *window = new Window();
122 window->Show();
124 if (gHide)
125 HideCursor();
126 else
127 SetCursor(B_I_BEAM_CURSOR);
131 // #pragma mark -
134 int
135 main(int argc, char **argv)
137 if (argc > 1 && !strcmp(argv[1], "hide"))
138 gHide = true;
140 Application app;
142 app.Run();
143 return 0;