Ticket #2105: test.cpp

File test.cpp, 1.4 KB (added by pulkomandy, 13 years ago)

Test app showing TranslationUtil locking problem.

Line 
1#include <Window.h>
2#include <View.h>
3#include <Bitmap.h>
4#include <Screen.h>
5#include <TranslationUtils.h>
6#include <Application.h>
7
8#define kVBLlogoWidth 200
9#define kVBLlogoHeight 200
10
11
12class SplashScreen : public BWindow
13{
14public:
15 SplashScreen();
16 ~SplashScreen();
17 virtual void WindowActivated(bool active);
18private:
19 BView *splashView;
20 BBitmap *splashBitmap;
21};
22
23SplashScreen::SplashScreen()
24 : BWindow(BRect(0, 0, kVBLlogoWidth - 1, kVBLlogoHeight + 1), "SplashScreen", B_BORDERED_WINDOW,
25 B_NOT_CLOSABLE | B_NOT_RESIZABLE | B_NOT_MOVABLE | B_NOT_ZOOMABLE)
26{
27 BScreen *theScreen = new BScreen(this);
28 BRect screenRect = theScreen->Frame();
29
30 MoveTo(screenRect.Width() / 2 - Frame().Width() / 2, screenRect.Height() / 2 - Frame().Height() / 2);
31 delete theScreen;
32}
33
34void SplashScreen::WindowActivated(bool active)
35{
36 if (active)
37 {
38 BRect rect = Bounds();
39 splashView = new BView(rect, "splashview", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
40 AddChild(splashView);
41 splashBitmap = BTranslationUtils::GetBitmap("Marzi4.jpg");
42 splashView->SetViewBitmap(splashBitmap);
43 }
44}
45
46SplashScreen::~SplashScreen()
47{
48
49}
50
51class SplashApp : public BApplication
52{
53public:
54 SplashApp() : BApplication("application/SplashScreen")
55 {
56 SplashScreen* s = new SplashScreen();
57 s->Show();
58
59 sleep(10);
60
61 s->Lock();
62 s->Close();
63 }
64};
65
66int main(void)
67{
68 SplashApp* a = new SplashApp();
69 a->Run();
70
71 delete a;
72
73 return 0;
74}