1/*
2 * Copyright 2001-2006, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef	_ALERT_H
6#define	_ALERT_H
7
8
9#include <Window.h>
10
11
12class BBitmap;
13class BButton;
14class BInvoker;
15class BTextView;
16
17// enum for flavors of alert
18enum alert_type {
19	B_EMPTY_ALERT = 0,
20	B_INFO_ALERT,
21	B_IDEA_ALERT,
22	B_WARNING_ALERT,
23	B_STOP_ALERT
24};
25
26enum button_spacing {
27	B_EVEN_SPACING = 0,
28	B_OFFSET_SPACING
29};
30
31
32class BAlert : public BWindow {
33	public:
34							BAlert(const char* title, const char* text,
35								const char* button1, const char* button2 = NULL,
36								const char* button3 = NULL,
37								button_width width = B_WIDTH_AS_USUAL,
38								alert_type type = B_INFO_ALERT);
39							BAlert(const char *title, const char *text,
40								const char *button1, const char *button2,
41								const char *button3, button_width width,
42								button_spacing spacing,
43								alert_type type = B_INFO_ALERT);
44		virtual				~BAlert();
45
46		// Archiving
47							BAlert(BMessage *data);
48		static	BArchivable	*Instantiate(BMessage *data);
49		virtual	status_t	Archive(BMessage *data, bool deep = true) const;
50
51		// BAlert guts
52				void		SetShortcut(int32 button_index, char key);
53				char		Shortcut(int32 button_index) const;
54
55				int32		Go();
56				status_t	Go(BInvoker *invoker);
57
58		virtual	void		MessageReceived(BMessage *an_event);
59		virtual	void		FrameResized(float new_width, float new_height);
60				BButton*	ButtonAt(int32 index) const;
61				BTextView*	TextView() const;
62
63		virtual BHandler*	ResolveSpecifier(BMessage* message, int32 index,
64								BMessage* specifier, int32 form,
65								const char* property);
66		virtual	status_t	GetSupportedSuites(BMessage *data);
67
68		virtual void		DispatchMessage(BMessage* message, BHandler* handler);
69		virtual	void		Quit();
70		virtual	bool		QuitRequested();
71
72		static	BPoint		AlertPosition(float width, float height);
73
74		virtual status_t	Perform(perform_code d, void *arg);
75
76	private:
77		friend class _BAlertFilter_;
78
79		virtual	void		_ReservedAlert1();
80		virtual	void		_ReservedAlert2();
81		virtual	void		_ReservedAlert3();
82
83				void		_InitObject(const char* text, const char* button1,
84								const char* button2 = NULL,
85								const char* button3 = NULL,
86								button_width width = B_WIDTH_AS_USUAL,
87								button_spacing spacing = B_EVEN_SPACING,
88								alert_type type = B_INFO_ALERT);
89				BBitmap*	_InitIcon();
90				BButton*	_CreateButton(int32 which, const char* label);
91
92		sem_id				fAlertSem;
93		int32				fAlertValue;
94		BButton*			fButtons[3];
95		BTextView*			fTextView;
96		char				fKeys[3];
97		alert_type			fMsgType;
98		button_width		fButtonWidth;
99		BInvoker*			fInvoker;
100		uint32				_reserved[4];
101};
102
103#endif	// _ALERT_H
104