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:
@@ -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.
|
||||
*
|
||||
* Authors:
|
||||
* Andrew McCall ([email protected])
|
||||
* Jérôme Duval
|
||||
* Jérôme Duval,
|
||||
* Axel Dörfler ([email protected])
|
||||
* Andrew McCall ([email protected])
|
||||
*/
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ const char* kSignature = "application/x-vnd.Haiku-Mouse";
|
||||
|
||||
|
||||
MouseApplication::MouseApplication()
|
||||
: BApplication(kSignature)
|
||||
:
|
||||
BApplication(kSignature)
|
||||
{
|
||||
BRect rect(0, 0, 397, 293);
|
||||
MouseWindow *window = new MouseWindow(rect);
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
* Authors:
|
||||
* Andrew McCall ([email protected])
|
||||
* Jérôme Duval
|
||||
* Jérôme Duval,
|
||||
* Axel Dörfler ([email protected])
|
||||
* Andrew McCall ([email protected])
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MOUSE_H
|
||||
#define MOUSE_H
|
||||
|
||||
@@ -15,7 +17,7 @@
|
||||
|
||||
|
||||
class MouseApplication : public BApplication {
|
||||
public:
|
||||
public:
|
||||
MouseApplication();
|
||||
|
||||
virtual void AboutRequested();
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2003, OpenBeOS
|
||||
//
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
//
|
||||
// File: MouseConstants.h
|
||||
// Authors: Jérôme Duval,
|
||||
// Andrew McCall ([email protected])
|
||||
// Axel Dörfler ([email protected])
|
||||
// Description: Mouse Preferences
|
||||
// Created: December 10, 2003
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
/*
|
||||
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval,
|
||||
* Axel Dörfler ([email protected])
|
||||
* Andrew McCall ([email protected])
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MOUSE_CONSTANTS_H
|
||||
#define MOUSE_CONSTANTS_H
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2003, OpenBeOS
|
||||
//
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
//
|
||||
// File: MouseSettings.h
|
||||
// Authors: Jérôme Duval,
|
||||
// Andrew McCall ([email protected]),
|
||||
// Axel Dörfler ([email protected])
|
||||
// Description: Mouse Preferences
|
||||
// Created: December 10, 2003
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
/*
|
||||
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval,
|
||||
* Axel Dörfler ([email protected])
|
||||
* Andrew McCall ([email protected])
|
||||
*/
|
||||
|
||||
|
||||
#include <FindDirectory.h>
|
||||
#include <File.h>
|
||||
@@ -39,7 +33,7 @@ MouseSettings::MouseSettings()
|
||||
:
|
||||
fWindowPosition(-1, -1)
|
||||
{
|
||||
RetrieveSettings();
|
||||
_RetrieveSettings();
|
||||
|
||||
fOriginalSettings = fSettings;
|
||||
fOriginalMode = fMode;
|
||||
@@ -48,12 +42,12 @@ MouseSettings::MouseSettings()
|
||||
|
||||
MouseSettings::~MouseSettings()
|
||||
{
|
||||
SaveSettings();
|
||||
_SaveSettings();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
MouseSettings::GetSettingsPath(BPath &path)
|
||||
MouseSettings::_GetSettingsPath(BPath &path)
|
||||
{
|
||||
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||
if (status < B_OK)
|
||||
@@ -65,19 +59,19 @@ MouseSettings::GetSettingsPath(BPath &path)
|
||||
|
||||
|
||||
void
|
||||
MouseSettings::RetrieveSettings()
|
||||
MouseSettings::_RetrieveSettings()
|
||||
{
|
||||
// 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");
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
if (get_mouse_type(&fSettings.type)!=B_OK)
|
||||
if (get_mouse_type(&fSettings.type) != B_OK)
|
||||
fprintf(stderr, "error when get_mouse_type\n");
|
||||
|
||||
fMode = mouse_mode();
|
||||
@@ -85,7 +79,7 @@ MouseSettings::RetrieveSettings()
|
||||
// also try to load the window position from disk
|
||||
|
||||
BPath path;
|
||||
if (GetSettingsPath(path) < B_OK)
|
||||
if (_GetSettingsPath(path) < B_OK)
|
||||
return;
|
||||
|
||||
BFile file(path.Path(), B_READ_ONLY);
|
||||
@@ -93,13 +87,15 @@ MouseSettings::RetrieveSettings()
|
||||
return;
|
||||
|
||||
#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
|
||||
#else
|
||||
const off_t kOffset = sizeof(mouse_settings);
|
||||
#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
|
||||
// corrected by the application; the window will be centered
|
||||
// in this case)
|
||||
@@ -114,10 +110,10 @@ MouseSettings::RetrieveSettings()
|
||||
|
||||
|
||||
status_t
|
||||
MouseSettings::SaveSettings()
|
||||
MouseSettings::_SaveSettings()
|
||||
{
|
||||
BPath path;
|
||||
status_t status = GetSettingsPath(path);
|
||||
status_t status = _GetSettingsPath(path);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
@@ -126,7 +122,8 @@ MouseSettings::SaveSettings()
|
||||
return status;
|
||||
|
||||
#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
|
||||
#else
|
||||
const off_t kOffset = sizeof(mouse_settings);
|
||||
@@ -143,7 +140,9 @@ void
|
||||
MouseSettings::Dump()
|
||||
{
|
||||
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("accel:\t\t%s\n", fSettings.accel.enabled ? "enabled" : "disabled");
|
||||
printf("accel factor:\t%ld\n", fSettings.accel.accel_factor);
|
||||
@@ -169,9 +168,7 @@ MouseSettings::Dump()
|
||||
#endif
|
||||
|
||||
|
||||
/** Resets the settings to the system defaults
|
||||
*/
|
||||
|
||||
// Resets the settings to the system defaults
|
||||
void
|
||||
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
|
||||
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
|
||||
MouseSettings::Revert()
|
||||
{
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval
|
||||
* Andrew McCall ([email protected])
|
||||
* Jérôme Duval,
|
||||
* Axel Dörfler ([email protected])
|
||||
* Andrew McCall ([email protected])
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MOUSE_SETTINGS_H
|
||||
#define MOUSE_SETTINGS_H
|
||||
|
||||
@@ -20,7 +22,7 @@ class BPath;
|
||||
|
||||
|
||||
class MouseSettings {
|
||||
public:
|
||||
public:
|
||||
MouseSettings();
|
||||
~MouseSettings();
|
||||
|
||||
@@ -52,10 +54,10 @@ class MouseSettings {
|
||||
mode_mouse MouseMode() const { return fMode; }
|
||||
void SetMouseMode(mode_mouse mode);
|
||||
|
||||
private:
|
||||
static status_t GetSettingsPath(BPath &path);
|
||||
void RetrieveSettings();
|
||||
status_t SaveSettings();
|
||||
private:
|
||||
static status_t _GetSettingsPath(BPath &path);
|
||||
void _RetrieveSettings();
|
||||
status_t _SaveSettings();
|
||||
|
||||
mouse_settings fSettings, fOriginalSettings;
|
||||
mode_mouse fMode, fOriginalMode;
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
/*
|
||||
* Copyright 2003 - 2009, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval,
|
||||
* Andrew McCall ([email protected])
|
||||
* Axel Dörfler ([email protected])
|
||||
* Andrew McCall ([email protected])
|
||||
* Philippe Saint-Pierre [email protected]
|
||||
*/
|
||||
|
||||
|
||||
#include "MouseView.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 int32 *
|
||||
static const int32*
|
||||
getButtonOffsets(int32 type)
|
||||
{
|
||||
switch (type) {
|
||||
@@ -78,7 +79,8 @@ getMappingNumber(int32 mapping)
|
||||
|
||||
|
||||
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),
|
||||
fType(-1),
|
||||
fButtons(0),
|
||||
@@ -100,7 +102,7 @@ MouseView::~MouseView()
|
||||
|
||||
|
||||
void
|
||||
MouseView::GetPreferredSize(float *_width, float *_height)
|
||||
MouseView::GetPreferredSize(float* _width, float* _height)
|
||||
{
|
||||
if (_width)
|
||||
*_width = fMouseBitmap != NULL ? fMouseBitmap->Bounds().Width() : 57;
|
||||
@@ -143,7 +145,7 @@ MouseView::MouseDown(BPoint where)
|
||||
fOldButtons = fButtons;
|
||||
}
|
||||
|
||||
const int32 *offset = getButtonOffsets(fType);
|
||||
const int32* offset = getButtonOffsets(fType);
|
||||
int32 button = -1;
|
||||
for (int32 i = 0; i <= fType; i++) {
|
||||
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
|
||||
// the user clicked inside our view, but another window is on top.
|
||||
if (clipping.Contains(where)) {
|
||||
button = ConvertFromVisualOrder(button);
|
||||
button = _ConvertFromVisualOrder(button);
|
||||
|
||||
BPopUpMenu menu("Mouse Map Menu");
|
||||
BMessage message(kMsgMouseMap);
|
||||
@@ -203,19 +205,21 @@ MouseView::Draw(BRect updateFrame)
|
||||
mouse_map map;
|
||||
fSettings.Mapping(map);
|
||||
|
||||
const int32 *offset = getButtonOffsets(fType);
|
||||
const int32* offset = getButtonOffsets(fType);
|
||||
bool middlePressed = fType == 3 && (map.button[2] & fButtons) != 0;
|
||||
|
||||
for (int32 i = 0; i < fType; i++) {
|
||||
BRect border(offset[i] + 1, kButtonTop + 2, offset[i + 1] - 1,
|
||||
kButtonTop + fMouseDownBounds.Height() - 4);
|
||||
bool pressed = (fButtons & map.button[ConvertFromVisualOrder(i)]) != 0;
|
||||
bool pressed = (fButtons & map.button[_ConvertFromVisualOrder(i)]) != 0;
|
||||
// is button currently 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)
|
||||
DrawBitmapAsync(fMouseDownBitmap, frame, frame.OffsetByCopy(0, kButtonTop));
|
||||
DrawBitmapAsync(fMouseDownBitmap, frame,
|
||||
frame.OffsetByCopy(0, kButtonTop));
|
||||
else if (fMouseBitmap == NULL) {
|
||||
SetHighColor(kButtonPressedColor);
|
||||
SetDrawingMode(B_OP_OVER);
|
||||
@@ -226,7 +230,8 @@ MouseView::Draw(BRect updateFrame)
|
||||
|
||||
if (i > 0 && fType > i) {
|
||||
// left border
|
||||
SetHighColor(pressed ? kButtonPressedColor : kButtonReleasedLeftColor);
|
||||
SetHighColor(pressed ?
|
||||
kButtonPressedColor : kButtonReleasedLeftColor);
|
||||
StrokeLine(BPoint(border.LeftTop()), BPoint(border.LeftBottom()));
|
||||
|
||||
// draw separator
|
||||
@@ -237,13 +242,16 @@ MouseView::Draw(BRect updateFrame)
|
||||
|
||||
SetHighColor(middlePressed ?
|
||||
kButtonPressedSeparatorColor : kButtonReleasedSeparatorColor);
|
||||
StrokeLine(BPoint(separator.LeftTop()), BPoint(separator.LeftBottom()));
|
||||
StrokeLine(BPoint(separator.LeftTop()),
|
||||
BPoint(separator.LeftBottom()));
|
||||
}
|
||||
|
||||
if (fType > 1 && i + 1 < fType) {
|
||||
// right border
|
||||
SetHighColor(pressed ? kButtonPressedColor : kButtonReleasedRightColor);
|
||||
StrokeLine(BPoint(border.RightTop()), BPoint(border.RightBottom()));
|
||||
SetHighColor(pressed ?
|
||||
kButtonPressedColor : kButtonReleasedRightColor);
|
||||
StrokeLine(BPoint(border.RightTop()),
|
||||
BPoint(border.RightBottom()));
|
||||
}
|
||||
|
||||
// draw mapping number centered over the button
|
||||
@@ -251,16 +259,17 @@ MouseView::Draw(BRect updateFrame)
|
||||
SetHighColor(kButtonTextColor);
|
||||
|
||||
char number[2] = {0};
|
||||
number[0] = getMappingNumber(map.button[ConvertFromVisualOrder(i)]) + '1';
|
||||
number[0] = getMappingNumber(map.button[_ConvertFromVisualOrder(i)])
|
||||
+ '1';
|
||||
|
||||
DrawString(number,
|
||||
BPoint(border.left + (border.Width() - StringWidth(number)) / 2, kButtonTop + 18));
|
||||
DrawString(number, BPoint(border.left +
|
||||
(border.Width() - StringWidth(number)) / 2, kButtonTop + 18));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
MouseView::ConvertFromVisualOrder(int32 i)
|
||||
MouseView::_ConvertFromVisualOrder(int32 i)
|
||||
{
|
||||
if (fType < 3)
|
||||
return i;
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2003, OpenBeOS
|
||||
//
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
//
|
||||
// File: MouseView.h
|
||||
// Authors: Jérôme Duval,
|
||||
// Andrew McCall ([email protected])
|
||||
// Axel Dörfler ([email protected])
|
||||
// Description: Mouse Preferences
|
||||
// Created: December 10, 2003
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
/*
|
||||
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval,
|
||||
* Axel Dörfler ([email protected])
|
||||
* Andrew McCall ([email protected])
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MOUSE_VIEW_H
|
||||
#define MOUSE_VIEW_H
|
||||
|
||||
@@ -26,7 +21,7 @@
|
||||
class MouseSettings;
|
||||
|
||||
class MouseView : public BView {
|
||||
public:
|
||||
public:
|
||||
MouseView(BRect frame, const MouseSettings &settings);
|
||||
virtual ~MouseView();
|
||||
|
||||
@@ -40,8 +35,8 @@ class MouseView : public BView {
|
||||
void MouseMapUpdated();
|
||||
void UpdateFromSettings();
|
||||
|
||||
private:
|
||||
int32 ConvertFromVisualOrder(int32 button);
|
||||
private:
|
||||
int32 _ConvertFromVisualOrder(int32 button);
|
||||
|
||||
typedef BView inherited;
|
||||
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2003, OpenBeOS
|
||||
//
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
//
|
||||
// File: MouseWindow.cpp
|
||||
// Authors: Jérôme Duval,
|
||||
// Andrew McCall ([email protected])
|
||||
// Axel Dörfler ([email protected])
|
||||
// Description: Mouse Preferences
|
||||
// Created: December 10, 2003
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
/*
|
||||
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval,
|
||||
* Axel Dörfler (axeld@pinc-software.de)
|
||||
* Andrew McCall (mccall@digitalparadise.co.uk)
|
||||
*/
|
||||
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
@@ -33,29 +27,32 @@
|
||||
|
||||
|
||||
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));
|
||||
AddChild(view);
|
||||
|
||||
// Add the main settings view
|
||||
fSettingsView = new SettingsView(Bounds().InsetBySelf(kBorderSpace, kBorderSpace),
|
||||
fSettings);
|
||||
fSettingsView = new SettingsView(Bounds().InsetBySelf(kBorderSpace,
|
||||
kBorderSpace), fSettings);
|
||||
view->AddChild(fSettingsView);
|
||||
|
||||
// Add the "Default" button
|
||||
BRect rect(kBorderSpace, fSettingsView->Frame().bottom + kItemSpace + 2,
|
||||
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->SetEnabled(fSettings.IsDefaultable());
|
||||
view->AddChild(fDefaultsButton);
|
||||
|
||||
// Add the "Revert" button
|
||||
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->ResizeToPreferred();
|
||||
view->AddChild(fRevertButton);
|
||||
@@ -98,7 +95,7 @@ MouseWindow::QuitRequested()
|
||||
|
||||
|
||||
void
|
||||
MouseWindow::MessageReceived(BMessage *message)
|
||||
MouseWindow::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case kMsgDefaults: {
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2003, OpenBeOS
|
||||
//
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
//
|
||||
// File: MouseWindow.h
|
||||
// Authors: Jérôme Duval,
|
||||
// Andrew McCall ([email protected])
|
||||
// Axel Dörfler ([email protected])
|
||||
// Description: Mouse Preferences
|
||||
// Created: December 10, 2003
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
/*
|
||||
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval,
|
||||
* Axel Dörfler (axeld@pinc-software.de)
|
||||
* Andrew McCall (mccall@digitalparadise.co.uk)
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MOUSE_WINDOW_H
|
||||
#define MOUSE_WINDOW_H
|
||||
|
||||
@@ -27,13 +22,13 @@ class SettingsView;
|
||||
|
||||
|
||||
class MouseWindow : public BWindow {
|
||||
public:
|
||||
public:
|
||||
MouseWindow(BRect rect);
|
||||
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
private:
|
||||
private:
|
||||
MouseSettings fSettings;
|
||||
BButton *fDefaultsButton;
|
||||
BButton *fRevertButton;
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2003, OpenBeOS
|
||||
//
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
//
|
||||
// File: SettingsView.cpp
|
||||
// Authors: Jérôme Duval,
|
||||
// Andrew McCall ([email protected])
|
||||
// Axel Dörfler ([email protected])
|
||||
// Description: Mouse Preferences
|
||||
// Created: December 10, 2003
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
/*
|
||||
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval,
|
||||
* Axel Dörfler (axeld@pinc-software.de)
|
||||
* Andrew McCall (mccall@digitalparadise.co.uk)
|
||||
*/
|
||||
|
||||
|
||||
#include <InterfaceDefs.h>
|
||||
#include <Button.h>
|
||||
@@ -55,7 +49,8 @@ mouse_mode_to_index(mode_mouse mode)
|
||||
|
||||
|
||||
SettingsView::SettingsView(BRect rect, MouseSettings &settings)
|
||||
: BBox(rect, "main_view"),
|
||||
:
|
||||
BBox(rect, "main_view"),
|
||||
fSettings(settings)
|
||||
{
|
||||
ResizeToPreferred();
|
||||
@@ -70,7 +65,8 @@ SettingsView::SettingsView(BRect rect, MouseSettings &settings)
|
||||
fTypeMenu->AddItem(new BMenuItem("2-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->SetAlignment(B_ALIGN_RIGHT);
|
||||
AddChild(field);
|
||||
@@ -84,8 +80,8 @@ SettingsView::SettingsView(BRect rect, MouseSettings &settings)
|
||||
fRightArea.Set(fLeftArea.right + 10, 11, 200, 7);
|
||||
|
||||
// Create the "Double-click speed slider...
|
||||
fClickSpeedSlider = new BSlider(fRightArea, "double_click_speed", "Double-click speed",
|
||||
new BMessage(kMsgDoubleClickSpeed), 0, 1000);
|
||||
fClickSpeedSlider = new BSlider(fRightArea, "double_click_speed",
|
||||
"Double-click speed", new BMessage(kMsgDoubleClickSpeed), 0, 1000);
|
||||
fClickSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
|
||||
fClickSpeedSlider->SetHashMarkCount(5);
|
||||
fClickSpeedSlider->SetLimitLabels("Slow", "Fast");
|
||||
@@ -109,8 +105,8 @@ SettingsView::SettingsView(BRect rect, MouseSettings &settings)
|
||||
fRightArea.top += length;
|
||||
|
||||
// Create the "Mouse Acceleration" slider...
|
||||
fAccelerationSlider = new BSlider(fRightArea, "mouse_acceleration", "Mouse Acceleration",
|
||||
new BMessage(kMsgAccelerationFactor), 0, 1000);
|
||||
fAccelerationSlider = new BSlider(fRightArea, "mouse_acceleration",
|
||||
"Mouse Acceleration", new BMessage(kMsgAccelerationFactor), 0, 1000);
|
||||
fAccelerationSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
|
||||
fAccelerationSlider->SetHashMarkCount(5);
|
||||
fAccelerationSlider->SetLimitLabels("Slow", "Fast");
|
||||
@@ -123,7 +119,8 @@ SettingsView::SettingsView(BRect rect, MouseSettings &settings)
|
||||
// Add the "Focus follows mouse" pop up menu
|
||||
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,
|
||||
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 +
|
||||
font.StringWidth("Focus follows mouse:") +
|
||||
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->SetAlignment(B_ALIGN_RIGHT);
|
||||
AddChild(field);
|
||||
@@ -151,9 +149,11 @@ SettingsView::SettingsView(BRect rect, MouseSettings &settings)
|
||||
fLeftArea.bottom = fRightArea.bottom;
|
||||
|
||||
// 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;
|
||||
fAccelerationBmpPoint.x = fRightArea.right - fAccelerationBitmap->Bounds().right - 15;
|
||||
fAccelerationBmpPoint.x = fRightArea.right -
|
||||
fAccelerationBitmap->Bounds().right - 15;
|
||||
|
||||
// Resize sliders to equal size
|
||||
length = fRightArea.left - 5;
|
||||
@@ -174,8 +174,8 @@ SettingsView::SettingsView(BRect rect, MouseSettings &settings)
|
||||
|
||||
// Create the "Double-click test area" text box...
|
||||
frame.Set(fLeftArea.left, fLeftArea.bottom + 10, fLeftArea.right, 0);
|
||||
BTextControl *textControl = new BTextControl(frame, "double_click_test_area", NULL,
|
||||
"Double-click test area", NULL);
|
||||
BTextControl *textControl = new BTextControl(frame,
|
||||
"double_click_test_area", NULL, "Double-click test area", NULL);
|
||||
textControl->SetAlignment(B_ALIGN_LEFT, B_ALIGN_CENTER);
|
||||
AddChild(textControl);
|
||||
|
||||
@@ -199,7 +199,7 @@ SettingsView::AttachedToWindow()
|
||||
|
||||
|
||||
void
|
||||
SettingsView::GetPreferredSize(float *_width, float *_height)
|
||||
SettingsView::GetPreferredSize(float* _width, float* _height)
|
||||
{
|
||||
if (_width)
|
||||
*_width = fRightArea.right + 5;
|
||||
@@ -248,15 +248,14 @@ SettingsView::Draw(BRect updateFrame)
|
||||
DrawBitmapAsync(fDoubleClickBitmap, fDoubleClickBmpPoint);
|
||||
|
||||
if (fSpeedBitmap != NULL
|
||||
&& updateFrame.Intersects(BRect(fSpeedBmpPoint,
|
||||
fSpeedBmpPoint + fSpeedBitmap->Bounds().RightBottom())))
|
||||
&& updateFrame.Intersects(BRect(fSpeedBmpPoint, fSpeedBmpPoint
|
||||
+ fSpeedBitmap->Bounds().RightBottom())))
|
||||
DrawBitmapAsync(fSpeedBitmap, fSpeedBmpPoint);
|
||||
|
||||
if (fAccelerationBitmap != NULL
|
||||
&& updateFrame.Intersects(BRect(fAccelerationBmpPoint,
|
||||
fAccelerationBmpPoint + fAccelerationBitmap->Bounds().RightBottom())))
|
||||
&& updateFrame.Intersects(BRect(fAccelerationBmpPoint, fAccelerationBmpPoint
|
||||
+ fAccelerationBitmap->Bounds().RightBottom())))
|
||||
DrawBitmapAsync(fAccelerationBitmap, fAccelerationBmpPoint);
|
||||
|
||||
|
||||
SetDrawingMode(B_OP_COPY);
|
||||
}
|
||||
@@ -283,7 +282,7 @@ SettingsView::UpdateFromSettings()
|
||||
// slow = 1000000, fast = 0
|
||||
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
|
||||
fMouseSpeedSlider->SetValue(value);
|
||||
|
||||
@@ -301,4 +300,3 @@ SettingsView::UpdateFromSettings()
|
||||
if (item != NULL)
|
||||
item->SetMarked(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2003, OpenBeOS
|
||||
//
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
//
|
||||
// File: SettingsView.h
|
||||
// Authors: Jérôme Duval,
|
||||
// Andrew McCall ([email protected])
|
||||
// Axel Dörfler ([email protected])
|
||||
// Description: Mouse Preferences
|
||||
// Created: December 10, 2003
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
/*
|
||||
* Copyright 2003-2009 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval,
|
||||
* Axel Dörfler (axeld@pinc-software.de)
|
||||
* Andrew McCall (mccall@digitalparadise.co.uk)
|
||||
*/
|
||||
|
||||
#ifndef SETTINGS_VIEW_H
|
||||
#define SETTINGS_VIEW_H
|
||||
|
||||
@@ -30,19 +24,19 @@ class MouseView;
|
||||
|
||||
|
||||
class SettingsView : public BBox {
|
||||
public:
|
||||
public:
|
||||
SettingsView(BRect frame, MouseSettings &settings);
|
||||
virtual ~SettingsView();
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void GetPreferredSize(float *_width, float *_height);
|
||||
virtual void GetPreferredSize(float* _width, float* _height);
|
||||
virtual void Draw(BRect frame);
|
||||
|
||||
void SetMouseType(int32 type);
|
||||
void MouseMapUpdated();
|
||||
void UpdateFromSettings();
|
||||
|
||||
private:
|
||||
private:
|
||||
typedef BBox inherited;
|
||||
|
||||
const MouseSettings &fSettings;
|
||||
|
||||
Reference in New Issue
Block a user