[haiku-commits] haiku: hrev45852 - in src: apps/deskcalc kits/shared

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 13 Jul 2013 04:43:35 +0200 (CEST)

hrev45852 adds 9 changesets to branch 'master'
old head: 8f9c2223a391cf7b3ff91ca5cc031a0656852c78
new head: 747612e39033209fdca054fe2be0f1f086ec425a
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=747612e+%5E8f9c222

----------------------------------------------------------------------------

b98de09: DeskCalc: Update copyright headers
  
  Style fixes to header, update copyright years, remove my name
  from files that I didn't have anything to do with besides style fixes,
  add myself to ExpressionTextView.cpp

29fbfe3: DeskCalc: Style fixes

ed7d3e2: DeskCalc: Remove pre-ControlLook drawing code

d2577d7: DeskCalc: Remove ResizeTo()

43f09ad: DeskCalc: Add private _IsEmbedded() method

fbc8aea: DeskCalc: Replace comment with equivalent code

49620f7: DeskCalc: Preserve selection on resize

786b0f8: DeskCalc: Resize a bit more efficiently.
  
  Remove B_FULL_UPDATE_ON_RESIZE flag from view.
  
  We already Invalidate() on FrameResized() which redraws the
  view on resize for us. This reduces the number of times Draw() is called
  from 3+ in some cases to just one. Unfortunately Draw() is still called
  multiple times in some cases producing noticable flickering and drawing
  artifacts but it is marginally better.

747612e: ExpressionParser: Simplify pi detection

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

----------------------------------------------------------------------------

13 files changed, 131 insertions(+), 218 deletions(-)
src/apps/deskcalc/CalcApplication.cpp    |   6 +-
src/apps/deskcalc/CalcApplication.h      |   5 +-
src/apps/deskcalc/CalcOptions.cpp        |   6 +-
src/apps/deskcalc/CalcOptions.h          |   6 +-
src/apps/deskcalc/CalcView.cpp           | 267 +++++++++------------------
src/apps/deskcalc/CalcView.h             |  11 +-
src/apps/deskcalc/CalcWindow.cpp         |   8 +-
src/apps/deskcalc/CalcWindow.h           |   5 +-
src/apps/deskcalc/ExpressionTextView.cpp |  14 +-
src/apps/deskcalc/ExpressionTextView.h   |   2 +-
src/apps/deskcalc/InputTextView.cpp      |   2 +-
src/apps/deskcalc/InputTextView.h        |   2 +-
src/kits/shared/ExpressionParser.cpp     |  15 +-

############################################################################

Commit:      b98de092d8e0609615f4509c84498bb7df207f50
URL:         http://cgit.haiku-os.org/haiku/commit/?id=b98de09
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Jun 28 01:46:01 2013 UTC

DeskCalc: Update copyright headers

Style fixes to header, update copyright years, remove my name
from files that I didn't have anything to do with besides style fixes,
add myself to ExpressionTextView.cpp

----------------------------------------------------------------------------

diff --git a/src/apps/deskcalc/CalcApplication.cpp 
b/src/apps/deskcalc/CalcApplication.cpp
index 9c6d4c0..23d8f2a 100644
--- a/src/apps/deskcalc/CalcApplication.cpp
+++ b/src/apps/deskcalc/CalcApplication.cpp
@@ -4,9 +4,9 @@
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
- *             John Scipione <jscipione@xxxxxxxxx>
- *             Timothy Wayper <timmy@xxxxxxxxxxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
+ *             John Scipione, jscipione@xxxxxxxxx
+ *             Timothy Wayper, timmy@xxxxxxxxxxxxxx
  */
 
 
diff --git a/src/apps/deskcalc/CalcApplication.h 
b/src/apps/deskcalc/CalcApplication.h
index d66f4be..b16f88e 100644
--- a/src/apps/deskcalc/CalcApplication.h
+++ b/src/apps/deskcalc/CalcApplication.h
@@ -4,9 +4,8 @@
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
- *             John Scipione <jscipione@xxxxxxxxx>
- *             Timothy Wayper <timmy@xxxxxxxxxxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
+ *             Timothy Wayper, timmy@xxxxxxxxxxxxxx
  */
 #ifndef _CALC_APPLICATION_H
 #define _CALC_APPLICATION_H
diff --git a/src/apps/deskcalc/CalcOptions.cpp 
b/src/apps/deskcalc/CalcOptions.cpp
index c53adc4..1c93e30 100644
--- a/src/apps/deskcalc/CalcOptions.cpp
+++ b/src/apps/deskcalc/CalcOptions.cpp
@@ -4,9 +4,9 @@
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
- *             John Scipione <jscipione@xxxxxxxxx>
- *             Timothy Wayper <timmy@xxxxxxxxxxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
+ *             John Scipione, jscipione@xxxxxxxxx
+ *             Timothy Wayper, timmy@xxxxxxxxxxxxxx
  */
 
 
diff --git a/src/apps/deskcalc/CalcOptions.h b/src/apps/deskcalc/CalcOptions.h
index 186197b..135d4a1 100644
--- a/src/apps/deskcalc/CalcOptions.h
+++ b/src/apps/deskcalc/CalcOptions.h
@@ -4,9 +4,9 @@
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
- *             John Scipione <jscipione@xxxxxxxxx>
- *             Timothy Wayper <timmy@xxxxxxxxxxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
+ *             John Scipione, jscipione@xxxxxxxxx
+ *             Timothy Wayper, timmy@xxxxxxxxxxxxxx
  */
 #ifndef CALC_OPTIONS_H
 #define CALC_OPTIONS_H
diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp
index 0f20cff..c597bcd 100644
--- a/src/apps/deskcalc/CalcView.cpp
+++ b/src/apps/deskcalc/CalcView.cpp
@@ -1,13 +1,13 @@
 /*
- * Copyright 2006-2012, Haiku, Inc. All rights reserved.
+ * Copyright 2006-2013, Haiku, Inc. All rights reserved.
  * Copyright 1997, 1998 R3 Software Ltd. All Rights Reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
- *             Philippe Saint-Pierre <stpere@xxxxxxxxx>
- *             John Scipione <jscipione@xxxxxxxxx>
- *             Timothy Wayper <timmy@xxxxxxxxxxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
+ *             Philippe Saint-Pierre, stpere@xxxxxxxxx
+ *             John Scipione, jscipione@xxxxxxxxx
+ *             Timothy Wayper, timmy@xxxxxxxxxxxxxx
  */
 
 
diff --git a/src/apps/deskcalc/CalcView.h b/src/apps/deskcalc/CalcView.h
index 1dd1cff..309564e 100644
--- a/src/apps/deskcalc/CalcView.h
+++ b/src/apps/deskcalc/CalcView.h
@@ -1,12 +1,13 @@
 /*
- * Copyright 2006 Haiku, Inc. All Rights Reserved.
+ * Copyright 2006-2013, Haiku, Inc. All rights reserved.
  * Copyright 1997, 1998 R3 Software Ltd. All Rights Reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
- *             John Scipione <jscipione@xxxxxxxxx>
- *             Timothy Wayper <timmy@xxxxxxxxxxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
+ *             Philippe Saint-Pierre, stpere@xxxxxxxxx
+ *             John Scipione, jscipione@xxxxxxxxx
+ *             Timothy Wayper, timmy@xxxxxxxxxxxxxx
  */
 #ifndef _CALC_VIEW_H
 #define _CALC_VIEW_H
diff --git a/src/apps/deskcalc/CalcWindow.cpp b/src/apps/deskcalc/CalcWindow.cpp
index ae6e337..3f35c35 100644
--- a/src/apps/deskcalc/CalcWindow.cpp
+++ b/src/apps/deskcalc/CalcWindow.cpp
@@ -4,9 +4,9 @@
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
- *             John Scipione <jscipione@xxxxxxxxx>
- *             Timothy Wayper <timmy@xxxxxxxxxxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
+ *             John Scipione, jscipione@xxxxxxxxx
+ *             Timothy Wayper, timmy@xxxxxxxxxxxxxx
  */
 
 
diff --git a/src/apps/deskcalc/CalcWindow.h b/src/apps/deskcalc/CalcWindow.h
index 5e6b16c..a62cd49 100644
--- a/src/apps/deskcalc/CalcWindow.h
+++ b/src/apps/deskcalc/CalcWindow.h
@@ -4,9 +4,8 @@
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
- *             John Scipione <jscipione@xxxxxxxxx>
- *             Timothy Wayper <timmy@xxxxxxxxxxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
+ *             Timothy Wayper, timmy@xxxxxxxxxxxxxx
  */
 #ifndef _CALC_WINDOW_H
 #define _CALC_WINDOW_H
diff --git a/src/apps/deskcalc/ExpressionTextView.cpp 
b/src/apps/deskcalc/ExpressionTextView.cpp
index 4f8d3d3..f64b8c8 100644
--- a/src/apps/deskcalc/ExpressionTextView.cpp
+++ b/src/apps/deskcalc/ExpressionTextView.cpp
@@ -1,9 +1,10 @@
 /*
- * Copyright 2006-2011 Haiku, Inc. All Rights Reserved.
+ * Copyright 2006-2013 Haiku, Inc. All Rights Reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
+ *             John Scipione, jscipione@xxxxxxxxx
  */
 
 
diff --git a/src/apps/deskcalc/ExpressionTextView.h 
b/src/apps/deskcalc/ExpressionTextView.h
index 0a37fcf..0030a92 100644
--- a/src/apps/deskcalc/ExpressionTextView.h
+++ b/src/apps/deskcalc/ExpressionTextView.h
@@ -3,7 +3,7 @@
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
  */
 #ifndef EXPRESSION_TEXT_VIEW_H
 #define EXPRESSION_TEXT_VIEW_H
diff --git a/src/apps/deskcalc/InputTextView.cpp 
b/src/apps/deskcalc/InputTextView.cpp
index 92be1e4..9bd60a2 100644
--- a/src/apps/deskcalc/InputTextView.cpp
+++ b/src/apps/deskcalc/InputTextView.cpp
@@ -3,7 +3,7 @@
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
  */
 
 
diff --git a/src/apps/deskcalc/InputTextView.h 
b/src/apps/deskcalc/InputTextView.h
index acf173b..0667522 100644
--- a/src/apps/deskcalc/InputTextView.h
+++ b/src/apps/deskcalc/InputTextView.h
@@ -3,7 +3,7 @@
  * Distributed under the terms of the MIT License.
  *
  * Authors:
- *             Stephan Aßmus <superstippi@xxxxxx>
+ *             Stephan Aßmus, superstippi@xxxxxx
  */
 #ifndef INPUT_TEXT_VIEW_H
 #define INPUT_TEXT_VIEW_H

############################################################################

Commit:      29fbfe311067dbe6606afde7043b98a1234cef12
URL:         http://cgit.haiku-os.org/haiku/commit/?id=29fbfe3
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Jun 28 04:26:08 2013 UTC

DeskCalc: Style fixes

----------------------------------------------------------------------------

diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp
index c597bcd..d2eecdd 100644
--- a/src/apps/deskcalc/CalcView.cpp
+++ b/src/apps/deskcalc/CalcView.cpp
@@ -45,9 +45,11 @@
 #include "CalcOptions.h"
 #include "ExpressionTextView.h"
 
+
 #undef B_TRANSLATION_CONTEXT
 #define B_TRANSLATION_CONTEXT "CalcView"
 
+
 //const uint8 K_COLOR_OFFSET                           = 32;
 const float kFontScaleY                                                = 0.4f;
 const float kFontScaleX                                                = 0.4f;
@@ -87,11 +89,13 @@ const char *kKeypadDescriptionScientific =
     "1     2     3     +     -    \n"
     "0     .     BS    =     C    \n";
 
+
 enum {
        FLAGS_FLASH_KEY                                                 = 1 << 
0,
        FLAGS_MOUSE_DOWN                                                = 1 << 1
 };
 
+
 struct CalcView::CalcKey {
        char            label[8];
        char            code[8];
@@ -684,27 +688,27 @@ CalcView::FrameResized(float width, float height)
        fHeight = height;
 
        // layout expression text view
-       BRect frame = _ExpressionRect();
+       BRect expressionRect = _ExpressionRect();
        if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT) {
-               frame.InsetBy(2, 2);
-               frame.right -= ceilf(fCalcIcon->Bounds().Width() * 1.5);
+               expressionRect.InsetBy(2, 2);
+               expressionRect.right -= ceilf(fCalcIcon->Bounds().Width() * 
1.5);
        } else
-               frame.InsetBy(4, 4);
+               expressionRect.InsetBy(4, 4);
 
-       fExpressionTextView->MoveTo(frame.LeftTop());
-       fExpressionTextView->ResizeTo(frame.Width(), frame.Height());
+       fExpressionTextView->MoveTo(expressionRect.LeftTop());
+       fExpressionTextView->ResizeTo(expressionRect.Width(), 
expressionRect.Height());
 
        // configure expression text view font size and color
        float sizeDisp = fOptions->keypad_mode == KEYPAD_MODE_COMPACT
-                                        ? fHeight : fHeight * kDisplayScaleY;
+               ? fHeight : fHeight * kDisplayScaleY;
        BFont font(be_bold_font);
        font.SetSize(sizeDisp * kExpressionFontScaleY);
        fExpressionTextView->SetFontAndColor(&font, B_FONT_ALL);
 
-       frame.OffsetTo(B_ORIGIN);
-       float inset = (frame.Height() - fExpressionTextView->LineHeight(0)) / 2;
-       frame.InsetBy(0, inset);
-       fExpressionTextView->SetTextRect(frame);
+       expressionRect.OffsetTo(B_ORIGIN);
+       float inset = (expressionRect.Height() - 
fExpressionTextView->LineHeight(0)) / 2;
+       expressionRect.InsetBy(0, inset);
+       fExpressionTextView->SetTextRect(expressionRect);
        Invalidate();
 }
 
@@ -929,12 +933,12 @@ CalcView::SetKeypadMode(uint8 mode)
                {
                        if (window->Bounds() == Frame()) {
                                window->SetSizeLimits(kMinimumWidthCompact,
-                                                                         
kMaximumWidthCompact,
-                                                                         
kMinimumHeightCompact,
-                                                                         
kMaximumHeightCompact);
+                                       kMaximumWidthCompact, 
kMinimumHeightCompact,
+                                       kMaximumHeightCompact);
                                window->ResizeTo(width, height * 
kDisplayScaleY);
                        } else
                                ResizeTo(width, height * kDisplayScaleY);
+
                        break;
                }
 
@@ -946,13 +950,14 @@ CalcView::SetKeypadMode(uint8 mode)
                        _ParseCalcDesc(fKeypadDescription);
 
                        window->SetSizeLimits(kMinimumWidthScientific,
-                                                                 
kMaximumWidthScientific,
-                                                                 
kMinimumHeightScientific,
-                                                                 
kMaximumHeightScientific);
+                               kMaximumWidthScientific, 
kMinimumHeightScientific,
+                               kMaximumHeightScientific);
+
                        if (width < kMinimumWidthScientific)
                                width = kMinimumWidthScientific;
                        if (width > kMaximumWidthScientific)
                                width = kMaximumWidthScientific;
+
                        if (height < kMinimumHeightScientific)
                                height = kMinimumHeightScientific;
                        if (height > kMaximumHeightScientific)
@@ -969,11 +974,13 @@ CalcView::SetKeypadMode(uint8 mode)
                        _ParseCalcDesc(fKeypadDescription);
 
                        window->SetSizeLimits(kMinimumWidthBasic, 
kMaximumWidthBasic,
-                                                                 
kMinimumHeightBasic, kMaximumHeightBasic);
+                               kMinimumHeightBasic, kMaximumHeightBasic);
+
                        if (width < kMinimumWidthBasic)
                                width = kMinimumWidthBasic;
                        if (width > kMaximumWidthBasic)
                                width = kMaximumWidthBasic;
+
                        if (height < kMinimumHeightBasic)
                                height = kMinimumHeightBasic;
                        if (height > kMaximumHeightBasic)
diff --git a/src/apps/deskcalc/CalcWindow.cpp b/src/apps/deskcalc/CalcWindow.cpp
index 3f35c35..97212bf 100644
--- a/src/apps/deskcalc/CalcWindow.cpp
+++ b/src/apps/deskcalc/CalcWindow.cpp
@@ -42,7 +42,7 @@ CalcWindow::CalcWindow(BRect frame, BMessage* settings)
 
        // Size Limits are defined in CalcView.h
        SetSizeLimits(kMinimumWidthBasic, kMaximumWidthBasic,
-                                 kMinimumHeightBasic, kMaximumHeightBasic);
+               kMinimumHeightBasic, kMaximumHeightBasic);
 
        frame.OffsetTo(B_ORIGIN);
        fCalcView = new CalcView(frame, baseColor, settings);
diff --git a/src/apps/deskcalc/ExpressionTextView.cpp 
b/src/apps/deskcalc/ExpressionTextView.cpp
index f64b8c8..5dcbc57 100644
--- a/src/apps/deskcalc/ExpressionTextView.cpp
+++ b/src/apps/deskcalc/ExpressionTextView.cpp
@@ -401,7 +401,7 @@ ExpressionTextView::PreviousExpression()
        }
 
        BString* item = (BString*)fPreviousExpressions.ItemAt(fHistoryPos);
-       if (item)
+       if (item != NULL)
                SetExpression(item->String());
 }
 

############################################################################

Commit:      ed7d3e22f9e7a0c57bc1b41846ae873a46994348
URL:         http://cgit.haiku-os.org/haiku/commit/?id=ed7d3e2
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Jun 28 04:26:54 2013 UTC

DeskCalc: Remove pre-ControlLook drawing code

----------------------------------------------------------------------------

diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp
index d2eecdd..c41b63f 100644
--- a/src/apps/deskcalc/CalcView.cpp
+++ b/src/apps/deskcalc/CalcView.cpp
@@ -362,47 +362,11 @@ CalcView::Draw(BRect updateRect)
                        expressionRect.InsetBy(1, 1);
                }
 
-               if (be_control_look != NULL) {
-                       uint32 flags = 0;
-                       if (!drawBackground)
-                               flags |= BControlLook::B_BLEND_FRAME;
-                       be_control_look->DrawTextControlBorder(this, 
expressionRect,
-                               updateRect, fBaseColor, flags);
-               } else {
-                       BeginLineArray(8);
-
-                       rgb_color lightShadow = tint_color(fBaseColor, 
B_DARKEN_1_TINT);
-                       rgb_color darkShadow = tint_color(fBaseColor, 
B_DARKEN_3_TINT);
-
-                       AddLine(BPoint(expressionRect.left, 
expressionRect.bottom),
-                                       BPoint(expressionRect.left, 
expressionRect.top),
-                                       lightShadow);
-                       AddLine(BPoint(expressionRect.left + 1, 
expressionRect.top),
-                                       BPoint(expressionRect.right, 
expressionRect.top),
-                                       lightShadow);
-                       AddLine(BPoint(expressionRect.right, expressionRect.top 
+ 1),
-                                       BPoint(expressionRect.right, 
expressionRect.bottom),
-                                       fLightColor);
-                       AddLine(BPoint(expressionRect.left + 1, 
expressionRect.bottom),
-                                       BPoint(expressionRect.right - 1, 
expressionRect.bottom),
-                                       fLightColor);
-
-                       expressionRect.InsetBy(1, 1);
-                       AddLine(BPoint(expressionRect.left, 
expressionRect.bottom),
-                                       BPoint(expressionRect.left, 
expressionRect.top),
-                                       darkShadow);
-                       AddLine(BPoint(expressionRect.left + 1, 
expressionRect.top),
-                                       BPoint(expressionRect.right, 
expressionRect.top),
-                                       darkShadow);
-                       AddLine(BPoint(expressionRect.right, expressionRect.top 
+ 1),
-                                       BPoint(expressionRect.right, 
expressionRect.bottom),
-                                       fBaseColor);
-                       AddLine(BPoint(expressionRect.left + 1, 
expressionRect.bottom),
-                                       BPoint(expressionRect.right - 1, 
expressionRect.bottom),
-                                       fBaseColor);
-
-                       EndLineArray();
-               }
+               uint32 flags = 0;
+               if (!drawBackground)
+                       flags |= BControlLook::B_BLEND_FRAME;
+               be_control_look->DrawTextControlBorder(this, expressionRect,
+                       updateRect, fBaseColor, flags);
        }
 
        if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT)
@@ -426,101 +390,38 @@ CalcView::Draw(BRect updateRect)
 
        SetFontSize(min_c(sizeRow * kFontScaleY, sizeCol * kFontScaleX));
 
-       if (be_control_look != NULL) {
-               CalcKey* key = fKeypad;
-               for (int row = 0; row < fRows; row++) {
-                       for (int col = 0; col < fColumns; col++) {
-                               BRect frame;
-                               frame.left = keypadRect.left + col * sizeCol;
-                               frame.right = keypadRect.left + (col + 1) * 
sizeCol - 1;
-                               frame.top = sizeDisp + row * sizeRow;
-                               frame.bottom = sizeDisp + (row + 1) * sizeRow - 
1;
-
-                               if (drawBackground) {
-                                       SetHighColor(fBaseColor);
-                                       StrokeRect(frame);
-                               }
-                               frame.InsetBy(1, 1);
-
-                               uint32 flags = 0;
-                               if (!drawBackground)
-                                       flags |= BControlLook::B_BLEND_FRAME;
-                               if (key->flags != 0)
-                                       flags |= BControlLook::B_ACTIVATED;
-                               flags |= BControlLook::B_IGNORE_OUTLINE;
-
-                               be_control_look->DrawButtonFrame(this, frame, 
updateRect,
-                                       fBaseColor, fBaseColor, flags);
-
-                               be_control_look->DrawButtonBackground(this, 
frame, updateRect,
-                                       fBaseColor, flags);
-
-                               be_control_look->DrawLabel(this, key->label, 
frame, updateRect,
-                                       fBaseColor, flags, 
BAlignment(B_ALIGN_HORIZONTAL_CENTER,
-                                               B_ALIGN_VERTICAL_CENTER));
+       CalcKey* key = fKeypad;
+       for (int row = 0; row < fRows; row++) {
+               for (int col = 0; col < fColumns; col++) {
+                       BRect frame;
+                       frame.left = keypadRect.left + col * sizeCol;
+                       frame.right = keypadRect.left + (col + 1) * sizeCol - 1;
+                       frame.top = sizeDisp + row * sizeRow;
+                       frame.bottom = sizeDisp + (row + 1) * sizeRow - 1;
 
-                               key++;
+                       if (drawBackground) {
+                               SetHighColor(fBaseColor);
+                               StrokeRect(frame);
                        }
-               }
-               return;
-       }
-
-       // TODO: support pressed keys
+                       frame.InsetBy(1, 1);
 
-       // paint keypad b/g
-       SetHighColor(fBaseColor);
-       FillRect(updateRect & keypadRect);
-
-       // render key main grid
-       BeginLineArray(((fColumns + fRows) << 1) + 1);
-
-       // render cols
-       AddLine(BPoint(0.0, sizeDisp),
-                       BPoint(0.0, fHeight),
-                       fLightColor);
-       for (int col = 1; col < fColumns; col++) {
-               AddLine(BPoint(col * sizeCol - 1.0, sizeDisp),
-                               BPoint(col * sizeCol - 1.0, fHeight),
-                               fDarkColor);
-               AddLine(BPoint(col * sizeCol, sizeDisp),
-                               BPoint(col * sizeCol, fHeight),
-                               fLightColor);
-       }
-       AddLine(BPoint(fColumns * sizeCol, sizeDisp),
-                       BPoint(fColumns * sizeCol, fHeight),
-                       fDarkColor);
+                       uint32 flags = 0;
+                       if (!drawBackground)
+                               flags |= BControlLook::B_BLEND_FRAME;
+                       if (key->flags != 0)
+                               flags |= BControlLook::B_ACTIVATED;
+                       flags |= BControlLook::B_IGNORE_OUTLINE;
 
-       // render rows
-       for (int row = 0; row < fRows; row++) {
-               AddLine(BPoint(0.0, sizeDisp + row * sizeRow - 1.0),
-                               BPoint(fWidth, sizeDisp + row * sizeRow - 1.0),
-                               fDarkColor);
-               AddLine(BPoint(0.0, sizeDisp + row * sizeRow),
-                               BPoint(fWidth, sizeDisp + row * sizeRow),
-                               fLightColor);
-       }
-       AddLine(BPoint(0.0, sizeDisp + fRows * sizeRow),
-                       BPoint(fWidth, sizeDisp + fRows * sizeRow),
-                       fDarkColor);
+                       be_control_look->DrawButtonFrame(this, frame, 
updateRect,
+                               fBaseColor, fBaseColor, flags);
 
-       // main grid complete
-       EndLineArray();
+                       be_control_look->DrawButtonBackground(this, frame, 
updateRect,
+                               fBaseColor, flags);
 
-       // render key symbols
-       float halfSizeCol = sizeCol * 0.5f;
-       SetHighColor(fButtonTextColor);
-       SetLowColor(fBaseColor);
-       SetDrawingMode(B_OP_COPY);
+                       be_control_look->DrawLabel(this, key->label, frame, 
updateRect,
+                               fBaseColor, flags, 
BAlignment(B_ALIGN_HORIZONTAL_CENTER,
+                                       B_ALIGN_VERTICAL_CENTER));
 
-       float baselineOffset = ((fHeight - sizeDisp) / (float)fRows)
-                                                       * (1.0 - kFontScaleY) * 
0.5;
-       CalcKey* key = fKeypad;
-       for (int row = 0; row < fRows; row++) {
-               for (int col = 0; col < fColumns; col++) {
-                       float halfSymbolWidth = StringWidth(key->label) * 0.5f;
-                       DrawString(key->label,
-                               BPoint(col * sizeCol + halfSizeCol - 
halfSymbolWidth,
-                               sizeDisp + (row + 1) * sizeRow - 
baselineOffset));
                        key++;
                }
        }

############################################################################

Commit:      d2577d74afe8cc6da36786cfdde68d8731b4c4a0
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d2577d7
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Jun 28 04:27:45 2013 UTC

DeskCalc: Remove ResizeTo()

----------------------------------------------------------------------------

diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp
index c41b63f..b916570 100644
--- a/src/apps/deskcalc/CalcView.cpp
+++ b/src/apps/deskcalc/CalcView.cpp
@@ -576,13 +576,6 @@ CalcView::MakeFocus(bool focused)
 
 
 void
-CalcView::ResizeTo(float width, float height)
-{
-       BView::ResizeTo(width, height);
-}
-
-
-void
 CalcView::FrameResized(float width, float height)
 {
        fWidth = width;
diff --git a/src/apps/deskcalc/CalcView.h b/src/apps/deskcalc/CalcView.h
index 309564e..811313d 100644
--- a/src/apps/deskcalc/CalcView.h
+++ b/src/apps/deskcalc/CalcView.h
@@ -60,7 +60,6 @@ class CalcView : public BView {
        virtual void                            MouseUp(BPoint point);
        virtual void                            KeyDown(const char* bytes, 
int32 numBytes);
        virtual void                            MakeFocus(bool focused = true);
-       virtual void                            ResizeTo(float width, float 
height);
        virtual void                            FrameResized(float width, float 
height);
 
                        // Archive this view.

############################################################################

Commit:      43f09adbe2a11c16b67cb8ec930782c08a0374fa
URL:         http://cgit.haiku-os.org/haiku/commit/?id=43f09ad
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Jun 28 04:33:03 2013 UTC

DeskCalc: Add private _IsEmbedded() method

----------------------------------------------------------------------------

diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp
index b916570..673e857 100644
--- a/src/apps/deskcalc/CalcView.cpp
+++ b/src/apps/deskcalc/CalcView.cpp
@@ -315,12 +315,7 @@ CalcView::MessageReceived(BMessage* message)
 void
 CalcView::Draw(BRect updateRect)
 {
-       bool drawBackground = true;
-       if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
-               // CalcView is embedded somewhere, most likely the Tracker 
Desktop
-               // shelf.
-               drawBackground = false;
-       }
+       bool drawBackground = !_IsEmbedded();
 
        SetHighColor(fBaseColor);
        BRect expressionRect(_ExpressionRect());
@@ -809,13 +804,16 @@ CalcView::SetDegreeMode(bool degrees)
 void
 CalcView::SetKeypadMode(uint8 mode)
 {
-       if (fOptions->keypad_mode == mode)
+       if (_IsEmbedded())
                return;
 
        BWindow* window = Window();
        if (window == NULL)
                return;
 
+       if (fOptions->keypad_mode == mode)
+               return;
+
        fOptions->keypad_mode = mode;
        _MarkKeypadItems(fOptions->keypad_mode);
 
@@ -1278,3 +1276,12 @@ CalcView::_FetchAppIcon(BBitmap* into)
        if (status != B_OK)
                memset(into->Bits(), 0, into->BitsLength());
 }
+
+
+// Returns whether or not CalcView is embedded somewhere, most likely
+// the Desktop
+bool
+CalcView::_IsEmbedded()
+{
+       return Parent() != NULL && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 
0;
+}
diff --git a/src/apps/deskcalc/CalcView.h b/src/apps/deskcalc/CalcView.h
index 811313d..a4a45bc 100644
--- a/src/apps/deskcalc/CalcView.h
+++ b/src/apps/deskcalc/CalcView.h
@@ -117,6 +117,7 @@ class CalcView : public BView {
                        void                            _MarkKeypadItems(uint8 
mode);
 
                        void                            _FetchAppIcon(BBitmap* 
into);
+                       bool                            _IsEmbedded();
 
                        // grid dimensions
                        int16                           fColumns;

############################################################################

Commit:      fbc8aeaac80c417df5eebbcd3cfc19fd5a767e0d
URL:         http://cgit.haiku-os.org/haiku/commit/?id=fbc8aea
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Jun 28 04:33:40 2013 UTC

DeskCalc: Replace comment with equivalent code

----------------------------------------------------------------------------

diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp
index 673e857..9e69113 100644
--- a/src/apps/deskcalc/CalcView.cpp
+++ b/src/apps/deskcalc/CalcView.cpp
@@ -858,7 +858,8 @@ CalcView::SetKeypadMode(uint8 mode)
                        break;
                }
 
-               default: // KEYPAD_MODE_BASIC is the default
+               case KEYPAD_MODE_BASIC:
+               default:
                {
                        free(fKeypadDescription);
                        fKeypadDescription = strdup(kKeypadDescriptionBasic);

############################################################################

Commit:      49620f7b7dbb31339573d93975235151585d47fc
URL:         http://cgit.haiku-os.org/haiku/commit/?id=49620f7
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Jun 28 04:34:15 2013 UTC

DeskCalc: Preserve selection on resize

----------------------------------------------------------------------------

diff --git a/src/apps/deskcalc/ExpressionTextView.cpp 
b/src/apps/deskcalc/ExpressionTextView.cpp
index 5dcbc57..e303731 100644
--- a/src/apps/deskcalc/ExpressionTextView.cpp
+++ b/src/apps/deskcalc/ExpressionTextView.cpp
@@ -136,8 +136,13 @@ ExpressionTextView::SetTextRect(BRect rect)
        InputTextView::SetTextRect(rect);
 
        int32 count = fPreviousExpressions.CountItems();
-       if (fHistoryPos == count && fCurrentValue.CountChars() > 0)
+       if (fHistoryPos == count && fCurrentValue.CountChars() > 0) {
+               int32 start;
+               int32 finish;
+               GetSelection(&start, &finish);
                SetValue(fCurrentValue.String());
+               Select(start, finish);
+       }
 }
 
 

############################################################################

Commit:      786b0f8f1ecc9f9fd289d096a5ce12de619fe59e
URL:         http://cgit.haiku-os.org/haiku/commit/?id=786b0f8
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Fri Jun 28 04:38:01 2013 UTC

DeskCalc: Resize a bit more efficiently.

Remove B_FULL_UPDATE_ON_RESIZE flag from view.

We already Invalidate() on FrameResized() which redraws the
view on resize for us. This reduces the number of times Draw() is called
from 3+ in some cases to just one. Unfortunately Draw() is still called
multiple times in some cases producing noticable flickering and drawing
artifacts but it is marginally better.

----------------------------------------------------------------------------

diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp
index 9e69113..b0ceda2 100644
--- a/src/apps/deskcalc/CalcView.cpp
+++ b/src/apps/deskcalc/CalcView.cpp
@@ -117,8 +117,7 @@ CalcView::Instantiate(BMessage* archive)
 
 CalcView::CalcView(BRect frame, rgb_color rgbBaseColor, BMessage* settings)
        :
-       BView(frame, "DeskCalc", B_FOLLOW_ALL_SIDES,
-               B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS),
+       BView(frame, "DeskCalc", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | 
B_FRAME_EVENTS),
        fColumns(5),
        fRows(4),
 
@@ -847,14 +846,19 @@ CalcView::SetKeypadMode(uint8 mode)
 
                        if (width < kMinimumWidthScientific)
                                width = kMinimumWidthScientific;
-                       if (width > kMaximumWidthScientific)
+                       else if (width > kMaximumWidthScientific)
                                width = kMaximumWidthScientific;
 
                        if (height < kMinimumHeightScientific)
                                height = kMinimumHeightScientific;
-                       if (height > kMaximumHeightScientific)
+                       else if (height > kMaximumHeightScientific)
                                height = kMaximumHeightScientific;
-                       ResizeTo(width, height);
+
+                       if (width != fWidth || height != fHeight)
+                               ResizeTo(width, height);
+                       else
+                               Invalidate();
+
                        break;
                }
 
@@ -871,14 +875,18 @@ CalcView::SetKeypadMode(uint8 mode)
 
                        if (width < kMinimumWidthBasic)
                                width = kMinimumWidthBasic;
-                       if (width > kMaximumWidthBasic)
+                       else if (width > kMaximumWidthBasic)
                                width = kMaximumWidthBasic;
 
                        if (height < kMinimumHeightBasic)
                                height = kMinimumHeightBasic;
-                       if (height > kMaximumHeightBasic)
+                       else if (height > kMaximumHeightBasic)
                                height = kMaximumHeightBasic;
-                       ResizeTo(width, height);
+
+                       if (width != fWidth || height != fHeight)
+                               ResizeTo(width, height);
+                       else
+                               Invalidate();
                }
        }
 }

############################################################################

Revision:    hrev45852
Commit:      747612e39033209fdca054fe2be0f1f086ec425a
URL:         http://cgit.haiku-os.org/haiku/commit/?id=747612e
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Tue Jul  9 16:46:19 2013 UTC

ExpressionParser: Simplify pi detection

----------------------------------------------------------------------------

diff --git a/src/kits/shared/ExpressionParser.cpp 
b/src/kits/shared/ExpressionParser.cpp
index fbc416b..382d919 100644
--- a/src/kits/shared/ExpressionParser.cpp
+++ b/src/kits/shared/ExpressionParser.cpp
@@ -197,7 +197,6 @@ class ExpressionParser::Tokenizer {
                        fCurrentToken = Token(begin, length, _CurrentPos() - 
length,
                                TOKEN_CONSTANT);
                        fCurrentToken.value = temp.String();
-
                } else if (isalpha(*fCurrentChar) && *fCurrentChar != 'x') {
                        const char* begin = fCurrentChar;
                        while (*fCurrentChar != 0 && (isalpha(*fCurrentChar)
@@ -207,14 +206,10 @@ class ExpressionParser::Tokenizer {
                        int32 length = fCurrentChar - begin;
                        fCurrentToken = Token(begin, length, _CurrentPos() - 
length,
                                TOKEN_IDENTIFIER);
-
-               } else if ((unsigned char)fCurrentChar[0] == 0xCF
-                       && (unsigned char)fCurrentChar[1] == 0x80) {
-                       // UTF-8 small greek letter PI
+               } else if (strncmp(fCurrentChar, "π", 2) == 0) {
                        fCurrentToken = Token(fCurrentChar, 2, _CurrentPos() - 
1,
                                TOKEN_IDENTIFIER);
                        fCurrentChar += 2;
-
                } else {
                        int32 type = TOKEN_NONE;
 
@@ -567,14 +562,10 @@ ExpressionParser::_InitArguments(MAPM values[], int32 
argumentCount)
 MAPM
 ExpressionParser::_ParseFunction(const Token& token)
 {
-       if (strcmp("e", token.string.String()) == 0)
+       if (token.string == "e")
                return _ParseFactorial(MAPM(MM_E));
-       else if (strcasecmp("pi", token.string.String()) == 0
-               || ((unsigned char)token.string.String()[0] == 0xCF
-                       && (unsigned char)token.string.String()[1] == 0x80)) {
-               // UTF-8 small greek letter PI
+       else if (token.string.ICompare("pi") == 0 || token.string == "π")
                return _ParseFactorial(MAPM(MM_PI));
-       }
 
        // hard coded cases for different count of arguments
        // supports functions with 3 arguments at most


Other related posts: