Cleanup code
[platform/framework/web/nwrt.git] / tests / popup / popup.h
1 // Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef WRT_RUNTIME_POPUP_H_
6 #define WRT_RUNTIME_POPUP_H_
7
8 #include <Evas.h>
9 #include <Elementary.h>
10
11 #include <string>
12 #include <vector>
13 #include <functional>
14
15 namespace wrt {
16
17 class NativeWindow;
18
19 class Popup {
20  public:
21   enum class ButtonType {
22     OkButton,
23     OkCancelButton,
24     LoginCancelButton,
25     AllowDenyButton
26   };
27
28   enum class EntryType {
29     Edit,
30     PwEdit
31   };
32   // static Popup* CreatePopup(NativeWindow* window);
33   static Popup* CreatePopup(Evas_Object* window);
34
35   // button
36   void SetButtonType(ButtonType type);
37   bool IsPositiveButton(Evas_Object* button);
38   bool GetButtonResult() const;  // yes/allow/ok: true, the others: false
39
40   void SetFirstEntry(const std::string& str_id, EntryType type);
41   void SetSecondEntry(const std::string& str_id, EntryType type);
42   std::string GetFirstEntryResult() const;
43   std::string GetSecondEntryResult() const;
44
45   // check box
46   void SetCheckBox(const std::string& str_id = std::string());
47   bool GetCheckBoxResult() const;
48
49   // etc.
50   void SetTitle(const std::string& str_id);
51   void SetBody(const std::string& str_id);
52   void SetResultHandler(std::function
53       <void(Popup* popup, void* user_data)> handler, void* user_data);
54
55   // Popup's actions
56   void Show();
57   void Hide();
58   void Result(bool is_positive);
59
60   // getter
61   Evas_Object* popup() { return popup_; }
62
63  private:
64   Popup(Evas_Object* popup, Evas_Object* grid, Evas_Object* box);
65   ~Popup();
66
67   Evas_Object* popup_;
68   Evas_Object* grid_;
69   Evas_Object* box_;
70   Evas_Object* button1_;
71   Evas_Object* button2_;
72   Evas_Object* entry1_;
73   Evas_Object* entry2_;
74   Evas_Object* check_box_;
75
76   std::function<void(Popup* popup, void* user_data)> handler_;
77   void* user_data_;
78
79   bool enable_button_;
80   bool result_button_;
81   bool enable_entry_;
82   std::string result_entry1_;
83   std::string result_entry2_;
84   bool enable_check_box_;
85   bool result_check_box_;
86 };
87
88 }  // namespace wrt
89
90 #endif  // WRT_RUNTIME_POPUP_H_