a0ba79fbff
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.
97 lines
2.8 KiB
C++
97 lines
2.8 KiB
C++
/*
|
|
* Copyright 2015 Haiku, Inc. All rights reserved.
|
|
* Distributed under the terms of the MIT license.
|
|
*
|
|
* Authors:
|
|
* John Scipione, jscipione@gmail.com
|
|
*/
|
|
#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
|