summaryrefslogtreecommitdiffstats
path: root/quanta/parts/kafka/cursors.h
blob: 6ff94439442b7cf5757190eeacc2892e90f43b97 (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/***************************************************************************
                                   cursor.h
                             -------------------

    copyright            : (C) 2004 - Nicolas Deschildre
    email                : [email protected]
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
 
 #ifndef CURSORS_H
 #define CURSORS_H
 
 /**
  * This represents a Node selection : StartNode and StartOffset, endNode and endOffset.
  * IT can also only hold the cursor. If so, cursorNodeEndSel() will be empty.
  * TODO: selection support
  */
 class NodeSelection
 {
 public:
   NodeSelection(Node* node = 0L, int offset = 0){m_cursorNode = node; m_cursorOffset = offset;}
   ~NodeSelection(){}
   
   /**
    * @return Return the Node when the selection start (and where the cursor is if 
    * m_cursorAtSelectionStart).
    */
   Node* cursorNode(){return m_cursorNode;}
   void setCursorNode(Node* node){m_cursorNode = node;}
   
   /**
    * @return Returns the offset of the cursor where the selection begin (and where the cursor is if 
    * m_cursorAtSelectionStart)
    */
   int cursorOffset(){return m_cursorOffset;}
   void setCursorOffset(int offset){m_cursorOffset = offset;}
   
 private:
  Node* m_cursorNode, *m_cursorNodeEndSel;
  int m_cursorOffset, m_cursorOffsetEndSel;
  bool m_cursorAtSelectionStart;
 };
 
 /**
 * This represents a Node selection : startNode and startOffset, endNode and endOffset.
 * The difference with NodeSelection is that it don't store the Node address of startNode
 * and endNode, but it store the Node position of the Node tree e.g. it is the first child
 * of the second child of the rootNode...
 * It can also only hold the cursor. If so, cursorNodeEndSel() will be empty.
 */
class NodeSelectionInd
{
public:
  NodeSelectionInd();
  NodeSelectionInd(Node* cursor_node, int cursor_offset);
  NodeSelectionInd(Node* start_node, int start_offset, Node* end_node, int end_offset);
  ~NodeSelectionInd();
  
  /**
   * Compare nodeselection to the current instance.
   */
  bool operator==(const NodeSelectionInd & nodeSelection);
  
  void operator=(const NodeSelectionInd & nodeSelection);
  
  /**
   * Take the current VPL cursor selection coordinates, if not speficied otherwise, translate
   * them into Node cursor coordinates and store them.
   */
  void fillWithVPLCursorSelection();
  
  bool hasSelection() const;
  
  /**---------------------------------- GET/SET --------------------------------------------*/

  /**
  * @return Returns the location of the Node where the selection begin (and where the cursor is if 
  * m_cursorAtSelectionStart).
  */
  TQValueList<int>& cursorNode() {return m_cursorNode;}
  
  /**
  * @param cursorNode Set the location of the Node where the selection begin (and where the cursor is if 
  * m_cursorAtSelectionStart)
  */
  void setCursorNode(TQValueList<int> cursorNode) {m_cursorNode = cursorNode;}
  
  /**
  * @return Returns the offset of the cursor where the selection begin (and where the cursor is if 
  * m_cursorAtSelectionStart)
  */
  int cursorOffset() {return m_cursorOffset;}
  
  /**
  * @param cursorOffset Set the offset of the cursor where the selection begin (and where the cursor is if 
  * m_cursorAtSelectionStart)
  */
  void setCursorOffset(int cursorOffset) {m_cursorOffset = cursorOffset;}
  
  /**
   * @return Returns true if the cursor is at the beginning of the selection. Otherwise, it is
   * at the end of the selection.
   */
  bool cursorAtSelectionStart() {return m_cursorAtSelectionStart;}
  
  /**
   * @param cursorAtSelectionStart Set if the cursor is at the beginning of the selection.
   */
  void setCursorAtSelectionStart(bool cursorAtSelectionStart) {m_cursorAtSelectionStart = cursorAtSelectionStart;}
  
  /**
  * @return Returns the location of the end selection Node where the
  * selection ends.
  * Empty if this instance only carry the cursor coordinates.
  */
  TQValueList<int>& cursorNodeEndSel() {return m_cursorNodeEndSel;}
  
  /**
  * @param cursorNodeEndSel Set the location of the end selection Node where the
  * selection ends.
  */
  void setCursorNodeEndSel(TQValueList<int> cursorNodeEndSel) 
    {m_cursorNodeEndSel = cursorNodeEndSel;}
    
  /**
  * @return Returns the offset of the cursor in the Node of the end of the selection.
  */
  int cursorOffsetEndSel() {return m_cursorOffsetEndSel;}
  
  /**
  * @param cursorOffsetEndSel Set the offset of the cursor in the Node of the end of the selection
  */
  void setCursorOffsetEndSel(int cursorOffsetEndSel)
    {m_cursorOffsetEndSel = cursorOffsetEndSel;}
  
private:
  TQValueList<int> m_cursorNode, m_cursorNodeEndSel;
  int m_cursorOffset, m_cursorOffsetEndSel;
  bool m_cursorAtSelectionStart;
};

#endif