Blame view

build2/epsilon-master/apps/probability/responder_image_cell.cpp 1.75 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  #include "responder_image_cell.h"
  #include <assert.h>
  
  namespace Probability {
  
  ResponderImageCell::ResponderImageCell(Responder * parentResponder, Law * law, Calculation * calculation, CalculationController * calculationController) :
    HighlightCell(),
    Responder(parentResponder),
    m_calculationTypeController(nullptr, law, calculation, calculationController)
  {
  }
  
  void ResponderImageCell::drawRect(KDContext * ctx, KDRect rect) const {
    ctx->fillRect(bounds(), KDColorWhite);
    ctx->strokeRect(KDRect(0, 0, ImageCell::k_width+2*k_outline, ImageCell::k_height+2*k_outline), Palette::GreyMiddle);
  }
  
  KDSize ResponderImageCell::minimalSizeForOptimalDisplay() const {
    return KDSize(2*k_outline+ImageCell::k_width, 2*k_outline*ImageCell::k_height);
  }
  
  bool ResponderImageCell::handleEvent(Ion::Events::Event event) {
    if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Down) {
      KDPoint topLeftAngle = app()->modalView()->pointFromPointInView(this, KDPoint(k_outline, k_outline));
      app()->displayModalViewController(&m_calculationTypeController, 0.0f, 0.0f, topLeftAngle.y(), topLeftAngle.x());
      return true;
    }
    return false;
  }
  
  void ResponderImageCell::setHighlighted(bool highlight) {
    HighlightCell::setHighlighted(highlight);
    m_imageCell.setHighlighted(highlight);
  }
  
  void ResponderImageCell::setImage(const Image * image, const Image * focusedImage) {
    m_imageCell.setImage(image, focusedImage);
  }
  
  int ResponderImageCell::numberOfSubviews() const {
    return 1;
  }
  
  View * ResponderImageCell::subviewAtIndex(int index) {
    assert(index == 0);
    return &m_imageCell;
  }
  
  void ResponderImageCell::layoutSubviews() {
    m_imageCell.setFrame(KDRect(k_outline, k_outline, bounds().width()-2*k_outline, bounds().height()-2*k_outline));
  }
  
  }