Split BSpinner into BAbstractSpinner and...
2 concrete classes which are currently implemented: * BSpinner (works on int32s) * BDecimalSpinner (works on doubles) In addition BAbstractSpinner now inherits from BControl instead of BView/BInvoker. This allowed for code simplification at the cost of needing to cast for the decimal version because SetValue(int32 value) comes from BControl. Also, add a spinner_button_style enum with 3 options: * SPINNER_BUTTON_HORIZONTAL_ARROWS * SPINNER_BUTTON_VERTICAL_ARROWS * SPINNER_BUTTON_PLUS_MINUS which sets the spinner arrows to either use horizontal arrows (left/right) vertical arrows, (up/down), or +/- symbols (the default). If the spinner button is using horizontal arrows you can decrement and increment the spinner value by pushing control+left/right, otherwise you can increment and decrement by pushing up or down. The reason for needing control is so that you can move the cursor in the textbox otherwise. Switch the 3 apps that are currently using BSpinners to use the integer variety in Deskbar preferences, WebPostive preferences, and Screen preferences.
This commit is contained in:
@@ -0,0 +1,168 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2004 DarkWyrm <[email protected]>
|
||||||
|
* Copyright 2013 FeemanLou
|
||||||
|
* Copyright 2014-2015 Haiku, Inc. All rights reserved.
|
||||||
|
*
|
||||||
|
* Distributed under the terms of the MIT license.
|
||||||
|
*
|
||||||
|
* Originally written by DarkWyrm <[email protected]>
|
||||||
|
* Updated by FreemanLou as part of Google GCI 2013
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* DarkWyrm, [email protected]
|
||||||
|
* FeemanLou
|
||||||
|
* John Scipione, [email protected]
|
||||||
|
*/
|
||||||
|
#ifndef _ABSTRACT_SPINNER_H
|
||||||
|
#define _ABSTRACT_SPINNER_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Control.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SPINNER_BUTTON_HORIZONTAL_ARROWS,
|
||||||
|
SPINNER_BUTTON_VERTICAL_ARROWS,
|
||||||
|
SPINNER_BUTTON_PLUS_MINUS
|
||||||
|
} spinner_button_style;
|
||||||
|
|
||||||
|
|
||||||
|
class BTextView;
|
||||||
|
class SpinnerButton;
|
||||||
|
class SpinnerTextView;
|
||||||
|
|
||||||
|
|
||||||
|
/*! BAbstractSpinner provides an input whose value can be nudged up or down
|
||||||
|
by way of two small buttons on the right.
|
||||||
|
*/
|
||||||
|
class BAbstractSpinner : public BControl {
|
||||||
|
public:
|
||||||
|
BAbstractSpinner(BRect frame, const char* name,
|
||||||
|
const char* label, BMessage* message,
|
||||||
|
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
|
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||||
|
BAbstractSpinner(const char* name, const char* label,
|
||||||
|
BMessage* message,
|
||||||
|
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||||
|
BAbstractSpinner(BMessage* data);
|
||||||
|
virtual ~BAbstractSpinner();
|
||||||
|
|
||||||
|
static BArchivable* Instantiate(BMessage* data);
|
||||||
|
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
||||||
|
|
||||||
|
virtual status_t GetSupportedSuites(BMessage* message);
|
||||||
|
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
|
||||||
|
BMessage* specifier, int32 form,
|
||||||
|
const char* property);
|
||||||
|
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
virtual void Draw(BRect updateRect);
|
||||||
|
virtual void FrameResized(float width, float height);
|
||||||
|
virtual void ValueChanged();
|
||||||
|
|
||||||
|
virtual void Decrement() = 0;
|
||||||
|
virtual void Increment() = 0;
|
||||||
|
virtual void MakeFocus(bool focus = true);
|
||||||
|
virtual void ResizeToPreferred();
|
||||||
|
virtual void SetFlags(uint32 flags);
|
||||||
|
virtual void WindowActivated(bool active);
|
||||||
|
|
||||||
|
alignment Alignment() const { return fAlignment; };
|
||||||
|
virtual void SetAlignment(alignment align);
|
||||||
|
|
||||||
|
spinner_button_style ButtonStyle() const { return fButtonStyle; };
|
||||||
|
virtual void SetButtonStyle(spinner_button_style buttonStyle);
|
||||||
|
|
||||||
|
float Divider() const { return fDivider; };
|
||||||
|
virtual void SetDivider(float position);
|
||||||
|
|
||||||
|
virtual void SetEnabled(bool enable);
|
||||||
|
|
||||||
|
virtual void SetLabel(const char* label);
|
||||||
|
|
||||||
|
virtual void SetValueFromText() = 0;
|
||||||
|
|
||||||
|
bool IsDecrementEnabled() const;
|
||||||
|
virtual void SetDecrementEnabled(bool enable);
|
||||||
|
|
||||||
|
bool IsIncrementEnabled() const;
|
||||||
|
virtual void SetIncrementEnabled(bool enable);
|
||||||
|
|
||||||
|
virtual BSize MinSize();
|
||||||
|
virtual BSize MaxSize();
|
||||||
|
virtual BSize PreferredSize();
|
||||||
|
virtual BAlignment LayoutAlignment();
|
||||||
|
|
||||||
|
BLayoutItem* CreateLabelLayoutItem();
|
||||||
|
BLayoutItem* CreateTextViewLayoutItem();
|
||||||
|
|
||||||
|
BTextView* TextView() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// FBC padding
|
||||||
|
virtual void _ReservedAbstractSpinner20();
|
||||||
|
virtual void _ReservedAbstractSpinner19();
|
||||||
|
virtual void _ReservedAbstractSpinner18();
|
||||||
|
virtual void _ReservedAbstractSpinner17();
|
||||||
|
virtual void _ReservedAbstractSpinner16();
|
||||||
|
virtual void _ReservedAbstractSpinner15();
|
||||||
|
virtual void _ReservedAbstractSpinner14();
|
||||||
|
virtual void _ReservedAbstractSpinner13();
|
||||||
|
virtual void _ReservedAbstractSpinner12();
|
||||||
|
virtual void _ReservedAbstractSpinner11();
|
||||||
|
virtual void _ReservedAbstractSpinner10();
|
||||||
|
virtual void _ReservedAbstractSpinner9();
|
||||||
|
virtual void _ReservedAbstractSpinner8();
|
||||||
|
virtual void _ReservedAbstractSpinner7();
|
||||||
|
virtual void _ReservedAbstractSpinner6();
|
||||||
|
virtual void _ReservedAbstractSpinner5();
|
||||||
|
virtual void _ReservedAbstractSpinner4();
|
||||||
|
virtual void _ReservedAbstractSpinner3();
|
||||||
|
virtual void _ReservedAbstractSpinner2();
|
||||||
|
virtual void _ReservedAbstractSpinner1();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual status_t AllArchived(BMessage* into) const;
|
||||||
|
virtual status_t AllUnarchived(const BMessage* from);
|
||||||
|
|
||||||
|
virtual void LayoutInvalidated(bool descendants);
|
||||||
|
virtual void DoLayout();
|
||||||
|
|
||||||
|
private:
|
||||||
|
class LabelLayoutItem;
|
||||||
|
class TextViewLayoutItem;
|
||||||
|
struct LayoutData;
|
||||||
|
|
||||||
|
friend class SpinnerButton;
|
||||||
|
friend class SpinnerTextView;
|
||||||
|
|
||||||
|
friend class LabelLayoutItem;
|
||||||
|
friend class TextViewLayoutItem;
|
||||||
|
friend struct LayoutData;
|
||||||
|
|
||||||
|
void _DrawLabel(BRect updateRect);
|
||||||
|
void _DrawTextView(BRect updateRect);
|
||||||
|
void _InitObject();
|
||||||
|
void _LayoutTextView();
|
||||||
|
void _UpdateFrame();
|
||||||
|
void _UpdateTextViewColors(bool enable);
|
||||||
|
void _ValidateLayoutData();
|
||||||
|
|
||||||
|
BAbstractSpinner& operator=(const BAbstractSpinner& other);
|
||||||
|
|
||||||
|
alignment fAlignment;
|
||||||
|
spinner_button_style fButtonStyle;
|
||||||
|
float fDivider;
|
||||||
|
|
||||||
|
LayoutData* fLayoutData;
|
||||||
|
|
||||||
|
SpinnerTextView* fTextView;
|
||||||
|
SpinnerButton* fIncrement;
|
||||||
|
SpinnerButton* fDecrement;
|
||||||
|
|
||||||
|
// FBC padding
|
||||||
|
uint32 _reserved[20];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _ABSTRACT_SPINNER_H
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 Haiku, Inc. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT license.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* John Scipione, [email protected]
|
||||||
|
*/
|
||||||
|
#ifndef _DECIMAL_SPINNER_H
|
||||||
|
#define _DECIMAL_SPINNER_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Spinner.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BDecimalSpinner : public BAbstractSpinner {
|
||||||
|
public:
|
||||||
|
BDecimalSpinner(BRect frame, const char* name,
|
||||||
|
const char* label, BMessage* message,
|
||||||
|
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
|
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||||
|
BDecimalSpinner(const char* name, const char* label,
|
||||||
|
BMessage* message,
|
||||||
|
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
||||||
|
BDecimalSpinner(BMessage* data);
|
||||||
|
virtual ~BDecimalSpinner();
|
||||||
|
|
||||||
|
static BArchivable* Instantiate(BMessage* data);
|
||||||
|
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
||||||
|
|
||||||
|
virtual status_t GetSupportedSuites(BMessage* message);
|
||||||
|
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
|
||||||
|
virtual void Increment();
|
||||||
|
virtual void Decrement();
|
||||||
|
|
||||||
|
virtual void SetEnabled(bool enable);
|
||||||
|
|
||||||
|
uint32 Precision() const { return fPrecision; };
|
||||||
|
virtual void SetPrecision(uint32 precision) { fPrecision = precision; };
|
||||||
|
|
||||||
|
double MaxValue() const { return fMaxValue; }
|
||||||
|
virtual void SetMaxValue(double max);
|
||||||
|
|
||||||
|
double MinValue() const { return fMinValue; }
|
||||||
|
virtual void SetMinValue(double min);
|
||||||
|
|
||||||
|
void Range(double* min, double* max);
|
||||||
|
virtual void SetRange(double min, double max);
|
||||||
|
|
||||||
|
double Step() const { return fStep; }
|
||||||
|
virtual void SetStep(double step) { fStep = step; };
|
||||||
|
|
||||||
|
double Value() const { return fValue; };
|
||||||
|
virtual void SetValue(int32 value);
|
||||||
|
virtual void SetValue(double value);
|
||||||
|
virtual void SetValueFromText();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// FBC padding
|
||||||
|
virtual void _ReservedDecimalSpinner20();
|
||||||
|
virtual void _ReservedDecimalSpinner19();
|
||||||
|
virtual void _ReservedDecimalSpinner18();
|
||||||
|
virtual void _ReservedDecimalSpinner17();
|
||||||
|
virtual void _ReservedDecimalSpinner16();
|
||||||
|
virtual void _ReservedDecimalSpinner15();
|
||||||
|
virtual void _ReservedDecimalSpinner14();
|
||||||
|
virtual void _ReservedDecimalSpinner13();
|
||||||
|
virtual void _ReservedDecimalSpinner12();
|
||||||
|
virtual void _ReservedDecimalSpinner11();
|
||||||
|
virtual void _ReservedDecimalSpinner10();
|
||||||
|
virtual void _ReservedDecimalSpinner9();
|
||||||
|
virtual void _ReservedDecimalSpinner8();
|
||||||
|
virtual void _ReservedDecimalSpinner7();
|
||||||
|
virtual void _ReservedDecimalSpinner6();
|
||||||
|
virtual void _ReservedDecimalSpinner5();
|
||||||
|
virtual void _ReservedDecimalSpinner4();
|
||||||
|
virtual void _ReservedDecimalSpinner3();
|
||||||
|
virtual void _ReservedDecimalSpinner2();
|
||||||
|
virtual void _ReservedDecimalSpinner1();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void _InitObject();
|
||||||
|
|
||||||
|
double fMinValue;
|
||||||
|
double fMaxValue;
|
||||||
|
double fStep;
|
||||||
|
double fValue;
|
||||||
|
uint32 fPrecision;
|
||||||
|
|
||||||
|
// FBC padding
|
||||||
|
uint32 _reserved[20];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _DECIMAL_SPINNER_H
|
||||||
@@ -1,35 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004 DarkWyrm <[email protected]>
|
* Copyright 2015 Haiku, Inc. All rights reserved.
|
||||||
* Copyright 2013 FeemanLou
|
|
||||||
* Copyright 2014 Haiku, Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Originally written by DarkWyrm <[email protected]>
|
|
||||||
* Updated by FreemanLou as part of Google GCI 2013
|
|
||||||
*
|
|
||||||
* Authors:
|
* Authors:
|
||||||
* DarkWyrm, [email protected]
|
|
||||||
* FeemanLou
|
|
||||||
* John Scipione, [email protected]
|
* John Scipione, [email protected]
|
||||||
*/
|
*/
|
||||||
#ifndef SPINNER_H
|
#ifndef _SPINNER_H
|
||||||
#define SPINNER_H
|
#define _SPINNER_H
|
||||||
|
|
||||||
|
|
||||||
#include <Invoker.h>
|
#include <AbstractSpinner.h>
|
||||||
#include <View.h>
|
|
||||||
|
|
||||||
|
|
||||||
class BTextView;
|
class BSpinner : public BAbstractSpinner {
|
||||||
class SpinnerArrow;
|
|
||||||
class SpinnerTextView;
|
|
||||||
|
|
||||||
|
|
||||||
/*! BSpinner provides a numeric input whose value can be nudged up or down
|
|
||||||
by way of two small buttons on the right.
|
|
||||||
*/
|
|
||||||
class BSpinner : public BView, public BInvoker {
|
|
||||||
public:
|
public:
|
||||||
BSpinner(BRect frame, const char* name,
|
BSpinner(BRect frame, const char* name,
|
||||||
const char* label, BMessage* message,
|
const char* label, BMessage* message,
|
||||||
@@ -44,69 +27,27 @@ public:
|
|||||||
static BArchivable* Instantiate(BMessage* data);
|
static BArchivable* Instantiate(BMessage* data);
|
||||||
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
||||||
|
|
||||||
|
virtual void Increment();
|
||||||
|
virtual void Decrement();
|
||||||
|
|
||||||
virtual status_t GetSupportedSuites(BMessage* message);
|
virtual status_t GetSupportedSuites(BMessage* message);
|
||||||
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
|
|
||||||
BMessage* specifier, int32 form,
|
|
||||||
const char* property);
|
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void Draw(BRect updateRect);
|
|
||||||
virtual void FrameResized(float width, float height);
|
|
||||||
virtual void ValueChanged();
|
|
||||||
|
|
||||||
virtual void Decrement();
|
|
||||||
virtual void Increment();
|
|
||||||
virtual void MakeFocus(bool focus = true);
|
|
||||||
virtual void ResizeToPreferred();
|
|
||||||
virtual void SetFlags(uint32 flags);
|
|
||||||
virtual void SetValueFromText();
|
|
||||||
virtual void WindowActivated(bool active);
|
|
||||||
|
|
||||||
alignment Alignment() const { return fAlignment; };
|
|
||||||
virtual void SetAlignment(alignment align);
|
|
||||||
|
|
||||||
float Divider() const { return fDivider; };
|
|
||||||
virtual void SetDivider(float position);
|
|
||||||
|
|
||||||
bool IsEnabled() const { return fIsEnabled; };
|
|
||||||
virtual void SetEnabled(bool enable);
|
virtual void SetEnabled(bool enable);
|
||||||
|
|
||||||
const char* Label() const { return fLabel; };
|
int32 MaxValue() const { return fMaxValue; }
|
||||||
virtual void SetLabel(const char* text);
|
virtual void SetMaxValue(int32 max);
|
||||||
|
|
||||||
uint32 Precision() const { return fPrecision; };
|
int32 MinValue() const { return fMinValue; }
|
||||||
virtual void SetPrecision(uint32 precision) { fPrecision = precision; };
|
virtual void SetMinValue(int32 min);
|
||||||
|
|
||||||
double MaxValue() const { return fMaxValue; }
|
void Range(int32* min, int32* max);
|
||||||
virtual void SetMaxValue(double max);
|
virtual void SetRange(int32 min, int32 max);
|
||||||
|
|
||||||
double MinValue() const { return fMinValue; }
|
int32 Value() const { return fValue; };
|
||||||
virtual void SetMinValue(double min);
|
virtual void SetValue(int32 value);
|
||||||
|
virtual void SetValueFromText();
|
||||||
void Range(double* min, double* max);
|
|
||||||
virtual void SetRange(double min, double max);
|
|
||||||
|
|
||||||
double Step() const { return fStep; }
|
|
||||||
virtual void SetStep(double step) { fStep = step; };
|
|
||||||
|
|
||||||
double Value() const { return fValue; };
|
|
||||||
virtual void SetValue(double value);
|
|
||||||
|
|
||||||
bool IsDecrementEnabled() const;
|
|
||||||
virtual void SetDecrementEnabled(bool enable);
|
|
||||||
|
|
||||||
bool IsIncrementEnabled() const;
|
|
||||||
virtual void SetIncrementEnabled(bool enable);
|
|
||||||
|
|
||||||
virtual BSize MinSize();
|
|
||||||
virtual BSize MaxSize();
|
|
||||||
virtual BSize PreferredSize();
|
|
||||||
virtual BAlignment LayoutAlignment();
|
|
||||||
|
|
||||||
BLayoutItem* CreateLabelLayoutItem();
|
|
||||||
BLayoutItem* CreateTextViewLayoutItem();
|
|
||||||
|
|
||||||
BTextView* TextView() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// FBC padding
|
// FBC padding
|
||||||
@@ -131,54 +72,16 @@ private:
|
|||||||
virtual void _ReservedSpinner2();
|
virtual void _ReservedSpinner2();
|
||||||
virtual void _ReservedSpinner1();
|
virtual void _ReservedSpinner1();
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual status_t AllArchived(BMessage* into) const;
|
|
||||||
virtual status_t AllUnarchived(const BMessage* from);
|
|
||||||
|
|
||||||
virtual void LayoutInvalidated(bool descendants);
|
|
||||||
virtual void DoLayout();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class LabelLayoutItem;
|
|
||||||
class TextViewLayoutItem;
|
|
||||||
struct LayoutData;
|
|
||||||
|
|
||||||
friend class SpinnerArrow;
|
|
||||||
friend class SpinnerTextView;
|
|
||||||
|
|
||||||
friend class LabelLayoutItem;
|
|
||||||
friend class TextViewLayoutItem;
|
|
||||||
friend struct LayoutData;
|
|
||||||
|
|
||||||
void _DrawLabel(BRect updateRect);
|
|
||||||
void _DrawTextView(BRect updateRect);
|
|
||||||
void _InitObject();
|
void _InitObject();
|
||||||
void _LayoutTextView();
|
|
||||||
void _UpdateFrame();
|
|
||||||
void _UpdateTextViewColors(bool enable);
|
|
||||||
void _ValidateLayoutData();
|
|
||||||
|
|
||||||
BSpinner& operator=(const BSpinner& other);
|
int32 fMinValue;
|
||||||
|
int32 fMaxValue;
|
||||||
alignment fAlignment;
|
int32 fValue;
|
||||||
float fDivider;
|
|
||||||
bool fIsEnabled;
|
|
||||||
const char* fLabel;
|
|
||||||
double fMinValue;
|
|
||||||
double fMaxValue;
|
|
||||||
double fStep;
|
|
||||||
double fValue;
|
|
||||||
uint32 fPrecision;
|
|
||||||
|
|
||||||
LayoutData* fLayoutData;
|
|
||||||
|
|
||||||
SpinnerTextView* fTextView;
|
|
||||||
SpinnerArrow* fIncrement;
|
|
||||||
SpinnerArrow* fDecrement;
|
|
||||||
|
|
||||||
// FBC padding
|
// FBC padding
|
||||||
uint32 _reserved[20];
|
uint32 _reserved[20];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // SPINNER_H
|
#endif // _SPINNER_H
|
||||||
|
|||||||
@@ -103,23 +103,17 @@ PreferencesWindow::PreferencesWindow(BRect frame)
|
|||||||
// Menu settings
|
// Menu settings
|
||||||
fMenuRecentDocuments->SetValue(fSettings.recentDocsEnabled);
|
fMenuRecentDocuments->SetValue(fSettings.recentDocsEnabled);
|
||||||
fMenuRecentDocumentCount->SetEnabled(fSettings.recentDocsEnabled);
|
fMenuRecentDocumentCount->SetEnabled(fSettings.recentDocsEnabled);
|
||||||
fMenuRecentDocumentCount->SetPrecision(0);
|
|
||||||
fMenuRecentDocumentCount->SetRange(0, 50);
|
fMenuRecentDocumentCount->SetRange(0, 50);
|
||||||
fMenuRecentDocumentCount->SetStep(1);
|
|
||||||
fMenuRecentDocumentCount->SetValue(fSettings.recentDocsCount);
|
fMenuRecentDocumentCount->SetValue(fSettings.recentDocsCount);
|
||||||
|
|
||||||
fMenuRecentApplications->SetValue(fSettings.recentAppsEnabled);
|
fMenuRecentApplications->SetValue(fSettings.recentAppsEnabled);
|
||||||
fMenuRecentApplicationCount->SetEnabled(fSettings.recentAppsEnabled);
|
fMenuRecentApplicationCount->SetEnabled(fSettings.recentAppsEnabled);
|
||||||
fMenuRecentApplicationCount->SetPrecision(0);
|
|
||||||
fMenuRecentApplicationCount->SetRange(0, 50);
|
fMenuRecentApplicationCount->SetRange(0, 50);
|
||||||
fMenuRecentApplicationCount->SetStep(1);
|
|
||||||
fMenuRecentApplicationCount->SetValue(fSettings.recentAppsCount);
|
fMenuRecentApplicationCount->SetValue(fSettings.recentAppsCount);
|
||||||
|
|
||||||
fMenuRecentFolders->SetValue(fSettings.recentFoldersEnabled);
|
fMenuRecentFolders->SetValue(fSettings.recentFoldersEnabled);
|
||||||
fMenuRecentFolderCount->SetEnabled(fSettings.recentFoldersEnabled);
|
fMenuRecentFolderCount->SetEnabled(fSettings.recentFoldersEnabled);
|
||||||
fMenuRecentFolderCount->SetPrecision(0);
|
|
||||||
fMenuRecentFolderCount->SetRange(0, 50);
|
fMenuRecentFolderCount->SetRange(0, 50);
|
||||||
fMenuRecentFolderCount->SetStep(1);
|
|
||||||
fMenuRecentFolderCount->SetValue(fSettings.recentFoldersCount);
|
fMenuRecentFolderCount->SetValue(fSettings.recentFoldersCount);
|
||||||
|
|
||||||
// Applications settings
|
// Applications settings
|
||||||
|
|||||||
@@ -307,9 +307,7 @@ SettingsWindow::_CreateGeneralPage(float spacing)
|
|||||||
fDaysInHistory = new BSpinner("days in history",
|
fDaysInHistory = new BSpinner("days in history",
|
||||||
B_TRANSLATE("Number of days to keep links in History menu:"),
|
B_TRANSLATE("Number of days to keep links in History menu:"),
|
||||||
new BMessage(MSG_HISTORY_MENU_DAYS_CHANGED));
|
new BMessage(MSG_HISTORY_MENU_DAYS_CHANGED));
|
||||||
fDaysInHistory->SetPrecision(0);
|
|
||||||
fDaysInHistory->SetRange(1, 35);
|
fDaysInHistory->SetRange(1, 35);
|
||||||
fDaysInHistory->SetStep(1);
|
|
||||||
fDaysInHistory->SetValue(
|
fDaysInHistory->SetValue(
|
||||||
BrowsingHistory::DefaultInstance()->MaxHistoryItemAge());
|
BrowsingHistory::DefaultInstance()->MaxHistoryItemAge());
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,372 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 Haiku, Inc. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT license.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* John Scipione, jscipione@gmail.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <DecimalSpinner.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <PropertyInfo.h>
|
||||||
|
#include <TextView.h>
|
||||||
|
|
||||||
|
|
||||||
|
static double
|
||||||
|
roundTo(double value, uint32 n)
|
||||||
|
{
|
||||||
|
return floor(value * pow(10.0, n) + 0.5) / pow(10.0, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static property_info sProperties[] = {
|
||||||
|
{
|
||||||
|
"MaxValue",
|
||||||
|
{ B_GET_PROPERTY, 0 },
|
||||||
|
{ B_DIRECT_SPECIFIER, 0 },
|
||||||
|
"Returns the maximum value of the spinner.",
|
||||||
|
0,
|
||||||
|
{ B_DOUBLE_TYPE }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"MaxValue",
|
||||||
|
{ B_SET_PROPERTY, 0 },
|
||||||
|
{ B_DIRECT_SPECIFIER, 0},
|
||||||
|
"Sets the maximum value of the spinner.",
|
||||||
|
0,
|
||||||
|
{ B_DOUBLE_TYPE }
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"MinValue",
|
||||||
|
{ B_GET_PROPERTY, 0 },
|
||||||
|
{ B_DIRECT_SPECIFIER, 0 },
|
||||||
|
"Returns the minimum value of the spinner.",
|
||||||
|
0,
|
||||||
|
{ B_DOUBLE_TYPE }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"MinValue",
|
||||||
|
{ B_SET_PROPERTY, 0 },
|
||||||
|
{ B_DIRECT_SPECIFIER, 0},
|
||||||
|
"Sets the minimum value of the spinner.",
|
||||||
|
0,
|
||||||
|
{ B_DOUBLE_TYPE }
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"Precision",
|
||||||
|
{ B_SET_PROPERTY, 0 },
|
||||||
|
{ B_DIRECT_SPECIFIER, 0},
|
||||||
|
"Sets the number of decimal places of precision of the spinner.",
|
||||||
|
0,
|
||||||
|
{ B_UINT32_TYPE }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Precision",
|
||||||
|
{ B_GET_PROPERTY, 0 },
|
||||||
|
{ B_DIRECT_SPECIFIER, 0 },
|
||||||
|
"Returns the number of decimal places of precision of the spinner.",
|
||||||
|
0,
|
||||||
|
{ B_UINT32_TYPE }
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"Step",
|
||||||
|
{ B_GET_PROPERTY, 0 },
|
||||||
|
{ B_DIRECT_SPECIFIER, 0 },
|
||||||
|
"Returns the step size of the spinner.",
|
||||||
|
0,
|
||||||
|
{ B_DOUBLE_TYPE }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Step",
|
||||||
|
{ B_SET_PROPERTY, 0 },
|
||||||
|
{ B_DIRECT_SPECIFIER, 0},
|
||||||
|
"Sets the step size of the spinner.",
|
||||||
|
0,
|
||||||
|
{ B_DOUBLE_TYPE }
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"Value",
|
||||||
|
{ B_GET_PROPERTY, 0 },
|
||||||
|
{ B_DIRECT_SPECIFIER, 0 },
|
||||||
|
"Returns the value of the spinner.",
|
||||||
|
0,
|
||||||
|
{ B_DOUBLE_TYPE }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Value",
|
||||||
|
{ B_SET_PROPERTY, 0 },
|
||||||
|
{ B_DIRECT_SPECIFIER, 0},
|
||||||
|
"Sets the value of the spinner.",
|
||||||
|
0,
|
||||||
|
{ B_DOUBLE_TYPE }
|
||||||
|
},
|
||||||
|
|
||||||
|
{ 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - BDecimalSpinner
|
||||||
|
|
||||||
|
|
||||||
|
BDecimalSpinner::BDecimalSpinner(BRect frame, const char* name,
|
||||||
|
const char* label, BMessage* message, uint32 resizingMode, uint32 flags)
|
||||||
|
:
|
||||||
|
BAbstractSpinner(frame, name, label, message, resizingMode, flags)
|
||||||
|
{
|
||||||
|
_InitObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BDecimalSpinner::BDecimalSpinner(const char* name, const char* label,
|
||||||
|
BMessage* message, uint32 flags)
|
||||||
|
:
|
||||||
|
BAbstractSpinner(name, label, message, flags)
|
||||||
|
{
|
||||||
|
_InitObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BDecimalSpinner::BDecimalSpinner(BMessage* data)
|
||||||
|
:
|
||||||
|
BAbstractSpinner(data)
|
||||||
|
{
|
||||||
|
_InitObject();
|
||||||
|
|
||||||
|
if (data->FindDouble("_max", &fMaxValue) != B_OK)
|
||||||
|
fMinValue = 100.0;
|
||||||
|
|
||||||
|
if (data->FindDouble("_min", &fMinValue) != B_OK)
|
||||||
|
fMinValue = 0.0;
|
||||||
|
|
||||||
|
if (data->FindUInt32("_precision", &fPrecision) != B_OK)
|
||||||
|
fPrecision = 2;
|
||||||
|
|
||||||
|
if (data->FindDouble("_step", &fStep) != B_OK)
|
||||||
|
fStep = 1.0;
|
||||||
|
|
||||||
|
if (data->FindDouble("_val", &fValue) != B_OK)
|
||||||
|
fValue = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BDecimalSpinner::~BDecimalSpinner()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BArchivable*
|
||||||
|
BDecimalSpinner::Instantiate(BMessage* data)
|
||||||
|
{
|
||||||
|
if (validate_instantiation(data, "DecimalSpinner"))
|
||||||
|
return new BDecimalSpinner(data);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BDecimalSpinner::Archive(BMessage* data, bool deep) const
|
||||||
|
{
|
||||||
|
status_t status = BAbstractSpinner::Archive(data, deep);
|
||||||
|
data->AddString("class", "DecimalSpinner");
|
||||||
|
|
||||||
|
if (status == B_OK)
|
||||||
|
status = data->AddDouble("_max", fMaxValue);
|
||||||
|
|
||||||
|
if (status == B_OK)
|
||||||
|
status = data->AddDouble("_min", fMinValue);
|
||||||
|
|
||||||
|
if (status == B_OK)
|
||||||
|
status = data->AddUInt32("_precision", fPrecision);
|
||||||
|
|
||||||
|
if (status == B_OK)
|
||||||
|
status = data->AddDouble("_step", fStep);
|
||||||
|
|
||||||
|
if (status == B_OK)
|
||||||
|
status = data->AddDouble("_val", fValue);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BDecimalSpinner::GetSupportedSuites(BMessage* message)
|
||||||
|
{
|
||||||
|
message->AddString("suites", "suite/vnd.Haiku-decimal-spinner");
|
||||||
|
|
||||||
|
BPropertyInfo prop_info(sProperties);
|
||||||
|
message->AddFlat("messages", &prop_info);
|
||||||
|
|
||||||
|
return BView::GetSupportedSuites(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BDecimalSpinner::AttachedToWindow()
|
||||||
|
{
|
||||||
|
SetValue(fValue);
|
||||||
|
|
||||||
|
BAbstractSpinner::AttachedToWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BDecimalSpinner::Decrement()
|
||||||
|
{
|
||||||
|
SetValue(Value() - Step());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BDecimalSpinner::Increment()
|
||||||
|
{
|
||||||
|
SetValue(Value() + Step());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BDecimalSpinner::SetEnabled(bool enable)
|
||||||
|
{
|
||||||
|
if (IsEnabled() == enable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SetIncrementEnabled(enable && Value() < fMaxValue);
|
||||||
|
SetDecrementEnabled(enable && Value() > fMinValue);
|
||||||
|
|
||||||
|
BAbstractSpinner::SetEnabled(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BDecimalSpinner::SetMaxValue(double max)
|
||||||
|
{
|
||||||
|
fMaxValue = max;
|
||||||
|
if (fValue > fMaxValue)
|
||||||
|
SetValue(fMaxValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BDecimalSpinner::SetMinValue(double min)
|
||||||
|
{
|
||||||
|
fMinValue = min;
|
||||||
|
if (fValue < fMinValue)
|
||||||
|
SetValue(fMinValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BDecimalSpinner::Range(double* min, double* max)
|
||||||
|
{
|
||||||
|
*min = fMinValue;
|
||||||
|
*max = fMaxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BDecimalSpinner::SetRange(double min, double max)
|
||||||
|
{
|
||||||
|
SetMinValue(min);
|
||||||
|
SetMaxValue(max);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BDecimalSpinner::SetValue(int32 value)
|
||||||
|
{
|
||||||
|
SetValue((double)value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BDecimalSpinner::SetValue(double value)
|
||||||
|
{
|
||||||
|
// clip to range
|
||||||
|
if (value < fMinValue)
|
||||||
|
value = fMinValue;
|
||||||
|
else if (value > fMaxValue)
|
||||||
|
value = fMaxValue;
|
||||||
|
|
||||||
|
// update the text view
|
||||||
|
char* format;
|
||||||
|
asprintf(&format, "%%.%" B_PRId32 "f", fPrecision);
|
||||||
|
char* valueString;
|
||||||
|
asprintf(&valueString, format, value);
|
||||||
|
TextView()->SetText(valueString);
|
||||||
|
free(format);
|
||||||
|
free(valueString);
|
||||||
|
|
||||||
|
// update the up and down arrows
|
||||||
|
SetIncrementEnabled(IsEnabled() && value < fMaxValue);
|
||||||
|
SetDecrementEnabled(IsEnabled() && value > fMinValue);
|
||||||
|
|
||||||
|
if (value == fValue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fValue = value;
|
||||||
|
ValueChanged();
|
||||||
|
|
||||||
|
Invoke();
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BDecimalSpinner::SetValueFromText()
|
||||||
|
{
|
||||||
|
SetValue(roundTo(atof(TextView()->Text()), Precision()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - BDecimalSpinner private methods
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BDecimalSpinner::_InitObject()
|
||||||
|
{
|
||||||
|
fMaxValue = 100.0;
|
||||||
|
fMinValue = 0.0;
|
||||||
|
fPrecision = 2;
|
||||||
|
fStep = 1.0;
|
||||||
|
fValue = 0.0;
|
||||||
|
|
||||||
|
TextView()->SetAlignment(B_ALIGN_RIGHT);
|
||||||
|
for (uint32 c = 0; c <= 42; c++)
|
||||||
|
TextView()->DisallowChar(c);
|
||||||
|
|
||||||
|
TextView()->DisallowChar('/');
|
||||||
|
for (uint32 c = 58; c <= 127; c++)
|
||||||
|
TextView()->DisallowChar(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FBC padding
|
||||||
|
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner20() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner19() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner18() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner17() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner16() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner15() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner14() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner13() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner12() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner11() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner10() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner9() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner8() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner7() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner6() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner5() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner4() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner3() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner2() {}
|
||||||
|
void BDecimalSpinner::_ReservedDecimalSpinner1() {}
|
||||||
@@ -42,6 +42,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
|||||||
AboutWindow.cpp
|
AboutWindow.cpp
|
||||||
AbstractLayout.cpp
|
AbstractLayout.cpp
|
||||||
AbstractLayoutItem.cpp
|
AbstractLayoutItem.cpp
|
||||||
|
AbstractSpinner.cpp
|
||||||
AffineTransform.cpp
|
AffineTransform.cpp
|
||||||
Alert.cpp
|
Alert.cpp
|
||||||
Alignment.cpp
|
Alignment.cpp
|
||||||
@@ -60,6 +61,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
|||||||
ControlLook.cpp
|
ControlLook.cpp
|
||||||
DecorInfo.cpp
|
DecorInfo.cpp
|
||||||
Deskbar.cpp
|
Deskbar.cpp
|
||||||
|
DecimalSpinner.cpp
|
||||||
Dragger.cpp
|
Dragger.cpp
|
||||||
Font.cpp
|
Font.cpp
|
||||||
Gradient.cpp
|
Gradient.cpp
|
||||||
|
|||||||
+52
-1611
File diff suppressed because it is too large
Load Diff
@@ -238,13 +238,11 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
|
|||||||
fColumnsControl = new BSpinner("columns", B_TRANSLATE("Columns:"),
|
fColumnsControl = new BSpinner("columns", B_TRANSLATE("Columns:"),
|
||||||
new BMessage(kMsgWorkspaceColumnsChanged));
|
new BMessage(kMsgWorkspaceColumnsChanged));
|
||||||
fColumnsControl->SetAlignment(B_ALIGN_RIGHT);
|
fColumnsControl->SetAlignment(B_ALIGN_RIGHT);
|
||||||
fColumnsControl->SetPrecision(0);
|
|
||||||
fColumnsControl->SetRange(1, 32);
|
fColumnsControl->SetRange(1, 32);
|
||||||
|
|
||||||
fRowsControl = new BSpinner("rows", B_TRANSLATE("Rows:"),
|
fRowsControl = new BSpinner("rows", B_TRANSLATE("Rows:"),
|
||||||
new BMessage(kMsgWorkspaceRowsChanged));
|
new BMessage(kMsgWorkspaceRowsChanged));
|
||||||
fRowsControl->SetAlignment(B_ALIGN_RIGHT);
|
fRowsControl->SetAlignment(B_ALIGN_RIGHT);
|
||||||
fRowsControl->SetPrecision(0);
|
|
||||||
fRowsControl->SetRange(1, 32);
|
fRowsControl->SetRange(1, 32);
|
||||||
|
|
||||||
uint32 columns;
|
uint32 columns;
|
||||||
|
|||||||
Reference in New Issue
Block a user