xref: /haiku/src/preferences/input/InputWindow.cpp (revision 77fb9ca3e653f72d1d15c9f1a50c3d4287f680e0)
1 /*
2  * Copyright 2019, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  *
5  * Author:
6  *		Preetpal Kaur <preetpalok123@gmail.com>
7  */
8 
9 
10 #include <Alert.h>
11 #include <Alignment.h>
12 #include <Application.h>
13 #include <Button.h>
14 #include <CardLayout.h>
15 #include <CardView.h>
16 #include <Catalog.h>
17 #include <Control.h>
18 #include <ControlLook.h>
19 #include <LayoutBuilder.h>
20 #include <SplitView.h>
21 #include <Screen.h>
22 #include <TabView.h>
23 #include <stdio.h>
24 
25 
26 #include "InputWindow.h"
27 #include "MouseSettings.h"
28 #include "InputMouse.h"
29 #include "InputConstants.h"
30 #include "SettingsView.h"
31 #include "InputTouchpadPref.h"
32 
33 #undef B_TRANSLATION_CONTEXT
34 #define B_TRANSLATION_CONTEXT "InputWindow"
35 
36 
37 InputWindow::InputWindow(BRect rect)
38 	:
39 	BWindow(rect, B_TRANSLATE_SYSTEM_NAME("Input"), B_TITLED_WINDOW,
40 		B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS
41 		| B_AUTO_UPDATE_SIZE_LIMITS | B_QUIT_ON_WINDOW_CLOSE)
42 {
43 	fInputMouse = new InputMouse();
44 	fTouchpadPrefView = new TouchpadPrefView(B_TRANSLATE("Touchpad"));
45 	fDeviceListView = new DeviceListView(B_TRANSLATE("Device List"));
46 
47 	fCardView = new BCardView();
48 	fCardView->AddChild(fInputMouse);
49 	fCardView->AddChild(fTouchpadPrefView);
50 
51 	BLayoutBuilder::Group<>(this, B_HORIZONTAL, 10)
52 		.SetInsets(B_USE_WINDOW_SPACING)
53 		.Add(fDeviceListView)
54 		.AddGroup(B_VERTICAL, 0)
55 			.Add(fCardView)
56 		.End();
57 }
58 
59 void
60 InputWindow::MessageReceived(BMessage* message)
61 {
62 	int32 name = message->GetInt32("index", 0);
63 
64 	switch (message->what) {
65 
66 		case ITEM_SELECTED:
67 		{
68 			fCardView->CardLayout()->SetVisibleItem(name);
69 		}
70 		case kMsgMouseType:
71 		case kMsgMouseMap:
72 		case kMsgMouseFocusMode:
73 		case kMsgFollowsMouseMode:
74 		case kMsgAcceptFirstClick:
75 		case kMsgDoubleClickSpeed:
76 		case kMsgMouseSpeed:
77 		case kMsgAccelerationFactor:
78 		case kMsgDefaults:
79 		case kMsgRevert:
80 		{
81 			PostMessage(message, fInputMouse);
82 			break;
83 		}
84 		case SCROLL_AREA_CHANGED:
85 		case SCROLL_CONTROL_CHANGED:
86 		case TAP_CONTROL_CHANGED:
87 		case DEFAULT_SETTINGS:
88 		case REVERT_SETTINGS:
89 		{
90 			PostMessage(message, fTouchpadPrefView);
91 			break;
92 		}
93 		default:
94 			BWindow::MessageReceived(message);
95 			break;
96 	}
97 }
98