/[fenfire]/fenfire/org/fenfire/fenmm/MMTextCursor.java
ViewVC logotype

Diff of /fenfire/org/fenfire/fenmm/MMTextCursor.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by tjl, Wed Sep 10 13:28:24 2003 UTC revision 1.8 by tjl, Sat Oct 18 06:06:29 2003 UTC
# Line 1  Line 1 
1  // (c): Asko Soukka  /*
2    MMTextCursor.java
3     *    
4     *    Copyright (c) 2003, Asko Soukka
5     *    This file is part of Fenfire.
6     *    
7     *    Fenfire is free software; you can redistribute it and/or modify it under
8     *    the terms of the GNU Lesser General Public License as published by
9     *    the Free Software Foundation; either version 2 of the License, or
10     *    (at your option) any later version.
11     *    
12     *    Fenfire is distributed in the hope that it will be useful, but WITHOUT
13     *    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14     *    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
15     *    Public License for more details.
16     *    
17     *    You should have received a copy of the GNU Lesser General
18     *    Public License along with Fenfire; if not, write to the Free
19     *    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20     *    MA  02111-1307  USA
21     *    
22     */
23    /*
24     * Written by Asko Soukka
25     */
26    
27  /**  /**
28   * Cursor class especially designed for MM purposes. Could be   * Cursor class especially designed for MM purposes. Could be
# Line 69  public class MMTextCursor { Line 93  public class MMTextCursor {
93      /** Move the cursor to the previous line. */      /** Move the cursor to the previous line. */
94      public int moveUp() throws NotYetRenderedException {      public int moveUp() throws NotYetRenderedException {
95          if (p == null) throw new NotYetRenderedException();          if (p == null) throw new NotYetRenderedException();
96          float cursorXY[] = new float[2];          float cursorXY[] = new float[3];
97          p.getCursorXY(offset, cursorXY);          p.getCursorXYY(offset, cursorXY);
98          cursorXY[1] -= style.getHeight(scale);          cursorXY[2] -= style.getHeight(scale);
99          offset = p.getCursorPos(cursorXY[0], cursorXY[1]);          offset = p.getCursorPos(cursorXY[0], cursorXY[2]);
100          return offset;          return offset;
101      }      }
102      /** Move the cursor to the next line. */      /** Move the cursor to the next line. */
103      public int moveDown() throws NotYetRenderedException {      public int moveDown() throws NotYetRenderedException {
104          if (p == null) throw new NotYetRenderedException();          if (p == null) throw new NotYetRenderedException();
105          float cursorXY[] = new float[2];          float cursorXY[] = new float[3];
106          p.getCursorXY(offset, cursorXY);          p.getCursorXYY(offset, cursorXY);
107          cursorXY[1] += style.getHeight(scale);          cursorXY[2] += style.getHeight(scale);
108          offset = p.getCursorPos(cursorXY[0], cursorXY[1]);          offset = p.getCursorPos(cursorXY[0], cursorXY[2]);
109          return offset;          return offset;
110      }      }
111      /** Move the cursor into the beginning of the text. */      /** Move the cursor into the beginning of the text. */
# Line 99  public class MMTextCursor { Line 123  public class MMTextCursor {
123      /** Move the cursor into the beginning of the line. */      /** Move the cursor into the beginning of the line. */
124      public int moveBeginLine() throws NotYetRenderedException{      public int moveBeginLine() throws NotYetRenderedException{
125          if (p == null) throw new NotYetRenderedException();          if (p == null) throw new NotYetRenderedException();
126          float cursorXY[] = new float[2];          float cursorXY[] = new float[3];
127          p.getCursorXY(offset, cursorXY);          p.getCursorXYY(offset, cursorXY);
128          cursorXY[0] = 0;          cursorXY[0] = 0;
129          offset = p.getCursorPos(cursorXY[0], cursorXY[1]);          offset = p.getCursorPos(cursorXY[0], cursorXY[2]);
130          return offset;          return offset;
131      }      }
132      /** Move the cursor to the end of the line. */      /** Move the cursor to the end of the line. */
# Line 111  public class MMTextCursor { Line 135  public class MMTextCursor {
135          if (length == 0) length = getLength();          if (length == 0) length = getLength();
136          // the end of line is reached by going to home of the line below          // the end of line is reached by going to home of the line below
137          // and returning a single character back if not the end of text was reached          // and returning a single character back if not the end of text was reached
138          float cursorXY[] = new float[2];          float cursorXY[] = new float[3];
139          p.getCursorXY(offset, cursorXY);          p.getCursorXYY(offset, cursorXY);
140          cursorXY[0] = 0;          cursorXY[0] = 0;
141          cursorXY[1] += style.getHeight(scale);          cursorXY[2] += style.getHeight(scale);
142          offset = p.getCursorPos(cursorXY[0], cursorXY[1]);          offset = p.getCursorPos(cursorXY[0], cursorXY[2]);
143          if (offset < length) offset -= 1;          if (offset < length) offset -= 1;
144          return offset;          return offset;
145      }      }
# Line 132  public class MMTextCursor { Line 156  public class MMTextCursor {
156      public void render(VobScene vs, int into, int matchCS, int matchParentCS, TextPlaceable p) {      public void render(VobScene vs, int into, int matchCS, int matchParentCS, TextPlaceable p) {
157          setTextPlaceable(p);          setTextPlaceable(p);
158    
159          float cursorXY[] = new float[2];          float cursorXY[] = new float[3];
160          this.p.getCursorXY(offset, cursorXY);          this.p.getCursorXYY(offset, cursorXY);
161    
162          int nodeCS = 0;          int nodeCS = 0;
163          int cursorCS = 0;          int cursorCS = 0;
164          if (matchParentCS == -1) {          if (matchParentCS == -1) {
165              cursorCS = vs.coords.ortho(into, -1000,              cursorCS = vs.coords.ortho(into, -1000,
166                                         -p.getWidth()/2 + cursorXY[0],                                         -p.getWidth()/2 + cursorXY[0],
167                                         -p.getHeight()/2 + cursorXY[1],                                         -p.getHeight()/2 + cursorXY[2],
168                                         1, -style.getHeight(scale));                                         1, -style.getHeight(scale));
169              vs.matcher.add(matchCS, cursorCS, "CURSOR");              vs.matcher.add(matchCS, cursorCS, "CURSOR");
170          } else {          } else {
# Line 150  public class MMTextCursor { Line 174  public class MMTextCursor {
174                    
175              cursorCS = vs.coords.ortho(into, -1000,              cursorCS = vs.coords.ortho(into, -1000,
176                                        nodeXY[0] + cursorXY[0],                                        nodeXY[0] + cursorXY[0],
177                                        nodeXY[1] + cursorXY[1],                                        nodeXY[1] + cursorXY[2],
178                                        1, -style.getHeight(scale));                                        1, -style.getHeight(scale));
179              vs.matcher.add(matchCS, cursorCS, "CURSOR");              vs.matcher.add(matchCS, cursorCS, "CURSOR");
180          }          }

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26