virtualkeyboard: style fixes
Change-Id: Iee76c0cae38a0677b60e51f73aa0e2e5d9b7c2ee Reviewed-on: https://review.haiku-os.org/c/haiku/+/8902 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
c8cd427e30
commit
9d2283baab
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
|
|
||||||
|
|
||||||
extern "C" BInputServerDevice*
|
extern "C" BInputServerDevice*
|
||||||
instantiate_input_device()
|
instantiate_input_device()
|
||||||
{
|
{
|
||||||
@@ -26,8 +27,7 @@ VirtualKeyboardInputDevice::~VirtualKeyboardInputDevice()
|
|||||||
status_t
|
status_t
|
||||||
VirtualKeyboardInputDevice::InitCheck()
|
VirtualKeyboardInputDevice::InitCheck()
|
||||||
{
|
{
|
||||||
static input_device_ref keyboard = {(char*) "VirtualKeyboard",
|
static input_device_ref keyboard = {(char*)"VirtualKeyboard", B_KEYBOARD_DEVICE, (void*)this};
|
||||||
B_KEYBOARD_DEVICE, (void*) this};
|
|
||||||
static input_device_ref* devices[2] = {&keyboard, NULL};
|
static input_device_ref* devices[2] = {&keyboard, NULL};
|
||||||
|
|
||||||
RegisterDevices(devices);
|
RegisterDevices(devices);
|
||||||
@@ -56,8 +56,8 @@ 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,
|
||||||
uint32 command, BMessage* message)
|
BMessage* message)
|
||||||
{
|
{
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,20 +32,19 @@ compare_key_list_items(const void* a, const void* b)
|
|||||||
|
|
||||||
VirtualKeyboardWindow::VirtualKeyboardWindow(BInputServerDevice* dev)
|
VirtualKeyboardWindow::VirtualKeyboardWindow(BInputServerDevice* dev)
|
||||||
:
|
:
|
||||||
BWindow(BRect(0,0,0,0),"Virtual Keyboard",
|
BWindow(BRect(0, 0, 0, 0), "Virtual Keyboard", B_NO_BORDER_WINDOW_LOOK,
|
||||||
B_NO_BORDER_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL,
|
B_FLOATING_ALL_WINDOW_FEEL, B_WILL_ACCEPT_FIRST_CLICK | B_AVOID_FOCUS),
|
||||||
B_WILL_ACCEPT_FIRST_CLICK | B_AVOID_FOCUS),
|
|
||||||
fDevice(dev)
|
fDevice(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");
|
||||||
@@ -54,17 +53,15 @@ VirtualKeyboardWindow::VirtualKeyboardWindow(BInputServerDevice* dev)
|
|||||||
_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->SetKeymap(&fCurrentKeymap);
|
fKeyboardView->SetKeymap(&fCurrentKeymap);
|
||||||
|
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
AddChild(BGroupLayoutBuilder(B_VERTICAL).Add(fKeyboardView));
|
||||||
.Add(fKeyboardView));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -78,7 +75,7 @@ VirtualKeyboardWindow::_LoadLayouts(BMenu* menu)
|
|||||||
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;
|
||||||
@@ -108,8 +105,8 @@ VirtualKeyboardWindow::_LoadLayoutMenu(BMenu* menu, BDirectory directory)
|
|||||||
_LoadLayoutMenu(submenu, subdirectory);
|
_LoadLayoutMenu(submenu, subdirectory);
|
||||||
menu->AddItem(submenu);
|
menu->AddItem(submenu);
|
||||||
} else {
|
} else {
|
||||||
//BMessage* message = new BMessage(kChangeKeyboardLayout);
|
// BMessage* message = new BMessage(kChangeKeyboardLayout);
|
||||||
//message->AddRed("ref",&ref);
|
// message->AddRed("ref",&ref);
|
||||||
menu->AddItem(new BMenuItem(ref.name, NULL));
|
menu->AddItem(new BMenuItem(ref.name, NULL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,11 +141,11 @@ VirtualKeyboardWindow::_LoadFonts()
|
|||||||
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));
|
||||||
fFontMenu->AddItem(item);
|
fFontMenu->AddItem(item);
|
||||||
if (!strcmp(family, currentFamily))
|
if (!strcmp(family, currentFamily))
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ class BDirectory;
|
|||||||
class BListView;
|
class BListView;
|
||||||
class BMenu;
|
class BMenu;
|
||||||
|
|
||||||
class VirtualKeyboardWindow : public BWindow{
|
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user