Make UEFI boot-platform build again
[haiku.git] / headers / private / interface / AbstractSpinner.h
blob8326f48c7e070453deaa1db1616c3dec355d5cef
1 /*
2 * Copyright 2004 DarkWyrm <darkwyrm@earthlink.net>
3 * Copyright 2013 FeemanLou
4 * Copyright 2014-2015 Haiku, Inc. All rights reserved.
6 * Distributed under the terms of the MIT license.
8 * Originally written by DarkWyrm <darkwyrm@earthlink.net>
9 * Updated by FreemanLou as part of Google GCI 2013
11 * Authors:
12 * DarkWyrm, darkwyrm@earthlink.net
13 * FeemanLou
14 * John Scipione, jscipione@gmail.com
16 #ifndef _ABSTRACT_SPINNER_H
17 #define _ABSTRACT_SPINNER_H
20 #include <Control.h>
23 typedef enum {
24 SPINNER_BUTTON_HORIZONTAL_ARROWS,
25 SPINNER_BUTTON_VERTICAL_ARROWS,
26 SPINNER_BUTTON_PLUS_MINUS
27 } spinner_button_style;
30 class BTextView;
31 class SpinnerButton;
32 class SpinnerTextView;
35 /*! BAbstractSpinner provides an input whose value can be nudged up or down
36 by way of two small buttons on the right.
38 class BAbstractSpinner : public BControl {
39 public:
40 BAbstractSpinner(BRect frame, const char* name,
41 const char* label, BMessage* message,
42 uint32 resizingMode = B_FOLLOW_LEFT_TOP,
43 uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
44 BAbstractSpinner(const char* name, const char* label,
45 BMessage* message,
46 uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
47 BAbstractSpinner(BMessage* data);
48 virtual ~BAbstractSpinner();
50 static BArchivable* Instantiate(BMessage* data);
51 virtual status_t Archive(BMessage* data, bool deep = true) const;
53 virtual status_t GetSupportedSuites(BMessage* message);
54 virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
55 BMessage* specifier, int32 form,
56 const char* property);
58 virtual void AttachedToWindow();
59 virtual void Draw(BRect updateRect);
60 virtual void FrameResized(float width, float height);
61 virtual void ValueChanged();
62 virtual void MessageReceived(BMessage* message);
64 virtual void Decrement() = 0;
65 virtual void Increment() = 0;
66 virtual void MakeFocus(bool focus = true);
67 virtual void ResizeToPreferred();
68 virtual void SetFlags(uint32 flags);
69 virtual void WindowActivated(bool active);
71 alignment Alignment() const { return fAlignment; };
72 virtual void SetAlignment(alignment align);
74 spinner_button_style ButtonStyle() const { return fButtonStyle; };
75 virtual void SetButtonStyle(spinner_button_style buttonStyle);
77 float Divider() const { return fDivider; };
78 virtual void SetDivider(float position);
80 virtual void SetEnabled(bool enable);
82 virtual void SetLabel(const char* label);
84 virtual void SetValueFromText() = 0;
86 bool IsDecrementEnabled() const;
87 virtual void SetDecrementEnabled(bool enable);
89 bool IsIncrementEnabled() const;
90 virtual void SetIncrementEnabled(bool enable);
92 virtual BSize MinSize();
93 virtual BSize MaxSize();
94 virtual BSize PreferredSize();
95 virtual BAlignment LayoutAlignment();
97 BLayoutItem* CreateLabelLayoutItem();
98 BLayoutItem* CreateTextViewLayoutItem();
100 BTextView* TextView() const;
102 private:
103 // FBC padding
104 virtual void _ReservedAbstractSpinner20();
105 virtual void _ReservedAbstractSpinner19();
106 virtual void _ReservedAbstractSpinner18();
107 virtual void _ReservedAbstractSpinner17();
108 virtual void _ReservedAbstractSpinner16();
109 virtual void _ReservedAbstractSpinner15();
110 virtual void _ReservedAbstractSpinner14();
111 virtual void _ReservedAbstractSpinner13();
112 virtual void _ReservedAbstractSpinner12();
113 virtual void _ReservedAbstractSpinner11();
114 virtual void _ReservedAbstractSpinner10();
115 virtual void _ReservedAbstractSpinner9();
116 virtual void _ReservedAbstractSpinner8();
117 virtual void _ReservedAbstractSpinner7();
118 virtual void _ReservedAbstractSpinner6();
119 virtual void _ReservedAbstractSpinner5();
120 virtual void _ReservedAbstractSpinner4();
121 virtual void _ReservedAbstractSpinner3();
122 virtual void _ReservedAbstractSpinner2();
123 virtual void _ReservedAbstractSpinner1();
125 protected:
126 virtual status_t AllArchived(BMessage* into) const;
127 virtual status_t AllUnarchived(const BMessage* from);
129 virtual void LayoutInvalidated(bool descendants);
130 virtual void DoLayout();
132 private:
133 class LabelLayoutItem;
134 class TextViewLayoutItem;
135 struct LayoutData;
137 friend class SpinnerButton;
138 friend class SpinnerTextView;
140 friend class LabelLayoutItem;
141 friend class TextViewLayoutItem;
142 friend struct LayoutData;
144 void _DrawLabel(BRect updateRect);
145 void _DrawTextView(BRect updateRect);
146 void _InitObject();
147 void _LayoutTextView();
148 void _UpdateFrame();
149 void _UpdateTextViewColors(bool enable);
150 void _ValidateLayoutData();
152 BAbstractSpinner& operator=(const BAbstractSpinner& other);
154 alignment fAlignment;
155 spinner_button_style fButtonStyle;
156 float fDivider;
158 LayoutData* fLayoutData;
160 SpinnerTextView* fTextView;
161 SpinnerButton* fIncrement;
162 SpinnerButton* fDecrement;
164 // FBC padding
165 uint32 _reserved[20];
169 #endif // _ABSTRACT_SPINNER_H