xref: /haiku/src/preferences/keymap/ModifierKeysWindow.h (revision da4dbfa47a47beb355289f3dd685797cee69ab77)
1 /*
2  * Copyright 2011-2023 Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		John Scipione, jscipione@gmail.com
7  *		Jorge Acereda, jacereda@gmail.com
8  */
9 #ifndef MODIFIER_KEYS_WINDOW_H
10 #define MODIFIER_KEYS_WINDOW_H
11 
12 
13 #include <View.h>
14 #include <Window.h>
15 
16 
17 class BMenuField;
18 class BPopUpMenu;
19 
20 
21 class ConflictView : public BView {
22 public:
23 								ConflictView(const char* name);
24 								~ConflictView();
25 
26 	virtual	void				Draw(BRect updateRect);
27 
28 			BBitmap*			Icon();
29 			void				SetStopIcon(bool show);
30 			void				SetWarnIcon(bool show);
31 
32 private:
33 			void				_FillIcons();
34 
35 			BBitmap*			fIcon;
36 			BBitmap*			fStopIcon;
37 			BBitmap*			fWarnIcon;
38 };
39 
40 
41 class ModifierKeysWindow : public BWindow {
42 public:
43 									ModifierKeysWindow();
44 	virtual							~ModifierKeysWindow();
45 
46 	virtual	void					MessageReceived(BMessage* message);
47 
48 private:
49 			void					_CreateMenuField(BPopUpMenu** _menu, BMenuField** _field,
50 										uint32 key, const char* label);
51 			void					_MarkMenuItems();
52 			void					_MarkMenuItem(BPopUpMenu* menu, ConflictView* conflictView,
53 										uint32 leftKey, uint32 rightKey);
54 			const char*				_KeyToString(int32 key);
55 			uint32					_KeyToKeyCode(int32 key,
56 										bool right = false);
57 			int32					_LastKey();
58 			void					_ValidateDuplicateKeys();
59 			void					_ValidateDuplicateKey(ConflictView* view, uint32 mask);
60 			uint32					_DuplicateKeys();
61 			void					_HideShowStatusIcons();
62 			void					_ToggleStatusIcon(ConflictView* view);
63 			void					_UpdateStatus();
64 
65 			BPopUpMenu*				fCapsMenu;
66 			BPopUpMenu*				fShiftMenu;
67 			BPopUpMenu*				fControlMenu;
68 			BPopUpMenu*				fOptionMenu;
69 			BPopUpMenu*				fCommandMenu;
70 
71 			ConflictView*			fCapsConflictView;
72 			ConflictView*			fShiftConflictView;
73 			ConflictView*			fControlConflictView;
74 			ConflictView*			fOptionConflictView;
75 			ConflictView*			fCommandConflictView;
76 
77 			BButton*				fRevertButton;
78 			BButton*				fCancelButton;
79 			BButton*				fOkButton;
80 
81 			key_map*				fCurrentMap;
82 			key_map*				fSavedMap;
83 
84 			char*					fCurrentBuffer;
85 			char*					fSavedBuffer;
86 };
87 
88 
89 #endif	// MODIFIER_KEYS_WINDOW_H
90