1 /* 2 * Copyright 2015, Axel Dörfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef ADDRESS_TEXT_CONTROL_H 6 #define ADDRESS_TEXT_CONTROL_H 7 8 9 #include <Control.h> 10 11 12 class BButton; 13 class BPopUpMenu; 14 class BTextView; 15 16 17 class AddressTextControl : public BControl { 18 public: 19 AddressTextControl(const char* name, 20 BMessage* message); 21 virtual ~AddressTextControl(); 22 23 virtual void AttachedToWindow(); 24 virtual void WindowActivated(bool active); 25 virtual void Draw(BRect updateRect); 26 virtual void MakeFocus(bool focus = true); 27 virtual void SetEnabled(bool enabled); 28 virtual void MessageReceived(BMessage* message); 29 30 const BMessage* ModificationMessage() const; 31 void SetModificationMessage(BMessage* message); 32 33 bool IsEditable() const; 34 void SetEditable(bool editable); 35 36 void SetText(const char* text); 37 const char* Text() const; 38 int32 TextLength() const; 39 void GetSelection(int32* start, int32* end) const; 40 void Select(int32 start, int32 end); 41 void SelectAll(); 42 43 bool HasFocus(); 44 45 private: 46 void _AddAddress(const char* text); 47 void _UpdateTextViewColors(); 48 49 private: 50 class TextView; 51 class PopUpButton; 52 53 TextView* fTextView; 54 PopUpButton* fPopUpButton; 55 BPopUpMenu* fRefDropMenu; 56 bool fWindowActive; 57 bool fEditable; 58 }; 59 60 61 #endif // ADDRESS_TEXT_CONTROL_H 62 63