Code style changes and License/Copyright fixes.

I hope I found most of them.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32832 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Fredrik Modeen
2009-08-30 14:03:37 +00:00
parent 83a23fd38b
commit e8f87bad4c
11 changed files with 189 additions and 209 deletions
+5 -4
View File
@@ -1,11 +1,11 @@
/* /*
* Copyright 2002-2006, Haiku. All rights reserved. * Copyright 2003-2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Andrew McCall ([email protected]) * Jérôme Duval,
* Jérôme Duval
* Axel Dörfler ([email protected]) * Axel Dörfler ([email protected])
* Andrew McCall ([email protected])
*/ */
@@ -20,7 +20,8 @@ const char* kSignature = "application/x-vnd.Haiku-Mouse";
MouseApplication::MouseApplication() MouseApplication::MouseApplication()
: BApplication(kSignature) :
BApplication(kSignature)
{ {
BRect rect(0, 0, 397, 293); BRect rect(0, 0, 397, 293);
MouseWindow *window = new MouseWindow(rect); MouseWindow *window = new MouseWindow(rect);
+6 -4
View File
@@ -1,12 +1,14 @@
/* /*
* Copyright 2002-2006, Haiku. All rights reserved. * Copyright 2003-2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Andrew McCall ([email protected]) * Jérôme Duval,
* Jérôme Duval
* Axel Dörfler ([email protected]) * Axel Dörfler ([email protected])
* Andrew McCall ([email protected])
*/ */
#ifndef MOUSE_H #ifndef MOUSE_H
#define MOUSE_H #define MOUSE_H
@@ -15,7 +17,7 @@
class MouseApplication : public BApplication { class MouseApplication : public BApplication {
public: public:
MouseApplication(); MouseApplication();
virtual void AboutRequested(); virtual void AboutRequested();
+10 -16
View File
@@ -1,19 +1,13 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ /*
// * Copyright 2003-2009 Haiku Inc. All rights reserved.
// Copyright (c) 2003, OpenBeOS * Distributed under the terms of the MIT License.
// *
// This software is part of the OpenBeOS distribution and is covered * Authors:
// by the OpenBeOS license. * Jérôme Duval,
// * Axel Dörfler ([email protected])
// * Andrew McCall ([email protected])
// File: MouseConstants.h */
// Authors: Jérôme Duval,
// Andrew McCall ([email protected])
// Axel Dörfler ([email protected])
// Description: Mouse Preferences
// Created: December 10, 2003
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#ifndef MOUSE_CONSTANTS_H #ifndef MOUSE_CONSTANTS_H
#define MOUSE_CONSTANTS_H #define MOUSE_CONSTANTS_H
+34 -41
View File
@@ -1,19 +1,13 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ /*
// * Copyright 2003-2009 Haiku Inc. All rights reserved.
// Copyright (c) 2003, OpenBeOS * Distributed under the terms of the MIT License.
// *
// This software is part of the OpenBeOS distribution and is covered * Authors:
// by the OpenBeOS license. * Jérôme Duval,
// * Axel Dörfler ([email protected])
// * Andrew McCall ([email protected])
// File: MouseSettings.h */
// Authors: Jérôme Duval,
// Andrew McCall ([email protected]),
// Axel Dörfler ([email protected])
// Description: Mouse Preferences
// Created: December 10, 2003
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#include <FindDirectory.h> #include <FindDirectory.h>
#include <File.h> #include <File.h>
@@ -39,7 +33,7 @@ MouseSettings::MouseSettings()
: :
fWindowPosition(-1, -1) fWindowPosition(-1, -1)
{ {
RetrieveSettings(); _RetrieveSettings();
fOriginalSettings = fSettings; fOriginalSettings = fSettings;
fOriginalMode = fMode; fOriginalMode = fMode;
@@ -48,12 +42,12 @@ MouseSettings::MouseSettings()
MouseSettings::~MouseSettings() MouseSettings::~MouseSettings()
{ {
SaveSettings(); _SaveSettings();
} }
status_t status_t
MouseSettings::GetSettingsPath(BPath &path) MouseSettings::_GetSettingsPath(BPath &path)
{ {
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path); status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
if (status < B_OK) if (status < B_OK)
@@ -65,19 +59,19 @@ MouseSettings::GetSettingsPath(BPath &path)
void void
MouseSettings::RetrieveSettings() MouseSettings::_RetrieveSettings()
{ {
// retrieve current values // retrieve current values
if (get_mouse_map(&fSettings.map)!=B_OK) if (get_mouse_map(&fSettings.map) != B_OK)
fprintf(stderr, "error when get_mouse_map\n"); fprintf(stderr, "error when get_mouse_map\n");
if (get_click_speed(&fSettings.click_speed)!=B_OK) if (get_click_speed(&fSettings.click_speed) != B_OK)
fprintf(stderr, "error when get_click_speed\n"); fprintf(stderr, "error when get_click_speed\n");
if (get_mouse_speed(&fSettings.accel.speed)!=B_OK) if (get_mouse_speed(&fSettings.accel.speed) != B_OK)
fprintf(stderr, "error when get_mouse_speed\n"); fprintf(stderr, "error when get_mouse_speed\n");
if (get_mouse_acceleration(&fSettings.accel.accel_factor)!=B_OK) if (get_mouse_acceleration(&fSettings.accel.accel_factor) != B_OK)
fprintf(stderr, "error when get_mouse_acceleration\n"); fprintf(stderr, "error when get_mouse_acceleration\n");
if (get_mouse_type(&fSettings.type)!=B_OK) if (get_mouse_type(&fSettings.type) != B_OK)
fprintf(stderr, "error when get_mouse_type\n"); fprintf(stderr, "error when get_mouse_type\n");
fMode = mouse_mode(); fMode = mouse_mode();
@@ -85,7 +79,7 @@ MouseSettings::RetrieveSettings()
// also try to load the window position from disk // also try to load the window position from disk
BPath path; BPath path;
if (GetSettingsPath(path) < B_OK) if (_GetSettingsPath(path) < B_OK)
return; return;
BFile file(path.Path(), B_READ_ONLY); BFile file(path.Path(), B_READ_ONLY);
@@ -93,13 +87,15 @@ MouseSettings::RetrieveSettings()
return; return;
#if R5_COMPATIBLE #if R5_COMPATIBLE
const off_t kOffset = sizeof(mouse_settings) - sizeof(mouse_map) + sizeof(int32) * 3; const off_t kOffset = sizeof(mouse_settings) - sizeof(mouse_map)
+ sizeof(int32) * 3;
// we have to do this because mouse_map counts 16 buttons in OBOS // we have to do this because mouse_map counts 16 buttons in OBOS
#else #else
const off_t kOffset = sizeof(mouse_settings); const off_t kOffset = sizeof(mouse_settings);
#endif #endif
if (file.ReadAt(kOffset, &fWindowPosition, sizeof(BPoint)) != sizeof(BPoint)) { if (file.ReadAt(kOffset, &fWindowPosition, sizeof(BPoint))
!= sizeof(BPoint)) {
// set default window position (invalid positions will be // set default window position (invalid positions will be
// corrected by the application; the window will be centered // corrected by the application; the window will be centered
// in this case) // in this case)
@@ -114,10 +110,10 @@ MouseSettings::RetrieveSettings()
status_t status_t
MouseSettings::SaveSettings() MouseSettings::_SaveSettings()
{ {
BPath path; BPath path;
status_t status = GetSettingsPath(path); status_t status = _GetSettingsPath(path);
if (status < B_OK) if (status < B_OK)
return status; return status;
@@ -126,7 +122,8 @@ MouseSettings::SaveSettings()
return status; return status;
#if R5_COMPATIBLE #if R5_COMPATIBLE
const off_t kOffset = sizeof(mouse_settings) - sizeof(mouse_map) + sizeof(int32) * 3; const off_t kOffset = sizeof(mouse_settings) - sizeof(mouse_map)
+ sizeof(int32) * 3;
// we have to do this because mouse_map counts 16 buttons in OBOS // we have to do this because mouse_map counts 16 buttons in OBOS
#else #else
const off_t kOffset = sizeof(mouse_settings); const off_t kOffset = sizeof(mouse_settings);
@@ -143,7 +140,9 @@ void
MouseSettings::Dump() MouseSettings::Dump()
{ {
printf("type:\t\t%ld button mouse\n", fSettings.type); printf("type:\t\t%ld button mouse\n", fSettings.type);
printf("map:\t\tleft = %lu : middle = %lu : right = %lu\n", fSettings.map.button[0], fSettings.map.button[2], fSettings.map.button[1]); printf("map:\t\tleft = %lu : middle = %lu : right = %lu\n",
fSettings.map.button[0], fSettings.map.button[2],
fSettings.map.button[1]);
printf("click speed:\t%Ld\n", fSettings.click_speed); printf("click speed:\t%Ld\n", fSettings.click_speed);
printf("accel:\t\t%s\n", fSettings.accel.enabled ? "enabled" : "disabled"); printf("accel:\t\t%s\n", fSettings.accel.enabled ? "enabled" : "disabled");
printf("accel factor:\t%ld\n", fSettings.accel.accel_factor); printf("accel factor:\t%ld\n", fSettings.accel.accel_factor);
@@ -169,9 +168,7 @@ MouseSettings::Dump()
#endif #endif
/** Resets the settings to the system defaults // Resets the settings to the system defaults
*/
void void
MouseSettings::Defaults() MouseSettings::Defaults()
{ {
@@ -191,9 +188,7 @@ MouseSettings::Defaults()
} }
/** Checks if the settings are different then the system defaults // Checks if the settings are different then the system defaults
*/
bool bool
MouseSettings::IsDefaultable() MouseSettings::IsDefaultable()
{ {
@@ -208,9 +203,7 @@ MouseSettings::IsDefaultable()
} }
/** Reverts to the active settings at program startup // Reverts to the active settings at program startup
*/
void void
MouseSettings::Revert() MouseSettings::Revert()
{ {
+10 -8
View File
@@ -1,12 +1,14 @@
/* /*
* Copyright 2003-2007, Haiku Inc. All Rights Reserved. * Copyright 2003-2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Jérôme Duval * Jérôme Duval,
* Andrew McCall ([email protected])
* Axel Dörfler ([email protected]) * Axel Dörfler ([email protected])
* Andrew McCall ([email protected])
*/ */
#ifndef MOUSE_SETTINGS_H #ifndef MOUSE_SETTINGS_H
#define MOUSE_SETTINGS_H #define MOUSE_SETTINGS_H
@@ -20,7 +22,7 @@ class BPath;
class MouseSettings { class MouseSettings {
public: public:
MouseSettings(); MouseSettings();
~MouseSettings(); ~MouseSettings();
@@ -52,10 +54,10 @@ class MouseSettings {
mode_mouse MouseMode() const { return fMode; } mode_mouse MouseMode() const { return fMode; }
void SetMouseMode(mode_mouse mode); void SetMouseMode(mode_mouse mode);
private: private:
static status_t GetSettingsPath(BPath &path); static status_t _GetSettingsPath(BPath &path);
void RetrieveSettings(); void _RetrieveSettings();
status_t SaveSettings(); status_t _SaveSettings();
mouse_settings fSettings, fOriginalSettings; mouse_settings fSettings, fOriginalSettings;
mode_mouse fMode, fOriginalMode; mode_mouse fMode, fOriginalMode;
+29 -20
View File
@@ -1,14 +1,15 @@
/* /*
* Copyright 2003 - 2009, Haiku, Inc. All rights reserved. * Copyright 2003-2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Jérôme Duval, * Jérôme Duval,
* Andrew McCall ([email protected])
* Axel Dörfler ([email protected]) * Axel Dörfler ([email protected])
* Andrew McCall ([email protected])
* Philippe Saint-Pierre [email protected] * Philippe Saint-Pierre [email protected]
*/ */
#include "MouseView.h" #include "MouseView.h"
#include <Bitmap.h> #include <Bitmap.h>
@@ -44,7 +45,7 @@ static const rgb_color kButtonReleasedSeparatorColor = {88, 88, 88};
static const rgb_color kButtonTextColor = {32, 32, 32}; static const rgb_color kButtonTextColor = {32, 32, 32};
static const int32 * static const int32*
getButtonOffsets(int32 type) getButtonOffsets(int32 type)
{ {
switch (type) { switch (type) {
@@ -78,7 +79,8 @@ getMappingNumber(int32 mapping)
MouseView::MouseView(BRect rect, const MouseSettings &settings) MouseView::MouseView(BRect rect, const MouseSettings &settings)
: BView(rect, "mouse_view", B_FOLLOW_ALL, B_PULSE_NEEDED | B_WILL_DRAW), :
BView(rect, "mouse_view", B_FOLLOW_ALL, B_PULSE_NEEDED | B_WILL_DRAW),
fSettings(settings), fSettings(settings),
fType(-1), fType(-1),
fButtons(0), fButtons(0),
@@ -100,7 +102,7 @@ MouseView::~MouseView()
void void
MouseView::GetPreferredSize(float *_width, float *_height) MouseView::GetPreferredSize(float* _width, float* _height)
{ {
if (_width) if (_width)
*_width = fMouseBitmap != NULL ? fMouseBitmap->Bounds().Width() : 57; *_width = fMouseBitmap != NULL ? fMouseBitmap->Bounds().Width() : 57;
@@ -143,7 +145,7 @@ MouseView::MouseDown(BPoint where)
fOldButtons = fButtons; fOldButtons = fButtons;
} }
const int32 *offset = getButtonOffsets(fType); const int32* offset = getButtonOffsets(fType);
int32 button = -1; int32 button = -1;
for (int32 i = 0; i <= fType; i++) { for (int32 i = 0; i <= fType; i++) {
BRect frame(offset[i], kButtonTop, offset[i + 1] - 1, BRect frame(offset[i], kButtonTop, offset[i + 1] - 1,
@@ -160,7 +162,7 @@ MouseView::MouseDown(BPoint where)
// is not active, so make sure that we don't display the menu when // is not active, so make sure that we don't display the menu when
// the user clicked inside our view, but another window is on top. // the user clicked inside our view, but another window is on top.
if (clipping.Contains(where)) { if (clipping.Contains(where)) {
button = ConvertFromVisualOrder(button); button = _ConvertFromVisualOrder(button);
BPopUpMenu menu("Mouse Map Menu"); BPopUpMenu menu("Mouse Map Menu");
BMessage message(kMsgMouseMap); BMessage message(kMsgMouseMap);
@@ -203,19 +205,21 @@ MouseView::Draw(BRect updateFrame)
mouse_map map; mouse_map map;
fSettings.Mapping(map); fSettings.Mapping(map);
const int32 *offset = getButtonOffsets(fType); const int32* offset = getButtonOffsets(fType);
bool middlePressed = fType == 3 && (map.button[2] & fButtons) != 0; bool middlePressed = fType == 3 && (map.button[2] & fButtons) != 0;
for (int32 i = 0; i < fType; i++) { for (int32 i = 0; i < fType; i++) {
BRect border(offset[i] + 1, kButtonTop + 2, offset[i + 1] - 1, BRect border(offset[i] + 1, kButtonTop + 2, offset[i + 1] - 1,
kButtonTop + fMouseDownBounds.Height() - 4); kButtonTop + fMouseDownBounds.Height() - 4);
bool pressed = (fButtons & map.button[ConvertFromVisualOrder(i)]) != 0; bool pressed = (fButtons & map.button[_ConvertFromVisualOrder(i)]) != 0;
// is button currently pressed? // is button currently pressed?
if (pressed) { if (pressed) {
BRect frame(offset[i], 0, offset[i + 1], fMouseDownBounds.Height() + 1); BRect frame(offset[i], 0, offset[i + 1],
fMouseDownBounds.Height() + 1);
if (fMouseDownBitmap != NULL) if (fMouseDownBitmap != NULL)
DrawBitmapAsync(fMouseDownBitmap, frame, frame.OffsetByCopy(0, kButtonTop)); DrawBitmapAsync(fMouseDownBitmap, frame,
frame.OffsetByCopy(0, kButtonTop));
else if (fMouseBitmap == NULL) { else if (fMouseBitmap == NULL) {
SetHighColor(kButtonPressedColor); SetHighColor(kButtonPressedColor);
SetDrawingMode(B_OP_OVER); SetDrawingMode(B_OP_OVER);
@@ -226,7 +230,8 @@ MouseView::Draw(BRect updateFrame)
if (i > 0 && fType > i) { if (i > 0 && fType > i) {
// left border // left border
SetHighColor(pressed ? kButtonPressedColor : kButtonReleasedLeftColor); SetHighColor(pressed ?
kButtonPressedColor : kButtonReleasedLeftColor);
StrokeLine(BPoint(border.LeftTop()), BPoint(border.LeftBottom())); StrokeLine(BPoint(border.LeftTop()), BPoint(border.LeftBottom()));
// draw separator // draw separator
@@ -237,13 +242,16 @@ MouseView::Draw(BRect updateFrame)
SetHighColor(middlePressed ? SetHighColor(middlePressed ?
kButtonPressedSeparatorColor : kButtonReleasedSeparatorColor); kButtonPressedSeparatorColor : kButtonReleasedSeparatorColor);
StrokeLine(BPoint(separator.LeftTop()), BPoint(separator.LeftBottom())); StrokeLine(BPoint(separator.LeftTop()),
BPoint(separator.LeftBottom()));
} }
if (fType > 1 && i + 1 < fType) { if (fType > 1 && i + 1 < fType) {
// right border // right border
SetHighColor(pressed ? kButtonPressedColor : kButtonReleasedRightColor); SetHighColor(pressed ?
StrokeLine(BPoint(border.RightTop()), BPoint(border.RightBottom())); kButtonPressedColor : kButtonReleasedRightColor);
StrokeLine(BPoint(border.RightTop()),
BPoint(border.RightBottom()));
} }
// draw mapping number centered over the button // draw mapping number centered over the button
@@ -251,16 +259,17 @@ MouseView::Draw(BRect updateFrame)
SetHighColor(kButtonTextColor); SetHighColor(kButtonTextColor);
char number[2] = {0}; char number[2] = {0};
number[0] = getMappingNumber(map.button[ConvertFromVisualOrder(i)]) + '1'; number[0] = getMappingNumber(map.button[_ConvertFromVisualOrder(i)])
+ '1';
DrawString(number, DrawString(number, BPoint(border.left +
BPoint(border.left + (border.Width() - StringWidth(number)) / 2, kButtonTop + 18)); (border.Width() - StringWidth(number)) / 2, kButtonTop + 18));
} }
} }
int32 int32
MouseView::ConvertFromVisualOrder(int32 i) MouseView::_ConvertFromVisualOrder(int32 i)
{ {
if (fType < 3) if (fType < 3)
return i; return i;
+14 -19
View File
@@ -1,19 +1,14 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ /*
// * Copyright 2003-2009 Haiku Inc. All rights reserved.
// Copyright (c) 2003, OpenBeOS * Distributed under the terms of the MIT License.
// *
// This software is part of the OpenBeOS distribution and is covered * Authors:
// by the OpenBeOS license. * Jérôme Duval,
// * Axel Dörfler ([email protected])
// * Andrew McCall ([email protected])
// File: MouseView.h */
// Authors: Jérôme Duval,
// Andrew McCall ([email protected])
// Axel Dörfler ([email protected])
// Description: Mouse Preferences
// Created: December 10, 2003
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#ifndef MOUSE_VIEW_H #ifndef MOUSE_VIEW_H
#define MOUSE_VIEW_H #define MOUSE_VIEW_H
@@ -26,7 +21,7 @@
class MouseSettings; class MouseSettings;
class MouseView : public BView { class MouseView : public BView {
public: public:
MouseView(BRect frame, const MouseSettings &settings); MouseView(BRect frame, const MouseSettings &settings);
virtual ~MouseView(); virtual ~MouseView();
@@ -40,8 +35,8 @@ class MouseView : public BView {
void MouseMapUpdated(); void MouseMapUpdated();
void UpdateFromSettings(); void UpdateFromSettings();
private: private:
int32 ConvertFromVisualOrder(int32 button); int32 _ConvertFromVisualOrder(int32 button);
typedef BView inherited; typedef BView inherited;
+21 -24
View File
@@ -1,19 +1,13 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ /*
// * Copyright 2003-2009 Haiku Inc. All rights reserved.
// Copyright (c) 2003, OpenBeOS * Distributed under the terms of the MIT License.
// *
// This software is part of the OpenBeOS distribution and is covered * Authors:
// by the OpenBeOS license. * Jérôme Duval,
// * Axel Dörfler ([email protected])
// * Andrew McCall ([email protected])
// File: MouseWindow.cpp */
// Authors: Jérôme Duval,
// Andrew McCall ([email protected])
// Axel Dörfler ([email protected])
// Description: Mouse Preferences
// Created: December 10, 2003
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#include <Alert.h> #include <Alert.h>
#include <Application.h> #include <Application.h>
@@ -33,29 +27,32 @@
MouseWindow::MouseWindow(BRect _rect) MouseWindow::MouseWindow(BRect _rect)
: BWindow(_rect, "Mouse", B_TITLED_WINDOW, :
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS) BWindow(_rect, "Mouse", B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
{ {
BView *view = new BView(Bounds(), "view", B_FOLLOW_ALL, 0); BView* view = new BView(Bounds(), "view", B_FOLLOW_ALL, 0);
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(view); AddChild(view);
// Add the main settings view // Add the main settings view
fSettingsView = new SettingsView(Bounds().InsetBySelf(kBorderSpace, kBorderSpace), fSettingsView = new SettingsView(Bounds().InsetBySelf(kBorderSpace,
fSettings); kBorderSpace), fSettings);
view->AddChild(fSettingsView); view->AddChild(fSettingsView);
// Add the "Default" button // Add the "Default" button
BRect rect(kBorderSpace, fSettingsView->Frame().bottom + kItemSpace + 2, BRect rect(kBorderSpace, fSettingsView->Frame().bottom + kItemSpace + 2,
kBorderSpace + 75, fSettingsView->Frame().bottom + 20); kBorderSpace + 75, fSettingsView->Frame().bottom + 20);
fDefaultsButton = new BButton(rect, "defaults", "Defaults", new BMessage(kMsgDefaults)); fDefaultsButton = new BButton(rect, "defaults", "Defaults",
new BMessage(kMsgDefaults));
fDefaultsButton->ResizeToPreferred(); fDefaultsButton->ResizeToPreferred();
fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
view->AddChild(fDefaultsButton); view->AddChild(fDefaultsButton);
// Add the "Revert" button // Add the "Revert" button
rect.OffsetBy(fDefaultsButton->Bounds().Width() + kItemSpace, 0); rect.OffsetBy(fDefaultsButton->Bounds().Width() + kItemSpace, 0);
fRevertButton = new BButton(rect, "revert", "Revert", new BMessage(kMsgRevert)); fRevertButton = new BButton(rect, "revert", "Revert",
new BMessage(kMsgRevert));
fRevertButton->SetEnabled(false); fRevertButton->SetEnabled(false);
fRevertButton->ResizeToPreferred(); fRevertButton->ResizeToPreferred();
view->AddChild(fRevertButton); view->AddChild(fRevertButton);
@@ -98,7 +95,7 @@ MouseWindow::QuitRequested()
void void
MouseWindow::MessageReceived(BMessage *message) MouseWindow::MessageReceived(BMessage* message)
{ {
switch (message->what) { switch (message->what) {
case kMsgDefaults: { case kMsgDefaults: {
+13 -18
View File
@@ -1,19 +1,14 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ /*
// * Copyright 2003-2009 Haiku Inc. All rights reserved.
// Copyright (c) 2003, OpenBeOS * Distributed under the terms of the MIT License.
// *
// This software is part of the OpenBeOS distribution and is covered * Authors:
// by the OpenBeOS license. * Jérôme Duval,
// * Axel Dörfler ([email protected])
// * Andrew McCall ([email protected])
// File: MouseWindow.h */
// Authors: Jérôme Duval,
// Andrew McCall ([email protected])
// Axel Dörfler ([email protected])
// Description: Mouse Preferences
// Created: December 10, 2003
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#ifndef MOUSE_WINDOW_H #ifndef MOUSE_WINDOW_H
#define MOUSE_WINDOW_H #define MOUSE_WINDOW_H
@@ -27,13 +22,13 @@ class SettingsView;
class MouseWindow : public BWindow { class MouseWindow : public BWindow {
public: public:
MouseWindow(BRect rect); MouseWindow(BRect rect);
virtual bool QuitRequested(); virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage *message);
private: private:
MouseSettings fSettings; MouseSettings fSettings;
BButton *fDefaultsButton; BButton *fDefaultsButton;
BButton *fRevertButton; BButton *fRevertButton;
+34 -36
View File
@@ -1,19 +1,13 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ /*
// * Copyright 2003-2009 Haiku Inc. All rights reserved.
// Copyright (c) 2003, OpenBeOS * Distributed under the terms of the MIT License.
// *
// This software is part of the OpenBeOS distribution and is covered * Authors:
// by the OpenBeOS license. * Jérôme Duval,
// * Axel Dörfler ([email protected])
// * Andrew McCall ([email protected])
// File: SettingsView.cpp */
// Authors: Jérôme Duval,
// Andrew McCall ([email protected])
// Axel Dörfler ([email protected])
// Description: Mouse Preferences
// Created: December 10, 2003
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#include <InterfaceDefs.h> #include <InterfaceDefs.h>
#include <Button.h> #include <Button.h>
@@ -55,7 +49,8 @@ mouse_mode_to_index(mode_mouse mode)
SettingsView::SettingsView(BRect rect, MouseSettings &settings) SettingsView::SettingsView(BRect rect, MouseSettings &settings)
: BBox(rect, "main_view"), :
BBox(rect, "main_view"),
fSettings(settings) fSettings(settings)
{ {
ResizeToPreferred(); ResizeToPreferred();
@@ -70,7 +65,8 @@ SettingsView::SettingsView(BRect rect, MouseSettings &settings)
fTypeMenu->AddItem(new BMenuItem("2-Button", new BMessage(kMsgMouseType))); fTypeMenu->AddItem(new BMenuItem("2-Button", new BMessage(kMsgMouseType)));
fTypeMenu->AddItem(new BMenuItem("3-Button", new BMessage(kMsgMouseType))); fTypeMenu->AddItem(new BMenuItem("3-Button", new BMessage(kMsgMouseType)));
BMenuField *field = new BMenuField(BRect(7, 8, 155, 190), "mouse_type", "Mouse type:", fTypeMenu); BMenuField *field = new BMenuField(BRect(7, 8, 155, 190), "mouse_type",
"Mouse type:", fTypeMenu);
field->SetDivider(field->StringWidth(field->Label()) + kItemSpace); field->SetDivider(field->StringWidth(field->Label()) + kItemSpace);
field->SetAlignment(B_ALIGN_RIGHT); field->SetAlignment(B_ALIGN_RIGHT);
AddChild(field); AddChild(field);
@@ -84,8 +80,8 @@ SettingsView::SettingsView(BRect rect, MouseSettings &settings)
fRightArea.Set(fLeftArea.right + 10, 11, 200, 7); fRightArea.Set(fLeftArea.right + 10, 11, 200, 7);
// Create the "Double-click speed slider... // Create the "Double-click speed slider...
fClickSpeedSlider = new BSlider(fRightArea, "double_click_speed", "Double-click speed", fClickSpeedSlider = new BSlider(fRightArea, "double_click_speed",
new BMessage(kMsgDoubleClickSpeed), 0, 1000); "Double-click speed", new BMessage(kMsgDoubleClickSpeed), 0, 1000);
fClickSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fClickSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fClickSpeedSlider->SetHashMarkCount(5); fClickSpeedSlider->SetHashMarkCount(5);
fClickSpeedSlider->SetLimitLabels("Slow", "Fast"); fClickSpeedSlider->SetLimitLabels("Slow", "Fast");
@@ -109,8 +105,8 @@ SettingsView::SettingsView(BRect rect, MouseSettings &settings)
fRightArea.top += length; fRightArea.top += length;
// Create the "Mouse Acceleration" slider... // Create the "Mouse Acceleration" slider...
fAccelerationSlider = new BSlider(fRightArea, "mouse_acceleration", "Mouse Acceleration", fAccelerationSlider = new BSlider(fRightArea, "mouse_acceleration",
new BMessage(kMsgAccelerationFactor), 0, 1000); "Mouse Acceleration", new BMessage(kMsgAccelerationFactor), 0, 1000);
fAccelerationSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fAccelerationSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fAccelerationSlider->SetHashMarkCount(5); fAccelerationSlider->SetHashMarkCount(5);
fAccelerationSlider->SetLimitLabels("Slow", "Fast"); fAccelerationSlider->SetLimitLabels("Slow", "Fast");
@@ -123,7 +119,8 @@ SettingsView::SettingsView(BRect rect, MouseSettings &settings)
// Add the "Focus follows mouse" pop up menu // Add the "Focus follows mouse" pop up menu
fFocusMenu = new BPopUpMenu("Disabled"); fFocusMenu = new BPopUpMenu("Disabled");
const char *focusLabels[] = {"Disabled", "Enabled", "Warping", "Instant-Warping"}; const char *focusLabels[] = {"Disabled", "Enabled", "Warping",
"Instant-Warping"};
const mode_mouse focusModes[] = {B_NORMAL_MOUSE, B_FOCUS_FOLLOWS_MOUSE, const mode_mouse focusModes[] = {B_NORMAL_MOUSE, B_FOCUS_FOLLOWS_MOUSE,
B_WARP_MOUSE, B_INSTANT_WARP_MOUSE}; B_WARP_MOUSE, B_INSTANT_WARP_MOUSE};
@@ -137,7 +134,8 @@ SettingsView::SettingsView(BRect rect, MouseSettings &settings)
BRect frame(fRightArea.left, fRightArea.top + 10, fRightArea.left + BRect frame(fRightArea.left, fRightArea.top + 10, fRightArea.left +
font.StringWidth("Focus follows mouse:") + font.StringWidth("Focus follows mouse:") +
font.StringWidth(focusLabels[0]) + 30, 200); font.StringWidth(focusLabels[0]) + 30, 200);
field = new BMenuField(frame, "ffm", "Focus follows mouse:", fFocusMenu, true); field = new BMenuField(frame, "ffm", "Focus follows mouse:", fFocusMenu,
true);
field->SetDivider(field->StringWidth(field->Label()) + kItemSpace); field->SetDivider(field->StringWidth(field->Label()) + kItemSpace);
field->SetAlignment(B_ALIGN_RIGHT); field->SetAlignment(B_ALIGN_RIGHT);
AddChild(field); AddChild(field);
@@ -151,9 +149,11 @@ SettingsView::SettingsView(BRect rect, MouseSettings &settings)
fLeftArea.bottom = fRightArea.bottom; fLeftArea.bottom = fRightArea.bottom;
// Position mouse bitmaps // Position mouse bitmaps
fDoubleClickBmpPoint.x = fRightArea.right - fDoubleClickBitmap->Bounds().right - 15; fDoubleClickBmpPoint.x = fRightArea.right -
fDoubleClickBitmap->Bounds().right - 15;
fSpeedBmpPoint.x = fRightArea.right - fSpeedBitmap->Bounds().right - 15; fSpeedBmpPoint.x = fRightArea.right - fSpeedBitmap->Bounds().right - 15;
fAccelerationBmpPoint.x = fRightArea.right - fAccelerationBitmap->Bounds().right - 15; fAccelerationBmpPoint.x = fRightArea.right -
fAccelerationBitmap->Bounds().right - 15;
// Resize sliders to equal size // Resize sliders to equal size
length = fRightArea.left - 5; length = fRightArea.left - 5;
@@ -174,8 +174,8 @@ SettingsView::SettingsView(BRect rect, MouseSettings &settings)
// Create the "Double-click test area" text box... // Create the "Double-click test area" text box...
frame.Set(fLeftArea.left, fLeftArea.bottom + 10, fLeftArea.right, 0); frame.Set(fLeftArea.left, fLeftArea.bottom + 10, fLeftArea.right, 0);
BTextControl *textControl = new BTextControl(frame, "double_click_test_area", NULL, BTextControl *textControl = new BTextControl(frame,
"Double-click test area", NULL); "double_click_test_area", NULL, "Double-click test area", NULL);
textControl->SetAlignment(B_ALIGN_LEFT, B_ALIGN_CENTER); textControl->SetAlignment(B_ALIGN_LEFT, B_ALIGN_CENTER);
AddChild(textControl); AddChild(textControl);
@@ -199,7 +199,7 @@ SettingsView::AttachedToWindow()
void void
SettingsView::GetPreferredSize(float *_width, float *_height) SettingsView::GetPreferredSize(float* _width, float* _height)
{ {
if (_width) if (_width)
*_width = fRightArea.right + 5; *_width = fRightArea.right + 5;
@@ -248,15 +248,14 @@ SettingsView::Draw(BRect updateFrame)
DrawBitmapAsync(fDoubleClickBitmap, fDoubleClickBmpPoint); DrawBitmapAsync(fDoubleClickBitmap, fDoubleClickBmpPoint);
if (fSpeedBitmap != NULL if (fSpeedBitmap != NULL
&& updateFrame.Intersects(BRect(fSpeedBmpPoint, && updateFrame.Intersects(BRect(fSpeedBmpPoint, fSpeedBmpPoint
fSpeedBmpPoint + fSpeedBitmap->Bounds().RightBottom()))) + fSpeedBitmap->Bounds().RightBottom())))
DrawBitmapAsync(fSpeedBitmap, fSpeedBmpPoint); DrawBitmapAsync(fSpeedBitmap, fSpeedBmpPoint);
if (fAccelerationBitmap != NULL if (fAccelerationBitmap != NULL
&& updateFrame.Intersects(BRect(fAccelerationBmpPoint, && updateFrame.Intersects(BRect(fAccelerationBmpPoint, fAccelerationBmpPoint
fAccelerationBmpPoint + fAccelerationBitmap->Bounds().RightBottom()))) + fAccelerationBitmap->Bounds().RightBottom())))
DrawBitmapAsync(fAccelerationBitmap, fAccelerationBmpPoint); DrawBitmapAsync(fAccelerationBitmap, fAccelerationBmpPoint);
SetDrawingMode(B_OP_COPY); SetDrawingMode(B_OP_COPY);
} }
@@ -283,7 +282,7 @@ SettingsView::UpdateFromSettings()
// slow = 1000000, fast = 0 // slow = 1000000, fast = 0
fClickSpeedSlider->SetValue(value); fClickSpeedSlider->SetValue(value);
value = int32((log(fSettings.MouseSpeed() / 8192.0) / log(2)) * 1000 / 6); value = int32((log(fSettings.MouseSpeed() / 8192.0) / log(2)) * 1000 / 6);
// slow = 8192, fast = 524287 // slow = 8192, fast = 524287
fMouseSpeedSlider->SetValue(value); fMouseSpeedSlider->SetValue(value);
@@ -301,4 +300,3 @@ SettingsView::UpdateFromSettings()
if (item != NULL) if (item != NULL)
item->SetMarked(true); item->SetMarked(true);
} }
+13 -19
View File
@@ -1,19 +1,13 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ /*
// * Copyright 2003-2009 Haiku Inc. All rights reserved.
// Copyright (c) 2003, OpenBeOS * Distributed under the terms of the MIT License.
// *
// This software is part of the OpenBeOS distribution and is covered * Authors:
// by the OpenBeOS license. * Jérôme Duval,
// * Axel Dörfler ([email protected])
// * Andrew McCall ([email protected])
// File: SettingsView.h */
// Authors: Jérôme Duval,
// Andrew McCall ([email protected])
// Axel Dörfler ([email protected])
// Description: Mouse Preferences
// Created: December 10, 2003
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#ifndef SETTINGS_VIEW_H #ifndef SETTINGS_VIEW_H
#define SETTINGS_VIEW_H #define SETTINGS_VIEW_H
@@ -30,19 +24,19 @@ class MouseView;
class SettingsView : public BBox { class SettingsView : public BBox {
public: public:
SettingsView(BRect frame, MouseSettings &settings); SettingsView(BRect frame, MouseSettings &settings);
virtual ~SettingsView(); virtual ~SettingsView();
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void GetPreferredSize(float *_width, float *_height); virtual void GetPreferredSize(float* _width, float* _height);
virtual void Draw(BRect frame); virtual void Draw(BRect frame);
void SetMouseType(int32 type); void SetMouseType(int32 type);
void MouseMapUpdated(); void MouseMapUpdated();
void UpdateFromSettings(); void UpdateFromSettings();
private: private:
typedef BBox inherited; typedef BBox inherited;
const MouseSettings &fSettings; const MouseSettings &fSettings;