xref: /haiku/src/preferences/shortcuts/ShortcutsWindow.h (revision 3c6e2dd68577c34d93e17f19711f6245bf6d0915)
1 /*
2  * Copyright 1999-2009 Haiku Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Jeremy Friesner
7  */
8 #ifndef ShortcutsWindow_h
9 #define ShortcutsWindow_h
10 
11 
12 #include <Entry.h>
13 #include <FilePanel.h>
14 #include <Message.h>
15 #include <Point.h>
16 #include <Window.h>
17 
18 #include "ColumnListView.h"
19 #include "ResizableButton.h"
20 
21 
22 // This class defines our preferences/configuration window.
23 class ShortcutsWindow : public BWindow {
24 public:
25 							ShortcutsWindow();
26 							~ShortcutsWindow();
27 
28 	virtual void 			DispatchMessage(BMessage* msg, BHandler* handler);
29 	virtual void 			Quit();
30 	virtual void			FrameResized(float w, float h);
31 	virtual void 			MessageReceived(BMessage * msg);
32 	virtual bool 			QuitRequested();
33 
34 	// BMessage 'what' codes, representing commands understood by this Window.
35 	enum {
36 		ADD_HOTKEY_ITEM = 'SpKy',	// Add a new hotkey entry to the GUI list.
37 		REMOVE_HOTKEY_ITEM,			// Remove a hotkey entry from the GUI list.
38 		HOTKEY_ITEM_SELECTED,		// Give the "focus bar" to the specified
39 									// entry.
40 		HOTKEY_ITEM_MODIFIED,		// Update the state of an entry to reflect
41 									// user's changes.
42 		OPEN_KEYSET,				// Bring up a File requester to load new
43 									// settings.
44 		APPEND_KEYSET,				// Bring up a File requester to append
45 									// settings.
46 		REVERT_KEYSET,				// Dump the current state and re-read
47 									// settings from disk.
48 		SAVE_KEYSET,				// Save the current settings to disk
49 		SAVE_KEYSET_AS,				// Bring up a File requester to save
50 									// current settings.
51 		SELECT_APPLICATION,			// Set the current entry to point to the
52 									// given file.
53 	};
54 private:
55 			BMenuItem* 			_CreateActuatorPresetMenuItem(const char* label)
56 									const;
57 			void 				_AddNewSpec(const char* defaultCommand);
58 			void 				_MarkKeySetModified();
59 			bool 				_LoadKeySet(const BMessage& loadMsg);
60 			bool 				_SaveKeySet(BEntry & saveEntry);
61 			bool				_GetSettingsFile(entry_ref* ref);
62 
63 			ResizableButton*	fAddButton;
64 			ResizableButton* 	fRemoveButton;
65 			ResizableButton* 	fSaveButton;
66 			ColumnListView* 	fColumnListView;
67 			BFilePanel* 		fSavePanel;		// for saving settings
68 			BFilePanel* 		fOpenPanel;		// for loading settings
69 			BFilePanel* 		fSelectPanel;	// for selecting apps to launch
70 
71 			// Points to the settings file to save to
72 			BEntry 				fLastSaved;
73 
74 			// true iff changes were made since last load or save
75 			bool				fKeySetModified;
76 
77 			// true iff the file-requester's ref should be appended to current
78 			bool 				fLastOpenWasAppend;
79 };
80 
81 
82 #endif
83 
84