Style fixes, update copyright, add myself as author.
No functional change.
This commit is contained in:
@@ -1,20 +1,22 @@
|
||||
/*
|
||||
* Copyright 2006-2011 Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2006-2012 Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 1997, 1998 R3 Software Ltd. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Timothy Wayper <[email protected]>
|
||||
* Stephan Aßmus <[email protected]>
|
||||
* John Scipione, [email protected]
|
||||
* Timothy Wayper <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#include "CalcApplication.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <Catalog.h>
|
||||
#include <Directory.h>
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
@@ -22,9 +24,11 @@
|
||||
|
||||
#include "CalcWindow.h"
|
||||
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "CalcApplication"
|
||||
|
||||
|
||||
static const char* kSettingsFileName = "DeskCalc_settings";
|
||||
const char* kAppSig = "application/x-vnd.Haiku-DeskCalc";
|
||||
|
||||
@@ -154,5 +158,3 @@ CalcApplication::_InitSettingsFile(BFile* file, bool write)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,14 +2,11 @@
|
||||
* Copyright 2006 Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 1997, 1998 R3 Software Ltd. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Timothy Wayper <[email protected]>
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
#ifndef _CALC_APPLICATION_H
|
||||
#define _CALC_APPLICATION_H
|
||||
|
||||
|
||||
#include <Application.h>
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
/*
|
||||
* Copyright 2006-2009 Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2006-2012 Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 1997, 1998 R3 Software Ltd. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Timothy Wayper <[email protected]>
|
||||
* Stephan Aßmus <[email protected]>
|
||||
* John Scipione, [email protected]
|
||||
* Timothy Wayper <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#include "CalcOptions.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
/*
|
||||
* Copyright 2006-2009 Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2006-2012 Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 1997, 1998 R3 Software Ltd. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Timothy Wayper <[email protected]>
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
#ifndef CALC_OPTIONS_H
|
||||
#define CALC_OPTIONS_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
enum {
|
||||
KEYPAD_MODE_COMPACT,
|
||||
KEYPAD_MODE_BASIC,
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Timothy Wayper <[email protected]>
|
||||
* Stephan Aßmus <[email protected]>
|
||||
* Philippe Saint-Pierre, [email protected]
|
||||
* John Scipione, [email protected]
|
||||
* Timothy Wayper <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -2,17 +2,14 @@
|
||||
* Copyright 2006 Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 1997, 1998 R3 Software Ltd. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Timothy Wayper <[email protected]>
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
#ifndef _CALC_VIEW_H
|
||||
#define _CALC_VIEW_H
|
||||
|
||||
|
||||
#include <View.h>
|
||||
|
||||
|
||||
enum {
|
||||
MSG_OPTIONS_AUTO_NUM_LOCK = 'oanl',
|
||||
MSG_OPTIONS_AUDIO_FEEDBACK = 'oafb',
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
/*
|
||||
* Copyright 2006-2011 Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2006-2012 Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 1997, 1998 R3 Software Ltd. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Timothy Wayper <[email protected]>
|
||||
* Stephan Aßmus <[email protected]>
|
||||
* John Scipione, [email protected]
|
||||
* Timothy Wayper <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#include "CalcWindow.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -2,18 +2,14 @@
|
||||
* Copyright 2006 Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 1997, 1998 R3 Software Ltd. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Timothy Wayper <[email protected]>
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _CALC_WINDOW_H
|
||||
#define _CALC_WINDOW_H
|
||||
|
||||
|
||||
#include <Window.h>
|
||||
|
||||
|
||||
class CalcView;
|
||||
|
||||
class CalcWindow : public BWindow {
|
||||
@@ -21,7 +17,7 @@ class CalcWindow : public BWindow {
|
||||
CalcWindow(BRect frame, BMessage* settings);
|
||||
virtual ~CalcWindow();
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void Show();
|
||||
virtual bool QuitRequested();
|
||||
|
||||
|
||||
@@ -8,18 +8,20 @@
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "CalcApplication.h"
|
||||
#include "ExpressionParser.h"
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
if (argc == 1) {
|
||||
// run GUI
|
||||
CalcApplication* app = new CalcApplication();
|
||||
|
||||
|
||||
app->Run();
|
||||
delete app;
|
||||
} else {
|
||||
|
||||
@@ -12,7 +12,7 @@ resource app_version {
|
||||
internal = 1,
|
||||
|
||||
short_info = "DeskCalc",
|
||||
long_info = "DeskCalc ©2006-2011 Haiku, Inc."
|
||||
long_info = "DeskCalc ©2006-2012 Haiku, Inc."
|
||||
};
|
||||
|
||||
resource app_flags B_SINGLE_LAUNCH;
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus <[email protected]>
|
||||
* John Scipione, [email protected]
|
||||
*/
|
||||
|
||||
|
||||
#include "ExpressionTextView.h"
|
||||
|
||||
#include <new>
|
||||
@@ -16,6 +18,7 @@
|
||||
|
||||
#include "CalcView.h"
|
||||
|
||||
|
||||
using std::nothrow;
|
||||
|
||||
static const int32 kMaxPreviousExpressions = 20;
|
||||
@@ -93,7 +96,7 @@ ExpressionTextView::KeyDown(const char* bytes, int32 numBytes)
|
||||
// history.
|
||||
if (current != Text())
|
||||
fHistoryPos = fPreviousExpressions.CountItems();
|
||||
|
||||
|
||||
// If changes where not applied the value has become a new expression
|
||||
// note that even if only the left or right arrow keys are pressed the
|
||||
// fCurrentValue string will be cleared.
|
||||
@@ -131,7 +134,7 @@ void
|
||||
ExpressionTextView::SetTextRect(BRect rect)
|
||||
{
|
||||
InputTextView::SetTextRect(rect);
|
||||
|
||||
|
||||
int32 count = fPreviousExpressions.CountItems();
|
||||
if (fHistoryPos == count && fCurrentValue.CountChars() > 0)
|
||||
SetValue(fCurrentValue.String());
|
||||
@@ -207,7 +210,7 @@ ExpressionTextView::SetValue(BString value)
|
||||
if (offset == firstDigit + 1) {
|
||||
// if the value is 0.01 or larger then scientific notation
|
||||
// won't shorten the string
|
||||
if (value[firstDigit] != '0' || value[firstDigit + 2] != '0'
|
||||
if (value[firstDigit] != '0' || value[firstDigit + 2] != '0'
|
||||
|| value[firstDigit + 3] != '0') {
|
||||
exponent = 0;
|
||||
} else {
|
||||
@@ -236,7 +239,7 @@ ExpressionTextView::SetValue(BString value)
|
||||
// move the period
|
||||
value.Remove(offset, 1);
|
||||
value.Insert('.', 1, firstDigit + 1);
|
||||
|
||||
|
||||
exponent = offset - (firstDigit + 1);
|
||||
}
|
||||
}
|
||||
@@ -252,7 +255,7 @@ ExpressionTextView::SetValue(BString value)
|
||||
stringWidth = font.StringWidth(value);
|
||||
char lastRemovedDigit = '0';
|
||||
while (offset > firstDigit && stringWidth > viewWidth) {
|
||||
if (value[offset] != '.')
|
||||
if (value[offset] != '.')
|
||||
lastRemovedDigit = value[offset];
|
||||
value.Remove(offset--, 1);
|
||||
stringWidth = font.StringWidth(value);
|
||||
@@ -270,9 +273,11 @@ ExpressionTextView::SetValue(BString value)
|
||||
for (; offset >= firstDigit; offset--) {
|
||||
if (value[offset] == '.')
|
||||
continue;
|
||||
|
||||
digit = (int)(value[offset]) - '0' + 1; // ascii to int + 1
|
||||
if (digit != 10)
|
||||
break;
|
||||
|
||||
value[offset] = '0';
|
||||
}
|
||||
if (digit == 10) {
|
||||
@@ -285,8 +290,9 @@ ExpressionTextView::SetValue(BString value)
|
||||
|
||||
// remove the exponent value and the last digit
|
||||
offset = value.FindFirst('E');
|
||||
if (offset == B_ERROR)
|
||||
if (offset == B_ERROR)
|
||||
offset = value.CountChars();
|
||||
|
||||
value.Truncate(--offset);
|
||||
offset--; // offset now points to the last digit
|
||||
|
||||
@@ -301,6 +307,7 @@ ExpressionTextView::SetValue(BString value)
|
||||
offset = value.FindFirst('E');
|
||||
if (offset == B_ERROR)
|
||||
offset = value.CountChars();
|
||||
|
||||
offset--;
|
||||
}
|
||||
}
|
||||
@@ -317,7 +324,7 @@ ExpressionTextView::SetValue(BString value)
|
||||
}
|
||||
}
|
||||
|
||||
// set the new value
|
||||
// set the new value
|
||||
SetExpression(value);
|
||||
}
|
||||
|
||||
@@ -444,4 +451,3 @@ ExpressionTextView::SaveSettings(BMessage* archive) const
|
||||
}
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
/*
|
||||
* Copyright 2006 Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
#ifndef EXPRESSION_TEXT_VIEW_H
|
||||
#define EXPRESSION_TEXT_VIEW_H
|
||||
|
||||
|
||||
#include <List.h>
|
||||
#include <String.h>
|
||||
|
||||
#include "InputTextView.h"
|
||||
|
||||
|
||||
class CalcView;
|
||||
|
||||
class ExpressionTextView : public InputTextView {
|
||||
@@ -62,7 +60,7 @@ class ExpressionTextView : public InputTextView {
|
||||
int32 fHistoryPos;
|
||||
BString fCurrentExpression;
|
||||
BString fCurrentValue;
|
||||
|
||||
|
||||
bool fChangesApplied;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
#include "InputTextView.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
/*
|
||||
* Copyright 2006 Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Stephan Aßmus <[email protected]>
|
||||
*/
|
||||
|
||||
#ifndef INPUT_TEXT_VIEW_H
|
||||
#define INPUT_TEXT_VIEW_H
|
||||
|
||||
|
||||
#include <Invoker.h>
|
||||
#include <TextView.h>
|
||||
|
||||
|
||||
class InputTextView : public BTextView, public BInvoker {
|
||||
public:
|
||||
InputTextView(BRect frame,
|
||||
@@ -35,7 +33,7 @@ class InputTextView : public BTextView, public BInvoker {
|
||||
virtual void RevertChanges() = 0;
|
||||
virtual void ApplyChanges() = 0;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// BTextView
|
||||
virtual void Select(int32 start, int32 finish);
|
||||
|
||||
@@ -52,5 +50,3 @@ protected:
|
||||
};
|
||||
|
||||
#endif // INPUT_TEXT_VIEW_H
|
||||
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ Application DeskCalc :
|
||||
;
|
||||
|
||||
DoCatalogs DeskCalc :
|
||||
x-vnd.Haiku-DeskCalc
|
||||
:
|
||||
x-vnd.Haiku-DeskCalc
|
||||
:
|
||||
CalcApplication.cpp
|
||||
CalcView.cpp
|
||||
CalcWindow.cpp
|
||||
|
||||
Reference in New Issue
Block a user