a test application for BPicture, written by Lucasz

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19104 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2006-10-23 12:04:22 +00:00
parent 467dbaa9e2
commit 2b77c6f651
2 changed files with 77 additions and 0 deletions

View File

@ -122,6 +122,11 @@ SimpleTest MenuBeginningTest :
: be
;
SimpleTest PictureTest :
PictureTest.cpp
: be
;
SEARCH on [ FGristFiles
ScrollView.cpp CheckBox.cpp ChannelSlider.cpp ChannelControl.cpp Slider.cpp Control.cpp
] = [ FDirName $(HAIKU_TOP) src kits interface ] ;

View File

@ -0,0 +1,72 @@
#include <Application.h>
#include <Window.h>
#include <Box.h>
#include <View.h>
#include <Shape.h>
#include <Picture.h>
class PictureView : public BBox {
public:
PictureView(BRect frame);
~PictureView();
virtual void Draw(BRect update);
virtual void AllAttached(void);
private:
BPicture *fPicture;
};
PictureView::PictureView(BRect frame)
: BBox(frame, "pict_view", B_FOLLOW_ALL_SIDES, B_WILL_DRAW)
{
}
PictureView::~PictureView()
{
delete fPicture;
}
void
PictureView::AllAttached(void)
{
BShape shape;
BPoint bezier[3] = {BPoint(100,0), BPoint(100, 100), BPoint(25, 50)};
BeginPicture(new BPicture);
shape.MoveTo(BPoint(150,0));
shape.LineTo(BPoint(200,100));
shape.BezierTo(bezier);
shape.Close();
StrokeShape(&shape);
StrokeEllipse(BPoint(50, 150), 50, 50);
FillEllipse(BPoint(100, 120), 50, 50);
StrokeArc(BRect(0, 200, 50, 250), 180, 180);
FillArc(BPoint(150, 250), 50, 50, 0, 125);
fPicture = EndPicture();
}
void
PictureView::Draw(BRect update)
{
if (fPicture)
DrawPicture(fPicture, B_ORIGIN);
}
int
main(void)
{
BApplication *pictureApp = new BApplication("application/x-vnd.picture");
BWindow *pictureWindow = new BWindow(BRect(100, 100, 300, 400), "BPicture test",
B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE);
PictureView *pictureView = new PictureView(pictureWindow->Bounds());
pictureWindow->AddChild(pictureView);
pictureWindow->Show();
pictureApp->Run();
delete pictureApp;
return 0;
}