xref: /haiku/src/preferences/keymap/KeymapWindow.h (revision 5e7964b0a929555415798dea3373db9ac4611caa)
1 /*
2  * Copyright 2004-2014 Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Alexandre Deckner, alex@zappotek.com
7  *		Axel Dörfler, axeld@pinc-software.de
8  *		Jérôme Duval
9  *		John Scipione, jscipione@gmai.com
10  *		Sandor Vroemisse
11  */
12 #ifndef KEYMAP_WINDOW_H
13 #define KEYMAP_WINDOW_H
14 
15 
16 #include <FilePanel.h>
17 #include <ListView.h>
18 #include <String.h>
19 #include <Window.h>
20 
21 #include "Keymap.h"
22 
23 
24 class BMenu;
25 class BMenuBar;
26 class BMenuField;
27 class BTextControl;
28 class KeyboardLayoutView;
29 class KeymapListItem;
30 
31 
32 class KeymapWindow : public BWindow {
33 public:
34 								KeymapWindow();
35 	virtual						~KeymapWindow();
36 
37 	virtual	bool				QuitRequested();
38 	virtual void				MessageReceived(BMessage* message);
39 
40 protected:
41 			BMenuBar*			_CreateMenu();
42 			BView*				_CreateMapLists();
43 			void				_AddKeyboardLayouts(BMenu* menu);
44 			void				_AddKeyboardLayoutMenu(BMenu* menu,
45 									BDirectory directory);
46 			status_t			_SetKeyboardLayout(const char* path);
47 			void				_MarkKeyboardLayoutItem(const char* path,
48 									BMenu* menu);
49 
50 			void				_UpdateSwitchShortcutButton();
51 			void				_UpdateButtons();
52 			void				_SwitchShortcutKeys();
53 
54 			void				_UseKeymap();
55 			void				_DefaultKeymap();
56 			void				_RevertKeymap();
57 
58 			BMenuField*			_CreateDeadKeyMenuField();
59 			void				_UpdateDeadKeyMenu();
60 
61 			void 				_FillSystemMaps();
62 			void				_FillUserMaps();
63 			void				_SetListViewSize(BListView* listView);
64 
65 			status_t			_GetCurrentKeymap(entry_ref& ref);
66 			BString				_GetActiveKeymapName();
67 			bool				_SelectCurrentMap(BListView* list);
68 			void				_SelectCurrentMap();
69 
70 			status_t			_GetSettings(BFile& file, int mode) const;
71 			status_t			_LoadSettings(BRect& frame);
72 			status_t			_SaveSettings();
73 			BPath				_GetMarkedKeyboardLayoutPath(BMenu* menu);
74 
75 private:
76 			BListView*			fSystemListView;
77 			BListView*			fUserListView;
78 			BButton*			fDefaultsButton;
79 			BButton*			fRevertButton;
80 			BMenu*				fLayoutMenu;
81 			BMenu*				fFontMenu;
82 			KeyboardLayoutView*	fKeyboardLayoutView;
83 			BTextControl*		fTextControl;
84 			BButton*			fSwitchShortcutsButton;
85 			BMenu*				fAcuteMenu;
86 			BMenu*				fCircumflexMenu;
87 			BMenu*				fDiaeresisMenu;
88 			BMenu*				fGraveMenu;
89 			BMenu*				fTildeMenu;
90 
91 			Keymap				fCurrentMap;
92 			Keymap				fPreviousMap;
93 			Keymap				fAppliedMap;
94 			BString				fCurrentMapName;
95 
96 			BFilePanel*			fOpenPanel;
97 			BFilePanel*			fSavePanel;
98 };
99 
100 #endif	// KEYMAP_WINDOW_H
101