2 * Copyright 1999-2009 Jeremy Friesner
3 * Copyright 2009-2010 Haiku, Inc. All rights reserved.
4 * Distributed under the terms of the MIT License.
9 #ifndef SHORTCUTS_SPEC_H
10 #define SHORTCUTS_SPEC_H
15 #include <ColumnListView.h>
19 class CommandActuator
;
20 class MetaKeyStateMap
;
23 MetaKeyStateMap
& GetNthKeyMap(int which
);
26 * Objects of this class represent one hotkey "entry" in the preferences
27 * ListView. Each ShortcutsSpec contains the info necessary to generate both
28 * the proper GUI display, and the proper BitFieldTester and CommandActuator
29 * object for the ShortcutsCatcher add-on to use.
31 class ShortcutsSpec
: public BRow
, public BArchivable
{
33 static void InitializeMetaMaps();
35 ShortcutsSpec(const char* command
);
36 ShortcutsSpec(const ShortcutsSpec
& copyMe
);
37 ShortcutsSpec(BMessage
* from
);
40 virtual status_t
Archive(BMessage
* into
, bool deep
= true) const;
41 static BArchivable
* Instantiate(BMessage
* from
);
42 const char* GetCellText(int whichColumn
) const;
43 void SetCommand(const char* commandStr
);
45 // Returns the name of the Nth Column.
46 static const char* GetColumnName(int index
);
48 // Update this spec's state in response to a keystroke to the given
49 // column. Returns true iff a change occurred.
50 bool ProcessColumnKeyStroke(int whichColumn
,
51 const char* bytes
, int32 key
);
53 // Same as ProcessColumnKeyStroke, but for a mouse click instead.
54 bool ProcessColumnMouseClick(int whichColumn
);
56 // Same as ProcessColumnKeyStroke, but for a text string instead.
57 bool ProcessColumnTextString(int whichColumn
,
60 int32
GetSelectedColumn() const { return fSelectedColumn
; }
61 void SetSelectedColumn(int32 i
) { fSelectedColumn
= i
; }
63 // default layout of columns is set in here.
65 SHIFT_COLUMN_INDEX
= 0,
66 CONTROL_COLUMN_INDEX
= 1,
67 COMMAND_COLUMN_INDEX
= 2,
68 OPTION_COLUMN_INDEX
= 3,
69 NUM_META_COLUMNS
= 4, // shift, control, command, option, for now
70 KEY_COLUMN_INDEX
= NUM_META_COLUMNS
,
71 STRING_COLUMN_INDEX
= 5
75 void _CacheViewFont(BView
* owner
);
76 bool _AttemptTabCompletion();
79 uint32 fCommandLen
; // number of bytes in fCommand buffer
80 uint32 fCommandNul
; // index of the NUL byte in fCommand
82 // icon for associated program. Invalid if none available.
85 char* fLastBitmapName
;
88 int32 fMetaCellStateIndex
[NUM_META_COLUMNS
];
92 mutable char fScratch
[50];
93 int32 fSelectedColumn
;
96 static void _InitModifierNames();
98 static const char* sShiftName
;
99 static const char* sControlName
;
100 static const char* sOptionName
;
101 static const char* sCommandName
;
105 #endif // SHORTCUTS_SPEC_H