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