1 /* 2 * Copyright 2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 9 #ifndef NUMMERICAL_TEXT_VIEW_H 10 #define NUMMERICAL_TEXT_VIEW_H 11 12 #include "InputTextView.h" 13 14 class NummericalTextView : public InputTextView { 15 public: 16 NummericalTextView(BRect frame, 17 const char* name, 18 BRect textRect, 19 uint32 resizingMode, 20 uint32 flags); 21 virtual ~NummericalTextView(); 22 23 // BInvoker interface 24 virtual status_t Invoke(BMessage* message = NULL); 25 26 // InputTextView interface 27 virtual void RevertChanges(); 28 virtual void ApplyChanges(); 29 30 // NummericalTextView 31 void SetFloatMode(bool floatingPoint); 32 33 void SetValue(int32 value); 34 void SetValue(float value); 35 int32 IntValue() const; 36 float FloatValue() const; 37 38 protected: 39 // BTextView 40 virtual void Select(int32 start, int32 finish); 41 42 virtual void InsertText(const char* inText, 43 int32 inLength, 44 int32 inOffset, 45 const text_run_array* inRuns); 46 virtual void DeleteText(int32 fromOffset, 47 int32 toOffset); 48 49 // NummericalTextView 50 void _ToggleAllowChar(char c); 51 void _CheckMinusAllowed(); 52 void _CheckDotAllowed(); 53 54 bool fFloatMode; 55 56 mutable int32 fIntValueCache; 57 mutable float fFloatValueCache; 58 }; 59 60 #endif // NUMMERICAL_TEXT_VIEW_H 61 62 63