Added a test which our app_server/libbe does not pass yet.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13058 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2005-06-11 13:21:25 +00:00
parent 9851ab5c1e
commit a2e24cf5ce
2 changed files with 74 additions and 0 deletions

View File

@ -96,6 +96,11 @@ SimpleTest GetMouseTest :
: be
;
SimpleTest PulseTest :
PulseTest.cpp
: be
;
SEARCH on [ FGristFiles
ScrollView.cpp CheckBox.cpp ChannelSlider.cpp ChannelControl.cpp
] = [ FDirName $(OBOS_TOP) src kits interface ] ;

View File

@ -0,0 +1,69 @@
#include <Application.h>
#include <View.h>
#include <Window.h>
#include <stdio.h>
#include <stdlib.h>
static void
ChangeColor(rgb_color &color)
{
color.red = rand() % 255;
color.green = rand() % 255;
}
class PulseView : public BView {
public:
PulseView(BRect rect, const char *name, uint32 resizeMode, uint32 flags)
: BView(rect, name, resizeMode, flags)
{
fLeft = Bounds().OffsetToCopy(B_ORIGIN);
fLeft.right -= Bounds().Width() / 2;
fRight = fLeft.OffsetByCopy(fLeft.Width(), 0);
fColor.red = 255;
fColor.green = 255;
fColor.blue = 255;
}
virtual void Pulse()
{
SetHighColor(fColor);
BRect rect = fRight;
if (fLeftTurn)
rect = fLeft;
FillRect(rect, B_SOLID_HIGH);
fLeftTurn = !fLeftTurn;
ChangeColor(fColor);
}
BRect fLeft;
BRect fRight;
bool fLeftTurn;
rgb_color fColor;
};
void
show_window(BWindow *window)
{
BView *view = new PulseView(window->Bounds(), "pulse view", B_FOLLOW_ALL, B_PULSE_NEEDED|B_WILL_DRAW);
window->SetPulseRate(500000);
window->AddChild(view);
window->Show();
}
int main()
{
srand(time(NULL));
BApplication app("application/x-vnd.pulse_test");
BWindow *window = new BWindow(BRect(100, 100, 400, 300), "pulse test",
B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE | B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE);
show_window(window);
app.Run();
}