From fa1ee6d4d1c15a655d7d5877f88f7e397be16bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sundstr=C3=B6m?= Date: Sun, 15 Nov 2009 13:09:37 +0000 Subject: [PATCH] Clean-up git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34059 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/shortcuts/Jamfile | 2 +- src/preferences/shortcuts/MetaKeyStateMap.cpp | 1 + src/preferences/shortcuts/MetaKeyStateMap.h | 53 +++++++++-------- src/preferences/shortcuts/ResizableButton.cpp | 6 +- src/preferences/shortcuts/ResizableButton.h | 20 +++---- src/preferences/shortcuts/Shortcuts.rdef | 19 ++++++ src/preferences/shortcuts/Shortcuts.rsrc | Bin 4159 -> 0 bytes src/preferences/shortcuts/ShortcutsApp.cpp | 15 ++--- src/preferences/shortcuts/ShortcutsApp.h | 14 +++-- src/preferences/shortcuts/ShortcutsSpec.cpp | 55 ++++++++++-------- src/preferences/shortcuts/ShortcutsSpec.h | 14 +++-- src/preferences/shortcuts/ShortcutsWindow.cpp | 31 +++++----- src/preferences/shortcuts/ShortcutsWindow.h | 15 +++-- src/preferences/shortcuts/main.cpp | 8 ++- 14 files changed, 145 insertions(+), 108 deletions(-) create mode 100644 src/preferences/shortcuts/Shortcuts.rdef delete mode 100644 src/preferences/shortcuts/Shortcuts.rsrc diff --git a/src/preferences/shortcuts/Jamfile b/src/preferences/shortcuts/Jamfile index 02bb103f49..3c313bba88 100644 --- a/src/preferences/shortcuts/Jamfile +++ b/src/preferences/shortcuts/Jamfile @@ -21,5 +21,5 @@ Preference Shortcuts : ScrollViewCorner.cpp : be tracker libshortcuts_shared.a $(TARGET_LIBSTDC++) - : Shortcuts.rsrc + : Shortcuts.rdef ; diff --git a/src/preferences/shortcuts/MetaKeyStateMap.cpp b/src/preferences/shortcuts/MetaKeyStateMap.cpp index 15180e9389..76b36bcd48 100644 --- a/src/preferences/shortcuts/MetaKeyStateMap.cpp +++ b/src/preferences/shortcuts/MetaKeyStateMap.cpp @@ -89,3 +89,4 @@ MetaKeyStateMap::GetName() const { return fKeyName; } + diff --git a/src/preferences/shortcuts/MetaKeyStateMap.h b/src/preferences/shortcuts/MetaKeyStateMap.h index a119c7920a..bd2b316a6a 100644 --- a/src/preferences/shortcuts/MetaKeyStateMap.h +++ b/src/preferences/shortcuts/MetaKeyStateMap.h @@ -5,16 +5,17 @@ * Authors: * Jeremy Friesner */ - - #ifndef MetaKeyStateMap_h #define MetaKeyStateMap_h -#include + #include +#include + class BitFieldTester; + // This class defines a set of possible chording states (e.g. "Left only", // "Right only", "Both", "Either") for a meta-key (e.g. Shift), and the // description strings and qualifier bit-chords that go with them. @@ -22,45 +23,47 @@ class MetaKeyStateMap { public: // Note: You MUST call SetInfo() directly after using this ctor! - MetaKeyStateMap(); + MetaKeyStateMap(); // Creates a MetaKeyStateMap with the give name // (e.g. "Shift" or "Ctrl") - MetaKeyStateMap(const char* keyName); - - - ~MetaKeyStateMap(); + MetaKeyStateMap(const char* keyName); + + + ~MetaKeyStateMap(); // For when you have to use the default ctor - void SetInfo(const char* keyName); + void SetInfo(const char* keyName); // (tester) becomes property of this map! - void AddState(const char* desc, const BitFieldTester* tester); - + void AddState(const char* desc, + const BitFieldTester* tester); + // Returns the name of the meta-key (e.g. "Ctrl") - const char* GetName() const; - + const char* GetName() const; + // Returns the number of possible states contained in this // MetaKeyStateMap. - int GetNumStates() const; + int GetNumStates() const; // Returns a BitFieldTester that tests for the nth state's // presence. - const BitFieldTester* GetNthStateTester(int stateNum) const; + const BitFieldTester* GetNthStateTester(int stateNum) const; // Returns a textual description of the nth state (e.g. "Left") - const char* GetNthStateDesc(int stateNum) const; + const char* GetNthStateDesc(int stateNum) const; private: - // e.g. "Alt" or "Ctrl" - char* fKeyName; - - // list of strings e.g. "Left" or "Both" - BList fStateDescs; - - // list of BitFieldTesters for testing bits of modifiers - // in state - BList fStateTesters; + // e.g. "Alt" or "Ctrl" + char* fKeyName; + + // list of strings e.g. "Left" or "Both" + BList fStateDescs; + + // list of BitFieldTesters for testing bits of modifiers in state + BList fStateTesters; }; + #endif + diff --git a/src/preferences/shortcuts/ResizableButton.cpp b/src/preferences/shortcuts/ResizableButton.cpp index daf6b12d02..966e70bd80 100644 --- a/src/preferences/shortcuts/ResizableButton.cpp +++ b/src/preferences/shortcuts/ResizableButton.cpp @@ -9,10 +9,11 @@ #include "ResizableButton.h" + ResizableButton::ResizableButton(BRect parentFrame, BRect frame, - const char* name, const char* label, BMessage* msg) + const char* name, const char* label, BMessage* message) : - BButton(frame, name, label, msg, B_FOLLOW_BOTTOM) + BButton(frame, name, label, message, B_FOLLOW_BOTTOM) { float width = parentFrame.right - parentFrame.left; float height = parentFrame.bottom - parentFrame.top; @@ -33,3 +34,4 @@ ResizableButton::ChangeToNewSize(float newWidth, float newHeight) ResizeTo(newW, b.bottom - b.top); Invalidate(); } + diff --git a/src/preferences/shortcuts/ResizableButton.h b/src/preferences/shortcuts/ResizableButton.h index 81fc4bcd4d..0b4c20635d 100644 --- a/src/preferences/shortcuts/ResizableButton.h +++ b/src/preferences/shortcuts/ResizableButton.h @@ -5,26 +5,24 @@ * Authors: * Jeremy Friesner */ - - #ifndef ResizableButton_h #define ResizableButton_h -#include -#include -#include + #include -//Just like a regular BButton, but with a handy resize method added + class ResizableButton : public BButton { public: - ResizableButton(BRect parentFrame, BRect frame, - const char* name, const char* label, - BMessage* msg); + ResizableButton(BRect parentFrame, BRect frame, + const char* name, const char* label, + BMessage* message); - virtual void ChangeToNewSize(float newWidth, float newHeight); + virtual void ChangeToNewSize(float newWidth, float newHeight); private: - BRect fPercentages; + BRect fPercentages; }; + #endif + diff --git a/src/preferences/shortcuts/Shortcuts.rdef b/src/preferences/shortcuts/Shortcuts.rdef new file mode 100644 index 0000000000..0a30c8a8b7 --- /dev/null +++ b/src/preferences/shortcuts/Shortcuts.rdef @@ -0,0 +1,19 @@ + +resource app_signature "application/x-vnd.Haiku-Shortcuts"; + +resource app_flags B_SINGLE_LAUNCH; + +resource app_version { + major = 1, + middle = 0, + minor = 0, + + /* 0 = development 1 = alpha 2 = beta + 3 = gamma 4 = golden master 5 = final */ + variety = 2, + internal = 0, + + short_info = "Shortcuts", + long_info = "Shortcuts ©1999-2009 Jeremy Friesner ©2009 Haiku Inc." +}; + diff --git a/src/preferences/shortcuts/Shortcuts.rsrc b/src/preferences/shortcuts/Shortcuts.rsrc deleted file mode 100644 index c88b5bc79649b8403279f11e74ea715f63f23dc0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4159 zcmeHLJx|*}74t^Eio!{sEy60XGmqpjItnu>nJxtT| zSbmH( zY9m>O?=!PXhMTODGGy^Hp0ggvdLZk8tOx$32NL$OF=OEWW`KHpq#OhzAp-=#!JiFI zuEB$A62v!zQ`kUY7*$^ohyxTia(@PFjw-KKuZsXOoIl|!X7g6#X!!00P{yQGjb>vA zyFzhhOV5)^oi%9-SELSS+dHpHuGIa;0Dr!+8D~|(xrzoWsGH;l)?5kl_x-*UR2=uJ z9%qi$4)O~H=~~oK9Ah3uC;TLi>q>1n&qJXcgbbw&L#1qP zb}l8{3D+mFh#UniR5lA~#?HHNg!so=BSV~N4Ha21WGW1sDPa`dZEjjh{(KvI*dPz zNV>4ug9dK$Ac979rx($UnP|6lfnXw)ob!F&$ugHmh>kuz)w-R}4Zx(xwT5Jfsw@?(DqXTwC4S z+} #include "ShortcutsWindow.h" -#define APPLICATION_SIGNATURE "application/x-vnd.ShortcutsKeys" + +#define APPLICATION_SIGNATURE "application/x-vnd.Haiku-Shortcuts" + ShortcutsApp::ShortcutsApp() : @@ -34,7 +35,6 @@ ShortcutsApp::ReadyToRun() ShortcutsApp::~ShortcutsApp() { - } @@ -42,7 +42,8 @@ void ShortcutsApp::AboutRequested() { BAlert* alert = new BAlert("About Shortcuts", - "Shortcuts v1.28(SpicyKeys v1.28)\nby Jeremy Friesner" - , "Ok"); + "Shortcuts\n\n" + "Based on SpicyKeys for BeOS made by Jeremy Friesner.", "Ok"); alert->Go(); } + diff --git a/src/preferences/shortcuts/ShortcutsApp.h b/src/preferences/shortcuts/ShortcutsApp.h index 9c6e63e8c8..0dfa5ca3f0 100644 --- a/src/preferences/shortcuts/ShortcutsApp.h +++ b/src/preferences/shortcuts/ShortcutsApp.h @@ -6,19 +6,21 @@ * Jeremy Friesner * Fredrik Modéen */ - - #ifndef ShortcutsApp_h #define ShortcutsApp_h + #include + class ShortcutsApp : public BApplication { public: - ShortcutsApp(); - ~ShortcutsApp(); - virtual void ReadyToRun(); - virtual void AboutRequested(); + ShortcutsApp(); + ~ShortcutsApp(); + virtual void ReadyToRun(); + virtual void AboutRequested(); }; + #endif + diff --git a/src/preferences/shortcuts/ShortcutsSpec.cpp b/src/preferences/shortcuts/ShortcutsSpec.cpp index 4ec72fbd2d..2e9aed1003 100644 --- a/src/preferences/shortcuts/ShortcutsSpec.cpp +++ b/src/preferences/shortcuts/ShortcutsSpec.cpp @@ -9,29 +9,28 @@ #include "ShortcutsSpec.h" - #include #include +#include +#include +#include +#include #include #include -#include -#include -#include -#include - #include "ColumnListView.h" - -#include "Colors.h" -#include "MetaKeyStateMap.h" #include "BitFieldTesters.h" +#include "Colors.h" #include "CommandActuators.h" +#include "MetaKeyStateMap.h" #include "ParseCommandLine.h" + #define CLASS "ShortcutsSpec : " + const float _height = 20.0f; static MetaKeyStateMap _metaMaps[ShortcutsSpec::NUM_META_COLUMNS]; @@ -42,6 +41,7 @@ static BFont _viewFont; static float _fontHeight; static BBitmap * _actuatorBitmaps[2]; + // These meta-keys are pretty standard #define SHIFT_NAME "Shift" #define CONTROL_NAME "Control" @@ -58,10 +58,12 @@ static BBitmap * _actuatorBitmaps[2]; #define ICON_BITMAP_RECT BRect(0.0f, 0.0f, 15.0f, 15.0f) #define ICON_BITMAP_SPACE B_COLOR_8_BIT + // Returns the (pos)'th char in the string, or '\0' if (pos) if off the end of // the string static char GetLetterAt(const char* str, int pos); + static char GetLetterAt(const char* str, int pos) { @@ -281,16 +283,16 @@ static bool IsValidActuatorName(const char* c); static bool IsValidActuatorName(const char* c) { - return ((strcmp(c, "InsertString") == 0) || - (strcmp(c, "MoveMouse") == 0) || - (strcmp(c, "MoveMouseTo") == 0) || - (strcmp(c, "MouseButton") == 0) || - (strcmp(c, "LaunchHandler") == 0) || // new for v1.21 --jaf - (strcmp(c, "Multi") == 0) || // new for v1.24 --jaf - (strcmp(c, "MouseDown") == 0) || // new for v1.24 --jaf - (strcmp(c, "MouseUp") == 0) || // new for v1.24 --jaf - (strcmp(c, "SendMessage") == 0) || // new for v1.25 --jaf - (strcmp(c, "Beep") == 0)); + return (strcmp(c, "InsertString") == 0 + || strcmp(c, "MoveMouse") == 0 + || strcmp(c, "MoveMouseTo") == 0 + || strcmp(c, "MouseButton") == 0 + || strcmp(c, "LaunchHandler") == 0 + || strcmp(c, "Multi") == 0 + || strcmp(c, "MouseDown") == 0 + || strcmp(c, "MouseUp") == 0 + || strcmp(c, "SendMessage") == 0 + || strcmp(c, "Beep") == 0); } @@ -300,7 +302,7 @@ ShortcutsSpec::Instantiate(BMessage* from) bool validateOK = false; if (validate_instantiation(from, "ShortcutsSpec")) validateOK = true; - else //test the old one. + else // test the old one. if (validate_instantiation(from, "SpicyKeysSpec")) validateOK = true; @@ -362,7 +364,8 @@ ShortcutsSpec::DrawItemColumn(BView* owner, BRect item_column_rect, point.Set(item_column_rect.left + STRING_COLUMN_LEFT_MARGIN, item_column_rect.top + fTextOffset); - item_column_rect.left = point.x;//keep text from drawing into icon area + item_column_rect.left = point.x; + // keep text from drawing into icon area // scroll if too wide float rectWidth = item_column_rect.Width() - STRING_COLUMN_LEFT_MARGIN; @@ -668,7 +671,7 @@ ShortcutsSpec::ProcessColumnKeyStroke(int whichColumn, const char* bytes, case B_BACKSPACE: case B_DELETE: if (fCommandNul > 0) { - //trim a char off the string + // trim a char off the string fCommand[fCommandNul - 1] = '\0'; fCommandNul--; // note new nul position ret = true; @@ -745,7 +748,8 @@ ShortcutsSpec::ProcessColumnKeyStroke(int whichColumn, const char* bytes, letter = toupper(letter); // convert to upper case if ((letter == B_BACKSPACE) || (letter == B_DELETE)) - letter = '(';//so space bar will blank out an entry + letter = '('; + // so space bar will blank out an entry for (int i = 0; i < numStates; i++) { const char* desc = map->GetNthStateDesc(i); @@ -774,8 +778,8 @@ ShortcutsSpec::ProcessColumnKeyStroke(int whichColumn, const char* bytes, int -ShortcutsSpec::MyCompare(const CLVListItem* a_Item1, const CLVListItem* a_Item2 - , int32 KeyColumn) +ShortcutsSpec::MyCompare(const CLVListItem* a_Item1, const CLVListItem* a_Item2, + int32 KeyColumn) { ShortcutsSpec* left = (ShortcutsSpec*) a_Item1; ShortcutsSpec* right = (ShortcutsSpec*) a_Item2; @@ -836,3 +840,4 @@ ShortcutsSpec::_UpdateIconBitmap() } } } + diff --git a/src/preferences/shortcuts/ShortcutsSpec.h b/src/preferences/shortcuts/ShortcutsSpec.h index 3a6587f8e8..a39e69032d 100644 --- a/src/preferences/shortcuts/ShortcutsSpec.h +++ b/src/preferences/shortcuts/ShortcutsSpec.h @@ -5,23 +5,24 @@ * Authors: * Jeremy Friesner */ - - #ifndef ShortcutsSpec_h #define ShortcutsSpec_h -#include +#include #include "CLVListItem.h" #include "KeyInfos.h" + class CommandActuator; class MetaKeyStateMap; + MetaKeyStateMap & GetNthKeyMap(int which); void InitializeMetaMaps(); + /* 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 @@ -41,7 +42,9 @@ public: 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); + 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); @@ -97,8 +100,9 @@ private: BPoint fCursorPt1; BPoint fCursorPt2; bool fCursorPtsValid; - mutable char fScratch[50]; + mutable char fScratch[50]; int32 fSelectedColumn; }; #endif + diff --git a/src/preferences/shortcuts/ShortcutsWindow.cpp b/src/preferences/shortcuts/ShortcutsWindow.cpp index 8c92162a25..ec7c9920b0 100644 --- a/src/preferences/shortcuts/ShortcutsWindow.cpp +++ b/src/preferences/shortcuts/ShortcutsWindow.cpp @@ -6,39 +6,37 @@ * Jeremy Friesner * Fredrik Modéen */ - + #include "ShortcutsWindow.h" - #include #include - #include #include #include -#include +#include +#include +#include #include -#include #include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include #include "ColumnListView.h" - #include "KeyInfos.h" -#include "ShortcutsSpec.h" -#include "ParseCommandLine.h" #include "MetaKeyStateMap.h" +#include "ParseCommandLine.h" #include "ShortcutsFilterConstants.h" +#include "ShortcutsSpec.h" + // Window sizing constraints #define MIN_WIDTH 600 @@ -72,6 +70,7 @@ static BPopUpMenu* CreateMetaPopUp(int col) return popup; } + // Creates a pop-up that allows the user to choose a key-cap visually static BPopUpMenu* CreateKeysPopUp(); static BPopUpMenu* CreateKeysPopUp() @@ -113,7 +112,8 @@ ShortcutsWindow::ShortcutsWindow() fileMenu->AddItem(new BMenuItem("Save KeySet As...", new BMessage(SAVE_KEYSET_AS), 'S')); fileMenu->AddItem(new BSeparatorItem); - fileMenu->AddItem(new BMenuItem("About Shortcuts", new BMessage(B_ABOUT_REQUESTED))); + fileMenu->AddItem(new BMenuItem("About Shortcuts", + new BMessage(B_ABOUT_REQUESTED))); fileMenu->AddItem(new BSeparatorItem); fileMenu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q')); @@ -257,7 +257,7 @@ ShortcutsWindow::QuitRequested() } if (ret) - fColumnListView->DeselectAll(); // avoid mysterious crash on PPC!? + fColumnListView->DeselectAll(); return ret; } @@ -720,3 +720,4 @@ ShortcutsWindow::DispatchMessage(BMessage* msg, BHandler* handler) break; } } + diff --git a/src/preferences/shortcuts/ShortcutsWindow.h b/src/preferences/shortcuts/ShortcutsWindow.h index b704a5a095..9e7ffa7521 100644 --- a/src/preferences/shortcuts/ShortcutsWindow.h +++ b/src/preferences/shortcuts/ShortcutsWindow.h @@ -5,26 +5,23 @@ * Authors: * Jeremy Friesner */ - - #ifndef ShortcutsWindow_h #define ShortcutsWindow_h -#include -#include -#include + #include #include - +#include +#include +#include #include "ColumnListView.h" #include "ResizableButton.h" + // This class defines our preferences/configuration window. class ShortcutsWindow : public BWindow { public: -// If (optSaveTo) is non-NULL, settings will be loaded from the file it -// represents. ShortcutsWindow(); ~ShortcutsWindow(); @@ -81,4 +78,6 @@ private: bool fLastOpenWasAppend; }; + #endif + diff --git a/src/preferences/shortcuts/main.cpp b/src/preferences/shortcuts/main.cpp index cfffe7a3a4..6657373cb9 100644 --- a/src/preferences/shortcuts/main.cpp +++ b/src/preferences/shortcuts/main.cpp @@ -7,12 +7,14 @@ */ -#include "ShortcutsApp.h" #include "KeyInfos.h" +#include "ShortcutsApp.h" + int main(int argc, char** argv) { InitKeyIndices(); - (new ShortcutsApp)->Run(); - delete be_app; + ShortcutsApp app; + app.Run(); } +