Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Application.h>
- #include <InterfaceDefs.h>
- #include <Rect.h>
- #include <View.h>
- #include <Window.h>
- static const rgb_color red = (rgb_color){ 255, 0, 0 };
- static const rgb_color green = (rgb_color){ 0, 255, 0 };
- static const rgb_color blue = (rgb_color){ 0, 0, 255 };
- class View : public BView {
- public:
- View();
- virtual ~View();
- virtual void FrameResized(float width, float height);
- virtual void Draw(BRect updateRect);
- };
- View::View()
- :
- BView(BRect(0, 0, 400, 200), "bwah", B_FOLLOW_ALL_SIDES,
- B_FRAME_EVENTS | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
- {
- SetViewColor(green);
- }
- View::~View()
- {
- }
- void
- View::FrameResized(float width, float height)
- {
- SetViewColor(blue);
- }
- void
- View::Draw(BRect updateRect)
- {
- SetViewColor(red);
- }
- class App : public BApplication {
- public:
- App();
- ~App();
- protected:
- void ReadyToRun();
- };
- App::App()
- :
- BApplication("application/x-vnd.Haiku-ResizeTester")
- {
- }
- App::~App(void)
- {
- }
- void
- App::ReadyToRun()
- {
- BWindow* window = new BWindow(BRect(100, 100, 400, 200), "resize tester window",
- B_TITLED_WINDOW, B_NOT_ZOOMABLE);
- View* view = new View();
- window->AddChild(view);
- window->Show();
- }
- int
- main(void)
- {
- App app;
- app.Run();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement