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