textview enhancements, still need to have mouse working
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8398 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -7,4 +7,5 @@ Preference Keymap :
|
||||
KeymapWindow.cpp
|
||||
KeymapListItem.cpp
|
||||
Keymap.cpp
|
||||
KeymapTextView.cpp
|
||||
: be ;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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 <TextView.h>
|
||||
|
||||
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
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <Application.h>
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <Clipboard.h>
|
||||
#include <Debug.h>
|
||||
#include <Directory.h>
|
||||
#include <FindDirectory.h>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <interface/Window.h>
|
||||
#include <support/List.h>
|
||||
#include <interface/MenuBar.h>
|
||||
#include "KeymapTextView.h"
|
||||
#include "Keymap.h"
|
||||
|
||||
#define WINDOW_TITLE "Keymap"
|
||||
@@ -48,7 +49,7 @@ private:
|
||||
BFont fCurrentFont;
|
||||
|
||||
Keymap *fCurrentMap;
|
||||
BTextView *fTextView;
|
||||
KeymapTextView *fTextView;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user