Blame view

Giac_maj/epsilon-giac/escher/src/editable_text_cell.cpp 1.86 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
67
  #include <escher/editable_text_cell.h>
  #include <escher/app.h>
  #include <escher/palette.h>
  #include <assert.h>
  
  EditableTextCell::EditableTextCell(Responder * parentResponder, TextFieldDelegate * delegate, char * draftTextBuffer,
     KDText::FontSize size, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) :
    HighlightCell(),
    Responder(parentResponder),
    m_textField(this, m_textBody, draftTextBuffer, TextField::maxBufferSize(), delegate, true, size, horizontalAlignment, verticalAlignment, textColor, backgroundColor)
  {
  }
  
  void EditableTextCell::setTextFieldDelegate(TextFieldDelegate * delegate) {
    m_textField.setDelegate(delegate);
  }
  
  void EditableTextCell::setTextFieldDraftTextBuffer(char * draftTextBuffer) {
    m_textField.setDraftTextBuffer(draftTextBuffer);
  }
  
  TextField * EditableTextCell::textField() {
    return &m_textField;
  }
  
  void EditableTextCell::setHighlighted(bool highlight) {
    HighlightCell::setHighlighted(highlight);
    KDColor backgroundColor = highlight? Palette::Select : KDColorWhite;
    m_textField.setBackgroundColor(backgroundColor);
  }
  
  const char * EditableTextCell::text() const {
    return m_textField.text();
  }
  
  void EditableTextCell::setText(const char * text) {
    m_textField.setText(text);
  }
  
  int EditableTextCell::numberOfSubviews() const {
    return 1;
  }
  
  View * EditableTextCell::subviewAtIndex(int index) {
    assert(index == 0);
    return &m_textField;
  }
  
  void EditableTextCell::layoutSubviews() {
    m_textField.setFrame(bounds());
  }
  
  void EditableTextCell::didBecomeFirstResponder() {
    app()->setFirstResponder(&m_textField);
  }
  
  bool EditableTextCell::isEditing() {
    return m_textField.isEditing();
  }
  
  void EditableTextCell::setEditing(bool isEditing) {
    m_textField.setEditing(isEditing);
  }
  
  KDSize EditableTextCell::minimalSizeForOptimalDisplay() const {
    return m_textField.minimalSizeForOptimalDisplay();
  }