* Repurposed the calculator icon. The icon only shows when the keypad is hidden,

so someone using it to trigger evaluation is highly unlikely, since he can
  just press return/enter. But when DeskCalc is embedded into the Desktop, it
  is convenient to clear the text view. (Clicking anywhere in DeskCalc already
  gives the text view focus.)
* Automatic whitespace cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30697 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-05-10 11:26:03 +00:00
parent 1c0f89a7fd
commit b4dce77e73
+16 -6
View File
@@ -502,8 +502,11 @@ void
CalcView::MouseDown(BPoint point) CalcView::MouseDown(BPoint point)
{ {
// ensure this view is the current focus // ensure this view is the current focus
if (!IsFocus()) if (!fExpressionTextView->IsFocus()) {
// Call our version of MakeFocus(), since that will also apply the
// num_lock setting.
MakeFocus(); MakeFocus();
}
// read mouse buttons state // read mouse buttons state
int32 buttons = 0; int32 buttons = 0;
@@ -513,8 +516,9 @@ CalcView::MouseDown(BPoint point)
if ((B_PRIMARY_MOUSE_BUTTON & buttons) == 0) { if ((B_PRIMARY_MOUSE_BUTTON & buttons) == 0) {
BMenuItem* selected; BMenuItem* selected;
if ((selected = fPopUpMenu->Go(ConvertToScreen(point))) != NULL if ((selected = fPopUpMenu->Go(ConvertToScreen(point))) != NULL
&& selected->Message() != NULL) && selected->Message() != NULL) {
MessageReceived(selected->Message()); Window()->PostMessage(selected->Message(), this);
}
return; return;
} }
@@ -524,7 +528,7 @@ CalcView::MouseDown(BPoint point)
bounds.left = bounds.right - fCalcIcon->Bounds().Width(); bounds.left = bounds.right - fCalcIcon->Bounds().Width();
if (bounds.Contains(point)) { if (bounds.Contains(point)) {
// user clicked on calculator icon // user clicked on calculator icon
fExpressionTextView->ApplyChanges(); fExpressionTextView->Clear();
} }
} }
return; return;
@@ -557,6 +561,9 @@ CalcView::MouseDown(BPoint point)
void void
CalcView::MouseUp(BPoint point) CalcView::MouseUp(BPoint point)
{ {
if (!fShowKeypad)
return;
int keys = fRows * fColums; int keys = fRows * fColums;
for (int i = 0; i < keys; i++) { for (int i = 0; i < keys; i++) {
if (fKeypad[i].flags & FLAGS_MOUSE_DOWN) { if (fKeypad[i].flags & FLAGS_MOUSE_DOWN) {
@@ -628,8 +635,8 @@ CalcView::MakeFocus(bool focused)
if (focused) { if (focused) {
// set num lock // set num lock
if (fOptions->auto_num_lock) { if (fOptions->auto_num_lock) {
set_keyboard_locks(B_NUM_LOCK | set_keyboard_locks(B_NUM_LOCK
(modifiers() & (B_CAPS_LOCK | B_SCROLL_LOCK))); | (modifiers() & (B_CAPS_LOCK | B_SCROLL_LOCK)));
} }
} }
@@ -1026,6 +1033,9 @@ CalcView::_KeyForLabel(const char *label) const
void void
CalcView::_FlashKey(int32 key, uint32 flashFlags) CalcView::_FlashKey(int32 key, uint32 flashFlags)
{ {
if (!fShowKeypad)
return;
if (flashFlags != 0) if (flashFlags != 0)
fKeypad[key].flags |= flashFlags; fKeypad[key].flags |= flashFlags;
else else