/* */ package NET.worlds.console; /* */ /* */ import NET.worlds.core.IniFile; /* */ import java.awt.Canvas; /* */ import java.awt.Color; /* */ import java.awt.Container; /* */ import java.awt.FontMetrics; /* */ import java.awt.Graphics; /* */ import java.awt.Image; /* */ import java.awt.Rectangle; /* */ import java.awt.Scrollbar; /* */ import java.awt.event.KeyEvent; /* */ import java.awt.event.MouseEvent; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ class StyledTextCanvas /* */ extends Canvas /* */ { /* */ private static final long serialVersionUID = -2680423246934436331L; /* */ /* */ public StyledTextCanvas() /* */ { /* 1186 */ enableEvents(53L); /* */ /* */ /* 1189 */ setEnabled(true); /* */ } /* */ /* 1192 */ private MouseEvent delayedMouseEvent = null; /* */ /* */ public void sendDelayedMouseEvent(MouseEvent e) { /* 1195 */ synchronized (getParent()) { /* 1196 */ this.delayedMouseEvent = e; /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 1218 */ protected int mouseX = -1; /* 1219 */ protected int mouseY = -1; /* 1220 */ protected int startX = -1; /* 1221 */ protected int startY = -1; /* 1222 */ protected int endX = -1; /* 1223 */ protected int endY = -1; /* 1224 */ protected long mouseWhen = 0L; /* 1225 */ protected boolean mouseActive = false; /* 1226 */ protected boolean mouseDoubleClick = false; /* */ /* 1228 */ protected static long doubleClickSpeed = IniFile.override().getIniInt("DoubleClickSpeed", 300); /* */ /* */ protected void processMouseMotionEvent(MouseEvent e) /* */ { /* 1232 */ if ((e.getID() == 506) && (this.mouseActive)) { /* 1233 */ processMouseEvent(e); /* */ } /* */ /* 1236 */ super.processMouseMotionEvent(e); /* */ } /* */ /* */ protected void processMouseEvent(MouseEvent e) /* */ { /* 1241 */ synchronized (getParent()) { /* 1242 */ if (e.getID() == 500) /* */ { /* 1244 */ if ((this.mouseWhen > 0L) && /* 1245 */ (e.getWhen() - this.mouseWhen <= doubleClickSpeed)) /* */ { /* 1247 */ this.mouseDoubleClick = true; /* 1248 */ this.mouseWhen = 0L; /* 1249 */ this.mouseX = (this.startX = this.endX = e.getX()); /* 1250 */ this.mouseY = (this.startY = this.endY = e.getY()); /* 1251 */ ((GammaTextArea)getParent()).selectionConversion = true; /* 1252 */ getParent().repaint(); /* */ } /* */ else { /* 1255 */ this.mouseDoubleClick = false; /* 1256 */ this.mouseWhen = e.getWhen(); /* 1257 */ if ((e.getButton() == 1) && /* 1258 */ (!this.mouseActive) && /* 1259 */ ((e.getModifiers() & 0x1) == 0)) { /* 1260 */ ((GammaTextArea)getParent()).selectionStart = -1; /* 1261 */ ((GammaTextArea)getParent()).selectionEnd = -1; /* */ } /* */ } /* */ /* 1265 */ getParent().requestFocus(); /* 1266 */ } else if (e.getID() == 501) { /* 1267 */ if (e.getButton() == 1) { /* 1268 */ if ((e.getModifiers() & 0x1) == 0) { /* 1269 */ if ((((GammaTextArea)getParent()).selectionStart >= 0) && /* 1270 */ (((GammaTextArea)getParent()).selectionEnd > ((GammaTextArea)getParent()).selectionStart)) /* */ { /* 1272 */ ((GammaTextArea)getParent()).selectionStart = -1; /* 1273 */ ((GammaTextArea)getParent()).selectionEnd = -1; /* */ } else { /* 1275 */ this.mouseX = (this.startX = this.endX = e.getX()); /* 1276 */ this.mouseY = (this.startY = this.endY = e.getY()); /* 1277 */ this.mouseActive = true; /* 1278 */ ((GammaTextArea)getParent()).selectionConversion = true; /* */ } /* */ } else { /* 1281 */ this.mouseX = (this.startX = this.endX = e.getX()); /* 1282 */ this.mouseY = (this.startY = this.endY = e.getY()); /* 1283 */ this.mouseActive = true; /* 1284 */ ((GammaTextArea)getParent()).selectionConversion = true; /* */ } /* 1286 */ getParent().repaint(); /* */ } /* 1288 */ getParent().requestFocus(); /* 1289 */ } else if ((this.mouseActive) && ( /* 1290 */ (e.getID() == 506) || /* 1291 */ (e.getID() == 507) || (e.getID() == 507))) { /* 1292 */ if ((e.getModifiers() & 0x10) != 0) { /* 1293 */ this.mouseX = (this.endX = e.getX()); /* 1294 */ this.mouseY = (this.endY = e.getY()); /* */ /* 1296 */ ((GammaTextArea)getParent()).selectionConversion = true; /* 1297 */ getParent().repaint(); /* */ } /* 1299 */ getParent().requestFocus(); /* 1300 */ } else if (e.getID() == 502) { /* 1301 */ if ((e.getButton() == 1) && (this.mouseActive)) { /* 1302 */ this.mouseX = (this.endX = e.getX()); /* 1303 */ this.mouseY = (this.endY = e.getY()); /* 1304 */ this.mouseActive = false; /* */ /* 1306 */ ((GammaTextArea)getParent()).selectionConversion = false; /* 1307 */ getParent().repaint(); /* */ } /* 1309 */ getParent().requestFocus(); /* */ } /* */ /* 1312 */ ((GammaTextArea)getParent()).processMouseEvent(e); /* 1313 */ super.processMouseEvent(e); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ protected void processKeyEvent(KeyEvent e) /* */ { /* 1326 */ synchronized (getParent()) { /* 1327 */ if (e.getID() == 401) { /* 1328 */ Scrollbar s = null; /* 1329 */ if ((getParent() instanceof GammaTextArea)) { /* 1330 */ GammaTextArea gta = (GammaTextArea)getParent(); /* 1331 */ s = gta.getVertScrollbar(); /* */ } /* */ /* 1334 */ if (e.getKeyCode() == 33) { /* 1335 */ if ((s != null) && (s.isEnabled())) /* 1336 */ s.dispatchEvent(e); /* 1337 */ } else if ((e.getKeyCode() == 34) && /* 1338 */ (s != null) && (s.isEnabled())) { /* 1339 */ s.dispatchEvent(e); /* */ } /* */ } /* */ /* 1343 */ super.processKeyEvent(e); /* */ } /* */ } /* */ /* */ public void paint(Graphics g) /* */ { /* 1349 */ if (getParent() != null) { /* 1350 */ synchronized (getParent()) { /* 1351 */ super.paint(g); /* 1352 */ if (getParent().isEnabled()) { /* 1353 */ GammaTextArea gta = (GammaTextArea)getParent(); /* */ /* 1355 */ Rectangle r = getBounds(); /* */ /* 1357 */ if ((r.width <= 0) || (r.height <= 0)) { /* 1358 */ return; /* */ } /* 1360 */ Image offImage = createImage(r.width, r.height); /* 1361 */ Graphics offGraphic = offImage.getGraphics(); /* */ /* 1363 */ offGraphic.setColor(GammaTextArea.getBackgroundColor()); /* 1364 */ offGraphic.setClip(r.x, r.y, r.width, r.height); /* 1365 */ offGraphic.fillRect(r.x, r.y, r.width, r.height); /* 1366 */ offGraphic.setColor(Color.black); /* */ /* 1368 */ if (gta.getHasFocus()) { /* 1369 */ offGraphic.setColor(Color.blue); /* 1370 */ offGraphic.drawRect(r.x, r.y, r.width - 1, r.height - 1); /* 1371 */ offGraphic.drawRect(r.x + 1, r.y + 1, r.width - 2, r.height - 2); /* 1372 */ offGraphic.setColor(Color.black); /* */ } /* */ /* 1375 */ offGraphic.setFont(gta.getFont()); /* 1376 */ FontMetrics fm = offGraphic.getFontMetrics(gta.getFont()); /* */ /* 1378 */ gta._curpos = 0; /* 1379 */ if (gta.getNumLines() <= gta.getCanvasLines()) { /* 1380 */ for (int i = 0; i < gta.getNumLines(); i++) { /* 1381 */ gta.drawLine(offGraphic, i, (i + 1) * fm.getHeight() - fm.getDescent()); /* */ } /* */ } else { /* 1384 */ int i = gta.getScrollLine(); for (int j = 1; i < gta.getNumLines(); j++) { /* 1385 */ gta.drawLine(offGraphic, i, j * fm.getHeight() - fm.getDescent());i++; /* */ } /* */ } /* */ /* 1389 */ g.drawImage(offImage, 0, 0, null); /* */ /* */ /* 1392 */ if (this.delayedMouseEvent != null) { /* 1393 */ processMouseEvent(this.delayedMouseEvent); /* 1394 */ this.delayedMouseEvent = null; /* */ } /* */ } /* */ } /* */ } /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\StyledTextCanvas.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */