Advertisement
Guest User

Untitled

a guest
Mar 27th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include "MainComponent.h"
  2.  
  3.  
  4. void Box1::paint(Graphics& g)
  5. {
  6.     std::cout << g.getClipBounds().toString() << "\n";
  7.     g.setColour(Colour(150, 150, 150));
  8.     g.fillRect(g.getClipBounds());
  9.  
  10.     g.setColour(Colour(200, 200, 200));
  11.     g.drawRect(g.getClipBounds(), 1);
  12.     g.drawText("I'm a wide box", getLocalBounds(), Justification::centred, true);
  13. }
  14.  
  15.  
  16. void Box2::paint(Graphics& g)
  17. {
  18.     g.setColour(Colour(20, 20, 20));
  19.     g.fillRect(g.getClipBounds());
  20. }
  21.  
  22.  
  23. MainComponent::MainComponent()
  24. {
  25.     viewport.setViewedComponent(&box1);
  26.     addAndMakeVisible(viewport);
  27.     addAndMakeVisible(box2);
  28.     setSize(600, 400);
  29. }
  30.  
  31.  
  32. void MainComponent::mouseDrag(const MouseEvent& m)
  33. {
  34.     box2.setTopLeftPosition(m.x, m.y);
  35. };
  36.  
  37.  
  38. void MainComponent::paint(Graphics& g)
  39. {
  40.     g.fillAll(getLookAndFeel().findColour(ResizableWindow::backgroundColourId));
  41. }
  42.  
  43.  
  44. void MainComponent::resized()
  45. {
  46.     box1.setBounds(0, 0, 1000, 100);
  47.     box2.setBounds(200, 200, 100, 100);
  48.     viewport.setBounds(0, 0, getWidth(), getHeight());
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement