haiku/headers/private/interface/Spinner.h
John Scipione a0ba79fbff 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.
2015-08-22 15:15:08 -07:00

88 lines
2.3 KiB
C++

/*
* Copyright 2015 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT license.
*
* Authors:
* John Scipione, jscipione@gmail.com
*/
#ifndef _SPINNER_H
#define _SPINNER_H
#include <AbstractSpinner.h>
class BSpinner : public BAbstractSpinner {
public:
BSpinner(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);
BSpinner(const char* name, const char* label,
BMessage* message,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BSpinner(BMessage* data);
virtual ~BSpinner();
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
virtual void Increment();
virtual void Decrement();
virtual status_t GetSupportedSuites(BMessage* message);
virtual void AttachedToWindow();
virtual void SetEnabled(bool enable);
int32 MaxValue() const { return fMaxValue; }
virtual void SetMaxValue(int32 max);
int32 MinValue() const { return fMinValue; }
virtual void SetMinValue(int32 min);
void Range(int32* min, int32* max);
virtual void SetRange(int32 min, int32 max);
int32 Value() const { return fValue; };
virtual void SetValue(int32 value);
virtual void SetValueFromText();
private:
// FBC padding
virtual void _ReservedSpinner20();
virtual void _ReservedSpinner19();
virtual void _ReservedSpinner18();
virtual void _ReservedSpinner17();
virtual void _ReservedSpinner16();
virtual void _ReservedSpinner15();
virtual void _ReservedSpinner14();
virtual void _ReservedSpinner13();
virtual void _ReservedSpinner12();
virtual void _ReservedSpinner11();
virtual void _ReservedSpinner10();
virtual void _ReservedSpinner9();
virtual void _ReservedSpinner8();
virtual void _ReservedSpinner7();
virtual void _ReservedSpinner6();
virtual void _ReservedSpinner5();
virtual void _ReservedSpinner4();
virtual void _ReservedSpinner3();
virtual void _ReservedSpinner2();
virtual void _ReservedSpinner1();
private:
void _InitObject();
int32 fMinValue;
int32 fMaxValue;
int32 fValue;
// FBC padding
uint32 _reserved[20];
};
#endif // _SPINNER_H