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 12class TextChangeEvent { 13protected: 14 TextChangeEvent(); 15 TextChangeEvent(int32 firstChangedParagraph, 16 int32 changedParagraphCount); 17 virtual ~TextChangeEvent(); 18 19public: 20 int32 FirstChangedParagraph() const 21 { return fFirstChangedParagraph; } 22 int32 ChangedParagraphCount() const 23 { return fChangedParagraphCount; } 24 25private: 26 int32 fFirstChangedParagraph; 27 int32 fChangedParagraphCount; 28}; 29 30 31class TextChangingEvent : public TextChangeEvent { 32public: 33 TextChangingEvent(int32 firstChangedParagraph, 34 int32 changedParagraphCount); 35 virtual ~TextChangingEvent(); 36 37 void Cancel(); 38 bool IsCanceled() const 39 { return fIsCanceled; } 40 41private: 42 TextChangingEvent(); 43 44private: 45 bool fIsCanceled; 46}; 47 48 49class TextChangedEvent : public TextChangeEvent { 50public: 51 TextChangedEvent(int32 firstChangedParagraph, 52 int32 changedParagraphCount); 53 virtual ~TextChangedEvent(); 54 55private: 56 TextChangedEvent(); 57}; 58 59 60class TextListener : public BReferenceable { 61public: 62 TextListener(); 63 virtual ~TextListener(); 64 65 virtual void TextChanging(TextChangingEvent& event); 66 67 virtual void TextChanged(const TextChangedEvent& event); 68}; 69 70 71typedef BReference<TextListener> TextListenerRef; 72 73 74#endif // TEXT_LISTENER_H 75