Blame view

emulateur/epsilon-nofrendo/apps/code/console_line_cell.h 1.79 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
54
55
56
57
58
59
60
61
62
63
64
65
66
  #ifndef CODE_CONSOLE_LINE_CELL_H
  #define CODE_CONSOLE_LINE_CELL_H
  
  #include <escher/highlight_cell.h>
  #include <escher/message_text_view.h>
  #include <escher/responder.h>
  #include <escher/palette.h>
  #include <escher/scrollable_view.h>
  #include <escher/scroll_view_data_source.h>
  #include <assert.h>
  
  #include "console_line.h"
  
  namespace Code {
  
  class ConsoleLineCell : public HighlightCell, public Responder {
  public:
    ConsoleLineCell(Responder * parentResponder = nullptr);
    void setLine(ConsoleLine line);
  
    /* HighlightCell */
    void setHighlighted(bool highlight) override;
    void reloadCell() override;
    Responder * responder() override {
      return this;
    }
    const char * text() const override {
      return m_line.text();
    }
    /* View */
    int numberOfSubviews() const override;
    View * subviewAtIndex(int index) override;
    void layoutSubviews() override;
  
    /* Responder */
    void didBecomeFirstResponder() override;
  private:
    class ScrollableConsoleLineView : public ScrollableView, public ScrollViewDataSource {
    public:
      class ConsoleLineView : public HighlightCell {
      public:
        ConsoleLineView();
        void setLine(ConsoleLine * line);
        void drawRect(KDContext * ctx, KDRect rect) const override;
        KDSize minimalSizeForOptimalDisplay() const override;
      private:
        ConsoleLine * m_line;
      };
  
      ScrollableConsoleLineView(Responder * parentResponder);
      KDSize minimalSizeForOptimalDisplay() const override;
      ConsoleLineView * consoleLineView() { return &m_consoleLineView; }
    private:
      ConsoleLineView m_consoleLineView;
    };
    static KDColor textColor(ConsoleLine * line) {
      return line->isFromCurrentSession() ? KDColorBlack : Palette::GreyDark;
    }
    MessageTextView m_promptView;
    ScrollableConsoleLineView m_scrollableView;
    ConsoleLine m_line;
  };
  
  }
  
  #endif