1 /* 2 * Copyright 2015, Rene Gollent, rene@gollent.com. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef TABLE_CELL_VALUE_EDITOR_H 6 #define TABLE_CELL_VALUE_EDITOR_H 7 8 #include <Referenceable.h> 9 10 #include <util/DoublyLinkedList.h> 11 12 13 class BView; 14 class Value; 15 16 17 class TableCellValueEditor : public BReferenceable { 18 public: 19 class Listener; 20 TableCellValueEditor(); 21 virtual ~TableCellValueEditor(); 22 23 void AddListener(Listener* listener); 24 void RemoveListener(Listener* listener); 25 26 inline Value* InitialValue() const { return fInitialValue; } 27 void SetInitialValue(Value* value); 28 29 virtual BView* GetView() = 0; 30 31 protected: 32 void NotifyEditBeginning(); 33 void NotifyEditCancelled(); 34 void NotifyEditCompleted(Value* newValue); 35 36 private: 37 typedef DoublyLinkedList<Listener> ListenerList; 38 39 private: 40 ListenerList fListeners; 41 Value* fInitialValue; 42 }; 43 44 45 class TableCellValueEditor::Listener : public 46 DoublyLinkedListLinkImpl<TableCellValueEditor::Listener> { 47 public: 48 virtual ~Listener(); 49 50 virtual void TableCellEditBeginning(); 51 virtual void TableCellEditCancelled(); 52 virtual void TableCellEditEnded(Value* newValue); 53 }; 54 55 #endif // TABLE_CELL_VALUE_EDITOR_H 56