xref: /haiku/src/preferences/keymap/KeymapWindow.h (revision a381c8a06378de22ff08adf4282b4e3f7e50d250)
1 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
2 //
3 //	Copyright (c) 2004, Haiku
4 //
5 //  This software is part of the Haiku distribution and is covered
6 //  by the Haiku license.
7 //
8 //
9 //  File:        KeymapWindow.h
10 //  Author:      Sandor Vroemisse, Jérôme Duval
11 //  Description: Keymap Preferences
12 //  Created :    July 12, 2004
13 //
14 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
15 
16 #ifndef KEYMAP_WINDOW_H
17 #define KEYMAP_WINDOW_H
18 
19 #include <Control.h>
20 #include <FilePanel.h>
21 #include <ListView.h>
22 #include <Window.h>
23 #include <MenuBar.h>
24 #include "KeymapTextView.h"
25 #include "Keymap.h"
26 
27 class KeymapListItem;
28 class BBitmap;
29 
30 class MapView : public BControl
31 {
32 public:
33 	MapView(BRect rect, const char *name, Keymap *keymap);
34 	~MapView();
35 
36 	void Draw(BRect rect);
37 	void AttachedToWindow();
38 	void KeyDown(const char* bytes, int32 numBytes);
39 	void KeyUp(const char* bytes, int32 numBytes);
40 	void MessageReceived(BMessage *msg);
41 	void SetFontFamily(const font_family family);
42 	void MouseDown(BPoint point);
43 	void MouseUp(BPoint point);
44 	void MouseMoved(BPoint point, uint32 transit, const BMessage *msg);
45 
46 private:
47 	void _InvalidateKey(uint32 keyCode);
48 	void _InvalidateKeys();
49 	void _DrawKey(uint32 keyCode);
50 	void _DrawBackground();
51 	void _DrawKeysBackground();
52 	void _DrawLocksBackground();
53 	void _DrawBorder(BView *view, const BRect &borderRect);
54 	void _DrawLocksLights();
55 	void _InitOffscreen();
56 
57 	BBitmap		*fBitmap;
58 	BView		*fOffscreenView;
59 
60 	key_info fOldKeyInfo;
61 	BRect fKeysRect[128];
62 	bool fKeysVertical[128];
63 	bool fKeysToDraw[128];
64 	uint8 fKeyState[16];
65 	BFont fCurrentFont;
66 
67 	Keymap				*fCurrentMap;
68 	KeymapTextView		*fTextView;
69 	uint32 fCurrentMouseKey;
70 	uint8 fActiveDeadKey;		// 0 : none, 1 : acute , ...
71 };
72 
73 
74 class KeymapWindow : public BWindow {
75 public:
76 			KeymapWindow();
77 			~KeymapWindow();
78 	bool	QuitRequested();
79 	void	MessageReceived( BMessage* message );
80 
81 protected:
82 	BListView			*fSystemListView;
83 	BListView			*fUserListView;
84 	// the map that's currently highlighted
85 	BButton				*fUseButton;
86 	BButton				*fRevertButton;
87 	BMenu				*fFontMenu;
88 
89 	MapView				*fMapView;
90 
91 	BMenuBar			*AddMenuBar();
92 	void				AddMaps(BView *placeholderView);
93 	void				UseKeymap();
94 
95 	void 				FillSystemMaps();
96 	void 				FillUserMaps();
97 
98 	BEntry* 			CurrentMap();
99 
100 	Keymap				fCurrentMap;
101 
102 	BFilePanel 			*fOpenPanel;		// the file panel to open
103 	BFilePanel 			*fSavePanel;		// the file panel to save
104 };
105 
106 #endif // KEYMAP_WINDOW_H
107