libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / preferences / shortcuts / ShortcutsSpec.h
blobd43658a6c359b433f3900a9f06913b16af9d553f
1 /*
2 * Copyright 1999-2009 Jeremy Friesner
3 * Copyright 2009-2010 Haiku, Inc. All rights reserved.
4 * Distributed under the terms of the MIT License.
6 * Authors:
7 * Jeremy Friesner
8 */
9 #ifndef SHORTCUTS_SPEC_H
10 #define SHORTCUTS_SPEC_H
13 #include <Bitmap.h>
15 #include <ColumnListView.h>
16 #include "KeyInfos.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 {
32 public:
33 static void InitializeMetaMaps();
35 ShortcutsSpec(const char* command);
36 ShortcutsSpec(const ShortcutsSpec& copyMe);
37 ShortcutsSpec(BMessage* from);
38 ~ShortcutsSpec();
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,
58 const char* string);
60 int32 GetSelectedColumn() const { return fSelectedColumn; }
61 void SetSelectedColumn(int32 i) { fSelectedColumn = i; }
63 // default layout of columns is set in here.
64 enum {
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
74 private:
75 void _CacheViewFont(BView* owner);
76 bool _AttemptTabCompletion();
78 char* fCommand;
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.
83 BBitmap fBitmap;
85 char* fLastBitmapName;
86 bool fBitmapValid;
87 uint32 fKey;
88 int32 fMetaCellStateIndex[NUM_META_COLUMNS];
89 BPoint fCursorPt1;
90 BPoint fCursorPt2;
91 bool fCursorPtsValid;
92 mutable char fScratch[50];
93 int32 fSelectedColumn;
95 private:
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