[haiku-commits] r33923 - haiku/trunk/src/apps/deskcalc

  • From: alex@xxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 6 Nov 2009 18:32:08 +0100 (CET)

Author: aldeck
Date: 2009-11-06 18:32:07 +0100 (Fri, 06 Nov 2009)
New Revision: 33923
Changeset: http://dev.haiku-os.org/changeset/33923/haiku

Modified:
   haiku/trunk/src/apps/deskcalc/CalcApplication.cpp
   haiku/trunk/src/apps/deskcalc/CalcApplication.h
   haiku/trunk/src/apps/deskcalc/CalcOptions.cpp
   haiku/trunk/src/apps/deskcalc/CalcView.cpp
   haiku/trunk/src/apps/deskcalc/CalcView.h
   haiku/trunk/src/apps/deskcalc/CalcWindow.cpp
   haiku/trunk/src/apps/deskcalc/CalcWindow.h
   haiku/trunk/src/apps/deskcalc/ExpressionTextView.cpp
   haiku/trunk/src/apps/deskcalc/ExpressionTextView.h
   haiku/trunk/src/apps/deskcalc/InputTextView.cpp
   haiku/trunk/src/apps/deskcalc/InputTextView.h
Log:
* Style fixes. Encountered ambiguous cases, please see my following questions
in the commit ml.


Modified: haiku/trunk/src/apps/deskcalc/CalcApplication.cpp
===================================================================
--- haiku/trunk/src/apps/deskcalc/CalcApplication.cpp   2009-11-06 16:12:53 UTC 
(rev 33922)
+++ haiku/trunk/src/apps/deskcalc/CalcApplication.cpp   2009-11-06 17:32:07 UTC 
(rev 33923)
@@ -30,8 +30,9 @@
 
 
 CalcApplication::CalcApplication()
-       : BApplication(kAppSig),
-         fCalcWindow(NULL)
+       :
+       BApplication(kAppSig),
+       fCalcWindow(NULL)
 {
 }
 
@@ -77,7 +78,7 @@
 
 
 void
-CalcApplication::_LoadSettings(BMessage &archive)
+CalcApplication::_LoadSettings(BMessage& archive)
 {
        // locate preferences file
        BFile prefsFile;
@@ -128,10 +129,11 @@
        }
 }
 
+
 status_t
 CalcApplication::_InitSettingsFile(BFile* file, bool write)
 {
-       // find user settings directory 
+       // find user settings directory
        BPath prefsPath;
        status_t ret = find_directory(B_USER_SETTINGS_DIRECTORY, &prefsPath);
        if (ret < B_OK)
@@ -141,9 +143,10 @@
        if (ret < B_OK)
                return ret;
 
-       if (write)
-               ret = file->SetTo(prefsPath.Path(), B_CREATE_FILE | 
B_ERASE_FILE | B_WRITE_ONLY);
-       else
+       if (write) {
+               ret = file->SetTo(prefsPath.Path(),
+                       B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY);
+       } else
                ret = file->SetTo(prefsPath.Path(), B_READ_ONLY);
 
        return ret;

Modified: haiku/trunk/src/apps/deskcalc/CalcApplication.h
===================================================================
--- haiku/trunk/src/apps/deskcalc/CalcApplication.h     2009-11-06 16:12:53 UTC 
(rev 33922)
+++ haiku/trunk/src/apps/deskcalc/CalcApplication.h     2009-11-06 17:32:07 UTC 
(rev 33923)
@@ -28,7 +28,7 @@
        virtual bool                            QuitRequested();
 
  private:
-                       void                            _LoadSettings(BMessage 
&settings);
+                       void                            _LoadSettings(BMessage& 
settings);
                        void                            _SaveSettings();
                        status_t                        
_InitSettingsFile(BFile* file, bool write);
 

Modified: haiku/trunk/src/apps/deskcalc/CalcOptions.cpp
===================================================================
--- haiku/trunk/src/apps/deskcalc/CalcOptions.cpp       2009-11-06 16:12:53 UTC 
(rev 33922)
+++ haiku/trunk/src/apps/deskcalc/CalcOptions.cpp       2009-11-06 17:32:07 UTC 
(rev 33923)
@@ -17,9 +17,10 @@
 
 
 CalcOptions::CalcOptions()
-       : auto_num_lock(false),
-         audio_feedback(false),
-         show_keypad(true)
+       :
+       auto_num_lock(false),
+       audio_feedback(false),
+       show_keypad(true)
 {
 }
 

Modified: haiku/trunk/src/apps/deskcalc/CalcView.cpp
===================================================================
--- haiku/trunk/src/apps/deskcalc/CalcView.cpp  2009-11-06 16:12:53 UTC (rev 
33922)
+++ haiku/trunk/src/apps/deskcalc/CalcView.cpp  2009-11-06 17:32:07 UTC (rev 
33923)
@@ -80,7 +80,8 @@
 };
 
 
-CalcView *CalcView::Instantiate(BMessage *archive)
+CalcView*
+CalcView::Instantiate(BMessage* archive)
 {
        if (!validate_instantiation(archive, "CalcView"))
                return NULL;
@@ -89,7 +90,7 @@
 }
 
 
-CalcView::CalcView(BRect frame, rgb_color rgbBaseColor, BMessage *settings)
+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),
@@ -241,7 +242,7 @@
                        case B_PASTE:
                                // access system clipboard
                                if (be_clipboard->Lock()) {
-                                       BMessage *clipper = 
be_clipboard->Data();
+                                       BMessage* clipper = 
be_clipboard->Data();
                                        //clipper->PrintToStream();
                                        Paste(clipper);
                                        be_clipboard->Unlock();
@@ -400,7 +401,7 @@
        SetFontSize(min_c(sizeRow * kFontScaleY, sizeCol * kFontScaleX));
 
        if (be_control_look != NULL) {
-               CalcKey *key = fKeypad;
+               CalcKey* key = fKeypad;
                for (int row = 0; row < fRows; row++) {
                        for (int col = 0; col < fColums; col++) {
                                BRect frame;
@@ -486,7 +487,7 @@
 
        float baselineOffset = ((fHeight - sizeDisp) / (float)fRows)
                                                        * (1.0 - kFontScaleY) * 
0.5;
-       CalcKey *key = fKeypad;
+       CalcKey* key = fKeypad;
        for (int row = 0; row < fRows; row++) {
                for (int col = 0; col < fColums; col++) {
                        float halfSymbolWidth = StringWidth(key->label) * 0.5f;
@@ -545,8 +546,8 @@
        int gridRow = (int)floorf((point.y - sizeDisp) / sizeRow);
 
        // check limits
-       if ((gridCol >= 0) && (gridCol < fColums) &&
-               (gridRow >= 0) && (gridRow < fRows)) {
+       if ((gridCol >= 0) && (gridCol < fColums)
+               && (gridRow >= 0) && (gridRow < fRows)) {
 
                // process key press
                int key = gridRow * fColums + gridCol;
@@ -576,7 +577,7 @@
 
 
 void
-CalcView::KeyDown(const char *bytes, int32 numBytes)
+CalcView::KeyDown(const char* bytes, int32 numBytes)
 {
        // if single byte character...
        if (numBytes == 1) {
@@ -702,8 +703,8 @@
        const_cast<CalcView*>(this)->AddChild(fExpressionTextView);
 
        // save app signature for replicant add-on loading
-    if (ret == B_OK)
-       ret = archive->AddString("add_on", kAppSig);
+       if (ret == B_OK)
+               ret = archive->AddString("add_on", kAppSig);
 
        // save all the options
        if (ret == B_OK)
@@ -731,14 +732,12 @@
        // access system clipboard
        if (be_clipboard->Lock()) {
                be_clipboard->Clear();
-               BMessage *clipper = be_clipboard->Data();
+               BMessage* clipper = be_clipboard->Data();
                clipper->what = B_MIME_DATA;
                // TODO: should check return for errors!
                BString expression = fExpressionTextView->Text();
-               clipper->AddData("text/plain",
-                                                B_MIME_TYPE,
-                                                expression.String(),
-                                                expression.Length());
+               clipper->AddData("text/plain", B_MIME_TYPE,
+                       expression.String(), expression.Length());
                //clipper->PrintToStream();
                be_clipboard->Commit();
                be_clipboard->Unlock();
@@ -747,16 +746,14 @@
 
 
 void
-CalcView::Paste(BMessage *message)
+CalcView::Paste(BMessage* message)
 {
        // handle color drops first
        // read incoming color
        const rgb_color* dropColor = NULL;
        ssize_t dataSize;
-       if (message->FindData("RGBColor",
-                                                 B_RGB_COLOR_TYPE,
-                                                 (const void**)&dropColor,
-                                                 &dataSize) == B_OK
+       if (message->FindData("RGBColor", B_RGB_COLOR_TYPE,
+                       (const void**)&dropColor, &dataSize) == B_OK
                && dataSize == sizeof(rgb_color)) {
 
                // calculate view relative drop point
@@ -778,10 +775,8 @@
                // look for text/plain MIME data
                const char* text;
                ssize_t numBytes;
-               if (message->FindData("text/plain",
-                                                         B_MIME_TYPE,
-                                                         (const void**)&text,
-                                                         &numBytes) == B_OK) {
+               if (message->FindData("text/plain", B_MIME_TYPE,
+                               (const void**)&text, &numBytes) == B_OK) {
                        BString temp;
                        temp.Append(text, numBytes);
                        fExpressionTextView->Insert(temp.String());
@@ -815,8 +810,8 @@
        const rgb_color* color;
        ssize_t size;
        if (archive->FindData("rgbBaseColor", B_RGB_COLOR_TYPE,
-                                                 (const void**)&color, &size) 
< B_OK
-                                                 || size != sizeof(rgb_color)) 
{
+                       (const void**)&color, &size) < B_OK
+               || size != sizeof(rgb_color)) {
                fBaseColor = (rgb_color){ 128, 128, 128, 255 };
                puts("Missing rgbBaseColor from CalcView archive!\n");
        } else {
@@ -824,8 +819,8 @@
        }
 
        if (archive->FindData("rgbDisplay", B_RGB_COLOR_TYPE,
-                                                 (const void**)&color, &size) 
< B_OK
-                                                 || size != sizeof(rgb_color)) 
{
+                       (const void**)&color, &size) < B_OK
+               || size != sizeof(rgb_color)) {
                fExpressionBGColor = (rgb_color){ 0, 0, 0, 255 };
                puts("Missing rgbBaseColor from CalcView archive!\n");
        } else {
@@ -871,10 +866,10 @@
        // record color scheme
        if (ret == B_OK)
                ret = archive->AddData("rgbBaseColor", B_RGB_COLOR_TYPE,
-                                                          &fBaseColor, 
sizeof(rgb_color));
+                       &fBaseColor, sizeof(rgb_color));
        if (ret == B_OK)
                ret = archive->AddData("rgbDisplay", B_RGB_COLOR_TYPE,
-                                                          &fExpressionBGColor, 
sizeof(rgb_color));
+                       &fExpressionBGColor, sizeof(rgb_color));
 
        // record current options
        if (ret == B_OK)
@@ -947,12 +942,12 @@
        fKeypad = new CalcKey[fRows * fColums];
 
        // scan through calculator description and assemble keypad
-       CalcKey *key = fKeypad;
-       const char *p = keypadDescription;
+       CalcKey* key = fKeypad;
+       const char* p = keypadDescription;
 
        while (*p != 0) {
                // copy label
-               char *l = key->label;
+               char* l = key->label;
                while (!isspace(*p))
                        *l++ = *p++;
                *l = '\0';
@@ -1010,7 +1005,7 @@
 
 
 void
-CalcView::_PressKey(const char *label)
+CalcView::_PressKey(const char* label)
 {
        int32 key = _KeyForLabel(label);
        if (key >= 0)
@@ -1019,7 +1014,7 @@
 
 
 int32
-CalcView::_KeyForLabel(const char *label) const
+CalcView::_KeyForLabel(const char* label) const
 {
        int keys = fRows * fColums;
        for (int i = 0; i < keys; i++) {
@@ -1090,8 +1085,8 @@
                fButtonTextColor = (rgb_color){ 255, 255, 255, 255 };
 
        // expression text color
-       lightness = (fExpressionBGColor.red +
-                                fExpressionBGColor.green + 
fExpressionBGColor.blue) / 3;
+       lightness = (fExpressionBGColor.red
+               + fExpressionBGColor.green + fExpressionBGColor.blue) / 3;
        if (lightness > 200)
                fExpressionTextColor = (rgb_color){ 0, 0, 0, 255 };
        else
@@ -1164,8 +1159,8 @@
        if (fShowKeypadItem && fShowKeypadItem->IsMarked() ^ fShowKeypad)
                fShowKeypadItem->SetMarked(fShowKeypad);
 
-       float height = fShowKeypad ? fHeight / kDisplayScaleY
-                                                          : fHeight * 
kDisplayScaleY;
+       float height
+               = fShowKeypad ? fHeight / kDisplayScaleY : fHeight * 
kDisplayScaleY;
 
        BWindow* window = Window();
        if (window) {

Modified: haiku/trunk/src/apps/deskcalc/CalcView.h
===================================================================
--- haiku/trunk/src/apps/deskcalc/CalcView.h    2009-11-06 16:12:53 UTC (rev 
33922)
+++ haiku/trunk/src/apps/deskcalc/CalcView.h    2009-11-06 17:32:07 UTC (rev 
33923)
@@ -23,13 +23,13 @@
 _EXPORT
 class CalcView : public BView {
  public:
-               
+
        static  CalcView*                       Instantiate(BMessage* archive);
-               
-               
+
+
                                                                CalcView(BRect 
frame,
-                                                                               
rgb_color rgbBaseColor,
-                                                                               
BMessage *settings);
+                                                                       
rgb_color rgbBaseColor,
+                                                                       
BMessage* settings);
 
                                                                
CalcView(BMessage* archive);
 
@@ -57,7 +57,7 @@
                        void                            Copy();
 
                        // Paste contents of system clipboard to view.
-                       void                            Paste(BMessage 
*message);
+                       void                            Paste(BMessage* 
message);
 
                        // Save current settings
                        status_t                        SaveSettings(BMessage* 
archive) const;
@@ -68,7 +68,7 @@
 
  private:
                        void                            _ParseCalcDesc(const 
char* keypadDescription);
-                       
+
                        void                            _PressKey(int key);
                        void                            _PressKey(const char* 
label);
                        int32                           _KeyForLabel(const 
char* label) const;

Modified: haiku/trunk/src/apps/deskcalc/CalcWindow.cpp
===================================================================
--- haiku/trunk/src/apps/deskcalc/CalcWindow.cpp        2009-11-06 16:12:53 UTC 
(rev 33922)
+++ haiku/trunk/src/apps/deskcalc/CalcWindow.cpp        2009-11-06 17:32:07 UTC 
(rev 33923)
@@ -24,7 +24,7 @@
 static const char* kWindowTitle                = "DeskCalc";
 
 
-CalcWindow::CalcWindow(BRect frame, BMessage *settings)
+CalcWindow::CalcWindow(BRect frame, BMessage* settings)
        : BWindow(frame, kWindowTitle, B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
 {
        // create calculator view with calculator description and
@@ -36,14 +36,14 @@
 
        frame.OffsetTo(B_ORIGIN);
        fCalcView = new CalcView(frame, baseColor, settings);
-       
+
        // create replicant dragger
        BRect replicantFrame(frame);
        replicantFrame.top = replicantFrame.bottom - 7.0f;
        replicantFrame.left = replicantFrame.right - 7.0f;
        BDragger* dragger = new BDragger(replicantFrame, fCalcView,
                B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
-       
+
        // attach views
        AddChild(fCalcView);
        fCalcView->AddChild(dragger);

Modified: haiku/trunk/src/apps/deskcalc/CalcWindow.h
===================================================================
--- haiku/trunk/src/apps/deskcalc/CalcWindow.h  2009-11-06 16:12:53 UTC (rev 
33922)
+++ haiku/trunk/src/apps/deskcalc/CalcWindow.h  2009-11-06 17:32:07 UTC (rev 
33923)
@@ -18,7 +18,7 @@
 
 class CalcWindow : public BWindow {
  public:
-                                                               
CalcWindow(BRect frame, BMessage *settings);
+                                                               
CalcWindow(BRect frame, BMessage* settings);
        virtual                                         ~CalcWindow();
 
        virtual void                            Show();
@@ -27,7 +27,7 @@
                        status_t                        SaveSettings(BMessage* 
archive) const;
 
                        void                            SetFrame(BRect frame,
-                                                                               
 bool forceCenter = false);
+                                                                       bool 
forceCenter = false);
 
  private:
                        CalcView*                       fCalcView;

Modified: haiku/trunk/src/apps/deskcalc/ExpressionTextView.cpp
===================================================================
--- haiku/trunk/src/apps/deskcalc/ExpressionTextView.cpp        2009-11-06 
16:12:53 UTC (rev 33922)
+++ haiku/trunk/src/apps/deskcalc/ExpressionTextView.cpp        2009-11-06 
17:32:07 UTC (rev 33923)
@@ -257,9 +257,9 @@
 {
        const char* oldExpression;
        for (int32 i = 0;
-                archive->FindString("previous expression", i, &oldExpression) 
== B_OK;
-                i++) {
-                AddExpressionToHistory(oldExpression);
+               archive->FindString("previous expression", i, &oldExpression) 
== B_OK;
+               i++) {
+               AddExpressionToHistory(oldExpression);
        }
 }
 

Modified: haiku/trunk/src/apps/deskcalc/ExpressionTextView.h
===================================================================
--- haiku/trunk/src/apps/deskcalc/ExpressionTextView.h  2009-11-06 16:12:53 UTC 
(rev 33922)
+++ haiku/trunk/src/apps/deskcalc/ExpressionTextView.h  2009-11-06 17:32:07 UTC 
(rev 33923)
@@ -19,7 +19,7 @@
 class ExpressionTextView : public InputTextView {
  public:
                                                                
ExpressionTextView(BRect frame,
-                                                                               
                   CalcView* calcView);
+                                                                       
CalcView* calcView);
        virtual                                         ~ExpressionTextView();
 
        // BView

Modified: haiku/trunk/src/apps/deskcalc/InputTextView.cpp
===================================================================
--- haiku/trunk/src/apps/deskcalc/InputTextView.cpp     2009-11-06 16:12:53 UTC 
(rev 33922)
+++ haiku/trunk/src/apps/deskcalc/InputTextView.cpp     2009-11-06 17:32:07 UTC 
(rev 33923)
@@ -13,23 +13,22 @@
 
 #include <String.h>
 
-// constructor
-InputTextView::InputTextView(BRect frame, const char* name,
-                                                        BRect textRect,
-                                                        uint32 resizingMode,
-                                                        uint32 flags)
-       : BTextView(frame, name, textRect, resizingMode, flags),
-         fWasFocus(false)
+
+InputTextView::InputTextView(BRect frame, const char* name, BRect textRect,
+       uint32 resizingMode, uint32 flags)
+       :
+       BTextView(frame, name, textRect, resizingMode, flags),
+       fWasFocus(false)
 {
        SetWordWrap(false);
 }
 
-// destructor
+
 InputTextView::~InputTextView()
 {
 }
 
-// MouseDown
+
 void
 InputTextView::MouseDown(BPoint where)
 {
@@ -47,7 +46,7 @@
        }
 }
 
-// MouseUp
+
 void
 InputTextView::MouseUp(BPoint where)
 {
@@ -58,7 +57,7 @@
                BTextView::MouseUp(where);
 }
 
-// KeyDown
+
 void
 InputTextView::KeyDown(const char* bytes, int32 numBytes)
 {
@@ -85,7 +84,7 @@
                BTextView::KeyDown(bytes, numBytes);
 }
 
-// MakeFocus
+
 void
 InputTextView::MakeFocus(bool focus)
 {
@@ -98,7 +97,7 @@
        }
 }
 
-// Invoke
+
 status_t
 InputTextView::Invoke(BMessage* message)
 {
@@ -114,9 +113,10 @@
        return B_BAD_VALUE;
 }
 
+
 // #pragma mark -
 
-// Select
+
 void
 InputTextView::Select(int32 start, int32 finish)
 {
@@ -125,17 +125,17 @@
        _CheckTextRect();
 }
 
-// InsertText
+
 void
 InputTextView::InsertText(const char* inText, int32 inLength, int32 inOffset,
-                                                 const text_run_array* inRuns)
+       const text_run_array* inRuns)
 {
        BTextView::InsertText(inText, inLength, inOffset, inRuns);
 
        _CheckTextRect();
 }
 
-// DeleteText
+
 void
 InputTextView::DeleteText(int32 fromOffset, int32 toOffset)
 {
@@ -144,9 +144,10 @@
        _CheckTextRect();
 }
 
+
 // #pragma mark -
 
-// _CheckTextRect
+
 void
 InputTextView::_CheckTextRect()
 {

Modified: haiku/trunk/src/apps/deskcalc/InputTextView.h
===================================================================
--- haiku/trunk/src/apps/deskcalc/InputTextView.h       2009-11-06 16:12:53 UTC 
(rev 33922)
+++ haiku/trunk/src/apps/deskcalc/InputTextView.h       2009-11-06 17:32:07 UTC 
(rev 33923)
@@ -12,14 +12,13 @@
 #include <Invoker.h>
 #include <TextView.h>
 
-class InputTextView : public BTextView,
-                                         public BInvoker {
+class InputTextView : public BTextView, public BInvoker {
  public:
                                                                
InputTextView(BRect frame,
-                                                                               
          const char* name,
-                                                                               
          BRect textRect,
-                                                                               
          uint32 resizingMode,
-                                                                               
          uint32 flags);
+                                                                       const 
char* name,
+                                                                       BRect 
textRect,
+                                                                       uint32 
resizingMode,
+                                                                       uint32 
flags);
        virtual                                         ~InputTextView();
 
        // BTextView interface
@@ -41,11 +40,11 @@
        virtual void                            Select(int32 start, int32 
finish);
 
        virtual void                            InsertText(const char* inText,
-                                                                               
   int32 inLength,
-                                                                               
   int32 inOffset,
-                                                                               
   const text_run_array* inRuns);
+                                                                       int32 
inLength,
+                                                                       int32 
inOffset,
+                                                                       const 
text_run_array* inRuns);
        virtual void                            DeleteText(int32 fromOffset,
-                                                                               
   int32 toOffset);
+                                                                       int32 
toOffset);
 
                        void                            _CheckTextRect();
 


Other related posts: