* Style cleanup.

* Include correct header for strcmp().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37695 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2010-07-22 13:54:36 +00:00
parent 9ea2a07cf3
commit 80e6909dd1

View File

@ -1,35 +1,37 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <Application.h> #include <Application.h>
#include <Box.h> #include <Box.h>
#include <OS.h> #include <OS.h>
#include <Screen.h> #include <Screen.h>
#include <String.h>
#include <Window.h> #include <Window.h>
#include <stdio.h>
#include <stdlib.h>
static BRect* sFrames = NULL;
static BRect *sFrames = NULL;
static uint32 sNumFrames = 0; static uint32 sNumFrames = 0;
class TestApp : public BApplication { class TestApp : public BApplication {
public: public:
TestApp(uint32 numWindows, bool views); TestApp(uint32 numWindows, bool views);
virtual ~TestApp(); virtual ~TestApp();
virtual void ReadyToRun(); virtual void ReadyToRun();
private: private:
uint32 fFrameNum; void _CreateFrames(uint32 numWindows);
BRect fScreenFrame; int32 _WindowCreator();
uint32 fNumWindows; static int32 _ThreadStarter(void* data);
uint32 fMaxWindows;
bool fTestViews;
void _CreateFrames(uint32 numWindows); private:
int32 _WindowCreator(); uint32 fFrameNum;
static int32 _ThreadStarter(void *data); BRect fScreenFrame;
uint32 fNumWindows;
uint32 fMaxWindows;
bool fTestViews;
}; };
@ -37,13 +39,12 @@ class TestWindow : public BWindow {
public: public:
TestWindow(BRect frame, bool createView); TestWindow(BRect frame, bool createView);
virtual ~TestWindow(); virtual ~TestWindow();
}; };
TestApp::TestApp(uint32 numWindows, bool views) TestApp::TestApp(uint32 numWindows, bool views)
: BApplication("application/x.vnd-Haiku.window-creation"), :
BApplication("application/x.vnd-Haiku.window-creation"),
fScreenFrame(), fScreenFrame(),
fNumWindows(0), fNumWindows(0),
fMaxWindows(numWindows), fMaxWindows(numWindows),
@ -64,7 +65,8 @@ TestApp::~TestApp()
void void
TestApp::ReadyToRun() TestApp::ReadyToRun()
{ {
thread_id thread = spawn_thread(_ThreadStarter, "Window creator", B_NORMAL_PRIORITY, this); thread_id thread = spawn_thread(_ThreadStarter, "Window creator",
B_NORMAL_PRIORITY, this);
resume_thread(thread); resume_thread(thread);
} }
@ -73,8 +75,10 @@ void
TestApp::_CreateFrames(uint32 numWindows) TestApp::_CreateFrames(uint32 numWindows)
{ {
BRect frame(0, 0, 50, 50); BRect frame(0, 0, 50, 50);
uint32 numHorizontal = (fScreenFrame.IntegerWidth() + 1) / (frame.IntegerWidth() + 1); uint32 numHorizontal = (fScreenFrame.IntegerWidth() + 1)
uint32 numVertical = (fScreenFrame.IntegerHeight() + 1) / (frame.IntegerHeight() + 1); / (frame.IntegerWidth() + 1);
uint32 numVertical = (fScreenFrame.IntegerHeight() + 1)
/ (frame.IntegerHeight() + 1);
sNumFrames = numHorizontal * numVertical; sNumFrames = numHorizontal * numVertical;
sFrames = new BRect[sNumFrames]; sFrames = new BRect[sNumFrames];
for (uint32 i = 0; i < sNumFrames; i++) { for (uint32 i = 0; i < sNumFrames; i++) {
@ -95,14 +99,15 @@ TestApp::_WindowCreator()
if (fFrameNum >= sNumFrames) if (fFrameNum >= sNumFrames)
fFrameNum = 0; fFrameNum = 0;
BWindow *window = new TestWindow(sFrames[fFrameNum++], fTestViews); BWindow* window = new TestWindow(sFrames[fFrameNum++], fTestViews);
window->Show(); window->Show();
fNumWindows++; fNumWindows++;
} }
bigtime_t endTime = system_time(); bigtime_t endTime = system_time();
printf("Test completed. %ld windows created in %lld usecs.\n", fNumWindows, endTime - startTime); printf("Test completed. %ld windows created in %lld usecs.\n", fNumWindows,
endTime - startTime);
PostMessage(B_QUIT_REQUESTED); PostMessage(B_QUIT_REQUESTED);
return B_OK; return B_OK;
@ -110,14 +115,15 @@ TestApp::_WindowCreator()
int32 int32
TestApp::_ThreadStarter(void *data) TestApp::_ThreadStarter(void* data)
{ {
return static_cast<TestApp *>(data)->_WindowCreator(); return static_cast<TestApp*>(data)->_WindowCreator();
} }
TestWindow::TestWindow(BRect frame, bool views) TestWindow::TestWindow(BRect frame, bool views)
: BWindow(frame, "Test", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) :
BWindow(frame, "Test", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
{ {
if (views) if (views)
AddChild(new BBox(Bounds())); AddChild(new BBox(Bounds()));
@ -129,16 +135,13 @@ TestWindow::~TestWindow()
} }
// main
int int
main(int argc, char** argv) main(int argc, char** argv)
{ {
uint32 numWindows = 10; uint32 numWindows = 10;
bool testViews = false; bool testViews = false;
if (argc > 1) { if (argc > 1)
numWindows = atoi(argv[1]); numWindows = atoi(argv[1]);
}
if (argc > 2) { if (argc > 2) {
if (!strcmp(argv[2], "views")) if (!strcmp(argv[2], "views"))