[haiku-commits] haiku: hrev46776 - in src/preferences/shortcuts/clv: . src/preferences/shortcuts

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 27 Jan 2014 22:23:17 +0100 (CET)

hrev46776 adds 1 changeset to branch 'master'
old head: 87784cafb89306b7e11440470a23302c14469c28
new head: b42302c5d343ffce4d7ed87bed26e7ffcabce1ae
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=b42302c+%5E87784ca

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

b42302c: Shortcuts: Big style refactor
  
  Update the style of this preference app to match Haiku’s coding guidelines.
  Since this app used a completely different style this is a big commit, but,
  there should be no behavioral changes.
  
  Style changes include but are not limited to:
  * private member variables use fMemberVariable style
  * local variables and public member variables use camelCase style
  * compare pointers to NULL explicitly
  * compare integers against 0 explicitly
  * always flank binary operators with spaces such as + - , / *
  * pointer goes with type, not value or flanked by spaces
  * lots of variable renaming especially for abbreviations
  * comments start with a leading space, prefer lowercase unless full sentence
  * space after keywords such as if and for and { and } on same line
  * multi-line if statement style fixes
  * remove trailing spaces
  * 80 char fixes
  * ... and many more, and I'm sure I missed some.
  
  Add/update copyright headers giving credit where due, obviously this code
  can’t be copyright Haiku, Inc. from 1999 since Haiku, Inc. didn’t exist
  so this change attributes copyright to Jeremy Friesner from 1999-2009 and
  Haiku, Inc. from 2009 onwards matching the long description of the rdef file.
  
  Added myself to the authors section of the files in the clv directory.

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

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

Revision:    hrev46776
Commit:      b42302c5d343ffce4d7ed87bed26e7ffcabce1ae
URL:         http://cgit.haiku-os.org/haiku/commit/?id=b42302c
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Mon Jan 20 23:30:59 2014 UTC

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

25 files changed, 3229 insertions(+), 2736 deletions(-)
src/preferences/shortcuts/MetaKeyStateMap.cpp    |    4 +-
src/preferences/shortcuts/MetaKeyStateMap.h      |   11 +-
src/preferences/shortcuts/Shortcuts.rdef         |    2 +-
src/preferences/shortcuts/ShortcutsApp.cpp       |    7 +-
src/preferences/shortcuts/ShortcutsApp.h         |   12 +-
src/preferences/shortcuts/ShortcutsSpec.cpp      |  165 +-
src/preferences/shortcuts/ShortcutsSpec.h        |   56 +-
src/preferences/shortcuts/ShortcutsWindow.cpp    |  234 +-
src/preferences/shortcuts/ShortcutsWindow.h      |   67 +-
src/preferences/shortcuts/clv/CLVColumn.cpp      |  267 +-
src/preferences/shortcuts/clv/CLVColumn.h        |  189 +-
.../shortcuts/clv/CLVColumnLabelView.cpp         | 1212 ++++-----
.../shortcuts/clv/CLVColumnLabelView.h           |  123 +-
src/preferences/shortcuts/clv/CLVListItem.cpp    |  240 +-
src/preferences/shortcuts/clv/CLVListItem.h      |  111 +-
src/preferences/shortcuts/clv/Colors.h           |   87 +-
src/preferences/shortcuts/clv/ColumnListView.cpp | 2426 ++++++++++--------
src/preferences/shortcuts/clv/ColumnListView.h   |  416 +--
src/preferences/shortcuts/clv/MouseWatcher.cpp   |  115 +-
src/preferences/shortcuts/clv/MouseWatcher.h     |   75 +-
.../shortcuts/clv/PrefilledBitmap.cpp            |   26 +-
src/preferences/shortcuts/clv/PrefilledBitmap.h  |   30 +-
.../shortcuts/clv/ScrollViewCorner.cpp           |   41 +-
src/preferences/shortcuts/clv/ScrollViewCorner.h |   42 +-
src/preferences/shortcuts/main.cpp               |    7 +-

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

diff --git a/src/preferences/shortcuts/MetaKeyStateMap.cpp 
b/src/preferences/shortcuts/MetaKeyStateMap.cpp
index 76b36bc..fa23f83 100644
--- a/src/preferences/shortcuts/MetaKeyStateMap.cpp
+++ b/src/preferences/shortcuts/MetaKeyStateMap.cpp
@@ -1,5 +1,6 @@
 /*
- * Copyright 1999-2009 Haiku Inc. All rights reserved.
+ * Copyright 1999-2009 Jeremy Friesner
+ * Copyright 2009 Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -89,4 +90,3 @@ MetaKeyStateMap::GetName() const
 {
        return fKeyName;
 }
-
diff --git a/src/preferences/shortcuts/MetaKeyStateMap.h 
b/src/preferences/shortcuts/MetaKeyStateMap.h
index bd2b316..0e57488 100644
--- a/src/preferences/shortcuts/MetaKeyStateMap.h
+++ b/src/preferences/shortcuts/MetaKeyStateMap.h
@@ -1,12 +1,13 @@
 /*
- * Copyright 1999-2009 Haiku Inc. All rights reserved.
+ * Copyright 1999-2009 Jeremy Friesner
+ * Copyright 2009 Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
  *             Jeremy Friesner
  */
-#ifndef MetaKeyStateMap_h
-#define MetaKeyStateMap_h
+#ifndef META_KEY_STATE_MAP_H
+#define META_KEY_STATE_MAP_H
 
 
 #include <List.h>
@@ -21,7 +22,6 @@ class BitFieldTester;
 // description strings and qualifier bit-chords that go with them.
 class MetaKeyStateMap {
 public:
-       
                        // Note: You MUST call SetInfo() directly after using 
this ctor!
                                                        MetaKeyStateMap();
 
@@ -65,5 +65,4 @@ private:
 };
 
 
-#endif
-
+#endif // META_KEY_STATE_MAP_H
diff --git a/src/preferences/shortcuts/Shortcuts.rdef 
b/src/preferences/shortcuts/Shortcuts.rdef
index fa548a4..2224a08 100644
--- a/src/preferences/shortcuts/Shortcuts.rdef
+++ b/src/preferences/shortcuts/Shortcuts.rdef
@@ -16,7 +16,7 @@ resource app_version {
        internal = 0,
 
        short_info = "Shortcuts",
-       long_info  = "Shortcuts ©1999-2009 Jeremy Friesner ©2009 Haiku Inc."
+       long_info  = "Shortcuts ©1999-2009 Jeremy Friesner ©2009-2014 Haiku, 
Inc."
 };
 
 resource vector_icon {
diff --git a/src/preferences/shortcuts/ShortcutsApp.cpp 
b/src/preferences/shortcuts/ShortcutsApp.cpp
index 8d8ff2d..79f67fc 100644
--- a/src/preferences/shortcuts/ShortcutsApp.cpp
+++ b/src/preferences/shortcuts/ShortcutsApp.cpp
@@ -1,12 +1,13 @@
 /*
- * Copyright 1999-2010 Haiku Inc. All rights reserved.
+ * Copyright 1999-2009 Jeremy Friesner
+ * Copyright 2009-2010 Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
  *             Jeremy Friesner
  *             Fredrik Modéen
  */
- 
+
 
 #include "ShortcutsApp.h"
 
@@ -35,5 +36,5 @@ ShortcutsApp::ReadyToRun()
 
 
 ShortcutsApp::~ShortcutsApp()
-{ 
+{
 }
diff --git a/src/preferences/shortcuts/ShortcutsApp.h 
b/src/preferences/shortcuts/ShortcutsApp.h
index 19b9031..c0ad7b2 100644
--- a/src/preferences/shortcuts/ShortcutsApp.h
+++ b/src/preferences/shortcuts/ShortcutsApp.h
@@ -1,13 +1,14 @@
 /*
- * Copyright 1999-2009 Haiku Inc. All rights reserved.
+ * Copyright 1999-2009 Jeremy Friesner
+ * Copyright 2009-2010 Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
  *             Jeremy Friesner
- *             Fredrik Modéen
+ *             Fredrik Modéen
  */
-#ifndef ShortcutsApp_h
-#define ShortcutsApp_h
+#ifndef SHORTCUTS_APP_H
+#define SHORTCUTS_APP_H
 
 
 #include <Application.h>
@@ -21,5 +22,4 @@ public:
 };
 
 
-#endif
-
+#endif // SHORTCUTS_APP_H
diff --git a/src/preferences/shortcuts/ShortcutsSpec.cpp 
b/src/preferences/shortcuts/ShortcutsSpec.cpp
index d7f5ca5..41917c4 100644
--- a/src/preferences/shortcuts/ShortcutsSpec.cpp
+++ b/src/preferences/shortcuts/ShortcutsSpec.cpp
@@ -1,12 +1,12 @@
 /*
- * Copyright 1999-2010 Haiku Inc. All rights reserved.
+ * Copyright 1999-2009 Jeremy Friesner
+ * Copyright 2009-2010 Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
  *             Jeremy Friesner
  */
 
-
 #include "ShortcutsSpec.h"
 
 #include <ctype.h>
@@ -227,7 +227,8 @@ ShortcutsSpec::ShortcutsSpec(BMessage* from)
 void
 ShortcutsSpec::SetCommand(const char* command)
 {
-       delete[] fCommand;      // out with the old (if any)...
+       delete[] fCommand;
+               // out with the old (if any)...
        fCommandLen = strlen(command) + 1;
        fCommandNul = fCommandLen - 1;
        fCommand = new char[fCommandLen];
@@ -342,7 +343,8 @@ void
 ShortcutsSpec::DrawItemColumn(BView* owner, BRect item_column_rect,
        int32 column_index, bool columnSelected, bool complete)
 {
-       const float STRING_COLUMN_LEFT_MARGIN = 25.0f; // 16 for the icon,+9 
empty
+       const float STRING_COLUMN_LEFT_MARGIN = 25.0f;
+               // 16 for the icon, +9 empty
 
        rgb_color color;
        bool selected = IsSelected();
@@ -406,8 +408,8 @@ ShortcutsSpec::DrawItemColumn(BView* owner, BRect 
item_column_rect,
                _CacheViewFont(owner);
 
                // How about I draw a nice "key" background for this one?
-               BRect textRect(point.x - KEY_MARGIN, (point.y-sFontHeight) - 
KEY_MARGIN
-                       , point.x + textWidth + KEY_MARGIN - 2.0f, point.y + 
KEY_MARGIN);
+               BRect textRect(point.x - KEY_MARGIN, (point.y - sFontHeight) - 
KEY_MARGIN,
+                       point.x + textWidth + KEY_MARGIN - 2.0f, point.y + 
KEY_MARGIN);
 
                if (column_index == KEY_COLUMN_INDEX)
                        lowColor = ReallyLightPurple;
@@ -547,7 +549,7 @@ ShortcutsSpec::ProcessColumnTextString(int whichColumn, 
const char* string)
 bool
 ShortcutsSpec::_AttemptTabCompletion()
 {
-       bool ret = false;
+       bool result = false;
 
        int32 argc;
        char** argv = ParseArgvFromString(fCommand, argc);
@@ -555,11 +557,11 @@ ShortcutsSpec::_AttemptTabCompletion()
                // Try to complete the path partially expressed in the last 
argument!
                char* arg = argv[argc - 1];
                char* fileFragment = strrchr(arg, '/');
-               if (fileFragment) {
+               if (fileFragment != NULL) {
                        const char* directoryName = (fileFragment == arg) ? "/" 
: arg;
                        *fileFragment = '\0';
                        fileFragment++;
-                       int fragLen = strlen(fileFragment);
+                       int fragmentLength = strlen(fileFragment);
 
                        BDirectory dir(directoryName);
                        if (dir.InitCheck() == B_NO_ERROR) {
@@ -573,7 +575,7 @@ ShortcutsSpec::_AttemptTabCompletion()
                                while (dir.GetNextEntry(&nextEnt) == 
B_NO_ERROR) {
                                        if (nextEnt.GetPath(&nextPath) == 
B_NO_ERROR) {
                                                char* filePath = 
strrchr(nextPath.Path(), '/') + 1;
-                                               if (strncmp(filePath, 
fileFragment, fragLen) == 0) {
+                                               if (strncmp(filePath, 
fileFragment, fragmentLength) == 0) {
                                                        int len = 
strlen(filePath);
                                                        if (len > maxEntryLen)
                                                                maxEntryLen = 
len;
@@ -586,13 +588,13 @@ ShortcutsSpec::_AttemptTabCompletion()
 
                                // Now slowly extend our keyword to its full 
length, counting
                                // numbers of matches at each step. If the 
match list length
-                               // is 1, we can use that whole entry. If it's 
greater than one
-                               // , we can use just the match length.
+                               // is 1, we can use that whole entry. If it's 
greater than one,
+                               // we can use just the match length.
                                int matchLen = matchList.CountItems();
                                if (matchLen > 0) {
                                        int i;
                                        BString result(fileFragment);
-                                       for (i = fragLen; i < maxEntryLen; i++) 
{
+                                       for (i = fragmentLength; i < 
maxEntryLen; i++) {
                                                // See if all the matching 
entries have the same letter
                                                // in the next position... if 
so, we can go farther.
                                                char commonLetter = '\0';
@@ -615,7 +617,7 @@ ShortcutsSpec::_AttemptTabCompletion()
                                                        
result.Append(commonLetter, 1);
                                        }
 
-                                       // Free all the strings we allocated
+                                       // free all the strings we allocated
                                        for (int k = 0; k < matchLen; k++)
                                                delete [] 
((char*)matchList.ItemAt(k));
 
@@ -637,10 +639,10 @@ ShortcutsSpec::_AttemptTabCompletion()
 
                                        // Remove any trailing slash...
                                        const char* fileStr = file.String();
-                                       if (fileStr[strlen(fileStr)-1] == '/')
+                                       if (fileStr[strlen(fileStr) - 1] == '/')
                                                file.RemoveLast("/");
 
-                                       // And re-append it iff the file is a 
dir.
+                                       // and re-append it iff the file is a 
dir.
                                        BDirectory testFileAsDir(file.String());
                                        if ((strcmp(file.String(), "/") != 0)
                                                && (testFileAsDir.InitCheck() 
== B_NO_ERROR))
@@ -649,14 +651,15 @@ ShortcutsSpec::_AttemptTabCompletion()
                                        wholeLine += file;
 
                                        SetCommand(wholeLine.String());
-                                       ret = true;
+                                       result = true;
                                }
                        }
                        *(fileFragment - 1) = '/';
                }
        }
        FreeArgv(argv);
-       return ret;
+
+       return result;
 }
 
 
@@ -664,13 +667,14 @@ bool
 ShortcutsSpec::ProcessColumnKeyStroke(int whichColumn, const char* bytes,
        int32 key)
 {
-       bool ret = false;
+       bool result = false;
+
        switch(whichColumn) {
                case KEY_COLUMN_INDEX:
                        if (key > -1) {
                                if ((int32)fKey != key) {
                                        fKey = key;
-                                       ret = true;
+                                       result = true;
                                }
                        }
                        break;
@@ -684,18 +688,18 @@ ShortcutsSpec::ProcessColumnKeyStroke(int whichColumn, 
const char* bytes,
                                                // trim a char off the string
                                                fCommand[fCommandNul - 1] = 
'\0';
                                                fCommandNul--;  // note new nul 
position
-                                               ret = true;
+                                               result = true;
                                                _UpdateIconBitmap();
                                        }
-                               break;
+                                       break;
 
                                case B_TAB:
                                        if (_AttemptTabCompletion()) {
                                                _UpdateIconBitmap();
-                                               ret = true;
+                                               result = true;
                                        } else
                                                beep();
-                               break;
+                                       break;
 
                                default:
                                {
@@ -722,7 +726,7 @@ ShortcutsSpec::ProcessColumnKeyStroke(int whichColumn, 
const char* bytes,
                                                // Here we should be guaranteed 
enough room.
                                                strncat(fCommand, bytes, 
fCommandLen);
                                                fCommandNul += newCharLen;
-                                               ret = true;
+                                               result = true;
                                                _UpdateIconBitmap();
                                        }
                                }
@@ -731,72 +735,73 @@ ShortcutsSpec::ProcessColumnKeyStroke(int whichColumn, 
const char* bytes,
                }
 
                default:
-                       if ((whichColumn >= 0) && (whichColumn < 
NUM_META_COLUMNS)) {
-                               MetaKeyStateMap * map = &sMetaMaps[whichColumn];
-                               int curState = fMetaCellStateIndex[whichColumn];
-                               int origState = curState;
-                               int numStates = map->GetNumStates();
+                       if (whichColumn < 0 || whichColumn >= NUM_META_COLUMNS)
+                               break;
+
+                       MetaKeyStateMap * map = &sMetaMaps[whichColumn];
+                       int curState = fMetaCellStateIndex[whichColumn];
+                       int origState = curState;
+                       int numStates = map->GetNumStates();
+
+                       switch(bytes[0]) {
+                               case B_RETURN:
+                                       // cycle to the previous state
+                                       curState = (curState + numStates - 1) % 
numStates;
+                                       break;
 
-                               switch(bytes[0])
+                               case B_SPACE:
+                                       // cycle to the next state
+                                       curState = (curState + 1) % numStates;
+                                       break;
+
+                               default:
                                {
-                                       case B_RETURN:
-                                               // cycle to the previous state
-                                               curState = (curState + 
numStates - 1) % numStates;
-                                               break;
-
-                                       case B_SPACE:
-                                               // cycle to the next state
-                                               curState = (curState + 1) % 
numStates;
-                                               break;
-
-                                       default:
-                                       {
-                                               // Go to the state starting 
with the given letter, if
-                                               // any
-                                               char letter = bytes[0];
-                                               if (islower(letter))
-                                                       letter = 
toupper(letter); // convert to upper case
-
-                                               if ((letter == B_BACKSPACE) || 
(letter == B_DELETE))
-                                                       letter = '(';
-                                                               // so space bar 
will blank out an entry
-
-                                               for (int i = 0; i < numStates; 
i++) {
-                                                       const char* desc = 
map->GetNthStateDesc(i);
-
-                                                       if (desc) {
-                                                               if (desc[0] == 
letter) {
-                                                                       
curState = i;
-                                                                       break;
-                                                               }
-                                                       } else
-                                                               
printf(B_TRANSLATE("Error, NULL state description?\n"));
+                                       // Go to the state starting with the 
given letter, if
+                                       // any
+                                       char letter = bytes[0];
+                                       if (islower(letter))
+                                               letter = toupper(letter); // 
convert to upper case
+
+                                       if ((letter == B_BACKSPACE) || (letter 
== B_DELETE))
+                                               letter = '(';
+                                                       // so space bar will 
blank out an entry
+
+                                       for (int i = 0; i < numStates; i++) {
+                                               const char* desc = 
map->GetNthStateDesc(i);
+
+                                               if (desc) {
+                                                       if (desc[0] == letter) {
+                                                               curState = i;
+                                                               break;
+                                                       }
+                                               } else {
+                                                       puts(B_TRANSLATE(
+                                                               "Error, NULL 
state description?"));
                                                }
-                                               break;
                                        }
                                }
-                               fMetaCellStateIndex[whichColumn] = curState;
-
-                               if (curState != origState)
-                                       ret = true;
                        }
-                       break;
+                       fMetaCellStateIndex[whichColumn] = curState;
+
+                       if (curState != origState)
+                               result = true;
        }
 
-       return ret;
+       return result;
 }
 
 
 int
-ShortcutsSpec::MyCompare(const CLVListItem* a_Item1, const CLVListItem* 
a_Item2,
-       int32 KeyColumn)
+ShortcutsSpec::CLVListItemCompare(const CLVListItem* firstItem,
+       const CLVListItem* secondItem, int32 keyColumn)
 {
-       ShortcutsSpec* left = (ShortcutsSpec*) a_Item1;
-       ShortcutsSpec* right = (ShortcutsSpec*) a_Item2;
+       ShortcutsSpec* left = (ShortcutsSpec*) firstItem;
+       ShortcutsSpec* right = (ShortcutsSpec*) secondItem;
 
-       int ret = strcmp(left->GetCellText(KeyColumn),
-               right->GetCellText(KeyColumn));
-       return (ret > 0) ? 1 : ((ret == 0) ? 0 : -1);
+       int result = strcmp(left->GetCellText(keyColumn),
+               right->GetCellText(keyColumn));
+
+       return result > 0 ? 1 : (result == 0 ? 0 : -1);
 }
 
 
@@ -821,13 +826,14 @@ ShortcutsSpec::_UpdateIconBitmap()
 {
        BString firstWord = ParseArgvZeroFromString(fCommand);
 
-       // Only need to change if the first word has changed...
+       // we only need to change if the first word has changed...
        if (fLastBitmapName == NULL || firstWord.Length() == 0
                || firstWord.Compare(fLastBitmapName)) {
                if (firstWord.ByteAt(0) == '*')
                        fBitmapValid = 
IsValidActuatorName(&firstWord.String()[1]);
                else {
-                       fBitmapValid = false; // default till we prove 
otherwise!
+                       fBitmapValid = false;
+                       // default until we prove otherwise
 
                        if (firstWord.Length() > 0) {
                                delete [] fLastBitmapName;
@@ -873,4 +879,3 @@ ShortcutsSpec::_InitModifierNames()
                "Name for modifier on keyboard");
 #endif
 }
-
diff --git a/src/preferences/shortcuts/ShortcutsSpec.h 
b/src/preferences/shortcuts/ShortcutsSpec.h
index 0dbfc91..289656e 100644
--- a/src/preferences/shortcuts/ShortcutsSpec.h
+++ b/src/preferences/shortcuts/ShortcutsSpec.h
@@ -1,12 +1,13 @@
 /*
- * Copyright 1999-2009 Haiku Inc. All rights reserved.
+ * Copyright 1999-2009 Jeremy Friesner
+ * Copyright 2009-2010 Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
  *             Jeremy Friesner
  */
-#ifndef ShortcutsSpec_h
-#define ShortcutsSpec_h
+#ifndef SHORTCUTS_SPEC_H
+#define SHORTCUTS_SPEC_H
 
 
 #include <Bitmap.h>
@@ -19,11 +20,12 @@ class CommandActuator;
 class MetaKeyStateMap;
 
 
-MetaKeyStateMap & GetNthKeyMap(int which);
+MetaKeyStateMap& GetNthKeyMap(int which);
 
-/* Objects of this class represent one hotkey "entry" in the preferences 
- * ListView. Each ShortcutsSpec contains the info necessary to generate both 
- * the proper GUI display, and the proper BitFieldTester and CommandActuator 
+/*
+ * Objects of this class represent one hotkey "entry" in the preferences
+ * ListView. Each ShortcutsSpec contains the info necessary to generate both
+ * the proper GUI display, and the proper BitFieldTester and CommandActuator
  * object for the ShortcutsCatcher add-on to use.
  */
 class ShortcutsSpec : public CLVListItem {
@@ -36,36 +38,36 @@ public:
                                                        ~ShortcutsSpec();
 
        virtual status_t                Archive(BMessage* into, bool deep = 
true) const;
-       virtual void                    Pulse(BView* owner);
-       static  BArchivable*    Instantiate(BMessage* from);                    
                                                        
-                       void                    Update(BView* owner, const 
BFont* font);        
-       const   char*                   GetCellText(int whichColumn) const;
+       virtual void                    Pulse(BView* owner);
+       static  BArchivable*    Instantiate(BMessage* from);
+                       void                    Update(BView* owner, const 
BFont* font);
+       const   char*                   GetCellText(int whichColumn) const;
                        void                    SetCommand(const char* 
commandStr);
-                       
+
        virtual void                    DrawItemColumn(BView* owner, BRect 
item_column_rect,
                                                                int32 
column_index, bool columnSelected,
                                                                bool complete);
        
-       static  int                             MyCompare(const CLVListItem* 
a_Item1, 
-                                                               const 
CLVListItem* a_Item2, int32 KeyColumn);
+       static  int                             CLVListItemCompare(const 
CLVListItem* firstItem,
+                                                               const 
CLVListItem* secondItem, int32 keyColumn);
 
        // Returns the name of the Nth Column.
        static  const char*             GetColumnName(int index);
 
                        // Update this spec's state in response to a keystroke 
to the given
                        // column. Returns true iff a change occurred.
-                       bool                    ProcessColumnKeyStroke(int 
whichColumn, 
+                       bool                    ProcessColumnKeyStroke(int 
whichColumn,
                                                                const char* 
bytes, int32 key);
 
                        // Same as ProcessColumnKeyStroke, but for a mouse 
click instead.
                        bool                    ProcessColumnMouseClick(int 
whichColumn);
        
                        // Same as ProcessColumnKeyStroke, but for a text 
string instead.
-                       bool                    ProcessColumnTextString(int 
whichColumn, 
+                       bool                    ProcessColumnTextString(int 
whichColumn,
                                                                const char* 
string);
 
-                       int32                   GetSelectedColumn() const 
{return fSelectedColumn;}
-                       void                    SetSelectedColumn(int32 i) 
{fSelectedColumn = i;}
+                       int32                   GetSelectedColumn() const { 
return fSelectedColumn; }
+                       void                    SetSelectedColumn(int32 i) { 
fSelectedColumn = i; }
 
        // default layout of columns is set in here.
        enum {
@@ -81,20 +83,20 @@ public:
 private:
                        void                    _CacheViewFont(BView* owner);
                        bool                    _AttemptTabCompletion();
-                       
+
                        // call this to ensure the icon is up-to-date
                        void                    _UpdateIconBitmap();
 
                        char*                   fCommand;
-                       uint32                  fCommandLen; // number of bytes 
in fCommand buffer
-                       uint32                  fCommandNul; // index of the 
NUL byte in fCommand
-                       float                   fTextOffset;            
-                       
+                       uint32                  fCommandLen;    // number of 
bytes in fCommand buffer
+                       uint32                  fCommandNul;    // index of the 
NUL byte in fCommand
+                       float                   fTextOffset;
+
                        // icon for associated program. Invalid if none 
available.
-                       BBitmap                 fBitmap; 
-                       
+                       BBitmap                 fBitmap;
+
                        char*                   fLastBitmapName;
-                       bool                    fBitmapValid;           
+                       bool                    fBitmapValid;
                        uint32                  fKey;
                        int32                   
fMetaCellStateIndex[NUM_META_COLUMNS];
                        BPoint                  fCursorPt1;
@@ -112,5 +114,5 @@ private:
        static  const char*             sCommandName;
 };
 
-#endif
 
+#endif // SHORTCUTS_SPEC_H
diff --git a/src/preferences/shortcuts/ShortcutsWindow.cpp 
b/src/preferences/shortcuts/ShortcutsWindow.cpp
index dd28039..953daaa 100644
--- a/src/preferences/shortcuts/ShortcutsWindow.cpp
+++ b/src/preferences/shortcuts/ShortcutsWindow.cpp
@@ -1,5 +1,6 @@
 /*
- * Copyright 1999-2010 Haiku Inc. All rights reserved.
+ * Copyright 1999-2009 Jeremy Friesner
+ * Copyright 2009-2010 Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -50,14 +51,14 @@
 #define MAX_WIDTH 10000
 #define MAX_HEIGHT 10000
        // SetSizeLimits does not provide a mechanism for specifying an
-       // unrestricted maximum.  10,000 seems to be the most common value used
+       // unrestricted maximum. 10,000 seems to be the most common value used
        // in other Haiku system applications.
 
 #define WINDOW_SETTINGS_FILE_NAME "Shortcuts_window_settings"
        // Because the "shortcuts_settings" file (SHORTCUTS_SETTING_FILE_NAME) 
is
        // already used as a communications method between this configurator and
        // the "shortcut_catcher" input_server filter, it should not be 
overloaded
-       // with window position information.  Instead, a separate file is used.
+       // with window position information, instead, a separate file is used.
 
 #undef B_TRANSLATION_CONTEXT
 #define B_TRANSLATION_CONTEXT "ShortcutsWindow"
@@ -66,18 +67,18 @@
 #define WARNING "Shortcuts warning"
 
 
-// Creates a pop-up-menu that reflects the possible states of the specified 
+// Creates a pop-up-menu that reflects the possible states of the specified
 // meta-key.
 static BPopUpMenu*
-CreateMetaPopUp(int col)
+CreateMetaPopUp(int column)
 {
-       MetaKeyStateMap& map = GetNthKeyMap(col);
-       BPopUpMenu * popup = new BPopUpMenu(NULL, false);
-       int numStates = map.GetNumStates();
-       
-       for (int i = 0; i < numStates; i++) 
+       MetaKeyStateMap& map = GetNthKeyMap(column);
+       BPopUpMenu* popup = new BPopUpMenu(NULL, false);
+       int stateCount = map.GetNumStates();
+
+       for (int i = 0; i < stateCount; i++)
                popup->AddItem(new BMenuItem(map.GetNthStateDesc(i), NULL));
-       
+
        return popup;
 }
 
@@ -90,10 +91,10 @@ CreateKeysPopUp()
        int numKeys = GetNumKeyIndices();
        for (int i = 0; i < numKeys; i++) {
                const char* next = GetKeyName(i);
-               
-               if (next) 
+               if (next != NULL)
                        popup->AddItem(new BMenuItem(next, NULL));
        }
+
        return popup;
 }
 
@@ -102,14 +103,14 @@ ShortcutsWindow::ShortcutsWindow()
        :
        BWindow(BRect(0, 0, 0, 0), B_TRANSLATE_SYSTEM_NAME("Shortcuts"),
                B_TITLED_WINDOW, 0L),
-       fSavePanel(NULL), 
-       fOpenPanel(NULL), 
-       fSelectPanel(NULL), 
-       fKeySetModified(false),                 
+       fSavePanel(NULL),
+       fOpenPanel(NULL),
+       fSelectPanel(NULL),
+       fKeySetModified(false),
        fLastOpenWasAppend(false)
 {
        ShortcutsSpec::InitializeMetaMaps();
-       
+
        float spacing = be_control_look->DefaultItemSpacing();
 
        BView* top = new BView(Bounds(), NULL, B_FOLLOW_ALL_SIDES, 0);
@@ -194,7 +195,7 @@ ShortcutsWindow::ShortcutsWindow()
        minListWidth += 323.0 + 1;
        minListWidth += B_V_SCROLL_BAR_WIDTH;
 
-       fColumnListView->SetSortFunction(ShortcutsSpec::MyCompare);
+       fColumnListView->SetSortFunction(ShortcutsSpec::CLVListItemCompare);
        top->AddChild(containerView);
 
        fColumnListView->SetSelectionMessage(new 
BMessage(HOTKEY_ITEM_SELECTED));
@@ -250,19 +251,20 @@ ShortcutsWindow::ShortcutsWindow()
                // is a behind-the-scenes file that the user will never see or
                // interact with.
                BFile windowSettingsFile(&windowSettingsRef, B_READ_ONLY);
-               BMessage loadMsg;
-               if (loadMsg.Unflatten(&windowSettingsFile) == B_OK)
-                       _LoadWindowSettings(loadMsg);
+               BMessage loadMessage;
+               if (loadMessage.Unflatten(&windowSettingsFile) == B_OK)
+                       _LoadWindowSettings(loadMessage);
        }
 
        entry_ref keySetRef;
        if (_GetSettingsFile(&keySetRef)) {
-               BMessage msg(B_REFS_RECEIVED);
-               msg.AddRef("refs", &keySetRef);
-               msg.AddString("startupRef", "please");
-               PostMessage(&msg);
-                       // Tell ourselves to load this file if it exists.
+               BMessage message(B_REFS_RECEIVED);
+               message.AddRef("refs", &keySetRef);
+               message.AddString("startupRef", "please");
+               PostMessage(&message);
+                       // tell ourselves to load this file if it exists
        }
+
        Show();
 }
 
@@ -279,10 +281,10 @@ ShortcutsWindow::~ShortcutsWindow()
 bool
 ShortcutsWindow::QuitRequested()
 {
-       bool ret = true;
+       bool result = true;
 
        if (fKeySetModified) {
-               BAlert* alert = new BAlert(WARNING, 
+               BAlert* alert = new BAlert(WARNING,
                        B_TRANSLATE("Save changes before closing?"),
                        B_TRANSLATE("Cancel"), B_TRANSLATE("Don't save"),
                        B_TRANSLATE("Save"));
@@ -291,11 +293,11 @@ ShortcutsWindow::QuitRequested()
                alert->SetShortcut(2, 's');
                switch(alert->Go()) {
                        case 0:
-                               ret = false;
+                               result = false;
                                break;
 
                        case 1:
-                               ret = true;
+                               result = true;
                                break;
 
                        case 2:
@@ -309,17 +311,17 @@ ShortcutsWindow::QuitRequested()
                                                        B_TRANSLATE("Oh no"));
                                                alert->SetFlags(alert->Flags() 
| B_CLOSE_ON_ESCAPE);
                                                alert->Go();
-                                               ret = true; //quit anyway
+                                               result = true; //quit anyway
                                        }
                                } else {
                                        PostMessage(SAVE_KEYSET);
-                                       ret = false;
+                                       result = false;
                                }
                                break;
                }
        }
 
-       if (ret) {
+       if (result) {
                fColumnListView->DeselectAll();
 
                // Save the window position.
@@ -329,8 +331,8 @@ ShortcutsWindow::QuitRequested()
                        _SaveWindowSettings(entry);
                }
        }
-       
-       return ret;
+
+       return result;
 }
 
 
@@ -358,41 +360,43 @@ ShortcutsWindow::_SaveKeySet(BEntry& saveEntry)
        if (saveTo.InitCheck() != B_OK)
                return false;
 
-       BMessage saveMsg;
+       BMessage saveMessage;
        for (int i = 0; i < fColumnListView->CountItems(); i++) {
                BMessage next;
-               if 
(((ShortcutsSpec*)fColumnListView->ItemAt(i))->Archive(&next) 
-                       == B_OK)
-                       saveMsg.AddMessage("spec", &next);
-               else
+               if (((ShortcutsSpec*)fColumnListView->ItemAt(i))->Archive(&next)
+                               == B_OK) {
+                       saveMessage.AddMessage("spec", &next);
+               } else
                        printf("Error archiving ShortcutsSpec #%i!\n", i);
        }
-       
-       bool ret = (saveMsg.Flatten(&saveTo) == B_OK);
-       
-       if (ret) {
+
+       bool result = (saveMessage.Flatten(&saveTo) == B_OK);
+
+       if (result) {
                fKeySetModified = false;
                fSaveButton->SetEnabled(false);
        }
 
-       return ret;
+       return result;
 }
 
 
 // Appends new entries from the file specified in the "spec" entry of 
-// (loadMsg). Returns true iff successful.
+// (loadMessage). Returns true iff successful.
 bool
-ShortcutsWindow::_LoadKeySet(const BMessage& loadMsg)
+ShortcutsWindow::_LoadKeySet(const BMessage& loadMessage)
 {
        int i = 0;
-       BMessage msg;
-       while (loadMsg.FindMessage("spec", i++, &msg) == B_OK) {
-               ShortcutsSpec* spec = 
(ShortcutsSpec*)ShortcutsSpec::Instantiate(&msg);
-               if (spec != NULL) 
+       BMessage message;
+       while (loadMessage.FindMessage("spec", i++, &message) == B_OK) {
+               ShortcutsSpec* spec
+                       = (ShortcutsSpec*)ShortcutsSpec::Instantiate(&message);
+               if (spec != NULL)
                        fColumnListView->AddItem(spec);
-               else 
+               else
                        printf("_LoadKeySet: Error parsing spec!\n");
        }
+
        return true;
 }
 
@@ -432,20 +436,20 @@ ShortcutsWindow::_SaveWindowSettings(BEntry& saveEntry)
 }
 
 
-// Loads the application settings file from (loadMsg) and resizes the interface
-// to match the previously saved settings.  Because this is a non-essential
-// file, errors are ignored when loading the settings.
+// Loads the application settings file from (loadMessage) and resizes
+// the interface to match the previously saved settings. Because this
+// is a non-essential file, errors are ignored when loading the settings.
 void
-ShortcutsWindow::_LoadWindowSettings(const BMessage& loadMsg)
+ShortcutsWindow::_LoadWindowSettings(const BMessage& loadMessage)
 {
        BRect frame;
-       if (loadMsg.FindRect("window frame", &frame) == B_OK) {
-               // Ensure the frame does not resize below the computed minimum.
+       if (loadMessage.FindRect("window frame", &frame) == B_OK) {
+               // ensure the frame does not resize below the computed minimum.
                float width = max_c(Bounds().right, frame.right - frame.left);
                float height = max_c(Bounds().bottom, frame.bottom - frame.top);
                ResizeTo(width, height);
 
-               // Ensure the frame is not placed outside of the screen.
+               // ensure the frame is not placed outside of the screen.
                BScreen screen(this);
                float left = min_c(screen.Frame().right - width, frame.left);
                float top = min_c(screen.Frame().bottom - height, frame.top);
@@ -455,13 +459,13 @@ ShortcutsWindow::_LoadWindowSettings(const BMessage& 
loadMsg)
        for (int i = 0; i < fColumnListView->CountColumns(); i++) {
                CLVColumn* column = fColumnListView->ColumnAt(i);
                float columnWidth;
-               if (loadMsg.FindFloat("column width", i, &columnWidth) == B_OK)
+               if (loadMessage.FindFloat("column width", i, &columnWidth) == 
B_OK)
                        column->SetWidth(max_c(column->Width(), columnWidth));
        }
 }
 
 
-// Creates a new entry and adds it to the GUI. (defaultCommand) will be the 
+// Creates a new entry and adds it to the GUI. (defaultCommand) will be the
 // text in the entry, or NULL if no text is desired.
 void
 ShortcutsWindow::_AddNewSpec(const char* defaultCommand)
@@ -476,7 +480,7 @@ ShortcutsWindow::_AddNewSpec(const char* defaultCommand)
 
                if (defaultCommand)
                        spec->SetCommand(defaultCommand);
-       } else 
+       } else
                spec = new ShortcutsSpec(defaultCommand ? defaultCommand : "");
 
        fColumnListView->AddItem(spec);
@@ -486,26 +490,27 @@ ShortcutsWindow::_AddNewSpec(const char* defaultCommand)
 
 
 void
-ShortcutsWindow::MessageReceived(BMessage* msg)
+ShortcutsWindow::MessageReceived(BMessage* message)
 {
-       switch(msg->what) {
-               case OPEN_KEYSET: 
-               case APPEND_KEYSET: 
-                       fLastOpenWasAppend = (msg->what == APPEND_KEYSET);
-                       if (fOpenPanel) 
+       switch(message->what) {
+               case OPEN_KEYSET:
+               case APPEND_KEYSET:
+                       fLastOpenWasAppend = (message->what == APPEND_KEYSET);
+                       if (fOpenPanel)
                                fOpenPanel->Show();
                        else {
-                               BMessenger m(this);
-                               fOpenPanel = new BFilePanel(B_OPEN_PANEL, &m, 
NULL, 0, false);
+                               BMessenger messenger(this);
+                               fOpenPanel = new BFilePanel(B_OPEN_PANEL, 
&messenger, NULL,
+                                       0, false);
                                fOpenPanel->Show();
                        }
                        fOpenPanel->SetButtonLabel(B_DEFAULT_BUTTON, 
fLastOpenWasAppend ? 
                                B_TRANSLATE("Append") : B_TRANSLATE("Open"));
                        break;
 
+               // send a message to myself, to get me to reload the settings 
file
                case REVERT_KEYSET:
                {
-                       // Send a message to myself, to get me to reload the 
settings file
                        fLastOpenWasAppend = false;
                        BMessage reload(B_REFS_RECEIVED);
                        entry_ref eref;
@@ -516,13 +521,13 @@ ShortcutsWindow::MessageReceived(BMessage* msg)
                        break;
                }
 
-               // Respond to drag-and-drop messages here
+               // respond to drag-and-drop messages here
                case B_SIMPLE_DATA:
                {
                        int i = 0;
 
                        entry_ref ref;
-                       while (msg->FindRef("refs", i++, &ref) == B_OK) {
+                       while (message->FindRef("refs", i++, &ref) == B_OK) {
                                BEntry entry(&ref);
                                if (entry.InitCheck() == B_OK) {
                                        BPath path(&entry);
@@ -538,13 +543,13 @@ ShortcutsWindow::MessageReceived(BMessage* msg)
                        break;
                }
 
-               // Respond to FileRequester's messages here
+               // respond to FileRequester's messages here
                case B_REFS_RECEIVED:
                {
                        // Find file ref
                        entry_ref ref;
-                       bool isStartMsg = msg->HasString("startupRef");
-                       if (msg->FindRef("refs", &ref) == B_OK) {
+                       bool isStartMsg = message->HasString("startupRef");
+                       if (message->FindRef("refs", &ref) == B_OK) {
                                // load the file into (fileMsg)
                                BMessage fileMsg;
                                {
@@ -579,7 +584,7 @@ ShortcutsWindow::MessageReceived(BMessage* msg)
                                        if (isStartMsg) fLastSaved = 
BEntry(&ref);
                                        fSaveButton->SetEnabled(isStartMsg == 
false);
 
-                                       // If we just loaded in the Shortcuts 
settings file, then 
+                                       // If we just loaded in the Shortcuts 
settings file, then
                                        // no need to tell the user to save on 
exit.
                                        entry_ref eref;
                                        _GetSettingsFile(&eref);
@@ -596,22 +601,20 @@ ShortcutsWindow::MessageReceived(BMessage* msg)
                        break;
                }
 
-               // These messages come from the pop-up menu of the Applications 
column
+               // these messages come from the pop-up menu of the Applications 
column
                case SELECT_APPLICATION:
                {
                        int csel = fColumnListView->CurrentSelection();
                        if (csel >= 0) {
                                entry_ref aref;
-                               if (msg->FindRef("refs", &aref) == B_OK) {
+                               if (message->FindRef("refs", &aref) == B_OK) {
                                        BEntry ent(&aref);
                                        if (ent.InitCheck() == B_OK) {
                                                BPath path;
-                                               if ((ent.GetPath(&path) == 
B_OK) 
-                                                       && (((ShortcutsSpec *)
-                                                       
fColumnListView->ItemAt(csel))->
-                                                       
ProcessColumnTextString(ShortcutsSpec::
-                                                       STRING_COLUMN_INDEX, 
path.Path()))) {
-                                                       
+                                               if ((ent.GetPath(&path) == B_OK)
+                                                       && 
(((ShortcutsSpec*)fColumnListView->ItemAt(csel))->
+                                                               
ProcessColumnTextString(ShortcutsSpec::STRING_COLUMN_INDEX,
+                                                                       
path.Path()))) {
                                                        
fColumnListView->InvalidateItem(csel);
                                                        _MarkKeySetModified();
                                                }
@@ -625,21 +628,23 @@ ShortcutsWindow::MessageReceived(BMessage* msg)
                {
                        bool showSaveError = false;
 
-                       const char * name;
+                       const char* name;
                        entry_ref entry;
-                       if ((msg->FindString("name", &name) == B_OK) 
-                               && (msg->FindRef("directory", &entry) == B_OK)) 
{
+                       if ((message->FindString("name", &name) == B_OK)
+                               && (message->FindRef("directory", &entry) == 
B_OK)) {
                                BDirectory dir(&entry);
                                BEntry saveTo(&dir, name, true);
-                               showSaveError = ((saveTo.InitCheck() != B_OK) 
-                               || (_SaveKeySet(saveTo) == false));
+                               showSaveError = ((saveTo.InitCheck() != B_OK)
+                                       || (_SaveKeySet(saveTo) == false));
                        } else if (fLastSaved.InitCheck() == B_OK) {
                                // We've saved this before, save over previous 
file.
                                showSaveError = (_SaveKeySet(fLastSaved) == 
false);
-                       } else PostMessage(SAVE_KEYSET_AS); // open the save 
requester...
+                       } else
+                               PostMessage(SAVE_KEYSET_AS);
+                                       // open the save requester...
 
                        if (showSaveError) {
-                               BAlert* alert = new BAlert(ERROR, 
+                               BAlert* alert = new BAlert(ERROR,
                                        B_TRANSLATE("Shortcuts wasn't able to 
save your keyset."), 
                                        B_TRANSLATE("OK"));
                                alert->SetFlags(alert->Flags() | 
B_CLOSE_ON_ESCAPE);
@@ -653,10 +658,10 @@ ShortcutsWindow::MessageReceived(BMessage* msg)
                        if (fSavePanel)
                                fSavePanel->Show();
                        else {
-                               BMessage msg(SAVE_KEYSET);
+                               BMessage message(SAVE_KEYSET);
                                BMessenger messenger(this);
-                               fSavePanel = new BFilePanel(B_SAVE_PANEL, 
&messenger, NULL, 0, 
-                                       false, &msg);
+                               fSavePanel = new BFilePanel(B_SAVE_PANEL, 
&messenger, NULL, 0,
+                                       false, &message);
                                fSavePanel->Show();
                        }
                        break;
@@ -698,7 +703,7 @@ ShortcutsWindow::MessageReceived(BMessage* msg)
                case HOTKEY_ITEM_SELECTED:
                {
                        int32 index = -1;
-                       msg->FindInt32("index", &index);
+                       message->FindInt32("index", &index);
                        bool validItem = (index >= 0);
                        fRemoveButton->SetEnabled(validItem);
                        break;
@@ -709,8 +714,8 @@ ShortcutsWindow::MessageReceived(BMessage* msg)
                {
                        int32 row, column;
 
-                       if ((msg->FindInt32("row", &row) == B_OK) 
-                               && (msg->FindInt32("column", &column) == B_OK)) 
{
+                       if ((message->FindInt32("row", &row) == B_OK)
+                               && (message->FindInt32("column", &column) == 
B_OK)) {
                                int32 key;
                                const char* bytes;
 
@@ -719,27 +724,27 @@ ShortcutsWindow::MessageReceived(BMessage* msg)
                                                fColumnListView->ItemAt(row);
                                        bool repaintNeeded = false; // default
 
-                                       if (msg->HasInt32("mouseClick")) {
+                                       if (message->HasInt32("mouseClick")) {
                                                repaintNeeded = 
item->ProcessColumnMouseClick(column);
-                                       } else if ((msg->FindString("bytes", 
&bytes) == B_OK)
-                                               && (msg->FindInt32("key", &key) 
== B_OK)) {
+                                       } else if 
((message->FindString("bytes", &bytes) == B_OK)
+                                               && (message->FindInt32("key", 
&key) == B_OK)) {
                                                repaintNeeded = 
item->ProcessColumnKeyStroke(column, 
                                                        bytes, key);
-                                       } else if 
(msg->FindInt32("unmappedkey", &key) == 
+                                       } else if 
(message->FindInt32("unmappedkey", &key) ==
                                                B_OK) {
                                                repaintNeeded = ((column == 
item->KEY_COLUMN_INDEX) 
                                                        && ((key > 0xFF) || 
(GetKeyName(key) != NULL)) 
                                                        && 
(item->ProcessColumnKeyStroke(column, NULL, 
                                                        key)));
-                                       } else if (msg->FindString("text", 
&bytes) == B_OK) {
+                                       } else if (message->FindString("text", 
&bytes) == B_OK) {
                                                if ((bytes[0] == 
'(')&&(bytes[1] == 'C')) {
                                                        if (fSelectPanel)
                                                                
fSelectPanel->Show();
                                                        else {
-                                                               BMessage 
msg(SELECT_APPLICATION);
+                                                               BMessage 
message(SELECT_APPLICATION);
                                                                BMessenger 
m(this);
                                                                fSelectPanel = 
new BFilePanel(B_OPEN_PANEL, &m,
-                                                                       NULL, 
0, false, &msg);
+                                                                       NULL, 
0, false, &message);
                                                                
fSelectPanel->Show();
                                                        }
                                                        
fSelectPanel->SetButtonLabel(B_DEFAULT_BUTTON, 
@@ -760,7 +765,7 @@ ShortcutsWindow::MessageReceived(BMessage* msg)
                }
 
                default:
-                       BWindow::MessageReceived(msg);
+                       BWindow::MessageReceived(message);
                        break;
        }
 }
@@ -788,9 +793,9 @@ ShortcutsWindow::Quit()
 
 
 void
-ShortcutsWindow::DispatchMessage(BMessage* msg, BHandler* handler)
+ShortcutsWindow::DispatchMessage(BMessage* message, BHandler* handler)
 {
-       switch(msg->what) {
+       switch(message->what) {
                case B_COPY:
                case B_CUT:
                        if (be_clipboard->Lock()) {
@@ -808,7 +813,7 @@ ShortcutsWindow::DispatchMessage(BMessage* msg, BHandler* 
handler)
                                                        
strlen(spec->GetCellText(column)));
                                                be_clipboard->Commit();
                                                
-                                               if (msg->what == B_CUT) {
+                                               if (message->what == B_CUT) {
                                                        
spec->ProcessColumnTextString(column, "");
                                                        _MarkKeySetModified();
                                                        
fColumnListView->InvalidateItem(row);
@@ -824,13 +829,13 @@ ShortcutsWindow::DispatchMessage(BMessage* msg, BHandler* 
handler)
                                BMessage* data = be_clipboard->Data();
                                const char* text;
                                ssize_t textLen;
-                               if (data->FindData("text/plain", B_MIME_TYPE, 
(const void**) 
+                               if (data->FindData("text/plain", B_MIME_TYPE, 
(const void**)
                                        &text, &textLen) == B_OK) {
-                                       int32 row = 
fColumnListView->CurrentSelection(); 
+                                       int32 row = 
fColumnListView->CurrentSelection();
                                        int32 column = 
fColumnListView->GetSelectedColumn();
                                        if ((row >= 0) 
                                                && (column == 
ShortcutsSpec::STRING_COLUMN_INDEX)) {
-                                               ShortcutsSpec* spec = 
(ShortcutsSpec*) 
+                                               ShortcutsSpec* spec = 
(ShortcutsSpec*)
                                                        
fColumnListView->ItemAt(row);
                                                if (spec) {
                                                        for (ssize_t i = 0; i < 
textLen; i++) {
@@ -847,8 +852,7 @@ ShortcutsWindow::DispatchMessage(BMessage* msg, BHandler* 
handler)
                        break;
                
                default:
-                       BWindow::DispatchMessage(msg, handler);
+                       BWindow::DispatchMessage(message, handler);
                        break;
        }
 }
-
diff --git a/src/preferences/shortcuts/ShortcutsWindow.h 
b/src/preferences/shortcuts/ShortcutsWindow.h
index db12b0d..792ec2d 100644
--- a/src/preferences/shortcuts/ShortcutsWindow.h
+++ b/src/preferences/shortcuts/ShortcutsWindow.h
@@ -1,12 +1,13 @@
 /*
- * Copyright 1999-2009 Haiku Inc. All rights reserved.
+ * Copyright 1999-2009 Jeremy Friesner
+ * Copyright 2009-2010 Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
  *             Jeremy Friesner
  */
-#ifndef ShortcutsWindow_h
-#define ShortcutsWindow_h
+#ifndef SHORTCUTS_WINDOW_H
+#define SHORTCUTS_WINDOW_H
 
 
 #include <Entry.h>
@@ -14,6 +15,7 @@
 
 #include "ColumnListView.h"
 
+
 class BButton;
 class BFilePanel;
 class BMessage;
@@ -24,61 +26,66 @@ public:
                                                        ShortcutsWindow();
                                                        ~ShortcutsWindow();
 
-       virtual void                    DispatchMessage(BMessage* msg, 
BHandler* handler);
-       virtual void                    Quit();
-       virtual void                    MessageReceived(BMessage* msg);
-       virtual bool                    QuitRequested();
+       virtual void                    DispatchMessage(BMessage* message,
+                                                               BHandler* 
handler);
+       virtual void                    Quit();
+       virtual void                    MessageReceived(BMessage* message);
+       virtual bool                    QuitRequested();
 
        // BMessage 'what' codes, representing commands understood by this 
Window.
        enum {
                ADD_HOTKEY_ITEM = 'SpKy',       // Add a new hotkey entry to 
the GUI list.
                REMOVE_HOTKEY_ITEM,                     // Remove a hotkey 
entry from the GUI list.
-               HOTKEY_ITEM_SELECTED,           // Give the "focus bar" to the 
specified 
+               HOTKEY_ITEM_SELECTED,           // Give the "focus bar" to the 
specified
                                                                        // 
entry.
-               HOTKEY_ITEM_MODIFIED,           // Update the state of an entry 
to reflect 
+               HOTKEY_ITEM_MODIFIED,           // Update the state of an entry 
to reflect
                                                                        // 
user's changes.
-               OPEN_KEYSET,                            // Bring up a File 
requester to load new 
+               OPEN_KEYSET,                            // Bring up a File 
requester to load new
                                                                        // 
settings.
-               APPEND_KEYSET,                          // Bring up a File 
requester to append 
+               APPEND_KEYSET,                          // Bring up a File 
requester to append
                                                                        // 
settings.
-               REVERT_KEYSET,                          // Dump the current 
state and re-read 
+               REVERT_KEYSET,                          // Dump the current 
state and re-read
                                                                        // 
settings from disk.
                SAVE_KEYSET,                            // Save the current 
settings to disk
-               SAVE_KEYSET_AS,                         // Bring up a File 
requester to save 
+               SAVE_KEYSET_AS,                         // Bring up a File 
requester to save
                                                                        // 
current settings.
-               SELECT_APPLICATION,                     // Set the current 
entry to point to the 
+               SELECT_APPLICATION,                     // Set the current 
entry to point to the
                                                                        // 
given file.
        };
+
 private:
                        BMenuItem*                      
_CreateActuatorPresetMenuItem(const char* label)
                                                                        const;
                        void                            _AddNewSpec(const char* 
defaultCommand);
                        void                            _MarkKeySetModified();
-                       bool                            _LoadKeySet(const 
BMessage& loadMsg);
+                       bool                            _LoadKeySet(const 
BMessage& loadMessage);
                        bool                            _SaveKeySet(BEntry& 
saveEntry);
                        bool                            
_GetSettingsFile(entry_ref* ref);
-                       void                            
_LoadWindowSettings(const BMessage& loadMsg);
+                       void                            _LoadWindowSettings(
+                                                                       const 
BMessage& loadMessage);
                        void                            
_SaveWindowSettings(BEntry& saveEntry);
                        bool                            
_GetWindowSettingsFile(entry_ref* ref);
 
-                       BButton*                fAddButton;
-                       BButton*                fRemoveButton;
-                       BButton*                fSaveButton;
-                       ColumnListView*         fColumnListView;
-                       BFilePanel*             fSavePanel;             // for 
saving settings
-                       BFilePanel*             fOpenPanel;             // for 
loading settings
-                       BFilePanel*             fSelectPanel;   // for 
selecting apps to launch
-                       
+                       BButton*                        fAddButton;
+                       BButton*                        fRemoveButton;
+                       BButton*                        fSaveButton;
+                       ColumnListView*         fColumnListView;
+                       BFilePanel*                     fSavePanel;
+                               // for saving settings
+                       BFilePanel*                     fOpenPanel;
+                               // for loading settings
+                       BFilePanel*                     fSelectPanel;
+                               // for selecting apps to launch
+
                        // Points to the settings file to save to
-                       BEntry                          fLastSaved;
-                       
+                       BEntry                          fLastSaved;
+
                        // true iff changes were made since last load or save
                        bool                            fKeySetModified;
-                       
+
                        // true iff the file-requester's ref should be appended 
to current
-                       bool                            fLastOpenWasAppend;
+                       bool                            fLastOpenWasAppend;
 };
 
 
-#endif
-
+#endif // SHORTCUTS_WINDOW_H
diff --git a/src/preferences/shortcuts/clv/CLVColumn.cpp 
b/src/preferences/shortcuts/clv/CLVColumn.cpp
index ed88dc2..1b3e635 100644
--- a/src/preferences/shortcuts/clv/CLVColumn.cpp
+++ b/src/preferences/shortcuts/clv/CLVColumn.cpp
@@ -1,211 +1,228 @@
-//Column list header source file
+/*
+ * Copyright 1999-2009 Jeremy Friesner
+ * Copyright 2009-2014 Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Jeremy Friesner
+ *             John Scipione, jscipione@xxxxxxxxx
+ */
 
 
-//******************************************************************************************************
-//**** PROJECT HEADER FILES
-//******************************************************************************************************
 #define CLVColumn_CPP
+
 #include <string.h>
+
 #include "CLVColumn.h"
 #include "ColumnListView.h"
 #include "CLVColumnLabelView.h"
 
 
-//******************************************************************************************************
-//**** CLVColumn CLASS DEFINITION
-//******************************************************************************************************
-CLVColumn::CLVColumn(const char* label,BPopUpMenu * popup,float width,uint32 
flags,float min_width)
+CLVColumn::CLVColumn(const char* label, BPopUpMenu* popup, float width,
+       uint32 flags, float minWidth)
 {
-    fPopup = popup;
+       fPopup = popup;
 
-       if(flags & CLV_EXPANDER)
-       {
+       if (flags & CLV_EXPANDER) {
                label = NULL;
                width = 20.0;
-               min_width = 20.0;
-               flags &= CLV_NOT_MOVABLE | CLV_LOCK_AT_BEGINNING | CLV_HIDDEN | 
CLV_LOCK_WITH_RIGHT;
+               minWidth = 20.0;
+               flags &= CLV_NOT_MOVABLE | CLV_LOCK_AT_BEGINNING | CLV_HIDDEN
+                       | CLV_LOCK_WITH_RIGHT;
                flags |= CLV_EXPANDER | CLV_NOT_RESIZABLE | 
CLV_MERGE_WITH_RIGHT;
        }
-       if(min_width < 4.0)
-               min_width = 4.0;
-       if(width < min_width)
-               width = min_width;
-       if(label)
-       {
-               fLabel = new char[strlen(label)+1];
-               strcpy((char*)fLabel,label);
-       }
-       else
+
+       if (minWidth < 4.0)
+               minWidth = 4.0;
+
+       if (width < minWidth)
+               width = minWidth;
+
+       if (label != NULL) {
+               fLabel = new char[strlen(label) + 1];
+               strcpy((char*)fLabel, label);
+       } else
                fLabel = NULL;
+
        fWidth = width;
-       fMinWidth = min_width;
+       fMinWidth = minWidth;
        fFlags = flags;
        fPushedByExpander = false;
        fParent = NULL;
-       fSortMode = NoSort;
+       fSortMode = SORT_MODE_NONE;
 }
 
 
 CLVColumn::~CLVColumn()
 {
-       delete [] fLabel;
-       if(fParent) fParent->RemoveColumn(this);
-    delete fPopup;
+       delete[] fLabel;
+       if (fParent != NULL)
+               fParent->RemoveColumn(this);
+
+       delete fPopup;
 }
 
 
-float CLVColumn::Width() const
+float
+CLVColumn::Width() const
 {
        return fWidth;
 }
 
 
-void CLVColumn::SetWidth(float width)
+void
+CLVColumn::SetWidth(float width)
 {
        if(width < fMinWidth)
                width = fMinWidth;
-       if(width != fWidth)
-       {
-               float OldWidth = fWidth;
+
+       if(width != fWidth) {
+               float oldWidth = fWidth;
                fWidth = width;
-               if(IsShown() && fParent)
-               {
-                       BWindow* ParentWindow = fParent->Window();
-                       if(ParentWindow)
-                               ParentWindow->Lock();
-                       //Figure out the area after this column to scroll
+               if (IsShown() && fParent != NULL) {
+                       BWindow* parentWindow = fParent->Window();
+                       if (parentWindow != NULL)
+                               parentWindow->Lock();
+
+                       // figure out the area after this column to scroll
                        BRect ColumnViewBounds = 
fParent->fColumnLabelView->Bounds();
                        BRect MainViewBounds = fParent->Bounds();
-                       BRect SourceArea = ColumnViewBounds;
-                       SourceArea.left = fColumnEnd+1.0;
-                       BRect DestArea = SourceArea;
-                       float Delta = width-OldWidth;
-                       DestArea.left += Delta;
-                       DestArea.right += Delta;
+                       BRect sourceArea = ColumnViewBounds;
+                       sourceArea.left = fColumnEnd + 1.0;
+                       BRect destArea = sourceArea;
+                       float delta = width-oldWidth;
+                       destArea.left += delta;
+                       destArea.right += delta;
                        float LimitShift;
-                       if(DestArea.right > ColumnViewBounds.right)
-                       {
-                               LimitShift = 
DestArea.right-ColumnViewBounds.right;
-                               DestArea.right -= LimitShift;
-                               SourceArea.right -= LimitShift;
-                       }
-                       if(DestArea.left < ColumnViewBounds.left)
-                       {
-                               LimitShift = ColumnViewBounds.left - 
DestArea.left;
-                               DestArea.left += LimitShift;
-                               SourceArea.left += LimitShift;
+                       if (destArea.right > ColumnViewBounds.right) {
+                               LimitShift = 
destArea.right-ColumnViewBounds.right;
+                               destArea.right -= LimitShift;
+                               sourceArea.right -= LimitShift;
                        }
-                       //Scroll the area that is being shifted
-                       if(ParentWindow)
-                               ParentWindow->UpdateIfNeeded();
-                       
fParent->fColumnLabelView->CopyBits(SourceArea,DestArea);
-                       SourceArea.top = MainViewBounds.top;
-                       SourceArea.bottom = MainViewBounds.bottom;
-                       DestArea.top = MainViewBounds.top;
-                       DestArea.bottom = MainViewBounds.bottom;
-                       fParent->CopyBits(SourceArea,DestArea);
-
-                       //Invalidate the region that got revealed
-                       DestArea = ColumnViewBounds;
-                       if(width > OldWidth)
-                       {
-                               DestArea.left = fColumnEnd+1.0;
-                               DestArea.right = fColumnEnd+Delta;
+                       if (destArea.left < ColumnViewBounds.left) {
+                               LimitShift = ColumnViewBounds.left - 
destArea.left;
+                               destArea.left += LimitShift;
+                               sourceArea.left += LimitShift;
                        }
-                       else
-                       {
-                               DestArea.left = 
ColumnViewBounds.right+Delta+1.0;
-                               DestArea.right = ColumnViewBounds.right;
+
+                       // scroll the area that is being shifted
+                       if(parentWindow)
+                               parentWindow->UpdateIfNeeded();
+
+                       fParent->fColumnLabelView->CopyBits(sourceArea, 
destArea);
+                       sourceArea.top = MainViewBounds.top;
+                       sourceArea.bottom = MainViewBounds.bottom;
+                       destArea.top = MainViewBounds.top;
+                       destArea.bottom = MainViewBounds.bottom;
+                       fParent->CopyBits(sourceArea, destArea);
+
+                       // invalidate the region that got revealed
+                       destArea = ColumnViewBounds;
+                       if (width > oldWidth) {
+                               destArea.left = fColumnEnd + 1.0;
+                               destArea.right = fColumnEnd + delta;
+                       } else {
+                               destArea.left = ColumnViewBounds.right + delta 
+ 1.0;
+                               destArea.right = ColumnViewBounds.right;
                        }
-                       fParent->fColumnLabelView->Invalidate(DestArea);
-                       DestArea.top = MainViewBounds.top;
-                       DestArea.bottom = MainViewBounds.bottom;
-                       fParent->Invalidate(DestArea);
-
-                       //Invalidate the old or new resize handle as necessary
-                       DestArea = ColumnViewBounds;
-                       if(width > OldWidth)
-                               DestArea.left = fColumnEnd;
+                       fParent->fColumnLabelView->Invalidate(destArea);
+                       destArea.top = MainViewBounds.top;
+                       destArea.bottom = MainViewBounds.bottom;
+                       fParent->Invalidate(destArea);
+
+                       // invalidate the old or new resize handle as necessary
+                       destArea = ColumnViewBounds;
+                       if (width > oldWidth)
+                               destArea.left = fColumnEnd;
                        else
-                               DestArea.left = fColumnEnd + Delta;
-                       DestArea.right = DestArea.left;
-                       fParent->fColumnLabelView->Invalidate(DestArea);
+                               destArea.left = fColumnEnd + delta;
+
+                       destArea.right = destArea.left;
+                       fParent->fColumnLabelView->Invalidate(destArea);
 
-                       //Update the column sizes, positions and group positions
-                       fParent->UpdateColumnSizesDataRectSizeScrollBars();
+                       // update the column sizes, positions and group 
positions
+                       fParent->ShiftDragGroup();
                        fParent->fColumnLabelView->UpdateDragGroups();
-                       if(ParentWindow)
-                               ParentWindow->Unlock();
+                       if(parentWindow)
+                               parentWindow->Unlock();
+               }
+               if (fParent != NULL) {
+                       
fParent->ColumnWidthChanged(fParent->fColumnList.IndexOf(this),
+                               fWidth);
                }
-               if(fParent)
-                       
fParent->ColumnWidthChanged(fParent->fColumnList.IndexOf(this),fWidth);
        }
 }
 
 
-uint32 CLVColumn::Flags() const
+uint32
+CLVColumn::Flags() const
 {
        return fFlags;
 }
 
 
-bool CLVColumn::IsShown() const
+bool
+CLVColumn::IsShown() const
 {
-       if(fFlags & CLV_HIDDEN)
+       if ((fFlags & CLV_HIDDEN) != 0)
                return false;
        else
                return true;
 }
 
 
-void CLVColumn::SetShown(bool Shown)
+void
+CLVColumn::SetShown(bool show)
 {
        bool shown = IsShown();
-       if(shown != Shown)
-       {
-               if(Shown)
+       if (shown != show) {
+               if (show)
                        fFlags &= 0xFFFFFFFF^CLV_HIDDEN;
                else
                        fFlags |= CLV_HIDDEN;
-               if(fParent)
-               {
-                       float UpdateLeft = fColumnBegin;
-                       BWindow* ParentWindow = fParent->Window();
-                       if(ParentWindow)
-                               ParentWindow->Lock();
-                       fParent->UpdateColumnSizesDataRectSizeScrollBars();
+
+               if (fParent != NULL) {
+                       float updateLeft = fColumnBegin;
+                       BWindow* parentWindow = fParent->Window();
+                       if (parentWindow != NULL)
+                               parentWindow->Lock();
+
+                       fParent->ShiftDragGroup();
                        fParent->fColumnLabelView->UpdateDragGroups();
-                       if(Shown)
-                               UpdateLeft = fColumnBegin;
-                       BRect Area = fParent->fColumnLabelView->Bounds();
-                       Area.left = UpdateLeft;
-                       fParent->fColumnLabelView->Invalidate(Area);
-                       Area = fParent->Bounds();
-                       Area.left = UpdateLeft;
-                       fParent->Invalidate(Area);
-                       if(fFlags & CLV_EXPANDER)
-                       {
-                               if(!Shown)
+                       if (show)
+                               updateLeft = fColumnBegin;
+
+                       BRect area = fParent->fColumnLabelView->Bounds();
+                       area.left = updateLeft;
+                       fParent->fColumnLabelView->Invalidate(area);
+                       area = fParent->Bounds();
+                       area.left = updateLeft;
+                       fParent->Invalidate(area);
+                       if ((fFlags & CLV_EXPANDER) != 0) {
+                               if (!show)
                                        fParent->fExpanderColumn = -1;
                                else
                                        fParent->fExpanderColumn = 
fParent->IndexOfColumn(this);
                        }
-                       if(ParentWindow)
-                               ParentWindow->Unlock();
+                       if (parentWindow != NULL)
+                               parentWindow->Unlock();
                }
        }
 }
 
 
-CLVSortMode CLVColumn::SortMode() const
+CLVSortMode
+CLVColumn::SortMode() const
 {
        return fSortMode;
 }
 
-void CLVColumn::SetSortMode(CLVSortMode mode)
+
+void
+CLVColumn::SetSortMode(CLVSortMode mode)
 {
-       if(fParent)
-               fParent->SetSortMode(fParent->IndexOfColumn(this),mode);
+       if (fParent != NULL)
+               fParent->SetSortMode(fParent->IndexOfColumn(this), mode);
        else
                fSortMode = mode;
 }
diff --git a/src/preferences/shortcuts/clv/CLVColumn.h 
b/src/preferences/shortcuts/clv/CLVColumn.h
index 89e809d..2b77288 100644
--- a/src/preferences/shortcuts/clv/CLVColumn.h
+++ b/src/preferences/shortcuts/clv/CLVColumn.h
@@ -1,107 +1,118 @@
-#ifndef CLVColumn_h
-#define CLVColumn_h
+/*
+ * Copyright 1999-2009 Jeremy Friesner
+ * Copyright 2009-2014 Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Jeremy Friesner
+ *             John Scipione, jscipione@xxxxxxxxx
+ */
+#ifndef CLV_COLUMN_H
+#define CLV_COLUMN_H
+
 
 #include <support/SupportDefs.h>
 #include <interface/PopUpMenu.h>
 
-//******************************************************************************************************
-//**** PROJECT HEADER FILES AND CLASS NAME DECLARATIONS
-//******************************************************************************************************
+
+// flags
+enum {
+       CLV_SORT_KEYABLE =                      0x00000001,
+               // Can be used as the sorting key
+       CLV_NOT_MOVABLE =                       0x00000002,
+               // Column can't be moved by user
+       CLV_NOT_RESIZABLE =                     0x00000004,
+               // Column can't be resized by user
+       CLV_LOCK_AT_BEGINNING =         0x00000008,
+               // Movable columns may not be placed or moved by the user
+               // into a position before this one
+       CLV_LOCK_AT_END =                       0x00000010,
+               // Movable columns may not be placed or moved by the user
+               // into a position after this one
+       CLV_HIDDEN =                            0x00000020,
+               // This column is hidden initially
+       CLV_MERGE_WITH_RIGHT =          0x00000040,
+               // Merge this column label with the one that follows it.
+       CLV_LOCK_WITH_RIGHT =           0x00000080,
+               // Lock this column to the one that follows it such that
+               // if the column to the right is moved by the user, this
+               // one will move with it and vice versa
+       CLV_EXPANDER =                          0x00000100,
+               // Column contains an expander. You may only use one
+               // expander in a ColumnListView, and an expander may not be
+               // added to a non-hierarchal ColumnListView.  It may not
+               // have a label.  Its width is automatically set to 20.0.
+               // The only flags that affect it are CLV_NOT_MOVABLE,
+               // CLV_LOCK_AT_BEGINNING, CLV_NOT_SHOWN and
+               // CLV_LOCK_WITH_RIGHT.  The others are set for you:
+               // CLV_NOT_RESIZABLE | CLV_MERGE_WITH_RIGHT
+       CLV_PUSH_PASS =                         0x00000200
+               // Causes this column, if pushed by an expander to the
+               // left, to pass that push on and also push the next
+               // column to the right.
+};
+
+enum CLVSortMode {
+       SORT_MODE_ASCENDING,
+       SORT_MODE_DESCENDING,
+       SORT_MODE_NONE
+};
+
+
 class ColumnListView;
 class CLVColumn;
 class CLVListItem;
 
 
-//******************************************************************************************************
-//**** CONSTANTS
-//******************************************************************************************************
-//Flags
-enum
-{
-       CLV_SORT_KEYABLE =                      0x00000001,             //Can 
be used as the sorting key
-       CLV_NOT_MOVABLE =                       0x00000002,             
//Column can't be moved by user
-       CLV_NOT_RESIZABLE =                     0x00000004,             
//Column can't be resized by user
-       CLV_LOCK_AT_BEGINNING =         0x00000008,             //Movable 
columns may not be placed or moved by the user
-                                                                               
                //into a position before this one
-       CLV_LOCK_AT_END =                       0x00000010,             
//Movable columns may not be placed or moved by the user
-                                                                               
                //into a position after this one
-       CLV_HIDDEN =                            0x00000020,             //This 
column is hidden initially
-       CLV_MERGE_WITH_RIGHT =          0x00000040,             //Merge this 
column label with the one that follows it.
-       CLV_LOCK_WITH_RIGHT =           0x00000080,             //Lock this 
column to the one that follows it such that
-                                                                               
                //if the column to the right is moved by the user, this
-                                                                               
                //one will move with it and vice versa
-       CLV_EXPANDER =                          0x00000100,             
//Column contains an expander.  You may only use one
-                                                                               
                //expander in a ColumnListView, and an expander may not be
-                                                                               
                //added to a non-hierarchal ColumnListView.  It may not
-                                                                               
                //have a label.  Its width is automatically set to 20.0.
-                                                                               
                //The only flags that affect it are CLV_NOT_MOVABLE,
-                                                                               
                //CLV_LOCK_AT_BEGINNING, CLV_NOT_SHOWN and
-                                                                               
                //CLV_LOCK_WITH_RIGHT.  The others are set for you:
-                                                                               
                //CLV_NOT_RESIZABLE | CLV_MERGE_WITH_RIGHT
-       CLV_PUSH_PASS =                         0x00000200              
//Causes this column, if pushed by an expander to the
-                                                                               
                //left, to pass that push on and also push the next
-};                                                                             
                //column to the right.
-
-enum CLVSortMode
-{
-       Ascending,
-       Descending,
-       NoSort
-};
+class CLVColumn {
+public:
+                                                               CLVColumn(const 
char* label,
+                                                                       
BPopUpMenu* popup = NULL,
+                                                                       float 
width = 20.0, uint32 flags = 0L,
+                                                                       float 
min_width = 20.0);
+       virtual                                         ~CLVColumn();
 
+       // Archival stuff
+       /* Not implemented yet
+                                                               
CLVColumn(BMessage* archive);
+                                                               static 
CLVColumn* Instantiate(BMessage* data);
+       virtual status_t                        Archive(BMessage* data, bool 
deep = true) const;
+       */
 
-//******************************************************************************************************
-//**** ColumnListView CLASS DECLARATION
-//******************************************************************************************************
-class CLVColumn
-{
-       public:
-               //Constructor and destructor
-               CLVColumn(      const char* label,
-                           BPopUpMenu * popup = NULL,
-                                       float width = 20.0,
-                                       uint32 flags = 0L,
-                                       float min_width = 20.0);
-               virtual ~CLVColumn();
+       // Functions
+                       float                           Width() const;
+       virtual void                            SetWidth(float width);
+                       // Can be overridden to detect changes to the column 
width
+                       // however since you are probably overriding 
ColumnListView
+                       // and dealing with an array of columns anyway, it is
+                       // probably more useful to override
+                       // ColumnListView::ColumnWidthChanged to detect changes 
to
+                       // column widths
+                       uint32                          Flags() const;
+                       bool                            IsShown() const;
+                       void                            SetShown(bool show);
+                       CLVSortMode                     SortMode() const;
+                       void                            SetSortMode(CLVSortMode 
mode);
+                       const char*                     GetLabel() const { 
return fLabel; }
+                       BPopUpMenu*                     GetPopup() { return 
fPopup; }
 
-               //Archival stuff
-               /* Not implemented yet
-               CLVColumn(BMessage* archive);
-               static CLVColumn* Instantiate(BMessage* data);
-               virtual status_t Archive(BMessage* data, bool deep = true) 
const;
-               */
-
-               //Functions
-               float Width() const;
-               virtual void SetWidth(float width);     //Can be overridden to 
detect changes to the column width
-                                                                               
                //however since you are probably overriding
-                                                                               
                //ColumnListView and dealing with an array of columns
-                                                                               
                //anyway, it is probably more useful to override
-                                                                               
                //ColumnListView::ColumnWidthChanged to detect changes to
-                                                                               
                //column widths
-               uint32 Flags() const;
-               bool IsShown() const;
-               void SetShown(bool shown);
-               CLVSortMode SortMode() const;
-               void SetSortMode(CLVSortMode mode);
-        const char * GetLabel() const {return fLabel;}
-        BPopUpMenu * GetPopup() {return fPopup;}
-        
-       private:
+private:
                friend class ColumnListView;
                friend class CLVColumnLabelView;
                friend class CLVListItem;
 
-               const char *fLabel;
-               float fWidth;
-               float fMinWidth;
-               float fColumnBegin;
-               float fColumnEnd;
-               uint32 fFlags;
-               bool fPushedByExpander;
-               CLVSortMode fSortMode;
-               ColumnListView* fParent;
-               BPopUpMenu * fPopup;  // added by jaf
+                       const char*                     fLabel;
+                       float                           fWidth;
+                       float                           fMinWidth;
+                       float                           fColumnBegin;
+                       float                           fColumnEnd;
+                       uint32                          fFlags;
+                       bool                            fPushedByExpander;
+                       CLVSortMode                     fSortMode;
+                       ColumnListView*         fParent;
+                       BPopUpMenu*                     fPopup;
+                               // added by jaf
 };
 
-#endif
+
+#endif // CLV_COLUMN_H
diff --git a/src/preferences/shortcuts/clv/CLVColumnLabelView.cpp 
b/src/preferences/shortcuts/clv/CLVColumnLabelView.cpp
index e1ea8cc..3567bce 100644
--- a/src/preferences/shortcuts/clv/CLVColumnLabelView.cpp
+++ b/src/preferences/shortcuts/clv/CLVColumnLabelView.cpp
@@ -1,24 +1,30 @@
-//ColumnLabelView class source file
+/*
+ * Copyright 1999-2009 Jeremy Friesner
+ * Copyright 2009-2014 Haiku, Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             Jeremy Friesner
+ *             John Scipione, jscipione@xxxxxxxxx
+ */
 
 
-//******************************************************************************************************
-//**** PROJECT HEADER FILES
-//******************************************************************************************************
 #define CLVColumnLabelView_CPP
+
 #include "CLVColumnLabelView.h"
 #include "ColumnListView.h"
 #include "CLVColumn.h"
 #include "MouseWatcher.h"
 
 
-//******************************************************************************************************
-//**** FUNCTION DEFINITIONS
-//******************************************************************************************************
-CLVColumnLabelView::CLVColumnLabelView(BRect Bounds,ColumnListView* 
parent,const BFont* Font)
-: 
BView(Bounds,NULL,B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,B_WILL_DRAW|B_FRAME_EVENTS),
-fDragGroups(10)
+CLVColumnLabelView::CLVColumnLabelView(BRect frame, ColumnListView* parent,
+       const BFont* font)
+       :
+       BView(frame, NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
+               B_WILL_DRAW | B_FRAME_EVENTS),
+       fDragGroupsList(10)
 {
-       SetFont(Font);
+       SetFont(font);
        SetViewColor(BeBackgroundGrey);
        SetLowColor(BeBackgroundGrey);
        SetHighColor(Black);
@@ -27,726 +33,778 @@ fDragGroups(10)
        fColumnClicked = NULL;
        fColumnDragging = false;
        fColumnResizing = false;
-       font_height FontAttributes;
-       Font->GetHeight(&FontAttributes);
-       fFontAscent = ceil(FontAttributes.ascent);
+       font_height fontAttributes;
+       font->GetHeight(&fontAttributes);
+       fFontAscent = ceil(fontAttributes.ascent);
 }
 
 
 CLVColumnLabelView::~CLVColumnLabelView()
 {
-       int32 NumberOfGroups = fDragGroups.CountItems();
-       for(int32 Counter = 0; Counter < NumberOfGroups; Counter++)
-               fDragGroups.RemoveItem(int32(0));
+       int32 groupCount = fDragGroupsList.CountItems();
+       for (int32 i = 0; i < groupCount; i++)
+               fDragGroupsList.RemoveItem(int32(0));
 }
 
 
-void CLVColumnLabelView::Draw(BRect UpdateRect)
+void
+CLVColumnLabelView::Draw(BRect updateRect)
 {
-       BRegion ClippingRegion;
-       GetClippingRegion(&ClippingRegion);
-       BRect ViewBounds = Bounds();
-
-       //Draw each column label in turn
-       float ColumnBegin = 0.0;
-       float ColumnEnd = -1.0;
-       bool MergeWithLeft = false;
-       int32 NumberOfColumns = fDisplayList->CountItems();
-       BPoint Start,Stop;
-       for(int32 ColumnDraw = 0; ColumnDraw < NumberOfColumns; ColumnDraw++)
-       {
-               CLVColumn* ThisColumn = 
(CLVColumn*)fDisplayList->ItemAt(ColumnDraw);
-               if(ThisColumn->IsShown())
-               {
-                       //Figure out where this column is
-                       ColumnBegin = ThisColumn->fColumnBegin;
-                       ColumnEnd = ThisColumn->fColumnEnd;
-                       //Start by figuring out if this column will merge with 
a shown column to the right
-                       bool MergeWithRight = false;
-                       if(ThisColumn->fFlags & CLV_MERGE_WITH_RIGHT)
-                       {
-                               for(int32 ColumnCounter = ColumnDraw+1; 
ColumnCounter < NumberOfColumns;
-                                       ColumnCounter++)
-                               {
-                                       CLVColumn* NextColumn = 
(CLVColumn*)fDisplayList->ItemAt(ColumnCounter);
-                                       if(NextColumn->IsShown())
-                                       {
-                                               //The next column is shown
-                                               MergeWithRight = true;
+       BRegion clippingRegion;
+       GetClippingRegion(&clippingRegion);
+       BRect bounds = Bounds();
+
+       // draw each column label in turn
+       float columnBegin = 0.0;
+       float columnEnd = -1.0;
+       bool shouldMergeWithLeft = false;
+       int32 columnCount = fDisplayList->CountItems();
+       BPoint startingPoint;
+       BPoint stoppingPoint;
+       for (int32 i = 0; i < columnCount; i++) {
+               CLVColumn* column = (CLVColumn*)fDisplayList->ItemAt(i);
+               if (column->IsShown()) {
+                       // figure out where this column is
+                       columnBegin = column->fColumnBegin;
+                       columnEnd = column->fColumnEnd;
+                       // start by figuring out if this column will merge
+                       // with a shown column to the right
+                       bool shouldMergeWithRight = false;
+                       if ((column->fFlags & CLV_MERGE_WITH_RIGHT) != 0) {
+                               for (int32 j = i + 1; j < columnCount; j++) {
+                                       CLVColumn* nextColumn = 
(CLVColumn*)fDisplayList->ItemAt(j);
+                                       if (nextColumn->IsShown()) {
+                                               // next column is shown
+                                               shouldMergeWithRight = true;
                                                break;
-                                       }
-                                       else if(!(NextColumn->fFlags & 
CLV_MERGE_WITH_RIGHT))
-                                               //The next column is not shown 
and doesn't pass on the merge
+                                       } else if ((nextColumn->fFlags & 
CLV_MERGE_WITH_RIGHT)
+                                                       == 0) {
+                                               // next column is not shown and 
doesn't
+                                               // pass on the merge
                                                break;
+                                       }
                                }
                        }
-                       
if(ClippingRegion.Intersects(BRect(ColumnBegin,ViewBounds.top,ColumnEnd,
-                               ViewBounds.bottom)))
-                       {
-                               //Need to draw this column
+
+                       if (clippingRegion.Intersects(BRect(columnBegin,
+                                       bounds.top, columnEnd, bounds.bottom))) 
{
+                               // need to draw this column
                                BeginLineArray(4);
-                               //Top line
-                               Start.Set(ColumnBegin,ViewBounds.top);
-                               Stop.Set(ColumnEnd-1.0,ViewBounds.top);
-                               if(MergeWithRight && !(ThisColumn == 
fColumnClicked && fColumnResizing))
-                                       Stop.x = ColumnEnd;
-                               AddLine(Start,Stop,BeHighlight);
-                               //Left line
-                               if(!MergeWithLeft)
-                                       
AddLine(BPoint(ColumnBegin,ViewBounds.top+1.0),
-                                               
BPoint(ColumnBegin,ViewBounds.bottom),BeHighlight);
-                               //Bottom line
-                               Start.Set(ColumnBegin+1.0,ViewBounds.bottom);
-                               if(MergeWithLeft)
-                                       Start.x = ColumnBegin;
-                               Stop.Set(ColumnEnd-1.0,ViewBounds.bottom);
-                               if(MergeWithRight && !(ThisColumn == 
fColumnClicked && fColumnResizing))
-                                       Stop.x = ColumnEnd;
-                               AddLine(Start,Stop,BeShadow);
-                               //Right line
-                               if(ThisColumn == fColumnClicked && 
fColumnResizing)
-                                       
AddLine(BPoint(ColumnEnd,ViewBounds.top),BPoint(ColumnEnd,ViewBounds.bottom),
-                                               BeFocusBlue);
-                               else if(!MergeWithRight)
-                                       
AddLine(BPoint(ColumnEnd,ViewBounds.top),BPoint(ColumnEnd,ViewBounds.bottom),
-                                               BeShadow);
+
+                               // top line
+                               startingPoint.Set(columnBegin, bounds.top);
+                               stoppingPoint.Set(columnEnd - 1.0, bounds.top);
+                               if (shouldMergeWithRight && !(column == 
fColumnClicked
+                                       && fColumnResizing)) {
+                                       stoppingPoint.x = columnEnd;
+                               }
+                               AddLine(startingPoint, stoppingPoint, 
BeHighlight);
+
+                               // left line
+                               if (!shouldMergeWithLeft) {
+                                       AddLine(BPoint(columnBegin, bounds.top 
+ 1.0),
+                                               BPoint(columnBegin, 
bounds.bottom), BeHighlight);
+                               }
+
+                               // bottom line
+                               startingPoint.Set(columnBegin + 1.0, 
bounds.bottom);
+                               if (shouldMergeWithLeft)
+                                       startingPoint.x = columnBegin;
+
+                               stoppingPoint.Set(columnEnd - 1.0, 
bounds.bottom);
+                               if (shouldMergeWithRight && !(column == 
fColumnClicked
+                                       && fColumnResizing)) {
+                                       stoppingPoint.x = columnEnd;
+                               }
+                               AddLine(startingPoint, stoppingPoint, BeShadow);
+
+                               // right line
+                               if (column == fColumnClicked && 
fColumnResizing) {
+                                       AddLine(BPoint(columnEnd, bounds.top),
+                                       BPoint(columnEnd, bounds.bottom), 
BeFocusBlue);
+                               } else if (!shouldMergeWithRight) {
+                                       AddLine(BPoint(columnEnd, bounds.top),
+                                               BPoint(columnEnd, 
bounds.bottom), BeShadow);
+                               }
                                EndLineArray();
 
-                               //Add the label
-                               if(ThisColumn->fLabel)
-                               {
-                                       //Limit the clipping region to the 
interior of the box
-                                       BRegion TextRegion;
-                                       
TextRegion.Include(BRect(ColumnBegin+1.0,ViewBounds.top+1.0,ColumnEnd-1.0,
-                                               ViewBounds.bottom-1.0));
-                                       ConstrainClippingRegion(&TextRegion);
-
-                                       //Draw the label
-                                       if(ThisColumn == fColumnClicked && 
!fColumnResizing)
+                               // add the label
+                               if (column->fLabel != NULL) {
+                                       // limit the clipping region to the 
interior of the box
+                                       BRegion textRegion;
+                                       textRegion.Include(BRect(columnBegin + 
1.0,
+                                               bounds.top + 1.0, columnEnd - 
1.0,
+                                               bounds.bottom - 1.0));
+                                       ConstrainClippingRegion(&textRegion);
+
+                                       // draw the label
+                                       if (column == fColumnClicked && 
!fColumnResizing)
                                                SetHighColor(BeFocusBlue);
+
                                        SetDrawingMode(B_OP_OVER);
-                                       
DrawString(ThisColumn->fLabel,BPoint(ColumnBegin+9.0,ViewBounds.top+2.0+fFontAscent));
+                                       DrawString(column->fLabel,
+                                               BPoint(columnBegin + 9.0,
+                                                       bounds.top + 2.0 + 
fFontAscent));
                                        SetDrawingMode(B_OP_COPY);
 
-                                       //Underline if this is a selected sort 
column
-                                       
if(fParent->fSortKeyList.HasItem(ThisColumn) && ThisColumn->fSortMode != NoSort)
-                                       {
-                                               float Width = 
StringWidth(ThisColumn->fLabel);
-                                               
StrokeLine(BPoint(ColumnBegin+8.0,ViewBounds.top+2.0+fFontAscent+2.0),
-                                                       
BPoint(ColumnBegin+8.0+Width,ViewBounds.top+2.0+fFontAscent+2.0));
+                                       // underline if this is a selected sort 
column
+                                       if 
(fParent->fSortKeyList.HasItem(column)
+                                               && column->fSortMode != 
SORT_MODE_NONE) {
+                                               float Width = 
StringWidth(column->fLabel);
+                                               StrokeLine(BPoint(columnBegin + 
8.0,
+                                                       bounds.top + 2.0 + 
fFontAscent + 2.0),
+                                                       BPoint(columnBegin + 
8.0 + Width,
+                                                               bounds.top + 
2.0 + fFontAscent + 2.0));
                                        }
-                                       if(ThisColumn == fColumnClicked && 
!fColumnResizing)
+                                       if (column == fColumnClicked && 
!fColumnResizing)
                                                SetHighColor(Black);
 
-                                       //Restore the clipping region
+                                       // restore the clipping region
                                        ConstrainClippingRegion(NULL);
                                }
                        }
-                       //Set MergeWithLeft flag for the next column to the 
appropriate state
-                       MergeWithLeft = MergeWithRight;
+
+                       // set shouldMergeWithLeft flag for the next column to
+                       // the appropriate state
+                       shouldMergeWithLeft = shouldMergeWithRight;
                }
        }
 
-       //Add highlight and shadow to the region after the columns if necessary
-       if(ColumnEnd < ViewBounds.right)
-       {
-               ColumnBegin = ColumnEnd+1.0;
-               
if(ClippingRegion.Intersects(BRect(ColumnEnd+1.0,ViewBounds.top,ViewBounds.right,
-                       ViewBounds.bottom)))
-               {
+       // add highlight and shadow to the region after the columns if necessary
+       if (columnEnd < bounds.right) {
+               columnBegin = columnEnd + 1.0;
+
+               if (clippingRegion.Intersects(BRect(columnEnd + 1.0,
+                               bounds.top, bounds.right, bounds.bottom))) {
                        BeginLineArray(3);
-                       //Top line
-                       
AddLine(BPoint(ColumnBegin,ViewBounds.top),BPoint(ViewBounds.right,ViewBounds.top),
-                               BeHighlight);
-                       //Left line
-                       
AddLine(BPoint(ColumnBegin,ViewBounds.top+1.0),BPoint(ColumnBegin,ViewBounds.bottom),
-                               BeHighlight);
-                       //Bottom line
-                       Start.Set(ColumnBegin+1.0,ViewBounds.bottom);
-                       if(MergeWithLeft)
-                               Start.x = ColumnBegin;
-                       Stop.Set(ViewBounds.right,ViewBounds.bottom);
-                       AddLine(Start,Stop,BeShadow);
+
+                       // top line
+                       AddLine(BPoint(columnBegin, bounds.top),
+                               BPoint(bounds.right, bounds.top), BeHighlight);
+
+                       // left line
+                       AddLine(BPoint(columnBegin, bounds.top + 1.0),
+                               BPoint(columnBegin, bounds.bottom), 
BeHighlight);
+
+                       // bottom line
+                       startingPoint.Set(columnBegin + 1.0, bounds.bottom);
+                       if (shouldMergeWithLeft)
+                               startingPoint.x = columnBegin;
+
+                       stoppingPoint.Set(bounds.right, bounds.bottom);
+                       AddLine(startingPoint, stoppingPoint, BeShadow);
                        EndLineArray();
                }
        }
 
-       //Draw the dragging box if necessary
-       if(fColumnClicked && fColumnDragging)
-       {
-               float DragOutlineLeft = 
fPreviousMousePos.x-fDragBoxMouseHoldOffset;
-               float GroupBegin = 
((CLVDragGroup*)fDragGroups.ItemAt(fDragGroup))->GroupBegin;
-               if(DragOutlineLeft < GroupBegin && fSnapGroupBefore == -1)
-                       DragOutlineLeft = GroupBegin;
-               if(DragOutlineLeft > GroupBegin && fSnapGroupAfter == -1)
-                       DragOutlineLeft = GroupBegin;
-               float DragOutlineRight = DragOutlineLeft + fDragBoxWidth;
+       // draw the dragging box if necessary
+       if (fColumnClicked && fColumnDragging) {
+               float dragOutlineLeft = fPreviousMousePosition.x
+                       - fDragBoxMouseHoldOffset;
+               float groupBegin = ((CLVDragGroup*)fDragGroupsList.ItemAt(
+                       fDragGroupIndex))->groupBeginIndex;
+               if (dragOutlineLeft < groupBegin && fSnapGroupBeforeIndex == -1)
+                       dragOutlineLeft = groupBegin;
+
+               if (dragOutlineLeft > groupBegin && fSnapGroupAfterIndex == -1)
+                       dragOutlineLeft = groupBegin;
+
+               float DragOutlineRight = dragOutlineLeft + fDragBoxWidth;
+
                BeginLineArray(4);
-               
AddLine(BPoint(DragOutlineLeft,ViewBounds.top),BPoint(DragOutlineRight,
-                       ViewBounds.top),BeFocusBlue);
-               
AddLine(BPoint(DragOutlineLeft,ViewBounds.bottom),BPoint(DragOutlineRight,
-                       ViewBounds.bottom),BeFocusBlue);
-               
AddLine(BPoint(DragOutlineLeft,ViewBounds.top+1.0),BPoint(DragOutlineLeft,
-                       ViewBounds.bottom-1.0),BeFocusBlue);
-               
AddLine(BPoint(DragOutlineRight,ViewBounds.top+1.0),BPoint(DragOutlineRight,
-                       ViewBounds.bottom-1.0),BeFocusBlue);
+               AddLine(BPoint(dragOutlineLeft, bounds.top),
+                       BPoint(DragOutlineRight, bounds.top), BeFocusBlue);
+               AddLine(BPoint(dragOutlineLeft, bounds.bottom),
+                       BPoint(DragOutlineRight, bounds.bottom), BeFocusBlue);
+               AddLine(BPoint(dragOutlineLeft, bounds.top + 1.0),
+                       BPoint(dragOutlineLeft, bounds.bottom - 1.0), 
BeFocusBlue);
+               AddLine(BPoint(DragOutlineRight, bounds.top + 1.0),
+                       BPoint(DragOutlineRight, bounds.bottom - 1.0), 
BeFocusBlue);
                EndLineArray();
-               fPrevDragOutlineLeft = DragOutlineLeft;
-               fPrevDragOutlineRight = DragOutlineRight;
+
+               fPreviousDragOutlineLeft = dragOutlineLeft;
+               fPreviousDragOutlineRight = DragOutlineRight;
        }
 }
 
 
-void CLVColumnLabelView::MouseDown(BPoint Point)
+void
+CLVColumnLabelView::MouseDown(BPoint where)
 {
-       //Only pay attention to primary mouse button
-       bool WatchMouse = false;
-       BPoint MousePos;
-       uint32 Buttons;
-       GetMouse(&MousePos,&Buttons);
-       if(Buttons == B_PRIMARY_MOUSE_BUTTON)
-       {
-               BRect ViewBounds = Bounds();
-
-               //Make sure no other column was already clicked.  If so, just 
discard the old one and redraw the
-               //view
-               if(fColumnClicked != NULL)
-               {
+       // pay attention only to primary mouse button
+       bool shouldWatchMouse = false;
+       BPoint mousePosition;
+       uint32 buttons;
+       GetMouse(&mousePosition, &buttons);
+       if (buttons == B_PRIMARY_MOUSE_BUTTON) {
+               BRect bounds = Bounds();
+
+               // Make sure no other column was already clicked.
+               // If so, just discard the old one and redraw the view.
+               if (fColumnClicked != NULL) {
                        Invalidate();
                        fColumnClicked = NULL;
                }
 
-               //Find the column that the user clicked, if any
-               bool GrabbedResizeTab = false;
-               int32 NumberOfColumns = fDisplayList->CountItems();
-               int32 ColumnFind;
-               CLVColumn* ThisColumn = NULL;
-               for(ColumnFind = 0; ColumnFind < NumberOfColumns; ColumnFind++)
-               {
-                       ThisColumn = 
(CLVColumn*)fDisplayList->ItemAt(ColumnFind);
-                       if(ThisColumn->IsShown())
-                       {
-                               float ColumnBegin = ThisColumn->fColumnBegin;
-                               float ColumnEnd = ThisColumn->fColumnEnd;
-                               if ((Point.x >= ColumnBegin && Point.x <= 
ColumnEnd) ||
-                                   ((ColumnFind == 
NumberOfColumns-1)&&(Point.x >= ColumnBegin)))  // anything after the rightmost 
column can drag... jaf
-                               {
-                                   const float resizeTolerance = 5.0f;  // jaf 
is too clumsy to click on a 2 pixel space.  :)
-
-                                       //User clicked in this column
-                                       if(Point.x <= 
ColumnBegin+resizeTolerance)
-                                       {
-                                               //User clicked the resize tab 
preceding this column
-                                               for(ColumnFind--; ColumnFind >= 
0; ColumnFind--)
-                                               {
-                                                       ThisColumn = 
(CLVColumn*)fDisplayList->ItemAt(ColumnFind);
-                                                       
if(ThisColumn->IsShown())
-                                                       {
-                                                               
GrabbedResizeTab = true;
+               // find the column that the user clicked, if any
+               bool didGrabResizeTab = false;
+               int32 columnCount = fDisplayList->CountItems();
+               int32 i;
+               CLVColumn* column = NULL;
+               for (i = 0; i < columnCount; i++) {
+                       column = (CLVColumn*)fDisplayList->ItemAt(i);
+                       if (column->IsShown()) {
+                               float columnBegin = column->fColumnBegin;
+                               float columnEnd = column->fColumnEnd;
+                               if ((where.x >= columnBegin && where.x <= 
columnEnd)
+                                       || ((i == columnCount - 1) && (where.x 
>= columnBegin))) {
+                                       // anything after the rightmost column 
can drag... jaf
+                                   const float resizeTolerance = 5.0f;
+                                       // jaf is too clumsy to click on a 2 
pixel space.  :)
+
+                                       // user clicked in this column
+                                       if (where.x <= columnBegin + 
resizeTolerance) {
+                                               // user clicked the resize tab 
preceding this column
+                                               for (i--; i >= 0; i--) {
+                                                       column = 
(CLVColumn*)fDisplayList->ItemAt(i);
+                                                       if (column->IsShown()) {
+                                                               
didGrabResizeTab = true;
                                                                break;
                                                        }
                                                }
-                                       }
-                                       else if(Point.x >= 
ColumnEnd-resizeTolerance)
-                                       {
-                                               //User clicked the resize tab 
for (after) this column
-                                               GrabbedResizeTab = true;
-                                       }
-                                       else
-                                       {
-                                               //The user clicked in this 
column
-                                               fColumnClicked = 
(CLVColumn*)fDisplayList->ItemAt(ColumnFind);
+                                       } else if (where.x >= 
columnEnd-resizeTolerance) {
+                                               // user clicked the resize tab 
for (after) this column
+                                               didGrabResizeTab = true;
+                                       } else {
+                                               // user clicked in this column
+                                               fColumnClicked = 
(CLVColumn*)fDisplayList->ItemAt(i);
                                                fColumnResizing = false;
-                                               fPreviousMousePos = Point;
-                                               fMouseClickedPos = Point;
+                                               fPreviousMousePosition = where;
+                                               fMouseClickedPosition = where;
                                                fColumnDragging = false;
                                                SetSnapMinMax();
-                                               fDragBoxMouseHoldOffset = 
Point.x-
-                                                       
((CLVDragGroup*)fDragGroups.ItemAt(fDragGroup))->GroupBegin;
-                                               
Invalidate(BRect(ColumnBegin+1.0,ViewBounds.top+1.0,ColumnEnd-1.0,
-                                                       ViewBounds.bottom-1.0));
+                                               fDragBoxMouseHoldOffset = 
where.x
+                                                       - 
((CLVDragGroup*)fDragGroupsList.ItemAt(
+                                                               
fDragGroupIndex))->groupBeginIndex;
 
-                                               //Start watching the mouse
-                                               WatchMouse = true;
+                                                       
Invalidate(BRect(columnBegin + 1.0,
+                                                               bounds.top + 
1.0, columnEnd - 1.0,
+                                                               bounds.bottom - 
1.0));
+
+                                               // start watching the mouse
+                                               shouldWatchMouse = true;
                                        }
                                        break;
                                }
                        }
                }
-               if(GrabbedResizeTab)
-               {
-                       //The user grabbed a resize tab.  See if resizing of 
this column is allowed
-                       if(!(ThisColumn->fFlags & CLV_NOT_RESIZABLE))
-                       {
-                               fColumnClicked = 
(CLVColumn*)fDisplayList->ItemAt(ColumnFind);
+
+               if (didGrabResizeTab) {
+                       // user grabbed a resize tab, check to see if
+                       // resizing this column is allowed
+                       if ((column->fFlags & CLV_NOT_RESIZABLE) == 0) {
+                               fColumnClicked = 
(CLVColumn*)fDisplayList->ItemAt(i);
                                fColumnResizing = true;
-                               fPreviousMousePos = Point;
-                               fMouseClickedPos = Point;
+                               fPreviousMousePosition = where;
+                               fMouseClickedPosition = where;
                                fColumnDragging = false;
-                               fResizeMouseHoldOffset = 
Point.x-fColumnClicked->fColumnEnd;
-                               
Invalidate(BRect(fColumnClicked->fColumnEnd,ViewBounds.top,ThisColumn->fColumnEnd,
-                                       ViewBounds.bottom));
+                               fResizeMouseHoldOffset = where.x - 
fColumnClicked->fColumnEnd;
+                               Invalidate(BRect(fColumnClicked->fColumnEnd, 
bounds.top,
+                                       column->fColumnEnd, bounds.bottom));
 
-                               //Start watching the mouse
-                               WatchMouse = true;
+                               // start watching the mouse
+                               shouldWatchMouse = true;
                        }
                }
        }
-       if(WatchMouse)
-       {
+
+       if (shouldWatchMouse) {
                thread_id MouseWatcherThread = StartMouseWatcher(this);
-               if(MouseWatcherThread == B_NO_MORE_THREADS || 
MouseWatcherThread == B_NO_MEMORY)
+               if (MouseWatcherThread == B_NO_MORE_THREADS
+                       || MouseWatcherThread == B_NO_MEMORY) {
                        fColumnClicked = NULL;
+               }
        }
 }
 
 
-void CLVColumnLabelView::MessageReceived(BMessage *message)
+void
+CLVColumnLabelView::MessageReceived(BMessage* message)
 {
-       if(message->what != MW_MOUSE_MOVED && message->what != MW_MOUSE_DOWN && 
message->what != MW_MOUSE_UP)
+       if (message->what != MW_MOUSE_MOVED && message->what != MW_MOUSE_DOWN
+               && message->what != MW_MOUSE_UP) {
                BView::MessageReceived(message);
-       else if(fColumnClicked != NULL)
-       {
-               BPoint MousePos;
-               message->FindPoint("where",&MousePos);
-               uint32 Buttons;
-               message->FindInt32("buttons",(int32*)&Buttons);
-               uint32 Modifiers;
-               message->FindInt32("modifiers",(int32*)&Modifiers);
-               BRect ViewBounds;
-               ViewBounds = Bounds();
-               uint32 ColumnFlags = fColumnClicked->Flags();
-               if(Buttons == B_PRIMARY_MOUSE_BUTTON)
-               {
-                       //Mouse is still held down
-                       if(!fColumnResizing)
-                       {
-                               //User is clicking or dragging
-                               if((MousePos.x<fMouseClickedPos.x-2.0 || 
MousePos.x>fMouseClickedPos.x+2.0) &&
-                                       !fColumnDragging)
-                               {
-                                       //User is initiating a drag
-                                       if(fTheDragGroup->Flags & 
CLV_NOT_MOVABLE)
-                                       {
-                                               //Not allowed to drag this 
column - terminate the click
-                                               
Invalidate(BRect(fColumnClicked->fColumnBegin,ViewBounds.top,
-                                                       
fColumnClicked->fColumnEnd,ViewBounds.bottom));
+       } else if (fColumnClicked != NULL) {
+               BPoint mousePosition;
+               message->FindPoint("where", &mousePosition);
+               uint32 buttons;
+               message->FindInt32("buttons", (int32*)&buttons);
+               uint32 modifiers;
+               message->FindInt32("modifiers", (int32*)&modifiers);
+               BRect bounds;
+               bounds = Bounds();
+               uint32 columnFlags = fColumnClicked->Flags();
+               if (buttons == B_PRIMARY_MOUSE_BUTTON) {
+                       // mouse is still held down
+                       if (!fColumnResizing) {
+                               // user is clicking or dragging
+                               if ((mousePosition.x < fMouseClickedPosition.x 
- 2.0
+                                               || mousePosition.x > 
fMouseClickedPosition.x + 2.0)
+                                       && !fColumnDragging) {
+                                       // user is initiating a drag
+                                       if ((fDragGroup->flags & 
CLV_NOT_MOVABLE) != 0) {
+                                               // not allowed to drag this 
column - terminate the click
+                                               
Invalidate(BRect(fColumnClicked->fColumnBegin,
+                                                       bounds.top, 
fColumnClicked->fColumnEnd,
+                                                       bounds.bottom));
                                                fColumnClicked = NULL;
-                                       }
-                                       else
-                                       {
-                                               //Actually initiate a drag
+                                       } else {
+                                               // actually initiate a drag
                                                fColumnDragging = true;
-                                               fPrevDragOutlineLeft = -1.0;
-                                               fPrevDragOutlineRight = -1.0;
+                                               fPreviousDragOutlineLeft = -1.0;
+                                               fPreviousDragOutlineRight = 
-1.0;
                                        }
                                }
 
-                               //Now deal with dragging
-                               if(fColumnDragging)
-                               {
-                                       //User is dragging
-                                       if(MousePos.x<fPreviousMousePos.x || 
MousePos.x>fPreviousMousePos.x)
-                                       {
-                                               //Mouse moved since I last 
checked
-                                               ViewBounds = Bounds();
-
-                                               bool ColumnSnapped;
-                                               do
-                                               {
-                                                       //Live dragging of 
columns
-                                                       ColumnSnapped = false;
-                                                       float ColumnsUpdateLeft 
= 0;
-                                                       float 
ColumnsUpdateRight = 0;
+                               // now deal with dragging
+                               if (fColumnDragging) {
+                                       // user is dragging
+                                       if (mousePosition.x < 
fPreviousMousePosition.x
+                                               || mousePosition.x > 
fPreviousMousePosition.x) {
+                                               // mouse moved since I last 
checked
+                                               bounds = Bounds();
+
+                                               bool hasColumnSnapped;
+                                               do {
+                                                       // live dragging of 
columns
+                                                       hasColumnSnapped = 
false;
+                                                       float columnsUpdateLeft 
= 0;
+                                                       float 
columnsUpdateRight = 0;
                                                        float 
MainViewUpdateLeft = 0;
                                                        float 
MainViewUpdateRight = 0;
-                                                       CLVColumn* 
LastSwapColumn = NULL;
-                                                       if(fSnapMin != -1.0 && 
MousePos.x < fSnapMin)
-                                                       {
-                                                               //Shift the 
group left
-                                                               
ColumnsUpdateLeft = fTheShownGroupBefore->GroupBegin;
-                                                               
ColumnsUpdateRight = fTheDragGroup->GroupEnd;
-                                                               
MainViewUpdateLeft = ColumnsUpdateLeft;

[ *** diff truncated: 5399 lines dropped *** ]



Other related posts: