Advertisement
Guest User

ResizeTester

a guest
Jul 13th, 2013
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Application.h>
  2. #include <InterfaceDefs.h>
  3. #include <Rect.h>
  4. #include <View.h>
  5. #include <Window.h>
  6.  
  7.  
  8. static const rgb_color red = (rgb_color){ 255, 0, 0 };
  9. static const rgb_color green = (rgb_color){ 0, 255, 0 };
  10. static const rgb_color blue = (rgb_color){ 0, 0, 255 };
  11.  
  12.  
  13. class View : public BView {
  14. public:
  15.     View();
  16.     virtual ~View();
  17.  
  18.     virtual void FrameResized(float width, float height);
  19.     virtual void Draw(BRect updateRect);
  20. };
  21.  
  22.  
  23. View::View()
  24.     :
  25.     BView(BRect(0, 0, 400, 200), "bwah", B_FOLLOW_ALL_SIDES,
  26.         B_FRAME_EVENTS | B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
  27. {
  28.     SetViewColor(green);
  29. }
  30.  
  31.  
  32. View::~View()
  33. {
  34. }
  35.  
  36.  
  37. void
  38. View::FrameResized(float width, float height)
  39. {
  40.     SetViewColor(blue);
  41. }
  42.  
  43.  
  44. void
  45. View::Draw(BRect updateRect)
  46. {
  47.     SetViewColor(red);
  48. }
  49.  
  50.  
  51. class App : public BApplication {
  52. public:
  53.     App();
  54.     ~App();
  55.  
  56. protected:
  57.     void ReadyToRun();
  58. };
  59.  
  60.  
  61. App::App()
  62.     :
  63.     BApplication("application/x-vnd.Haiku-ResizeTester")
  64. {
  65. }
  66.  
  67.  
  68. App::~App(void)
  69. {
  70. }
  71.  
  72.  
  73. void
  74. App::ReadyToRun()
  75. {
  76.     BWindow* window = new BWindow(BRect(100, 100, 400, 200), "resize tester window",
  77.         B_TITLED_WINDOW, B_NOT_ZOOMABLE);
  78.  
  79.     View* view = new View();
  80.     window->AddChild(view);
  81.  
  82.     window->Show();
  83. }
  84.  
  85.  
  86. int
  87. main(void)
  88. {
  89.     App app;
  90.     app.Run();
  91.  
  92.     return 0;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement