virtualkeyboard: code style fixes
This commit is contained in:
committed by
François Revol
parent
b8fe0b588d
commit
67b3c67768
@@ -6,14 +6,14 @@ UsePrivateSystemHeaders ;
|
|||||||
AddResources <input>virtualkeyboard : VirtualKeyboard.rdef ;
|
AddResources <input>virtualkeyboard : VirtualKeyboard.rdef ;
|
||||||
|
|
||||||
Addon <input>virtualkeyboard :
|
Addon <input>virtualkeyboard :
|
||||||
|
|
||||||
KeyboardLayout.cpp
|
KeyboardLayout.cpp
|
||||||
KeyboardLayoutView.cpp
|
KeyboardLayoutView.cpp
|
||||||
Keymap.cpp
|
Keymap.cpp
|
||||||
KeymapListItem.cpp
|
KeymapListItem.cpp
|
||||||
VirtualKeyboardInputDevice.cpp
|
VirtualKeyboardInputDevice.cpp
|
||||||
VirtualKeyboardWindow.cpp
|
VirtualKeyboardWindow.cpp
|
||||||
|
|
||||||
: be tracker input_server localestub libshared.a $(TARGET_LIBSTDC++)
|
: be tracker input_server localestub libshared.a $(TARGET_LIBSTDC++)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -87,11 +87,6 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
KeyboardLayoutView::KeyboardLayoutView(const char* name,
|
KeyboardLayoutView::KeyboardLayoutView(const char* name,
|
||||||
BInputServerDevice* dev)
|
BInputServerDevice* dev)
|
||||||
:
|
:
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ private:
|
|||||||
void _SetFontSize(BView* view, key_kind keyKind);
|
void _SetFontSize(BView* view, key_kind keyKind);
|
||||||
void _EvaluateDropTarget(BPoint point);
|
void _EvaluateDropTarget(BPoint point);
|
||||||
void _SendKeyDown(const Key* key);
|
void _SendKeyDown(const Key* key);
|
||||||
|
|
||||||
BBitmap* fOffscreenBitmap;
|
BBitmap* fOffscreenBitmap;
|
||||||
BView* fOffscreenView;
|
BView* fOffscreenView;
|
||||||
|
|
||||||
@@ -121,9 +121,8 @@ private:
|
|||||||
BPoint fOffset;
|
BPoint fOffset;
|
||||||
float fFactor;
|
float fFactor;
|
||||||
float fGap;
|
float fGap;
|
||||||
|
|
||||||
BInputServerDevice* fDevice;
|
|
||||||
|
|
||||||
|
BInputServerDevice* fDevice;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ print_key(char *chars, int32 offset, bool last = false)
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
// 2-, 3-, or 4-byte UTF-8 character
|
// 2-, 3-, or 4-byte UTF-8 character
|
||||||
char *str = new char[size + 1];
|
char* str = new char[size + 1];
|
||||||
strncpy(str, &chars[offset], size);
|
strncpy(str, &chars[offset], size);
|
||||||
str[size] = 0;
|
str[size] = 0;
|
||||||
fputs(str, stdout);
|
fputs(str, stdout);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
* A BStringItem modified such that it holds
|
* A BStringItem modified such that it holds
|
||||||
* the BEntry object it corresponds with
|
* the BEntry object it corresponds with
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "KeymapListItem.h"
|
#include "KeymapListItem.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ VirtualKeyboardInputDevice::Stop(const char* name, void* cookie)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
VirtualKeyboardInputDevice::Control(const char* name, void* cookie,
|
VirtualKeyboardInputDevice::Control(const char* name, void* cookie,
|
||||||
uint32 command, BMessage* message)
|
uint32 command, BMessage* message)
|
||||||
{
|
{
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
* Copyright 2014 Freeman Lou <freemanlou2430@yahoo.com>
|
* Copyright 2014 Freeman Lou <freemanlou2430@yahoo.com>
|
||||||
* All rights reserved. Distributed under the terms of the MIT license.
|
* All rights reserved. Distributed under the terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
#ifndef VKID_H
|
#ifndef VIRTUAL_KEYBOARD_INPUT_DEVICE_H
|
||||||
#define VKID_H
|
#define VIRTUAL_KEYBOARD_INPUT_DEVICE_H
|
||||||
|
|
||||||
|
|
||||||
#include <InputServerDevice.h>
|
#include <InputServerDevice.h>
|
||||||
@@ -23,9 +23,9 @@ public:
|
|||||||
uint32 command, BMessage* message);
|
uint32 command, BMessage* message);
|
||||||
private:
|
private:
|
||||||
VirtualKeyboardWindow* fKeyboardWindow;
|
VirtualKeyboardWindow* fKeyboardWindow;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" BInputServerDevice* instantiate_input_device();
|
extern "C" BInputServerDevice* instantiate_input_device();
|
||||||
|
|
||||||
#endif // VKID_H
|
#endif // VIRTUAL_KEYBOARD_INPUT_DEVICE_H
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#include "KeyboardLayoutView.h"
|
#include "KeyboardLayoutView.h"
|
||||||
#include "KeymapListItem.h"
|
#include "KeymapListItem.h"
|
||||||
|
|
||||||
static const uint32 kMsgMenuFontChange = 'MMFC';
|
static const uint32 kMsgMenuFontChange = 'mMFC';
|
||||||
|
|
||||||
static int
|
static int
|
||||||
compare_key_list_items(const void* a, const void* b)
|
compare_key_list_items(const void* a, const void* b)
|
||||||
@@ -40,30 +40,30 @@ VirtualKeyboardWindow::VirtualKeyboardWindow(BInputServerDevice* dev)
|
|||||||
BScreen screen;
|
BScreen screen;
|
||||||
BRect screenRect(screen.Frame());
|
BRect screenRect(screen.Frame());
|
||||||
|
|
||||||
ResizeTo(screenRect.Width(), screenRect.Height()/3);
|
ResizeTo(screenRect.Width(), screenRect.Height() / 3);
|
||||||
MoveTo(0,screenRect.Height()-screenRect.Height()/3);
|
MoveTo(0,screenRect.Height() - screenRect.Height() / 3);
|
||||||
|
|
||||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
SetLayout(new BGroupLayout(B_VERTICAL));
|
||||||
|
|
||||||
//Add to an options window later, use as list for now
|
//Add to an options window later, use as list for now
|
||||||
fMapListView = new BListView("Maps");
|
fMapListView = new BListView("Maps");
|
||||||
fFontMenu = new BMenu("Font");
|
fFontMenu = new BMenu("Font");
|
||||||
fLayoutMenu = new BMenu("Layout");
|
fLayoutMenu = new BMenu("Layout");
|
||||||
|
|
||||||
_LoadMaps();
|
_LoadMaps();
|
||||||
_LoadLayouts(fLayoutMenu);
|
_LoadLayouts(fLayoutMenu);
|
||||||
_LoadFonts();
|
_LoadFonts();
|
||||||
|
|
||||||
KeymapListItem* current =
|
KeymapListItem* current =
|
||||||
static_cast<KeymapListItem*>(fMapListView->LastItem());
|
static_cast<KeymapListItem*>(fMapListView->LastItem());
|
||||||
fCurrentKeymap.Load(current->EntryRef());
|
fCurrentKeymap.Load(current->EntryRef());
|
||||||
|
|
||||||
|
|
||||||
fKeyboardView = new KeyboardLayoutView("Keyboard",fDevice);
|
fKeyboardView = new KeyboardLayoutView("Keyboard",fDevice);
|
||||||
fKeyboardView->GetKeyboardLayout()->SetDefault();
|
fKeyboardView->GetKeyboardLayout()->SetDefault();
|
||||||
fKeyboardView->SetEditable(false);
|
fKeyboardView->SetEditable(false);
|
||||||
fKeyboardView->SetKeymap(&fCurrentKeymap);
|
fKeyboardView->SetKeymap(&fCurrentKeymap);
|
||||||
|
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
||||||
.Add(fKeyboardView));
|
.Add(fKeyboardView));
|
||||||
}
|
}
|
||||||
@@ -78,14 +78,14 @@ VirtualKeyboardWindow::_LoadLayouts(BMenu* menu)
|
|||||||
B_SYSTEM_NONPACKAGED_DIRECTORY,
|
B_SYSTEM_NONPACKAGED_DIRECTORY,
|
||||||
B_SYSTEM_DATA_DIRECTORY,
|
B_SYSTEM_DATA_DIRECTORY,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (uint i = 0; i < sizeof(dataDirectories)/sizeof(directory_which); i++) {
|
for (uint i = 0; i < sizeof(dataDirectories)/sizeof(directory_which); i++) {
|
||||||
BPath path;
|
BPath path;
|
||||||
if (find_directory(dataDirectories[i], &path) != B_OK)
|
if (find_directory(dataDirectories[i], &path) != B_OK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
path.Append("KeyboardLayouts");
|
path.Append("KeyboardLayouts");
|
||||||
|
|
||||||
BDirectory directory;
|
BDirectory directory;
|
||||||
if (directory.SetTo(path.Path()) == B_OK)
|
if (directory.SetTo(path.Path()) == B_OK)
|
||||||
_LoadLayoutMenu(menu, directory);
|
_LoadLayoutMenu(menu, directory);
|
||||||
@@ -97,11 +97,11 @@ void
|
|||||||
VirtualKeyboardWindow::_LoadLayoutMenu(BMenu* menu, BDirectory directory)
|
VirtualKeyboardWindow::_LoadLayoutMenu(BMenu* menu, BDirectory directory)
|
||||||
{
|
{
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
|
|
||||||
while (directory.GetNextRef(&ref) == B_OK) {
|
while (directory.GetNextRef(&ref) == B_OK) {
|
||||||
if (menu->FindItem(ref.name) != NULL)
|
if (menu->FindItem(ref.name) != NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BDirectory subdirectory;
|
BDirectory subdirectory;
|
||||||
subdirectory.SetTo(&ref);
|
subdirectory.SetTo(&ref);
|
||||||
if (subdirectory.InitCheck() == B_OK) {
|
if (subdirectory.InitCheck() == B_OK) {
|
||||||
@@ -123,11 +123,11 @@ VirtualKeyboardWindow::_LoadMaps()
|
|||||||
BPath path;
|
BPath path;
|
||||||
if (find_directory(B_SYSTEM_DATA_DIRECTORY, &path) != B_OK)
|
if (find_directory(B_SYSTEM_DATA_DIRECTORY, &path) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
path.Append("Keymaps");
|
path.Append("Keymaps");
|
||||||
BDirectory directory;
|
BDirectory directory;
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
|
|
||||||
if (directory.SetTo(path.Path()) == B_OK) {
|
if (directory.SetTo(path.Path()) == B_OK) {
|
||||||
while (directory.GetNextRef(&ref) == B_OK) {
|
while (directory.GetNextRef(&ref) == B_OK) {
|
||||||
fMapListView->AddItem(new KeymapListItem(ref));
|
fMapListView->AddItem(new KeymapListItem(ref));
|
||||||
@@ -144,9 +144,9 @@ VirtualKeyboardWindow::_LoadFonts()
|
|||||||
font_family family, currentFamily;
|
font_family family, currentFamily;
|
||||||
font_style currentStyle;
|
font_style currentStyle;
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
|
|
||||||
be_plain_font->GetFamilyAndStyle(¤tFamily,¤tStyle);
|
be_plain_font->GetFamilyAndStyle(¤tFamily,¤tStyle);
|
||||||
|
|
||||||
for (int32 i = 0; i< numFamilies; i++) {
|
for (int32 i = 0; i< numFamilies; i++) {
|
||||||
if (get_font_family(i, &family, &flags) == B_OK) {
|
if (get_font_family(i, &family, &flags) == B_OK) {
|
||||||
BMenuItem* item = new BMenuItem(family, NULL); //new BMessage(kMsgMenuFontChanged));
|
BMenuItem* item = new BMenuItem(family, NULL); //new BMessage(kMsgMenuFontChanged));
|
||||||
@@ -161,5 +161,5 @@ VirtualKeyboardWindow::_LoadFonts()
|
|||||||
void
|
void
|
||||||
VirtualKeyboardWindow::MessageReceived(BMessage* message)
|
VirtualKeyboardWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
|
BWindow::MessageReceived(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class VirtualKeyboardWindow : public BWindow{
|
|||||||
public:
|
public:
|
||||||
VirtualKeyboardWindow(BInputServerDevice* dev);
|
VirtualKeyboardWindow(BInputServerDevice* dev);
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KeyboardLayoutView* fKeyboardView;
|
KeyboardLayoutView* fKeyboardView;
|
||||||
BListView* fMapListView;
|
BListView* fMapListView;
|
||||||
@@ -28,7 +28,7 @@ private:
|
|||||||
BMenu* fLayoutMenu;
|
BMenu* fLayoutMenu;
|
||||||
Keymap fCurrentKeymap;
|
Keymap fCurrentKeymap;
|
||||||
BInputServerDevice* fDevice;
|
BInputServerDevice* fDevice;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _LoadLayouts(BMenu* menu);
|
void _LoadLayouts(BMenu* menu);
|
||||||
void _LoadLayoutMenu(BMenu* menu, BDirectory directory);
|
void _LoadLayoutMenu(BMenu* menu, BDirectory directory);
|
||||||
|
|||||||
Reference in New Issue
Block a user