1 11 package org.eclipse.swt.custom; 12 13 import org.eclipse.swt.events.*; 14 import org.eclipse.swt.widgets.*; 15 import org.eclipse.swt.internal.SWTEventListener; 16 17 class StyledTextListener extends TypedListener { 18 20 StyledTextListener(SWTEventListener listener) { 21 super(listener); 22 } 23 26 public void handleEvent(Event e) { 27 28 switch (e.type) { 29 case StyledText.ExtendedModify: 30 ExtendedModifyEvent extendedModifyEvent = new ExtendedModifyEvent((StyledTextEvent) e); 31 ((ExtendedModifyListener) eventListener).modifyText(extendedModifyEvent); 32 break; 33 case StyledText.LineGetBackground: 34 LineBackgroundEvent lineBgEvent = new LineBackgroundEvent((StyledTextEvent) e); 35 ((LineBackgroundListener) eventListener).lineGetBackground(lineBgEvent); 36 ((StyledTextEvent) e).lineBackground = lineBgEvent.lineBackground; 37 break; 38 case StyledText.LineGetSegments: 39 BidiSegmentEvent segmentEvent = new BidiSegmentEvent((StyledTextEvent) e); 40 ((BidiSegmentListener) eventListener).lineGetSegments(segmentEvent); 41 ((StyledTextEvent) e).segments = segmentEvent.segments; 42 break; 43 case StyledText.LineGetStyle: 44 LineStyleEvent lineStyleEvent = new LineStyleEvent((StyledTextEvent) e); 45 ((LineStyleListener) eventListener).lineGetStyle(lineStyleEvent); 46 ((StyledTextEvent) e).ranges = lineStyleEvent.ranges; 47 ((StyledTextEvent) e).styles = lineStyleEvent.styles; 48 ((StyledTextEvent) e).alignment = lineStyleEvent.alignment; 49 ((StyledTextEvent) e).indent = lineStyleEvent.indent; 50 ((StyledTextEvent) e).justify = lineStyleEvent.justify; 51 ((StyledTextEvent) e).bullet = lineStyleEvent.bullet; 52 ((StyledTextEvent) e).bulletIndex = lineStyleEvent.bulletIndex; 53 break; 54 case StyledText.PaintObject: 55 PaintObjectEvent paintObjectEvent = new PaintObjectEvent((StyledTextEvent) e); 56 ((PaintObjectListener) eventListener).paintObject(paintObjectEvent); 57 break; 58 case StyledText.VerifyKey: 59 VerifyEvent verifyEvent = new VerifyEvent(e); 60 ((VerifyKeyListener) eventListener).verifyKey(verifyEvent); 61 e.doit = verifyEvent.doit; 62 break; 63 case StyledText.TextChanged: { 64 TextChangedEvent textChangedEvent = new TextChangedEvent((StyledTextContent) e.data); 65 ((TextChangeListener) eventListener).textChanged(textChangedEvent); 66 break; 67 } 68 case StyledText.TextChanging: 69 TextChangingEvent textChangingEvent = new TextChangingEvent((StyledTextContent) e.data, (StyledTextEvent) e); 70 ((TextChangeListener) eventListener).textChanging(textChangingEvent); 71 break; 72 case StyledText.TextSet: { 73 TextChangedEvent textChangedEvent = new TextChangedEvent((StyledTextContent) e.data); 74 ((TextChangeListener) eventListener).textSet(textChangedEvent); 75 break; 76 } 77 case StyledText.WordNext: { 78 MovementEvent wordBoundaryEvent = new MovementEvent((StyledTextEvent) e); 79 ((MovementListener) eventListener).getNextOffset(wordBoundaryEvent); 80 ((StyledTextEvent) e).end = wordBoundaryEvent.newOffset; 81 break; 82 } 83 case StyledText.WordPrevious: { 84 MovementEvent wordBoundaryEvent = new MovementEvent((StyledTextEvent) e); 85 ((MovementListener) eventListener).getPreviousOffset(wordBoundaryEvent); 86 ((StyledTextEvent) e).end = wordBoundaryEvent.newOffset; 87 break; 88 } 89 } 90 } 91 } 92 93 94 | Popular Tags |