1 /*
2  * Copyright(c) 2016, OpenAV
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *     * Redistributions of source code must retain the above copyright
9  *       notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above copyright
11  *       notice, this list of conditions and the following disclaimer in
12  *       the documentation and/or other materials provided with the
13  *       distribution.
14  *     * Neither the name of the <organization> nor the
15  *       names of its contributors may be used to endorse or promote
16  *       products derived from this software without specific prior
17  *       written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OPENAV BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
26  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 
32 #ifndef OPENAV_AVTK_DIALOG_HXX
33 #define OPENAV_AVTK_DIALOG_HXX
34 
35 #include "group.hxx"
36 
37 namespace Avtk
38 {
39 
40 class Button;
41 
42 class Dialog : public Group
43 {
44 public:
45 	Dialog( Avtk::UI* ui, int x, int y, int w, int h, std::string label);
~Dialog()46 	virtual ~Dialog() {}
47 
48 	enum BUTTONS {
49 		OK = 0,
50 		OK_CANCEL,
51 	};
52 
53 	/// Optionally pass in X,Y co-ords of the mouse, and the OK/YES button will
54 	/// be positioned under the mouse cursor.
55 	void run( const char* header, const char* content, BUTTONS b = OK, int x = -1, int y = -1 );
56 
57 	virtual void draw( cairo_t* cr );
58 
59 private:
60 	BUTTONS buttons_;
61 	std::string contents;
62 
63 	int mx, my;
64 
65 	Avtk::Button* ok;
66 	Avtk::Button* cancel;
67 
68 	// internally highjack the OK / Cancel buttons events
69 	virtual void valueCB( Avtk::Widget* widget);
70 };
71 
72 };
73 
74 #endif // OPENAV_AVTK_DIALOG_HXX
75