1 /* 2 * Copyright 2014, Stephan Aßmus <superstippi@gmx.de>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef TEXT_LISTENER_H 6 #define TEXT_LISTENER_H 7 8 9 #include <Referenceable.h> 10 11 12 class TextChangeEvent { 13 protected: 14 TextChangeEvent(); 15 TextChangeEvent(int32 firstChangedParagraph, 16 int32 changedParagraphCount); 17 virtual ~TextChangeEvent(); 18 19 public: FirstChangedParagraph()20 int32 FirstChangedParagraph() const 21 { return fFirstChangedParagraph; } ChangedParagraphCount()22 int32 ChangedParagraphCount() const 23 { return fChangedParagraphCount; } 24 25 private: 26 int32 fFirstChangedParagraph; 27 int32 fChangedParagraphCount; 28 }; 29 30 31 class TextChangingEvent : public TextChangeEvent { 32 public: 33 TextChangingEvent(int32 firstChangedParagraph, 34 int32 changedParagraphCount); 35 virtual ~TextChangingEvent(); 36 37 void Cancel(); IsCanceled()38 bool IsCanceled() const 39 { return fIsCanceled; } 40 41 private: 42 TextChangingEvent(); 43 44 private: 45 bool fIsCanceled; 46 }; 47 48 49 class TextChangedEvent : public TextChangeEvent { 50 public: 51 TextChangedEvent(int32 firstChangedParagraph, 52 int32 changedParagraphCount); 53 virtual ~TextChangedEvent(); 54 55 private: 56 TextChangedEvent(); 57 }; 58 59 60 class TextListener : public BReferenceable { 61 public: 62 TextListener(); 63 virtual ~TextListener(); 64 65 virtual void TextChanging(TextChangingEvent& event); 66 67 virtual void TextChanged(const TextChangedEvent& event); 68 }; 69 70 71 typedef BReference<TextListener> TextListenerRef; 72 73 74 #endif // TEXT_LISTENER_H 75