xref: /haiku/headers/os/interface/TextControl.h (revision 4f00613311d0bd6b70fa82ce19931c41f071ea4e)
1 //------------------------------------------------------------------------------
2 //	Copyright (c) 2001-2002, OpenBeOS
3 //
4 //	Permission is hereby granted, free of charge, to any person obtaining a
5 //	copy of this software and associated documentation files (the "Software"),
6 //	to deal in the Software without restriction, including without limitation
7 //	the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 //	and/or sell copies of the Software, and to permit persons to whom the
9 //	Software is furnished to do so, subject to the following conditions:
10 //
11 //	The above copyright notice and this permission notice shall be included in
12 //	all copies or substantial portions of the Software.
13 //
14 //	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 //	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 //	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 //	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 //	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 //	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 //	DEALINGS IN THE SOFTWARE.
21 //
22 //	File Name:		TextControl.cpp
23 //	Author:			Frans van Nispen (xlr8@tref.nl)
24 //	Description:	BTextControl displays text that can act like a control.
25 //------------------------------------------------------------------------------
26 
27 #ifndef	_TEXT_CONTROL_H
28 #define	_TEXT_CONTROL_H
29 
30 // Standard Includes -----------------------------------------------------------
31 
32 // System Includes -------------------------------------------------------------
33 #include <BeBuild.h>
34 #include <Control.h>
35 #include <TextView.h>		/* For convenience */
36 
37 // Project Includes ------------------------------------------------------------
38 
39 // Local Includes --------------------------------------------------------------
40 
41 // Local Defines ---------------------------------------------------------------
42 
43 // Globals ---------------------------------------------------------------------
44 
45 class _BTextInput_;
46 
47 // BTextControl class ----------------------------------------------------------
48 class BTextControl : public BControl {
49 
50 public:
51 						BTextControl(BRect frame,
52 									const char *name,
53 									const char *label,
54 									const char *initial_text,
55 									BMessage *message,
56 									uint32 rmask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
57 									uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
58 virtual					~BTextControl();
59 
60 						BTextControl(BMessage *data);
61 static	BArchivable		*Instantiate(BMessage *data);
62 virtual	status_t		Archive(BMessage *data, bool deep = true) const;
63 
64 virtual	void			SetText(const char *text);
65 		const char		*Text() const;
66 
67 virtual	void			SetValue(int32 value);
68 virtual	status_t		Invoke(BMessage *msg = NULL);
69 
70 		BTextView		*TextView() const;
71 
72 virtual	void			SetModificationMessage(BMessage *message);
73 		BMessage		*ModificationMessage() const;
74 
75 virtual	void			SetAlignment(alignment label, alignment text);
76 		void			GetAlignment(alignment *label, alignment *text) const;
77 virtual	void			SetDivider(float dividing_line);
78 		float			Divider() const;
79 
80 virtual	void			Draw(BRect updateRect);
81 virtual	void			MouseDown(BPoint where);
82 virtual	void			AttachedToWindow();
83 virtual	void			MakeFocus(bool focusState = true);
84 virtual	void			SetEnabled(bool state);
85 virtual	void			FrameMoved(BPoint new_position);
86 virtual	void			FrameResized(float new_width, float new_height);
87 virtual	void			WindowActivated(bool active);
88 
89 virtual	void			GetPreferredSize(float *width, float *height);
90 virtual	void			ResizeToPreferred();
91 
92 virtual void			MessageReceived(BMessage *msg);
93 virtual BHandler		*ResolveSpecifier(BMessage *msg,
94 										int32 index,
95 										BMessage *specifier,
96 										int32 form,
97 										const char *property);
98 
99 virtual	void			MouseUp(BPoint pt);
100 virtual	void			MouseMoved(BPoint pt, uint32 code, const BMessage *msg);
101 virtual	void			DetachedFromWindow();
102 
103 virtual void			AllAttached();
104 virtual void			AllDetached();
105 virtual status_t		GetSupportedSuites(BMessage *data);
106 virtual void			SetFlags(uint32 flags);
107 
108 
109 /*----- Private or reserved -----------------------------------------*/
110 virtual status_t		Perform(perform_code d, void *arg);
111 
112 private:
113 friend	class _BTextInput_;
114 
115 virtual	void			_ReservedTextControl1();
116 virtual	void			_ReservedTextControl2();
117 virtual	void			_ReservedTextControl3();
118 virtual	void			_ReservedTextControl4();
119 
120 		BTextControl	&operator=(const BTextControl &);
121 
122 		void			CommitValue();
123 		void			InitData(const char *label,
124 								const char *initial_text,
125 								BMessage *data = NULL);
126 
127 		_BTextInput_	*fText;
128 		char			*fLabel;
129 		BMessage		*fModificationMessage;
130 		alignment		fLabelAlign;
131 		float			fDivider;
132 		uint16			fPrevWidth;
133 		uint16			fPrevHeight;
134 		uint32			_reserved[3];	/* was 4 */
135 #if !_PR3_COMPATIBLE_
136 		uint32			_more_reserved[4];
137 #endif
138 
139 		bool			fClean;
140 		bool			fSkipSetFlags;
141 		bool			fUnusedBool1;
142 		bool			fUnusedBool2;
143 };
144 //------------------------------------------------------------------------------
145 
146 #endif // _TEXT_CONTROL_H
147 
148 /*
149  * $Log $
150  *
151  * $Id  $
152  *
153  */
154