1 /* 2 * Copyright 2006 Haiku, Inc. All Rights Reserved. 3 * Copyright 1997, 1998 R3 Software Ltd. All Rights Reserved. 4 * Distributed under the terms of the MIT License. 5 * 6 * Authors: 7 * Timothy Wayper <timmy@wunderbear.com> 8 * Stephan Aßmus <superstippi@gmx.de> 9 */ 10 11 #ifndef _CALC_VIEW_H 12 #define _CALC_VIEW_H 13 14 #include <View.h> 15 16 class BString; 17 class BMenuItem; 18 class CalcOptions; 19 class CalcOptionsWindow; 20 class ExpressionTextView; 21 22 _EXPORT 23 class CalcView : public BView { 24 public: 25 26 static CalcView* Instantiate(BMessage* archive); 27 28 29 CalcView(BRect frame, 30 rgb_color rgbBaseColor); 31 32 CalcView(BMessage* archive); 33 34 virtual ~CalcView(); 35 36 virtual void AttachedToWindow(); 37 virtual void MessageReceived(BMessage* message); 38 virtual void Draw(BRect updateRect); 39 virtual void MouseDown(BPoint point); 40 virtual void KeyDown(const char* bytes, int32 numBytes); 41 virtual void MakeFocus(bool focused = true); 42 virtual void FrameResized(float width, float height); 43 44 // Present about box for view (replicant). 45 virtual void AboutRequested(); 46 47 // Archive this view. 48 virtual status_t Archive(BMessage* archive, bool deep) const; 49 50 // Cut contents of view to system clipboard. 51 void Cut(); 52 53 // Copy contents of view to system clipboard. 54 void Copy(); 55 56 // Paste contents of system clipboard to view. 57 void Paste(BMessage *message); 58 59 // Load/Save current settings 60 status_t LoadSettings(BMessage* archive); 61 status_t SaveSettings(BMessage* archive) const; 62 63 void Evaluate(); 64 65 void FlashKey(const char* bytes, int32 numBytes); 66 67 void AddExpressionToHistory(const char* expression); 68 void PreviousExpression(); 69 void NextExpression(); 70 71 private: 72 void _ParseCalcDesc(const char* keypadDescription); 73 74 void _PressKey(int key); 75 void _PressKey(const char* label); 76 int32 _KeyForLabel(const char* label) const; 77 void _FlashKey(int32 key); 78 79 void _Colorize(); 80 81 void _CreatePopUpMenu(); 82 83 BRect _ExpressionRect() const; 84 BRect _KeypadRect() const; 85 86 void _ShowKeypad(bool show); 87 void _FetchAppIcon(BBitmap* into); 88 89 // grid dimensions 90 int16 fColums; 91 int16 fRows; 92 93 // color scheme 94 rgb_color fBaseColor; 95 rgb_color fLightColor; 96 rgb_color fDarkColor; 97 rgb_color fButtonTextColor; 98 rgb_color fExpressionBGColor; 99 rgb_color fExpressionTextColor; 100 101 // view dimensions 102 float fWidth; 103 float fHeight; 104 105 // keypad grid 106 struct CalcKey; 107 108 char* fKeypadDescription; 109 CalcKey* fKeypad; 110 111 // icon 112 BBitmap* fCalcIcon; 113 114 // expression 115 ExpressionTextView* fExpressionTextView; 116 117 // pop-up context menu. 118 BMenuItem* fAboutItem; 119 BMenuItem* fOptionsItem; 120 BPopUpMenu* fPopUpMenu; 121 122 // calculator options. 123 CalcOptions* fOptions; 124 CalcOptionsWindow* fOptionsWindow; 125 BRect fOptionsWindowFrame; 126 bool fShowKeypad; 127 }; 128 129 #endif // _CALC_VIEW_H 130