diff --git a/src/prefs/keymap/Jamfile b/src/prefs/keymap/Jamfile index feacd5d7f1..326275c900 100644 --- a/src/prefs/keymap/Jamfile +++ b/src/prefs/keymap/Jamfile @@ -7,4 +7,5 @@ Preference Keymap : KeymapWindow.cpp KeymapListItem.cpp Keymap.cpp + KeymapTextView.cpp : be ; diff --git a/src/prefs/keymap/KeymapTextView.cpp b/src/prefs/keymap/KeymapTextView.cpp new file mode 100644 index 0000000000..f19f5acb47 --- /dev/null +++ b/src/prefs/keymap/KeymapTextView.cpp @@ -0,0 +1,43 @@ +// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ +// +// Copyright (c) 2004, Haiku +// +// This software is part of the Haiku distribution and is covered +// by the Haiku license. +// +// +// File: KeymapTextView.cpp +// Author: Jérôme Duval +// Description: Keymap Preferences +// Created : July 14, 2004 +// +// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + +#include "KeymapTextView.h" + + +KeymapTextView::KeymapTextView(BRect frame, + const char *name, + BRect textRect, + uint32 resizeMask, + uint32 flags = B_WILL_DRAW | B_PULSE_NEEDED) : + BTextView(frame, name, textRect, resizeMask, flags) +{ + + +} + + +void +KeymapTextView::KeyDown(const char *bytes, int32 numBytes) +{ + + +} + + +void +KeymapTextView::FakeKeyDown(const char *bytes, int32 numBytes) +{ + BTextView::KeyDown(bytes, numBytes); +} diff --git a/src/prefs/keymap/KeymapTextView.h b/src/prefs/keymap/KeymapTextView.h new file mode 100644 index 0000000000..d281ea10e3 --- /dev/null +++ b/src/prefs/keymap/KeymapTextView.h @@ -0,0 +1,34 @@ +// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ +// +// Copyright (c) 2004, Haiku +// +// This software is part of the Haiku distribution and is covered +// by the Haiku license. +// +// +// File: KeymapTextView.h +// Author: Jérôme Duval +// Description: Keymap Preferences +// Created : July 14, 2004 +// +// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + +#ifndef KEYMAPTEXTVIEW_H +#define KEYMAPTEXTVIEW_H + +#include + +class KeymapTextView : public BTextView +{ +public: + KeymapTextView(BRect frame, + const char *name, + BRect textRect, + uint32 resizeMask, + uint32 flags = B_WILL_DRAW | B_PULSE_NEEDED); + virtual void KeyDown(const char *bytes, int32 numBytes); + virtual void FakeKeyDown(const char *bytes, int32 numBytes); +}; + + +#endif //KEYMAPTEXTVIEW_H diff --git a/src/prefs/keymap/KeymapWindow.cpp b/src/prefs/keymap/KeymapWindow.cpp index e25b8eda5b..e93115eb5e 100644 --- a/src/prefs/keymap/KeymapWindow.cpp +++ b/src/prefs/keymap/KeymapWindow.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -57,9 +58,9 @@ KeymapWindow::KeymapWindow( BRect frame ) // The view to hold all but the menu bar BRect bounds = Bounds(); bounds.top = menubar->Bounds().bottom + 1; - BView *placeholderView = new BView( bounds, "placeholderView", - B_FOLLOW_NONE, 0 ); - placeholderView->SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR)); + BBox *placeholderView = new BBox(bounds, "placeholderView", + B_FOLLOW_ALL); + placeholderView->SetBorder(B_NO_BORDER); AddChild( placeholderView ); // Create the Maps box and contents @@ -708,7 +709,7 @@ MapView::MapView(BRect rect, const char *name, Keymap* keymap) BRect textRect = frameRect; textRect.OffsetTo(B_ORIGIN); textRect.InsetBy(1,1); - fTextView = new BTextView(frameRect, "testzone", textRect, + fTextView = new KeymapTextView(frameRect, "testzone", textRect, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS); fTextView->MakeEditable(true); fTextView->MakeSelectable(true); @@ -1208,16 +1209,25 @@ MapView::MessageReceived(BMessage *msg) fOldKeyInfo.key_states[i] = states[i]; Invalidate(); } else { - + int32 keyCode = -1; for (int8 i=0; i<16; i++) if (fOldKeyInfo.key_states[i] != states[i]) { uint8 stbits = fOldKeyInfo.key_states[i] ^ states[i]; fOldKeyInfo.key_states[i] = states[i]; for (int8 j=7; stbits; j--,stbits>>=1) - if (stbits & 1) - DrawKey(i*8 + j); + if (stbits & 1) { + keyCode = i*8 + j; + DrawKey(keyCode); + } } + if (Window()->IsActive() && keyCode >= 0 + && msg->what == B_KEY_DOWN) { + fTextView->MakeFocus(); + char *str; + fCurrentMap->GetChars(keyCode, fOldKeyInfo.modifiers, &str); + fTextView->FakeKeyDown(str, 1); + } } } diff --git a/src/prefs/keymap/KeymapWindow.h b/src/prefs/keymap/KeymapWindow.h index 7e9537d663..f1dc43e0cc 100644 --- a/src/prefs/keymap/KeymapWindow.h +++ b/src/prefs/keymap/KeymapWindow.h @@ -19,6 +19,7 @@ #include #include #include +#include "KeymapTextView.h" #include "Keymap.h" #define WINDOW_TITLE "Keymap" @@ -48,7 +49,7 @@ private: BFont fCurrentFont; Keymap *fCurrentMap; - BTextView *fTextView; + KeymapTextView *fTextView; };